duheng
7 天以前 4de480ec624d3b79ca690dc906e10cd2fbdc9be7
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
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
using DevExpress.Utils;
using DevExpress.XtraCharts;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
 
namespace IStation.WinFrmUI.Curve
{
    /// <summary>
    /// 曲线展示控件 nsx 废弃
    /// </summary>
    public partial class CurveViewChartCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        #region 构造函数和加载函数
        public CurveViewChartCtrl()
        {
            InitializeComponent();
            InitialChart();
            InitialChartDisplay();
        }
 
        /// <summary>
        /// 初始化图表
        /// </summary>
        private void InitialChart()
        {
            SeriesQHpoint = chartControl1.Series["SeriesQHpoint"];
            SeriesQEpoint = chartControl1.Series["SeriesQEpoint"];
            SeriesQPpoint = chartControl1.Series["SeriesQPpoint"];
 
            SeriesQHcurve = chartControl1.Series["SeriesQHcurve"];
            SeriesQEcurve = chartControl1.Series["SeriesQEcurve"];
            SeriesQPcurve = chartControl1.Series["SeriesQPcurve"];
 
            SeriesQHline = chartControl1.Series["SeriesQHline"];
 
            mainChartDiagram = (XYDiagram)chartControl1.Diagram;
 
            SeriesQHpoint.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
            SeriesQEpoint.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
            SeriesQPpoint.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
 
            SeriesQHcurve.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
            SeriesQEcurve.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
            SeriesQPcurve.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
 
            SeriesQHpoint.Visible = false;
            SeriesQEpoint.Visible = false;
            SeriesQPpoint.Visible = false;
            SeriesQHline.Visible = false;
 
            SeriesQHcurve.CrosshairEnabled = DefaultBoolean.False;
            SeriesQEcurve.CrosshairEnabled = DefaultBoolean.False;
            SeriesQPcurve.CrosshairEnabled = DefaultBoolean.False;
 
            SeriesQHpoint.CrosshairEnabled = DefaultBoolean.False;
            SeriesQEpoint.CrosshairEnabled = DefaultBoolean.False;
            SeriesQPpoint.CrosshairEnabled = DefaultBoolean.False;
 
            SeriesQHline.CrosshairHighlightPoints = DefaultBoolean.False;
            SeriesQHline.CrosshairEnabled = DefaultBoolean.False;
 
            AxisQ = mainChartDiagram.AxisX;
            QHAxisY = mainChartDiagram.AxisY;
            AxisQ.Visibility = DefaultBoolean.False;
            QHAxisY.Visibility = DefaultBoolean.False;
 
            QEAxisY = mainChartDiagram.SecondaryAxesY.GetAxisByName("QEAxisY");
            QPAxisY = mainChartDiagram.SecondaryAxesY.GetAxisByName("QPAxisY");
            QEAxisY.Visibility = DefaultBoolean.False;
            QPAxisY.Visibility = DefaultBoolean.False;
 
            WorkRegionStrip = AxisQ.Strips.GetStripByName("WorkRegion");
            WorkRegionStrip.Visible = false;
 
            RatedParasLine = (DevExpress.XtraCharts.ConstantLine)mainChartDiagram.AxisX.ConstantLines.GetElementByName("RatedParasLine");
            RatedParasLine.Visible = false;
 
            WorkParasLine = (DevExpress.XtraCharts.ConstantLine)mainChartDiagram.AxisX.ConstantLines.GetElementByName("WorkParasLine");
            WorkParasLine.Visible = false;
 
            TextAnnotationQH = chartControl1.AnnotationRepository[0] as DevExpress.XtraCharts.TextAnnotation;
            TextAnnotationQE = chartControl1.AnnotationRepository[1] as DevExpress.XtraCharts.TextAnnotation;
            TextAnnotationQP = chartControl1.AnnotationRepository[2] as DevExpress.XtraCharts.TextAnnotation;
            TextAnnoWorkPoint = chartControl1.AnnotationRepository[3] as DevExpress.XtraCharts.TextAnnotation;
            TextAnnotationEquip = chartControl1.AnnotationRepository[4] as DevExpress.XtraCharts.TextAnnotation;
            TextAnnotationMaxE = chartControl1.AnnotationRepository[5] as DevExpress.XtraCharts.TextAnnotation;
 
            TextAnnotationMaxE.Visible = false;
            TextAnnoWorkPoint.Visible = false;
            TextAnnotationEquip.Visible = false;
 
            LineSeriesView view1 = (SplineSeriesView)SeriesQHcurve.View;
            view1.MarkerVisibility = DevExpress.Utils.DefaultBoolean.False;
            LineSeriesView view2 = (SplineSeriesView)SeriesQEcurve.View;
            view2.MarkerVisibility = DevExpress.Utils.DefaultBoolean.False;
            LineSeriesView view3 = (SplineSeriesView)SeriesQPcurve.View;
            view3.MarkerVisibility = DevExpress.Utils.DefaultBoolean.False;
 
            this.chartControl1.SeriesSelectionMode = SeriesSelectionMode.Point;//设置此属性 表示可以选择CHART上物体
            // this.chartControl1.RuntimeSeriesSelectionMode = SeriesSelectionMode.Point;//系列选择是选择其中的点而不是整个系列                                                              
            this.SeriesQHpoint.CrosshairHighlightPoints = DefaultBoolean.True;
            //this.chartControl1.RuntimeSeriesSelectionMode = SeriesSelectionMode.Series; 
 
            //添加重绘事件
            this.chartControl1.CustomPaint += new DevExpress.XtraCharts.CustomPaintEventHandler(this.chartControl_CustomPaint);
            this.chartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseDown);
            this.chartControl1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseMove);
            this.chartControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseUp);
        }
        #endregion
 
        #region  显示 
        /// <summary>
        /// 是否显示点
        /// </summary>
        private bool _isDispCurrentPoint = false;
 
        /// <summary>
        /// 是否显示点
        /// </summary>
        public bool IsDispCurvePoint
        {
            get
            {
                return _isDispCurrentPoint;
            }
            set
            {
                _isDispCurrentPoint = value;
            }
        }
 
        /// <summary>
        /// 是否显示曲线标签
        /// </summary> 
        private bool isDispCurveName = false;
 
        /// <summary>
        /// 是否显示曲线标签
        /// </summary>
        public bool IsDispCurveName
        {
            get { return isDispCurveName; }
            set
            {
                isDispCurveName = value;
                if (TextAnnotationQH != null)
                    TextAnnotationQH.Visible = isDispCurveName;
                if (TextAnnotationQE != null)
                    TextAnnotationQE.Visible = isDispCurveName;
                if (TextAnnotationQP != null)
                    TextAnnotationQP.Visible = isDispCurveName;
            }
        }
 
        /// <summary>
        /// 初始化图标控件 (读取Cookie)
        /// </summary>
        private void InitialChartDisplay()
        {
            IStation.WinFrmUI.Curve.XtraChartHelper.SetDisplay(AxisQ, QHAxisY, QEAxisY, QPAxisY);
            IStation.WinFrmUI.Curve.XtraChartHelper.SetCurveDisplay(SeriesQHcurve, SeriesQEcurve, SeriesQPcurve);
            IStation.WinFrmUI.Curve.XtraChartHelper.SetPointDisplay(SeriesQHpoint, SeriesQEpoint, SeriesQPpoint);
            IStation.WinFrmUI.Curve.XtraChartHelper.SetDisplay(WorkRegionStrip);
 
            if (isDispCurveName)
                IStation.WinFrmUI.Curve.XtraChartHelper.SetDisplay(TextAnnotationQH, TextAnnotationQE, TextAnnotationQP);
 
            TextAnnotationQH.Visible = isDispCurveName;
            TextAnnotationQE.Visible = isDispCurveName;
            TextAnnotationQP.Visible = isDispCurveName;
        }
 
        #endregion
 
        #region 曲线 
        /// <summary>
        /// 是否只显示流量扬程线
        /// </summary>
        private bool _isOnlyCurveQH = false;
 
        double _CurveMaxQ = 0, _CurveMinQ = 0;
        double _CurveMaxH = 0, _CurveMinH = 0;
        private List<Model.CurvePoint> CurveInfoQH = null;
        public Model.CurveExpress CurveExprQH = null;
        private List<Model.CurvePoint> CurveInfoQE = null;
        public Model.CurveExpress CurveExprQE = null;
        private List<Model.CurvePoint> CurveInfoQP = null;
        private Model.CurveExpress CurveExprQP = null;
 
        public void SetCurveInfo(Model.FeatCurveExpressGroup curveExpressGroup)
        {
            if (curveExpressGroup == null)
                return;
            SetCurveInfo(curveExpressGroup.CurveQH, curveExpressGroup.CurveQE, curveExpressGroup.CurveQP);
        }
 
        public void SetCurveInfo(Model.CurveExpress curveQH, Model.CurveExpress curveQE, Model.CurveExpress curveQP)
        {
            if (curveQH == null)
                return;
 
            this.CurveExprQH = curveQH;
            this.CurveExprQE = curveQE;
            this.CurveExprQP = curveQP;
 
            this.CurveInfoQH = Model.FitCurveHelper.GetFitPoints(curveQH, 11);
            this.CurveInfoQE = Model.FitCurveHelper.GetFitPoints(curveQE, 11);
            this.CurveInfoQP = Model.FitCurveHelper.GetFitPoints(curveQP, 11);
 
            _isOnlyCurveQH = false;
            if (curveQE == null && curveQP == null)
                _isOnlyCurveQH = true;
 
            IsDispCurveName = true;
        }
 
 
        #endregion
 
        #region CHART变量
        //测试的原始点
        private Series SeriesQHpoint = null;
        private Series SeriesQEpoint = null;
        private Series SeriesQPpoint = null;
 
        //拟合后的曲线上的点
        private Series SeriesQHcurve = null;
        private Series SeriesQEcurve = null;
        private Series SeriesQPcurve = null;
        private Series SeriesQHline = null;
 
        //
        private DevExpress.XtraCharts.XYDiagram mainChartDiagram;
        private DevExpress.XtraCharts.Strip WorkRegionStrip = null;
        private DevExpress.XtraCharts.ConstantLine RatedParasLine = null;
        private DevExpress.XtraCharts.ConstantLine WorkParasLine = null;
        //
        private DevExpress.XtraCharts.TextAnnotation TextAnnotationQH = null;
        private DevExpress.XtraCharts.TextAnnotation TextAnnotationQE = null;
        private DevExpress.XtraCharts.TextAnnotation TextAnnotationQP = null;
        private DevExpress.XtraCharts.TextAnnotation TextAnnotationEquip = null;
        private DevExpress.XtraCharts.TextAnnotation TextAnnoWorkPoint = null;
 
        private DevExpress.XtraCharts.TextAnnotation TextAnnotationMaxE = null;
 
        //
        AxisX AxisQ = null;
        AxisY QHAxisY = null;
        SecondaryAxisY QEAxisY = null;
        SecondaryAxisY QPAxisY = null;
 
        #endregion
 
        #region 坐标
        //坐标
        private Model.CurveCoordinateParas _coordinateParas = null;
        public Model.CurveCoordinateParas CoordinateParas { get { return _coordinateParas; } set { _coordinateParas = value; } }
 
        //更新图表坐标
        public void UpdateCoordinate()
        {
            //先设置为不显示
            AxisQ.Visibility = DefaultBoolean.False;
            QHAxisY.GridLines.Visible = false;
            QHAxisY.Visibility = DefaultBoolean.False;
            QPAxisY.GridLines.Visible = false;
            QPAxisY.Visibility = DefaultBoolean.False;
            QEAxisY.GridLines.Visible = false;
            QEAxisY.Visibility = DefaultBoolean.False;
 
            WorkRegionStrip.Visible = false;
            RatedParasLine.Visible = false;
 
            if (CoordinateParas == null)
                return;
 
            var coord = CoordinateParas;
 
            //流量
            if (CurveInfoQH != null)
            {
                AxisQ.CustomLabels.Clear();
                //坐标刻度
                var Q_Label_List = new List<CustomAxisLabel>();
                double disQ = coord.CoordMinQ;
                for (int i = 0; i < coord.GridNumberX + 1; i++)
                {
                    Q_Label_List.Add(new CustomAxisLabel(disQ.ToString(), disQ));
                    disQ = disQ + coord.CoordSpaceQ;
                }
                AxisQ.CustomLabels.AddRange(Q_Label_List.ToArray());
                AxisQ.Visibility = DefaultBoolean.True;   //设置显示
                AxisQ.GridLines.Visible = true;
                Curve.XtraChartHelper.SetAxisRange(AxisQ, coord.CoordMinQ, coord.CoordMinQ + coord.GridNumberX * coord.CoordSpaceQ);
            }
 
            //扬程
            if (CurveInfoQH != null)
            {
                QHAxisY.CustomLabels.Clear();
                //坐标刻度  
                var H_Label_List = new List<CustomAxisLabel>();
                double disH = coord.CoordMinH + coord.CoordSpaceH * coord.StartLineNoH;
                for (int i = coord.StartLineNoH; i < coord.EndLineNoH + 1; i++)
                {
                    H_Label_List.Add(new CustomAxisLabel(disH.ToString(), disH));
                    disH = disH + coord.CoordSpaceH;
                }
                QHAxisY.CustomLabels.AddRange(H_Label_List.ToArray());
                //QHAxisY.GridLines.Visible = true;   //设置显示
                QHAxisY.Visibility = DefaultBoolean.True;
                if (_isOnlyCurveQH)
                {
                    Curve.XtraChartHelper.SetAxisRange(QHAxisY, coord.DispMinH(), coord.DispMaxH());
                }
                else
                {
                    Curve.XtraChartHelper.SetAxisRange(QHAxisY, coord.CoordMinH, coord.CoordMinH + coord.GridNumberY * coord.CoordSpaceH);
                }
            }
 
            //效率
            if (CurveInfoQE != null)
            {
                //坐标刻度
                QEAxisY.CustomLabels.Clear();
                List<CustomAxisLabel> E_Label_List = new List<CustomAxisLabel>();
                double disE = coord.CoordMinE + coord.CoordSpaceE * coord.StartLineNoE;
                for (int i = coord.StartLineNoE; i < coord.EndLineNoE + 1; i++)
                {
                    E_Label_List.Add(new CustomAxisLabel(disE.ToString(), disE));
                    disE = disE + coord.CoordSpaceE;
                }
                QEAxisY.CustomLabels.AddRange(E_Label_List.ToArray());
                //QEAxisY.GridLines.Visible = true;       //设置显示
                QEAxisY.Visibility = DefaultBoolean.True;
                IStation.WinFrmUI.Curve.XtraChartHelper.SetAxisRange(QEAxisY, coord.CoordMinE, coord.CoordMinE + coord.GridNumberY * coord.CoordSpaceE);
            }
 
            //功率
            if (CurveInfoQP != null)
            {
                //坐标刻度
                QPAxisY.CustomLabels.Clear();
                var P_Label_List = new List<CustomAxisLabel>();
                double disP = coord.CoordMinP + coord.CoordSpaceP * coord.StartLineNoP;
                for (int i = coord.StartLineNoP; i < coord.EndLineNoP + 1; i++)
                {
                    P_Label_List.Add(new CustomAxisLabel(disP.ToString(), disP));
                    disP = disP + coord.CoordSpaceP;
                }
                QPAxisY.CustomLabels.AddRange(P_Label_List.ToArray());
                //设置显示
                //QPAxisY.GridLines.Visible = true;
                QPAxisY.Visibility = DefaultBoolean.True;
                IStation.WinFrmUI.Curve.XtraChartHelper.SetAxisRange(QPAxisY, coord.CoordMinP, coord.CoordMinP + coord.GridNumberY * coord.CoordSpaceP);
            }
        }
 
        #endregion
 
        #region 工作点
 
        #region 设置工作点
        private bool isDispWorkPt = false;
        private Model.GroupPoint workPt = new Model.GroupPoint(0, 0, 0, 0, 0);
 
        public void SetWorkPointQ(double wrkQ)
        {
            if (this.CurveInfoQH != null && this.CurveInfoQH.Count > 3)
            {
                workPt.Q = wrkQ;
                isDispWorkPt = true;
                SeriesQHline.Visible = true;
                WorkParasLine.Visible = true;
                WorkParasLine.Title.Visible = true;
                SeriesQHline.Visible = true;
                TextAnnoWorkPoint.Visible = true;
 
                CalcWorkPtByQ(wrkQ);
                SetQHLineByWorkPt();
            }
        }
 
        public void SetWorkPointQ_Auto()
        {
            if (this.CurveInfoQH != null && this.CurveInfoQH.Count > 3)
            {
                double wrkQ = (_CurveMinQ + _CurveMaxQ) / 2;
 
                SetWorkPointQ(wrkQ);
            }
        }
 
        public void SetWorkPointH(double wrkH)
        {
            if (this.CurveInfoQH != null && this.CurveInfoQH.Count > 3)
            {
                workPt.H = wrkH;
                isDispWorkPt = true;
                SeriesQHline.Visible = true;
                WorkParasLine.Visible = true;
                WorkParasLine.Title.Visible = true;
                SeriesQHline.Visible = true;
                TextAnnoWorkPoint.Visible = true;
 
                double wrkQ = 0;
                if (CalcWorkQByH(wrkH, ref wrkQ))
                {
                    CalcWorkPtByQ(wrkQ);
                    SetQHLineByWorkPt();
                }
            }
        }
 
        public void IsNotDispWorkPt()
        {
            isDispWorkPt = false;
            WorkParasLine.Visible = false;
            WorkParasLine.Title.Visible = false;
            TextAnnoWorkPoint.Visible = false;
            SeriesQHline.Visible = false;
        }
        #endregion
 
        #region 计算
        private void CalcWorkPtByQ(double refQ)
        {
            if (!isDispWorkPt)
                return;
            if (CurveInfoQH == null)
                return;
            if (refQ < _CurveMinQ * 1.01 || refQ > _CurveMaxQ * 0.999)
                return;
 
            workPt.Q = refQ;
            WorkParasLine.AxisValue = refQ;
 
            //WorkParasLine.Title.Visible = true;
            //WorkParasLine.Visible = true;
            //WorkParasLine.Title.Text = string.Format("{0:N1}", refQ);
 
            StringBuilder builder = new StringBuilder();
 
            builder.AppendLine("---工作点参数---");
            builder.AppendFormat("流量:{0:N1}", workPt.Q);
 
            workPt.H = Model.FitCurveHelper.GetFitPointY(CurveExprQH, refQ);
            builder.AppendLine("");
            builder.AppendFormat("扬程:{0:N1}", workPt.H);
 
 
            if (CurveExprQE != null)
            {
                workPt.E = Model.FitCurveHelper.GetFitPointY(CurveExprQE, refQ);
                builder.AppendLine("");
                builder.AppendFormat("效率:{0:N1}", workPt.E);
            }
 
            if (CurveExprQP != null)
            {
                workPt.P = Model.FitCurveHelper.GetFitPointY(CurveExprQP, refQ);
                builder.AppendLine("");
                builder.AppendFormat("功率:{0:N1}", workPt.P);
            }
 
            TextAnnoWorkPoint.Visible = true;
            TextAnnoWorkPoint.Text = builder.ToString();
        }
 
        private bool CalcWorkQByH(double wrkH, ref double wrkQ)
        {
            if (this.CurveInfoQH == null)
                return false;
 
            if (wrkH < _CurveMinH * 1.01 || wrkH > _CurveMaxH * 0.999)
                return false;
 
            List<Model.CurvePoint> intrPts = Model.FitCurveHelper.GetInterPointX(CurveExprQH, wrkH);
            if (intrPts == null || intrPts.Count == 0)
            {
                return false;
            }
            else
            {
                wrkQ = intrPts.Last().X;
                return true;
            }
        }
 
        private void SetQHLineByWorkPt()
        {
            SeriesQHline.Visible = true;
            SeriesQHline.Points.Clear();
            SeriesQHline.Points.Add(new SeriesPoint(CoordinateParas.CoordMinQ, workPt.H));
            SeriesQHline.Points.Add(new SeriesPoint(workPt.Q, workPt.H));
        }
 
        #endregion
 
        #endregion
 
        #region 更新
 
        //更新所有
        public void UpdateChart(bool isCalcCoordinate = false)
        {
            //要依次更新
            if (this.CurveInfoQH == null || this.CurveInfoQH.Count < 3)
                return;
            if (isCalcCoordinate || CoordinateParas == null)
            {//不强迫计算,就用上次更新的坐标系
                CalcCoordinate();
            }
 
            UpdateCoordinate();
 
            UpdatePoints();
 
            UpdateWorkParas();
 
            if (isDispWorkPt && workPt != null && this.CurveInfoQH != null && this.CurveInfoQH.Count > 2)
            {
                if (workPt.Q < _CurveMaxQ && workPt.Q > _CurveMinQ)
                {
                    SetWorkPointQ(workPt.Q);
                }
            }
        }
 
        /// <summary>
        /// 计算坐标
        /// </summary>
        public void CalcCoordinate()
        {
            if (CurveInfoQH != null && CurveInfoQH.Count() > 3)
            {
                CoordinateParas = Model.CurveCoordinateParas.CalcCoordinate(CurveInfoQH, CurveInfoQE, CurveInfoQP);
 
                _CurveMinQ = (from x in CurveInfoQH select x.X).Min();
                _CurveMaxQ = (from x in CurveInfoQH select x.X).Max();
                _CurveMinH = (from x in CurveInfoQH select x.Y).Min();
                _CurveMaxH = (from x in CurveInfoQH select x.Y).Max();
            }
            else
            {
                CoordinateParas = GetBlankCoordinate();
                if (_CurveMinQ > _CurveMaxQ - 1)
                {
                    _CurveMinQ = _CurveMinQ * 0.8;
                    _CurveMaxQ = _CurveMaxQ * 1.2;
                }
                if (_CurveMinH > _CurveMaxH - 0.1)
                {
                    _CurveMinH = _CurveMinH * 0.8;
                    _CurveMaxH = _CurveMaxH * 1.2;
                }
            }
        }
 
        //更新所有点
        public void UpdatePoints()
        {
            if (this.CurveInfoQH == null || this.CurveInfoQH.Count < 3)
            {
                SeriesQHpoint.Visible = false;
                SeriesQEpoint.Visible = false;
                SeriesQPpoint.Visible = false;
 
                SeriesQHcurve.Visible = false;
                SeriesQEcurve.Visible = false;
                SeriesQPcurve.Visible = false;
                return;
            }
 
            if (_isDispCurrentPoint)
            {
                SeriesQHpoint.Visible = true;
                SeriesQEpoint.Visible = true;
                SeriesQPpoint.Visible = true;
            }
            else
            {
                SeriesQHpoint.Visible = false;
                SeriesQEpoint.Visible = false;
                SeriesQPpoint.Visible = false;
            }
 
            int i = 0;
            //更新所有曲线
            if (CurveInfoQH != null && CurveInfoQH.Count > 3)
            {
                SeriesQHcurve.Visible = true;
                SeriesQHcurve.Points.Clear();
                for (i = 0; i < CurveInfoQH.Count(); i++)
                {
                    SeriesQHcurve.Points.Add(new SeriesPoint(CurveInfoQH[i].X, new double[] { CurveInfoQH[i].Y }));
                }
 
                DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPoint1 = TextAnnotationQH.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint;
                paneAnchorPoint1.AxisXCoordinate.AxisValue = CurveInfoQH[CurveInfoQH.Count() - 2].X.ToString();
                paneAnchorPoint1.AxisYCoordinate.AxisValue = CurveInfoQH[CurveInfoQH.Count() - 2].Y.ToString();
                TextAnnotationQH.Visible = isDispCurveName;
            }
            else
            {
                SeriesQHcurve.Visible = false;
                TextAnnoWorkPoint.Visible = false;
                TextAnnotationQH.Visible = false;
                WorkParasLine.Visible = false;
                SeriesQHline.Visible = false;
                SeriesQHcurve.Points.Clear();
            }
 
            if (CurveInfoQE != null && CurveInfoQE.Count > 3)
            {
                SeriesQEcurve.Visible = true;
                SeriesQEcurve.Points.Clear();
                for (i = 0; i < CurveInfoQE.Count(); i++)
                {
                    SeriesQEcurve.Points.Add(new SeriesPoint(CurveInfoQE[i].X, new double[] { CurveInfoQE[i].Y }));
                }
 
                DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPoint2 = TextAnnotationQE.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint;
                paneAnchorPoint2.AxisXCoordinate.AxisValue = CurveInfoQE[CurveInfoQE.Count() - 2].X.ToString();
                paneAnchorPoint2.AxisYCoordinate.AxisValue = CurveInfoQE[CurveInfoQE.Count() - 2].Y.ToString();
                TextAnnotationQE.Visible = isDispCurveName;
            }
            else
            {
                SeriesQEcurve.Visible = false;
                TextAnnotationQE.Visible = false;
                SeriesQEcurve.Points.Clear();
            }
 
            if (CurveInfoQP != null && CurveInfoQP.Count > 3)
            {
                SeriesQPcurve.Visible = true;
                SeriesQPcurve.Points.Clear();
                for (i = 0; i < CurveInfoQP.Count(); i++)
                {
                    SeriesQPcurve.Points.Add(new SeriesPoint(CurveInfoQP[i].X, new double[] { CurveInfoQP[i].Y }));
                }
 
                DevExpress.XtraCharts.PaneAnchorPoint paneAnchorPoint3 = TextAnnotationQP.AnchorPoint as DevExpress.XtraCharts.PaneAnchorPoint;
                paneAnchorPoint3.AxisXCoordinate.AxisValue = CurveInfoQP[CurveInfoQP.Count() - 2].X.ToString();
                paneAnchorPoint3.AxisYCoordinate.AxisValue = CurveInfoQP[CurveInfoQP.Count() - 2].Y.ToString();
                TextAnnotationQP.Visible = isDispCurveName;
            }
            else
            {
                SeriesQPcurve.Visible = false;
                TextAnnotationQP.Visible = false;
                SeriesQEcurve.Points.Clear();
            }
        }
 
        //更新工作参数
        public void UpdateWorkParas()
        {
            if (WorkParasLine == null)
                return;
            if (isDispWorkPt && this.CurveInfoQH != null && this.CurveInfoQH.Count > 3)
            {
                if (workPt.Q > 2)
                {
                    WorkParasLine.AxisValue = workPt.Q;
                    WorkParasLine.Visible = true;
                }
                else
                {
                    WorkParasLine.Visible = false;
                }
            }
            else
            {
                WorkParasLine.Visible = false;
            }
        }
        #endregion
 
        #region 重绘
 
        Rectangle CalculateDiagramBounds()
        {
            Point p1 = mainChartDiagram.DiagramToPoint((double)mainChartDiagram.AxisX.VisualRange.MinValue, (double)mainChartDiagram.AxisY.VisualRange.MinValue).Point;
            Point p2 = mainChartDiagram.DiagramToPoint((double)mainChartDiagram.AxisX.VisualRange.MaxValue, (double)mainChartDiagram.AxisY.VisualRange.MaxValue).Point;
            return GeomHelper.CreateRectangle(p1, p2);
        }
 
        void chartControl_CustomPaint(object sender, CustomPaintEventArgs e)
        {
            if (_coordinateParas == null)
                return;
            if (!(e is DXCustomPaintEventArgs dxArgs))
                return;
            chartControl1.DrawGridLineY(dxArgs, _coordinateParas, IStation.WinFrmUI.Curve.Cookie.ChartDisp.Default.GridLinesColorY, 0.2f, true);
        }
 
        #endregion
 
        #region chartControl1
 
        bool isMoveWorkRefLine = false;
        bool isMoveSeriesQHline = false;
        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ChartHitInfo hitInfo = chartControl1.CalcHitInfo(e.Location);
                if (hitInfo.InConstantLine)
                {
                    if (hitInfo.ConstantLine == WorkParasLine)
                        isMoveWorkRefLine = true;
                }
                else if (hitInfo.InSeries)
                {
                    if (hitInfo.Series == SeriesQHline)
                        isMoveSeriesQHline = true;
                }
                else
                {
                    DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
                    double refQ = coordPt.NumericalArgument;
                    double refH = coordPt.NumericalValue;
                }
            }
        }
 
        private void chartControl1_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMoveWorkRefLine)
            {
                DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
                double refQ = coordPt.NumericalArgument;
                CalcWorkPtByQ(refQ);
                SetQHLineByWorkPt();
            }
            else if (isMoveSeriesQHline)
            {
                DiagramCoordinates coordPt = mainChartDiagram.PointToDiagram(e.Location);
                double refH = coordPt.NumericalValue;
                double refQ = 0;
                if (CalcWorkQByH(refH, ref refQ))
                {
                    CalcWorkPtByQ(refQ);
                    SetQHLineByWorkPt();
                }
            }
        }
 
        private void chartControl1_MouseUp(object sender, MouseEventArgs e)
        {
            isMoveWorkRefLine = false;
            isMoveSeriesQHline = false;
        }
 
        #endregion 
 
        /// <summary>
        /// 获取空白坐标
        /// </summary> 
        private Model.CurveCoordinateParas GetBlankCoordinate()
        {
            var para = new Model.CurveCoordinateParas();
            para.GridNumberX = 30;
            para.GridNumberY = 16;
 
            //显示的坐标线号
            para.StartLineNoH = 10;
            para.EndLineNoH = 15;
 
            para.StartLineNoE = 0;
            para.EndLineNoE = 10;
 
            para.StartLineNoP = 2;
            para.EndLineNoP = 9;
 
            //坐标最小值和间隔
            para.CoordMinQ = 0; para.CoordSpaceQ = 1000;
            para.CoordMinH = 10; para.CoordSpaceH = 100;
            para.CoordMinE = 0; para.CoordSpaceE = 100;
            para.CoordMinP = 10; para.CoordSpaceP = 100;
            return para;
        }
 
 
 
        /// <summary>
        /// 清除数据
        /// </summary>
        public void ClearData()
        {
            CurveExprQH = null; CurveInfoQH = null;
            CurveExprQE = null; CurveInfoQE = null;
            CurveExprQP = null; CurveInfoQP = null;
            UpdatePoints();
        }
 
        /// <summary>
        /// 导出Excel
        /// </summary>
        public void ExportExcel()
        {
            IStation.WinFrmUI.Curve.ExportToXLS.Export(this.CurveExprQH, this.CurveExprQE, this.CurveExprQP, 12);
        }
    }
}