using DevExpress.Utils;
|
using DevExpress.XtraCharts;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Windows.Forms;
|
|
|
namespace IStation.WinFrmUI.Curve
|
{
|
/// <summary>
|
/// 曲线展示控件 nsx 废弃
|
/// </summary>
|
public partial class CurveViewChartCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
#region 构造函数和加载函数
|
public CurveViewChartCtrl()
|
{
|
InitializeComponent();
|
InitialChart();
|
InitialChartDisplay();
|
}
|
|
/// <summary>
|
/// 初始化图表
|
/// </summary>
|
private void InitialChart()
|
{
|
SeriesQHpoint = chartControl1.Series["SeriesQHpoint"];
|
SeriesQEpoint = chartControl1.Series["SeriesQEpoint"];
|
SeriesQPpoint = chartControl1.Series["SeriesQPpoint"];
|
|
SeriesQHcurve = chartControl1.Series["SeriesQHcurve"];
|
SeriesQEcurve = chartControl1.Series["SeriesQEcurve"];
|
SeriesQPcurve = chartControl1.Series["SeriesQPcurve"];
|
|
SeriesQHline = chartControl1.Series["SeriesQHline"];
|
|
mainChartDiagram = (XYDiagram)chartControl1.Diagram;
|
|
SeriesQHpoint.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
SeriesQEpoint.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
SeriesQPpoint.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
|
SeriesQHcurve.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
SeriesQEcurve.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
SeriesQPcurve.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
|
SeriesQHpoint.Visible = false;
|
SeriesQEpoint.Visible = false;
|
SeriesQPpoint.Visible = false;
|
SeriesQHline.Visible = false;
|
|
SeriesQHcurve.CrosshairEnabled = DefaultBoolean.False;
|
SeriesQEcurve.CrosshairEnabled = DefaultBoolean.False;
|
SeriesQPcurve.CrosshairEnabled = DefaultBoolean.False;
|
|
SeriesQHpoint.CrosshairEnabled = DefaultBoolean.False;
|
SeriesQEpoint.CrosshairEnabled = DefaultBoolean.False;
|
SeriesQPpoint.CrosshairEnabled = DefaultBoolean.False;
|
|
SeriesQHline.CrosshairHighlightPoints = DefaultBoolean.False;
|
SeriesQHline.CrosshairEnabled = 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;
|
|
WorkRegionStrip = AxisQ.Strips.GetStripByName("WorkRegion");
|
WorkRegionStrip.Visible = false;
|
|
RatedParasLine = (DevExpress.XtraCharts.ConstantLine)mainChartDiagram.AxisX.ConstantLines.GetElementByName("RatedParasLine");
|
RatedParasLine.Visible = false;
|
|
WorkParasLine = (DevExpress.XtraCharts.ConstantLine)mainChartDiagram.AxisX.ConstantLines.GetElementByName("WorkParasLine");
|
WorkParasLine.Visible = false;
|
|
TextAnnotationQH = chartControl1.AnnotationRepository[0] as DevExpress.XtraCharts.TextAnnotation;
|
TextAnnotationQE = chartControl1.AnnotationRepository[1] as DevExpress.XtraCharts.TextAnnotation;
|
TextAnnotationQP = chartControl1.AnnotationRepository[2] as DevExpress.XtraCharts.TextAnnotation;
|
TextAnnoWorkPoint = chartControl1.AnnotationRepository[3] as DevExpress.XtraCharts.TextAnnotation;
|
TextAnnotationEquip = chartControl1.AnnotationRepository[4] as DevExpress.XtraCharts.TextAnnotation;
|
TextAnnotationMaxE = chartControl1.AnnotationRepository[5] as DevExpress.XtraCharts.TextAnnotation;
|
|
TextAnnotationMaxE.Visible = false;
|
TextAnnoWorkPoint.Visible = false;
|
TextAnnotationEquip.Visible = false;
|
|
LineSeriesView view1 = (SplineSeriesView)SeriesQHcurve.View;
|
view1.MarkerVisibility = DevExpress.Utils.DefaultBoolean.False;
|
LineSeriesView view2 = (SplineSeriesView)SeriesQEcurve.View;
|
view2.MarkerVisibility = DevExpress.Utils.DefaultBoolean.False;
|
LineSeriesView view3 = (SplineSeriesView)SeriesQPcurve.View;
|
view3.MarkerVisibility = DevExpress.Utils.DefaultBoolean.False;
|
|
this.chartControl1.SeriesSelectionMode = SeriesSelectionMode.Point;//设置此属性 表示可以选择CHART上物体
|
// this.chartControl1.RuntimeSeriesSelectionMode = SeriesSelectionMode.Point;//系列选择是选择其中的点而不是整个系列
|
this.SeriesQHpoint.CrosshairHighlightPoints = DefaultBoolean.True;
|
//this.chartControl1.RuntimeSeriesSelectionMode = SeriesSelectionMode.Series;
|
|
//添加重绘事件
|
this.chartControl1.CustomPaint += new DevExpress.XtraCharts.CustomPaintEventHandler(this.chartControl_CustomPaint);
|
this.chartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseDown);
|
this.chartControl1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseMove);
|
this.chartControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseUp);
|
}
|
#endregion
|
|
#region 显示
|
/// <summary>
|
/// 是否显示点
|
/// </summary>
|
private bool _isDispCurrentPoint = false;
|
|
/// <summary>
|
/// 是否显示点
|
/// </summary>
|
public bool IsDispCurvePoint
|
{
|
get
|
{
|
return _isDispCurrentPoint;
|
}
|
set
|
{
|
_isDispCurrentPoint = value;
|
}
|
}
|
|
/// <summary>
|
/// 是否显示曲线标签
|
/// </summary>
|
private bool isDispCurveName = false;
|
|
/// <summary>
|
/// 是否显示曲线标签
|
/// </summary>
|
public bool IsDispCurveName
|
{
|
get { return isDispCurveName; }
|
set
|
{
|
isDispCurveName = value;
|
if (TextAnnotationQH != null)
|
TextAnnotationQH.Visible = isDispCurveName;
|
if (TextAnnotationQE != null)
|
TextAnnotationQE.Visible = isDispCurveName;
|
if (TextAnnotationQP != null)
|
TextAnnotationQP.Visible = isDispCurveName;
|
}
|
}
|
|
/// <summary>
|
/// 初始化图标控件 (读取Cookie)
|
/// </summary>
|
private void InitialChartDisplay()
|
{
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetDisplay(AxisQ, QHAxisY, QEAxisY, QPAxisY);
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetCurveDisplay(SeriesQHcurve, SeriesQEcurve, SeriesQPcurve);
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetPointDisplay(SeriesQHpoint, SeriesQEpoint, SeriesQPpoint);
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetDisplay(WorkRegionStrip);
|
|
if (isDispCurveName)
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetDisplay(TextAnnotationQH, TextAnnotationQE, TextAnnotationQP);
|
|
TextAnnotationQH.Visible = isDispCurveName;
|
TextAnnotationQE.Visible = isDispCurveName;
|
TextAnnotationQP.Visible = isDispCurveName;
|
}
|
|
#endregion
|
|
#region 曲线
|
/// <summary>
|
/// 是否只显示流量扬程线
|
/// </summary>
|
private bool _isOnlyCurveQH = false;
|
|
double _CurveMaxQ = 0, _CurveMinQ = 0;
|
double _CurveMaxH = 0, _CurveMinH = 0;
|
private List<Model.CurvePoint> CurveInfoQH = null;
|
public Model.CurveExpress CurveExprQH = null;
|
private List<Model.CurvePoint> CurveInfoQE = null;
|
public Model.CurveExpress CurveExprQE = null;
|
private List<Model.CurvePoint> CurveInfoQP = null;
|
private Model.CurveExpress CurveExprQP = null;
|
|
public void SetCurveInfo(Model.FeatCurveExpressGroup curveExpressGroup)
|
{
|
if (curveExpressGroup == null)
|
return;
|
SetCurveInfo(curveExpressGroup.CurveQH, curveExpressGroup.CurveQE, curveExpressGroup.CurveQP);
|
}
|
|
public void SetCurveInfo(Model.CurveExpress curveQH, Model.CurveExpress curveQE, Model.CurveExpress curveQP)
|
{
|
if (curveQH == null)
|
return;
|
|
this.CurveExprQH = curveQH;
|
this.CurveExprQE = curveQE;
|
this.CurveExprQP = curveQP;
|
|
this.CurveInfoQH = Model.FitCurveHelper.GetFitPoints(curveQH, 11);
|
this.CurveInfoQE = Model.FitCurveHelper.GetFitPoints(curveQE, 11);
|
this.CurveInfoQP = Model.FitCurveHelper.GetFitPoints(curveQP, 11);
|
|
_isOnlyCurveQH = false;
|
if (curveQE == null && curveQP == null)
|
_isOnlyCurveQH = true;
|
|
IsDispCurveName = true;
|
}
|
|
|
#endregion
|
|
#region CHART变量
|
//测试的原始点
|
private Series SeriesQHpoint = null;
|
private Series SeriesQEpoint = null;
|
private Series SeriesQPpoint = null;
|
|
//拟合后的曲线上的点
|
private Series SeriesQHcurve = null;
|
private Series SeriesQEcurve = null;
|
private Series SeriesQPcurve = null;
|
private Series SeriesQHline = null;
|
|
//
|
private DevExpress.XtraCharts.XYDiagram mainChartDiagram;
|
private DevExpress.XtraCharts.Strip WorkRegionStrip = null;
|
private DevExpress.XtraCharts.ConstantLine RatedParasLine = null;
|
private DevExpress.XtraCharts.ConstantLine WorkParasLine = null;
|
//
|
private DevExpress.XtraCharts.TextAnnotation TextAnnotationQH = null;
|
private DevExpress.XtraCharts.TextAnnotation TextAnnotationQE = null;
|
private DevExpress.XtraCharts.TextAnnotation TextAnnotationQP = null;
|
private DevExpress.XtraCharts.TextAnnotation TextAnnotationEquip = null;
|
private DevExpress.XtraCharts.TextAnnotation TextAnnoWorkPoint = null;
|
|
private DevExpress.XtraCharts.TextAnnotation TextAnnotationMaxE = null;
|
|
//
|
AxisX AxisQ = null;
|
AxisY QHAxisY = null;
|
SecondaryAxisY QEAxisY = null;
|
SecondaryAxisY QPAxisY = null;
|
|
#endregion
|
|
#region 坐标
|
//坐标
|
private Model.CurveCoordinateParas _coordinateParas = null;
|
public Model.CurveCoordinateParas CoordinateParas { get { return _coordinateParas; } set { _coordinateParas = value; } }
|
|
//更新图表坐标
|
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;
|
|
WorkRegionStrip.Visible = false;
|
RatedParasLine.Visible = false;
|
|
if (CoordinateParas == null)
|
return;
|
|
var coord = CoordinateParas;
|
|
//流量
|
if (CurveInfoQH != null)
|
{
|
AxisQ.CustomLabels.Clear();
|
//坐标刻度
|
var Q_Label_List = new List<CustomAxisLabel>();
|
double disQ = coord.CoordMinQ;
|
for (int i = 0; i < coord.GridNumberX + 1; i++)
|
{
|
Q_Label_List.Add(new CustomAxisLabel(disQ.ToString(), disQ));
|
disQ = disQ + coord.CoordSpaceQ;
|
}
|
AxisQ.CustomLabels.AddRange(Q_Label_List.ToArray());
|
AxisQ.Visibility = DefaultBoolean.True; //设置显示
|
AxisQ.GridLines.Visible = true;
|
Curve.XtraChartHelper.SetAxisRange(AxisQ, coord.CoordMinQ, coord.CoordMinQ + coord.GridNumberX * coord.CoordSpaceQ);
|
}
|
|
//扬程
|
if (CurveInfoQH != null)
|
{
|
QHAxisY.CustomLabels.Clear();
|
//坐标刻度
|
var H_Label_List = new List<CustomAxisLabel>();
|
double disH = coord.CoordMinH + coord.CoordSpaceH * coord.StartLineNoH;
|
for (int i = coord.StartLineNoH; i < coord.EndLineNoH + 1; i++)
|
{
|
H_Label_List.Add(new CustomAxisLabel(disH.ToString(), disH));
|
disH = disH + coord.CoordSpaceH;
|
}
|
QHAxisY.CustomLabels.AddRange(H_Label_List.ToArray());
|
//QHAxisY.GridLines.Visible = true; //设置显示
|
QHAxisY.Visibility = DefaultBoolean.True;
|
if (_isOnlyCurveQH)
|
{
|
Curve.XtraChartHelper.SetAxisRange(QHAxisY, coord.DispMinH(), coord.DispMaxH());
|
}
|
else
|
{
|
Curve.XtraChartHelper.SetAxisRange(QHAxisY, coord.CoordMinH, coord.CoordMinH + coord.GridNumberY * coord.CoordSpaceH);
|
}
|
}
|
|
//效率
|
if (CurveInfoQE != null)
|
{
|
//坐标刻度
|
QEAxisY.CustomLabels.Clear();
|
List<CustomAxisLabel> E_Label_List = new List<CustomAxisLabel>();
|
double disE = coord.CoordMinE + coord.CoordSpaceE * coord.StartLineNoE;
|
for (int i = coord.StartLineNoE; i < coord.EndLineNoE + 1; i++)
|
{
|
E_Label_List.Add(new CustomAxisLabel(disE.ToString(), disE));
|
disE = disE + coord.CoordSpaceE;
|
}
|
QEAxisY.CustomLabels.AddRange(E_Label_List.ToArray());
|
//QEAxisY.GridLines.Visible = true; //设置显示
|
QEAxisY.Visibility = DefaultBoolean.True;
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetAxisRange(QEAxisY, coord.CoordMinE, coord.CoordMinE + coord.GridNumberY * coord.CoordSpaceE);
|
}
|
|
//功率
|
if (CurveInfoQP != null)
|
{
|
//坐标刻度
|
QPAxisY.CustomLabels.Clear();
|
var P_Label_List = new List<CustomAxisLabel>();
|
double disP = coord.CoordMinP + coord.CoordSpaceP * coord.StartLineNoP;
|
for (int i = coord.StartLineNoP; i < coord.EndLineNoP + 1; i++)
|
{
|
P_Label_List.Add(new CustomAxisLabel(disP.ToString(), disP));
|
disP = disP + coord.CoordSpaceP;
|
}
|
QPAxisY.CustomLabels.AddRange(P_Label_List.ToArray());
|
//设置显示
|
//QPAxisY.GridLines.Visible = true;
|
QPAxisY.Visibility = DefaultBoolean.True;
|
IStation.WinFrmUI.Curve.XtraChartHelper.SetAxisRange(QPAxisY, coord.CoordMinP, coord.CoordMinP + coord.GridNumberY * coord.CoordSpaceP);
|
}
|
}
|
|
#endregion
|
|
#region 工作点
|
|
#region 设置工作点
|
private bool isDispWorkPt = false;
|
private Model.GroupPoint workPt = new Model.GroupPoint(0, 0, 0, 0, 0);
|
|
public void SetWorkPointQ(double wrkQ)
|
{
|
if (this.CurveInfoQH != null && this.CurveInfoQH.Count > 3)
|
{
|
workPt.Q = wrkQ;
|
isDispWorkPt = true;
|
SeriesQHline.Visible = true;
|
WorkParasLine.Visible = true;
|
WorkParasLine.Title.Visible = true;
|
SeriesQHline.Visible = true;
|
TextAnnoWorkPoint.Visible = true;
|
|
CalcWorkPtByQ(wrkQ);
|
SetQHLineByWorkPt();
|
}
|
}
|
|
public void SetWorkPointQ_Auto()
|
{
|
if (this.CurveInfoQH != null && this.CurveInfoQH.Count > 3)
|
{
|
double wrkQ = (_CurveMinQ + _CurveMaxQ) / 2;
|
|
SetWorkPointQ(wrkQ);
|
}
|
}
|
|
public void SetWorkPointH(double wrkH)
|
{
|
if (this.CurveInfoQH != null && this.CurveInfoQH.Count > 3)
|
{
|
workPt.H = wrkH;
|
isDispWorkPt = true;
|
SeriesQHline.Visible = true;
|
WorkParasLine.Visible = true;
|
WorkParasLine.Title.Visible = true;
|
SeriesQHline.Visible = true;
|
TextAnnoWorkPoint.Visible = true;
|
|
double wrkQ = 0;
|
if (CalcWorkQByH(wrkH, ref wrkQ))
|
{
|
CalcWorkPtByQ(wrkQ);
|
SetQHLineByWorkPt();
|
}
|
}
|
}
|
|
public void IsNotDispWorkPt()
|
{
|
isDispWorkPt = false;
|
WorkParasLine.Visible = false;
|
WorkParasLine.Title.Visible = false;
|
TextAnnoWorkPoint.Visible = false;
|
SeriesQHline.Visible = false;
|
}
|
#endregion
|
|
#region 计算
|
private void CalcWorkPtByQ(double refQ)
|
{
|
if (!isDispWorkPt)
|
return;
|
if (CurveInfoQH == null)
|
return;
|
if (refQ < _CurveMinQ * 1.01 || refQ > _CurveMaxQ * 0.999)
|
return;
|
|
workPt.Q = refQ;
|
WorkParasLine.AxisValue = refQ;
|
|
//WorkParasLine.Title.Visible = true;
|
//WorkParasLine.Visible = true;
|
//WorkParasLine.Title.Text = string.Format("{0:N1}", refQ);
|
|
StringBuilder builder = new StringBuilder();
|
|
builder.AppendLine("---工作点参数---");
|
builder.AppendFormat("流量:{0:N1}", workPt.Q);
|
|
workPt.H = Model.FitCurveHelper.GetFitPointY(CurveExprQH, refQ);
|
builder.AppendLine("");
|
builder.AppendFormat("扬程:{0:N1}", workPt.H);
|
|
|
if (CurveExprQE != null)
|
{
|
workPt.E = Model.FitCurveHelper.GetFitPointY(CurveExprQE, refQ);
|
builder.AppendLine("");
|
builder.AppendFormat("效率:{0:N1}", workPt.E);
|
}
|
|
if (CurveExprQP != null)
|
{
|
workPt.P = Model.FitCurveHelper.GetFitPointY(CurveExprQP, refQ);
|
builder.AppendLine("");
|
builder.AppendFormat("功率:{0:N1}", workPt.P);
|
}
|
|
TextAnnoWorkPoint.Visible = true;
|
TextAnnoWorkPoint.Text = builder.ToString();
|
}
|
|
private bool CalcWorkQByH(double wrkH, ref double wrkQ)
|
{
|
if (this.CurveInfoQH == null)
|
return false;
|
|
if (wrkH < _CurveMinH * 1.01 || wrkH > _CurveMaxH * 0.999)
|
return false;
|
|
List<Model.CurvePoint> intrPts = Model.FitCurveHelper.GetInterPointX(CurveExprQH, wrkH);
|
if (intrPts == null || intrPts.Count == 0)
|
{
|
return false;
|
}
|
else
|
{
|
wrkQ = intrPts.Last().X;
|
return true;
|
}
|
}
|
|
private void SetQHLineByWorkPt()
|
{
|
SeriesQHline.Visible = true;
|
SeriesQHline.Points.Clear();
|
SeriesQHline.Points.Add(new SeriesPoint(CoordinateParas.CoordMinQ, workPt.H));
|
SeriesQHline.Points.Add(new SeriesPoint(workPt.Q, workPt.H));
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 更新
|
|
//更新所有
|
public void UpdateChart(bool isCalcCoordinate = false)
|
{
|
//要依次更新
|
if (this.CurveInfoQH == null || this.CurveInfoQH.Count < 3)
|
return;
|
if (isCalcCoordinate || CoordinateParas == null)
|
{//不强迫计算,就用上次更新的坐标系
|
CalcCoordinate();
|
}
|
|
UpdateCoordinate();
|
|
UpdatePoints();
|
|
UpdateWorkParas();
|
|
if (isDispWorkPt && workPt != null && this.CurveInfoQH != null && this.CurveInfoQH.Count > 2)
|
{
|
if (workPt.Q < _CurveMaxQ && workPt.Q > _CurveMinQ)
|
{
|
SetWorkPointQ(workPt.Q);
|
}
|
}
|
}
|
|
/// <summary>
|
/// 计算坐标
|
/// </summary>
|
public void CalcCoordinate()
|
{
|
if (CurveInfoQH != null && CurveInfoQH.Count() > 3)
|
{
|
CoordinateParas = Model.CurveCoordinateParas.CalcCoordinate(CurveInfoQH, CurveInfoQE, CurveInfoQP);
|
|
_CurveMinQ = (from x in CurveInfoQH select x.X).Min();
|
_CurveMaxQ = (from x in CurveInfoQH select x.X).Max();
|
_CurveMinH = (from x in CurveInfoQH select x.Y).Min();
|
_CurveMaxH = (from x in CurveInfoQH select x.Y).Max();
|
}
|
else
|
{
|
CoordinateParas = GetBlankCoordinate();
|
if (_CurveMinQ > _CurveMaxQ - 1)
|
{
|
_CurveMinQ = _CurveMinQ * 0.8;
|
_CurveMaxQ = _CurveMaxQ * 1.2;
|
}
|
if (_CurveMinH > _CurveMaxH - 0.1)
|
{
|
_CurveMinH = _CurveMinH * 0.8;
|
_CurveMaxH = _CurveMaxH * 1.2;
|
}
|
}
|
}
|
|
//更新所有点
|
public void UpdatePoints()
|
{
|
if (this.CurveInfoQH == null || this.CurveInfoQH.Count < 3)
|
{
|
SeriesQHpoint.Visible = false;
|
SeriesQEpoint.Visible = false;
|
SeriesQPpoint.Visible = false;
|
|
SeriesQHcurve.Visible = false;
|
SeriesQEcurve.Visible = false;
|
SeriesQPcurve.Visible = false;
|
return;
|
}
|
|
if (_isDispCurrentPoint)
|
{
|
SeriesQHpoint.Visible = true;
|
SeriesQEpoint.Visible = true;
|
SeriesQPpoint.Visible = true;
|
}
|
else
|
{
|
SeriesQHpoint.Visible = false;
|
SeriesQEpoint.Visible = false;
|
SeriesQPpoint.Visible = false;
|
}
|
|
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 }));
|
}
|
|
DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPoint1 = TextAnnotationQH.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint;
|
paneAnchorPoint1.AxisXCoordinate.AxisValue = CurveInfoQH[CurveInfoQH.Count() - 2].X.ToString();
|
paneAnchorPoint1.AxisYCoordinate.AxisValue = CurveInfoQH[CurveInfoQH.Count() - 2].Y.ToString();
|
TextAnnotationQH.Visible = isDispCurveName;
|
}
|
else
|
{
|
SeriesQHcurve.Visible = false;
|
TextAnnoWorkPoint.Visible = false;
|
TextAnnotationQH.Visible = false;
|
WorkParasLine.Visible = false;
|
SeriesQHline.Visible = false;
|
SeriesQHcurve.Points.Clear();
|
}
|
|
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 }));
|
}
|
|
DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPoint2 = TextAnnotationQE.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint;
|
paneAnchorPoint2.AxisXCoordinate.AxisValue = CurveInfoQE[CurveInfoQE.Count() - 2].X.ToString();
|
paneAnchorPoint2.AxisYCoordinate.AxisValue = CurveInfoQE[CurveInfoQE.Count() - 2].Y.ToString();
|
TextAnnotationQE.Visible = isDispCurveName;
|
}
|
else
|
{
|
SeriesQEcurve.Visible = false;
|
TextAnnotationQE.Visible = false;
|
SeriesQEcurve.Points.Clear();
|
}
|
|
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 }));
|
}
|
|
DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPoint3 = TextAnnotationQP.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint;
|
paneAnchorPoint3.AxisXCoordinate.AxisValue = CurveInfoQP[CurveInfoQP.Count() - 2].X.ToString();
|
paneAnchorPoint3.AxisYCoordinate.AxisValue = CurveInfoQP[CurveInfoQP.Count() - 2].Y.ToString();
|
TextAnnotationQP.Visible = isDispCurveName;
|
}
|
else
|
{
|
SeriesQPcurve.Visible = false;
|
TextAnnotationQP.Visible = false;
|
SeriesQEcurve.Points.Clear();
|
}
|
}
|
|
//更新工作参数
|
public void UpdateWorkParas()
|
{
|
if (WorkParasLine == null)
|
return;
|
if (isDispWorkPt && this.CurveInfoQH != null && this.CurveInfoQH.Count > 3)
|
{
|
if (workPt.Q > 2)
|
{
|
WorkParasLine.AxisValue = workPt.Q;
|
WorkParasLine.Visible = true;
|
}
|
else
|
{
|
WorkParasLine.Visible = false;
|
}
|
}
|
else
|
{
|
WorkParasLine.Visible = false;
|
}
|
}
|
#endregion
|
|
#region 重绘
|
|
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;
|
chartControl1.DrawGridLineY(dxArgs, _coordinateParas, IStation.WinFrmUI.Curve.Cookie.ChartDisp.Default.GridLinesColorY, 0.2f, true);
|
}
|
|
#endregion
|
|
#region chartControl1
|
|
bool isMoveWorkRefLine = false;
|
bool isMoveSeriesQHline = false;
|
private void chartControl1_MouseDown(object sender, MouseEventArgs e)
|
{
|
if (e.Button == MouseButtons.Left)
|
{
|
ChartHitInfo hitInfo = chartControl1.CalcHitInfo(e.Location);
|
if (hitInfo.InConstantLine)
|
{
|
if (hitInfo.ConstantLine == WorkParasLine)
|
isMoveWorkRefLine = true;
|
}
|
else if (hitInfo.InSeries)
|
{
|
if (hitInfo.Series == SeriesQHline)
|
isMoveSeriesQHline = true;
|
}
|
else
|
{
|
DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
|
double refQ = coordPt.NumericalArgument;
|
double refH = coordPt.NumericalValue;
|
}
|
}
|
}
|
|
private void chartControl1_MouseMove(object sender, MouseEventArgs e)
|
{
|
if (isMoveWorkRefLine)
|
{
|
DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
|
double refQ = coordPt.NumericalArgument;
|
CalcWorkPtByQ(refQ);
|
SetQHLineByWorkPt();
|
}
|
else if (isMoveSeriesQHline)
|
{
|
DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
|
double refH = coordPt.NumericalValue;
|
double refQ = 0;
|
if (CalcWorkQByH(refH, ref refQ))
|
{
|
CalcWorkPtByQ(refQ);
|
SetQHLineByWorkPt();
|
}
|
}
|
}
|
|
private void chartControl1_MouseUp(object sender, MouseEventArgs e)
|
{
|
isMoveWorkRefLine = false;
|
isMoveSeriesQHline = false;
|
}
|
|
#endregion
|
|
/// <summary>
|
/// 获取空白坐标
|
/// </summary>
|
private Model.CurveCoordinateParas GetBlankCoordinate()
|
{
|
var para = new Model.CurveCoordinateParas();
|
para.GridNumberX = 30;
|
para.GridNumberY = 16;
|
|
//显示的坐标线号
|
para.StartLineNoH = 10;
|
para.EndLineNoH = 15;
|
|
para.StartLineNoE = 0;
|
para.EndLineNoE = 10;
|
|
para.StartLineNoP = 2;
|
para.EndLineNoP = 9;
|
|
//坐标最小值和间隔
|
para.CoordMinQ = 0; para.CoordSpaceQ = 1000;
|
para.CoordMinH = 10; para.CoordSpaceH = 100;
|
para.CoordMinE = 0; para.CoordSpaceE = 100;
|
para.CoordMinP = 10; para.CoordSpaceP = 100;
|
return para;
|
}
|
|
|
|
/// <summary>
|
/// 清除数据
|
/// </summary>
|
public void ClearData()
|
{
|
CurveExprQH = null; CurveInfoQH = null;
|
CurveExprQE = null; CurveInfoQE = null;
|
CurveExprQP = null; CurveInfoQP = null;
|
UpdatePoints();
|
}
|
|
/// <summary>
|
/// 导出Excel
|
/// </summary>
|
public void ExportExcel()
|
{
|
IStation.WinFrmUI.Curve.ExportToXLS.Export(this.CurveExprQH, this.CurveExprQE, this.CurveExprQP, 12);
|
}
|
}
|
}
|