| | |
| | | using DevExpress.Utils; |
| | | using DevExpress.XtraCharts; |
| | | using System.Text; |
| | | using System.Windows.Forms; |
| | | using Yw.Geometry; |
| | | |
| | | namespace Yw.WinFrmUI.Phart |
| | |
| | | { |
| | | InitializeComponent(); |
| | | InitialChart(); |
| | | this.chartControl1.RuntimeHitTesting = true; |
| | | this.chartControl1.RuntimeHitTesting = true; |
| | | } |
| | | |
| | | #region Private Variable |
| | |
| | | |
| | | private Yw.Geometry.Point2d _design_pt; |
| | | |
| | | private bool _cubic_spline_qh_visible = true; |
| | | private bool _cubic_spline_qe_visible = true; |
| | | private bool _cubic_spline_qp_visible = true; |
| | | private bool _qh_visible = true; |
| | | private bool _qe_visible = true; |
| | | private bool _qp_visible = true; |
| | | private bool _cubic_spline_eq_visible = true; |
| | | |
| | | private bool _initialData = false; |
| | |
| | | private void InitialChart() |
| | | { |
| | | this.chartControl1.SetChartDisplay(); |
| | | this.chartControl1.Legend.Direction = DevExpress.XtraCharts.LegendDirection.TopToBottom; |
| | | this.chartControl1.SelectionMode = ElementSelectionMode.Single; |
| | | this.chartControl1.SeriesSelectionMode = SeriesSelectionMode.Series; |
| | | this.chartControl1.Legend.Direction = DevExpress.XtraCharts.LegendDirection.TopToBottom; |
| | | |
| | | _main_chart_diagram = (XYDiagram)this.chartControl1.Diagram; |
| | | _pane_qh = _main_chart_diagram.DefaultPane; |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region Add Update Curve |
| | | #region Add Set |
| | | |
| | | /// <summary> |
| | | /// 添加曲线 |
| | |
| | | return; |
| | | _vm_list = new List<PumpSerialParallelInfoViewModel>(); |
| | | _design_pt = design_pt; |
| | | _initialData = true; |
| | | _vm_list.AddRange(vm_list); |
| | | UpdateChart(true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加曲线 |
| | | /// </summary> |
| | | /// <param name="vm_list"></param> |
| | | public void Add(List<PumpSerialParallelInfoViewModel> vm_list) |
| | | { |
| | | if (vm_list == null || !vm_list.Any()) |
| | | return; |
| | | _vm_list = new List<PumpSerialParallelInfoViewModel>(); |
| | | _initialData = true; |
| | | _vm_list.AddRange(vm_list); |
| | | UpdateChart(true); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加曲线 |
| | | /// </summary> |
| | | /// <param name="vm"></param> |
| | | public void Add(PumpSerialParallelInfoViewModel vm) |
| | | { |
| | | if (vm == null) |
| | | return; |
| | | if (_vm_list == null) |
| | | _vm_list = new List<PumpSerialParallelInfoViewModel>(); |
| | | _initialData = true; |
| | | _vm_list.Add(vm); |
| | | UpdateChart(true); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设置曲线 |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <param name="cubic_spline_qh"></param> |
| | | /// <param name="cubic_spline_qe"></param> |
| | | /// <param name="cubic_spline_qp"></param> |
| | | /// <param name="qh"></param> |
| | | /// <param name="qe"></param> |
| | | /// <param name="qp"></param> |
| | | /// <param name="name"></param> |
| | | public void Set(string id, Yw.Geometry.CubicSpline2d cubic_spline_qh, Yw.Geometry.CubicSpline2d cubic_spline_qe, Yw.Geometry.CubicSpline2d cubic_spline_qp, string name = "") |
| | | public void Set(string id, Yw.Geometry.CubicSpline2d qh, Yw.Geometry.CubicSpline2d qe, Yw.Geometry.CubicSpline2d qp, string name = "") |
| | | { |
| | | var exist = _vm_list.FirstOrDefault(x => x.Id == id); |
| | | if (exist == null) |
| | |
| | | { |
| | | exist.Name = name; |
| | | } |
| | | exist.QhCalc = cubic_spline_qh; |
| | | exist.QeCalc = cubic_spline_qe; |
| | | exist.QpCalc = cubic_spline_qp; |
| | | exist.QhCalc = qh; |
| | | exist.QeCalc = qe; |
| | | exist.QpCalc = qp; |
| | | |
| | | UpdateChart(true); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设置设计点 |
| | | /// </summary> |
| | |
| | | public void SetDesignPt(Yw.Geometry.Point2d design_pt) |
| | | { |
| | | _design_pt = design_pt; |
| | | UpdateChart(true); |
| | | UpdateChart(true,true); |
| | | } |
| | | |
| | | |
| | |
| | | /// 更新图表 |
| | | /// </summary> |
| | | /// <param name="calc_coordinate">计算坐标</param> |
| | | public void UpdateChart(bool calc_coordinate = false) |
| | | public void UpdateChart(bool calc_coordinate = false, bool calc_eq = false) |
| | | { |
| | | if (calc_coordinate || _coordinate_paras == null) |
| | | { |
| | |
| | | CalcCoordinate(); |
| | | } |
| | | |
| | | CalcSeries(); |
| | | CalcSeries(calc_eq); |
| | | |
| | | CalcChartAxis(); |
| | | |
| | | CalcWorkPointByQ(); |
| | | |
| | | CalcTextAnchorPoint(); |
| | | |
| | | } |
| | | |
| | | #endregion |
| | |
| | | _pane_qp.Visibility = ChartElementVisibility.Hidden; |
| | | |
| | | |
| | | _pane_qe.Visibility = _cubic_spline_qe_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden; |
| | | _pane_qp.Visibility = _cubic_spline_qp_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden; |
| | | _pane_qe.Visibility = _qe_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden; |
| | | _pane_qp.Visibility = _qp_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden; |
| | | |
| | | //计算刻度 Q |
| | | var axisQLabels = new List<CustomAxisLabel>(); |
| | |
| | | _axis_y_qh.GridLines.Visible = true; |
| | | |
| | | //效率 |
| | | if (_maxE > _minE && _cubic_spline_qe_visible) |
| | | if (_maxE > _minE && _qe_visible) |
| | | { |
| | | //计算刻度 |
| | | var axisQELabels = new List<CustomAxisLabel>(); |
| | |
| | | _axis_y_qp.GridLines.Visible = true; |
| | | } |
| | | |
| | | var minQ = _coordinate_paras.CoordMinQ; |
| | | var maxQ = _coordinate_paras.DispMaxQ(); |
| | | |
| | | _axis_x_q.SetAxisRange(_coordinate_paras.CoordMinQ, _coordinate_paras.DispMaxQ()); |
| | | _axis_y_qh.SetAxisRange(_coordinate_paras.DispMinH(), _coordinate_paras.DispMaxH()); |
| | | _axis_y_qe.SetAxisRange(_coordinate_paras.DispMinE(), _coordinate_paras.DispMaxE()); |
| | | _axis_y_qp.SetAxisRange(_coordinate_paras.DispMinP(), _coordinate_paras.DispMaxP()); |
| | | |
| | | var minH = _coordinate_paras.DispMinH(); |
| | | var maxH = _coordinate_paras.DispMaxH(); |
| | | |
| | | |
| | | var minE = _coordinate_paras.DispMinE(); |
| | | var maxE = _coordinate_paras.DispMaxE(); |
| | | |
| | | |
| | | |
| | | var minP = _coordinate_paras.DispMinP(); |
| | | var maxP = _coordinate_paras.DispMaxP(); |
| | | |
| | | if (double.IsNaN(minP)||double.IsNaN(maxP)) |
| | | { |
| | | minP = 0; |
| | | maxP = 1000; |
| | | } |
| | | |
| | | _axis_x_q.SetAxisRange(minQ, maxQ); |
| | | _axis_y_qh.SetAxisRange(minH, maxH); |
| | | _axis_y_qe.SetAxisRange(minE, maxE); |
| | | _axis_y_qp.SetAxisRange(minP, maxP); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 计算系列 |
| | | /// </summary> |
| | | private void CalcSeries() |
| | | private void CalcSeries(bool calc_eq) |
| | | { |
| | | this.chartControl1.BeginInit(); |
| | | this.chartControl1.Series.Clear(); |
| | |
| | | { |
| | | foreach (var vm in _vm_list) |
| | | { |
| | | if (!vm.IsSerialParallel) |
| | | if (!vm.IsDefault) |
| | | { |
| | | CreateLineSeries(vm); |
| | | } |
| | | else |
| | | { |
| | | CreateLineSeries(vm); |
| | | CreateEqSeries(vm, _design_pt); |
| | | if (calc_eq) |
| | | CreateEqSeries(vm, _design_pt); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LineVisible = false; |
| | | //LineVisible = false; |
| | | } |
| | | this.chartControl1.EndInit(); |
| | | } |
| | |
| | | if (_vm_list == null || !_vm_list.Any()) |
| | | return; |
| | | |
| | | if (_vm_list.Exists(x => x.IsSerialParallel)) |
| | | if (_vm_list.Exists(x => x.IsDefault)) |
| | | { |
| | | _work_pt_txt_annot.Visible = true; |
| | | } |
| | |
| | | OnCalcQueryPoint(vm.Id, workPoint); |
| | | } |
| | | |
| | | if (vm.IsSerialParallel) |
| | | if (vm.IsDefault) |
| | | { |
| | | _work_pt_txt_annot.Visible = false; |
| | | } |
| | |
| | | workInfoStringBuilder.Append($"功率:{workPoint.P.ToString("N1")} "); |
| | | } |
| | | |
| | | if (vm.IsSerialParallel) |
| | | if (vm.IsDefault) |
| | | { |
| | | _work_pt_txt_annot.Text = workInfoStringBuilder.ToString(); |
| | | _work_pt_txt_annot.AutoSize = true; |
| | |
| | | series_qh.SeriesPointsSorting = SortingMode.None; |
| | | series_qh.SeriesPointsSortingKey = SeriesPointKey.Value_1; |
| | | series_qh.View = series_qh_view; |
| | | series_qh.Visible = _cubic_spline_qh_visible; |
| | | series_qh.Visible = _qh_visible; |
| | | |
| | | var pointsQH = curve.QhCalc.GetPointList(12); |
| | | for (int i = 0; i < pointsQH.Count; i++) |
| | |
| | | } |
| | | |
| | | var point_qh = pointsQH[pointsQH.Count() - 1]; |
| | | var anchor_pt_qh = new DevExpress.XtraCharts.PaneAnchorPoint(); |
| | | anchor_pt_qh.Pane = _pane_qh; |
| | | anchor_pt_qh.AxisXCoordinate.AxisValue = point_qh.X.ToString(); |
| | | anchor_pt_qh.AxisYCoordinate.AxisValue = point_qh.Y.ToString(); |
| | | var anchor_qh_pt = new DevExpress.XtraCharts.PaneAnchorPoint(); |
| | | anchor_qh_pt.Pane = _pane_qh; |
| | | anchor_qh_pt.AxisXCoordinate.AxisValue = point_qh.X.ToString(); |
| | | anchor_qh_pt.AxisYCoordinate.AxisValue = point_qh.Y.ToString(); |
| | | |
| | | var position_qh = new DevExpress.XtraCharts.RelativePosition(); |
| | | position_qh.Angle = 30; |
| | |
| | | |
| | | var txt_qh = new TextAnnotation(); |
| | | txt_qh.Border.Visibility = DefaultBoolean.False; |
| | | txt_qh.AnchorPoint = anchor_pt_qh; |
| | | txt_qh.AnchorPoint = anchor_qh_pt; |
| | | txt_qh.AutoHeight = true; |
| | | txt_qh.AutoWidth = true; |
| | | txt_qh.BackColor = System.Drawing.Color.Transparent; |
| | |
| | | series_qe.SeriesPointsSorting = SortingMode.None; |
| | | series_qe.SeriesPointsSortingKey = SeriesPointKey.Value_1; |
| | | series_qe.View = series_qe_view; |
| | | series_qe.Visible = _cubic_spline_qe_visible; |
| | | series_qe.Visible = _qe_visible; |
| | | |
| | | var pointsQE = curve.QeCalc.GetPointList(12); |
| | | for (int i = 0; i < pointsQE.Count; i++) |
| | |
| | | series_qp.SeriesPointsSorting = SortingMode.None; |
| | | series_qp.SeriesPointsSortingKey = SeriesPointKey.Value_1; |
| | | series_qp.View = series_qp_view; |
| | | series_qp.Visible = _cubic_spline_qp_visible; |
| | | series_qp.Visible = _qp_visible; |
| | | |
| | | var pointsQP = curve.QpCalc.GetPointList(12); |
| | | for (int i = 0; i < pointsQP.Count; i++) |
| | |
| | | return; |
| | | } |
| | | var eq = eq_paras.EquipCurve; |
| | | if (!eq.IsValid()) |
| | | { |
| | | ClearEqSeries(); |
| | | return; |
| | | } |
| | | |
| | | _series_eq = new DevExpress.XtraCharts.Series(); |
| | | _series_eq.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical; |
| | |
| | | _series_eq_pt.SeriesPointsSortingKey = SeriesPointKey.Value_1; |
| | | _series_eq_pt.View = series_eq_pt_view; |
| | | _series_eq_pt.Visible = _cubic_spline_eq_visible; |
| | | _series_eq_pt.Points.Add(new SeriesPoint(design_pt.X, new double[] { design_pt.Y })); |
| | | _series_eq_pt.Points.Add(new SeriesPoint(sect_pt.X, new double[] { sect_pt.Y })); |
| | | |
| | | this.chartControl1.Series.Add(_series_eq_pt); |
| | | this.chartControl1.EndInit(); |
| | |
| | | return; |
| | | foreach (var item in _vm_list) |
| | | { |
| | | if (item.IsSerialParallel) |
| | | if (item.IsDefault) |
| | | continue; |
| | | var qh = item.QhCalc; |
| | | var qe = item.QeCalc; |