From 0329c48a57f33a4c94e44c5e4d3d3c116184986f Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期二, 22 四月 2025 15:51:43 +0800
Subject: [PATCH] 优化HelixToolkit的方法,增加水流方向功能,进一步封装Winform控件

---
 Yw.WpfUI.Hydro.L3d.Core/03-logical/08-manager/LogicalManager.cs |  196 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 188 insertions(+), 8 deletions(-)

diff --git a/Yw.WpfUI.Hydro.L3d.Core/03-logical/08-manager/LogicalManager.cs b/Yw.WpfUI.Hydro.L3d.Core/03-logical/08-manager/LogicalManager.cs
index d96e1d0..a580a1c 100644
--- a/Yw.WpfUI.Hydro.L3d.Core/03-logical/08-manager/LogicalManager.cs
+++ b/Yw.WpfUI.Hydro.L3d.Core/03-logical/08-manager/LogicalManager.cs
@@ -1,6 +1,4 @@
-锘縰sing System.Windows.Controls;
-
-namespace Yw.WpfUI.Hydro
+锘縩amespace Yw.WpfUI.Hydro
 {
     /// <summary>
     /// 鎶借薄绠$悊鍣�
@@ -20,8 +18,9 @@
             _highlightHelper = new LogicalHighlightHelper(_viewport);
             _selectionHelper = new LogicalSelectionHelper(_viewport);
             _zoomHelper = new LogicalZoomHelper(_viewport);
-            _billboardTextHelper = new LogicalBillboardLeadLabelHelper(_viewport);
+            _billboardTextHelper = new LogicalBillboardTextHelper(_viewport);
             _cameraHelper = new LogicalCameraHelper(_viewport);
+            _flowDirectionHelper = new LogicalFlowDirectionHelper(_viewport, _materialHelper);
         }
 
         #region 浜嬩欢闆嗗悎
@@ -46,8 +45,9 @@
         protected readonly LogicalHighlightHelper _highlightHelper = null;//楂樹寒杈呭姪绫�
         protected readonly LogicalSelectionHelper _selectionHelper = null;//閫夋嫨杈呭姪绫�
         protected readonly LogicalZoomHelper _zoomHelper = null;//缂╂斁杈呭姪绫�
-        protected readonly LogicalBillboardLeadLabelHelper _billboardTextHelper = null;//鍏憡鐗堟枃瀛楄緟鍔╃被
+        protected readonly LogicalBillboardTextHelper _billboardTextHelper = null;//鍏憡鐗堟枃瀛楄緟鍔╃被
         protected readonly LogicalCameraHelper _cameraHelper = null;//鐩告満杈呭姪绫�
+        protected readonly LogicalFlowDirectionHelper _flowDirectionHelper = null;//姘存祦鏂瑰悜杈呭姪绫�
 
         #endregion
 
@@ -436,6 +436,45 @@
 
         #endregion
 
+        #region 蹇嵎鏂规硶
+
+        //鑾峰彇Visual3D
+        protected virtual LogicalVisual3D GetVisual3D(string Id)
+        {
+            if (!Initialized)
+            {
+                return default;
+            }
+            var id = Id?.Trim();
+            if (string.IsNullOrEmpty(id))
+            {
+                return default;
+            }
+            if (_allVisualL3dDict.ContainsKey(id))
+            {
+                var visual = _allVisualL3dDict[Id];
+                if (_allVisualLogicalDict.ContainsKey(visual))
+                {
+                    var visual3d = _allVisualLogicalDict[visual];
+                    return visual3d;
+                }
+            }
+            return default;
+        }
+
+        //鑾峰彇Visual3D
+        protected virtual List<LogicalVisual3D> GetVisual3D(List<string> Ids)
+        {
+            if (!Initialized)
+            {
+                return default;
+            }
+            var list = Ids?.Select(x => GetVisual3D(x)).Where(x => x != null).ToList();
+            return list;
+        }
+
+        #endregion
+
         #region 瑙嗚
 
         /// <summary>
@@ -710,12 +749,110 @@
 
         #endregion
 
+        #region 缂╂斁
+
+        /// <summary>
+        /// 缂╂斁鑷冲彲瑙佹瀯浠�
+        /// </summary>
+        public virtual void ZoomToVisual(string Id)
+        {
+            if (!Initialized)
+            {
+                return;
+            }
+            var visual3d = GetVisual3D(Id);
+            if (visual3d != null)
+            {
+                _zoomHelper.ZoomToVisual(visual3d);
+            }
+        }
+
+        /// <summary>
+        /// 缂╂斁鑷冲彲瑙佹瀯浠�
+        /// </summary>
+        public virtual void ZoomToVisual(List<string> Ids)
+        {
+            if (!Initialized)
+            {
+                return;
+            }
+            var visual3ds = GetVisual3D(Ids);
+            if (visual3ds != null && visual3ds.Count > 0)
+            {
+                _zoomHelper.ZoomToVisual(visual3ds);
+            }
+        }
+
+        #endregion
+
+        #region 閫夋嫨
+
+        /// <summary>
+        /// 閫夋嫨鍙鏋勪欢
+        /// </summary>
+        public virtual void SelectVisual(string Id)
+        {
+            if (!Initialized)
+            {
+                return;
+            }
+            var visual3d = GetVisual3D(Id);
+            _selectionHelper.SelectVisual(visual3d);
+        }
+
+        /// <summary>
+        /// 閫夋嫨鍙鏋勪欢
+        /// </summary>
+        public virtual void SelectVisual(List<string> Ids)
+        {
+            if (!Initialized)
+            {
+                return;
+            }
+            var visual3ds = GetVisual3D(Ids);
+            _selectionHelper.SelectVisual(visual3ds);
+        }
+
+        #endregion
+
+        #region 缂╂斁骞堕�夋嫨
+
+        /// <summary>
+        /// 缂╂斁骞堕�夋嫨鍙鏋勪欢
+        /// </summary>
+        public virtual void ZoomAndSelectVisual(string Id)
+        {
+            if (!Initialized)
+            {
+                return;
+            }
+            var visual3d = GetVisual3D(Id);
+            _zoomHelper.ZoomToVisual(visual3d);
+            _selectionHelper.SelectVisual(visual3d);
+        }
+
+        /// <summary>
+        /// 缂╂斁骞堕�夋嫨鍙鏋勪欢
+        /// </summary>
+        public virtual void ZoomAndSelectVisual(List<string> Ids)
+        {
+            if (!Initialized)
+            {
+                return;
+            }
+            var visual3ds = GetVisual3D(Ids);
+            _zoomHelper.ZoomToVisual(visual3ds);
+            _selectionHelper.SelectVisual(visual3ds);
+        }
+
+        #endregion
+
         #region 鍏憡鏉挎枃鏈�
 
         /// <summary>
         /// 璁剧疆鍏憡鏉挎枃鏈�
         /// </summary>
-        public virtual void SetBillboardText(List<LogicalTextL3d> items)
+        public virtual void SetBillboardText(List<TextL3d> items)
         {
             if (!Initialized)
             {
@@ -727,7 +864,7 @@
         /// <summary>
         /// 鏇存柊鍏憡鏉挎枃鏈�
         /// </summary>
-        public virtual void UpdateBillboardText(LogicalTextL3d item)
+        public virtual void UpdateBillboardText(TextL3d item)
         {
             if (!Initialized)
             {
@@ -739,7 +876,7 @@
         /// <summary>
         /// 鏇存柊鍏憡鏉挎枃鏈�
         /// </summary>
-        public virtual void UpdateBillboardText(List<LogicalTextL3d> items)
+        public virtual void UpdateBillboardText(List<TextL3d> items)
         {
             if (!Initialized)
             {
@@ -791,7 +928,50 @@
 
         #endregion
 
+        #region 姘存祦鏂瑰悜
 
+        /// <summary>
+        /// 鏄剧ず姘存祦鏂瑰悜
+        /// </summary>
+        public void ShowFlowDirection()
+        {
+            var allLinkList = _allVisualLogicalDict.Values.Where(x => x is LogicalLink3D).Select(x => x as LogicalLink3D).ToList();
+            _flowDirectionHelper.Set(allLinkList);
+        }
+
+        /// <summary>
+        /// 璁剧疆姘存祦鏂瑰悜
+        /// </summary>
+        public void SetFlowDirection(List<FlowDirectionL3d> list)
+        {
+            var dict = new Dictionary<LogicalLink3D, bool>();
+            list?.ForEach(x =>
+            {
+                if (_allVisualL3dDict.ContainsKey(x.Id))
+                {
+                    var visual = _allVisualL3dDict[x.Id];
+                    if (_allVisualLogicalDict.ContainsKey(visual))
+                    {
+                        var visual3d = _allVisualLogicalDict[visual];
+                        if (visual3d is LogicalLink3D link3d)
+                        {
+                            dict.Add(link3d, x.Positive);
+                        }
+                    }
+                }
+            });
+            _flowDirectionHelper.Set(dict);
+        }
+
+        /// <summary>
+        /// 娓呴櫎姘存祦鏂瑰悜
+        /// </summary>
+        public void ClearFlowDirection()
+        {
+            _flowDirectionHelper.Clear();
+        }
+
+        #endregion
 
 
     }

--
Gitblit v1.9.3