From 75263eb2d74528acf0086ddf2d8eab89fcecd8fb Mon Sep 17 00:00:00 2001 From: chenn <gu.beic@qq.com> Date: 星期四, 27 三月 2025 18:31:57 +0800 Subject: [PATCH] 直线圆弧修改 --- WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/OccDesignBaseCtrl.cs | 510 +++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 339 insertions(+), 171 deletions(-) diff --git a/WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/OccDesignBaseCtrl.cs b/WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/OccDesignBaseCtrl.cs index d2b9f74..1a99f0e 100644 --- a/WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/OccDesignBaseCtrl.cs +++ b/WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/OccDesignBaseCtrl.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; -using System.Windows.Forms; +using System.Reflection.Metadata; +using System.Windows.Forms; +using DPumpHydr.WinFrmUI.Volute.ViewModel; using HydrEngineCSharp; namespace DPumpHydr.WinFrmUI.Volute @@ -8,35 +10,17 @@ public partial class OccDesignBaseCtrl : UserControl { protected HydrEngineCSharp.CDisplayView pDisplayView; - protected string strTurbopumpTopoShapeName = "蜗壳设计x"; - - + + public OccDesignBaseCtrl() { - InitializeComponent(); - - //this.DefaultDockArea = RLT.Enum.Crown.DockArea.Document; - //this._isDispCloseIcon = false ;//不能关闭 - - + //InitializeComponent(); this.MouseDown += OnMouseDown; this.MouseMove += OnMouseMove; this.MouseUp += OnMouseUp; this.MouseWheel += OnMouseWheel; - - - //string strTurbopumpTopoShapeName = "蜗壳设计" + (m_nNum++).ToString(); - //bool bSucc = pDisplayView.addTurbopumpTopoShape(strTurbopumpTopoShapeName); - //if (bSucc) - //{ - // m_nCreateCurve = 1; - // //MessageBox.Show("开始蜗壳设计"); - //} - - - } @@ -148,14 +132,10 @@ } protected bool _is3D = true; - - public void ClearAll() + + + public virtual void Initial() { - //pDisplayView.DeleteObject(strTurbopumpTopoShapeName); - //pDisplayView.addTurbopumpTopoShape(strTurbopumpTopoShapeName); - } - public virtual void Initial( ) - { } #region 1-8 截面设计 @@ -165,40 +145,63 @@ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> - public void RefreshAllSectShape18(ViewModel.SectionBundleInfo bundle) + public List<int> RefreshAllSectShape18(ViewModel.SectionBundleInfo bundle) { if (_isFirstSectShape18) { - CreateSectShape18(bundle); + _isFirstSectShape18 = false; + return CreateSectShape18(bundle); } else { - EditSectShape18(bundle); - } - _isFirstSectShape18 = false; + return EditSectShape18(bundle); + } } - protected void CreateSectShape18(ViewModel.SectionBundleInfo bundle) + protected double _sectStartAngle = -HydrDisplayEngineBridge.PI_4; + public double SectStartAngle { - //pDisplayView.Update3DViews(_is3D); + get + { + return _sectStartAngle; + } + set + { + _sectStartAngle = value; + } + } - double dStartAngle = -HydrDisplayEngineBridge.PI_4; + /// <summary> + /// + /// </summary> + /// <param name="bundle"></param> + protected List<int> CreateSectShape18(ViewModel.SectionBundleInfo bundle) + { + List<int> error_sect = new List<int>(); - double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8; - for (int i = 8; i >=1; i--) + + double dStartAngle = _sectStartAngle; + + double dDetAngle = HydrDisplayEngineBridge.PI / 4; + for (int i = 8; i >= 1; i--) { var theSectionParam = bundle.ToSectionShapePara(i); - double dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth, dBaseCircleRadius; + double dGama_Left, dGama_Right, dH, dR_out, dBaseWidth, dBaseCircleRadius; dGama_Left = theSectionParam.Gama_Left; dGama_Right = theSectionParam.Gama_Right; dH = theSectionParam.H; dR_out = theSectionParam.R_out; - dR_Left = theSectionParam.R_Left; - dR_Right = theSectionParam.R_Right; + double dR_Left = theSectionParam.R_Left; + double dR_Right = theSectionParam.R_Right; + if (dR_Left < 1) + dR_Left = 1; + if (dR_Right < 1) + dR_Right = 1; + dBaseWidth = theSectionParam.BaseWidth; dBaseCircleRadius = theSectionParam.BaseCircleRadius; - string wstrShapeNameI = string.Format("SectShape_{0}", theSectionParam.Index); + HydrProperties theHydrProperties = new HydrProperties(); @@ -210,94 +213,107 @@ } - - theHydrProperties.SetShapeName(wstrShapeNameI); + double dAngle = (8 - theSectionParam.Index) * dDetAngle + dStartAngle; + theHydrProperties.SetShapeGuid(GlobalParas.BuildSectShapeName(theSectionParam.Index)); pHydrGeomCurve.SetHydrProperties(theHydrProperties); - pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth, dBaseCircleRadius); - //if (_is3D) + pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth); + pHydrGeomCurve.SetMatrix(dAngle, dBaseCircleRadius); + + + ToolTips tt = pDisplayView.addVoluteCurve(theSectionParam.Index, pHydrGeomCurve); + if (tt == null || tt.GetTipsId() != 1) { - double dAngle = ( 8 - theSectionParam.Index ) * dDetAngle + dStartAngle; - BcGeMatrix theMatrix = BcGeMatrix.translate(0, dBaseCircleRadius, 0); - BcGeMatrix theMatrix1 = BcGeMatrix.rotate(-dAngle, 1.0, 0.0, 0.0); - theMatrix.postMult(theMatrix1); - pHydrGeomCurve.SetMatrix(theMatrix); + error_sect.Add(theSectionParam.Index); } - - pDisplayView.addVoluteCurve( theSectionParam.Index, pHydrGeomCurve); - } - - - - Invalidate(true); - pDisplayView.FitAll3DViews(true); - - } - - - - protected void EditSectShape18(ViewModel.SectionBundleInfo bundle) - { - pDisplayView.Update3DViews(_is3D); - - double dStartAngle = -HydrDisplayEngineBridge.PI_4; - - double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8; - for (int i = 1; i <= 8; i++) - { - var theSectionParam = bundle.ToSectionShapePara(i); - - double dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth, dBaseCircleRadius; - dGama_Left = theSectionParam.Gama_Left; - dGama_Right = theSectionParam.Gama_Right; - dH = theSectionParam.H; - dR_out = theSectionParam.R_out; - dR_Left = theSectionParam.R_Left; - dR_Right = theSectionParam.R_Right; - dBaseWidth = theSectionParam.BaseWidth; - dBaseCircleRadius = theSectionParam.BaseCircleRadius; - - string wstrShapeNameI = string.Format("SectShape_{0}", theSectionParam.Index); - - - HydrProperties theHydrProperties = new HydrProperties(); - HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomSection); - HydrGeomSection pHydrGeomCurve = theHydrGeomCurve as HydrGeomSection; - if (pHydrGeomCurve == null) - { - continue; - } - - - - theHydrProperties.SetShapeName(wstrShapeNameI); - pHydrGeomCurve.SetHydrProperties(theHydrProperties); - pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth, dBaseCircleRadius); - //if (_is3D) - { - double dAngle = (8 - theSectionParam.Index) * dDetAngle + dStartAngle; - BcGeMatrix theMatrix = BcGeMatrix.translate(0, dBaseCircleRadius, 0); - BcGeMatrix theMatrix1 = BcGeMatrix.rotate(-dAngle, 1.0, 0.0, 0.0); - theMatrix.postMult(theMatrix1); - pHydrGeomCurve.SetMatrix(theMatrix); - } - - pDisplayView.editVoluteCurve(wstrShapeNameI, pHydrGeomCurve); } Invalidate(true); - - + pDisplayView.FitAll3DViews(true); + return error_sect; } - + + /// <summary> + /// + /// </summary> + /// <param name="bundle"></param> + public List<int> EditSectShape18(ViewModel.SectionBundleInfo bundle) + { + List<int> error_sect = new List<int>(); + + double dStartAngle = _sectStartAngle; + + double dDetAngle = HydrDisplayEngineBridge.PI / 4; + for (int i = 1; i <= 8; i++) + { + var theSectionParam = bundle.ToSectionShapePara(i); + + double dGama_Left, dGama_Right, dH, dR_out, dBaseWidth, dBaseCircleRadius; + dGama_Left = theSectionParam.Gama_Left; + dGama_Right = theSectionParam.Gama_Right; + dH = theSectionParam.H; + dR_out = theSectionParam.R_out; + double dR_Left = theSectionParam.R_Left; + double dR_Right = theSectionParam.R_Right; + dBaseWidth = theSectionParam.BaseWidth; + dBaseCircleRadius = theSectionParam.BaseCircleRadius; + if (dR_Left < 1) + dR_Left = 1; + if (dR_Right < 1) + dR_Right = 1; + + string wstrShapeNameI = string.Format("SectShape_{0}", theSectionParam.Index); + + + HydrProperties theHydrProperties = new HydrProperties(); + HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomSection); + HydrGeomSection pHydrGeomCurve = theHydrGeomCurve as HydrGeomSection; + if (pHydrGeomCurve == null) + { + continue; + } + double dAngle = (8 - theSectionParam.Index) * dDetAngle + dStartAngle; + + + //theHydrProperties.SetShapeName(wstrShapeNameI); + pHydrGeomCurve.SetHydrProperties(theHydrProperties); + pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth); + pHydrGeomCurve.SetMatrix(dAngle, dBaseCircleRadius); + //if (_is3D) + //{ + // BcGeMatrix theMatrix = BcGeMatrix.translate(0, dBaseCircleRadius, 0); + // BcGeMatrix theMatrix1 = BcGeMatrix.rotate(-dAngle, 1.0, 0.0, 0.0); + // theMatrix.postMult(theMatrix1); + // pHydrGeomCurve.SetMatrix(theMatrix); + //} + + ToolTips tt = pDisplayView.editVoluteCurve(wstrShapeNameI, pHydrGeomCurve); + //pDisplayView.addVoluteCurve(theSectionParam.Index, pHydrGeomCurve); + if (tt == null || tt.GetTipsId() != 1) + { + error_sect.Add(theSectionParam.Index); + } + } + + + + Invalidate(true); + pDisplayView.ShowTopoShape(TopoTypeDisplay.ESectionCurve); + return error_sect; + } + + /// <summary> + /// + /// </summary> + /// <param name="theSectionParam"></param> public void RefreshSingleSectShape18(ViewModel.SectionShapePara theSectionParam) { - pDisplayView.Update3DViews(true ); + pDisplayView.Update3DViews(true); - double dStartAngle = -HydrDisplayEngineBridge.PI_4; + double dStartAngle = _sectStartAngle; - double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8; + double dDetAngle = HydrDisplayEngineBridge.PI / 4; double dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth, dBaseCircleRadius; @@ -310,8 +326,6 @@ dBaseWidth = theSectionParam.BaseWidth; dBaseCircleRadius = theSectionParam.BaseCircleRadius; - string wstrShapeNameI = string.Format("SectShape_{0}", theSectionParam.Index); - HydrProperties theHydrProperties = new HydrProperties(); HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomSection); @@ -321,90 +335,244 @@ return; } + double dAngle = (8 - theSectionParam.Index) * dDetAngle + dStartAngle; - - theHydrProperties.SetShapeName(wstrShapeNameI); + theHydrProperties.SetShapeGuid(GlobalParas.BuildSectShapeName(theSectionParam.Index)); pHydrGeomCurve.SetHydrProperties(theHydrProperties); - pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth, dBaseCircleRadius); - //if (_is3D) - { - double dAngle = (8 - theSectionParam.Index) * dDetAngle + dStartAngle; - BcGeMatrix theMatrix = BcGeMatrix.translate(0, dBaseCircleRadius, 0); - BcGeMatrix theMatrix1 = BcGeMatrix.rotate(-dAngle, 1.0, 0.0, 0.0); - theMatrix.postMult(theMatrix1); - pHydrGeomCurve.SetMatrix(theMatrix); - } + pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth); + pHydrGeomCurve.SetMatrix(dAngle, dBaseCircleRadius); - pDisplayView.editVoluteCurve(wstrShapeNameI, pHydrGeomCurve); - + pDisplayView.editVoluteCurve(GlobalParas.BuildSectShapeName(theSectionParam.Index), pHydrGeomCurve); - Invalidate(true); + + Invalidate(true); } + /// <summary> + /// + /// </summary> + /// <param name="isVisible"></param> + public void SetAllSectionCurveVisible(bool isVisible) + { + for (int i = 8; i >= 1; i--) + { + string wstrShapeNameI = string.Format("SectShape_{0}", i); + if (isVisible) + pDisplayView.showVoluteCurve(wstrShapeNameI); + else + pDisplayView.hideVoluteCurve(wstrShapeNameI); + } + } + /// <summary> + /// + /// </summary> + /// <param name="sectIndex"></param> + public void HightLightSectCurve(int sectIndex) + { + for (int i = 1; i <= 8; i++) + { + if (i == sectIndex) + this.pDisplayView.setVoluteCurveClr(i, 255, 20, 147); + else + this.pDisplayView.setVoluteCurveClr(i, 75, 0, 130); + } - - + Invalidate(true); + } #endregion - protected double theRad = 70.0; - protected double theHigh = 300.0; - protected double theOffset = 0.0; - protected double m_dTopValue = 1.0; - protected double m_dBtmValue = 1.0; - protected string ShapeNameOutflowBody = "OutflowBody"; - protected double dAngle = 70; - - protected double m_dMPlnBasePtScaleValue = 2.0; - protected double m_dMPlnOuterPtScaleValue = 2.0; - - public HydrGeomSplineParam Create2DWaterBody(WaterBodyOuterParam theWaterBodyOuterParam) + + #region 水体 + + public bool Create2DWaterBody(HydrEngineCSharp.WaterBodyOuterArcParam pHydrGeomArcCurve) { if (this._is3D) - return null; - - bool bSucc = pDisplayView.build2DMidCurve(theWaterBodyOuterParam); + return false; + + + + + ToolTips theToolTips = this.pDisplayView.build2DMidCurve(pHydrGeomArcCurve); + if (theToolTips == null) + return false; Invalidate(true); pDisplayView.FitAll3DViews(true); - if (bSucc) + + pDisplayView.set2DMidCurveClr( + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBoudaryColor.R, + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBoudaryColor.G, + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBoudaryColor.B); + + if (theToolTips.GetTipsId() == 1) { - return pDisplayView.getHydrGeomSplineParam(); + return true; } else { + MessageBox.Show(theToolTips.GetToolTips(), "提示"); + return false; + } + } + public bool Create2DWaterBody(HydrEngineCSharp.WaterBodyOuterSpParam pHydrGeomCurve) + { + if (this._is3D) + return false ; + + + + + ToolTips theToolTips = this.pDisplayView.build2DMidCurve(pHydrGeomCurve); + if (theToolTips == null) + return false ; + Invalidate(true); + pDisplayView.FitAll3DViews(true); + + pDisplayView.set2DMidCurveClr( + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBoudaryColor.R, + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBoudaryColor.G, + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBoudaryColor.B); + + if (theToolTips.GetTipsId() == 1) + { + return true ; + } + else + { + MessageBox.Show(theToolTips.GetToolTips(), "提示"); + return false ; + } + } + + public HydrEngineCSharp.ToolTips Create3DWaterBody(HydrEngineCSharp.WaterBodyOuterSpParam pHydrGeomCurve) + { + if (!this._is3D) return null; + + HydrProperties theHydrProperties = new HydrProperties(); + theHydrProperties.SetShapeGuid(DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyShapeName); + theHydrProperties.SetShapeColor( + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.R, + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.G, + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.B, 256); + + if (pDisplayView.hasBuildThicknessBody()) + pDisplayView.ClearTopoShape(TopoTypeDisplay.EThicknessBody); + var tt = pDisplayView.buildWaterBody(theHydrProperties, pHydrGeomCurve); + if (tt.GetTipsId() != 1) + { } + Invalidate(true); + pDisplayView.FitAll3DViews(true); + return tt; } - public void Create3DWaterBody(WaterBodyOuterParam theWaterBodyOuterParam, HydrGeomSplineParam theHydrGeomSplineParam) + public HydrEngineCSharp.ToolTips Create3DWaterBody(HydrEngineCSharp.WaterBodyOuterArcParam pHydrGeomArcCurve) { if (!this._is3D) - return; + return null; + HydrProperties theHydrProperties = new HydrProperties(); + theHydrProperties.SetShapeGuid(DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyShapeName); + theHydrProperties.SetShapeColor( + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.R, + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.G, + DPumpHydr.WinFrmUI.Volute.GlobalParas.WaterBodyColor.B, 256); + + if (pDisplayView.hasBuildThicknessBody()) + pDisplayView.ClearTopoShape(TopoTypeDisplay.EThicknessBody); + var tt = pDisplayView.buildWaterBody(theHydrProperties, pHydrGeomArcCurve); + if (tt.GetTipsId() != 1) { - string wstrName = "水体"; - string wstrShapeNameI = wstrName; - HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomCircle); - HydrProperties theHydrProperties = new HydrProperties(); - theHydrProperties.SetShapeName(wstrShapeNameI); - theHydrGeomCurve.SetHydrProperties(theHydrProperties); - if (pDisplayView.hasBuildThicknessBody()) - pDisplayView.removeThicknessBody();// - pDisplayView.buildWaterBody(wstrShapeNameI, theHydrGeomSplineParam, theWaterBodyOuterParam); - Invalidate(true); - pDisplayView.FitAll3DViews(true); } + Invalidate(true); + pDisplayView.FitAll3DViews(true); + + return tt; } - public void Edit3DWaterBody(WaterBodyOuterParam theWaterBodyOuterParam, HydrGeomSplineParam theHydrGeomSplineParam) + public HydrEngineCSharp.ToolTips Edit3DWaterBody(HydrEngineCSharp.WaterBodyOuterSpParam pHydrGeomCurve) { if (!this._is3D) - return; + return null; + if (pDisplayView.hasBuildThicknessBody()) + pDisplayView.ClearTopoShape(TopoTypeDisplay.EThicknessBody); + + var tt = pDisplayView.rebuildWaterBody(pHydrGeomCurve); + if (tt == null) + return null; + if (tt.GetTipsId() != 1) { - pDisplayView.rebuildWaterBody(theHydrGeomSplineParam, theWaterBodyOuterParam); - Invalidate(true); - pDisplayView.FitAll3DViews(true); + MessageBox.Show(tt.GetToolTips(), "提示"); } + Invalidate(true); + + return tt; + } + + public HydrEngineCSharp.ToolTips Edit3DWaterBody(HydrEngineCSharp.WaterBodyOuterArcParam pHydrGeomArcCurve) + { + if (!this._is3D) + return null; + if (pDisplayView.hasBuildThicknessBody()) + pDisplayView.ClearTopoShape(TopoTypeDisplay.EThicknessBody); + + var tt = pDisplayView.rebuildWaterBody(pHydrGeomArcCurve); + if (tt == null) + return null; + if (tt.GetTipsId() != 1) + { + MessageBox.Show(tt.GetToolTips(), "提示"); + } + Invalidate(true); + + return tt; + } + + #endregion + public virtual bool RemoveThicknessBody() + { + return pDisplayView.RemoveShow(TopoTypeDisplay.EThicknessBody); + } + public virtual bool RemoveWaterBody() + { + return pDisplayView.RemoveShow(TopoTypeDisplay.EWaterBody); + } + public virtual bool RemoveMidCurve() + { + return pDisplayView.RemoveShow(TopoTypeDisplay.E2DMidCurve); + } + public virtual bool RemoveSectCurve910() + { + pDisplayView.removeOuterSectionCurve(10); + return pDisplayView.removeOuterSectionCurve( 9); + } + public virtual bool HideSectCurve18() + { + for (int i= 1;i <= 8;i++) + pDisplayView.hideOuterSectionCurve(i); + return true; + } + public bool HideAll() + { + var ret = pDisplayView.HideTopoShape(TopoTypeDisplay.EAllBody); + //bool bSucc = pDisplayView.BeginTurbopumpTopoShape(DPumpHydr.WinFrmUI.Volute.GlobalParas.RootTopoShapeName); + Invalidate(true); + + return ret; + } + public bool ClearAll() + { + _isFirstSectShape18 = true; + var ret = pDisplayView.ClearTopoShape(TopoTypeDisplay.EAllBody); + //bool bSucc = pDisplayView.BeginTurbopumpTopoShape(DPumpHydr.WinFrmUI.Volute.GlobalParas.RootTopoShapeName); + Invalidate(true); + return ret; + } + + public void FitView() + { + pDisplayView.FitAll3DViews(true); } } } -- Gitblit v1.9.3