From 45929342d7825d680781001cbf6beb87be541faa Mon Sep 17 00:00:00 2001 From: Shuxia Ning <NingShuxia0927@outlook.com> Date: 星期三, 04 十二月 2024 10:01:13 +0800 Subject: [PATCH] 曲线修改 --- WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.Designer.cs | 32 ---- WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationChart.cs | 24 +- WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/RandomColorHelper.cs | 64 +++++++++ WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/03-variable-speed/PumpVariableSpeedChart.cs | 2 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/11-pump/03-analy/SimulationSingleWorkingPumpAnalyCtrl.cs | 1 WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewItemViewModel.cs | 5 WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationViewModel.cs | 3 WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewViewModel.cs | 4 WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/02-multi/01-parallel/PumpParallelChart.cs | 2 WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.cs | 229 ++++++++++++++------------------ 10 files changed, 193 insertions(+), 173 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/11-pump/03-analy/SimulationSingleWorkingPumpAnalyCtrl.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/11-pump/03-analy/SimulationSingleWorkingPumpAnalyCtrl.cs index ec59e0a..71a6956 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/11-pump/03-analy/SimulationSingleWorkingPumpAnalyCtrl.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/11-pump/03-analy/SimulationSingleWorkingPumpAnalyCtrl.cs @@ -54,6 +54,7 @@ } var vm = CreateViewModel(pump); this.pumpVariableSpeedViewChart1.SetBindingData(vm); + this.pumpVariableSpeedViewChart1.SetDesignPoint(70,80); } //鍒涘缓 diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/RandomColorHelper.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/RandomColorHelper.cs new file mode 100644 index 0000000..5e72fa5 --- /dev/null +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/RandomColorHelper.cs @@ -0,0 +1,64 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yw.WinFrmUI.Phart +{ + /// <summary> + /// 闅忔満鑹茶緟鍔╃被 + /// </summary> + public class RandomColorHelper + { + + private static readonly List<Color> _color_array = new List<Color>() + { + Color.Red, Color.Blue, Color.Green,Color.DodgerBlue, + Color.Fuchsia, Color.MidnightBlue, Color.Maroon, Color.Aquamarine, + Color.Bisque,Color.BurlyWood + }; + + /// <summary> + /// 鑾峰彇闅忔満棰滆壊 + /// </summary> + /// <returns></returns> + public static Color Get(int count) + { + if (count < _color_array.Count) + { + return _color_array[count]; + } + + //var _random = new Random(); + //int r = _random.Next(1, 256); + //int g = _random.Next(1, 256); + //int b = _random.Next(1, 256); + //return Color.FromArgb(r, g, b); + + return GetRandomDarkColor(); + } + + + private static Color GetRandomDarkColor() + { + Random random = new Random(); + int r, g, b; + do + { + r = random.Next(256); + g = random.Next(256); + b = random.Next(256); + } while (CalculateBrightness(r, g, b) > 128); // 纭繚棰滆壊鏄繁鑹� + + return Color.FromArgb(r, g, b); + } + + private static int CalculateBrightness(int r, int g, int b) + { + // 璁$畻棰滆壊鐨勪寒搴︼紝浜害鍊艰秺浣庯紝棰滆壊瓒婃繁 + return (r + g + b) / 3; + } + + } +} diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationChart.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationChart.cs index 861dd54..150ff62 100644 --- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationChart.cs +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationChart.cs @@ -260,14 +260,14 @@ return; } - start_head ??= _coordinate.DispMinH(); + start_head ??= _coordinate.DispMinH(); var equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_vm.CurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d sect_pt); if (equip_line == null || sect_pt == null) return; _equip_line = equip_line; _equip_sect_pt = sect_pt; - + double flow = 0, head = 0; double? eff = null, power = null; flow = sect_pt.X; @@ -282,12 +282,12 @@ eff = _vm.CurveQE.GetPointY(flow); power = PumpCalcHelper.CalculateP(flow, head, eff.Value); } - + var design_pt_list = new List<PumpDesignPointViewModel> { new() { - Id = _vm.Id + "棰濆畾", - Name = _vm.Name + "(棰濆畾)", + Id = _vm.Id, + Name = _vm.Name, Q = flow, H = head, E = eff, @@ -295,12 +295,12 @@ Hz = _vm.RatedHz, N = _vm.RatedN } - }; + }; if (_vm.CurrentStatus) { var current_equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_vm.CurrentCurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d current_sect_pt); - if ( current_sect_pt == null) + if (current_sect_pt == null) return; double current_flow = 0, current_head = 0; double? current_eff = null, current_power = null; @@ -315,7 +315,7 @@ { current_eff = _vm.CurrentCurveQE.GetPointY(current_flow); current_power = PumpCalcHelper.CalculateP(current_flow, current_head, current_eff.Value); - } + } design_pt_list.Add(new() { @@ -329,7 +329,7 @@ N = _vm.CurrentN }); - } + } this.DesignPointChangedEvent?.Invoke(design_pt_list); UpdateChart(true); @@ -560,7 +560,7 @@ } //鍔熺巼 - if (_max_power > _min_power) + if (_max_power > _min_power && _qp_visible) { //璁$畻鍒诲害 var labels = new List<CustomAxisLabel>(); @@ -816,7 +816,7 @@ txt_qh.RuntimeMoving = true; txt_qh.RuntimeResizing = false; txt_qh.RuntimeRotation = false; - txt_qh.Text = vm.Name; + txt_qh.Text = $"{vm.CurrentN}({vm.CurrentHz}hz)"; txt_qh.TextColor = PumpChartDisplay.CurveColorQH; txt_qh.ShapePosition = position_qh; txt_qh.Visible = _line_name_visible; @@ -951,7 +951,7 @@ txt_qh.RuntimeMoving = true; txt_qh.RuntimeResizing = false; txt_qh.RuntimeRotation = false; - txt_qh.Text = vm.Name; + txt_qh.Text = $"{vm.CurrentN}({vm.CurrentHz}hz)"; txt_qh.TextColor = PumpChartDisplay.CurveColorQH; txt_qh.ShapePosition = position_qh; txt_qh.Visible = _line_name_visible; diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationViewModel.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationViewModel.cs index 53e9c41..a19b332 100644 --- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationViewModel.cs +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/02-operation/PumpOperationViewModel.cs @@ -9,7 +9,7 @@ public PumpOperationViewModel(PumpOperationViewModel rhs) { this.Id = rhs.Id; - this.Name = rhs.Name; + this.Name = rhs.Name; this.RatedQ = rhs.RatedQ; this.RatedH = rhs.RatedH; this.RatedP = rhs.RatedP; @@ -37,6 +37,7 @@ /// 鍚嶇О /// </summary> public string Name { get; set; } + /// <summary> /// 棰濆畾娴侀噺 diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/03-variable-speed/PumpVariableSpeedChart.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/03-variable-speed/PumpVariableSpeedChart.cs index 41b466b..fdc4b36 100644 --- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/03-variable-speed/PumpVariableSpeedChart.cs +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/03-variable-speed/PumpVariableSpeedChart.cs @@ -514,7 +514,7 @@ } //鍔熺巼 - if (_max_power > _min_power) + if (_max_power > _min_power && _qp_visible) { //璁$畻鍒诲害 var labels = new List<CustomAxisLabel>(); diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.Designer.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.Designer.cs index 194ced6..ce221bc 100644 --- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.Designer.cs +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.Designer.cs @@ -29,11 +29,7 @@ private void InitializeComponent() { components = new System.ComponentModel.Container(); - DevExpress.XtraCharts.TextAnnotation textAnnotation1 = new DevExpress.XtraCharts.TextAnnotation(); - DevExpress.XtraCharts.ChartAnchorPoint chartAnchorPoint1 = new DevExpress.XtraCharts.ChartAnchorPoint(); - DevExpress.XtraCharts.RelativePosition relativePosition1 = new DevExpress.XtraCharts.RelativePosition(); DevExpress.XtraCharts.XYDiagram xyDiagram1 = new DevExpress.XtraCharts.XYDiagram(); - DevExpress.XtraCharts.ConstantLine constantLine1 = new DevExpress.XtraCharts.ConstantLine(); DevExpress.XtraCharts.LayoutDefinition layoutDefinition1 = new DevExpress.XtraCharts.LayoutDefinition(); DevExpress.XtraCharts.LayoutDefinition layoutDefinition2 = new DevExpress.XtraCharts.LayoutDefinition(); DevExpress.XtraCharts.LayoutDefinition layoutDefinition3 = new DevExpress.XtraCharts.LayoutDefinition(); @@ -61,9 +57,7 @@ barDockControlRight = new DevExpress.XtraBars.BarDockControl(); bar1 = new DevExpress.XtraBars.Bar(); ((System.ComponentModel.ISupportInitialize)chartControl1).BeginInit(); - ((System.ComponentModel.ISupportInitialize)textAnnotation1).BeginInit(); ((System.ComponentModel.ISupportInitialize)xyDiagram1).BeginInit(); - ((System.ComponentModel.ISupportInitialize)constantLine1).BeginInit(); ((System.ComponentModel.ISupportInitialize)xyDiagramPane1).BeginInit(); ((System.ComponentModel.ISupportInitialize)secondaryAxisy1).BeginInit(); ((System.ComponentModel.ISupportInitialize)secondaryAxisy2).BeginInit(); @@ -78,31 +72,7 @@ // // chartControl1 // - chartAnchorPoint1.X = 951; - chartAnchorPoint1.Y = 30; - textAnnotation1.AnchorPoint = chartAnchorPoint1; - textAnnotation1.AnnotationID = 0; - textAnnotation1.AutoHeight = true; - textAnnotation1.AutoWidth = true; - textAnnotation1.BackColor = Color.FromArgb(255, 255, 255); - textAnnotation1.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.None; - textAnnotation1.Name = "TextAnnoWorkPoint"; - relativePosition1.Angle = -131.51672853100234D; - relativePosition1.ConnectorLength = 81.467785044151043D; - textAnnotation1.ShapePosition = relativePosition1; - textAnnotation1.Text = "宸ヤ綔鐐�"; - textAnnotation1.TextColor = Color.FromArgb(0, 0, 0); - chartControl1.AnnotationRepository.AddRange(new DevExpress.XtraCharts.Annotation[] { textAnnotation1 }); chartControl1.BorderOptions.Visibility = DevExpress.Utils.DefaultBoolean.False; - constantLine1.AxisValueSerializable = "1"; - constantLine1.ConstantLineID = 0; - constantLine1.LineStyle.LineJoin = System.Drawing.Drawing2D.LineJoin.Miter; - constantLine1.LineStyle.Thickness = 2; - constantLine1.Name = "WorkPointLine"; - constantLine1.ShowInLegend = false; - constantLine1.Title.DXFont = new DevExpress.Drawing.DXFont("Tahoma", 8F); - constantLine1.Title.Text = "宸ヤ綔鐐�"; - xyDiagram1.AxisX.ConstantLines.AddRange(new DevExpress.XtraCharts.ConstantLine[] { constantLine1 }); xyDiagram1.AxisX.Title.Text = "娴侀噺 锛坢鲁/h锛�"; xyDiagram1.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.Default; xyDiagram1.AxisX.VisibleInPanesSerializable = "-1"; @@ -310,8 +280,6 @@ Controls.Add(barDockControlTop); Name = "PumpVariableSpeedViewChart"; Size = new Size(1023, 857); - ((System.ComponentModel.ISupportInitialize)textAnnotation1).EndInit(); - ((System.ComponentModel.ISupportInitialize)constantLine1).EndInit(); ((System.ComponentModel.ISupportInitialize)xyDiagramPane1).EndInit(); ((System.ComponentModel.ISupportInitialize)secondaryAxisy1).EndInit(); ((System.ComponentModel.ISupportInitialize)secondaryAxisy2).EndInit(); diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.cs index 9555024..3f754ad 100644 --- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.cs +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewChart.cs @@ -17,16 +17,16 @@ } #region Private Variable - + private readonly string _tag_qh = "QH", _tag_qe = "QE", _tag_qp = "QP"; private XYDiagram _diagram; - private XYDiagramDefaultPane _default_pane; + private XYDiagramDefaultPane _default_pane; private XYDiagramPane _bottom_pane; private AxisX _axis_x_flow; private AxisY _axis_y_head; - private SecondaryAxisY _axis_y_eff, _axis_y_power; - + private SecondaryAxisY _axis_y_eff, _axis_y_power; + private PumpCoordinate _coordinate; private bool _qe_visible = true; @@ -34,23 +34,22 @@ private bool _equip_visible = true; private Yw.Geometry.CubicSpline2d _equip_line = null; - private Yw.Geometry.Point2d _equip_pt = null; - private List<Tuple<string, Yw.Geometry.Point2d, Yw.Geometry.Point2d, Yw.Geometry.Point2d>> _equip_sect_pt_list; + private Yw.Geometry.Point2d _equip_pt = null; + private List<Tuple<string, Color, double, double, double?, double?>> _equip_sect_pt_list; private bool _initial_data = false; private PumpVariableSpeedViewViewModel _vm = null; #endregion - + #region Public Evnet /// <summary> /// 鍧愭爣鍙樻崲浜嬩欢 /// </summary> public event Action<PumpCoordinate> CoordinateChangedEvent = null; - - + #endregion #region Initial @@ -64,11 +63,11 @@ this.chartControl1.Legend.Direction = DevExpress.XtraCharts.LegendDirection.TopToBottom; _diagram = (XYDiagram)this.chartControl1.Diagram; - _default_pane = _diagram.DefaultPane; + _default_pane = _diagram.DefaultPane; _bottom_pane = (XYDiagramPane)_diagram.FindPaneByName("BottomPanel"); _axis_x_flow = _diagram.AxisX; - _axis_x_flow.SetAxisXQDisplay(); + _axis_x_flow.SetAxisXQDisplay(); _axis_y_head = _diagram.AxisY; _axis_y_head.SetAxisYQHDisplay(); _axis_y_eff = _diagram.SecondaryAxesY.GetAxisByName("AxisYQE"); @@ -77,7 +76,7 @@ _axis_y_power = _diagram.SecondaryAxesY.GetAxisByName("AxisYQP"); _axis_y_power.SetSecondaryAxisYQPDisplay(); - + this.chartControl1.SetChartMonoColorDisplay(); _axis_x_flow.Visibility = DefaultBoolean.False; _axis_x_flow.GridLines.Visible = false; @@ -87,7 +86,7 @@ _axis_y_eff.GridLines.Visible = false; _axis_y_power.Visibility = DefaultBoolean.False; _axis_y_power.GridLines.Visible = false; - + this.chartControl1.CustomPaint += ChartControl1_CustomPaint; } @@ -105,7 +104,16 @@ pen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; foreach (var tuple in _equip_sect_pt_list) { - DrawEquipPoint(dxArgs.Cache, pen, tuple.Item2, tuple.Item3, tuple.Item4); + var color = tuple.Item2; + var flow = tuple.Item3; + var head = tuple.Item4; + var eff = tuple.Item5; + var power = tuple.Item6; + DrawWorkPoint(dxArgs.Cache, color, _axis_y_head, flow, head); + if (eff.HasValue && _qe_visible) + DrawWorkPoint(dxArgs.Cache, color, _axis_y_eff, flow, eff.Value); + if (power.HasValue && _qp_visible) + DrawWorkPoint(dxArgs.Cache, color, _axis_y_power, flow, power.Value); } DrawEquipLine(dxArgs.Cache, pen, _equip_line); @@ -131,36 +139,12 @@ cache.DrawPath(pen, path); } - private void DrawEquipPoint(GraphicsCache cache, Pen pen, Yw.Geometry.Point2d qh_sect_pt, Yw.Geometry.Point2d qe_sect_pt, Yw.Geometry.Point2d qp_sect_pt) + private void DrawWorkPoint(GraphicsCache cache, Color color, AxisYBase axis_y, double x, double y) { - if (qh_sect_pt == null) - return; - - var offset_size = 10; - var qh_x = qh_sect_pt.X; - var qh_pt = _diagram.DiagramToPoint(qh_sect_pt.X, qh_sect_pt.Y, _axis_x_flow, _axis_y_head); - - var qh_pt_x = qh_pt.Point.X; - var qh_pt_y = qh_pt.Point.Y; - cache.DrawLine(pen, new Point(qh_pt_x, qh_pt_y - offset_size), new Point(qh_pt_x, qh_pt_y + offset_size)); - - if (qe_sect_pt != null && _qe_visible) - { - var qe_pt = _diagram.DiagramToPoint(qe_sect_pt.X, qe_sect_pt.Y, _axis_x_flow, _axis_y_eff); - var qe_pt_x = qe_pt.Point.X; - var qe_pt_y = qe_pt.Point.Y; - cache.DrawLine(pen, new Point(qe_pt_x, qe_pt_y - offset_size), new Point(qe_pt_x, qe_pt_y + offset_size)); - } - if (qp_sect_pt != null && _qp_visible) - { - var qp_pt = _diagram.DiagramToPoint(qp_sect_pt.X, qp_sect_pt.Y, _axis_x_flow, _axis_y_power); - var qp_pt_x = qp_pt.Point.X; - var qp_pt_y = qp_pt.Point.Y; - cache.DrawLine(pen, new Point(qp_pt_x, qp_pt_y - offset_size), new Point(qp_pt_x, qp_pt_y + offset_size)); - } - + var dg_pt = _diagram.DiagramToPoint(x, y, _axis_x_flow, axis_y); + cache.FillEllipse((int)(dg_pt.Point.X - 5), (int)(dg_pt.Point.Y - 5), 10, 10, color); } - + /// <summary> /// 鍒濆鍖栧浘琛ㄦ暟鎹� /// </summary> @@ -195,64 +179,61 @@ _equip_line = null; _equip_sect_pt_list = null; if (_vm == null) - { + { return; } start_head ??= _coordinate.DispMinH(); - + var equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(_vm.CurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d sect_pt); if (equip_line == null || sect_pt == null) return; _equip_line = equip_line; - _equip_sect_pt_list = new List<Tuple<string, Geometry.Point2d, Geometry.Point2d, Geometry.Point2d>>(); + _equip_sect_pt_list = new List<Tuple<string, Color, double, double, double?, double?>>(); - Yw.Geometry.Point2d sect_pt_eff=null, sect_pt_power = null; - if (_vm.CurveQE != null) - { - var eff = _vm.CurveQE.GetPointY(sect_pt.X); - sect_pt_eff = new Geometry.Point2d(sect_pt.X, eff); - } + double sect_flow = sect_pt.X; + double sect_head = _vm.CurveQH.GetPointYUnlimited(sect_flow); + double? sect_eff = null, sect_power = null; if (_vm.CurveQP != null) { - var power = _vm.CurveQP.GetPointY(sect_pt.X); - sect_pt_power = new Geometry.Point2d(sect_pt.X, power); + sect_power = _vm.CurveQP.GetPointYUnlimited(sect_flow); + //sect_eff = PumpCalcHelper.CalculateE(sect_flow, sect_head, sect_power.Value); } - - _equip_sect_pt_list.Add(new(_vm.Id, sect_pt,sect_pt_eff, sect_pt_power)); - foreach (var vm in _vm.Items) + if (_vm.CurveQE != null) { - double flow = 0, head = 0; - double? eff = null, power = null; - - var pump_equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(vm.CurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d pump_sect_pt); - if (pump_equip_line == null || pump_sect_pt == null) - return; - Yw.Geometry.Point2d pump_sect_pt_eff = null, pump_sect_pt_power = null; - - flow = pump_sect_pt.X; - head = vm.CurveQH.GetPointYUnlimited(flow); - if (vm.CurveQP != null) - { - power = vm.CurveQP.GetPointYUnlimited(flow); - eff = PumpCalcHelper.CalculateE(flow, head, power.Value); - - pump_sect_pt_eff = new Geometry.Point2d(flow, eff.Value); - pump_sect_pt_power = new Geometry.Point2d(flow, power.Value); - } - else if (vm.CurveQE != null) - { - eff = vm.CurveQE.GetPointYUnlimited(flow); - power = PumpCalcHelper.CalculateP(flow, head, eff.Value); - - pump_sect_pt_eff = new Geometry.Point2d(flow, eff.Value); - pump_sect_pt_power = new Geometry.Point2d(flow, power.Value); - } - - _equip_sect_pt_list.Add(new(vm.Id, new Geometry.Point2d(flow, head), pump_sect_pt_eff, pump_sect_pt_power)); + sect_eff = _vm.CurveQE.GetPointYUnlimited(sect_flow); + // sect_power = PumpCalcHelper.CalculateP(sect_flow, sect_head, sect_eff.Value); } - - UpdateChart(true); + + _equip_sect_pt_list.Add(new(_vm.Id, _vm.Color, sect_flow, sect_head, sect_eff, sect_power)); + if (_vm.Items != null && _vm.Items.Any()) + { + foreach (var vm in _vm.Items) + { + double flow = 0, head = 0; + double? eff = null, power = null; + + var pump_equip_line = Yw.Geometry.EquipCurveHelper.CalcEquipCurve(vm.CurveQH, _equip_pt, start_head.Value, out Yw.Geometry.Point2d pump_sect_pt); + if (pump_equip_line == null || pump_sect_pt == null) + return; + + flow = pump_sect_pt.X; + head = vm.CurveQH.GetPointYUnlimited(flow); + if (vm.CurveQP != null) + { + power = vm.CurveQP.GetPointYUnlimited(flow); + //eff = PumpCalcHelper.CalculateE(flow, head, power.Value); + } + if (vm.CurveQE != null) + { + eff = vm.CurveQE.GetPointYUnlimited(flow); + //power = PumpCalcHelper.CalculateP(flow, head, eff.Value); + } + + _equip_sect_pt_list.Add(new(vm.Id, vm.Color, flow, head, eff, power)); + } + } + UpdateChart(true); } @@ -279,7 +260,7 @@ CalcSeries(); - CalcChartAxis(); + CalcChartAxis(); } #endregion @@ -416,11 +397,9 @@ _axis_y_eff.GridLines.Visible = false; _axis_y_power.Visibility = DefaultBoolean.False; _axis_y_power.GridLines.Visible = false; - + _bottom_pane.Visibility = ChartElementVisibility.Hidden; - - _bottom_pane.Visibility = _qp_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden; //璁$畻鍒诲害 Q @@ -471,7 +450,7 @@ } //鍔熺巼 - if (_max_power > _min_power) + if (_max_power > _min_power && _qp_visible) { //璁$畻鍒诲害 var labels = new List<CustomAxisLabel>(); @@ -511,7 +490,7 @@ var grid_count_power = _coordinate.EndLineNoP - _coordinate.StartLineNoP; var min_axis_power = _coordinate.CoordMinP + _coordinate.StartLineNoP * _coordinate.CoordSpaceP; var max_axis_power = min_axis_power + grid_count_power * _coordinate.CoordSpaceP; - _axis_y_power.SetAxisRange(min_axis_power, max_axis_power); + _axis_y_power.SetAxisRange(min_axis_power, max_axis_power); } /// <summary> @@ -521,36 +500,33 @@ { this.chartControl1.BeginInit(); this.chartControl1.Series.Clear(); - - var annotation_count = this.chartControl1.AnnotationRepository.Count; - for (int i = annotation_count - 1; i > 0; i--) - { - if (i == 0) - break; - this.chartControl1.AnnotationRepository.RemoveAt(i); - } - + this.chartControl1.AnnotationRepository.Clear(); this.chartControl1.Legend.CustomItems.Clear(); + if (_vm != null) { - CreateLineSeries(_vm.Id, _vm.Name, _vm.CurveQH, _vm.CurveQE, _vm.CurveQP); + _vm.Color = RandomColorHelper.Get(0); + CreateLineSeries(_vm.Id, _vm.Color, _vm.Name, _vm.CurveQH, _vm.CurveQE, _vm.CurveQP); if (_vm.Items != null && _vm.Items.Any()) { - foreach (var vm in _vm.Items) + for (int i = 0; i < _vm.Items.Count; i++) { - CreateLineSeries(vm.Id, vm.Name, vm.CurveQH, vm.CurveQE, vm.CurveQP); + var vm = _vm.Items[i]; + vm.Color = RandomColorHelper.Get(i + 1); + CreateLineSeries(vm.Id, vm.Color, vm.CurveName, vm.CurveQH, vm.CurveQE, vm.CurveQP); } - } + } + } - this.chartControl1.EndInit(); + this.chartControl1.EndInit(); } - 銆� + /// <summary> /// 鍒涘缓绾跨郴鍒� /// </summary> - private void CreateLineSeries(string id, string curve_name, Yw.Geometry.CubicSpline2d qh, Yw.Geometry.CubicSpline2d qe, Yw.Geometry.CubicSpline2d qp) + private void CreateLineSeries(string id, Color color, string curve_name, Yw.Geometry.CubicSpline2d qh, Yw.Geometry.CubicSpline2d qe, Yw.Geometry.CubicSpline2d qp) { var series_qh = new DevExpress.XtraCharts.Series(); series_qh.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical; @@ -563,7 +539,7 @@ var series_qh_view = new DevExpress.XtraCharts.SplineSeriesView(); series_qh_view.LineStyle.Thickness = 2; - //series_qh_view.Color = vm.Color; + series_qh_view.Color = color; series_qh_view.EnableAntialiasing = DefaultBoolean.True; series_qh_view.LineTensionPercent = 50; @@ -594,7 +570,7 @@ txt_qh.AutoHeight = true; txt_qh.AutoWidth = true; txt_qh.BackColor = System.Drawing.Color.Transparent; - //txt_qh.Border.Color = vm.Color; + txt_qh.Border.Color = color; txt_qh.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.Line; txt_qh.DXFont = PumpChartDisplay.AnnoFontQH; txt_qh.Name = _tag_qh + id; @@ -607,7 +583,7 @@ txt_qh.RuntimeResizing = false; txt_qh.RuntimeRotation = false; txt_qh.Text = curve_name; - //txt_qh.TextColor = vm.Color; + txt_qh.TextColor = color; txt_qh.ShapePosition = position_qh; txt_qh.Visible = true; this.chartControl1.AnnotationRepository.Add(txt_qh); @@ -625,7 +601,7 @@ var series_qe_view = new DevExpress.XtraCharts.SplineSeriesView(); series_qe_view.LineStyle.Thickness = 2; - //series_qe_view.Color = vm.Color; + series_qe_view.Color = color; series_qe_view.AxisY = _axis_y_eff; series_qe_view.Pane = _default_pane; series_qe_view.EnableAntialiasing = DefaultBoolean.True; @@ -657,7 +633,7 @@ var series_qp_view = new DevExpress.XtraCharts.SplineSeriesView(); series_qp_view.LineStyle.Thickness = 2; - //series_qp_view.Color = vm.Color; + series_qp_view.Color = color; series_qp_view.AxisY = _axis_y_power; series_qp_view.Pane = _bottom_pane; series_qp_view.EnableAntialiasing = DefaultBoolean.True; @@ -675,26 +651,27 @@ } this.chartControl1.Series.Add(series_qp); - } + } + } - + #endregion - + #region Right Click Menu #region Event - + private void barBtnSetChartAxis_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { SetChartAxis(); - } - + } + private void barCekCurveQEVisible_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { - _qe_visible = this.barCekCurveQEVisible.Checked; + _qe_visible = this.barCekCurveQEVisible.Checked; UpdateChart(); } @@ -702,17 +679,17 @@ { _bottom_pane.Visibility = _bottom_pane.Visibility == ChartElementVisibility.Visible ? ChartElementVisibility.Hidden : ChartElementVisibility.Visible; _qp_visible = _bottom_pane.Visibility == ChartElementVisibility.Visible ? true : false; - + UpdateChart(); } private void barCekCurveEQVisible_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { - _equip_visible = this.barCekCurveEQVisible.Checked; + _equip_visible = this.barCekCurveEQVisible.Checked; } #endregion - - + + /// <summary> /// 璁剧疆鍧愭爣杞� /// </summary> @@ -731,8 +708,8 @@ #endregion - - + + } diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewItemViewModel.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewItemViewModel.cs index 6dd156b..3b20056 100644 --- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewItemViewModel.cs +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewItemViewModel.cs @@ -81,6 +81,11 @@ /// 娴侀噺鍔熺巼绾� /// </summary> public Yw.Geometry.CubicSpline2d CurveQP { get; set; } + + /// <summary> + /// 棰滆壊 + /// </summary> + public Color Color { get; set; } } diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewViewModel.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewViewModel.cs index 73c4457..23bd6bf 100644 --- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewViewModel.cs +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/01-single/04-variable-speed-view/PumpVariableSpeedViewViewModel.cs @@ -85,6 +85,10 @@ /// </summary> public List<PumpVariableSpeedViewItemViewModel> Items { get; set; } + /// <summary> + /// 棰滆壊 + /// </summary> + public Color Color { get; set; } } } diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/02-multi/01-parallel/PumpParallelChart.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/02-multi/01-parallel/PumpParallelChart.cs index 62178c3..e7457cb 100644 --- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/02-multi/01-parallel/PumpParallelChart.cs +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/02-multi/01-parallel/PumpParallelChart.cs @@ -584,7 +584,7 @@ } //鍔熺巼 - if (_max_power > _min_power) + if (_max_power > _min_power && _qp_visible) { //璁$畻鍒诲害 var labels = new List<CustomAxisLabel>(); -- Gitblit v1.9.3