duheng
2024-12-11 2e8e85f65748ee5a5adf0dcda864aa4167cbf2ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
using DevExpress.XtraEditors;
using System.ComponentModel.DataAnnotations;
using Yw.Geometry;
 
namespace Yw.WinFrmUI.Phart
{
    public partial class PumpImportByPictureCtrl : XtraUserControl
    {
        public PumpImportByPictureCtrl()
        {
            InitializeComponent();
            this.curvePictureBoxCtrl1.ReloadPickPointsEvent += CurvePictureBoxCtrl1_ReloadPickPointsEvent;
            this.curvePictureBoxCtrl1.ReloadBoundaryEvent += CurvePictureBoxCtrl1_ReloadBoundaryEvent;
            InitialPictureSizeMode();
            SetBindingData();
        }
 
 
        //初始化图片显示模式
        private void InitialPictureSizeMode()
        {
            foreach (PictureBoxSizeMode sizeMode in Enum.GetValues(typeof(PictureBoxSizeMode)))
            {
                var barCheckItem = new DevExpress.XtraBars.BarCheckItem();
                barCheckItem.Caption = sizeMode.ToString();
                barCheckItem.Id = (int)sizeMode;
                barCheckItem.Name = $"barBtn{barCheckItem.Caption}";
                barCheckItem.ItemClick += (object sender, DevExpress.XtraBars.ItemClickEventArgs e) =>
                {
                    foreach (DevExpress.XtraBars.BarCheckItemLink link in this.barSubPictureSizeMode.ItemLinks)
                    {
                        ((DevExpress.XtraBars.BarCheckItem)link.Item).Checked = false;
                    }
                    var clickItem = (DevExpress.XtraBars.BarCheckItem)e.Item;
                    clickItem.Checked = true;
                    this.barSubPictureSizeMode.Caption = sizeMode.ToString();
                    this.curvePictureBoxCtrl1.SetPictureSizeMode(sizeMode);
                };
 
                this.barSubPictureSizeMode.AddItem(barCheckItem);
                if (sizeMode == PictureBoxSizeMode.StretchImage)
                {
                    barCheckItem.Checked = true;
                    this.barSubPictureSizeMode.Caption = sizeMode.ToString();
                    this.curvePictureBoxCtrl1.SetPictureSizeMode(sizeMode);
                }
            }
        }
 
        private enum eCurveGetWay
        {
            [Display(Name = "全部")]
            All,
            [Display(Name = "流量扬程/功率,分析效率")]
            QhQpAnaQe,
            [Display(Name = "流量扬程/效率,分析功率")]
            QhQeAnaQp,
            [Display(Name = "仅流量扬程线")]
            OnlyQh
        }
        private eCurveGetWay _curveGetWay = eCurveGetWay.All;
 
        private Yw.Ahart.eCurveType _curveType = Yw.Ahart.eCurveType.QH;
        private List<Yw.Geometry.Point2d> _picQHPoints = null;
        private List<Yw.Geometry.Point2d> _picQPPoints = null;
        private List<Yw.Geometry.Point2d> _picQEPoints = null;
 
        private Rectangle? _rectQH, _rectQP, _rectQE;
 
 
 
        /// <summary>
        /// 初始化数据
        /// </summary>
        public void SetBindingData()
        {
            this.repimgCmbGetWay.AddEnum(typeof(eCurveGetWay), false);
            this.barEditImgCmbGetWay.EditValue = _curveGetWay;
 
            this.repImgCmbUnitQ.AddEnum(typeof(Unit.eUnitQ), false);
            this.barEditImgCmbUnitQ.EditValue = this.curvePictureBoxCtrl1.UnitQ;
 
        }
 
        //曲线获取方法
        private void repimgCmbGetWay_SelectedValueChanged(object sender, EventArgs e)
        {
            _curveGetWay = (eCurveGetWay)this.barEditImgCmbGetWay.EditValue;
            switch (_curveGetWay)
            {
                case eCurveGetWay.QhQpAnaQe:
                    {
                        _rectQE = null;
                        _picQEPoints = null;
                        this.layoutControlGroupQH.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                        this.layoutControlGroupQP.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                        this.layoutControlGroupQE.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    }
                    break;
                case eCurveGetWay.QhQeAnaQp:
                    {
                        _rectQP = null;
                        _picQPPoints = null;
                        this.layoutControlGroupQH.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                        this.layoutControlGroupQP.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                        this.layoutControlGroupQE.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                    }
                    break;
                case eCurveGetWay.OnlyQh:
                    {
                        _rectQE = null;
                        _rectQP = null;
                        _picQPPoints = null;
                        _picQEPoints = null;
                        this.layoutControlGroupQH.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                        this.layoutControlGroupQP.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                        this.layoutControlGroupQE.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    }
                    break;
                case eCurveGetWay.All:
                    {
                        this.layoutControlGroupQH.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                        this.layoutControlGroupQP.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                        this.layoutControlGroupQE.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                    }
                    break;
            }
        }
 
        //流量单位变换
        private void repImgCmbUnitQ_SelectedValueChanged(object sender, EventArgs e)
        {
            this.curvePictureBoxCtrl1.UnitQ = (Unit.eUnitQ)this.barEditImgCmbUnitQ.EditValue;
        }
 
        //导入图片
        private void barBtnImportPicture_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dlg = new OpenFileDialog();
            dlg.Filter = "*.BMP;*.JPG;*.GIF;*.PNG|*.BMP;*.JPG;*.GIF;*.PNG";
            if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                return;
            this.curvePictureBoxCtrl1.SetBindingData(dlg.FileName);
            this.curvePictureBoxCtrl1.Enabled = true;
        }
 
        //框选坐标
        private void barBtnSetCoordinates_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.curvePictureBoxCtrl1.StartSelectionRange();
            this.barCekPickPoint.Checked = false;
        }
 
        //坐标框选完成
        private void CurvePictureBoxCtrl1_ReloadBoundaryEvent(System.Drawing.Rectangle? obj)
        {
            switch (_curveType)
            {
                case Yw.Ahart.eCurveType.QH:
                    _rectQH = obj;
                    break;
                case Yw.Ahart.eCurveType.QE:
                    _rectQE = obj;
                    break;
                case Yw.Ahart.eCurveType.QP:
                    _rectQP = obj;
                    break;
            }
        }
        //抓取点
        private void barCekPickPoint_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (this.barCekPickPoint.Checked)
            {
                if (!ReloadChartCoordinate())
                {
                    this.barCekPickPoint.Checked = false;
                    XtraMessageBox.Show("请输入坐标!");
                    return;
                }
                this.curvePictureBoxCtrl1.StartPickPoint();
            }
            else
            {
                this.curvePictureBoxCtrl1.EndPickPoint();
            }
        }
 
        //刷新图表坐标
        private bool ReloadChartCoordinate()
        {
            if (this.barEditTxtMinQ.EditValue == null || this.barEditTxtMaxQ.EditValue == null)
                return false;
            this.curvePictureBoxCtrl1.ChartMinX = Convert.ToDouble(this.barEditTxtMinQ.EditValue);
            this.curvePictureBoxCtrl1.ChartMaxX = Convert.ToDouble(this.barEditTxtMaxQ.EditValue);
            switch (_curveType)
            {
                case Yw.Ahart.eCurveType.QH:
                    {
                        if (this.txtMaxH.EditValue == null || this.txtMinH.EditValue == null)
                        {
                            return false;
                        }
                        this.curvePictureBoxCtrl1.ChartMaxY = Convert.ToDouble(this.txtMaxH.EditValue);
                        this.curvePictureBoxCtrl1.ChartMinY = Convert.ToDouble(this.txtMinH.EditValue);
                    }
                    break;
                case Yw.Ahart.eCurveType.QE:
                    {
                        if (this.txtMaxE.EditValue == null || this.txtMinE.EditValue == null)
                        {
                            return false;
                        }
                        this.curvePictureBoxCtrl1.ChartMaxY = Convert.ToDouble(this.txtMaxE.EditValue);
                        this.curvePictureBoxCtrl1.ChartMinY = Convert.ToDouble(this.txtMinE.EditValue);
                    }
                    break;
                case Yw.Ahart.eCurveType.QP:
                    {
                        if (this.txtMaxP.EditValue == null || this.txtMinP.EditValue == null)
                        {
                            return false;
                        }
                        this.curvePictureBoxCtrl1.ChartMaxY = Convert.ToDouble(this.txtMaxP.EditValue);
                        this.curvePictureBoxCtrl1.ChartMinY = Convert.ToDouble(this.txtMinP.EditValue);
                    }
                    break;
            }
            return true;
        }
 
        //清空点
        private void barBtnClear_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.curvePictureBoxCtrl1.ClearPickPoint();
        }
 
        //预览曲线
        private void barBtnPreviewCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!Get(out string other_name, out Yw.Pump.CurveQH qh, out Yw.Pump.CurveQE qe, out Yw.Pump.CurveQP qp))
                return;
 
            var line_qh = new Yw.Geometry.CubicSpline2d(qh?.FeatCurve.GetPointList());
            var line_qe = new Yw.Geometry.CubicSpline2d(qe?.FeatCurve.GetPointList());
            var line_qp = new Yw.Geometry.CubicSpline2d(qp?.FeatCurve.GetPointList());
 
            var ctrl = new PumpViewChart();
            ctrl.SetBindingData(line_qh, line_qe, line_qp);
            ctrl.Dock = DockStyle.Fill;
            var dlg = new XtraForm();
            dlg.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            dlg.Text = "预览";
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.Size = new Size(900, 900);
            dlg.Controls.Add(ctrl);
            dlg.ShowDialog();
 
        }
 
        //选择曲线变换时
        private void tabbedControlGroup1_SelectedPageChanging(object sender, DevExpress.XtraLayout.LayoutTabPageChangingEventArgs e)
        {
            this.curvePictureBoxCtrl1.GetPicPoints(out List<Yw.Geometry.Point2d> clickPoints);
            if (e.PrevPage == this.layoutControlGroupQH)
            {
                _picQHPoints = clickPoints;
            }
            else if (e.PrevPage == this.layoutControlGroupQP)
            {
                _picQPPoints = clickPoints;
            }
            else if (e.PrevPage == this.layoutControlGroupQE)
            {
                _picQEPoints = clickPoints;
            }
        }
 
        //选择曲线变换
        private void tabbedControlGroup1_SelectedPageChanged(object sender, DevExpress.XtraLayout.LayoutTabPageChangedEventArgs e)
        {
            this.barCekPickPoint.Checked = false;
            if (e.Page == this.layoutControlGroupQH)
            {
                _curveType = Yw.Ahart.eCurveType.QH;
                ReloadChartCoordinate();
                this.curvePictureBoxCtrl1.CurrentCaptureCruve = Yw.Ahart.eCurveType.QH;
                this.curvePictureBoxCtrl1.RefreshPictureShape(_picQHPoints, _rectQH);
 
            }
            else if (e.Page == this.layoutControlGroupQP)
            {
                _curveType = Yw.Ahart.eCurveType.QP;
                ReloadChartCoordinate();
                this.curvePictureBoxCtrl1.CurrentCaptureCruve = Yw.Ahart.eCurveType.QP;
                this.curvePictureBoxCtrl1.RefreshPictureShape(_picQPPoints, _rectQP);
 
            }
            else if (e.Page == this.layoutControlGroupQE)
            {
                _curveType = Yw.Ahart.eCurveType.QE;
                ReloadChartCoordinate();
                this.curvePictureBoxCtrl1.CurrentCaptureCruve = Yw.Ahart.eCurveType.QE;
                this.curvePictureBoxCtrl1.RefreshPictureShape(_picQEPoints, _rectQE);
            }
        }
 
        //打点等效线
        private void cekCaputueEtaPtInEqupCurve_CheckedChanged(object sender, EventArgs e)
        {
            this.curvePictureBoxCtrl1.IsCaputueEtaPtInEqupCurve = this.cekCaputueEtaPtInEqupCurve.Checked;
        }
 
        //打点更新数据
        private void CurvePictureBoxCtrl1_ReloadPickPointsEvent(List<Yw.Geometry.Point2d> list)
        {
            switch (_curveType)
            {
                case Yw.Ahart.eCurveType.QH:
                    _picQHPoints = list;
                    break;
                case Yw.Ahart.eCurveType.QE:
                    _picQEPoints = list;
                    break;
                case Yw.Ahart.eCurveType.QP:
                    _picQPPoints = list;
                    break;
            }
        }
 
 
        /// <summary>
        /// 回调事件
        /// </summary>
        public event Action<string, Yw.Pump.CurveQH, Yw.Pump.CurveQE, Yw.Pump.CurveQP> ReloadDataEvent;
 
        private void barBtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!Get(out string other_name, out Yw.Pump.CurveQH qh, out Yw.Pump.CurveQE qe, out Yw.Pump.CurveQP qp))
                return;
            this?.ReloadDataEvent.Invoke(other_name, qh, qe, qp);
        }
 
 
 
        #region 方法
 
        //获取曲线
        public bool Get(out string other_name, out Yw.Pump.CurveQH qh, out Yw.Pump.CurveQE qe, out Yw.Pump.CurveQP qp)
        {
            other_name = null;
            qh = null;
            qe = null;
            qp = null;
            if (this.barEditTxtCurveCode.EditValue == null)
            {
                XtraMessageBox.Show("请输入曲线编码!");
                return false;
            }
 
 
            other_name = this.barEditTxtCurveCode.EditValue.ToString();
            switch (_curveGetWay)
            {
                case eCurveGetWay.All:
                    {
                        if (_picQHPoints == null || _picQHPoints.Count < 4)
                        {
                            XtraMessageBox.Show("请录入流量扬程点!");
                            return false;
                        }
 
                        if (_picQPPoints == null || _picQPPoints.Count < 4)
                        {
                            XtraMessageBox.Show("请录入流量功率点!");
                            return false;
                        }
                        if (_picQEPoints == null || _picQEPoints.Count < 4)
                        {
                            XtraMessageBox.Show("请录入流量效率点!");
                            return false;
                        }
                    }
                    break;
                case eCurveGetWay.QhQpAnaQe:
                    {
                        if (_picQHPoints == null || _picQHPoints.Count < 4)
                        {
                            XtraMessageBox.Show("请录入流量扬程点!");
                            return false;
                        }
 
                        if (_picQPPoints == null || _picQPPoints.Count < 4)
                        {
                            XtraMessageBox.Show("请录入流量功率点!");
                            return false;
                        }
                    }
                    break;
                case eCurveGetWay.QhQeAnaQp:
                    {
                        if (_picQHPoints == null || _picQHPoints.Count < 4)
                        {
                            XtraMessageBox.Show("请录入流量扬程点!");
                            return false;
                        }
 
                        if (_picQEPoints == null || _picQEPoints.Count < 4)
                        {
                            XtraMessageBox.Show("请录入流量效率点!");
                            return false;
                        }
                    }
                    break;
                case eCurveGetWay.OnlyQh:
                    {
                        if (_picQHPoints == null || _picQHPoints.Count < 4)
                        {
                            XtraMessageBox.Show("请录入流量扬程点!");
                            return false;
                        }
                    }
                    break;
                default:
                    break;
            }
 
 
 
            var curvePointsQH = new List<Yw.Geometry.Point2d>();
            var curvePointsQE = new List<Yw.Geometry.Point2d>();
            var curvePointsQP = new List<Yw.Geometry.Point2d>();
 
            var picPointsQH = new List<Yw.Geometry.Point2d>();
            var picPointsQE = new List<Yw.Geometry.Point2d>();
            var picPointsQP = new List<Yw.Geometry.Point2d>();
 
 
 
            var unitQ = this.curvePictureBoxCtrl1.UnitQ;
            double MinQ = 0;
            double MaxQ = 0;
 
            if (this.curvePictureBoxCtrl1.ChartMinX == 0)
                MinQ = 0;
            else
                MinQ = _picQHPoints.Min(x => x.X);
 
            MaxQ = _picQHPoints.Max(x => x.X);
 
            //换算单位
            MinQ = Unit.UnitQHelper.Convert(unitQ, Unit.eUnitQ.M3H, MinQ);
            MaxQ = Unit.UnitQHelper.Convert(unitQ, Unit.eUnitQ.M3H, MaxQ);
            picPointsQH = ToM3H(unitQ, _picQHPoints);
            picPointsQE = ToM3H(unitQ, _picQEPoints);
            picPointsQP = ToM3H(unitQ, _picQPPoints);
 
 
            int insert_num = 15;
            double space = (MaxQ - MinQ) / (insert_num - 1);
            int i = 0;
            double Q = MinQ;
            double H, E = 0, P = 0;
            for (i = 1; i < insert_num - 1; i++)
            {
                Q = Q + space;
                H = picPointsQH.GetFitPointList().GetInterPointsY(Q).Last();
                curvePointsQH.Add(new Yw.Geometry.Point2d(Q, H));
 
                if (_curveGetWay != eCurveGetWay.OnlyQh)
                {
                    switch (_curveGetWay)
                    {
                        case eCurveGetWay.All:
                            {
 
                                P = picPointsQP.GetFitPointList().GetInterPointsY(Q)?.LastOrDefault() ?? 0;
                                E = picPointsQE.GetFitPointList().GetInterPointsY(Q)?.LastOrDefault() ?? 0;
                            }
                            break;
                        case eCurveGetWay.QhQpAnaQe:
                            {
                                P = picPointsQP.GetFitPointList().GetInterPointsY(Q)?.LastOrDefault() ?? 0;
                                E = PumpCalcHelper.CalculateE(Q, H, P);
 
                            }
                            break;
                        case eCurveGetWay.QhQeAnaQp:
                            {
                                E = picPointsQE.GetFitPointList().GetInterPointsY(Q)?.LastOrDefault() ?? 0;
                                P = PumpCalcHelper.CalculateP(Q, H, E);
                            }
                            break;
                    }
 
                    curvePointsQP.Add(new Yw.Geometry.Point2d(Q, P));
                    curvePointsQE.Add(new Yw.Geometry.Point2d(Q, E));
                }
            }
 
            if (_curveGetWay == eCurveGetWay.OnlyQh)
            {
                if (curvePointsQH.Count < 3)
                {
                    XtraMessageBox.Show("未导入足够多的性能曲线点");
                    return false;
                }
            }
            else
            {
                if (curvePointsQH.Count < 3 || curvePointsQE.Count < 3 || curvePointsQP.Count < 3)
                {
                    curvePointsQH = null;
                    curvePointsQE = null;
                    curvePointsQP = null;
                    XtraMessageBox.Show("未导入足够多的性能曲线点");
                    return false;
                }
            }
 
 
 
            #region 首尾两点的处理:因为首尾2点按流量扬程获取范围,而点击不一定正好首尾2点流量一样
            //流量扬程首尾两点
            double startH = LineHelper.GetYbyX(curvePointsQH[0].X, curvePointsQH[0].Y, curvePointsQH[1].X, curvePointsQH[1].Y, MinQ);
            curvePointsQH.Insert(0, new Yw.Geometry.Point2d(MinQ, startH));
 
            int point_num = curvePointsQH.Count;//不一定和insert_num一样
            double endH = LineHelper.GetYbyX(curvePointsQH[point_num - 2].X, curvePointsQH[point_num - 2].Y,
                curvePointsQH[point_num - 1].X, curvePointsQH[point_num - 1].Y, MaxQ);
            curvePointsQH.Add(new Yw.Geometry.Point2d(MaxQ, endH));
 
            if (curvePointsQE != null && curvePointsQE.Count > 0)
            {
                //流量效率首尾两点
                double startE = 0;//起始点
                if (MinQ > 0.2)
                    startE = LineHelper.GetYbyX(curvePointsQE[0].X, curvePointsQE[0].Y, curvePointsQE[1].X, curvePointsQE[1].Y, MinQ);
                else
                    startE = 0;
                curvePointsQE.Insert(0, new Yw.Geometry.Point2d(MinQ, startE));
 
                point_num = curvePointsQE.Count;//末尾点
                double endE = LineHelper.GetYbyX(curvePointsQE[point_num - 2].X, curvePointsQE[point_num - 2].Y,
                    curvePointsQE[point_num - 1].X, curvePointsQE[point_num - 1].Y, MaxQ);
                curvePointsQE.Add(new Yw.Geometry.Point2d(MaxQ, endE));
            }
 
            if (curvePointsQP != null && curvePointsQP.Count > 0)
            {
                //流量功率首尾两点
                double startP = LineHelper.GetYbyX(curvePointsQP[0].X, curvePointsQP[0].Y, curvePointsQP[1].X, curvePointsQP[1].Y, MinQ);
                curvePointsQP.Insert(0, new Yw.Geometry.Point2d(MinQ, startP));
 
                point_num = curvePointsQP.Count;
                double endP = LineHelper.GetYbyX(curvePointsQP[point_num - 2].X, curvePointsQP[point_num - 2].Y,
                    curvePointsQP[point_num - 1].X, curvePointsQP[point_num - 1].Y, MaxQ);
                curvePointsQP.Add(new Yw.Geometry.Point2d(MaxQ, endP));
            }
            #endregion
 
 
            //圆整
            curvePointsQH = Regulate(curvePointsQH, 2);
            curvePointsQE = Regulate(curvePointsQE, 2);
            curvePointsQP = Regulate(curvePointsQP, 2);
 
            qh = new Pump.CurveQH(Yw.Ahart.eFeatType.Cubic, curvePointsQH);
            qe = new Pump.CurveQE(Yw.Ahart.eFeatType.Cubic, curvePointsQE);
            qp = new Pump.CurveQP(Yw.Ahart.eFeatType.Cubic, curvePointsQP);
 
 
            return true;
        }
 
 
        //单位换算
        private List<Yw.Geometry.Point2d> ToM3H(Unit.eUnitQ unit, List<Yw.Geometry.Point2d> points)
        {
            if (unit == Unit.eUnitQ.M3H)
            {
                return points;
            }
 
            if (points == null)
            {
                return null;
            }
 
            var list = new List<Yw.Geometry.Point2d>();
            for (int i = 0; i < points.Count; i++)
            {
                var point = new Yw.Geometry.Point2d(points[i]);
                point.X = Unit.UnitQHelper.Convert(unit, Unit.eUnitQ.M3H, point.X);
                list.Add(point);
            }
            return list;
        }
 
        //四舍五入圆整,如  0.44 -> 0.4  , 0.46 -> 0.5//flag--小数点后位数
        public static List<Yw.Geometry.Point2d> Regulate(List<Yw.Geometry.Point2d> inPoints, int flag)
        {
            if (inPoints == null)
                return null;
            List<Yw.Geometry.Point2d> outPoints = new List<Yw.Geometry.Point2d>();
            for (int i = 0; i < inPoints.Count(); i++)
            {
                outPoints.Add(new Yw.Geometry.Point2d(Regulate(inPoints[i].X, flag), Regulate(inPoints[i].Y, flag)));
            }
            return outPoints;
        }
 
        //四舍五入圆整,如  0.44 -> 0.4  , 0.46 -> 0.5//flag--小数点后位数
        public static double Regulate(double v, int flag)
        {
            bool isNegative = false;
            //如果是负数
            if (v < 0)
            {
                isNegative = true;
                v = Math.Abs(v);
            }
            else
            {
                isNegative = false;
            }
 
            double value = Math.Round(v, flag);
            if (isNegative)
            {
                value = -value;
            }
            return value;
        }
 
        #endregion
 
 
 
    }
}