using System;
using System.Collections.Generic;
using System.Windows.Forms;
using HydrEngineCSharp;
namespace DPumpHydr.WinFrmUI.Volute
{
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 ;//²»ÄܹرÕ
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();
}
}
protected 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);
}
}
protected 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Ù×÷
protected 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);
}
// Êó±êµÄ²Ù×÷
protected 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);
}
protected bool _is3D = true;
public void ClearAll()
{
//pDisplayView.DeleteObject(strTurbopumpTopoShapeName);
//pDisplayView.addTurbopumpTopoShape(strTurbopumpTopoShapeName);
}
public virtual void Initial( )
{
}
#region 1-8 ½ØÃæÉè¼Æ
bool _isFirstSectShape18 = true;
///
///
///
///
///
public void RefreshAllSectShape18(ViewModel.SectionBundleInfo bundle)
{
if (_isFirstSectShape18)
{
CreateSectShape18(bundle);
}
else
{
EditSectShape18(bundle);
}
_isFirstSectShape18 = false;
}
protected void CreateSectShape18(ViewModel.SectionBundleInfo bundle)
{
//pDisplayView.Update3DViews(_is3D);
double dStartAngle = -HydrDisplayEngineBridge.PI_4;
double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8;
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;
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.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);
}
public void RefreshSingleSectShape18(ViewModel.SectionShapePara theSectionParam)
{
pDisplayView.Update3DViews(true );
double dStartAngle = -HydrDisplayEngineBridge.PI_4;
double dDetAngle = 2 * HydrDisplayEngineBridge.PI / 8;
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)
{
return;
}
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);
}
#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;
protected bool CreateWaterBody(HydrEngineCSharp.BcGePoint theMPlnBasePt, HydrEngineCSharp.BcGePoint theMPlnOuterPt)
{
WaterBodyOuterParam m_theWaterBodyOuterParam = new WaterBodyOuterParam();
//theWaterBodyOuterParam.SetOuterOffset(theOffset);
//theWaterBodyOuterParam.SetOuterHigh(theHigh);
//theWaterBodyOuterParam.SetOuterRad(theRad);
//theWaterBodyOuterParam.SetTopValue(m_dTopValue);
//theWaterBodyOuterParam.SetBtmValue(m_dBtmValue);
double dOuterOffset = 0.0;
double dOuterHigh = 520.0;
double dOuterRad = 80.0;
double dOuterTopValue = m_dTopValue;
double dOuterBtmValue = m_dBtmValue;
double dH1 = 10;
double dH2 = 0;
double m_dRadConner = 8;
m_theWaterBodyOuterParam.SetOuterOffset(dOuterOffset);
m_theWaterBodyOuterParam.SetOuterHigh(dOuterHigh);
m_theWaterBodyOuterParam.SetOuterRad(dOuterRad);
m_theWaterBodyOuterParam.SetTopValue1(dOuterTopValue);
m_theWaterBodyOuterParam.SetBtmValue1(dOuterBtmValue);
m_theWaterBodyOuterParam.SetTopValue2(dOuterTopValue);
m_theWaterBodyOuterParam.SetBtmValue2(dOuterBtmValue);
m_theWaterBodyOuterParam.SetH1(dH1);
m_theWaterBodyOuterParam.SetH2(dH2);
m_theWaterBodyOuterParam.SetRadConner(m_dRadConner);
var m_theHydrGeomSplineParam = this.Create2DWaterBody(m_theWaterBodyOuterParam);
//if (this._is3D)
//{
// string wstrName = "Ë®Ìå";
// string wstrShapeNameI = wstrName;
// HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomCircle);
// HydrProperties theHydrProperties = new HydrProperties();
// theHydrProperties.SetShapeName(wstrShapeNameI);
// theHydrGeomCurve.SetHydrProperties(theHydrProperties);
// pDisplayView.buildWaterBody(wstrShapeNameI, m_dMPlnBasePtScaleValue, m_dMPlnOuterPtScaleValue, theMPlnBasePt, theMPlnOuterPt, m_theWaterBodyOuterParam);
// Invalidate(true);
// pDisplayView.FitAll3DViews(true);
//}
//else
//{
// //pDisplayView.build2DMidCurve(theWaterBodyOuterParam);
// //pDisplayView.build2DMidCurveFillet(dAngle, m_dMPlnBasePtScaleValue, m_dMPlnOuterPtScaleValue);
// //Invalidate(true);
// //pDisplayView.FitAll3DViews(true);
//}
return true;
}
public HydrGeomSplineParam Create2DWaterBody(WaterBodyOuterParam theWaterBodyOuterParam)
{
if (this._is3D)
return null;
bool bSucc = pDisplayView.build2DMidCurve(theWaterBodyOuterParam);
Invalidate(true);
pDisplayView.FitAll3DViews(true);
if (bSucc)
{
return pDisplayView.getHydrGeomSplineParam();
}
else
{
return null;
}
}
public void Create3DWaterBody(WaterBodyOuterParam theWaterBodyOuterParam, HydrGeomSplineParam theHydrGeomSplineParam)
{
if (!this._is3D)
return;
{
string wstrName = "Ë®Ìå";
string wstrShapeNameI = wstrName;
HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomCircle);
HydrProperties theHydrProperties = new HydrProperties();
theHydrProperties.SetShapeName(wstrShapeNameI);
theHydrGeomCurve.SetHydrProperties(theHydrProperties);
pDisplayView.buildWaterBody(wstrShapeNameI, theHydrGeomSplineParam, theWaterBodyOuterParam);
Invalidate(true);
pDisplayView.FitAll3DViews(true);
}
}
public void Edit3DWaterBody(WaterBodyOuterParam theWaterBodyOuterParam, HydrGeomSplineParam theHydrGeomSplineParam)
{
if (!this._is3D)
return;
{
pDisplayView.rebuildWaterBody(theHydrGeomSplineParam, theWaterBodyOuterParam);
Invalidate(true);
pDisplayView.FitAll3DViews(true);
}
}
}
}