using DevExpress.Utils;
|
using DevExpress.XtraCharts;
|
using Eventech.Model;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Drawing;
|
using System.Drawing.Drawing2D;
|
using System.Linq;
|
using System.Windows.Forms;
|
|
namespace IStation.WinFrmUI.Basic
|
{
|
public partial class ChartMultiCurveCompareCtrl : DevExpress.XtraEditors.XtraUserControl, Eventech.Model.IDispOperateInfo
|
{
|
public event Eventech.Model.DispOperateInfoHandler OnDispOperateInfo = null;
|
|
//public event TagEventHandler OnChangeQueryPtStatus = null;
|
public class CurrentViewModel
|
{
|
public long TestItemID { get; set; }
|
|
public CurveExpress CurveExpressQH { get; set; }
|
public CurveExpress CurveExpressQE { get; set; }
|
public CurveExpress CurveExpressQP { get; set; }
|
|
public List<Eventech.Model.FeatPoint> PointsQH { get; set; }
|
public List<Eventech.Model.FeatPoint> PointsQE { get; set; }
|
public List<Eventech.Model.FeatPoint> PointsQP { get; set; }
|
|
public bool IsDispCurveName { get; set; } = false;
|
|
public FeatPoint LabelPosiName { get; set; }
|
|
|
|
public string CurveName { get; set; }
|
public Color CurveColor
|
{
|
get
|
{
|
return _curveColor;
|
}
|
set
|
{
|
_curveColor = value;
|
}
|
}
|
protected Color _curveColor = Color.Black;
|
|
|
public eTextAligment LabelPosiNameAligment
|
{
|
get
|
{
|
return _labelPosiParaAligment;
|
}
|
set
|
{
|
_labelPosiParaAligment = value;
|
}
|
}
|
private eTextAligment _labelPosiParaAligment = eTextAligment.Left;
|
|
}
|
//泵的曲线
|
private List<CurrentViewModel> AllCurve = new List<CurrentViewModel>();
|
|
//private bool isDispCurvePoint = false;
|
|
private bool IsDisplayCurveQH = true;
|
private bool IsDisplayCurveQP = true;
|
private bool IsDisplayCurveQE = true;
|
|
private Dictionary<long, TextAnnotation> AnnoGuidDict_QH = new Dictionary<long, TextAnnotation>();
|
private Dictionary<long, TextAnnotation> AnnoGuidDict_QP = new Dictionary<long, TextAnnotation>();
|
|
//修改了查询点位置
|
public Action<long, Eventech.Model.GroupPoint> OnCalcQueryPtInfo = null;
|
|
|
#region CHART变量
|
|
//
|
private DevExpress.XtraCharts.XYDiagram mainChartDiagram = null;
|
|
private DevExpress.XtraCharts.XYDiagramPane bottomChartDiagram = null;
|
|
private DevExpress.XtraCharts.Series QueryLineHorizontal = null;
|
private DevExpress.XtraCharts.TextAnnotation QueryParaInfoText = null;
|
private DevExpress.XtraCharts.ConstantLine QueryLineVertical = null;
|
private DevExpress.XtraCharts.ConstantLine refConstantLineH = null;
|
|
private DevExpress.XtraCharts.Strip StripWorkRegion = null;
|
|
//
|
private AxisX AxisQ = null;
|
|
private AxisY QHAxisY = null;
|
private SecondaryAxisY QEAxisY = null;
|
private SecondaryAxisY QPAxisY = null;
|
private SecondaryAxisY NPSHAxisY = null;
|
|
private double _maxQ = 0, _minQ = 1000;
|
private double _maxH = 0, _minH = 1000;
|
private double _maxE = 100, _minE = 0;
|
private double _maxP = 0, _minP = 1000;
|
private double _maxNPSH = 0, _minNPSH = 1000;
|
|
//获取的最小扬程 用于计算坐标时放小的倍率
|
private double _scaleMinH = 1;
|
public double ChartScaleMinH
|
{
|
get { return _scaleMinH; }
|
set { _scaleMinH = value; }
|
}
|
|
private double _scaleMaxH = 1;
|
public double ChartScaleMaxH
|
{
|
get { return _scaleMaxH; }
|
set { _scaleMaxH = value; }
|
}
|
|
#endregion CHART变量
|
|
#region 构造函数和加载函数
|
|
public ChartMultiCurveCompareCtrl()
|
{
|
InitializeComponent();
|
|
var power_unit = Eventech.Model.UnitP.KW;
|
var flow_unit = Eventech.Model.UnitQ.M3H;
|
var head_unit = Eventech.Model.UnitH.M;
|
|
this.IsDisplayCurveQE = true;
|
this.IsDisplayCurveQP = true;
|
|
_queryInfo_unitQ = flow_unit;
|
_queryInfo_unitH = head_unit;
|
|
_coordinate_unitQ = flow_unit;
|
_coordinate_unitH = head_unit;
|
_coordinate_unitP = power_unit;
|
|
InitialChart();
|
}
|
|
private void LoadWindow(object sender, EventArgs e)
|
{
|
|
SetChartDisplay();
|
|
|
LocationDialog();
|
}
|
|
//翻译界面语言
|
private void LocationDialog()
|
{
|
this.查询曲线参数MenuItem.Text = "查询曲线参数";
|
this.设置曲线标签显示MenuItem.Text = "设置曲线标签";
|
this.设置图形显示Menu.Text = "设置图表显示";
|
this.调整坐标系Menu.Text = "设置图表坐标";
|
|
this.设置坐标AxisMenuItem.Text = "设置坐标";
|
this.显示坐标标签ItemMenu.Text = "显示坐标标签";
|
|
this.设置颜色AxisMenuItem.Text = "设置颜色";
|
this.颜色交织AxisMenuItem.Text = "颜色交织";
|
this.设置子刻度数AxisMenuItem.Text = "设置子刻度数";
|
this.MenuItemAnno修改内容.Text = "修改名称";
|
this.MenuItemAnno设置文字颜色.Text = "设置文字颜色";
|
this.MenuItemAnno设置背景色.Text = "设置背景色";
|
this.MenuItemAnno设置背景透明.Text = "设置背景透明";
|
this.设置颜色SeriesMenuItem.Text = "设置颜色";
|
this.设置宽度SeriesMenuItem.Text = "设置宽度";
|
this.设置线型SeriesMenuItem.Text = "设置线型";
|
this.设置颜色LineMenuItem.Text = "设置颜色";
|
this.设置值LineMenuItem.Text = "设置值";
|
|
//this.曲线显示ToolStripMenuItem.Text ="设置曲线显示";
|
//this.流量扬程曲线DispMenuItem.Text ="流量扬程曲线";
|
//this.流量效率曲线DispMenuItem.Text ="流量效率曲线";
|
//this.流量功率曲线DispMenuItem.Text ="流量功率曲线";
|
//this.流量汽蚀曲线DispMenuItem.Text ="流量汽蚀曲线";
|
}
|
|
|
private void InitialChart()
|
{
|
mainChartDiagram = (XYDiagram)chartControl1.Diagram;
|
for (int i = 0; i < mainChartDiagram.Panes.Count; i++)
|
{
|
var panel = mainChartDiagram.Panes[i];
|
if (panel.Name == "PaneBottom")
|
{
|
bottomChartDiagram = panel;
|
}
|
}
|
|
AxisQ = mainChartDiagram.AxisX;
|
QHAxisY = mainChartDiagram.AxisY;
|
QEAxisY = mainChartDiagram.SecondaryAxesY.GetAxisByName("QEAxisY");
|
QPAxisY = mainChartDiagram.SecondaryAxesY.GetAxisByName("QPAxisY");
|
NPSHAxisY = mainChartDiagram.SecondaryAxesY.GetAxisByName("NPSHAxisY");
|
|
AxisQ.NumericScaleOptions.AutoGrid = false;
|
AxisQ.VisualRange.Auto = false;
|
QHAxisY.VisualRange.Auto = false;
|
QHAxisY.NumericScaleOptions.AutoGrid = false;
|
QEAxisY.VisualRange.Auto = false;
|
QEAxisY.NumericScaleOptions.AutoGrid = false;
|
QPAxisY.VisualRange.Auto = false;
|
QPAxisY.NumericScaleOptions.AutoGrid = false;
|
NPSHAxisY.VisualRange.Auto = false;
|
NPSHAxisY.NumericScaleOptions.AutoGrid = false;
|
|
QueryLineHorizontal = chartControl1.Series["QueryLineHorizontal"];
|
QueryLineHorizontal.Visible = false;
|
QueryLineHorizontal.CrosshairHighlightPoints = DefaultBoolean.False;
|
QueryLineHorizontal.CrosshairEnabled = DefaultBoolean.False;
|
|
QueryLineVertical = (DevExpress.XtraCharts.ConstantLine)mainChartDiagram.AxisX.ConstantLines.GetElementByName("refConstantLineQ");
|
QueryLineVertical.Visible = false;
|
|
refConstantLineH = (DevExpress.XtraCharts.ConstantLine)mainChartDiagram.AxisY.ConstantLines.GetElementByName("refConstantLineH");
|
refConstantLineH.Visible = false;
|
|
QueryParaInfoText = chartControl1.AnnotationRepository[0] as DevExpress.XtraCharts.TextAnnotation;
|
QueryParaInfoText.Visible = false;
|
|
StripWorkRegion = AxisQ.Strips.GetStripByName("StripWorkRegion");
|
StripWorkRegion.Visible = false;
|
|
//设置此属性
|
this.chartControl1.SelectionMode = ElementSelectionMode.Single;// = true;// 表示可以选择CHART上物体
|
//this.chartControl1.SeriesSelectionMode = SeriesSelectionMode.Point;//系列选择是选择其中的点而不是整个系列
|
this.chartControl1.SeriesSelectionMode = SeriesSelectionMode.Series;
|
|
//添加事件
|
this.chartControl1.CustomPaint += new DevExpress.XtraCharts.CustomPaintEventHandler(this.chartControl_CustomPaint);
|
this.chartControl1.ObjectHotTracked += new DevExpress.XtraCharts.HotTrackEventHandler(this.chartControl1_ObjectHotTracked);
|
////this.chartControl1.MouseLeave += new System.EventHandler(this.chartControl1_MouseLeave);
|
this.chartControl1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chartControl_MouseMove);
|
this.chartControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chartControl_MouseUp);
|
this.chartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chartControl_MouseDown);
|
this.chartControl1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.chartControl_MouseClick);
|
this.chartControl1.LegendItemChecked += new DevExpress.XtraCharts.LegendItemCheckedEventHandler(this.chartControl1_LegendItemChecked);
|
|
this.AxisQ.Title.Text = string.Format("流量({0})",
|
Eventech.Common.UnitQHelper.GetEnUnitName(_coordinate_unitQ));
|
this.QPAxisY.Title.Text = string.Format("功率({0})",
|
Eventech.Common.UnitPHelper.GetEnUnitName(_coordinate_unitP));
|
}
|
|
|
#endregion 构造函数和加载函数
|
|
#region 坐标单位
|
protected Eventech.Model.UnitQ _queryInfo_unitQ = Eventech.Model.UnitQ.M3H;
|
protected Eventech.Model.UnitH _queryInfo_unitH = Eventech.Model.UnitH.M;//图表查询用的单位
|
|
|
//注意即使改了单位,曲线里面的数据没有变,只变化了图表的坐标显示
|
protected Eventech.Model.UnitQ _coordinate_unitQ = Eventech.Model.UnitQ.M3H;
|
protected Eventech.Model.UnitH _coordinate_unitH = Eventech.Model.UnitH.M;
|
protected Eventech.Model.UnitP _coordinate_unitP = Eventech.Model.UnitP.KW;
|
protected Eventech.Model.UnitH _coordinate_unitNPSH = Eventech.Model.UnitH.M;
|
|
|
|
//改变单位只改变了坐标显示,其他都没变
|
public double CalcDispValueQ(double q)
|
{
|
if (_coordinate_unitQ == Eventech.Model.UnitQ.M3H)
|
return q;
|
|
return Math.Round(Eventech.Common.UnitQHelper.fromM3H(_coordinate_unitQ, q), 2);
|
}
|
|
public string CalcDispValueQ_STR(double q)
|
{
|
if (_coordinate_unitQ != Eventech.Model.UnitQ.M3H)
|
{
|
q = Eventech.Common.UnitQHelper.fromM3H(_coordinate_unitQ, q);
|
}
|
|
if (q < 9)
|
return q.ToString("N2");
|
else
|
return q.ToString("N1");
|
}
|
|
public string CalcDispValueQ_STR(Eventech.Model.UnitQ UnitQ, double q)
|
{
|
if (_coordinate_unitQ != Eventech.Model.UnitQ.M3H)
|
{
|
q = Eventech.Common.UnitQHelper.fromM3H(UnitQ, q);
|
}
|
|
if (q < 5)
|
return q.ToString("N2");
|
else
|
return q.ToString("N1");
|
}
|
|
public double CalcDataValueQ(double q)
|
{
|
if (_coordinate_unitQ == Eventech.Model.UnitQ.M3H)
|
return q;
|
|
return Eventech.Common.UnitQHelper.toM3H(_coordinate_unitQ, q);
|
}
|
|
public double CalcDispValueH(double h)
|
{
|
if (_coordinate_unitH == Eventech.Model.UnitH.M)
|
return h;
|
else if (_coordinate_unitH == Eventech.Model.UnitH.MPa)
|
return Math.Round(Eventech.Common.UnitHHelper.fromM2(_coordinate_unitH, h), 4);
|
else
|
return Math.Round(Eventech.Common.UnitHHelper.fromM(_coordinate_unitH, h), 2);
|
}
|
|
public string CalcDispValueH_STR(double h)
|
{
|
if (_coordinate_unitH == Eventech.Model.UnitH.M)
|
return Math.Round(h, 1).ToString();
|
else if (_coordinate_unitH == Eventech.Model.UnitH.MPa)
|
return Math.Round(Eventech.Common.UnitHHelper.fromM2(_coordinate_unitH, h), 4).ToString();
|
else
|
{
|
var v = Eventech.Common.UnitHHelper.fromM2(_coordinate_unitH, h);
|
if (v > 100)
|
return Math.Round(v, 0).ToString();
|
else if (v > 10)
|
return Math.Round(v, 1).ToString();
|
else
|
return Math.Round(v, 2).ToString();
|
}
|
}
|
|
public string CalcDispValueH_STR(Eventech.Model.UnitH UnitH, double h)
|
{
|
if (UnitH == Eventech.Model.UnitH.M)
|
return Math.Round(h, 1).ToString();
|
else if (UnitH == Eventech.Model.UnitH.MPa)
|
return Math.Round(Eventech.Common.UnitHHelper.fromM2(UnitH, h), 4).ToString();
|
else
|
{
|
var v = Eventech.Common.UnitHHelper.fromM2(UnitH, h);
|
if (v > 100)
|
return Math.Round(v, 0).ToString();
|
else if (v > 10)
|
return Math.Round(v, 1).ToString();
|
else
|
return Math.Round(v, 2).ToString();
|
}
|
}
|
|
public double CalcDataValueH(double h)
|
{
|
if (_coordinate_unitH == Eventech.Model.UnitH.M)
|
return h;
|
else if (_coordinate_unitH == Eventech.Model.UnitH.MPa)
|
return Math.Round(Eventech.Common.UnitHHelper.toM2(_coordinate_unitH, h), 4);
|
else
|
return Math.Round(Eventech.Common.UnitHHelper.toM(_coordinate_unitH, h), 2);
|
}
|
|
public double CalcDispValueP(double power)
|
{
|
if (_coordinate_unitP == Eventech.Model.UnitP.KW)
|
return IStation.Common.RoundHelper.GetDispValuePower(power);
|
|
return IStation.Common.RoundHelper.GetDispValuePower(Eventech.Common.UnitPHelper.fromKW(_coordinate_unitP, power));
|
}
|
|
public double CalcDataValueP(double power)
|
{
|
if (_coordinate_unitP == Eventech.Model.UnitP.KW)
|
return power;
|
|
return Math.Round(Eventech.Common.UnitPHelper.toKW(_coordinate_unitP, power), 3);
|
}
|
public double CalcDispValueNPSH(double npsh)
|
{
|
if (_coordinate_unitNPSH == Eventech.Model.UnitH.M)
|
{
|
return IStation.Common.RoundHelper.GetDispValuePower(npsh);
|
}
|
|
var npsh2 = Eventech.Common.UnitHHelper.fromM2(_coordinate_unitNPSH, npsh);
|
return IStation.Common.RoundHelper.GetDispValuePower(npsh2);
|
}
|
#endregion 坐标单位
|
|
|
#region 设置曲线
|
|
public void AddTestItem(
|
IStation.Model.PumpCurve pumpCurve,
|
Color color)
|
{
|
if (pumpCurve == null)
|
return;
|
var curveInfo = pumpCurve.CurveInfo;
|
if (curveInfo == null)
|
return;
|
if (curveInfo.CurveQH == null)
|
return;
|
|
List<Eventech.Model.FeatPoint> PointInfoQH = new List<Eventech.Model.FeatPoint>();
|
List<Eventech.Model.FeatPoint> PointInfoQE = new List<Eventech.Model.FeatPoint>();
|
List<Eventech.Model.FeatPoint> PointInfoQP = new List<Eventech.Model.FeatPoint>();
|
|
if (curveInfo.CurveQH.DefinePoints != null)
|
{
|
PointInfoQH = curveInfo.CurveQH.DefinePoints.Select(x => new FeatPoint(x.X, x.Y)).ToList();
|
}
|
else
|
{
|
PointInfoQH = curveInfo.CurveQH.GetFitPoints(12)?.Select(x => new FeatPoint(x.X, x.Y)).ToList();
|
}
|
|
if (curveInfo.CurveQE != null)
|
if (curveInfo.CurveQE.DefinePoints != null)
|
{
|
PointInfoQE = curveInfo.CurveQE.DefinePoints.Select(x => new FeatPoint(x.X, x.Y)).ToList();
|
}
|
else
|
{
|
PointInfoQE = curveInfo.CurveQE.GetFitPoints(12)?.Select(x => new FeatPoint(x.X, x.Y)).ToList();
|
}
|
|
if (curveInfo.CurveQP != null)
|
if (curveInfo.CurveQP.DefinePoints != null)
|
{
|
PointInfoQP = curveInfo.CurveQP.DefinePoints.Select(x => new FeatPoint(x.X, x.Y)).ToList();
|
}
|
else
|
{
|
PointInfoQP = curveInfo.CurveQP.GetFitPoints(12)?.Select(x => new FeatPoint(x.X, x.Y)).ToList();
|
}
|
|
|
CurrentViewModel curve = new CurrentViewModel();
|
curve.TestItemID = pumpCurve.ID;
|
curve.PointsQH = PointInfoQH;
|
curve.PointsQE = PointInfoQE;
|
curve.PointsQP = PointInfoQP;
|
|
if (PointInfoQH.Any())
|
{
|
var fitType = (Eventech.Model.eCurveFitType)curveInfo.CurveQH.FitType;
|
if (fitType == Eventech.Model.eCurveFitType.FourM)
|
{
|
if (PointInfoQH.Count >= 5)
|
{
|
curve.CurveExpressQH = new Eventech.Model.CurveExpress(PointInfoQH, fitType, false);
|
}
|
}
|
else if (fitType == (int)Eventech.Model.eCurveFitType.CubicCurve)
|
{
|
if (PointInfoQH.Count >= 4)
|
{
|
curve.CurveExpressQH = new Eventech.Model.CurveExpress(PointInfoQH, fitType, false);
|
}
|
}
|
else
|
{
|
if (PointInfoQH.Count >= 3)
|
{
|
curve.CurveExpressQH = new Eventech.Model.CurveExpress(PointInfoQH, fitType, true);
|
}
|
}
|
}
|
|
|
if (PointInfoQE.Any())
|
{
|
var fitType = (Eventech.Model.eCurveFitType)curveInfo.CurveQE.FitType;
|
if (fitType == Eventech.Model.eCurveFitType.FourM)
|
{
|
if (PointInfoQE.Count >= 5)
|
{
|
curve.CurveExpressQE = new Eventech.Model.CurveExpress(PointInfoQE, fitType, false);
|
}
|
}
|
else if (fitType == Eventech.Model.eCurveFitType.CubicCurve)
|
{
|
if (PointInfoQE.Count >= 4)
|
{
|
curve.CurveExpressQE = new Eventech.Model.CurveExpress(PointInfoQE, fitType, false);
|
}
|
}
|
else
|
{
|
if (PointInfoQE.Count >= 3)
|
{
|
curve.CurveExpressQE = new Eventech.Model.CurveExpress(PointInfoQE, fitType, true);
|
}
|
}
|
}
|
|
if (PointInfoQP.Any())
|
{
|
var fitType = (Eventech.Model.eCurveFitType)curveInfo.CurveQP.FitType;
|
if (fitType == Eventech.Model.eCurveFitType.FourM)
|
{
|
if (PointInfoQP.Count >= 5)
|
{
|
curve.CurveExpressQP = new Eventech.Model.CurveExpress(PointInfoQP, fitType, false);
|
}
|
}
|
else if (fitType == Eventech.Model.eCurveFitType.CubicCurve)
|
{
|
if (PointInfoQP.Count >= 4)
|
{
|
curve.CurveExpressQP = new Eventech.Model.CurveExpress(PointInfoQP, fitType, false);
|
}
|
}
|
else
|
{
|
if (PointInfoQP.Count >= 3)
|
{
|
curve.CurveExpressQP = new Eventech.Model.CurveExpress(PointInfoQP, fitType, true);
|
}
|
}
|
}
|
|
|
|
curve.CurveColor = color;
|
|
AllCurve.Add(curve);
|
CalcCoordLimit();
|
UpdateChart(true);
|
}
|
|
|
//清理曲线
|
public void DeleteTestItem(long id)
|
{
|
var qh = from x in AllCurve where x.TestItemID == id select x;
|
if (qh.Count() != 0)
|
{
|
var c = qh.First();
|
AllCurve.Remove(c);
|
UpdateAllCurve();
|
}
|
}
|
public void SetCurveColor(long id, Color color)
|
{
|
for (int i = this.chartControl1.SeriesSerializable.Count() - 1; i >= 0; i--)
|
{
|
var series = this.chartControl1.Series[i];//.RemoveAt(iExcelCol);
|
if (series.Tag == null)
|
continue;
|
|
if (series.Tag.ToString() == id.ToString())
|
{
|
series.View.Color = color;
|
}
|
}
|
}
|
public void ClearAllCurves()
|
{
|
ClearCurveSeries();
|
|
AllCurve.Clear();
|
}
|
|
private void ClearCurveSeries()
|
{
|
foreach (var anno in AnnoGuidDict_QH.Values)
|
{
|
this.chartControl1.AnnotationRepository.Remove(anno);
|
}
|
foreach (var anno in AnnoGuidDict_QP.Values)
|
{
|
this.chartControl1.AnnotationRepository.Remove(anno);
|
}
|
|
AnnoGuidDict_QH.Clear();
|
AnnoGuidDict_QP.Clear();
|
|
|
for (int i = this.chartControl1.SeriesSerializable.Count() - 1; i >= 0; i--)
|
{
|
var series = this.chartControl1.Series[i];//.RemoveAt(iExcelCol);
|
if (series.Name == "QueryLineHorizontal")
|
continue;
|
if (series.Name.StartsWith("QH_") || series.Name.StartsWith("QE_") || series.Name.StartsWith("QP_") || series.Name.StartsWith("QNPSH_"))
|
{
|
i++;
|
if (i > this.chartControl1.SeriesSerializable.Count() - 1)
|
i = this.chartControl1.SeriesSerializable.Count() - 1;
|
this.chartControl1.Series.Remove(series);
|
}
|
}
|
|
//for (int i = this.chartControl1.AnnotationRepository.Count - 1; i >= 0; i--)
|
//{
|
// var anno = this.chartControl1.AnnotationRepository[i];
|
// if (anno.Name == "QueryParaInfoText")
|
// continue;
|
// if (anno.Name.StartsWith("QH_") || anno.Name.StartsWith("QE_") || anno.Name.StartsWith("QP_") || anno.Name.StartsWith("QNPSH_"))
|
// {
|
// i++;
|
// if (i > this.chartControl1.AnnotationRepository.Count - 1)
|
// i = this.chartControl1.AnnotationRepository.Count - 1;
|
// this.chartControl1.AnnotationRepository.Remove(anno);
|
// }
|
//}
|
}
|
|
#endregion 设置曲线
|
|
|
|
|
#region 查询点
|
|
//是否可以查询曲线参数
|
private bool _isQueryCurvePara = false;
|
|
public bool IsQueryCurvePara
|
{
|
set
|
{
|
_isQueryCurvePara = value;
|
QueryLineVertical.Visible = _isQueryCurvePara;
|
QueryLineVertical.Title.Visible = _isQueryCurvePara;
|
QueryParaInfoText.Visible = _isQueryCurvePara;
|
QueryLineHorizontal.Visible = _isQueryCurvePara;
|
}
|
get
|
{
|
return _isQueryCurvePara;
|
}
|
}
|
|
#endregion 查询点
|
|
|
#region 坐标
|
|
private Eventech.Model.LxpCoordinateParas _coordinateParas = null;
|
|
|
//计算最大最小值
|
private void CalcCoordLimit()
|
{
|
_maxQ = 0; _minQ = 1000000;
|
_maxH = 0; _minH = 1000000;
|
_maxE = 0; _minE = 0;
|
_maxP = 0; _minP = 100000;
|
_maxNPSH = 0; _minNPSH = 1000;
|
foreach (CurrentViewModel info in AllCurve)
|
{
|
var xxx = info.PointsQH.Select(x => x.X);
|
var yyy = info.PointsQH.Select(x => x.Y);
|
|
_minQ = Math.Min(_minQ, xxx.Min());
|
_maxQ = Math.Max(_maxQ, xxx.Max());
|
|
_minH = Math.Min(_minH, yyy.Min());
|
_maxH = Math.Max(_maxH, yyy.Max());
|
}
|
|
foreach (CurrentViewModel info in AllCurve)
|
{
|
var yyy = info.PointsQE.Select(x => x.Y);
|
|
|
//minE = Math.Min(minE, (from posi_off in pumpStr.CurveQE select posi_off.Y).Min());
|
_maxE = Math.Max(_maxE, yyy.Max());
|
}
|
foreach (CurrentViewModel info in AllCurve)
|
{
|
var yyy = info.PointsQP.Select(x => x.Y);
|
|
|
_minP = Math.Min(_minP, yyy.Min());
|
_maxP = Math.Max(_maxP, yyy.Max());
|
}
|
|
}
|
|
//计算坐标
|
public void CalcCoordinate()
|
{
|
if (AllCurve == null || AllCurve.Count() == 0)
|
return;
|
//
|
CalcCoordLimit();
|
|
_coordinateParas = Eventech.Common.CoordinateHelper.CalcCoordinate(
|
_minQ, _maxQ, this._coordinate_unitQ, _minH * _scaleMinH, _maxH * _scaleMaxH, this._coordinate_unitH, _minE, _maxE,
|
_minP, _maxP, this._coordinate_unitP, _minNPSH, _maxNPSH);
|
if (_coordinateParas == null)
|
return;
|
if (_coordinateParas.CoordMinQ + _coordinateParas.CoordSpaceQ * this._coordinateParas.GridNumberX < _maxQ * 1.05)
|
{
|
_coordinateParas.GridNumberX++;
|
}
|
|
if (QueryLineVertical != null && _coordinateParas != null)
|
{
|
|
if (QueryLineVertical.AxisValue != null)
|
{
|
var query_q = Convert.ToDouble(QueryLineVertical.AxisValue);
|
if (query_q <= _coordinateParas.CoordMinQ + _coordinateParas.CoordSpaceQ ||
|
query_q >= _coordinateParas.DispMaxQ() - _coordinateParas.CoordSpaceQ)
|
{
|
QueryLineVertical.AxisValue = (_coordinateParas.CoordMinQ + _coordinateParas.DispMaxQ()) * 0.5;
|
}
|
}
|
|
}
|
|
}
|
|
//更新坐标
|
public bool UpdateCoordinate()
|
{
|
if (_coordinateParas == null)
|
return false;
|
if (this._minH > this._maxH)
|
{
|
this.CalcCoordLimit();
|
}
|
|
if (_coordinateParas.CoordSpaceQ < 0.01)
|
{
|
return false;
|
}
|
if (_coordinateParas.CoordSpaceH < 0.01)
|
{
|
return false;
|
}
|
|
// 流量坐标刻度
|
List<CustomAxisLabel> q_Label_List = new List<CustomAxisLabel>();
|
AxisQ.CustomLabels.Clear();
|
AxisQ.Label.Visible = true;
|
double disQ = _coordinateParas.CoordMinQ;
|
for (int i = 0; i < _coordinateParas.GridNumberX + 1; i++)
|
{
|
q_Label_List.Add(new CustomAxisLabel(CalcDispValueQ(disQ).ToString(), disQ));
|
disQ = disQ + _coordinateParas.CoordSpaceQ;
|
}
|
AxisQ.CustomLabels.AddRange(q_Label_List.ToArray());
|
|
//设置显示
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(AxisQ, _coordinateParas.CoordMinQ,
|
_coordinateParas.CoordMinQ + _coordinateParas.GridNumberX * _coordinateParas.CoordSpaceQ);
|
|
//子刻度
|
AxisQ.MinorCount = 4;
|
//扬程
|
|
//坐标刻度
|
QHAxisY.CustomLabels.Clear();
|
List<CustomAxisLabel> h_Label_List = new List<CustomAxisLabel>();
|
double disH = _coordinateParas.CoordMinH + _coordinateParas.CoordSpaceH * _coordinateParas.StartLineNoH;
|
for (int i = _coordinateParas.StartLineNoH; i < _coordinateParas.EndLineNoH + 1; i++)
|
{
|
if (disH >= 0)
|
{
|
h_Label_List.Add(new CustomAxisLabel(CalcDispValueH(disH).ToString(), disH));
|
}
|
|
disH = disH + _coordinateParas.CoordSpaceH;
|
}
|
QHAxisY.CustomLabels.AddRange(h_Label_List.ToArray());
|
|
//子刻度
|
QHAxisY.MinorCount = 4;
|
|
|
//效率
|
if (_minE < _maxE)
|
{
|
//坐标刻度
|
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 <= 100 ? disE.ToString() : "", disE));
|
disE = disE + _coordinateParas.CoordSpaceE;
|
}
|
QEAxisY.CustomLabels.AddRange(E_Label_List.ToArray());
|
|
//子刻度
|
QEAxisY.MinorCount = 4;
|
}
|
|
//功率
|
if (_minP < _maxP)
|
{
|
//坐标刻度
|
QPAxisY.CustomLabels.Clear();
|
List<CustomAxisLabel> P_Label_List = new List<CustomAxisLabel>();
|
double disP = Math.Round(_coordinateParas.CoordMinP + _coordinateParas.CoordSpaceP * _coordinateParas.StartLineNoP, 4);//防止小数点过多
|
for (int i = _coordinateParas.StartLineNoP; i < _coordinateParas.EndLineNoP + 1; i++)
|
{
|
var coord_P = CalcDispValueP(disP);
|
P_Label_List.Add(new CustomAxisLabel(coord_P < 0.001 ? "0" : Math.Round(coord_P, 4).ToString("g"), disP));//改变单位只改变了坐标显示,其他都没变
|
disP = disP + _coordinateParas.CoordSpaceP;
|
}
|
QPAxisY.CustomLabels.AddRange(P_Label_List.ToArray());
|
|
//子刻度
|
QPAxisY.MinorCount = 4;
|
}
|
|
//汽蚀
|
if (_minNPSH < _maxNPSH)
|
{
|
//坐标刻度
|
NPSHAxisY.CustomLabels.Clear();
|
List<CustomAxisLabel> NPSH_Label_List = new List<CustomAxisLabel>();
|
double dispNPSH = _coordinateParas.CoordMinNPSH + _coordinateParas.CoordSpaceNPSH * _coordinateParas.StartLineNoNPSH;
|
for (int i = _coordinateParas.StartLineNoNPSH; i < _coordinateParas.EndLineNoNPSH + 1; i++)
|
{
|
if (dispNPSH >= 0)
|
{
|
NPSH_Label_List.Add(new CustomAxisLabel(dispNPSH.ToString(), dispNPSH));
|
}
|
|
dispNPSH = dispNPSH + _coordinateParas.CoordSpaceNPSH;
|
}
|
NPSHAxisY.CustomLabels.AddRange(NPSH_Label_List.ToArray());
|
//子刻度
|
NPSHAxisY.MinorCount = 4;
|
}
|
|
return true;
|
}
|
|
//检查坐标
|
private void CheckCoordinate()
|
{
|
if (_coordinateParas == null)
|
return;
|
|
|
|
if (this._maxH > this._minH)
|
{
|
var old_count = this._coordinateParas.EndLineNoH - this._coordinateParas.StartLineNoH;
|
|
for (int i = 0; i < 100; i++)
|
{
|
if (this._coordinateParas.DispMinH() < this._minH)
|
break;
|
//this._coordinateParas.StartLineNoH = this._coordinateParas.StartLineNoH - 1;
|
if (this._coordinateParas.StartLineNoH <= 0)
|
{
|
this._coordinateParas.CoordMinH = this._coordinateParas.CoordMinH - this._coordinateParas.CoordSpaceH;
|
}
|
else
|
{
|
this._coordinateParas.StartLineNoH--;
|
}
|
}
|
|
for (int i = 3; i < 100; i++)
|
{
|
if (this._coordinateParas.DispMaxH() > this._maxH)
|
break;
|
|
this._coordinateParas.EndLineNoH = this._coordinateParas.StartLineNoH + i;
|
}
|
|
if ((this._coordinateParas.EndLineNoH - this._coordinateParas.StartLineNoH) > old_count * 1.5 || this._coordinateParas.DispMaxH() > this._maxH * 1.4)
|
{
|
double disp_max_h, disp_min_h;
|
Eventech.Common.CoordinateHelper.CalcCoordinateH2(this._minH, this._maxH, this._coordinate_unitH,
|
old_count,
|
ref this._coordinateParas, out disp_min_h, out disp_max_h);
|
|
|
_coordinateParas.CoordMinH = Eventech.Common.NumberHelper.GetByPlacesLength(disp_max_h - _coordinateParas.EndLineNoH * _coordinateParas.CoordSpaceH, 3);
|
}
|
}
|
|
|
|
|
if (this._maxP > this._minP)
|
{
|
var old_count = this._coordinateParas.EndLineNoP - this._coordinateParas.StartLineNoP;
|
for (int i = 0; i < 100; i++)
|
{
|
if (this._coordinateParas.DispMinP() < this._minP)
|
break;
|
//
|
if (this._coordinateParas.StartLineNoP <= 0)
|
this._coordinateParas.CoordMinP = this._coordinateParas.CoordMinP - this._coordinateParas.CoordSpaceP;
|
else
|
this._coordinateParas.StartLineNoP = this._coordinateParas.StartLineNoP - 1;
|
|
}
|
|
for (int i = 3; i < 100; i++)
|
{
|
if (this._coordinateParas.DispMaxP() > this._maxP)
|
break;
|
|
this._coordinateParas.EndLineNoP = this._coordinateParas.StartLineNoP + i;
|
}
|
if ((this._coordinateParas.EndLineNoP - this._coordinateParas.StartLineNoP) > old_count * 1.5 || this._coordinateParas.DispMaxP() > this._maxP * 1.4)
|
{
|
double disp_max_p, disp_min_p;
|
var space = Eventech.Common.CoordinateHelper.GetOptimalSpaceMin(this._minP, this._maxP, old_count, out disp_min_p, out disp_max_p);
|
|
this._coordinateParas.CoordSpaceP = space;
|
//
|
double disP = disp_max_p;
|
this._coordinateParas.EndLineNoP = this._coordinateParas.StartLineNoH - 5;
|
this._coordinateParas.StartLineNoP = this._coordinateParas.EndLineNoP;
|
while (disP > this._minP * 0.98)
|
{
|
disP = disP - space;
|
if (disP < 0)
|
break;
|
this._coordinateParas.StartLineNoP--;
|
}
|
this._coordinateParas.CoordMinP = Eventech.Common.NumberHelper.GetByPlacesLength(disp_max_p - this._coordinateParas.EndLineNoP * this._coordinateParas.CoordSpaceP, 3);
|
}
|
}
|
|
|
|
if (this._maxQ > this._minQ)
|
{
|
var old_count = this._coordinateParas.GridNumberX;
|
for (int i = 3; i < 100; i++)
|
{
|
if (this._coordinateParas.DispMaxQ() > this._maxQ)
|
break;
|
|
this._coordinateParas.GridNumberX = this._coordinateParas.GridNumberX + 1;
|
}
|
if (this._coordinateParas.GridNumberX > old_count * 1.3 || this._coordinateParas.DispMaxQ() > this._maxQ * 1.4)
|
{
|
Eventech.Common.CoordinateHelper.CalcCoordinateQ1(this._minQ, this._maxQ, this._coordinate_unitQ, ref this._coordinateParas, old_count);
|
}
|
}
|
|
|
}
|
|
|
private void 调整坐标系MenuItem_Click(object sender, EventArgs e)
|
{
|
SetCoordinateByDlg();
|
}
|
|
public void SetCoordinateByDlg()
|
{
|
SetLxpCoordinateDlg theSetDlg = new SetLxpCoordinateDlg();
|
theSetDlg.SetCoordinate(_coordinateParas, this._coordinate_unitQ, this._coordinate_unitH, this._coordinate_unitP);
|
theSetDlg.OnChangedCoord += ChangedCoordHandler;
|
theSetDlg.ShowDialog();
|
}
|
|
private void ChangedCoordHandler(object sender, LxpCoordEventArgs e)
|
{
|
//if (e.IsChangeUnitQ)
|
//{
|
// UpdateChart(false);
|
//}
|
//else
|
{
|
UpdateCoordinate();
|
SetChartPanelStyle();
|
SetChartCurveStyle();
|
}
|
}
|
|
public Eventech.Model.LxpCoordinateParas GetCoordinateParas()
|
{
|
return _coordinateParas;
|
}
|
|
#endregion 坐标
|
|
#region 更新
|
|
//更新所有
|
public void UpdateChart(bool isCheckCoord)
|
{
|
if (_coordinateParas == null || _coordinateParas.CoordSpaceQ < .1 || _coordinateParas.CoordSpaceQ < 0.1)
|
{
|
CalcCoordinate();
|
}
|
|
if (isCheckCoord)
|
{
|
CheckCoordinate();
|
}
|
|
|
if (!UpdateCoordinate())
|
return;
|
|
UpdateAllCurve();
|
|
SetChartPanelStyle();
|
|
SetChartCurveStyle();
|
|
SetAxisTitleDispH();
|
}
|
|
|
//更新所有曲线
|
public void UpdateAllCurve()
|
{
|
ClearCurveSeries();
|
|
if (AllCurve == null || AllCurve.Count == 0)
|
{
|
QueryLineHorizontal.Visible = false;
|
QueryLineVertical.Visible = false;
|
refConstantLineH.Visible = false;
|
QueryParaInfoText.Visible = false;
|
return;
|
}
|
|
|
int i = 0;
|
for (i = 0; i < AllCurve.Count; i++)
|
{
|
CreateSeriesQH(AllCurve[i]);
|
|
CreateSeriesQE(AllCurve[i]);
|
|
CreateSeriesQP(AllCurve[i]);
|
}
|
|
|
}
|
|
|
//插入QH曲线
|
private void CreateSeriesQH(CurrentViewModel curve)
|
{
|
DevExpress.XtraCharts.Series series_curve = new DevExpress.XtraCharts.Series();
|
series_curve.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
series_curve.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
|
series_curve.Name = "QH_CURVE_" + curve.TestItemID.ToString();
|
series_curve.ShowInLegend = false;
|
series_curve.CrosshairEnabled = DefaultBoolean.False;
|
series_curve.Tag = curve.TestItemID.ToString();
|
|
DevExpress.XtraCharts.SplineSeriesView splineSeriesView = new DevExpress.XtraCharts.SplineSeriesView();
|
splineSeriesView.LineStyle.Thickness = 2;
|
//splineSeriesView.LineStyle.DashStyle = (DevExpress.XtraCharts.DashStyle)curve.CurveDashStyle;
|
splineSeriesView.Color = curve.CurveColor;
|
|
series_curve.SeriesPointsSorting = SortingMode.None;
|
series_curve.SeriesPointsSortingKey = SeriesPointKey.Value_1;
|
series_curve.Visible = IsDisplayCurveQH;
|
series_curve.View = splineSeriesView;
|
|
Eventech.Model.FeatPointList points =
|
Eventech.Common.FitCurveHelper.GetFitPoints(curve.CurveExpressQH, 12);
|
|
for (int j = 0; j < points.Count; j++)
|
{
|
series_curve.Points.Add(new SeriesPoint(points[j].X, new double[] { points[j].Y }));
|
}
|
|
this.chartControl1.Series.Add(series_curve);
|
|
//if (isDispCurvePoint)
|
//{
|
// DevExpress.XtraCharts.Series series_point = new DevExpress.XtraCharts.Series();
|
// series_point.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
// series_point.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
|
// series_point.Name = "QH_Point_" + nameAppend;
|
// series_point.ShowInLegend = false;
|
// series_point.CrosshairEnabled = DefaultBoolean.False;
|
// series_point.Tag = curve.TestItemID;
|
|
// DevExpress.XtraCharts.PointSeriesView pointSeriesView = new DevExpress.XtraCharts.PointSeriesView();
|
// pointSeriesView.Color = curve.CurveColor;
|
|
// series_point.View = pointSeriesView;
|
// this.chartControl1.Series.Add(series_point);
|
|
// for (int j = 0; j < points.Count(); j++)
|
// {
|
// series_point.Points.Add(new SeriesPoint(points[j].X, new double[] { points[j].Y }));
|
// }
|
//}
|
|
//if (curve.IsDispPara && curve.LabelPosiPara != null && !string.IsNullOrEmpty(curve.CurvePara))
|
//{
|
// DevExpress.XtraCharts.TextAnnotation annotationText = new DevExpress.XtraCharts.TextAnnotation();
|
|
// DevExpress.XtraCharts.PaneAnchorPoint ptPaneAnchor = new DevExpress.XtraCharts.PaneAnchorPoint();
|
// ptPaneAnchor.AxisXCoordinate.AxisValueSerializable = curve.LabelPosiPara.X.ToString();
|
// ptPaneAnchor.AxisYCoordinate.AxisValueSerializable = curve.LabelPosiPara.Y.ToString();
|
// annotationText.AnchorPoint = ptPaneAnchor;
|
|
// annotationText.BackColor = Color.Transparent;
|
// annotationText.TextColor = Color.LightGray;
|
// annotationText.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
// annotationText.LabelMode = false;
|
// annotationText.RuntimeAnchoring = true;
|
// annotationText.RuntimeMoving = true;
|
// annotationText.RuntimeResizing = true;
|
// annotationText.RuntimeRotation = true;
|
// annotationText.Name = "QH_" + nameAppend;
|
|
// DevExpress.XtraCharts.RelativePosition relativePosition1 = new DevExpress.XtraCharts.RelativePosition();
|
// relativePosition1.Angle = 90D;
|
// relativePosition1.ConnectorLength = 12;
|
// annotationText.ShapePosition = relativePosition1;
|
|
// annotationText.Visible = true;
|
// annotationText.Text = curve.CurvePara;
|
// annotationText.TextColor = curve.CurveColor;
|
// annotationText.BackColor = System.Drawing.Color.Transparent;
|
// annotationText.Shadow.Visible = false;
|
|
// //annotationText.Border.Color = Curve.CurveColor;
|
// this.chartControl1.AnnotationRepository.Add(annotationText);
|
|
// AnnoGuidDict_QH[curve.TestItemID] = annotationText;
|
//}
|
}
|
|
//插入QE曲线
|
public void CreateSeriesQE(CurrentViewModel curve)
|
{
|
DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
|
series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
|
series.Name = "QE_CURVE_" + curve.TestItemID.ToString();
|
series.ShowInLegend = false;
|
series.CrosshairEnabled = DefaultBoolean.False;
|
series.Tag = curve.TestItemID.ToString();
|
|
DevExpress.XtraCharts.SplineSeriesView splineSeriesView = new DevExpress.XtraCharts.SplineSeriesView();
|
splineSeriesView.Color = curve.CurveColor;
|
splineSeriesView.LineStyle.Thickness = 2;
|
//splineSeriesView.LineStyle.DashStyle = (DevExpress.XtraCharts.DashStyle)curve.CurveDashStyle;
|
splineSeriesView.AxisY = QEAxisY;//.AxisYName = "QEAxisY";
|
|
series.View = splineSeriesView;
|
this.chartControl1.Series.Add(series);
|
|
Eventech.Model.FeatPointList points =
|
Eventech.Common.FitCurveHelper.GetFitPoints(curve.CurveExpressQE, 12);
|
|
for (int j = 0; j < points.Count(); j++)
|
{
|
series.Points.Add(new SeriesPoint(points[j].X, new double[] { points[j].Y }));
|
}
|
|
series.Visible = IsDisplayCurveQE;
|
|
}
|
|
//更新QP曲线
|
public void CreateSeriesQP(CurrentViewModel curve)
|
{
|
DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
|
series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
|
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
|
series.Name = "QP_CURVE_" + curve.TestItemID.ToString();
|
series.ShowInLegend = false;
|
series.CrosshairEnabled = DefaultBoolean.False;
|
series.Tag = curve.TestItemID.ToString();
|
|
DevExpress.XtraCharts.SplineSeriesView splineSeriesView = new DevExpress.XtraCharts.SplineSeriesView();
|
splineSeriesView.Color = curve.CurveColor;
|
splineSeriesView.LineStyle.Thickness = 2;
|
//splineSeriesView.LineStyle.DashStyle = (DevExpress.XtraCharts.DashStyle)curve.CurveDashStyle;
|
splineSeriesView.AxisY = QPAxisY;//.AxisYName = "QEAxisY";
|
if (_chartPanelStyle == IStation.Model.eChartDiagramPanelStyle.Whole)
|
{//
|
splineSeriesView.Pane = mainChartDiagram.DefaultPane;
|
}
|
else
|
{//分开放
|
splineSeriesView.Pane = this.bottomChartDiagram;
|
}
|
series.View = splineSeriesView;
|
|
this.chartControl1.Series.Add(series);
|
|
Eventech.Model.FeatPointList points =
|
Eventech.Common.FitCurveHelper.GetFitPoints(curve.CurveExpressQP, 12);
|
for (int j = 0; j < points.Count(); j++)
|
{
|
series.Points.Add(new SeriesPoint(points[j].X, new double[] { points[j].Y }));
|
}
|
|
series.Visible = this.IsDisplayCurveQP;
|
|
|
//if (curve.IsDispPara && curve.LabelPosiPara != null && !string.IsNullOrEmpty(curve.CurvePara))
|
//{
|
// DevExpress.XtraCharts.TextAnnotation annotationText = new DevExpress.XtraCharts.TextAnnotation();
|
// if (_chartPanelStyle == IStation.Model.eChartDiagramPanelStyle.Whole)
|
// {
|
// DevExpress.XtraCharts.PaneAnchorPoint ptPaneAnchor = new DevExpress.XtraCharts.PaneAnchorPoint();
|
// ptPaneAnchor.AxisXCoordinate.AxisValueSerializable = curve.LabelPosiPara.X.ToString();
|
// ptPaneAnchor.AxisYCoordinate.AxisValueSerializable = curve.LabelPosiPara.Y.ToString();
|
// ptPaneAnchor.AxisYCoordinate.Axis = this.QPAxisY;
|
// annotationText.AnchorPoint = ptPaneAnchor;
|
// }
|
// else
|
// {
|
// DevExpress.XtraCharts.PaneAnchorPoint ptPaneAnchor = new DevExpress.XtraCharts.PaneAnchorPoint();
|
// ptPaneAnchor.AxisXCoordinate.AxisValueSerializable = curve.LabelPosiPara.X.ToString();
|
// ptPaneAnchor.AxisYCoordinate.AxisValueSerializable = curve.LabelPosiPara.Y.ToString();
|
// ptPaneAnchor.AxisYCoordinate.Axis = this.QPAxisY;
|
// ptPaneAnchor.Pane = this.bottomChartDiagram;
|
// annotationText.AnchorPoint = ptPaneAnchor;
|
// }
|
|
// annotationText.BackColor = Color.Transparent;
|
// annotationText.TextColor = Color.LightGray;
|
// annotationText.Border.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
// annotationText.LabelMode = false;
|
// annotationText.RuntimeAnchoring = true;
|
// annotationText.RuntimeMoving = true;
|
// annotationText.RuntimeResizing = true;
|
// annotationText.RuntimeRotation = true;
|
// annotationText.Name = "QP_" + nameAppend;
|
|
// DevExpress.XtraCharts.RelativePosition relativePosition1 = new DevExpress.XtraCharts.RelativePosition();
|
// relativePosition1.Angle = 0D;
|
// relativePosition1.ConnectorLength = 25;
|
// annotationText.ShapePosition = relativePosition1;
|
|
// annotationText.Visible = true;
|
// annotationText.Text = curve.CurvePara;
|
// annotationText.TextColor = curve.CurveColor;
|
// annotationText.BackColor = System.Drawing.Color.Transparent;
|
// annotationText.Shadow.Visible = false;
|
|
// //annotationText.Border.Color = Curve.CurveColor;
|
// this.chartControl1.AnnotationRepository.Add(annotationText);
|
|
// AnnoGuidDict_QP[curve.TestItemID] = annotationText;
|
//}
|
}
|
|
|
//
|
public void RefreshChart()
|
{
|
chartControl1.Refresh();
|
}
|
|
#endregion 更新
|
|
|
#region 重绘
|
|
private Rectangle CalculateDiagramBounds()
|
{
|
return CalculateDiagramBounds(mainChartDiagram.AxisX.VisualRange, mainChartDiagram.AxisY.VisualRange);
|
}
|
|
private Rectangle CalculateDiagramBounds(VisualRange RangeAxisX, VisualRange RangeAxisY)
|
{
|
Point p1 = mainChartDiagram.DiagramToPoint((double)RangeAxisX.MinValue, (double)RangeAxisY.MinValue).Point;
|
Point p2 = mainChartDiagram.DiagramToPoint((double)RangeAxisX.MaxValue, (double)RangeAxisY.MaxValue).Point;
|
|
return Eventech.Common.RectangleHelper.CreateRectangle(p1, p2);
|
}
|
|
private void chartControl_CustomPaint(object sender, CustomPaintEventArgs e)
|
{
|
if (_coordinateParas == null)
|
return;
|
|
Graphics g = e.Graphics;
|
//g.SetClip(CalculateDiagramBounds());
|
g.SmoothingMode = SmoothingMode.AntiAlias;
|
|
//绘制默认曲线的文字MaxCurveQH.PointInfo
|
//if (isDispCurveName && MaxCurveQH.CurvePara > 1)
|
//{
|
// ControlCoordinates coorPoint = mainChartDiagram.DiagramToPoint(MaxCurveQH.PointInfo.Last().X,
|
// MaxCurveQH.PointInfo.Last().Y, AxisX, AxisY);
|
// Point textPosi = new Point(coorPoint.Point.X - 3, coorPoint.Point.Y + 8);
|
// g.DrawString(MaxCurveQH.CurvePara.ToString(), IStation.WinFrmUI.Basic.Properties.Settings.Dia.AnnoCurveName, new SolidBrush(Color.Black), textPosi);
|
//}
|
|
#region 绘制网格线
|
|
if (_chartPanelStyle == IStation.Model.eChartDiagramPanelStyle.Whole)
|
{
|
chartControl1.DrawGridLineY(g, _coordinateParas,
|
isMonoColor ? Color.Silver : IStation.WinFrmUI.Basic.ChartDisp.Settings.Default.GridLinesColorY);
|
}
|
|
#endregion 绘制网格线
|
|
#region 添加水印
|
|
chartControl1.DrawCorpLogo(g);
|
|
#endregion 添加水印
|
|
|
|
|
}
|
|
|
#endregion 重绘
|
|
#region 显示
|
|
//是否显示曲线Legend
|
private bool isDispLegend = false;
|
public bool IsDispLegend
|
{
|
get { return isDispLegend; }
|
set
|
{
|
isDispLegend = value;
|
this.chartControl1.Legend.Visibility = value ? DefaultBoolean.True : DefaultBoolean.False;
|
}
|
}
|
|
//是否显示曲线参数
|
private bool isDispCurveName = false;
|
|
public bool IsDispCurveName
|
{
|
get { return isDispCurveName; }
|
set { isDispCurveName = value; 设置曲线标签显示MenuItem.Visible = value; }
|
}
|
|
private bool isMonoColor = false;
|
|
public bool IsMonoColor
|
{
|
get { return isMonoColor; }
|
set
|
{
|
isMonoColor = value;
|
if (isMonoColor)
|
{
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetMonoColor(chartControl1);
|
}
|
else
|
{
|
SetSettingColor();
|
}
|
}
|
}
|
|
public void SetChartDisplay()
|
{
|
if (isMonoColor)
|
{
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetMonoColor(chartControl1);
|
}
|
else
|
{
|
SetSettingColor();
|
}
|
}
|
|
private void SetSettingColor()
|
{
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetDisplay(AxisQ, QHAxisY, QEAxisY, QPAxisY, NPSHAxisY);
|
//IStation.WinFrmUI.Basic.XtraChartHelper.SetCurveDisplay(SeriesQHdefault, SeriesQEdefault, SeriesQPdefault, SeriesNPSHdefault);
|
//IStation.WinFrmUI.Basic.XtraChartHelper.SetCurveDisplay(SeriesQHmax, SeriesQEmax, SeriesQPmax, SeriesNPSHmax);
|
//IStation.WinFrmUI.Basic.XtraChartHelper.SetCurveDisplay(SeriesQHmin, SeriesQEmin, SeriesQPmin, SeriesNPSHmin);
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetDisplay(StripWorkRegion);
|
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetBackColor(chartControl1, mainChartDiagram);
|
}
|
|
#endregion 显示
|
|
#region 查询点
|
|
public void SetQueryPointQ(double q)
|
{
|
QueryLineVertical.AxisValue = q;
|
if (_coordinateParas == null)
|
{
|
QueryLineHorizontal.Points.Clear();
|
}
|
else
|
{
|
CalcCurveParasByQ(q);
|
}
|
}
|
|
//是否可以查询曲线参数
|
public void SetQueryLineDisp(bool isDisp)
|
{
|
_isQueryCurvePara = isDisp;
|
QueryLineVertical.Visible = _isQueryCurvePara;
|
QueryLineVertical.Title.Visible = _isQueryCurvePara;
|
QueryParaInfoText.Visible = _isQueryCurvePara;
|
QueryLineHorizontal.Visible = _isQueryCurvePara;
|
if (_isQueryCurvePara)
|
this.IsHandCursor();
|
else
|
this.IsCrossCursor();
|
}
|
|
#endregion 查询点
|
|
#region 图表事件
|
|
private object _rightClickObj = null;
|
|
private void chartControl_MouseClick(object sender, MouseEventArgs e)
|
{
|
if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
{
|
ChartHitInfo hitInfo = chartControl1.CalcHitInfo(e.Location);
|
|
DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
|
|
if (hitInfo.InAnnotation)
|
{
|
_rightClickObj = hitInfo.Annotation;
|
annoRightMenu.Show(chartControl1, e.Location);
|
}
|
else if (hitInfo.InSeries)
|
{
|
_rightClickObj = hitInfo.Series;
|
curveRightMenu.Show(chartControl1, e.Location);
|
}
|
else if (hitInfo.InAxis)
|
{
|
_rightClickObj = hitInfo.Axis;
|
axisRightMenu.Show(chartControl1, e.Location);
|
}
|
else if (hitInfo.InConstantLine)
|
{
|
_rightClickObj = hitInfo.ConstantLine;
|
lineMenuStrip.Show(chartControl1, e.Location);
|
}
|
//else if (hitInfo.InChartTitle)
|
//{
|
// rightClickObj = hitInfo.AxisTitle;
|
// lineMenuStrip.Show(chartControl1, e.locationType);
|
//}
|
else
|
{
|
_rightClickObj = null;
|
chartRightMenu.Show(chartControl1, e.Location);
|
}
|
}
|
}
|
|
//ToolTipController toolTipController1 = new ToolTipController();
|
private void chartControl1_ObjectHotTracked(object sender, HotTrackEventArgs e)
|
{
|
//if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
//{
|
// ChartHitInfo hitInfo = chartControl1.CalcHitInfo(e.Location);
|
// if (hitInfo.InConstantLine)
|
// {
|
// rightClickObj = hitInfo.ConstantLine;
|
// lineMenuStrip.Show(chartControl1, e.Location);
|
// }
|
// else
|
// {
|
// rightClickObj = null;
|
// chartRightMenu.Show(chartControl1, e.Location);
|
// }
|
//}
|
}
|
|
|
|
private void CalcCurveParasByQ(double queryQ)
|
{
|
for (int indx = 0; indx < this.AllCurve.Count(); indx++)
|
{
|
var queryPt = CalcQueryPointPt(
|
AllCurve[indx],
|
queryQ);
|
if (queryPt == null)
|
continue;
|
if (queryPt.Q < this._maxQ * 0.01)
|
continue;
|
if (indx == 0)
|
{
|
DispQueryInfoInChart(queryPt);
|
SetQueryParaLineQ(queryPt);
|
}
|
|
if (OnCalcQueryPtInfo != null)
|
{
|
OnCalcQueryPtInfo(this.AllCurve[indx].TestItemID, queryPt);
|
}
|
}
|
}
|
|
|
private Eventech.Model.GroupPoint CalcQueryPointPt(
|
CurrentViewModel featCurve,
|
double queryQ)
|
{
|
var query_posi = new Eventech.Model.GroupPoint(0, 0, 0, 0, 0);
|
query_posi.Q = queryQ;
|
query_posi.H = Eventech.Common.FitCurveHelper.GetFitPointY(featCurve.CurveExpressQH, queryQ);
|
if (IsDisplayCurveQE)
|
{
|
query_posi.E = Eventech.Common.FitCurveHelper.GetFitPointY(featCurve.CurveExpressQE, queryQ);
|
}
|
|
if (IsDisplayCurveQP)
|
{
|
query_posi.P = Eventech.Common.FitCurveHelper.GetFitPointY(featCurve.CurveExpressQP, queryQ);
|
}
|
|
|
return query_posi;
|
}
|
|
private void DispQueryInfoInChart(Eventech.Model.GroupPoint queryPt)
|
{
|
// if (queryPt == null)
|
// return;
|
|
// StringBuilder builder = new StringBuilder();
|
|
// builder.AppendLine("---" +"曲线点参数") + "---");
|
// if (_unit_design_point_Q == _coordinate_unitQ)
|
// {
|
// builder.AppendFormat("{0}:{1} {2}",
|
//IStation.WinFrmUI.Localization.TranslateHelper.GetString("流量"),
|
//CalcDispValueQ_STR(_coordinate_unitQ, queryPt.Q),
|
//Eventech.Common.UnitQHelper.GetEnUnitName(this._coordinate_unitQ));
|
// }
|
// else
|
// {
|
// builder.AppendFormat("{0}:{1} {2} ({3} {4})",
|
//IStation.WinFrmUI.Localization.TranslateHelper.GetString("流量"),
|
//CalcDispValueQ_STR(_queryInfo_unitQ, queryPt.Q),
|
//Eventech.Common.UnitQHelper.GetEnUnitName(this._queryInfo_unitQ),
|
//CalcDispValueQ_STR(Eventech.Common.UnitQHelper.Tran(this._coordinate_unitQ, _unit_design_point_Q, queryPt.Q)),
|
//Eventech.Common.UnitQHelper.GetEnUnitName(this._unit_design_point_Q));
|
// }
|
|
// builder.AppendLine("");
|
// if (_unit_design_point_H == _coordinate_unitH)
|
// {
|
// builder.AppendFormat("{0}:{1} {2}",
|
// "扬程"),
|
// CalcDispValueH_STR(_queryInfo_unitH, queryPt.H),
|
// Eventech.Common.UnitHHelper.GetEnUnitName(this._queryInfo_unitH));
|
// }
|
// else
|
// {
|
// builder.AppendFormat("{0}:{1} {2} ({3} {4})",
|
// "扬程"),
|
// CalcDispValueH_STR(_queryInfo_unitH, queryPt.H),
|
// Eventech.Common.UnitHHelper.GetEnUnitName(this._queryInfo_unitH),
|
// CalcDispValueH_STR(Eventech.Common.UnitHHelper.Tran(this._coordinate_unitH, _unit_design_point_H, queryPt.H)),
|
// Eventech.Common.UnitHHelper.GetEnUnitName(this._unit_design_point_H));
|
// }
|
|
// if (_seriesEntity.IsDisplayCurveQE() && queryPt.E > 0)
|
// {
|
// builder.AppendLine("");
|
// // builder.AppendFormat(IStation.WinFrmUI.Localization.TranslateHelper.GetString("效率") +
|
// // ":{0:N1}%", _queryPt.E);
|
// builder.AppendFormat("{0}:{1:N1}%",
|
// _seriesEntity.GetEtaTextName(IStation.WinFrmUI.Localization.Current)), queryPt.E);
|
// }
|
|
// if (_seriesEntity.IsDisplayCurveQP() && queryPt.P > 0)
|
// {
|
// queryPt.P = IStation.Common.RoundHelper.GetDispValuePower(queryPt.P);
|
// builder.AppendLine("");
|
|
// //builder.AppendFormat(IStation.WinFrmUI.Localization.TranslateHelper.GetString("轴功率") + ":{0:N1}{1}", CalcDispValueP(_queryPt.P),
|
// // Eventech.Common.UnitPHelper.GetEnUnitName(this._unitP));
|
|
// builder.AppendFormat("{0}:{1}{2}",_seriesEntity.GetPowerTextName(IStation.WinFrmUI.Localization.Current)), CalcDispValueP(queryPt.P),
|
//Eventech.Common.UnitPHelper.GetEnUnitName(this._coordinate_unitP));
|
// }
|
|
// if (queryPt.NPSH > 0)
|
// {
|
// builder.AppendLine("");
|
// if (queryPt.NPSH < 3)
|
// builder.AppendFormat(IStation.WinFrmUI.Localization.TranslateHelper.GetString("汽蚀") + ":{0:N2}", queryPt.NPSH);
|
// else
|
// builder.AppendFormat(IStation.WinFrmUI.Localization.TranslateHelper.GetString("汽蚀") + ":{0:N1}", queryPt.NPSH);
|
// }
|
|
//QueryParaInfoText.Text = builder.ToString();
|
}
|
|
private void SetQueryParaLineQ(Eventech.Model.GroupPoint queryPt)
|
{
|
QueryLineVertical.AxisValue = queryPt.Q;
|
QueryLineVertical.Title.Text = string.Format("{0} ({1})", CalcDispValueQ_STR(queryPt.Q), Eventech.Common.UnitQHelper.GetEnUnitName(this._coordinate_unitQ));
|
|
QueryLineHorizontal.Points.Clear();
|
if (_coordinateParas != null)
|
QueryLineHorizontal.Points.Add(new SeriesPoint(_coordinateParas.CoordMinQ, queryPt.H));
|
else
|
QueryLineHorizontal.Points.Add(new SeriesPoint(_minQ, queryPt.H));
|
QueryLineHorizontal.Points.Add(new SeriesPoint(queryPt.Q, queryPt.H));
|
}
|
|
private bool _isMoveQueryLineQ1 = false;
|
private bool _isMoveQueryLineH1 = false;
|
private Point _clickLocation;
|
|
private void chartControl_MouseDown(object sender, MouseEventArgs e)
|
{
|
if (this.AllCurve == null || this.AllCurve.Count == 0) return;
|
if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
{
|
_clickLocation = e.Location;
|
ChartHitInfo hitInfo = chartControl1.CalcHitInfo(_clickLocation);
|
if (hitInfo.InConstantLine)
|
{
|
if (hitInfo.ConstantLine == QueryLineVertical)
|
_isMoveQueryLineQ1 = true;
|
}
|
else if (hitInfo.InSeries)
|
{
|
if (hitInfo.Series == QueryLineHorizontal)
|
_isMoveQueryLineH1 = true;
|
}
|
else
|
{
|
DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
|
double refQ = coordPt.NumericalArgument;
|
double refH = coordPt.NumericalValue;
|
|
if (OnDispOperateInfo != null)
|
{
|
OnDispOperateInfo(this, new Eventech.Model.OperateInfoEventArgs(string.Format("鼠标点击处 流量={0:N1};扬程={1:N1}", refQ, refH)));
|
}
|
}
|
}
|
|
//if (isRectSel)
|
//{//进行框选删除点
|
// Rectangle bounds = CalculateDiagramBounds();
|
// if (bounds.Contains(e.locationType))
|
// {
|
// selCornerFirstPt = selCornerLastPt = e.locationType;
|
// selRectangleIng = Rectangle.Empty;
|
// }
|
//}
|
}
|
|
private void chartControl_MouseMove(object sender, MouseEventArgs e)
|
{
|
if (_isMoveQueryLineQ1)
|
{
|
DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
|
double refQ = coordPt.NumericalArgument;
|
CalcCurveParasByQ(refQ);
|
}
|
else if (_isMoveQueryLineH1)
|
{
|
//DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
|
////double refH = coordPt.NumericalValue;
|
//double refQ = 0;
|
|
// CalcCurveParasByQ(refQ);
|
|
}
|
}
|
|
//public event TagEventHandler OnChangeWorkPt = null;
|
private void chartControl_MouseUp(object sender, MouseEventArgs e)
|
{
|
//if (isMoveQueryLineQ || isMoveQueryLineH)
|
//{
|
// if (OnChangeWorkPt != null)
|
// {
|
// OnChangeWorkPt(this, new TagEventArgs(_queryPt));
|
// }
|
//}
|
|
_isMoveQueryLineQ1 = false;
|
_isMoveQueryLineH1 = false;
|
//if (isRectSel)
|
//{
|
// isRectSel = false;
|
// #region 框选删除
|
// if (isRectSelDelPts)
|
// {//
|
// isRectSelDelPts = false;
|
|
// DiagramCoordinates firstCoordinate = theXYDiagram.PointToDiagram(selCornerFirstPt);
|
// DiagramCoordinates lastCoordinate = theXYDiagram.PointToDiagram(selCornerLastPt); if
|
// (firstCoordinate.IsEmpty || lastCoordinate.IsEmpty) return; PointF firstPoint = new
|
// PointF((float)firstCoordinate.NumericalArgument,
|
// (float)firstCoordinate.NumericalValue); PointF lastPoint = new
|
// PointF((float)lastCoordinate.NumericalArgument, (float)lastCoordinate.NumericalValue);
|
|
// //foreach (var row in _clickPointInfo) //{ // if (row.X < lastPoint.X && row.X >
|
// firstPoint.X && row.Y > lastPoint.Y && row.Y < firstPoint.Y) // { //
|
// _clickPointInfo.Remove(row); // } //} for (int iExcelCol = _clickPointInfo.Count - 1;
|
// iExcelCol >= 0; iExcelCol--) { var row = _clickPointInfo[iExcelCol]; if (row.X <
|
// lastPoint.X && row.X > firstPoint.X && row.Y > lastPoint.Y && row.Y < firstPoint.Y) {
|
// _clickPointInfo.Remove(row); }
|
|
// }
|
|
// SeriesPoint.Spectrum.Clear(); foreach (var ftPoint in _clickPointInfo) {
|
// SeriesPoint.Spectrum.Add(new SeriesPoint(ftPoint.X, new double[] { ftPoint.Y })); } } #endregion
|
|
//}
|
//selCornerFirstPt = Point.Empty;
|
//selCornerLastPt = Point.Empty;
|
//selRectangleIng = Rectangle.Empty;
|
}
|
|
private void chartControl1_LegendItemChecked(object sender, LegendItemCheckedEventArgs e)
|
{
|
//if (curvesGroups.Count == 0)
|
// return;
|
|
////if (e.CheckedElement == SeriesQHdefault)
|
////{
|
//// SetCurveTypeDisp(eCurveType.QHcurve,e.NewCheckState,false);
|
////}
|
//if (e.CheckedElement == SeriesQEdefault)
|
//{
|
// SetCurveTypeDisp(eCurveType.QEcurve, e.NewCheckState, false);
|
//}
|
//if (e.CheckedElement == SeriesQPdefault)
|
//{
|
// SetCurveTypeDisp(eCurveType.QPcurve, e.NewCheckState, false);
|
//}
|
|
//UpdateCoordinate();
|
}
|
|
#endregion 图表事件
|
|
#region 鼠标样式
|
|
public void IsCrossCursor()
|
{
|
this.chartControl1.Cursor = System.Windows.Forms.Cursors.Cross;
|
}
|
|
public void IsHandCursor()
|
{
|
this.chartControl1.Cursor = System.Windows.Forms.Cursors.Hand;
|
}
|
|
#endregion 鼠标样式
|
|
#region 右击菜单
|
|
private void chartRightMenu_Opening(object sender, CancelEventArgs e)
|
{
|
if (_isQueryCurvePara)
|
{
|
查询曲线参数MenuItem.Text = "关闭曲线参数查询";
|
}
|
else
|
{
|
查询曲线参数MenuItem.Text = "查询曲线参数";
|
}
|
}
|
|
private void 查询曲线参数MenuItem_Click(object sender, EventArgs e)
|
{
|
//if (_maxCurves == null || _maxCurves.FeatCurveQH == null || _maxCurves.FeatCurveQH.PointInfo.Count < 4)
|
// return;
|
//查询曲线参数MenuItem.IsSelect = !查询曲线参数MenuItem.IsSelect;
|
//IsQueryCurvePara = 查询曲线参数MenuItem.IsSelect;
|
|
//if (OnChangeQueryPtStatus != null)
|
// OnChangeQueryPtStatus(this, new TagEventArgs(_isQueryCurvePara));
|
|
//AnalysisParasByQDlg theCalcParasByQDlg = new AnalysisParasByQDlg();
|
//theCalcParasByQDlg.SetPointInfo(MaxCurveQH.PointInfo, MaxCurveQE.PointInfo, MaxCurveQP.PointInfo, null);
|
//theCalcParasByQDlg.Show();
|
}
|
|
private bool isDispCoodTittle = true;
|
|
private void 显示坐标标签ItemMenu_Click(object sender, EventArgs e)
|
{
|
显示坐标标签ItemMenu.Checked = !显示坐标标签ItemMenu.Checked;
|
|
isDispCoodTittle = 显示坐标标签ItemMenu.Checked;
|
|
AxisQ.Title.Visibility = isDispCoodTittle ? DefaultBoolean.True : DefaultBoolean.False;
|
QHAxisY.Title.Visibility = isDispCoodTittle ? DefaultBoolean.True : DefaultBoolean.False;
|
QEAxisY.Title.Visibility = isDispCoodTittle ? DefaultBoolean.True : DefaultBoolean.False;
|
QPAxisY.Title.Visibility = isDispCoodTittle ? DefaultBoolean.True : DefaultBoolean.False;
|
NPSHAxisY.Title.Visibility = isDispCoodTittle ? DefaultBoolean.True : DefaultBoolean.False;
|
|
SetAxisTitleDispH();
|
}
|
|
private void SetAxisTitleDispH()
|
{
|
if (QEAxisY.Visibility != DefaultBoolean.True && QPAxisY.Visibility != DefaultBoolean.True)
|
{
|
QHAxisY.Title.Alignment = StringAlignment.Center;
|
}
|
else
|
{
|
QHAxisY.Title.Alignment = StringAlignment.Far;
|
}
|
}
|
|
private void 设置图形显示Menu_Click(object sender, EventArgs e)
|
{
|
SetChartDisp();
|
}
|
|
public void SetChartDisp()
|
{
|
//IStation.WinFrmUI.SetChartDisplayDlg theDlg = new IStation.WinFrmUI.SetChartDisplayDlg();
|
//if (theDlg.ShowDialog() == DialogResult.OK)
|
//{
|
// SetChartDisplay();
|
// chartControl1.Refresh();
|
//}
|
}
|
|
private void 设置曲线标签显示MenuItem_Click(object sender, EventArgs e)
|
{
|
//System.Windows.Forms.FontDialog fontDialog1 = new System.Windows.Forms.FontDialog();
|
//fontDialog1.Font = IStation.WinFrmUI.Basic.ChartDisp.Settings.Default.AnnoCurveName;
|
|
//if (fontDialog1.ShowDialog() != DialogResult.Cancel)
|
//{
|
// IStation.WinFrmUI.Basic.ChartDisp.Settings.Default.AnnoCurveName = fontDialog1.Font;
|
// chartControl1.Refresh();
|
//}
|
}
|
|
//显示曲线方程
|
public void DispCurveExpressInfo()
|
{
|
//if (AllCurveQH == null || AllCurveQH.Count() == 0)
|
// return;
|
//Eventech.WinFrmUI.DispCurveEquation2Dlg theSetDlg = new Eventech.WinFrmUI.DispCurveEquation2Dlg();
|
//theSetDlg.SetCurveInfo(this.AllCurveQH);
|
//theSetDlg.Show();
|
}
|
|
#region Anno
|
|
private void annoRightMenu_Opening(object sender, CancelEventArgs e)
|
{
|
var anno = _rightClickObj as DevExpress.XtraCharts.TextAnnotation;
|
if (anno == null)
|
return;
|
|
if (anno == QueryParaInfoText)
|
{
|
MenuItemAnno删除.Visible = false;
|
MenuItemAnno修改内容.Visible = false;
|
}
|
else if (anno.Name.StartsWith("EE_"))
|
{
|
MenuItemAnno删除.Visible = true;
|
MenuItemAnno修改内容.Visible = true;
|
}
|
else
|
{
|
MenuItemAnno删除.Visible = false;
|
MenuItemAnno修改内容.Visible = false;
|
}
|
}
|
|
private void MenuItemAnno删除_Click(object sender, EventArgs e)
|
{
|
|
|
|
}
|
|
public Func<double, bool, Eventech.Model.CombineCurve> OnCalcEqualEtaCurvePoints = null;
|
|
private void MenuItemAnno修改内容_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void 设置颜色AnnoMenuItem_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
var anno = _rightClickObj as DevExpress.XtraCharts.TextAnnotation;
|
if (anno == null)
|
return;
|
|
System.Windows.Forms.ColorDialog colorDialog1 = new System.Windows.Forms.ColorDialog();
|
colorDialog1.Color = anno.TextColor;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
anno.TextColor = colorDialog1.Color;
|
anno.Border.Color = colorDialog1.Color;
|
}
|
}
|
catch
|
{
|
return;
|
}
|
}
|
|
private void 设置背景色AnnoMenuItem_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
var anno = _rightClickObj as DevExpress.XtraCharts.TextAnnotation;
|
if (anno == null)
|
return;
|
|
System.Windows.Forms.ColorDialog colorDialog1 = new System.Windows.Forms.ColorDialog();
|
colorDialog1.Color = anno.BackColor;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
anno.BackColor = colorDialog1.Color;
|
}
|
}
|
catch
|
{
|
return;
|
}
|
}
|
|
private void 设置背景透明AnnoMenuItem_Click(object sender, EventArgs e)
|
{
|
var anno = _rightClickObj as DevExpress.XtraCharts.TextAnnotation;
|
if (anno == null)
|
return;
|
|
anno.BackColor = Color.Transparent;
|
anno.Shadow.Visible = false;
|
}
|
|
#endregion Anno
|
|
#region Axis
|
|
private void axisRightMenu_Opening(object sender, CancelEventArgs e)
|
{
|
if (_rightClickObj == null)
|
e.Cancel = true;
|
if (_rightClickObj == AxisQ)
|
{
|
颜色交织AxisMenuItem.Visible = true;
|
}
|
else
|
{
|
颜色交织AxisMenuItem.Visible = false;
|
}
|
}
|
|
private void 颜色交织AxisMenuItem_Click(object sender, EventArgs e)
|
{
|
var axis = _rightClickObj as DevExpress.XtraCharts.Axis;
|
if (axis == null)
|
return;
|
颜色交织AxisMenuItem.Checked = !颜色交织AxisMenuItem.Checked;
|
axis.Interlaced = 颜色交织AxisMenuItem.Checked;
|
}
|
|
private void 设置颜色AxisMenuItem_Click(object sender, EventArgs e)
|
{
|
var axis = _rightClickObj as DevExpress.XtraCharts.Axis;
|
if (axis == null)
|
return;
|
|
System.Windows.Forms.ColorDialog colorDialog1;
|
colorDialog1 = new System.Windows.Forms.ColorDialog();
|
colorDialog1.Color = axis.Label.TextColor;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
axis.Title.TextColor = colorDialog1.Color;
|
axis.Label.TextColor = colorDialog1.Color;
|
axis.Color = colorDialog1.Color;
|
}
|
}
|
|
private void 设置坐标值MenuItem_Click(object sender, EventArgs e)
|
{
|
var axis = _rightClickObj as DevExpress.XtraCharts.Axis;
|
if (axis == null)
|
return;
|
if (_rightClickObj == AxisQ)
|
{
|
IStation.WinFrmUI.Basic.SetSingleCoordLxpQDlg theSetDlg = new IStation.WinFrmUI.Basic.SetSingleCoordLxpQDlg();
|
theSetDlg.SetBindingData(_coordinateParas);
|
theSetDlg.OnChangedCoord += ChangedCoordHandler;
|
theSetDlg.ShowDialog();
|
}
|
else if (_rightClickObj == QHAxisY)
|
{
|
IStation.WinFrmUI.Basic.SetSingleCoordLxpHDlg theSetDlg = new IStation.WinFrmUI.Basic.SetSingleCoordLxpHDlg();
|
theSetDlg.SetBindingData(_coordinateParas);
|
theSetDlg.OnChangedCoord += ChangedCoordHandler;
|
theSetDlg.ShowDialog();
|
}
|
else if (_rightClickObj == QPAxisY)
|
{
|
IStation.WinFrmUI.Basic.SetSingleCoordLxpPDlg theSetDlg = new IStation.WinFrmUI.Basic.SetSingleCoordLxpPDlg();
|
theSetDlg.SetBindingData(_coordinateParas, this._coordinate_unitP);
|
theSetDlg.OnChangedCoord += ChangedCoordHandler;
|
theSetDlg.ShowDialog();
|
}
|
else if (_rightClickObj == NPSHAxisY)
|
{
|
IStation.WinFrmUI.Basic.SetSingleCoordLxpNpshDlg theSetDlg = new IStation.WinFrmUI.Basic.SetSingleCoordLxpNpshDlg();
|
theSetDlg.SetBindingData(_coordinateParas, this._coordinate_unitNPSH);
|
theSetDlg.OnChangedCoord += ChangedCoordHandler;
|
theSetDlg.ShowDialog();
|
}
|
else if (_rightClickObj == QEAxisY)
|
{
|
IStation.WinFrmUI.Basic.SetSingleCoordLxpEDlg theSetDlg = new IStation.WinFrmUI.Basic.SetSingleCoordLxpEDlg();
|
theSetDlg.SetBindingData(_coordinateParas);
|
theSetDlg.OnChangedCoord += ChangedCoordHandler;
|
theSetDlg.ShowDialog();
|
}
|
}
|
|
private void 设置子刻度数AxisMenuItem_Click(object sender, EventArgs e)
|
{
|
var axis = _rightClickObj as DevExpress.XtraCharts.Axis;
|
if (axis == null)
|
return;
|
SetNumberDlg theDlg = new SetNumberDlg();
|
theDlg.IsInt();
|
theDlg.Number = axis.MinorCount;
|
if (theDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
axis.MinorCount = Convert.ToInt32(theDlg.Number);
|
}
|
}
|
|
#endregion Axis
|
|
#region Series
|
|
private void 设置颜色SeriesMenuItem_Click(object sender, EventArgs e)
|
{
|
var series = _rightClickObj as DevExpress.XtraCharts.Series;
|
if (series == null)
|
return;
|
|
System.Windows.Forms.ColorDialog colorDialog1;
|
colorDialog1 = new System.Windows.Forms.ColorDialog();
|
|
colorDialog1.Color = series.View.Color;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
series.View.Color = colorDialog1.Color;
|
}
|
}
|
|
private void 设置宽度SeriesMenuItem_Click(object sender, EventArgs e)
|
{
|
var series = _rightClickObj as DevExpress.XtraCharts.Series;
|
if (series == null)
|
return;
|
if (!(series.View is DevExpress.XtraCharts.LineSeriesView))
|
return;
|
SetCurveWidthDlg theDlg = new SetCurveWidthDlg();
|
theDlg.CurveWidth = (series.View as DevExpress.XtraCharts.LineSeriesView).LineStyle.Thickness;
|
if (theDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
(series.View as DevExpress.XtraCharts.LineSeriesView).LineStyle.Thickness = theDlg.CurveWidth;
|
}
|
}
|
|
private void 设置线型SeriesMenuItem_Click(object sender, EventArgs e)
|
{
|
var series = _rightClickObj as DevExpress.XtraCharts.Series;
|
if (series == null)
|
return;
|
if (!(series.View is DevExpress.XtraCharts.LineSeriesView))
|
return;
|
SetLineStyleDlg theDlg = new SetLineStyleDlg();
|
theDlg.DashStyle = (series.View as DevExpress.XtraCharts.LineSeriesView).LineStyle.DashStyle;
|
if (theDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
(series.View as DevExpress.XtraCharts.LineSeriesView).LineStyle.DashStyle = theDlg.DashStyle;
|
}
|
}
|
|
#endregion Series
|
|
#region Line
|
|
private void 设置颜色LineMenuItem_Click(object sender, EventArgs e)
|
{
|
var refLine = _rightClickObj as DevExpress.XtraCharts.ConstantLine;
|
if (refLine == null)
|
return;
|
|
System.Windows.Forms.ColorDialog colorDialog1;
|
colorDialog1 = new System.Windows.Forms.ColorDialog();
|
|
colorDialog1.Color = refLine.Color;
|
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
{
|
refLine.Color = colorDialog1.Color;
|
refLine.Title.TextColor = colorDialog1.Color;
|
}
|
}
|
|
private void MenuItem设置值Line_Click(object sender, EventArgs e)
|
{
|
if (_rightClickObj == QueryLineHorizontal)
|
{
|
//SetRefLineValue1Dlg theDlg = new SetRefLineValue1Dlg();
|
//theDlg.SetUnitName(Eventech.Common.UnitHHelper.GetEnUnitName(this._unitH));
|
//theDlg.RefLineValue = Convert.ToDecimal(Math.Round(CalcDispValueH(QueryLineHorizontal.Points[0].Values[0]), 1));
|
//if (theDlg.ShowDialog() == DialogResult.OK)
|
//{
|
// double refH = CalcDataValueH(Convert.ToDouble(theDlg.RefLineValue));
|
// double refQ = 0;
|
// if (CalcCurveParasByH(refH, ref refQ))
|
// {
|
// CalcCurveParasByQ(refQ);
|
// SetQueryParaLineQ();
|
// }
|
//}
|
}
|
else
|
{
|
var refLine = _rightClickObj as DevExpress.XtraCharts.ConstantLine;
|
if (refLine == null)
|
return;
|
if (refLine == QueryLineVertical)
|
{
|
//SetRefLineValue2Dlg theDlg = new SetRefLineValue2Dlg();
|
//theDlg.SetUnitName(Eventech.Common.UnitQHelper.GetEnUnitName(this._coordinate_unitQ));
|
|
//theDlg.SetValue(Math.Round(CalcDispValueQ(Convert.ToDouble(QueryLineVertical.AxisValue)), 1));
|
//if (theDlg.ShowDialog() == DialogResult.OK)
|
//{
|
// CalcCurveParasByQ(CalcDataValueQ(theDlg.GetValue().Value));
|
//}
|
}
|
}
|
}
|
|
#endregion Line
|
|
#endregion 右击菜单
|
|
|
#region 曲线分开放菜单
|
|
protected IStation.Model.eChartDiagramPanelStyle _chartPanelStyle = IStation.Model.eChartDiagramPanelStyle.Two;
|
|
public void SetChartPanelStyleParas(IStation.Model.eChartDiagramPanelStyle style)
|
{
|
_chartPanelStyle = style;
|
SetChartPanelStyle();
|
}
|
|
//0 是一整块 1 上面扬程效率 下面功率汽蚀
|
public void SetChartPanelStyle()
|
{
|
//bool isHaveCurveQH = true ;
|
bool isHaveCurveQE = true;
|
bool isHaveCurveQP = true;
|
bool isHaveCurveNPSH = false;
|
|
|
|
this.QEAxisY.Visibility = isHaveCurveQE ? DefaultBoolean.True : DefaultBoolean.False;
|
this.QPAxisY.Visibility = isHaveCurveQP ? DefaultBoolean.True : DefaultBoolean.False;
|
this.NPSHAxisY.Visibility = isHaveCurveNPSH ? DefaultBoolean.True : DefaultBoolean.False;
|
|
if (!isHaveCurveQE)
|
this.QEAxisY.GridLines.Visible = false;
|
if (!isHaveCurveQP)
|
this.QPAxisY.GridLines.Visible = false;
|
if (!isHaveCurveNPSH)
|
this.NPSHAxisY.GridLines.Visible = false;
|
|
if (_chartPanelStyle == IStation.Model.eChartDiagramPanelStyle.Whole)
|
{
|
this.bottomChartDiagram.Visibility = ChartElementVisibility.Hidden;
|
|
this.QPAxisY.Title.Alignment = StringAlignment.Near;
|
this.NPSHAxisY.Title.Alignment = StringAlignment.Near;
|
|
this.QHAxisY.GridLines.Visible = false;
|
this.QEAxisY.GridLines.Visible = false;
|
this.QPAxisY.GridLines.Visible = false;
|
this.NPSHAxisY.GridLines.Visible = false;
|
}
|
else
|
{
|
this.QHAxisY.GridLines.Visible = true;
|
this.QPAxisY.Title.Alignment = StringAlignment.Center;
|
this.NPSHAxisY.Title.Alignment = StringAlignment.Center;
|
this.QEAxisY.GridLines.Visible = isHaveCurveQE;
|
|
if (isHaveCurveQP || isHaveCurveNPSH)
|
{
|
this.QPAxisY.GridLines.Visible = isHaveCurveQP;
|
this.NPSHAxisY.GridLines.Visible = isHaveCurveNPSH;
|
this.bottomChartDiagram.Visibility = ChartElementVisibility.Visible;
|
}
|
else
|
{
|
this.QPAxisY.Visibility = DefaultBoolean.False;
|
this.NPSHAxisY.Visibility = DefaultBoolean.False;
|
this.bottomChartDiagram.Visibility = ChartElementVisibility.Hidden;
|
}
|
}
|
|
if (_coordinateParas == null)
|
return;
|
|
if (_chartPanelStyle == IStation.Model.eChartDiagramPanelStyle.Whole)
|
{
|
#region 整个
|
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QHAxisY,
|
_coordinateParas.CoordMinH + _coordinateParas.StartLineNoH * _coordinateParas.CoordSpaceH,
|
_coordinateParas.CoordMinH + _coordinateParas.EndLineNoH * _coordinateParas.CoordSpaceH);
|
|
if (this._coordinate_unitH == Eventech.Model.UnitH.Psi)
|
{
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QHAxisY,
|
_coordinateParas.CoordMinH - 0.01,
|
_coordinateParas.CoordMinH + _coordinateParas.GridNumberY * _coordinateParas.CoordSpaceH + 0.01);
|
}
|
else
|
{
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QHAxisY,
|
_coordinateParas.CoordMinH,
|
_coordinateParas.CoordMinH + _coordinateParas.GridNumberY * _coordinateParas.CoordSpaceH);
|
}
|
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QEAxisY, _coordinateParas.CoordMinE,
|
_coordinateParas.CoordMinE + _coordinateParas.GridNumberY * _coordinateParas.CoordSpaceE);
|
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QPAxisY, _coordinateParas.CoordMinP,
|
_coordinateParas.CoordMinP + _coordinateParas.GridNumberY * _coordinateParas.CoordSpaceP);
|
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(NPSHAxisY, _coordinateParas.CoordMinNPSH,
|
_coordinateParas.CoordMinNPSH + _coordinateParas.GridNumberY * _coordinateParas.CoordSpaceNPSH);
|
|
#endregion 整个
|
}
|
else
|
{
|
#region 上面是扬程,效率, 下面是功率汽蚀
|
|
if (isHaveCurveQE)
|
{
|
var grid_num_h = _coordinateParas.EndLineNoH - _coordinateParas.StartLineNoH;
|
var grid_num_e = _coordinateParas.EndLineNoE - _coordinateParas.StartLineNoE;
|
|
int grid_num_up = Math.Max(grid_num_h, grid_num_e) + _coordinateParas.DislocationNumUp;//多两条
|
|
var max_coor_h = _coordinateParas.CoordMinH + _coordinateParas.EndLineNoH * _coordinateParas.CoordSpaceH;
|
var min_coor_h = max_coor_h - grid_num_up * _coordinateParas.CoordSpaceH;
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QHAxisY, min_coor_h, max_coor_h);
|
|
var min_coor_e = _coordinateParas.CoordMinE + _coordinateParas.StartLineNoE * _coordinateParas.CoordSpaceE;
|
var max_coor_e = min_coor_e + grid_num_up * _coordinateParas.CoordSpaceE;
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QEAxisY, min_coor_e, max_coor_e);
|
|
QEAxisY.Alignment = AxisAlignment.Far;
|
}
|
else
|
{
|
var grid_num_h = _coordinateParas.EndLineNoH - _coordinateParas.StartLineNoH;
|
var grid_num_e = _coordinateParas.EndLineNoE - _coordinateParas.StartLineNoE;
|
|
int grid_num_up = Math.Max(grid_num_h, grid_num_e);//多两条
|
|
var max_coor_h = _coordinateParas.CoordMinH + _coordinateParas.EndLineNoH * _coordinateParas.CoordSpaceH;
|
var min_coor_h = max_coor_h - grid_num_up * _coordinateParas.CoordSpaceH;
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QHAxisY, min_coor_h, max_coor_h);
|
|
var min_coor_e = _coordinateParas.CoordMinE + _coordinateParas.StartLineNoE * _coordinateParas.CoordSpaceE;
|
var max_coor_e = min_coor_e + grid_num_up * _coordinateParas.CoordSpaceE;
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QEAxisY, min_coor_e, max_coor_e);
|
|
QEAxisY.Alignment = AxisAlignment.Far;
|
}
|
|
if (isHaveCurveNPSH)
|
{
|
var grid_num_NPSH = _coordinateParas.EndLineNoNPSH - _coordinateParas.StartLineNoNPSH;
|
var grid_num_p = _coordinateParas.EndLineNoP - _coordinateParas.StartLineNoP;
|
int grid_num_down = Math.Max(grid_num_NPSH, grid_num_p) + 2;
|
|
var max_coor_p = _coordinateParas.CoordMinP + _coordinateParas.EndLineNoP * _coordinateParas.CoordSpaceP;
|
var min_coor_p = max_coor_p - grid_num_down * _coordinateParas.CoordSpaceP;
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QPAxisY, min_coor_p, max_coor_p);
|
|
var min_coor_NPSH = _coordinateParas.CoordMinNPSH + _coordinateParas.StartLineNoNPSH * _coordinateParas.CoordSpaceNPSH;
|
var max_coor_NPSH = min_coor_NPSH + grid_num_down * _coordinateParas.CoordSpaceNPSH;
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(NPSHAxisY, min_coor_NPSH, max_coor_NPSH);
|
}
|
else
|
{
|
var grid_num_NPSH = _coordinateParas.EndLineNoNPSH - _coordinateParas.StartLineNoNPSH;
|
var grid_num_p = _coordinateParas.EndLineNoP - _coordinateParas.StartLineNoP;
|
int grid_num_down = Math.Max(grid_num_NPSH, grid_num_p);
|
|
var min_coor_p = _coordinateParas.CoordMinP + _coordinateParas.StartLineNoP * _coordinateParas.CoordSpaceP;
|
var max_coor_p = min_coor_p + grid_num_down * _coordinateParas.CoordSpaceP;
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(QPAxisY, min_coor_p, max_coor_p);
|
|
var min_coor_NPSH = _coordinateParas.CoordMinNPSH + _coordinateParas.StartLineNoNPSH * _coordinateParas.CoordSpaceNPSH;
|
var max_coor_NPSH = min_coor_NPSH + grid_num_down * _coordinateParas.CoordSpaceNPSH;
|
IStation.WinFrmUI.Basic.XtraChartHelper.SetAxisRange(NPSHAxisY, min_coor_NPSH, max_coor_NPSH);
|
}
|
|
NPSHAxisY.Alignment = AxisAlignment.Far;
|
QPAxisY.Alignment = AxisAlignment.Near;
|
|
#endregion 上面是扬程,效率, 下面是功率汽蚀
|
}
|
}
|
|
#endregion 曲线分开放菜单
|
|
#region 设置曲线显示
|
|
//是否显示
|
private void DispCurveMenuItem_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void SetChartCurveStyle()
|
{
|
|
}
|
|
#endregion 设置曲线显示
|
}
|
}
|