cloudflight
2024-06-15 6ea5dced7cd5e9b6136b96f38be4ba4116943524
Hydraulic/Hydro.MapUI/Map/MapViewer.cs
@@ -1,5 +1,7 @@
//using CloudWaterNetwork.Magnifier;
using DevExpress.XtraEditors;
using Hydro.CommonBase;
using Hydro.Core.Model;
using Hydro.Inp;
//using ConfigApp;
//using DevExpress.Diagram.Core.Layout;
@@ -27,6 +29,7 @@
using System.Runtime.Remoting.Metadata;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
@@ -927,6 +930,8 @@
                NodeViewModel minNode = null;
                foreach (NodeViewModel node in nodes)
                {
                    PointF mapPos = WorldPointToMapPoint(node);
                    PointF currentPoint = MapToScreen(mapPos);
                    float currentDist = 0;
@@ -2468,7 +2473,98 @@
        }
        private void btn_初分配_Click(object sender, EventArgs e)
        {
            string result = null;
            if ((result=_Template.network.CheckValidate())!=null)
            {
                MessageBox.Show(result);
                return;
            }
            List<WaterEquivalentSettings> settings = new List<WaterEquivalentSettings>();
            settings.Add(new WaterEquivalentSettings()
            {
                waterEquivalents=new WaterEquivalentTemplate()
                {
                    ID="1",
                    Name="1",
                    WaterEquivalentCollection=new WaterEquivalentCollection()
                    {
                        new WaterEquivalent()
                        {
                            ID=1008,
                            MinRatedFlow=0.48f,
                            RatedFlow=0.72f,
                            Count=1,
                        },
                        new WaterEquivalent()
                        {
                            ID=1009,
                            MinRatedFlow=0.88f,
                            RatedFlow=0.96f,
                            Count=2,
                        },
                        new WaterEquivalent()
                        {
                            ID=1010,
                            MinRatedFlow=1.08f,
                            RatedFlow=1.08f,
                            Count=3,
                        }
                    }
                },
                Meters=new List<string>()
                {
                    //按以下规律生成数组到M10,"M1","M2"
                        "M1","M2","M3","M4","M5","M6","M7","M8","M9","M10","M11","M12","M13","M14","M15","M16",
                    "M17","M18","M19","M20","M21","M22","M23","M24","M25","M26","M27","M28","M29","M30"
                },
            });
            settings.Add(new WaterEquivalentSettings()
            {
                waterEquivalents = new WaterEquivalentTemplate()
                {
                    ID = "1",
                    Name = "1",
                    WaterEquivalentCollection = new WaterEquivalentCollection()
                    {
                        new WaterEquivalent()
                        {
                            ID=2008,
                            MinRatedFlow=0.48f,
                            RatedFlow=0.48f,
                            Count=1,
                        },
                        new WaterEquivalent()
                        {
                            ID=2009,
                            MinRatedFlow=0.12f,
                            RatedFlow=0.12f,
                            Count=5,
                        },
                        new WaterEquivalent()
                        {
                            ID=2010,
                            MinRatedFlow=0.16f,
                            RatedFlow=0.18f,
                            Count=6,
                        }
                    }
                },
                Meters = new List<string>()
                {
                    //按以下规律生成数组到M10,"M1","M2"
                       "M31","M32","M33","M34","M35","M36","M37","M38","M39","M40","M41","M42","M43","M44","M45","M46","M47","M48","M49","M50","M51","M52","M53","M54","M55","M56","M57","M58","M59","M60","M61","M62","M63","M64","M65","M66","M67","M68","M69","M70","M71","M72","M73","M74","M75","M76","M77","M78","M79","M80"
                },
            });
            var head=_Network.reservoirs.FirstOrDefault().Head;
            _Network.WaterDistribution(_Template.FullPath, GlobalPath.configPath + "config_waterDistri.wdb",settings,40, head);
        }
        public void toolStripButton_计算_Click(object sender, EventArgs e)
        {
@@ -3134,6 +3230,59 @@
            }
        }
        /// <summary>
        /// 批量一键生成楼层模型
        /// </summary>
        public void BatchInsertNet(Template temp)
        {
            var nodes = _Nodes.Where(c => c.Elev > 0).Select(node => (NodeViewModel)node).ToList();
            _undoOldValue = new PointF3D(0, 0, 0);
            _OperaNode = temp.network.Nodes.Find(node => node.ID == temp.Node1) as NodeViewModel;
            //foreach (var item in nodes)
            if (nodes.Any())
            {
                for (var i = 0; i < nodes.Count(); i++)
                {
                    var net = temp.network.DeepCopy();
                    float dx, dy, dz;
                    var p1 = (PointF3D)_undoOldValue;
                    var p2 = nodes[i].Position3D;
                    var dd = temp.OffSet;
                    dx = p2.X - p1.X;
                    dy = p2.Y - p1.Y;
                    dz = p2.Z - p1.Z;
                    net.Nodes.ForEach(n => { ((NodeViewModel)n).Position3D = new PointF3D(n.X + dx, n.Y + dy, n.Elev + dz); });
                    var list = _Network.Add(net);
                    //var j = _Network.AddPipe(nodes[i], _OperaNode);
                    //j.Length = 0.0001f;
                    //list.Add(j);
                    _NewNet.Clear();
                    _Network.BuildRelation();
                    selectedObjs.ForEach(o => o.Selected = false);
                    selectedObjs.Clear();
                    //list.ForEach(m => m.Selected = true);
                    //selectedObjs.AddRange(list);
                    MapObjectExtensions.AddCommand(_Network, "Add", null, list);
                }
                _OperaNode = null;
                //_OperaNode = null;
                //_Network.Nodes.AddRange(net.Nodes);
                //_Network.Links.AddRange(net.Links);
                SetMapInvalidate();
            }
        }
        private void 以当前视角另存ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_Template == null) return;
@@ -3463,7 +3612,7 @@
            {
                var backgroundImagePath = openFileDialog.FileName;
                Global.ClearFileReadOnly(_Template.BackGroundImg_FullPath);
                File.Copy(backgroundImagePath, _Template.BackGroundImg_FullPath, true);
                FileCopy.Copy(backgroundImagePath, _Template.BackGroundImg_FullPath, true);
                设置底图ToolStripMenuItem_Click(1, new EventArgs());
            }
        }
@@ -3712,18 +3861,30 @@
        private void cb_Link_Colour_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_Template == null) return;
            var type = cb_Link_Colour.SelectedItem==null?ColourType.管线流量:(ColourType)cb_Link_Colour.SelectedItem;
            mapOption.ColourLink = type;
            var type = cb_Link_Colour.SelectedItem == null ? ColourType.管线流量 : (ColourType)cb_Link_Colour.SelectedItem;
            var doubles = _Template.network.getMinMax(type);
            var colour = new Colour(type, null, type.ToString());
            List<ColourItem> colours = Colour.GetColourItems((float)doubles[0], (float)doubles[1], 5, Color.Gray, Color.Red);
            colour.Items = colours;
            LinkColour = colour;
            this.SetMapInvalidate();
        }
        private void cb_Node_Colour_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_Template == null) return;
            var type = cb_Node_Colour.SelectedItem==null?ColourType.节点自由压力:(ColourType)cb_Node_Colour.SelectedItem;
            mapOption.ColourNode = type;
            var type = cb_Node_Colour.SelectedItem == null ? ColourType.节点自由压力 : (ColourType)cb_Node_Colour.SelectedItem;
            var doubles = _Template.network.getMinMax(type);
            var colour = new Colour(type, null, type.ToString());
            List<ColourItem> colours = Colour.GetColourItems((float)doubles[0], (float)doubles[1], 5, Color.Gray, Color.Red);
            colour.Items = colours;
            NodeColour = colour;
            this.SetMapInvalidate();
        }
        private void label_ZZ_Click(object sender, EventArgs e)