| | |
| | | using DevExpress.Utils; |
| | | using DevExpress.XtraCharts; |
| | | using System.Text; |
| | | using System.Windows.Forms; |
| | | using Yw.Geometry; |
| | | |
| | | namespace Yw.WinFrmUI.Phart |
| | |
| | | |
| | | #region Private Variable |
| | | |
| | | private List<PumpSerialParallelViewModel> _vm_list = new List<PumpSerialParallelViewModel>(); |
| | | private List<PumpSerialParallelInfoViewModel> _vm_list = new List<PumpSerialParallelInfoViewModel>(); |
| | | private readonly string _tag_qh = "CurveQH", _tag_qe = "CurveQE", _tag_qp = "CurveQP"; |
| | | |
| | | private XYDiagram _main_chart_diagram; |
| | |
| | | this.barCekCurveNameVisible.Checked = _line_name_visible; |
| | | } |
| | | } |
| | | private bool _line_name_visible = false; |
| | | private bool _line_name_visible = true; |
| | | |
| | | #endregion |
| | | |
| | |
| | | { |
| | | this.chartControl1.SetChartDisplay(); |
| | | this.chartControl1.Legend.Direction = DevExpress.XtraCharts.LegendDirection.TopToBottom; |
| | | this.chartControl1.SelectionMode = ElementSelectionMode.Single; |
| | | this.chartControl1.SeriesSelectionMode = SeriesSelectionMode.Series; |
| | | |
| | | _main_chart_diagram = (XYDiagram)chartControl1.Diagram; |
| | | _main_chart_diagram = (XYDiagram)this.chartControl1.Diagram; |
| | | _pane_qh = _main_chart_diagram.DefaultPane; |
| | | _pane_qe = (XYDiagramPane)_main_chart_diagram.FindPaneByName("PaneQE"); |
| | | _pane_qp = (XYDiagramPane)_main_chart_diagram.FindPaneByName("PaneQP"); |
| | |
| | | /// 添加曲线 |
| | | /// </summary> |
| | | /// <param name="vm_list"></param> |
| | | public void Add(List<PumpSerialParallelViewModel> vm_list, Yw.Geometry.Point2d design_pt) |
| | | public void Add(List<PumpSerialParallelInfoViewModel> vm_list, Yw.Geometry.Point2d design_pt) |
| | | { |
| | | if (vm_list == null || !vm_list.Any()) |
| | | return; |
| | | _vm_list = new List<PumpSerialParallelViewModel>(); |
| | | _vm_list = new List<PumpSerialParallelInfoViewModel>(); |
| | | _design_pt = design_pt; |
| | | _initialData = true; |
| | | _vm_list.AddRange(vm_list); |
| | | UpdateChart(true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加曲线 |
| | | /// </summary> |
| | | /// <param name="vm"></param> |
| | | public void Add(PumpSerialParallelInfoViewModel vm, Yw.Geometry.Point2d design_pt) |
| | | { |
| | | if (vm == null) |
| | | return; |
| | | if (_vm_list == null) |
| | | _vm_list = new List<PumpSerialParallelInfoViewModel>(); |
| | | _design_pt = design_pt; |
| | | _initialData = true; |
| | | _vm_list.Add(vm); |
| | | UpdateChart(true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置曲线 |
| | |
| | | { |
| | | exist.Name = name; |
| | | } |
| | | exist.Qh = cubic_spline_qh; |
| | | exist.Qe = cubic_spline_qe; |
| | | exist.Qp = cubic_spline_qp; |
| | | exist.QhCalc = cubic_spline_qh; |
| | | exist.QeCalc = cubic_spline_qe; |
| | | exist.QpCalc = cubic_spline_qp; |
| | | |
| | | UpdateChart(true); |
| | | } |
| | |
| | | /// 设置曲线 |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <param name="name"></param> |
| | | /// <param name="color"></param> |
| | | public void Set(string id, Color color) |
| | | public void SetInfo(string id, string name, Color color) |
| | | { |
| | | var exist = _vm_list.FirstOrDefault(x => x.Id == id); |
| | | if (exist == null) |
| | |
| | | continue; |
| | | if (tag.ToString() != exist.Id) |
| | | continue; |
| | | exist.Name = name; |
| | | exist.Color = color; |
| | | series.View.Color = color; |
| | | for (int i = 0; i < this.chartControl1.AnnotationRepository.Count; i++) |
| | |
| | | var txt = this.chartControl1.AnnotationRepository[i]; |
| | | if (txt.Name == _tag_qh + id) |
| | | { |
| | | (txt as TextAnnotation).Text = name; |
| | | (txt as TextAnnotation).TextColor = color; |
| | | (txt as TextAnnotation).Border.Color = color; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置曲线(需手动更新图表) |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <param name="name"></param> |
| | | public void SetName(string id, string name) |
| | | { |
| | | var exist = _vm_list.FirstOrDefault(x => x.Id == id); |
| | | if (exist == null) |
| | | return; |
| | | exist.Name = name; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设置设计点 |
| | | /// </summary> |
| | |
| | | |
| | | foreach (var vm in _vm_list) |
| | | { |
| | | var qh_pt_list = vm.Qh.GetPointList(); |
| | | var qh_pt_list = vm.QhCalc.GetPointList(); |
| | | var xxx = qh_pt_list.Select(x => x.X); |
| | | var yyy = qh_pt_list.Select(x => x.Y); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | foreach (PumpSerialParallelViewModel vm in _vm_list) |
| | | foreach (PumpSerialParallelInfoViewModel vm in _vm_list) |
| | | { |
| | | if (vm.Qe == null) |
| | | if (vm.QeCalc == null) |
| | | continue; |
| | | var qe_pt_list = vm.Qe.GetPointList(); |
| | | var qe_pt_list = vm.QeCalc.GetPointList(); |
| | | var yyy = qe_pt_list.Select(x => x.Y); |
| | | _maxE = Math.Max(_maxE, yyy.Max()); |
| | | } |
| | | |
| | | foreach (PumpSerialParallelViewModel vm in _vm_list) |
| | | foreach (PumpSerialParallelInfoViewModel vm in _vm_list) |
| | | { |
| | | if (vm.Qp == null) |
| | | if (vm.QpCalc == null) |
| | | continue; |
| | | var yyy = vm.Qp.GetPointList().Select(x => x.Y); |
| | | var yyy = vm.QpCalc.GetPointList().Select(x => x.Y); |
| | | _minP = Math.Min(_minP, yyy.Min()); |
| | | _maxP = Math.Max(_maxP, yyy.Max()); |
| | | } |
| | |
| | | if (_vm_list.Count > 0) |
| | | { |
| | | foreach (var vm in _vm_list) |
| | | { |
| | | { |
| | | if (!vm.IsSerialParallel) |
| | | { |
| | | CreateLineSeries(vm); |
| | | } |
| | | else |
| | | { |
| | | CreateLineSeries(vm); |
| | | CreateEqSeries(vm, _design_pt); |
| | | } |
| | | } |
| | |
| | | if (_vm_list == null || !_vm_list.Any()) |
| | | return; |
| | | |
| | | if (_vm_list.Exists(x => x.Id == "-1")) |
| | | if (_vm_list.Exists(x => x.IsSerialParallel)) |
| | | { |
| | | _work_pt_txt_annot.Visible = true; |
| | | } |
| | |
| | | return; |
| | | foreach (var vm in _vm_list) |
| | | { |
| | | var curveMinQ = vm.Qh.MinX; |
| | | var curveMaxQ = vm.Qh.MaxX; |
| | | var curveMinQ = vm.QhCalc.MinX; |
| | | var curveMaxQ = vm.QhCalc.MaxX; |
| | | |
| | | var workPoint = new PumpGroupPt(0, 0, 0, 0, 0); |
| | | if (curveMinQ > workQ.Value || workQ.Value > curveMaxQ) |
| | |
| | | OnCalcQueryPoint(vm.Id, workPoint); |
| | | } |
| | | |
| | | if (vm.Id == "-1") |
| | | if (vm.IsSerialParallel) |
| | | { |
| | | _work_pt_txt_annot.Visible = false; |
| | | } |
| | |
| | | } |
| | | |
| | | workPoint.Q = workQ.Value; |
| | | workPoint.H = vm.Qh.GetPointY(workQ.Value); |
| | | workPoint.H = vm.QhCalc.GetPointY(workQ.Value); |
| | | |
| | | var workInfoStringBuilder = new StringBuilder(); |
| | | workInfoStringBuilder.AppendLine($"流量:{workPoint.Q.ToString("N1")} "); |
| | | workInfoStringBuilder.AppendLine($"扬程:{workPoint.H.ToString("N1")} "); |
| | | |
| | | |
| | | if (vm.Qe != null) |
| | | if (vm.QeCalc != null) |
| | | { |
| | | if (vm.Qp != null) |
| | | if (vm.QpCalc != null) |
| | | { |
| | | workPoint.P = vm.Qp.GetPointY(workPoint.Q); |
| | | workPoint.P = vm.QpCalc.GetPointY(workPoint.Q); |
| | | workPoint.E = PumpCalcHelper.CalculateE(workPoint.Q, workPoint.H, workPoint.P); |
| | | } |
| | | else |
| | | { |
| | | workPoint.E = vm.Qe.GetPointY(workPoint.Q); |
| | | workPoint.E = vm.QeCalc.GetPointY(workPoint.Q); |
| | | } |
| | | |
| | | workInfoStringBuilder.AppendLine($"效率:{workPoint.E.ToString("N2")} "); |
| | | } |
| | | if (vm.Qp != null) |
| | | if (vm.QpCalc != null) |
| | | { |
| | | workPoint.P = vm.Qp.GetPointY(workPoint.Q); |
| | | workPoint.P = vm.QpCalc.GetPointY(workPoint.Q); |
| | | workInfoStringBuilder.Append($"功率:{workPoint.P.ToString("N1")} "); |
| | | } |
| | | |
| | | if (vm.Id == "-1") |
| | | if (vm.IsSerialParallel) |
| | | { |
| | | _work_pt_txt_annot.Text = workInfoStringBuilder.ToString(); |
| | | _work_pt_txt_annot.AutoSize = true; |
| | |
| | | /// <summary> |
| | | /// 创建线系列 |
| | | /// </summary> |
| | | private void CreateLineSeries(PumpSerialParallelViewModel curve) |
| | | { |
| | | |
| | | private void CreateLineSeries(PumpSerialParallelInfoViewModel curve) |
| | | { |
| | | var series_qh = new DevExpress.XtraCharts.Series(); |
| | | series_qh.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical; |
| | | series_qh.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False; |
| | |
| | | series_qh.CrosshairEnabled = DefaultBoolean.False; |
| | | series_qh.Tag = curve.Id.ToString(); |
| | | series_qh.ShowInLegend = true; |
| | | series_qh.LegendTextPattern = curve.Name; |
| | | series_qh.LegendTextPattern = curve.Name; |
| | | |
| | | var series_qh_view = new DevExpress.XtraCharts.SplineSeriesView(); |
| | | series_qh_view.LineStyle.Thickness = 2; |
| | |
| | | series_qh.View = series_qh_view; |
| | | series_qh.Visible = _cubic_spline_qh_visible; |
| | | |
| | | var pointsQH = curve.Qh.GetPointList(12); |
| | | var pointsQH = curve.QhCalc.GetPointList(12); |
| | | for (int i = 0; i < pointsQH.Count; i++) |
| | | { |
| | | series_qh.Points.Add(new SeriesPoint(pointsQH[i].X, new double[] { pointsQH[i].Y })); |
| | |
| | | txt_qh.TextColor = curve.Color; |
| | | txt_qh.ShapePosition = position_qh; |
| | | txt_qh.Visible = _line_name_visible; |
| | | this.chartControl1.AnnotationRepository.Add(txt_qh); |
| | | |
| | | this.chartControl1.AnnotationRepository.Add(txt_qh); |
| | | this.chartControl1.Series.Add(series_qh); |
| | | |
| | | if (curve.Qe != null) |
| | | if (curve.QeCalc != null) |
| | | { |
| | | var series_qe = new DevExpress.XtraCharts.Series(); |
| | | series_qe.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical; |
| | |
| | | series_qe.View = series_qe_view; |
| | | series_qe.Visible = _cubic_spline_qe_visible; |
| | | |
| | | var pointsQE = curve.Qe.GetPointList(12); |
| | | var pointsQE = curve.QeCalc.GetPointList(12); |
| | | for (int i = 0; i < pointsQE.Count; i++) |
| | | { |
| | | series_qe.Points.Add(new SeriesPoint(pointsQE[i].X, new double[] { pointsQE[i].Y })); |
| | |
| | | this.chartControl1.Series.Add(series_qe); |
| | | } |
| | | |
| | | if (curve.Qp != null) |
| | | if (curve.QpCalc != null) |
| | | { |
| | | var series_qp = new DevExpress.XtraCharts.Series(); |
| | | series_qp.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical; |
| | |
| | | series_qp.View = series_qp_view; |
| | | series_qp.Visible = _cubic_spline_qp_visible; |
| | | |
| | | var pointsQP = curve.Qp.GetPointList(12); |
| | | var pointsQP = curve.QpCalc.GetPointList(12); |
| | | for (int i = 0; i < pointsQP.Count; i++) |
| | | { |
| | | series_qp.Points.Add(new SeriesPoint(pointsQP[i].X, new double[] { pointsQP[i].Y })); |
| | |
| | | |
| | | this.chartControl1.Series.Add(series_qp); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 创建装置系列 |
| | | /// </summary> |
| | | public void CreateEqSeries(PumpSerialParallelViewModel vm, Yw.Geometry.Point2d design_pt) |
| | | public void CreateEqSeries(PumpSerialParallelInfoViewModel vm, Yw.Geometry.Point2d design_pt) |
| | | { |
| | | this.chartControl1.BeginInit(); |
| | | if (vm == null || design_pt == null) |
| | |
| | | return; |
| | | } |
| | | |
| | | var eq_paras = EquipCurveHelper.CalcEquipCurve(vm.Qh, design_pt, out Yw.Geometry.Point2d sect_pt); |
| | | var eq_paras = EquipCurveHelper.CalcEquipCurve(vm.QhCalc, design_pt, out Yw.Geometry.Point2d sect_pt); |
| | | if (eq_paras == null) |
| | | { |
| | | ClearEqSeries(); |
| | |
| | | _series_eq.Name = "eq"; |
| | | _series_eq.ShowInLegend = false; |
| | | _series_eq.CrosshairEnabled = DefaultBoolean.False; |
| | | _series_eq.Tag = vm.Id.ToString(); |
| | | _series_eq.Tag = vm.Id.ToString(); |
| | | |
| | | |
| | | var series_qe_view = new DevExpress.XtraCharts.SplineSeriesView(); |
| | | series_qe_view.LineStyle.Thickness = 2; |
| | | series_qe_view.Color = vm.Color; |
| | | series_qe_view.AxisY = _axis_y_qe; |
| | | series_qe_view.Pane = _pane_qe; |
| | | series_qe_view.EnableAntialiasing = DefaultBoolean.True; |
| | | var series_eq_view = new DevExpress.XtraCharts.SplineSeriesView(); |
| | | series_eq_view.Color = vm.Color; |
| | | series_eq_view.AxisY = _axis_y_qh; |
| | | series_eq_view.Pane = _pane_qh; |
| | | series_eq_view.EnableAntialiasing = DefaultBoolean.True; |
| | | series_eq_view.LineStyle.DashStyle = DashStyle.Dash; |
| | | series_eq_view.LineStyle.Thickness = 2; |
| | | |
| | | _series_eq.SeriesPointsSorting = SortingMode.None; |
| | | _series_eq.SeriesPointsSortingKey = SeriesPointKey.Value_1; |
| | | _series_eq.View = series_qe_view; |
| | | |
| | | _series_eq.View = series_eq_view; |
| | | _series_eq.Visible = _cubic_spline_eq_visible; |
| | | |
| | | var eq_pt_list = eq.GetPointList(12); |
| | |
| | | _series_eq_pt.CrosshairEnabled = DefaultBoolean.False; |
| | | _series_eq_pt.ShowInLegend = true; |
| | | _series_eq_pt.LegendTextPattern = "设计点"; |
| | | _series_eq_pt.LabelsVisibility = DefaultBoolean.True; |
| | | _series_eq_pt.LabelsVisibility = DefaultBoolean.False; |
| | | |
| | | |
| | | var series_eq_pt_view = new DevExpress.XtraCharts.PointSeriesView(); |
| | | series_eq_pt_view.Color = vm.Color; |
| | | series_eq_pt_view.Pane = _pane_qh; |
| | | series_eq_pt_view.PointMarkerOptions.BorderColor = vm.Color; |
| | | series_eq_pt_view.PointMarkerOptions.Size = 15; |
| | | series_eq_pt_view.PointMarkerOptions.Kind = MarkerKind.ThinCross; |
| | | |
| | | _series_eq_pt.SeriesPointsSorting = SortingMode.None; |
| | | _series_eq_pt.SeriesPointsSortingKey = SeriesPointKey.Value_1; |
| | | _series_eq_pt.View = series_eq_pt_view; |
| | | _series_eq_pt.Visible = _cubic_spline_eq_visible; |
| | | |
| | | |
| | | _series_eq_pt.Visible = _cubic_spline_eq_visible; |
| | | _series_eq_pt.Points.Add(new SeriesPoint(design_pt.X, new double[] { design_pt.Y })); |
| | | |
| | | this.chartControl1.Series.Add(_series_eq_pt); |
| | | |
| | | this.chartControl1.Series.Add(_series_eq_pt); |
| | | this.chartControl1.EndInit(); |
| | | } |
| | | |
| | |
| | | return; |
| | | foreach (var item in _vm_list) |
| | | { |
| | | if (item.Id == "-1") |
| | | if (item.IsSerialParallel) |
| | | continue; |
| | | var qh = item.Qh; |
| | | var qe = item.Qe; |
| | | var qp = item.Qp; |
| | | |
| | | var qh = item.QhCalc; |
| | | var qe = item.QeCalc; |
| | | var qp = item.QpCalc; |
| | | list.Add(new Tuple<Geometry.CubicSpline2d, Geometry.CubicSpline2d, Geometry.CubicSpline2d>(qh, qe, qp)); |
| | | } |
| | | } |