| | |
| | | using Yw.WinFrmUI.Q3d; |
| | | |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using static Yw.WinFrmUI.Q3d.MapViewEnum; |
| | | using Yw.WinFrmUI.Q3d; |
| | | using Yw.WinFrmUI.Q3d; |
| | | using Yw.WinFrmUI.Q3d; |
| | | using static System.Net.Mime.MediaTypeNames; |
| | | using static System.Windows.Forms.AxHost; |
| | | using static System.Windows.Forms.LinkLabel; |
| | | using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button; |
| | | using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar; |
| | | using static Yw.WinFrmUI.Q3d.MapViewEnum; |
| | | using Cursor = System.Windows.Forms.Cursor; |
| | | using Yw.WinFrmUI.Q3d; |
| | | using Yw.WinFrmUI.Q3d; |
| | | |
| | | namespace Yw.WinFrmUI.Q3d |
| | | { |
| | |
| | | |
| | | 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) |
| | | { |
| | |
| | | this.Inited = true; |
| | | this.Status = DrawingStatus.Ready; |
| | | |
| | | |
| | | SetDefaultView(); |
| | | //TContainer TCCube = new TContainer(); |
| | | //TCCube.settings = new Settings(); |
| | | //TCCube.settings.network = new MapViewNetWork(); |
| | |
| | | public void Clear() |
| | | { |
| | | _Template = null; |
| | | MapCenter = PointF.Empty; |
| | | MapCenter = new PointF3D(0, 0, 0); |
| | | zoom = 1.0f; |
| | | Rotation = 0; |
| | | RotationF = 90; |
| | |
| | | //将RotationF.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; |
| | |
| | | { |
| | | p.X /= _Nodes.Count; |
| | | p.Y /= _Nodes.Count; |
| | | p.Z /= _Nodes.Count; |
| | | } |
| | | MapCenter = p; |
| | | } |
| | |
| | | { |
| | | _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) |
| | |
| | | Cursor = Cursors.Hand; |
| | | mapOption0 = mapOption.Copy(); |
| | | _isRotating = true; |
| | | //如果有锚点 |
| | | if (hoveredObjs.Count > 0 && hoveredObjs[0] is NodeViewModel node) |
| | | { |
| | | _OperaNode = node; |
| | | _HookPoint = MapToScreen(WorldPointToMapPoint(node)); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | 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; |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | _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); |
| | | |
| | | //将Rotation.ToString("0")通过RotationChanged传出 |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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; |
| | |
| | | return projectedPoints; |
| | | } |
| | | |
| | | public void SetSelectObj(List<string> ids) |
| | | { |
| | | //构造两个字典,一个是节点,一个是管道 |
| | | var dict_nodes = _Nodes.ToDictionary(o => o.ID); |
| | | var dict_links = _Links.ToDictionary(o => o.ID); |
| | | //遍历所有的id,找到对应的对象 |
| | | foreach (var id in ids) |
| | | { |
| | | if (dict_nodes.ContainsKey(id)) |
| | | { |
| | | dict_nodes[id].Selected = true; |
| | | selectedObjs.Add(dict_nodes[id]); |
| | | } |
| | | else if (dict_links.ContainsKey(id)) |
| | | { |
| | | dict_links[id].Selected = true; |
| | | selectedObjs.Add(dict_links[id]); |
| | | } |
| | | } |
| | | } |
| | | |
| | | bool _isSettingBackGroundPictur = false; |
| | | |
| | | |