using System; using System.Collections.Generic; using System.Windows.Forms; using System.IO; using System.Text; using System.Linq; using HydrEngineCSharp; namespace DPumpHydr.WinFrmUI.Volute { public partial class MainViewPage { ctrlSetOutflowParas _ctrlSetOutflowParas = null; ViewModel.OutflowParas _outflowParas = null; /// /// /// /// private bool SaveParaStep3() { return true; } /// /// /// /// private void EnterStep3(long last_step_id) { if (_sectionBundleInfo == null) return; CreateOutflowStepCtrl(); this._occDesign2dCtrl.SetAllSectionCurveVisible(false); this._occDesign3dCtrl.SetAllSectionCurveVisible(RbtnChk截面18.Checked); if (last_step_id >= this._stepTreeDockPanel.Step_ID_Thickness) { this._occDesign3dCtrl.setWaterBodyOpacity( DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.R, DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.G, DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.B, 256); this._occDesign3dCtrl.SetThicknessBodyVisible(false); } else { InitilOutflowStepCtrl(last_step_id); } this._sectAreaDockPanel.RefreshControl(); this._sectAreaDockPanel.Visible = true; DockStepParaCtrl(_ctrlSetOutflowParas); } /// /// /// /// private void InitilOutflowStepCtrl(long last_step_id) { var ret = _ctrlSetOutflowParas.InitialParas(_hdrBaseInfo, _geomBaseInfo, _sectionBundleInfo); if(ret == 0 && _outflowParas != null) {//基础参数没有任何变化 RefreshWaterBody3D(_outflowParas); // this._occDesign3dCtrl.setWaterBodyOpacity( //DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.R, //DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.G, //DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.B, 256); // this._occDesign3dCtrl.SetWaterBodyVisible(true); // this._occDesign3dCtrl.SetThicknessBodyVisible(false); } else if(ret == 1) { _ctrlSetOutflowParas.SetSect9Posi(_sect9Posi); _ctrlSetOutflowParas.SetSect10Posi(_sect10Posi); DPumpHydr.ViewModel.eWizardStepDiretion step_direction = DPumpHydr.ViewModel.eWizardStepDiretion.前进; if (last_step_id > this._stepTreeDockPanel.Step_ID_Outflow_Paras) step_direction = DPumpHydr.ViewModel.eWizardStepDiretion.后退; _ctrlSetOutflowParas.ShowPage(step_direction); string error = ""; _outflowParas = _ctrlSetOutflowParas.GetBindingData(out error); this._occDesign3dCtrl.setWaterBodyOpacity( DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.R, DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.G, DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.B, 256); this._occDesign3dCtrl.SetThicknessBodyVisible(false); } } /// /// /// private void CreateOutflowStepCtrl() { if (_ctrlSetOutflowParas != null) return; _ctrlSetOutflowParas = new ctrlSetOutflowParas(); _ctrlSetOutflowParas.Name = "ctrlSetOutflowStyle"; _ctrlSetOutflowParas.OnRefreshShape2D += RefreshWaterBody2D; _ctrlSetOutflowParas.OnRefreshShape3D += RefreshWaterBody3D; _ctrlSetOutflowParas.OnNextStep += () => { GoNextStep(); }; _ctrlSetOutflowParas.OnMoveSectPosi += (sect_index, posi) => { if (sect_index == 9) { _sect9Posi = posi; var SectArea9 = this._occDesign3dCtrl.GetSectArea9(_sect9Posi); this._sectAreaDockPanel.SetArea9(SectArea9); } if (sect_index == 10) { _sect10Posi = posi; var SectArea10 = this._occDesign3dCtrl.GetSectArea10(_sect10Posi); this._sectAreaDockPanel.SetArea10(SectArea10); } }; } private bool _isHaveCreateWaterBody3d = false; HydrEngineCSharp.WaterBodyOuterParam m_theWaterBodyOuterParam; private void RefreshOuterParam(DPumpHydr.WinFrmUI.Volute.ViewModel.OutflowParas outflowParas) { double dOuterRad = outflowParas.Dia * 0.5; double dOuterHigh = outflowParas.Heigh; double dOuterOffset = outflowParas.Offset; double dH1 = outflowParas.H1; double dH2 = outflowParas.H2; double dTopValue1 = outflowParas.Tangent_Top_Left; double dBtmValue1 = outflowParas.Tangent_Btm_Left; double dTopValue2 = outflowParas.Tangent_Top_Right; double dBtmValue2 = outflowParas.Tangent_Btm_Right; double dRadConner = outflowParas.Septalradius; double dRadConnerAngle = this._geomBaseInfo.FAI0; double R1 = outflowParas.R1; double R2 = outflowParas.R2; dRadConnerAngle = dRadConnerAngle * HydrDisplayEngineBridge.PI / 180.0; if (outflowParas.LinkStyle == ViewModel.eOutflowLinkStyle.直线圆弧 && outflowParas.ShapeStyle != ViewModel.eOutflowShapeStyle.侧面出口_直线连接) { if (m_theWaterBodyOuterParam == null || !(m_theWaterBodyOuterParam is HydrEngineCSharp.WaterBodyOuterArcParam)) m_theWaterBodyOuterParam = HydrDisplayEngineBridge.CreateWaterBodyOuter(WaterBodyOuterType.EWaterBodyOuterArc); } else { if (m_theWaterBodyOuterParam == null || !(m_theWaterBodyOuterParam is HydrEngineCSharp.WaterBodyOuterSpParam)) m_theWaterBodyOuterParam = HydrDisplayEngineBridge.CreateWaterBodyOuter(WaterBodyOuterType.EWaterBodyOuterSp); } // HydrEngineCSharp.WaterBodyOuterArcParam pHydrGeomCurve = m_theWaterBodyOuterParam as HydrEngineCSharp.WaterBodyOuterArcParam; if (outflowParas.LinkStyle == ViewModel.eOutflowLinkStyle.直线圆弧 && outflowParas.ShapeStyle != ViewModel.eOutflowShapeStyle.侧面出口_直线连接) { HydrEngineCSharp.WaterBodyOuterArcParam pHydrGeomCurveArc = m_theWaterBodyOuterParam as HydrEngineCSharp.WaterBodyOuterArcParam; pHydrGeomCurveArc.SetOuterOffset(dOuterOffset); pHydrGeomCurveArc.SetOuterHigh(dOuterHigh); pHydrGeomCurveArc.SetOuterRad(dOuterRad); pHydrGeomCurveArc.SetH1(dH1); pHydrGeomCurveArc.SetH2(dH2); pHydrGeomCurveArc.SetRadConner(dRadConner); pHydrGeomCurveArc.SetRadConnerAngle(dRadConnerAngle); pHydrGeomCurveArc.SetR1(R1); pHydrGeomCurveArc.SetR2(R2); } else { HydrEngineCSharp.WaterBodyOuterSpParam pHydrGeomCurve = m_theWaterBodyOuterParam as HydrEngineCSharp.WaterBodyOuterSpParam; pHydrGeomCurve.SetOuterOffset(dOuterOffset); pHydrGeomCurve.SetOuterHigh(dOuterHigh); pHydrGeomCurve.SetOuterRad(dOuterRad); pHydrGeomCurve.SetH1(dH1); pHydrGeomCurve.SetH2(dH2); pHydrGeomCurve.SetRadConner(dRadConner); pHydrGeomCurve.SetRadConnerAngle(dRadConnerAngle); pHydrGeomCurve.SetTopValue1(dTopValue1); pHydrGeomCurve.SetBtmValue1(dBtmValue1); pHydrGeomCurve.SetTopValue2(dTopValue2); pHydrGeomCurve.SetBtmValue2(dBtmValue2); } } private bool RefreshWaterBody2D(DPumpHydr.WinFrmUI.Volute.ViewModel.OutflowParas outflowParas) { if (outflowParas == null) return false; if (outflowParas.LinkStyle != ViewModel.eOutflowLinkStyle.直线圆弧 || outflowParas.ShapeStyle == ViewModel.eOutflowShapeStyle.侧面出口_直线连接) { if (outflowParas.Tangent_Top_Right <= 0 || outflowParas.Tangent_Btm_Right <= 0 || outflowParas.Tangent_Top_Left <= 0 || outflowParas.Tangent_Btm_Left <= 0) return false; } if (outflowParas.LinkStyle == ViewModel.eOutflowLinkStyle.直线圆弧 && outflowParas.ShapeStyle != ViewModel.eOutflowShapeStyle.侧面出口_直线连接) { if (outflowParas.R1 <= 0 || outflowParas.R2 <= 0) return false; } RefreshOuterParam(outflowParas); //WaterBodyOuterParam if (outflowParas.LinkStyle == ViewModel.eOutflowLinkStyle.直线圆弧 && outflowParas.ShapeStyle != ViewModel.eOutflowShapeStyle.侧面出口_直线连接) { HydrEngineCSharp.WaterBodyOuterArcParam pHydrGeomCurveArc = m_theWaterBodyOuterParam as HydrEngineCSharp.WaterBodyOuterArcParam; this._occDesign2dCtrl.Create2DWaterBody(pHydrGeomCurveArc); } else { HydrEngineCSharp.WaterBodyOuterSpParam pHydrGeomCurve = m_theWaterBodyOuterParam as HydrEngineCSharp.WaterBodyOuterSpParam; this._occDesign2dCtrl.Create2DWaterBody(pHydrGeomCurve); } //if (_isHaveCreateWaterBody2d == true) //{ // this._occDesign2dCtrl.Create2DWaterBody(pHydrGeomCurve); //} return true; } private ViewModel.OutflowParasCalcReponse RefreshWaterBody3D(DPumpHydr.WinFrmUI.Volute.ViewModel.OutflowParas outflowParas) { if (outflowParas == null || outflowParas.Tangent_Top_Right <= 0 || outflowParas.Tangent_Btm_Right <= 0 || outflowParas.Tangent_Top_Left <= 0 || outflowParas.Tangent_Btm_Left <= 0) return null; double start_angle = OutflowStyleHelper.GetSectStartAngle(outflowParas.ShapeStyle); if (Math.Abs(_occDesign2dCtrl.SectStartAngle - start_angle) > 0.01) { this._occDesign2dCtrl.SectStartAngle = start_angle; this._occDesign2dCtrl.ClearAll(); this._occDesign2dCtrl.RefreshAllSectShape18(this._sectionBundleInfo); this._occDesign2dCtrl.HideSectCurve18(); this._occDesign2dCtrl.SetAllSectionCurveVisible(false); _isHaveCreateWaterBody3d = false; this._occDesign3dCtrl.SectStartAngle = start_angle; this._occDesign3dCtrl.ClearAll(); this._occDesign3dCtrl.RefreshAllSectShape18(this._sectionBundleInfo); this._occDesign3dCtrl.SetAllSectionCurveVisible(RbtnChk截面18.Checked); this._sectAreaDockPanel.SetArea18(_sectionBundleInfo); } this._sectAreaDockPanel.SetAreaOutletDia(outflowParas.Dia); this._outflowParas = outflowParas; RefreshOuterParam(outflowParas); HydrEngineCSharp.WaterBodyOuterArcParam pHydrGeomArcCurve = m_theWaterBodyOuterParam as HydrEngineCSharp.WaterBodyOuterArcParam; HydrEngineCSharp.WaterBodyOuterSpParam pHydrGeomCurve = m_theWaterBodyOuterParam as HydrEngineCSharp.WaterBodyOuterSpParam; try { if (_isHaveCreateWaterBody3d == true) { if(_outflowParas.LinkStyle == ViewModel.eOutflowLinkStyle.直线圆弧 && _outflowParas.ShapeStyle != ViewModel.eOutflowShapeStyle.侧面出口_直线连接) { this._occDesign2dCtrl.Create2DWaterBody(pHydrGeomArcCurve); this._occDesign3dCtrl.Edit3DWaterBody(pHydrGeomArcCurve); this._occDesign3dCtrl.SetWaterBodyVisible(true); } else { this._occDesign2dCtrl.Create2DWaterBody(pHydrGeomCurve); this._occDesign3dCtrl.Edit3DWaterBody(pHydrGeomCurve); this._occDesign3dCtrl.SetWaterBodyVisible(true); } } else { _isHaveCreateWaterBody3d = true; if (_outflowParas.LinkStyle == ViewModel.eOutflowLinkStyle.直线圆弧 && _outflowParas.ShapeStyle != ViewModel.eOutflowShapeStyle.侧面出口_直线连接) { this._occDesign2dCtrl.Create2DWaterBody(pHydrGeomArcCurve); this._occDesign3dCtrl.Create3DWaterBody(pHydrGeomArcCurve); this._occDesign3dCtrl.SetWaterBodyVisible(true); } else { this._occDesign2dCtrl.Create2DWaterBody(pHydrGeomCurve); this._occDesign3dCtrl.Create3DWaterBody(pHydrGeomCurve); this._occDesign3dCtrl.SetWaterBodyVisible(true); } } return BuildRefreshWaterBodyReponse(); } catch { DialogResult result = MessageBox.Show("创建失败,请问是否保存当前参数", "询问", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ExportXmlFile(); } return null; } } private double _sect9Posi = 0.25; private double _sect10Posi = 0.65; private ViewModel.OutflowParasCalcReponse BuildRefreshWaterBodyReponse() { ViewModel.OutflowParasCalcReponse rep = new ViewModel.OutflowParasCalcReponse(); rep.IsSuccess = true; rep.SectArea9 = this._occDesign3dCtrl.GetSectArea9(_sect9Posi); rep.SectArea10 = this._occDesign3dCtrl.GetSectArea10(_sect10Posi); this._sectAreaDockPanel.SetArea9(rep.SectArea9); this._sectAreaDockPanel.SetArea10(rep.SectArea10); return rep; } } }