lixiaojun
2025-01-20 6e1306ab578ed1ad79fc33b0bb7e496b897bf4a4
WinFrmUI/Yw.WinFrmUI.Phart.Core/03-valve/02-edit/ValveChartExcelEditCtrl.cs
@@ -1,4 +1,5 @@
using NetTaste;
using Yw.Ahart;
namespace Yw.WinFrmUI.Phart
{
@@ -10,8 +11,7 @@
            this.gridView1.SetDefaultEditView();
            this.gridView1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            this.repImgCmbFeatType.Items.Add("穿过点", Yw.Ahart.eFeatType.Through, -1);
            this.repImgCmbFeatType.Items.Add("二次拟合", Yw.Ahart.eFeatType.Quadratic, -1);
            this.repImgCmbFeatType.Items.Add("三次拟合", Yw.Ahart.eFeatType.Cubic, -1);
@@ -28,6 +28,7 @@
                this.gridView1.FocusedRowHandle = index;
            };
            this.Enabled = false;
        }
        private Yw.Ahart.eCurveType _edit_curve_type = Ahart.eCurveType.QL;
@@ -65,6 +66,8 @@
            this.repImgCmbCurveType.EndInit(); 
            this.barImgCmbCurveType.EditValue = _edit_curve_type;
            this.Enabled = true;
        }
@@ -160,45 +163,12 @@
                e.Cancel = true;
            }
            var feat_type = (Yw.Ahart.eFeatType)e.NewValue;
            switch (feat_type)
            var bol = PhartVerifyHelper.VerifyCount(feat_type, vm.DefPointList.Count);
            if (!bol)
            {
                case Ahart.eFeatType.Cubic:
                    {
                        if (vm.DefPointList.Count < 4)
                        {
                            TipFormHelper.ShowInfo("点数少于4个点");
                            e.Cancel = true;
                        }
                    }
                    break;
                case Ahart.eFeatType.Through:
                    {
                        if (vm.DefPointList.Count < 1)
                        {
                            TipFormHelper.ShowInfo("点数少于1个点");
                            e.Cancel = true;
                        }
                    }
                    break;
                case Ahart.eFeatType.Quadratic:
                    {
                        if (vm.DefPointList.Count < 3)
                        {
                            TipFormHelper.ShowInfo("点数少于3个点");
                            e.Cancel = true;
                        }
                    }
                    break;
                case Ahart.eFeatType.Quartic:
                    {
                        if (vm.DefPointList.Count < 5)
                        {
                            TipFormHelper.ShowInfo("点数少于5个点");
                            e.Cancel = true;
                        }
                    }
                    break;
                e.Cancel = true;
            } 
        }
        //拟合类型
@@ -263,51 +233,60 @@
            var row = this.gridView1.GetCurrentViewModel(def_pt_list);
            if (row == null)
                return;
            var count = vm.DefPointList.Count - 1;
            switch (vm.FeatType)
            {
                case Ahart.eFeatType.Cubic:
                    {
                        if (count < 4)
                        {
                            TipFormHelper.ShowInfo("点数少于4个点");
                            return;
                        }
                    }
                    break;
                case Ahart.eFeatType.Through:
                    {
                        if (count < 1)
                        {
                            TipFormHelper.ShowInfo("点数少于1个点");
                            return;
                        }
                    }
                    break;
                case Ahart.eFeatType.Quadratic:
                    {
                        if (count < 3)
                        {
                            TipFormHelper.ShowInfo("点数少于3个点");
                            return;
                        }
                    }
                    break;
                case Ahart.eFeatType.Quartic:
                    {
                        if (count < 5)
                        {
                            TipFormHelper.ShowInfo("点数少于5个点");
                            return;
                        }
                    }
                    break;
            }
            var count = def_pt_list.Count - 1;
            var bol = PhartVerifyHelper.VerifyCount(vm.FeatType, count);
            if (!bol)
                return;
            def_pt_list.Remove(row);
            this.bindingSource1.ResetBindings(false);
            SetChart();
        }
        //粘贴板覆盖
        private void barBtnPastePlateCovering_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var vm = _vm_list?.Find(x => x.IsUpdate);
            if (vm == null)
            {
                this.valveEditChart1.Clear();
                return;
            }
            List<Yw.Geometry.Point2d> def_pt_list = vm.DefPointList;
            var row = this.gridView1.GetCurrentViewModel(def_pt_list);
            if (row == null)
                return;
            if (!ClipboardCurveTextUIHelper.CopyDouble(out List<List<double?>> list))
                return;
            if (list == null || list.Count < 1)
                return;
            if (list.Count != 2)
            {
                TipFormHelper.ShowError("数据不完整");
                return;
            }
            var cell_count = list.Count;
            var min_row_count = list.Min(x => x.Count);
            var pt_list = new List<Yw.Geometry.Point2d>(min_row_count);
            for (int i = 0; i < min_row_count; i++)
            {
                var x = list[0][i];
                var y = list[1][i];
                if (x.HasValue && y.HasValue)
                {
                    pt_list.Add(new Geometry.Point2d(x.Value, y.Value));
                }
            }
            var bol = PhartVerifyHelper.VerifyCount(vm.FeatType, pt_list.Count);
            if (!bol)
                return;
            def_pt_list.Clear();
            def_pt_list.AddRange(pt_list);
            this.bindingSource1.ResetBindings(false);
            SetChart();
        }
        private void SetChart()
        {
            if (_vm_list == null || !_vm_list.Any())