yangyin
2025-01-13 36616eb44dc36a4e6e3e7a7540310cb850218ea9
WinFrmUI/DPumpHydr.WinFrmUI.Volute/Occ/OccDesignBaseCtrl.cs
@@ -10,7 +10,6 @@
    public partial class OccDesignBaseCtrl : UserControl
    {
        protected HydrEngineCSharp.CDisplayView pDisplayView;
        protected string strTurbopumpTopoShapeName = "蜗壳设计x";
@@ -146,30 +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);
                return EditSectShape18(bundle);
            }
            _isFirstSectShape18 = false;
        }
        double GetSectStartAngle()
        {
            if (_stype == eOutflowStyle.未知 || _stype == eOutflowStyle.中心出口_垂直法兰面流出)
                return -HydrDisplayEngineBridge.PI_4;
            else
                return 0;
        }
        eOutflowStyle _stype = eOutflowStyle.中心出口_垂直法兰面流出;
        public bool SetOutflowStyle(eOutflowStyle style)
        {
            if (_stype == style)
                return false ;
            bool isNeedRebuild = false;
            if(style == eOutflowStyle.侧面出口_直线连接)
            {
                if(_stype != eOutflowStyle.侧面出口_直线连接)
                {
                    isNeedRebuild = true ;
                }
            }
            if (style != eOutflowStyle.侧面出口_直线连接)
            {
                if (_stype == eOutflowStyle.侧面出口_直线连接)
                {
                    isNeedRebuild = true;
                }
            }
            _stype = style;
            return isNeedRebuild;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="bundle"></param>
        protected void CreateSectShape18(ViewModel.SectionBundleInfo bundle)
        protected List<int> CreateSectShape18(ViewModel.SectionBundleInfo bundle)
        {
            //pDisplayView.Update3DViews(_is3D);
            List<int> error_sect = new List<int>();
            double dStartAngle = -HydrDisplayEngineBridge.PI_4;
            double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8;
            double dStartAngle = GetSectStartAngle();
            double dDetAngle =   HydrDisplayEngineBridge.PI / 4;
            for (int i = 8; i >= 1; i--)
            {
                var theSectionParam = bundle.ToSectionShapePara(i);
@@ -184,7 +216,7 @@
                dBaseWidth = theSectionParam.BaseWidth;
                dBaseCircleRadius = theSectionParam.BaseCircleRadius;
                string wstrShapeNameI = string.Format("SectShape_{0}", theSectionParam.Index);
                HydrProperties theHydrProperties = new HydrProperties();
@@ -197,40 +229,37 @@
                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);
                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);
                //}
                pDisplayView.addVoluteCurve(theSectionParam.Index, pHydrGeomCurve);
                ToolTips tt = pDisplayView.addVoluteCurve(theSectionParam.Index, pHydrGeomCurve);
                if (tt == null || tt.GetTipsId() != 1)
                {
                    error_sect.Add(theSectionParam.Index);
                }
            }
            Invalidate(true);
            pDisplayView.FitAll3DViews(true);
            return error_sect;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="bundle"></param>
        protected void EditSectShape18(ViewModel.SectionBundleInfo bundle)
        public List<int> EditSectShape18(ViewModel.SectionBundleInfo bundle)
        {
            pDisplayView.Update3DViews(_is3D);
            List<int> error_sect = new List<int>();
            double dStartAngle = -HydrDisplayEngineBridge.PI_4;
            double dStartAngle = GetSectStartAngle();
            double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8;
            double dDetAngle =   HydrDisplayEngineBridge.PI / 4;
            for (int i = 1; i <= 8; i++)
            {
                var theSectionParam = bundle.ToSectionShapePara(i);
@@ -258,7 +287,7 @@
                double dAngle = (8 - theSectionParam.Index) * dDetAngle + dStartAngle;
                theHydrProperties.SetShapeName(wstrShapeNameI);
                //theHydrProperties.SetShapeName(wstrShapeNameI);
                pHydrGeomCurve.SetHydrProperties(theHydrProperties);
                pHydrGeomCurve.SetGeomSection(dGama_Left, dGama_Right, dH, dR_out, dR_Left, dR_Right, dBaseWidth);
                pHydrGeomCurve.SetMatrix(dAngle, dBaseCircleRadius);
@@ -271,23 +300,32 @@
                //    pHydrGeomCurve.SetMatrix(theMatrix);
                //}
                pDisplayView.editVoluteCurve(wstrShapeNameI, pHydrGeomCurve);
                ToolTips tt = pDisplayView.editVoluteCurve(wstrShapeNameI, pHydrGeomCurve);
                //pDisplayView.addVoluteCurve(theSectionParam.Index, pHydrGeomCurve);
                if (tt == null || tt.GetTipsId() != 1)
                {
                    error_sect.Add(theSectionParam.Index);
                }
            }
            Invalidate(true);
            return error_sect;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="theSectionParam"></param>
        public void RefreshSingleSectShape18(ViewModel.SectionShapePara theSectionParam)
        {
            pDisplayView.Update3DViews(true);
            double dStartAngle = -HydrDisplayEngineBridge.PI_4;
            double dStartAngle = GetSectStartAngle();
            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;
@@ -300,8 +338,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);
@@ -313,37 +349,48 @@
            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);
            pHydrGeomCurve.SetMatrix(dAngle, dBaseCircleRadius);
            //{
            //    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);
            pDisplayView.editVoluteCurve(GlobalParas.BuildSectShapeName(theSectionParam.Index), pHydrGeomCurve);
            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)
                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, 0, 255);
                else
                    this.pDisplayView.setVoluteCurveClr(i, 100, 149, 237);
            }
            Invalidate(true);
        }
        #endregion
@@ -351,7 +398,7 @@
        #region 水体
        public HydrGeomSplineParam Create2DWaterBody(DPumpHydr.WinFrmUI.Volute.ViewModel.OtuflowParas outflowParas )
        public HydrGeomSplineParam Create2DWaterBody(DPumpHydr.WinFrmUI.Volute.ViewModel.OtuflowParas outflowParas)
        {
            if (this._is3D)
                return null;
@@ -368,10 +415,19 @@
            theWaterBodyOuterParam.SetRadConner(outflowParas.Septalradius);
            bool bSucc = pDisplayView.build2DMidCurve(theWaterBodyOuterParam);
            ToolTips theToolTips = pDisplayView.build2DMidCurve(theWaterBodyOuterParam);
            if (theToolTips == null)
                return null;
            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();
            }
@@ -380,13 +436,13 @@
                return null;
            }
        }
        string ShapeNameWaterSolid = "WaterSolid";
        public void Create3DWaterBody(DPumpHydr.WinFrmUI.Volute.ViewModel.OtuflowParas outflowParas, HydrGeomSplineParam theHydrGeomSplineParam)
        public ToolTips  Create3DWaterBody(DPumpHydr.WinFrmUI.Volute.ViewModel.OtuflowParas outflowParas, HydrGeomSplineParam theHydrGeomSplineParam)
        {
            if (!this._is3D)
                return;
                return null;
            if (theHydrGeomSplineParam == null)
                return;
                return null;
            WaterBodyOuterParam theWaterBodyOuterParam = new WaterBodyOuterParam();
            theWaterBodyOuterParam.SetOuterOffset(outflowParas.Offset);
@@ -400,27 +456,31 @@
            theWaterBodyOuterParam.SetH2(outflowParas.H2);
            theWaterBodyOuterParam.SetRadConner(outflowParas.Septalradius);
            {
                HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomCircle);
                HydrProperties theHydrProperties = new HydrProperties();
                theHydrProperties.SetShapeName(ShapeNameWaterSolid);
                theHydrGeomCurve.SetHydrProperties(theHydrProperties);
                if (pDisplayView.hasBuildThicknessBody())
                    pDisplayView.removeThicknessBody();//
                pDisplayView.buildWaterBody(ShapeNameWaterSolid, theHydrGeomSplineParam, theWaterBodyOuterParam);
                Invalidate(true);
                pDisplayView.FitAll3DViews(true);
            }
            // HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomCircle);
            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);
            //  theHydrGeomCurve.SetHydrProperties(theHydrProperties);
            if (pDisplayView.hasBuildThicknessBody())
                pDisplayView.ClearTopoShape(TopoTypeDisplay.EThicknessBody);
           var tt = pDisplayView.buildWaterBody(theHydrProperties, theHydrGeomSplineParam, theWaterBodyOuterParam);
            Invalidate(true);
            pDisplayView.FitAll3DViews(true);
            return tt;
        }
        public void Edit3DWaterBody(DPumpHydr.WinFrmUI.Volute.ViewModel.OtuflowParas outflowParas, HydrGeomSplineParam theHydrGeomSplineParam)
        public ToolTips Edit3DWaterBody(DPumpHydr.WinFrmUI.Volute.ViewModel.OtuflowParas outflowParas, HydrGeomSplineParam theHydrGeomSplineParam)
        {
            if (!this._is3D)
                return;
                return null;
            if (theHydrGeomSplineParam != null)
@@ -437,10 +497,21 @@
                theWaterBodyOuterParam.SetH2(outflowParas.H2);
                theWaterBodyOuterParam.SetRadConner(outflowParas.Septalradius);
                pDisplayView.rebuildWaterBody(theHydrGeomSplineParam, theWaterBodyOuterParam);
                if (pDisplayView.hasBuildThicknessBody())
                    pDisplayView.ClearTopoShape(TopoTypeDisplay.EThicknessBody);//
                var tt =  pDisplayView.rebuildWaterBody(theHydrGeomSplineParam, theWaterBodyOuterParam);
                if (tt == null)
                    return null;
                if(tt.GetTipsId () != 1)
                {
                }
                Invalidate(true);
                pDisplayView.FitAll3DViews(true);
                return tt;
            }
            return null;
        }
        /// <summary>
        /// 割舌的角度
@@ -453,5 +524,14 @@
        #endregion
        public bool  ClearAll()
        {
            _isFirstSectShape18 = true;
            var ret = pDisplayView.ClearTopoShape(TopoTypeDisplay.EAllBody);
            //bool bSucc = pDisplayView.BeginTurbopumpTopoShape(DPumpHydr.WinFrmUI.Volute.GlobalParas.RootTopoShapeName);
            return ret;
        }
    }
}