From 46e3091f9cdefc7e2ffbc69bcb9c39650b1c0587 Mon Sep 17 00:00:00 2001 From: cloudflight <cloudflight@126.com> Date: 星期六, 12 十月 2024 03:19:57 +0800 Subject: [PATCH] 1、修改用户输入的喷头流量系数为K系数,自动转换为EPA中的射流系数 --- WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/Map/Drawer.cs | 59 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 44 insertions(+), 15 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/Map/Drawer.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/Map/Drawer.cs index 3af7cbe..23b1384 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/Map/Drawer.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Q3d.Core/Map/Drawer.cs @@ -47,12 +47,24 @@ InitializeComponent(); this.DoubleBuffered = true; - MapCenter = PointF.Empty; + MapCenter =new PointF3D(0, 0, 0); zoom = 1.0f; SetStyle(ControlStyles.SupportsTransparentBackColor, true); BackColor = Color.Transparent; + + } + public void SetDefaultView() + { + mapOption0 = mapOption.Copy(); + + InitCenter(); + RotationF = 45; + Rotation = -45; + MapObjectExtensions.AddCommand(mapOption, "Map", mapOption0, mapOption); + + SetMapInvalidate(); } public void SetEditMode(bool isEditMode) { @@ -82,7 +94,7 @@ this.Inited = true; this.Status = DrawingStatus.Ready; - + SetDefaultView(); //TContainer TCCube = new TContainer(); //TCCube.settings = new Settings(); //TCCube.settings.network = new MapViewNetWork(); @@ -170,7 +182,7 @@ public void Clear() { _Template = null; - MapCenter = PointF.Empty; + MapCenter = new PointF3D(0, 0, 0); zoom = 1.0f; Rotation = 0; RotationF = 90; @@ -213,19 +225,21 @@ //灏哛otationF.ToString("0")閫氳繃RotationFChanged浼犲嚭 RotationFChanged?.Invoke(this, RotationF.ToString("0")); + SetDefaultView(); } private void InitCenter() { //MapCenter - var p = PointF.Empty; + var p = new PointF3D(0, 0, 0); float x0 = 99999999999f, y0 = 99999999999f, x1 = -99999999999f, y1 = -99999999999f; foreach (NodeViewModel junction in _Nodes) { p.X += (float)junction.X; p.Y += (float)junction.Y; + p.Z += (float)junction.Z; if (x0 > junction.X) x0 = junction.X; if (y0 > junction.Y) y0 = junction.Y; if (x1 < junction.X) x1 = junction.X; @@ -246,6 +260,7 @@ { p.X /= _Nodes.Count; p.Y /= _Nodes.Count; + p.Z /= _Nodes.Count; } MapCenter = p; } @@ -411,7 +426,8 @@ { _mouseState = MouseState.鏃�; DragStartPos = ScreenToMap(new PointF(e.X, e.Y)); - BackGroudPicLeftPos = MapPointToWorldPoint(ScreenToMap(new PointF(e.X, e.Y)), _Template.BackGroundElev); + var p3d = MapPointToWorldPoint(ScreenToMap(new PointF(e.X, e.Y)), _Template.BackGroundElev); + BackGroudPicLeftPos = new PointF(p3d.X, p3d.Y); _isSettingBackGroundPictur = true; } else if (e.Button == MouseButtons.Right) @@ -424,6 +440,12 @@ Cursor = Cursors.Hand; mapOption0 = mapOption.Copy(); _isRotating = true; + //濡傛灉鏈夐敋鐐� + if (hoveredObjs.Count > 0 && hoveredObjs[0] is NodeViewModel node) + { + _OperaNode = node; + _HookPoint = MapToScreen(WorldPointToMapPoint(node)); + } } } @@ -475,12 +497,12 @@ } else if (_isPanning) { - var vector = GetRotateVector(new PointF(e.X, e.Y), new PointF(_lastMouseX, _lastMouseY)); - MapCenter = new PointF(MapCenter.X - vector.X / Zoom.X, MapCenter.Y - vector.Y / Zoom.Y); + var vector = GetWorldVectorByScreenPoints(new PointF(e.X, e.Y), new PointF(_lastMouseX, _lastMouseY)); + MapCenter = new PointF3D(MapCenter.X - vector.X, MapCenter.Y - vector.Y, MapCenter.Z - vector.Z); //灏�$"{MapCenter.X.ToString("0.00")},{MapCenter.Y.ToString("0.00")}"閫氳繃CenterChanged浼犲嚭 - CenterChanged?.Invoke(this, $"{MapCenter.X.ToString("0.00")},{MapCenter.Y.ToString("0.00")}"); + CenterChanged?.Invoke(this, $"{MapCenter.X.ToString("0.00")},{MapCenter.Y.ToString("0.00")},{MapCenter.Z.ToString("0.00")}"); needInvalidate = true; } @@ -630,7 +652,8 @@ if /*璁剧疆鑳屾櫙*/(e.Button == MouseButtons.Left && _isSettingBackGroundPictur) { _Template.BackGroundPoint1 = BackGroudPicLeftPos; - _Template.BackGroundPoint2 = MapPointToWorldPoint(mousePosition, _Template.BackGroundElev); + var p3d = MapPointToWorldPoint(mousePosition, _Template.BackGroundElev); + _Template.BackGroundPoint2 = new PointF(p3d.X, p3d.Y); _isSettingBackGroundPictur = false; mapOption.isShowPic = true; @@ -874,6 +897,9 @@ _isRotating = false; this.Cursor = _lastCursor; if (recordView) MapObjectExtensions.AddCommand(mapOption, "Map", mapOption0, mapOption); + _OperaNode = null; + _HookPoint = new PointF(-1, -1); + MapCenter0 = MapCenter; mousePosition = new PointF(0, 0); //灏哛otation.ToString("0")閫氳繃RotationChanged浼犲嚭 @@ -887,7 +913,8 @@ z = 0; if (RotationF != 0) { - p = MapPointToWorldPoint(ScreenToMap(new PointF(e.X, e.Y), z)); + var p3d = MapPointToWorldPoint(ScreenToMap(new PointF(e.X, e.Y), z)); + p = new PointF(p3d.X, p3d.Y); } else @@ -902,7 +929,8 @@ z = j.Z; if (RotationF != 0) { - p = MapPointToWorldPoint(ScreenToMap(new PointF(e.X, e.Y), j.Z), j.Z); + var p3d = MapPointToWorldPoint(ScreenToMap(new PointF(e.X, e.Y), j.Z), j.Z); + p = new PointF(p3d.X, p3d.Y); } else @@ -1682,10 +1710,11 @@ position = obj.Position; PointF currentPos = MapToScreen(WorldPointToMapPoint(position, obj.Z)); PointF centerScreen = new PointF(this.Width / 2, this.Height / 2); - var vector = GetRotateVector(centerScreen, currentPos); - MapCenter = new PointF( - MapCenter.X - vector.X / Zoom.X, - MapCenter.Y - vector.Y / Zoom.Y); + var vector = GetWorldVectorByScreenPoints(centerScreen, currentPos); + MapCenter = new PointF3D( + MapCenter.X - vector.X, + MapCenter.Y - vector.Y, + MapCenter.Z - vector.Z); } bool ctrlPressed = false; -- Gitblit v1.9.3