From 0f99d4d12f2eae29bbe343f4b3131f2faeccda5d Mon Sep 17 00:00:00 2001
From: Shuxia Ning <NingShuxia0927@outlook.com>
Date: 星期二, 14 一月 2025 17:31:20 +0800
Subject: [PATCH] 泵曲线修改

---
 WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/04-special/02-working-view/PumpWorkingViewChart.cs |  165 ++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 96 insertions(+), 69 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/04-special/02-working-view/PumpWorkingViewChart.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/04-special/02-working-view/PumpWorkingViewChart.cs
index 0ddd5b3..34fefaf 100644
--- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/04-special/02-working-view/PumpWorkingViewChart.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/01-pump/04-special/02-working-view/PumpWorkingViewChart.cs
@@ -29,8 +29,8 @@
 
         private PumpCoordinate _coordinate;
 
-        private bool _qe_visible = true;
-        private bool _qp_visible = true;
+        private bool _eff_visible = true;
+        private bool _power_visible = true;
 
         private bool _run_point_visible = true;
         private bool _equip_visible = true;
@@ -91,11 +91,11 @@
         /// </summary>
         public bool QEVisible
         {
-            get => _qe_visible;
+            get => _eff_visible;
             set
             {
-                _qe_visible = value;
-                SetQEVisible(_qe_visible);
+                _eff_visible = value;
+                SetQEVisible(_eff_visible);
             }
         }
 
@@ -104,11 +104,11 @@
         /// </summary>
         public bool QPVisble
         {
-            get => _qp_visible;
+            get => _power_visible;
             set
             {
-                _qp_visible = value;
-                SetQPVisible(_qp_visible);
+                _power_visible = value;
+                SetQPVisible(_power_visible);
             }
         }
 
@@ -242,7 +242,7 @@
                         dx_args.Cache.FillEllipse(dg_x, dg_y, 10, 10, color);
                         _rect_list.Add(new(new Rectangle(dg_x, dg_y, 10, 10), color, vm));
                     }
-                    if (eff.HasValue && _qe_visible)
+                    if (eff.HasValue && _eff_visible)
                     {
                         var dg_pt = _diagram.DiagramToPoint(flow, eff.Value, _axis_x_flow, _axis_y_eff);
                         var dg_x = dg_pt.Point.X - 5;
@@ -251,7 +251,7 @@
                         _rect_list.Add(new(new Rectangle(dg_x, dg_y, 10, 10), color, vm));
                     }
 
-                    if (power.HasValue && _qp_visible)
+                    if (power.HasValue && _power_visible)
                     {
                         var dg_pt = _diagram.DiagramToPoint(flow, power.Value, _axis_x_flow, _axis_y_power);
                         var dg_x = dg_pt.Point.X - 5;
@@ -342,15 +342,15 @@
             _vm = vm;
             _initial_data = vm != null;
             if (vm != null)
-            { 
+            {
                 var start_point = new Yw.Geometry.Point2d(0.0, vm.StartH);
                 var end_point = new Yw.Geometry.Point2d(vm.PipeQ, vm.PipeH);
-                if (!end_point.IsZeroPoint())
+                if (vm.PipeQ > 0 && vm.PipeH > 0)
                 {
                     _equip_pt_list = Yw.Pump.PerformParabolaHelper.GetEquipCurvePointList(start_point, end_point, 30);
                 }
-
             }
+
             UpdateChart(true);
         }
 
@@ -440,11 +440,12 @@
 
             if (_vm.Items != null && _vm.Items.Any())
             {
-
                 foreach (var vm in _vm.Items)
                 {
+                    var qh_pt_list = vm.CurveQH.GetPointList(_feat_type_qh);
+                    var max_ratio = vm.Q / qh_pt_list.Max(x => x.X) * 1.05;
                     {
-                        var qh_pt_list = vm.CurveQH.GetPointList(_feat_type_qh);
+                        qh_pt_list = qh_pt_list.GetExpandPointList(_feat_type_qh, 1, max_ratio);
                         var xxx = qh_pt_list.Select(x => x.X);
                         var yyy = qh_pt_list.Select(x => x.Y);
 
@@ -457,7 +458,7 @@
 
                     if (vm.CurveQE != null)
                     {
-                        var qe_pt_list = vm.CurveQE.GetPointList(_feat_type_qe);
+                        var qe_pt_list = vm.CurveQE.GetExpandPointList(_feat_type_qe, 1, max_ratio);
                         var yyy = qe_pt_list.Select(x => x.Y);
                         _min_eff = Math.Min(_min_eff, yyy.Min());
                         _max_eff = Math.Max(_max_eff, yyy.Max());
@@ -465,7 +466,8 @@
 
                     if (vm.CurveQP != null)
                     {
-                        var yyy = vm.CurveQP.GetYList(_feat_type_qp);
+                        var qp_pt_list = vm.CurveQP.GetExpandPointList(_feat_type_qp, 1, max_ratio);
+                        var yyy = qp_pt_list.Select(x => x.Y);
                         _min_power = Math.Min(_min_power, yyy.Min());
                         _max_power = Math.Max(_max_power, yyy.Max());
                         if (vm.P.HasValue)
@@ -513,7 +515,7 @@
 
 
             _bottom_pane.Visibility = ChartElementVisibility.Hidden;
-            _bottom_pane.Visibility = _qp_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden;
+            _bottom_pane.Visibility = _power_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden;
 
             //璁$畻鍒诲害 Q
             var axisQLabels = new List<CustomAxisLabel>();
@@ -545,7 +547,7 @@
             _axis_y_head.GridLines.Visible = true;
 
             //鏁堢巼
-            if (_max_eff > _min_eff && _qe_visible)
+            if (_max_eff > _min_eff && _eff_visible)
             {
                 //璁$畻鍒诲害
                 var labels = new List<CustomAxisLabel>();
@@ -563,7 +565,7 @@
             }
 
             //鍔熺巼
-            if (_max_power > _min_power && _qp_visible)
+            if (_max_power > _min_power && _power_visible)
             {
                 //璁$畻鍒诲害
                 var labels = new List<CustomAxisLabel>();
@@ -587,7 +589,7 @@
             var grid_count_head = _coordinate.EndLineNoH - _coordinate.StartLineNoH;
             var grid_count_eff = _coordinate.EndLineNoE - _coordinate.StartLineNoE;
             int grid_count_up = Math.Max(grid_count_head, grid_count_eff);
-            if (_qe_visible)
+            if (_eff_visible)
             {
                 grid_count_up += 2;//澶氫袱鏉�
             }
@@ -623,14 +625,44 @@
                     for (int i = 0; i < _vm.Items.Count; i++)
                     {
                         var vm = _vm.Items[i];
-                        CreateCurrentLineSeries(vm.Id, vm.Color, vm.CurveName, vm.CurveQH, vm.CurveQE, vm.CurveQP);
+                        var qh = vm.CurveQH.GetFeatCurve(_feat_type_qh);
+                        if (qh.IsInvalid())
+                            continue;
+                        var max_pt = qh.GetPointList().LastOrDefault();
+                        CreateCurrentLineSeries(vm.Id, vm.Color, vm.CurveQH, vm.CurveQE, vm.CurveQP);
+                        CreateTextSeries(vm.Color, vm.CurveName, vm.Q, vm.H);
+                        if (max_pt.X < vm.Q)
+                        {
+                            var max_ratio = vm.Q / max_pt.X * 1.05;
+                            var qh_pt_ex_list = qh.GetPointListByXRatioRange(1, max_ratio, 100);
+                            qh_pt_ex_list = qh_pt_ex_list.Where(x => x.X >= max_pt.X).ToList();
+                            qh_pt_ex_list.Add(max_pt);
+                            CreateLineSeries(vm.Id + "qh", vm.Color, qh_pt_ex_list, _default_pane, _axis_y_head, DashStyle.Dot);
+
+                            if (vm.CurveQE != null && vm.CurveQE.Any() && _eff_visible)
+                            {
+                                var qe = vm.CurveQE.GetFeatCurve(_feat_type_qe);
+                                var qe_pt_ex_list = vm.CurveQE.GetExpandPointList(_feat_type_qe, 1, max_ratio, 100);
+                                qe_pt_ex_list = qe_pt_ex_list.Where(x => x.X >= max_pt.X * 0.8).ToList();
+                                CreateLineSeries(vm.Id + "qe", vm.Color, qe_pt_ex_list, _default_pane, _axis_y_eff, DashStyle.Dot);
+                            }
+
+                            if (vm.CurveQP != null && vm.CurveQP.Any() && _power_visible)
+                            {
+                                var qp = vm.CurveQP.GetFeatCurve(_feat_type_qp);
+                                var qp_pt_ex_list = vm.CurveQP.GetExpandPointList(_feat_type_qp, 1, max_ratio, 100);
+                                qp_pt_ex_list = qp_pt_ex_list.Where(x => x.X >= max_pt.X * 0.8).ToList();
+                                CreateLineSeries(vm.Id + "qp", vm.Color, qp_pt_ex_list, _bottom_pane, _axis_y_power, DashStyle.Dot);
+                            }
+                        }
+
                     }
                 }
 
                 if (_equip_pt_list != null && _equip_pt_list.Any())
                 {
                     var pt = _equip_pt_list.LastOrDefault();
-                    CreateTextSeries(Color.Black, pt.X, pt.Y);
+                    CreateTextSeries(Color.Black, $"{pt.X:N1}m鲁/h  {pt.Y:N1}m", pt.X, pt.Y);
                 }
             }
 
@@ -641,7 +673,7 @@
         /// <summary>
         /// 鍒涘缓绾跨郴鍒�
         /// </summary> 
-        private void CreateCurrentLineSeries(string id, Color color, string curve_name, List<Yw.Geometry.Point2d> qh, List<Yw.Geometry.Point2d> qe, List<Yw.Geometry.Point2d> qp)
+        private void CreateCurrentLineSeries(string id, Color color, List<Yw.Geometry.Point2d> qh, List<Yw.Geometry.Point2d> qe, List<Yw.Geometry.Point2d> qp)
         {
             var series_qh = new DevExpress.XtraCharts.Series();
             series_qh.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
@@ -649,8 +681,6 @@
             series_qh.Name = _tag_qh + id;
             series_qh.ShowInLegend = false;
             series_qh.CrosshairEnabled = DefaultBoolean.False;
-            series_qh.LegendTextPattern = curve_name;
-
 
             var series_qh_view = new DevExpress.XtraCharts.SplineSeriesView();
             series_qh_view.LineStyle.Thickness = 2;
@@ -668,40 +698,6 @@
             {
                 series_qh.Points.Add(new SeriesPoint(pt_qh_list[i].X, new double[] { pt_qh_list[i].Y }));
             }
-
-            var point_qh = pt_qh_list[pt_qh_list.Count() - 1];
-            var anchor_qh_pt = new DevExpress.XtraCharts.PaneAnchorPoint();
-            anchor_qh_pt.Pane = _default_pane;
-            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 = -50;
-            position_qh.ConnectorLength = 10;
-
-            var txt_qh = new TextAnnotation();
-            txt_qh.Border.Visibility = DefaultBoolean.False;
-            txt_qh.AnchorPoint = anchor_qh_pt;
-            txt_qh.AutoHeight = true;
-            txt_qh.AutoWidth = true;
-            txt_qh.BackColor = System.Drawing.Color.Transparent;
-            txt_qh.Border.Color = color;
-            txt_qh.ConnectorStyle = DevExpress.XtraCharts.AnnotationConnectorStyle.Line;
-            txt_qh.DXFont = PumpChartDisplay.AnnoFontQH;
-            txt_qh.Name = _tag_qh + id;
-            txt_qh.Padding.Bottom = 1;
-            txt_qh.Padding.Left = 1;
-            txt_qh.Padding.Right = 1;
-            txt_qh.Padding.Top = 1;
-            txt_qh.RuntimeAnchoring = false;
-            txt_qh.RuntimeMoving = true;
-            txt_qh.RuntimeResizing = false;
-            txt_qh.RuntimeRotation = false;
-            txt_qh.Text = curve_name;
-            txt_qh.TextColor = color;
-            txt_qh.ShapePosition = position_qh;
-            txt_qh.Visible = true;
-            this.chartControl1.AnnotationRepository.Add(txt_qh);
             this.chartControl1.Series.Add(series_qh);
 
             if (qe != null)
@@ -725,7 +721,7 @@
                 series_qe.SeriesPointsSorting = SortingMode.None;
                 series_qe.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                 series_qe.View = series_qe_view;
-                series_qe.Visible = _qe_visible;
+                series_qe.Visible = _eff_visible;
 
                 var pt_qe_list = qe.GetPointList(_feat_type_qe, 100);
                 for (int i = 0; i < pt_qe_list.Count; i++)
@@ -757,7 +753,7 @@
                 series_qp.SeriesPointsSorting = SortingMode.None;
                 series_qp.SeriesPointsSortingKey = SeriesPointKey.Value_1;
                 series_qp.View = series_qp_view;
-                series_qp.Visible = _qp_visible;
+                series_qp.Visible = _power_visible;
 
                 var pt_qp_list = qp.GetPointList(_feat_type_qp, 100);
                 for (int i = 0; i < pt_qp_list.Count; i++)
@@ -770,13 +766,44 @@
 
         }
 
+        /// <summary>
+        /// 鍒涘缓绾跨郴鍒�
+        /// </summary> 
+        private void CreateLineSeries(string id, Color color, List<Yw.Geometry.Point2d> pt_list, XYDiagramPaneBase pane, AxisYBase axiy, DashStyle dash = DashStyle.Solid)
+        {
+            var series = new DevExpress.XtraCharts.Series();
+            series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
+            series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
+            series.Name = id;
+            series.ShowInLegend = false;
+            series.CrosshairEnabled = DefaultBoolean.False;
+
+            var series_view = new DevExpress.XtraCharts.LineSeriesView();
+            series_view.LineStyle.Thickness = 2;
+            series_view.Color = color;
+            series_view.EnableAntialiasing = DefaultBoolean.True;
+            series_view.LineStyle.DashStyle = dash;
+            series_view.Pane = pane;
+            series_view.AxisY = axiy;
+
+            series.SeriesPointsSorting = SortingMode.None;
+            series.SeriesPointsSortingKey = SeriesPointKey.Value_1;
+            series.View = series_view;
+            series.Visible = true;
+
+            for (int i = 0; i < pt_list.Count; i++)
+            {
+                series.Points.Add(new SeriesPoint(pt_list[i].X, new double[] { pt_list[i].Y }));
+            }
+            this.chartControl1.Series.Add(series);
+        }
+
 
         /// <summary>
         /// 鍒涘缓鏂囨湰绯诲垪
         /// </summary> 
-        private void CreateTextSeries(Color color, double x, double y)
+        private void CreateTextSeries(Color color, string name, double x, double y)
         {
-
             var anchor_pt = new DevExpress.XtraCharts.PaneAnchorPoint();
             anchor_pt.Pane = _default_pane;
             anchor_pt.AxisXCoordinate.AxisValue = x.ToString();
@@ -804,12 +831,12 @@
             txt.RuntimeMoving = true;
             txt.RuntimeResizing = false;
             txt.RuntimeRotation = false;
-            txt.Text = $"{x}m鲁/h  {y}m";
+            txt.Text = name;
             txt.TextColor = color;
             txt.ShapePosition = position;
             txt.Visible = true;
             this.chartControl1.AnnotationRepository.Add(txt);
-             
+
         }
 
 
@@ -848,7 +875,7 @@
         /// </summary> 
         public void SetQEVisible(bool visible)
         {
-            _qe_visible = visible;
+            _eff_visible = visible;
             UpdateChart();
         }
 
@@ -858,8 +885,8 @@
         /// </summary> 
         public void SetQPVisible(bool visible)
         {
-            _qp_visible = visible;
-            _bottom_pane.Visibility = _qp_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden;
+            _power_visible = visible;
+            _bottom_pane.Visibility = _power_visible ? ChartElementVisibility.Visible : ChartElementVisibility.Hidden;
             UpdateChart();
         }
 

--
Gitblit v1.9.3