using DevExpress.Utils;
|
using DevExpress.XtraCharts;
|
using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Linq;
|
using System.Windows.Forms;
|
|
|
|
//用来编辑单泵的性能曲线
|
namespace IStation.WinFrmUI.Curve
|
{
|
public partial class ChartEditLxpCurveCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public enum eEditCurveType
|
{
|
QHcurve,
|
QEcurve,
|
QPcurve,
|
NPSHcurve,
|
EqualEcurve
|
}
|
|
public EventHandler ChangeFeatPointEvent = null;
|
public EventHandler ChangeEqualEPointEvent = null;
|
|
#region 私有字段
|
Model.eCurveFitType _fit_type_qh = Model.eCurveFitType.CubicCurve;
|
Model.eCurveFitType _fit_type_qe = Model.eCurveFitType.CubicCurve;
|
Model.eCurveFitType _fit_type_qp = Model.eCurveFitType.CubicCurve;
|
//原始点坐标
|
private List<Model.CurvePoint> PointInfoQH = null;
|
private List<Model.CurvePoint> PointInfoQE = null;
|
private List<Model.CurvePoint> PointInfoQP = null;
|
|
//拟合后的曲线上的点
|
private List<Model.CurvePoint> CurveInfoQH = null;
|
private List<Model.CurvePoint> CurveInfoQE = null;
|
private List<Model.CurvePoint> CurveInfoQP = null;
|
|
|
//坐标
|
public Model.CurveCoordinateParas _coordinateParas = null;
|
public Model.CurveCoordinateParas CoordinateParas
|
{
|
get { return _coordinateParas; }
|
set { _coordinateParas = value; }
|
}
|
|
//
|
eEditCurveType _editCurveType = eEditCurveType.QHcurve;
|
#endregion
|
|
#region CHART变量
|
//性能曲线
|
private Series SeriesQHcurve = null;
|
private Series SeriesQEcurve = null;
|
private Series SeriesQPcurve = null;
|
|
private Series SeriesQHpoint = null;
|
private Series SeriesQEpoint = null;
|
private Series SeriesQPpoint = null;
|
//
|
private DevExpress.XtraCharts.XYDiagram mainChartDiagram;
|
|
//
|
AxisX AxisQ = null;
|
AxisY QHAxisY = null;
|
SecondaryAxisY QEAxisY = null;
|
SecondaryAxisY QPAxisY = null;
|
|
#endregion
|
|
#region 构造函数和加载函数
|
public ChartEditLxpCurveCtrl()
|
{
|
InitializeComponent();
|
|
this.chartControl1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.chartControl_MouseClick);
|
this.chartControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chartControl_MouseUp);
|
this.chartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chartControl_MouseDown);
|
|
#region 图标控件显示
|
|
SeriesQHcurve = chartControl1.Series["SeriesQHcurve"];
|
SeriesQEcurve = chartControl1.Series["SeriesQEcurve"];
|
SeriesQPcurve = chartControl1.Series["SeriesQPcurve"];
|
SeriesQHcurve.CrosshairEnabled = DefaultBoolean.False;
|
SeriesQEcurve.CrosshairEnabled = DefaultBoolean.False;
|
SeriesQPcurve.CrosshairEnabled = DefaultBoolean.False;
|
|
SeriesQHpoint = chartControl1.Series["SeriesQHpoint"];
|
SeriesQEpoint = chartControl1.Series["SeriesQEpoint"];
|
SeriesQPpoint = chartControl1.Series["SeriesQPpoint"];
|
SeriesQHpoint.CrosshairEnabled = DefaultBoolean.False;
|
SeriesQEpoint.CrosshairEnabled = DefaultBoolean.False;
|
SeriesQPpoint.CrosshairEnabled = DefaultBoolean.False;
|
|
mainChartDiagram = (XYDiagram)chartControl1.Diagram;
|
|
|
|
SeriesQHcurve.Label.LineVisibility = DevExpress.Utils.DefaultBoolean.False;
|
SeriesQEcurve.Label.LineVisibility = DevExpress.Utils.DefaultBoolean.False;
|
SeriesQPcurve.Label.LineVisibility = DevExpress.Utils.DefaultBoolean.False;
|
|
//
|
AxisQ = mainChartDiagram.AxisX;
|
QHAxisY = mainChartDiagram.AxisY;
|
AxisQ.Visibility = DefaultBoolean.False;
|
QHAxisY.Visibility = DefaultBoolean.False;
|
|
QEAxisY = mainChartDiagram.SecondaryAxesY.GetAxisByName("QEAxisY");
|
QPAxisY = mainChartDiagram.SecondaryAxesY.GetAxisByName("QPAxisY");
|
QEAxisY.Visibility = DefaultBoolean.False;
|
QPAxisY.Visibility = DefaultBoolean.False;
|
|
|
//添加重绘事件
|
this.chartControl1.CustomPaint += new DevExpress.XtraCharts.CustomPaintEventHandler(this.chartControl_CustomPaint);
|
#endregion
|
}
|
|
private void LoadWindow(object sender, EventArgs e)
|
{
|
SetChartDisplay();
|
}
|
|
//设置显示
|
bool isMonoColor = false;
|
private void SetChartDisplay()
|
{
|
SetMonoColor();
|
}
|
|
|
|
private void SetMonoColor()
|
{
|
AxisQ.Color = Color.Black;
|
AxisQ.Label.TextColor = Color.Black;
|
AxisQ.Title.TextColor = Color.Black;
|
AxisQ.GridLines.Color = Color.Black;
|
AxisQ.GridLines.MinorColor = Color.Black;
|
|
QHAxisY.Color = Color.Black;
|
QHAxisY.Label.TextColor = Color.Black;
|
QHAxisY.Title.TextColor = Color.Black;
|
QHAxisY.GridLines.Color = Color.Black;
|
QHAxisY.GridLines.MinorColor = Color.Black;
|
|
QEAxisY.Color = Color.Black;
|
QEAxisY.Label.TextColor = Color.Black;
|
QEAxisY.Title.TextColor = Color.Black;
|
QEAxisY.GridLines.Color = Color.Black;
|
QEAxisY.GridLines.MinorColor = Color.Black;
|
|
QPAxisY.Color = Color.Black;
|
QPAxisY.Label.TextColor = Color.Black;
|
QPAxisY.Title.TextColor = Color.Black;
|
QPAxisY.GridLines.Color = Color.Black;
|
QPAxisY.GridLines.MinorColor = Color.Black;
|
|
SeriesQHcurve.View.Color = Color.Black;
|
SeriesQEcurve.View.Color = Color.Black;
|
SeriesQPcurve.View.Color = Color.Black;
|
}
|
|
#endregion
|
|
//输入性能曲线点信息
|
public void SetFeatCurvePoint(
|
List<Model.CurvePoint> pointInfoQH,
|
List<Model.CurvePoint> pointInfoQE,
|
List<Model.CurvePoint> pointInfoQP,
|
Model.eCurveFitType fit_type_qh,
|
Model.eCurveFitType fit_type_qe,
|
Model.eCurveFitType fit_type_qp)
|
{
|
|
this.chartControl1.BeginInit();
|
_screenPoints = null;
|
this.chartControl1.EndInit();
|
_dragPointNO = -1;
|
if (pointInfoQH == null)
|
return;
|
|
|
this.PointInfoQH = pointInfoQH;
|
this.PointInfoQE = pointInfoQE;
|
this.PointInfoQP = pointInfoQP;
|
|
this._fit_type_qh = fit_type_qh;
|
this._fit_type_qe = fit_type_qe;
|
this._fit_type_qp = fit_type_qp;
|
|
|
CalcCurveInfo();
|
//IsEditCurve(eEditCurveType.QHcurve); nsx -测试隐藏
|
}
|
|
//正在编辑曲线
|
public void IsEditCurve(eEditCurveType type)
|
{
|
_editCurveType = type;
|
|
switch (_editCurveType)
|
{
|
case eEditCurveType.QHcurve:
|
|
if (PointInfoQH == null)
|
return;
|
|
_screenPoints = new List<Point>();
|
for (int i = 0; i < PointInfoQH.Count; i++)
|
{ //得到屏幕上点坐标
|
ControlCoordinates coor = mainChartDiagram.DiagramToPoint(PointInfoQH[i].X, PointInfoQH[i].Y, AxisQ, QHAxisY);
|
_screenPoints.Add(coor.Point);
|
}
|
break;
|
case eEditCurveType.QEcurve:
|
if (PointInfoQE == null)
|
return;
|
|
_screenPoints = new List<Point>();
|
for (int i = 0; i < PointInfoQE.Count; i++)
|
{ //得到屏幕上点坐标
|
ControlCoordinates coor = mainChartDiagram.DiagramToPoint(PointInfoQE[i].X, PointInfoQE[i].Y, AxisQ, QEAxisY);
|
_screenPoints.Add(coor.Point);
|
}
|
|
break;
|
case eEditCurveType.QPcurve:
|
if (PointInfoQP == null)
|
return;
|
|
_screenPoints = new List<Point>();
|
for (int i = 0; i < PointInfoQP.Count; i++)
|
{ //得到屏幕上点坐标
|
ControlCoordinates coor = mainChartDiagram.DiagramToPoint(PointInfoQP[i].X, PointInfoQP[i].Y, AxisQ, QPAxisY);
|
_screenPoints.Add(coor.Point);
|
}
|
|
break;
|
default:
|
return;
|
}
|
_dragPointNO = -1;
|
chartControl1.Refresh();
|
}
|
|
//外部修改正在修改的曲线点参数
|
public void SetEditPoint(List<Model.CurvePoint> pointInfo)
|
{
|
_dragPointNO = -1;
|
|
switch (_editCurveType)
|
{
|
case eEditCurveType.QHcurve:
|
PointInfoQH = pointInfo;
|
if (PointInfoQH == null)
|
return;
|
if (this._fit_type_qh == Model.eCurveFitType.ThroughPoint)
|
this.CurveInfoQH = this.PointInfoQH;
|
else
|
this.CurveInfoQH = Model.FitCurveHelper.GetFitPoints(PointInfoQH);
|
|
this._screenPoints = new List<Point>();
|
for (int i = 0; i < PointInfoQH.Count; i++)
|
{ //得到屏幕上点坐标
|
ControlCoordinates coor = mainChartDiagram.DiagramToPoint(PointInfoQH[i].X, PointInfoQH[i].Y, AxisQ, QHAxisY);
|
_screenPoints.Add(coor.Point);
|
}
|
|
break;
|
case eEditCurveType.QEcurve:
|
PointInfoQE = pointInfo;
|
if (PointInfoQE == null)
|
return;
|
if (this._fit_type_qe == Model.eCurveFitType.ThroughPoint)
|
this.CurveInfoQE = this.PointInfoQE;
|
else
|
this.CurveInfoQE = Model.FitCurveHelper.GetFitPoints(PointInfoQE);
|
|
this._screenPoints = new List<Point>();
|
for (int i = 0; i < PointInfoQE.Count; i++)
|
{ //得到屏幕上点坐标
|
ControlCoordinates coor = mainChartDiagram.DiagramToPoint(PointInfoQE[i].X, PointInfoQE[i].Y, AxisQ, QEAxisY);
|
_screenPoints.Add(coor.Point);
|
}
|
|
break;
|
case eEditCurveType.QPcurve:
|
PointInfoQP = pointInfo;
|
if (PointInfoQP == null)
|
return;
|
if (this._fit_type_qp == Model.eCurveFitType.ThroughPoint)
|
this.CurveInfoQP = this.PointInfoQP;
|
else
|
this.CurveInfoQP = Model.FitCurveHelper.GetFitPoints(PointInfoQP);
|
|
this._screenPoints = new List<Point>();
|
for (int i = 0; i < PointInfoQP.Count; i++)
|
{ //得到屏幕上点坐标
|
ControlCoordinates coor = mainChartDiagram.DiagramToPoint(PointInfoQP[i].X, PointInfoQP[i].Y, AxisQ, QPAxisY);
|
_screenPoints.Add(coor.Point);
|
}
|
break;
|
default:
|
return;
|
}
|
|
|
_dragPointNO = -1;
|
|
UpdateFeatCurves();
|
UpdateFeatPoints();
|
}
|
|
//内部修改曲线点参数
|
public void SetEditPoint(int PointNO, Model.CurvePoint pointInfo)
|
{
|
if (PointNO < 0)
|
return;
|
|
switch (_editCurveType)
|
{
|
case eEditCurveType.QHcurve:
|
PointInfoQH[PointNO] = pointInfo;
|
if (this._fit_type_qh == Model.eCurveFitType.ThroughPoint)
|
this.CurveInfoQH = this.PointInfoQH;
|
else
|
this.CurveInfoQH = Model.FitCurveHelper.GetFitPoints(PointInfoQH);
|
|
UpdateFeatCurves();
|
UpdateFeatPoints();
|
|
if (_screenPoints != null)
|
{
|
ControlCoordinates coor = mainChartDiagram.DiagramToPoint(pointInfo.X, pointInfo.Y, AxisQ, QHAxisY);
|
_screenPoints[PointNO] = coor.Point;
|
}
|
|
if (ChangeFeatPointEvent != null)
|
ChangeFeatPointEvent(this, new EventArgs());
|
break;
|
|
case eEditCurveType.QEcurve:
|
PointInfoQE[PointNO] = pointInfo;
|
if (this._fit_type_qe == Model.eCurveFitType.ThroughPoint)
|
this.CurveInfoQE = this.PointInfoQE;
|
else
|
this.CurveInfoQE = Model.FitCurveHelper.GetFitPoints(PointInfoQE);
|
UpdateFeatCurves();
|
UpdateFeatPoints();
|
|
if (_screenPoints != null)
|
{
|
ControlCoordinates coor = mainChartDiagram.DiagramToPoint(pointInfo.X, pointInfo.Y, AxisQ, QEAxisY);
|
_screenPoints[PointNO] = coor.Point;
|
}
|
|
if (ChangeFeatPointEvent != null)
|
ChangeFeatPointEvent(this, new EventArgs());
|
break;
|
|
case eEditCurveType.QPcurve:
|
PointInfoQP[PointNO] = pointInfo;
|
if (this._fit_type_qp == Model.eCurveFitType.ThroughPoint)
|
this.CurveInfoQP = this.PointInfoQP;
|
else
|
this.CurveInfoQP = Model.FitCurveHelper.GetFitPoints(PointInfoQP);
|
UpdateFeatCurves();
|
UpdateFeatPoints();
|
|
if (_screenPoints != null)
|
{
|
ControlCoordinates coor = mainChartDiagram.DiagramToPoint(pointInfo.X, pointInfo.Y, AxisQ, QPAxisY);
|
_screenPoints[PointNO] = coor.Point;
|
}
|
|
if (ChangeFeatPointEvent != null)
|
ChangeFeatPointEvent(this, new EventArgs());
|
break;
|
default:
|
return;
|
}
|
}
|
|
//计算线上的点信息(如果不输入需要计算)
|
private void CalcCurveInfo()
|
{
|
if (this._fit_type_qh == Model.eCurveFitType.ThroughPoint)
|
{
|
this.CurveInfoQH = this.PointInfoQH;
|
}
|
else
|
{
|
this.CurveInfoQH = Model.FitCurveHelper.GetFitPoints(PointInfoQH);
|
}
|
if (this._fit_type_qe == Model.eCurveFitType.ThroughPoint)
|
{
|
this.CurveInfoQE = this.PointInfoQE;
|
}
|
else
|
{
|
if (PointInfoQE != null && PointInfoQE.Count > 3)
|
this.CurveInfoQE = Model.FitCurveHelper.GetFitPoints(PointInfoQE);
|
}
|
if (this._fit_type_qp == Model.eCurveFitType.ThroughPoint)
|
{
|
this.CurveInfoQP = this.PointInfoQP;
|
}
|
else
|
{
|
if (PointInfoQP != null && PointInfoQP.Count > 3)
|
this.CurveInfoQP = Model.FitCurveHelper.GetFitPoints(PointInfoQP);
|
}
|
}
|
|
#region 更新
|
|
//更新所有
|
public void UpdateChart(bool isCalcCoordinate = false)
|
{
|
//_screenPoints = new List<Point>();
|
//要依次更新
|
if (isCalcCoordinate || CoordinateParas == null)
|
{//不强迫计算,就用上次更新的坐标系
|
CalcCoordinate();
|
}
|
UpdateCoordinate();
|
|
UpdateFeatCurves();
|
|
UpdateFeatPoints();
|
}
|
|
public void Clear()
|
{
|
|
}
|
|
public double CalcDispValueH(double h)
|
{
|
return Math.Round(h, 1);
|
}
|
|
//更新图表坐标
|
public void UpdateCoordinate()
|
{
|
//先设置为不显示
|
AxisQ.Visibility = DefaultBoolean.False;
|
QHAxisY.GridLines.Visible = false;
|
QHAxisY.Visibility = DefaultBoolean.False;
|
QPAxisY.GridLines.Visible = false;
|
QPAxisY.Visibility = DefaultBoolean.False;
|
QEAxisY.GridLines.Visible = false;
|
QEAxisY.Visibility = DefaultBoolean.False;
|
|
if (CoordinateParas == null)
|
return;
|
|
//流量
|
if (CurveInfoQH != null)
|
{
|
//坐标刻度
|
List<CustomAxisLabel> q_Label_List = new List<CustomAxisLabel>();
|
AxisQ.CustomLabels.Clear();
|
double disQ = CoordinateParas.CoordMinQ;
|
for (int i = 0; i < CoordinateParas.GridNumberX + 1; i++)
|
{
|
q_Label_List.Add(new CustomAxisLabel(disQ.ToString(), disQ));
|
disQ = disQ + CoordinateParas.CoordSpaceQ;
|
}
|
AxisQ.CustomLabels.AddRange(q_Label_List.ToArray());
|
|
//设置显示
|
XtraChartHelper.SetAxisRange(AxisQ, CoordinateParas.CoordMinQ,
|
CoordinateParas.CoordMinQ + CoordinateParas.GridNumberX * CoordinateParas.CoordSpaceQ);
|
AxisQ.GridLines.Visible = true;
|
AxisQ.Visibility = DefaultBoolean.True;
|
}
|
|
//扬程
|
if (CurveInfoQH != null)
|
{
|
QHAxisY.CustomLabels.Clear();
|
List<CustomAxisLabel> h_Label_List = new List<CustomAxisLabel>();
|
double disH = MathHelper.GetByPlacesLength(_coordinateParas.CoordMinH + _coordinateParas.CoordSpaceH * _coordinateParas.StartLineNoH, 3);
|
for (int i = _coordinateParas.StartLineNoH; i < _coordinateParas.EndLineNoH + 1; i++)
|
{
|
h_Label_List.Add(new CustomAxisLabel(CalcDispValueH(disH).ToString(), disH));
|
disH = disH + _coordinateParas.CoordSpaceH;
|
}
|
QHAxisY.CustomLabels.AddRange(h_Label_List.ToArray());
|
//设置显示
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetAxisRange(QHAxisY,
|
_coordinateParas.CoordMinH,
|
_coordinateParas.CoordMinH + _coordinateParas.GridNumberY * _coordinateParas.CoordSpaceH);
|
QHAxisY.Visibility = DefaultBoolean.True;
|
}
|
|
//效率
|
if (CurveInfoQE != null)
|
{
|
//坐标刻度
|
QEAxisY.CustomLabels.Clear();
|
List<CustomAxisLabel> E_Label_List = new List<CustomAxisLabel>();
|
double disE = _coordinateParas.CoordMinE + _coordinateParas.CoordSpaceE * _coordinateParas.StartLineNoE;
|
for (int i = _coordinateParas.StartLineNoE; i < _coordinateParas.EndLineNoE + 1; i++)
|
{
|
E_Label_List.Add(new CustomAxisLabel(disE.ToString(), disE));
|
disE = disE + _coordinateParas.CoordSpaceE;
|
}
|
QEAxisY.CustomLabels.AddRange(E_Label_List.ToArray());
|
//设置显示
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetAxisRange(QEAxisY, _coordinateParas.CoordMinE,
|
_coordinateParas.CoordMinE + _coordinateParas.GridNumberY * _coordinateParas.CoordSpaceE);
|
QEAxisY.GridLines.Visible = false;
|
QEAxisY.Visibility = DefaultBoolean.True;
|
}
|
|
//功率
|
if (CurveInfoQP != null)
|
{
|
//坐标刻度
|
QPAxisY.CustomLabels.Clear();
|
List<CustomAxisLabel> P_Label_List = new List<CustomAxisLabel>();
|
double disP = _coordinateParas.CoordMinP + _coordinateParas.CoordSpaceP * _coordinateParas.StartLineNoP;
|
for (int i = _coordinateParas.StartLineNoP; i < _coordinateParas.EndLineNoP + 1; i++)
|
{
|
if (disP < 0.00001)
|
P_Label_List.Add(new CustomAxisLabel("0", disP));
|
else
|
P_Label_List.Add(new CustomAxisLabel(disP.ToString(), disP));
|
disP = disP + _coordinateParas.CoordSpaceP;
|
}
|
QPAxisY.CustomLabels.AddRange(P_Label_List.ToArray());
|
//设置显示
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetAxisRange(QPAxisY, _coordinateParas.CoordMinP,
|
_coordinateParas.CoordMinP + _coordinateParas.GridNumberY * _coordinateParas.CoordSpaceP);
|
QPAxisY.GridLines.Visible = false;
|
QPAxisY.Visibility = DefaultBoolean.True;
|
}
|
}
|
|
//更新等效点
|
public void UpdateEqualECurves()
|
{
|
chartControl1.Refresh();
|
}
|
|
//更新特性曲线
|
public void UpdateFeatCurves()
|
{
|
int i = 0;
|
if (CurveInfoQH != null && CurveInfoQH.Count > 3)
|
{
|
SeriesQHcurve.Visible = true;
|
SeriesQHcurve.Points.Clear();
|
for (i = 0; i < CurveInfoQH.Count(); i++)
|
{
|
SeriesQHcurve.Points.Add(new SeriesPoint(CurveInfoQH[i].X, new double[] { CurveInfoQH[i].Y }));
|
}
|
}
|
else
|
{
|
SeriesQHcurve.Visible = false;
|
}
|
|
if (CurveInfoQE != null && CurveInfoQE.Count > 3)
|
{
|
SeriesQEcurve.Visible = true;
|
SeriesQEcurve.Points.Clear();
|
for (i = 0; i < CurveInfoQE.Count(); i++)
|
{
|
SeriesQEcurve.Points.Add(new SeriesPoint(CurveInfoQE[i].X, new double[] { CurveInfoQE[i].Y }));
|
}
|
}
|
else
|
{
|
SeriesQEcurve.Visible = false;
|
}
|
|
if (CurveInfoQP != null && CurveInfoQP.Count > 3)
|
{
|
SeriesQPcurve.Visible = true;
|
SeriesQPcurve.Points.Clear();
|
for (i = 0; i < CurveInfoQP.Count(); i++)
|
{
|
SeriesQPcurve.Points.Add(new SeriesPoint(CurveInfoQP[i].X, new double[] { CurveInfoQP[i].Y }));
|
}
|
}
|
else
|
{
|
SeriesQPcurve.Visible = false;
|
}
|
}
|
|
|
//更新特性曲线
|
public void UpdateFeatPoints()
|
{
|
int i = 0;
|
SeriesQHpoint.Visible = false;
|
if (_editCurveType == eEditCurveType.QHcurve)
|
{
|
if (PointInfoQH != null && PointInfoQH.Count > 3 && this._editCurveType == eEditCurveType.QHcurve)
|
{
|
SeriesQHpoint.Visible = true;
|
SeriesQHpoint.Points.Clear();
|
for (i = 0; i < PointInfoQH.Count(); i++)
|
{
|
SeriesQHpoint.Points.Add(new SeriesPoint(PointInfoQH[i].X, new double[] { PointInfoQH[i].Y }));
|
}
|
}
|
else
|
{
|
SeriesQHpoint.Visible = false;
|
}
|
}
|
SeriesQEpoint.Visible = false;
|
if (_editCurveType == eEditCurveType.QEcurve)
|
{
|
|
if (PointInfoQE != null && PointInfoQE.Count > 3 && this._editCurveType == eEditCurveType.QEcurve)
|
{
|
SeriesQEpoint.Visible = true;
|
SeriesQEpoint.Points.Clear();
|
for (i = 0; i < PointInfoQE.Count(); i++)
|
{
|
SeriesQEpoint.Points.Add(new SeriesPoint(PointInfoQE[i].X, new double[] { PointInfoQE[i].Y }));
|
}
|
}
|
else
|
{
|
SeriesQEpoint.Visible = false;
|
}
|
}
|
SeriesQPpoint.Visible = false;
|
if (_editCurveType == eEditCurveType.QEcurve)
|
{
|
if (PointInfoQP != null && PointInfoQP.Count > 3 && this._editCurveType == eEditCurveType.QPcurve)
|
{
|
SeriesQPpoint.Visible = true;
|
SeriesQPpoint.Points.Clear();
|
for (i = 0; i < PointInfoQP.Count(); i++)
|
{
|
SeriesQPpoint.Points.Add(new SeriesPoint(PointInfoQP[i].X, new double[] { PointInfoQP[i].Y }));
|
}
|
}
|
else
|
{
|
SeriesQPpoint.Visible = false;
|
}
|
}
|
|
}
|
|
#endregion
|
#region 坐标
|
public void SetCoordinateByDialog()
|
{
|
IStation.WinFrmUI.Curve.SetCoordinateAllDlg theSetDlg = new IStation.WinFrmUI.Curve.SetCoordinateAllDlg();
|
theSetDlg.CoordinateParas = CoordinateParas;
|
theSetDlg.OnChangedCoord += (coor) =>
|
{
|
UpdateCoordinate();
|
|
IsEditCurve(this._editCurveType);
|
};
|
if (theSetDlg.ShowDialog() == DialogResult.OK)
|
{
|
|
}
|
}
|
//计算坐标
|
public void CalcCoordinate()
|
{
|
//CoordinateParas = Common.CoordinateHelper.CalcCoordinate(CurveInfoQH,
|
// CurveInfoQE, CurveInfoQP,null);
|
|
//计算最大最小值
|
double maxQ = 0, minQ = 1000;
|
double maxH = 0, minH = 1000;
|
double maxE = 0, minE = 1000;
|
double maxP = 0, minP = 1000;
|
|
Model.CurveCoordinateParas.CalcMinMaxValue(PointInfoQH, PointInfoQE, PointInfoQP,
|
ref maxQ, ref minQ,
|
ref maxH, ref minH,
|
ref maxE, ref minE,
|
ref maxP, ref minP);
|
//minNPSH = 0;// minNPSH * 0.5;//需要放余量给型谱
|
//minP = minP * 0.7;//需要放余量给型谱
|
//minH = minH * 0.5;//扬程都设置从0开始 minH * 0.7;//需要放余量给型谱
|
//if (this._allSimuCurves != null && this._allSimuCurves._)
|
_coordinateParas = Model.CurveCoordinateParas.CalcCoordinate(
|
minQ, maxQ * 1.1,
|
minH * 0.5, maxH * 1.1, //扬程都设置从0开始 minH * 0.7;//需要放余量给型谱
|
minE, maxE,
|
minP * 0.7, maxP * 1.05);//需要放余量给型谱
|
|
if (_coordinateParas.CoordMinQ + _coordinateParas.CoordSpaceQ * this._coordinateParas.GridNumberX < maxQ * 1.05)
|
{
|
_coordinateParas.GridNumberX++;
|
}
|
|
}
|
#endregion
|
|
#region 重绘
|
List<Point> _screenPoints = null;//得到屏幕上的点坐标
|
Rectangle CalculateDiagramBounds()
|
{
|
Point p1 = mainChartDiagram.DiagramToPoint((double)mainChartDiagram.AxisX.VisualRange.MinValue, (double)mainChartDiagram.AxisY.VisualRange.MinValue).Point;
|
Point p2 = mainChartDiagram.DiagramToPoint((double)mainChartDiagram.AxisX.VisualRange.MaxValue, (double)mainChartDiagram.AxisY.VisualRange.MaxValue).Point;
|
|
return GeomHelper.CreateRectangle(p1, p2);
|
}
|
|
|
void chartControl_CustomPaint(object sender, CustomPaintEventArgs e)
|
{
|
if (_coordinateParas == null)
|
return;
|
if (!(e is DXCustomPaintEventArgs dxArgs))
|
return;
|
|
XYDiagram mainDiagram = (XYDiagram)this.chartControl1.Diagram;
|
if (mainDiagram == null)
|
return;
|
|
chartControl1.DrawGridLineY(dxArgs, _coordinateParas, isMonoColor ? Color.Gray : IStation.WinFrmUI.Curve.Cookie.ChartDisp.Default.GridLinesColorY, 0.2f, true);
|
|
//得到屏幕上的点坐标
|
int i = 0;
|
switch (_editCurveType)
|
{
|
case eEditCurveType.QHcurve:
|
if (_screenPoints == null)
|
return;
|
for (i = 0; i < _screenPoints.Count; i++)
|
{
|
if (i == _dragPointNO)
|
dxArgs.Cache.FillEllipse(_screenPoints[i].X - 5, _screenPoints[i].Y - 5, 10, 10, Color.Black);
|
else
|
dxArgs.Cache.FillEllipse(_screenPoints[i].X - 5, _screenPoints[i].Y - 5, 10, 10, XtraChartHelper.GetCurveColorQH());
|
}
|
|
break;
|
case eEditCurveType.QEcurve:
|
if (_screenPoints == null)
|
return;
|
for (i = 0; i < _screenPoints.Count; i++)
|
{
|
if (i == _dragPointNO)
|
dxArgs.Cache.FillEllipse(_screenPoints[i].X - 5, _screenPoints[i].Y - 5, 10, 10, Color.Black);
|
else
|
dxArgs.Cache.FillEllipse(_screenPoints[i].X - 5, _screenPoints[i].Y - 5, 10, 10, XtraChartHelper.GetCurveColorQE());
|
}
|
break;
|
case eEditCurveType.QPcurve:
|
if (_screenPoints == null)
|
return;
|
for (i = 0; i < _screenPoints.Count; i++)
|
{
|
if (i == _dragPointNO)
|
dxArgs.Cache.FillEllipse(_screenPoints[i].X - 5, _screenPoints[i].Y - 5, 10, 10, Color.Black);
|
else
|
dxArgs.Cache.FillEllipse(_screenPoints[i].X - 5, _screenPoints[i].Y - 5, 10, 10, XtraChartHelper.GetCurveColorQP());
|
}
|
break;
|
default:
|
return;
|
}
|
}
|
#endregion
|
|
public void GetPointInfo(out List<Model.CurvePoint> featQHpoint, out List<Model.CurvePoint> featQEpoint, out List<Model.CurvePoint> featQPpoint)
|
{
|
featQHpoint = this.CurveInfoQH;
|
featQEpoint = this.CurveInfoQE;
|
featQPpoint = this.CurveInfoQP;
|
}
|
|
|
#region 键盘和鼠标
|
private int _dragPointNO = -1;
|
|
private void chartControl_MouseClick(object sender, MouseEventArgs e)
|
{
|
//if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
// chartRightMenu.Show(this, e.Location);
|
}
|
|
private void chartControl_MouseDown(object sender, MouseEventArgs e)
|
{
|
this.Cursor = Cursors.Default;
|
if (_screenPoints == null || _screenPoints.Count() == 0)
|
return;
|
|
if (e.Button != System.Windows.Forms.MouseButtons.Left)
|
return;
|
//判断是否在点周围
|
Rectangle r = new Rectangle(e.X - 6, e.Y - 6, 12, 12);
|
for (int i = 0; i < _screenPoints.Count; i++)
|
{
|
if (r.Contains(_screenPoints[i]))
|
{
|
_dragPointNO = i;
|
this.Cursor = Cursors.Hand;
|
break;
|
}
|
_dragPointNO = -1;
|
}
|
|
if (!isMouseMode)
|
chartControl1.Refresh();
|
}
|
|
private void chartControl_MouseUp(object sender, MouseEventArgs e)
|
{
|
if (isMouseMode)
|
{
|
this.Cursor = Cursors.Default;
|
if (_dragPointNO >= 0)
|
{
|
//鼠标未移除控件范围
|
if (this.ClientRectangle.Contains(e.Location))
|
{
|
//得到实际点参数
|
DiagramCoordinates coor = mainChartDiagram.PointToDiagram(e.Location);
|
if (coor.AxisX == null || coor.AxisY == null)
|
return;
|
_screenPoints[_dragPointNO] = e.Location;
|
if (_editCurveType == eEditCurveType.QEcurve)
|
{
|
double eff = coor.GetAxisValue(QEAxisY).NumericalValue;
|
SetEditPoint(_dragPointNO, new Model.CurvePoint(Math.Round(coor.NumericalArgument, 2), Math.Round(eff, 2)));
|
}
|
else if (_editCurveType == eEditCurveType.QPcurve)
|
{
|
double power = coor.GetAxisValue(QPAxisY).NumericalValue;
|
SetEditPoint(_dragPointNO, new Model.CurvePoint(Math.Round(coor.NumericalArgument, 2), Math.Round(power, 2)));
|
}
|
else
|
{
|
SetEditPoint(_dragPointNO, new Model.CurvePoint(Math.Round(coor.NumericalArgument, 2), Math.Round(coor.NumericalValue, 2)));
|
}
|
}
|
_dragPointNO = -1;
|
}
|
}
|
}
|
|
private void chartControl_KeyUp(object sender, KeyEventArgs e)
|
{
|
if (_dragPointNO < 0)
|
return;
|
if (isMouseMode)
|
return;
|
double spaceX = CoordinateParas.CoordSpaceQ / 50;
|
double spaceY = 0;
|
Model.CurvePoint pointInfo;
|
switch (_editCurveType)
|
{
|
case eEditCurveType.QHcurve:
|
pointInfo = PointInfoQH[_dragPointNO];
|
spaceY = CoordinateParas.CoordSpaceH / 50;
|
break;
|
case eEditCurveType.QEcurve:
|
pointInfo = PointInfoQE[_dragPointNO];
|
spaceY = CoordinateParas.CoordSpaceE / 50;
|
break;
|
case eEditCurveType.QPcurve:
|
pointInfo = PointInfoQP[_dragPointNO];
|
spaceY = CoordinateParas.CoordSpaceP / 50;
|
break;
|
default:
|
return;
|
}
|
|
if (e.KeyCode == Keys.Up)
|
{
|
SetEditPoint(_dragPointNO, new Model.CurvePoint(pointInfo.X, pointInfo.Y + spaceY));
|
}
|
else if (e.KeyCode == Keys.Down)
|
{
|
SetEditPoint(_dragPointNO, new Model.CurvePoint(pointInfo.X, pointInfo.Y - spaceY));
|
}
|
else if (e.KeyCode == Keys.Left)
|
{
|
SetEditPoint(_dragPointNO, new Model.CurvePoint(pointInfo.X - spaceX, pointInfo.Y));
|
}
|
else if (e.KeyCode == Keys.Right)
|
{
|
SetEditPoint(_dragPointNO, new Model.CurvePoint(pointInfo.X + spaceX, pointInfo.Y));
|
}
|
}
|
|
#endregion
|
|
#region 右击的菜单
|
|
private void 设置坐标Menu_Click(object sender, EventArgs e)
|
{
|
SetCoordinateByDialog();
|
}
|
|
private bool isMouseMode = false;
|
private void 鼠标拖动模式MenuItem_Click(object sender, EventArgs e)
|
{
|
isMouseMode = !isMouseMode;
|
if (isMouseMode)
|
{
|
键盘拖动模式MenuItem.Text = "键盘拖动模式";
|
}
|
else
|
{
|
键盘拖动模式MenuItem.Text = "键盘拖动模式";
|
}
|
_dragPointNO = -1;
|
}
|
#endregion
|
|
|
|
}
|
}
|