using System; using System.Collections.Generic; using System.Windows.Forms; using DPumpHydr.WinFrmUI.RLT.Docking.Crown; using HydrEngineCSharp; namespace DPumpHydr.WinFrmUI.Volute { public partial class OccDesignCtrl : UserControl { private HydrEngineCSharp.CDisplayView pDisplayView; private int m_nNum = 0; private int m_nSectionNum = 0; private int m_nVoluteNum = 0; public OccDesignCtrl() { InitializeComponent(); //this.DefaultDockArea = RLT.Enum.Crown.DockArea.Document; //this._isDispCloseIcon = false ;//²»ÄÜ¹Ø±Õ 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("¿ªÊ¼ÎÏ¿ÇÉè¼Æ"); //} } protected override void OnPaint(PaintEventArgs e) { // »æÖÆ´úÂë pDisplayView.OCCDraw(); } protected override void OnResize(EventArgs e) { base.OnResize(e); // ³ß´ç¸Ä±äʱµÄ´úÂë if (pDisplayView != null) { pDisplayView.OCCResize(); } } private void OnMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { // Êó±ê×ó¼ü°´ÏµIJÙ×÷ HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y); uint nF = 0; pDisplayView.LButtonDown(nF, pLT_PtInt2D); } else if (e.Button == MouseButtons.Middle) { HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y); uint nF = 0; pDisplayView.MButtonDown(nF, pLT_PtInt2D); } else if (e.Button == MouseButtons.Right) { HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y); uint nF = 0; pDisplayView.RButtonDown(nF, pLT_PtInt2D); } } private void OnMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { // Êó±ê×ó¼ü°´ÏµIJÙ×÷ HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y); uint nF = 0; pDisplayView.LButtonUp(nF, pLT_PtInt2D); } else if (e.Button == MouseButtons.Middle) { HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y); uint nF = 0; pDisplayView.MButtonUp(nF, pLT_PtInt2D); } else if (e.Button == MouseButtons.Right) { HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y); uint nF = 0; pDisplayView.RButtonUp(nF, pLT_PtInt2D); } } // Êó±ê¹öÂֵIJÙ×÷ private void OnMouseWheel(object sender, MouseEventArgs e) { // e.Delta ·µ»Ø¹öÂֵĹö¶¯Öµ // Èç¹û e.Delta > 0 Ôò±íʾ¹öÂÖÏòÉÏ // Èç¹û e.Delta < 0 Ôò±íʾ¹öÂÖÏòÏ HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y); uint nF = 0; pDisplayView.MouseWheel(nF, (short)e.Delta, pLT_PtInt2D); } // Êó±êµÄ²Ù×÷ private void OnMouseMove(object sender, MouseEventArgs e) { HydrEngineCSharp.LT_PtInt2D pLT_PtInt2D = new HydrEngineCSharp.LT_PtInt2D(e.X, e.Y); uint nF = 0; pDisplayView.MouseMove(nF, pLT_PtInt2D); } public void SetViewDirect(DPumpHydr.Model.eViewDirect vd) { if(vd == Model.eViewDirect.TOP) pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.TOPVIEW); if (vd == Model.eViewDirect.FRONT) pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.FRONTVIEW); if (vd == Model.eViewDirect.BACK) pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.BACKVIEW); if (vd == Model.eViewDirect.INI) pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.INITVIEW); if (vd == Model.eViewDirect.LEFT) pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.LEFTVIEW); if (vd == Model.eViewDirect.RIGHT) pDisplayView.SetViewDirect(HydrEngineCSharp.VIEWDIRECT.RIGHTVIEW); } private bool _is3D = true; string strTurbopumpTopoShapeName = "ÎÏ¿ÇÉè¼Æ1" ; public void Initial(bool is3D) { this._is3D = is3D; // ´´½¨Ê±µÄ´úÂë pDisplayView = new HydrEngineCSharp.CDisplayView(); pDisplayView.InitOCCDraw(); IntPtr hwnd = this.Handle; //IntPtr hwnd = splitContainer1.Handle; // ³õʼ»¯¸üдúÂë pDisplayView.InitialUpdateOCC((uint)hwnd, is3D); bool bSucc = pDisplayView.addTurbopumpTopoShape(strTurbopumpTopoShapeName); //OnSectiondesignbutton(); //OnBuildsolidbutton(); } /// /// /// /// /// public void RefreshAllSectShape18(ViewModel.SectionBundleInfo bundle) { string wstrName = "¶ÏÃæ"; 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; int nIndex = theSectionParam.Index; string wstrShapeNameI = wstrName + nIndex.ToString() + "(" + (m_nSectionNum++).ToString() + ")"; pDisplayView.DeleteObject(wstrShapeNameI);//ɾ³ýµôÀ쵀 HydrGeomSection pHydrGeomCurve = new HydrGeomSection(); HydrProperties theHydrProperties = new HydrProperties(); 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 = i * 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.addVoluteCurve(i, pHydrGeomCurve); } if (_is3D) { CreateSolid(); } else { Invalidate(true); pDisplayView.FitAll3DViews(true); } } // private void CreateSolid( ) { string wstrVoluteName = "±ÃÌå" + (m_nVoluteNum++).ToString(); bool bSucc = pDisplayView.buildVoluteShape(wstrVoluteName); if (bSucc) { } Invalidate(true); pDisplayView.FitAll3DViews(true); } } }