From bc99451a0ab10dbba6ac1fe4cea020d68bbbad2b Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期五, 28 三月 2025 18:51:18 +0800
Subject: [PATCH] 增加水池和水泵绘制

---
 Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/Draw2dHelper.cs                      |   20 +++++
 Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/DrawPump2dExtensions.cs              |   81 ++++++++++++++++++++
 Yw.Epanet.Core/Properties/PublishProfiles/FolderProfile.pubxml.user               |    2 
 Yw.Epanet.Calcu.Core/Yw.Epanet.Calcu.Core.csproj                                  |    4 
 Yw.Epanet.Core/Yw.Epanet.Core.csproj                                              |    2 
 Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2d.cs       |    3 
 Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2dHelper.cs |    9 +
 /dev/null                                                                         |   10 --
 Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleLink2dL3d.cs          |    2 
 Yw.Epanet.Calcu.Core/04-Inp/InpGenerater.cs                                       |    2 
 Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleNode2dL3d.cs          |    2 
 Yw.WinFrmUI.Hydro.L3d.Core/01-network/03-node/02-source/00-core/SourceL3d.cs      |    7 +
 Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/DrawSource2dExtensions.cs            |   64 ++++++++++++++++
 Yw.Epanet.Calcu.Core/04-Inp/InpSection.cs                                         |    2 
 Yw.WinFrmUI.Hydro.L3d.Core/02-helper/05-network/Network2dExtensions.cs            |   26 +++++-
 Yw.Epanet.Calcu.Core/Properties/PublishProfiles/FolderProfile.pubxml.user         |    2 
 16 files changed, 209 insertions(+), 29 deletions(-)

diff --git a/Yw.Epanet.Calcu.Core/04-Inp/InpGenerater.cs b/Yw.Epanet.Calcu.Core/04-Inp/InpGenerater.cs
index f368d09..533d9bf 100644
--- a/Yw.Epanet.Calcu.Core/04-Inp/InpGenerater.cs
+++ b/Yw.Epanet.Calcu.Core/04-Inp/InpGenerater.cs
@@ -113,7 +113,7 @@
                 var startNodeId = x.StartNodeId;
                 var endNodeId = x.EndNodeId;
                 var propertySb = new StringBuilder();
-                propertySb.Append($"Power {x.RatedP}");
+                //propertySb.Append($"Power {x.RatedP}");//姝ゆ浠g爜娉ㄩ噴锛屾槸鍥犱负姣忓彴姘存车蹇呴』鎻愪緵POWER鎴栬�匟EAD锛屽厛鏆傛椂鎶婂姛鐜囧幓鎺夌敤浜庡垽鏂璁$畻鐨勫奖鍝�
                 propertySb.Append($" HEAD {x.CurveQH}");
                 propertySb.Append($" SPEED {x.SpeedRatio}");
                 if (!string.IsNullOrEmpty(x.SpeedRatioPattern))
diff --git a/Yw.Epanet.Calcu.Core/04-Inp/InpSection.cs b/Yw.Epanet.Calcu.Core/04-Inp/InpSection.cs
index 9789fda..4d3bbd6 100644
--- a/Yw.Epanet.Calcu.Core/04-Inp/InpSection.cs
+++ b/Yw.Epanet.Calcu.Core/04-Inp/InpSection.cs
@@ -117,7 +117,7 @@
         /// <summary>
         /// 鎻忚堪浜嗕粠妯℃嫙浜х敓杈撳嚭鎶ュ憡鐨勫唴瀹�
         /// </summary>
-        public const string Report = "REPORT";
+        public const string Report = "[REPORT]";
 
         /// <summary>
         /// 鏍囪
diff --git a/Yw.Epanet.Calcu.Core/Properties/PublishProfiles/FolderProfile.pubxml.user b/Yw.Epanet.Calcu.Core/Properties/PublishProfiles/FolderProfile.pubxml.user
index 8817e19..8fdc3c9 100644
--- a/Yw.Epanet.Calcu.Core/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/Yw.Epanet.Calcu.Core/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -4,7 +4,7 @@
 -->
 <Project>
   <PropertyGroup>
-    <History>True|2025-03-12T11:06:53.4326230Z;False|2025-03-12T19:04:42.3438938+08:00;True|2025-03-12T16:14:19.2199322+08:00;True|2025-03-12T14:01:23.6851127+08:00;True|2025-03-12T10:58:01.1114649+08:00;True|2025-03-12T10:39:45.7032714+08:00;False|2025-03-10T14:34:27.3404982+08:00;False|2025-03-10T14:34:23.4248606+08:00;</History>
+    <History>True|2025-03-28T03:08:28.0243167Z;True|2025-03-28T10:53:40.3515997+08:00;True|2025-03-12T19:06:53.4326230+08:00;False|2025-03-12T19:04:42.3438938+08:00;True|2025-03-12T16:14:19.2199322+08:00;True|2025-03-12T14:01:23.6851127+08:00;True|2025-03-12T10:58:01.1114649+08:00;True|2025-03-12T10:39:45.7032714+08:00;False|2025-03-10T14:34:27.3404982+08:00;False|2025-03-10T14:34:23.4248606+08:00;</History>
     <LastFailureDetails />
   </PropertyGroup>
 </Project>
\ No newline at end of file
diff --git a/Yw.Epanet.Calcu.Core/Yw.Epanet.Calcu.Core.csproj b/Yw.Epanet.Calcu.Core/Yw.Epanet.Calcu.Core.csproj
index 062aac7..6b87dfd 100644
--- a/Yw.Epanet.Calcu.Core/Yw.Epanet.Calcu.Core.csproj
+++ b/Yw.Epanet.Calcu.Core/Yw.Epanet.Calcu.Core.csproj
@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>disable</Nullable>
     <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-    <Version>1.0.6</Version>
+    <Version>1.0.8</Version>
   </PropertyGroup>
 
   <ItemGroup>
@@ -16,7 +16,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="Yw.Epanet.Core" Version="1.0.3" />
+    <PackageReference Include="Yw.Epanet.Core" Version="1.0.5" />
   </ItemGroup>
 
 </Project>
diff --git a/Yw.Epanet.Core/Properties/PublishProfiles/FolderProfile.pubxml.user b/Yw.Epanet.Core/Properties/PublishProfiles/FolderProfile.pubxml.user
index 61530cf..6facdc0 100644
--- a/Yw.Epanet.Core/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/Yw.Epanet.Core/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -4,7 +4,7 @@
 -->
 <Project>
   <PropertyGroup>
-    <History>True|2025-03-12T11:00:59.6584483Z;True|2025-03-12T14:00:14.5595302+08:00;True|2025-03-12T10:36:56.6420798+08:00;True|2025-03-10T14:26:05.5992575+08:00;True|2025-03-10T14:25:20.8669529+08:00;True|2025-03-10T14:25:08.3622330+08:00;</History>
+    <History>True|2025-03-28T02:49:36.3463760Z;True|2025-03-12T19:00:59.6584483+08:00;True|2025-03-12T14:00:14.5595302+08:00;True|2025-03-12T10:36:56.6420798+08:00;True|2025-03-10T14:26:05.5992575+08:00;True|2025-03-10T14:25:20.8669529+08:00;True|2025-03-10T14:25:08.3622330+08:00;</History>
     <LastFailureDetails />
   </PropertyGroup>
 </Project>
\ No newline at end of file
diff --git a/Yw.Epanet.Core/Yw.Epanet.Core.csproj b/Yw.Epanet.Core/Yw.Epanet.Core.csproj
index ad8ff70..094c25e 100644
--- a/Yw.Epanet.Core/Yw.Epanet.Core.csproj
+++ b/Yw.Epanet.Core/Yw.Epanet.Core.csproj
@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>disable</Nullable>
     <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-    <Version>1.0.3</Version>
+    <Version>1.0.5</Version>
   </PropertyGroup>
 
   <ItemGroup>
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/01-network/03-node/02-source/00-core/SourceL3d.cs b/Yw.WinFrmUI.Hydro.L3d.Core/01-network/03-node/02-source/00-core/SourceL3d.cs
index 085dc07..5fb8665 100644
--- a/Yw.WinFrmUI.Hydro.L3d.Core/01-network/03-node/02-source/00-core/SourceL3d.cs
+++ b/Yw.WinFrmUI.Hydro.L3d.Core/01-network/03-node/02-source/00-core/SourceL3d.cs
@@ -13,7 +13,12 @@
         /// <summary>
         /// 
         /// </summary>
-        public SourceL3d(SourceL3d rhs) : base(rhs) { }
+        public SourceL3d(SourceL3d rhs) : base(rhs)
+        {
+
+        }
+
+
 
     }
 }
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/Style2dL3d.cs b/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/Style2dL3d.cs
deleted file mode 100644
index c13f092..0000000
--- a/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/Style2dL3d.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-锘縩amespace Yw.WinFrmUI.Hydro
-{
-    /// <summary>
-    /// 2d鏍峰紡
-    /// </summary>
-    public class Style2dL3d
-    {
-
-    }
-}
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleLink2dL3d.cs b/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleLink2dL3d.cs
index ced9ab1..d929bdf 100644
--- a/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleLink2dL3d.cs
+++ b/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleLink2dL3d.cs
@@ -3,7 +3,7 @@
     /// <summary>
     /// 
     /// </summary>
-    public class StyleLink2dL3d : Style2dL3d
+    public class StyleLink2dL3d
     {
         /// <summary>
         /// 
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleNode2dL3d.cs b/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleNode2dL3d.cs
index bfc84e5..5827ac0 100644
--- a/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleNode2dL3d.cs
+++ b/Yw.WinFrmUI.Hydro.L3d.Core/01-network/05-style/00-core/StyleNode2dL3d.cs
@@ -3,7 +3,7 @@
     /// <summary>
     /// 
     /// </summary>
-    public class StyleNode2dL3d : Style2dL3d
+    public class StyleNode2dL3d
     {
         /// <summary>
         /// 
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/Draw2dHelper.cs b/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/Draw2dHelper.cs
index 9527e38..acfc60d 100644
--- a/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/Draw2dHelper.cs
+++ b/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/Draw2dHelper.cs
@@ -73,6 +73,26 @@
             GL.End();
         }
 
+        /// <summary>
+        /// 缁樺埗鐭╁舰
+        /// </summary>
+        /// <param name="topLeft">宸︿笂</param>
+        /// <param name="topRight">鍙充笂</param>
+        /// <param name="bottomRight">鍙充笅</param>
+        /// <param name="bottomLeft">宸︿笅</param>
+        /// <param name="color">棰滆壊</param>
+        public static void DrawRectangle(Vector3 topLeft, Vector3 topRight, Vector3 bottomRight, Vector3 bottomLeft, Color color)
+        {
+            GL.Begin(PrimitiveType.Quads);
+            GL.Color3(color);
+            GL.Vertex3(topLeft);
+            GL.Vertex3(topRight);
+            GL.Vertex3(bottomRight);
+            GL.Vertex3(bottomLeft);
+            GL.End();
+        }
+
+
     }
 
 }
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/DrawPump2dExtensions.cs b/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/DrawPump2dExtensions.cs
new file mode 100644
index 0000000..f031829
--- /dev/null
+++ b/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/DrawPump2dExtensions.cs
@@ -0,0 +1,81 @@
+锘縰sing OpenTK.Graphics.OpenGL;
+using OpenTK.Mathematics;
+using OpenTK.Windowing.Common;
+using System.Drawing;
+
+namespace Yw.WinFrmUI.Hydro
+{
+    /// <summary>
+    /// 缁樺埗姘存车2d杈呭姪绫�
+    /// </summary>
+    internal static class DrawPump2dExtensions
+    {
+        /// <summary>
+        /// 缁樺埗姘存簮
+        /// </summary>
+        public static void Draw2d(this PumpL3d pump, float zoom)
+        {
+            var width = pump.Style2d.Normal.Width;
+            var color = pump.Style2d.Normal.Color;
+            if (pump.IsSelected)
+            {
+                width = pump.Style2d.Selected.Width;
+                color = pump.Style2d.Selected.Color;
+            }
+            if (pump.IsHovered)
+            {
+                width = pump.Style2d.Hovered.Width;
+                color = pump.Style2d.Hovered.Color;
+            }
+
+            Draw2dHelper.DrawLine(width, color, pump.StartPosition, pump.EndPosition);
+
+            var start = new Vector3(pump.StartPosition.X, pump.StartPosition.Y, pump.StartPosition.Z);
+            var end = new Vector3(pump.EndPosition.X, pump.EndPosition.Y, pump.EndPosition.Z);
+            var middle = (start + end) / 2f;
+            var direction = (start - middle).Normalized();
+            var circle = middle + direction * (width * zoom * 2f);
+            Draw2dHelper.DrawPoint(width * 4f, color, circle);
+
+
+            direction = (end - circle).Normalized();
+
+            var rect = circle + direction * (width * zoom * 4f);
+
+            // 閫夋嫨涓�涓緟鍔╁悜閲忥紙杩欓噷閫夋嫨 Y 杞存鏂瑰悜锛�
+            Vector3 up = Vector3.UnitY;
+            if (MathHelper.Abs(Vector3.Dot(direction, up)) > 0.99f)
+            {
+                up = Vector3.UnitZ;
+            }
+
+            // 璁$畻鍨傜洿浜庣嚎娈垫柟鍚戠殑鍚戦噺锛堝嵆宸︿晶鏂瑰悜锛�
+            Vector3 leftDirection = Vector3.Cross(direction, up).Normalized();
+
+            // 璁$畻鐭╁舰鐨勫洓涓《鐐�
+            Vector3 rectTopLeft = circle + leftDirection * (width * zoom);
+            Vector3 rectTopRight = rect + leftDirection * (width * zoom);
+            Vector3 rectBottomLeft = circle;
+            Vector3 rectBottomRight = rect;
+
+            // 缁樺埗鐭╁舰
+            Draw2dHelper.DrawRectangle(rectTopLeft, rectTopRight, rectBottomRight, rectBottomLeft, color);
+
+
+        }
+
+
+
+
+
+
+
+
+
+
+
+
+    }
+
+
+}
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/DrawSource2dExtensions.cs b/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/DrawSource2dExtensions.cs
new file mode 100644
index 0000000..43bf1d2
--- /dev/null
+++ b/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/04-draw/DrawSource2dExtensions.cs
@@ -0,0 +1,64 @@
+锘縰sing OpenTK.Graphics.OpenGL;
+
+namespace Yw.WinFrmUI.Hydro
+{
+    /// <summary>
+    /// 缁樺埗姘存簮2d杈呭姪绫�
+    /// </summary>
+    internal static class DrawSource2dExtensions
+    {
+        /// <summary>
+        /// 缁樺埗姘存簮
+        /// </summary>
+        public static void Draw2d(this SourceL3d source, float zoom)
+        {
+            var radiu = source.Style2d.Normal.Radiu;
+            var color = source.Style2d.Normal.Color;
+            if (source.IsSelected)
+            {
+                radiu = source.Style2d.Selected.Radiu;
+                color = source.Style2d.Selected.Color;
+            }
+            if (source.IsHovered)
+            {
+                radiu = source.Style2d.Hovered.Radiu;
+                color = source.Style2d.Hovered.Color;
+            }
+            radiu *= zoom;
+            float z = source.Position.Z;
+
+
+
+            //璁$畻姘存睜涓嬫柟鐭╁舰鐨勫洓涓《鐐圭浉瀵逛簬涓績鐐圭殑鍧愭爣
+            float left_b = source.Position.X - radiu * 1f;
+            float right_b = source.Position.X + radiu * 1f;
+            float bottom_b = source.Position.Y - radiu * 1.5f;
+            float top_b = source.Position.Y;
+
+            float left_t = source.Position.X - radiu * 2f;
+            float right_t = source.Position.X + radiu * 2f;
+            float bottom_t = source.Position.Y;
+            float top_t = source.Position.Y + radiu * 1.5f;
+
+            GL.Color3(color);
+
+            // 缁樺埗涓嬫柟鐭╁舰
+            GL.Begin(PrimitiveType.Quads);
+            GL.Vertex3(left_b, bottom_b, z);
+            GL.Vertex3(right_b, bottom_b, z);
+            GL.Vertex3(right_b, top_b, z);
+            GL.Vertex3(left_b, top_b, z);
+            GL.End();
+
+            // 缁樺埗姘存睜涓殑姘�
+            GL.Begin(PrimitiveType.Quads);
+            GL.Vertex3(left_t, bottom_t, z);
+            GL.Vertex3(right_t, bottom_t, z);
+            GL.Vertex3(right_t, top_t, z);
+            GL.Vertex3(left_t, top_t, z);
+            GL.End();
+        }
+
+
+    }
+}
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/05-network/Network2dExtensions.cs b/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/05-network/Network2dExtensions.cs
index f74559b..3350e05 100644
--- a/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/05-network/Network2dExtensions.cs
+++ b/Yw.WinFrmUI.Hydro.L3d.Core/02-helper/05-network/Network2dExtensions.cs
@@ -1,4 +1,6 @@
-锘縩amespace Yw.WinFrmUI.Hydro
+锘縰sing OpenTK.Graphics.ES20;
+
+namespace Yw.WinFrmUI.Hydro
 {
     /// <summary>
     /// 
@@ -8,7 +10,7 @@
         /// <summary>
         /// 缁樺埗2d
         /// </summary>
-        public static void Draw2d(this NetworkL3d nw)
+        public static void Draw2d(this NetworkL3d nw, float zoom)
         {
             if (nw == null)
             {
@@ -16,12 +18,28 @@
             }
             nw.Links.ForEach(x =>
             {
-                x.Draw2d();
+                if (x is PumpL3d pump)
+                {
+                    pump.Draw2d(zoom);
+                }
+                else
+                {
+                    x.Draw2d();
+                }
+
             });
 
             nw.Nodes.ForEach(x =>
             {
-                x.Draw2d();
+                if (x is SourceL3d source)
+                {
+                    source.Draw2d(zoom);
+                }
+                else
+                {
+                    x.Draw2d();
+                }
+
             });
         }
 
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2d.cs b/Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2d.cs
index 8dfd7a2..80c4b67 100644
--- a/Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2d.cs
+++ b/Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2d.cs
@@ -16,9 +16,6 @@
             InitializeGLEvents();
         }
 
-
-
-
         private NetworkL3d _nw = null;
         private OrthoViewer2dHelper _helper = null;
 
diff --git a/Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2dHelper.cs b/Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2dHelper.cs
index 91aa3b1..3ce7c79 100644
--- a/Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2dHelper.cs
+++ b/Yw.WinFrmUI.Hydro.L3d.Core/03-control/01-ortho/01-viewer2d/OrthoViewer2dHelper.cs
@@ -81,11 +81,16 @@
         private void InitialGLState()
         {
             GL.ClearColor(Color.Transparent); // 鑳屾櫙棰滆壊
-            GL.ShadeModel(ShadingModel.Smooth);
             GL.Enable(EnableCap.DepthTest);//娣卞害娴嬭瘯
             GL.DepthMask(true); // 鍏佽鍐欏叆娣卞害缂撳啿鍖�
             GL.Enable(EnableCap.PointSmooth);//鍚敤鐐瑰钩婊�
             GL.Enable(EnableCap.LineSmooth);//鍚敤绾垮钩婊�
+            GL.Enable(EnableCap.Multisample);// 鍚敤鍙嶉敮榻�
+            GL.ShadeModel(ShadingModel.Smooth);
+
+            // 璁剧疆娣峰悎妯″紡浠ユ敮鎸佸弽閿娇
+            GL.Enable(EnableCap.Blend);
+            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
             Resize();
         }
 
@@ -146,7 +151,7 @@
             var modelMatrix = _camera.ModelMatrix;
             GL.MultMatrix(ref modelMatrix);
 
-            _nw.Draw2d();
+            _nw.Draw2d(_camera.Zoom);
 
             _gl.SwapBuffers();
         }

--
Gitblit v1.9.3