using System;
using System.Collections.Generic;
using System.Reflection.Metadata;
using System.Windows.Forms;
using DPumpHydr.WinFrmUI.Volute.ViewModel;
using HydrEngineCSharp;
namespace DPumpHydr.WinFrmUI.Volute
{
public partial class OccDesignBaseCtrl : UserControl
{
protected HydrEngineCSharp.CDisplayView pDisplayView;
public OccDesignBaseCtrl()
{
//InitializeComponent();
this.MouseDown += OnMouseDown;
this.MouseMove += OnMouseMove;
this.MouseUp += OnMouseUp;
this.MouseWheel += OnMouseWheel;
}
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 virtual void Initial()
{
}
#region 1-8 ½ØÃæÉè¼Æ
bool _isFirstSectShape18 = true;
///
///
///
///
///
public List RefreshAllSectShape18(ViewModel.SectionBundleInfo bundle)
{
if (_isFirstSectShape18)
{
_isFirstSectShape18 = false;
return CreateSectShape18(bundle);
}
else
{
return EditSectShape18(bundle);
}
}
double GetSectStartAngle()
{
if (_stype == eOutflowStyle.δ֪ || _stype == eOutflowStyle.ÖÐÐijö¿Ú_´¹Ö±·¨À¼ÃæÁ÷³ö)
return -HydrDisplayEngineBridge.PI_4;
else
return 0;
}
eOutflowStyle _stype = eOutflowStyle.ÖÐÐijö¿Ú_´¹Ö±·¨À¼ÃæÁ÷³ö;
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;
}
///
///
///
///
protected List CreateSectShape18(ViewModel.SectionBundleInfo bundle)
{
List error_sect = new List();
double dStartAngle = GetSectStartAngle();
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;
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;
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.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);
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;
}
///
///
///
///
public List EditSectShape18(ViewModel.SectionBundleInfo bundle)
{
List error_sect = new List();
double dStartAngle = GetSectStartAngle();
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, 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;
}
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);
return error_sect;
}
///
///
///
///
public void RefreshSingleSectShape18(ViewModel.SectionShapePara theSectionParam)
{
pDisplayView.Update3DViews(true);
double dStartAngle = GetSectStartAngle();
double dDetAngle = HydrDisplayEngineBridge.PI / 4;
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;
HydrProperties theHydrProperties = new HydrProperties();
HydrGeomCurve theHydrGeomCurve = HydrDisplayEngineBridge.CreateGeomCurve(HydrCurveType.EHydrGeomSection);
HydrGeomSection pHydrGeomCurve = theHydrGeomCurve as HydrGeomSection;
if (pHydrGeomCurve == null)
{
return;
}
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);
pHydrGeomCurve.SetMatrix(dAngle, dBaseCircleRadius);
pDisplayView.editVoluteCurve(GlobalParas.BuildSectShapeName(theSectionParam.Index), pHydrGeomCurve);
Invalidate(true);
}
///
///
///
///
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);
}
}
///
///
///
///
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
#region Ë®Ìå
public HydrGeomSplineParam Create2DWaterBody(DPumpHydr.WinFrmUI.Volute.ViewModel.OtuflowParas outflowParas)
{
if (this._is3D)
return null;
WaterBodyOuterParam theWaterBodyOuterParam = new WaterBodyOuterParam();
theWaterBodyOuterParam.SetOuterOffset(outflowParas.Offset);
theWaterBodyOuterParam.SetOuterHigh(outflowParas.Heigh);
theWaterBodyOuterParam.SetOuterRad(outflowParas.Dia / 2);
theWaterBodyOuterParam.SetTopValue2(outflowParas.Tangent_Top_Right);
theWaterBodyOuterParam.SetBtmValue2(outflowParas.Tangent_Btm_Right);
theWaterBodyOuterParam.SetTopValue1(outflowParas.Tangent_Top_Left);
theWaterBodyOuterParam.SetBtmValue1(outflowParas.Tangent_Btm_Left);
theWaterBodyOuterParam.SetH1(outflowParas.H1);
theWaterBodyOuterParam.SetH2(outflowParas.H2);
theWaterBodyOuterParam.SetRadConner(outflowParas.Septalradius);
ToolTips theToolTips = pDisplayView.build2DMidCurve(theWaterBodyOuterParam);
if (theToolTips == null)
return null;
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 pDisplayView.getHydrGeomSplineParam();
}
else
{
return null;
}
}
public ToolTips Create3DWaterBody(DPumpHydr.WinFrmUI.Volute.ViewModel.OtuflowParas outflowParas, HydrGeomSplineParam theHydrGeomSplineParam)
{
if (!this._is3D)
return null;
if (theHydrGeomSplineParam == null)
return null;
WaterBodyOuterParam theWaterBodyOuterParam = new WaterBodyOuterParam();
theWaterBodyOuterParam.SetOuterOffset(outflowParas.Offset);
theWaterBodyOuterParam.SetOuterHigh(outflowParas.Heigh);
theWaterBodyOuterParam.SetOuterRad(outflowParas.Dia / 2);
theWaterBodyOuterParam.SetTopValue2(outflowParas.Tangent_Top_Right);
theWaterBodyOuterParam.SetBtmValue2(outflowParas.Tangent_Btm_Right);
theWaterBodyOuterParam.SetTopValue1(outflowParas.Tangent_Top_Left);
theWaterBodyOuterParam.SetBtmValue1(outflowParas.Tangent_Btm_Left);
theWaterBodyOuterParam.SetH1(outflowParas.H1);
theWaterBodyOuterParam.SetH2(outflowParas.H2);
theWaterBodyOuterParam.SetRadConner(outflowParas.Septalradius);
// 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 ToolTips Edit3DWaterBody(DPumpHydr.WinFrmUI.Volute.ViewModel.OtuflowParas outflowParas, HydrGeomSplineParam theHydrGeomSplineParam)
{
if (!this._is3D)
return null;
if (theHydrGeomSplineParam != null)
{
WaterBodyOuterParam theWaterBodyOuterParam = new WaterBodyOuterParam();
theWaterBodyOuterParam.SetOuterOffset(outflowParas.Offset);
theWaterBodyOuterParam.SetOuterHigh(outflowParas.Heigh);
theWaterBodyOuterParam.SetOuterRad(outflowParas.Dia / 2);
theWaterBodyOuterParam.SetTopValue2(outflowParas.Tangent_Top_Right);
theWaterBodyOuterParam.SetBtmValue2(outflowParas.Tangent_Btm_Right);
theWaterBodyOuterParam.SetTopValue1(outflowParas.Tangent_Top_Left);
theWaterBodyOuterParam.SetBtmValue1(outflowParas.Tangent_Btm_Left);
theWaterBodyOuterParam.SetH1(outflowParas.H1);
theWaterBodyOuterParam.SetH2(outflowParas.H2);
theWaterBodyOuterParam.SetRadConner(outflowParas.Septalradius);
if (pDisplayView.hasBuildThicknessBody())
pDisplayView.ClearTopoShape(TopoTypeDisplay.EThicknessBody);//
var tt = pDisplayView.rebuildWaterBody(theHydrGeomSplineParam, theWaterBodyOuterParam);
if (tt == null)
return null;
if(tt.GetTipsId () != 1)
{
}
Invalidate(true);
return tt;
}
return null;
}
///
/// ¸îÉàµÄ½Ç¶È
///
///
public double Get2DMidCurveAngleParam()
{
return pDisplayView.get2DMidCurveAngleParam();
}
#endregion
public bool ClearAll()
{
_isFirstSectShape18 = true;
var ret = pDisplayView.ClearTopoShape(TopoTypeDisplay.EAllBody);
//bool bSucc = pDisplayView.BeginTurbopumpTopoShape(DPumpHydr.WinFrmUI.Volute.GlobalParas.RootTopoShapeName);
return ret;
}
}
}