| | |
| | | using Hydro.MapView; |
| | | using Hydro.MapView.Common; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Drawing; |
| | |
| | | using (var pen = new Pen(Color.Black, 1 * r)) |
| | | { |
| | | pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; |
| | | bufferG.DrawLine(pen, WorldPointToMapPoint(_select_junction1), _MousePosition); |
| | | if (mapOption.IsOrtho) |
| | | { |
| | | var wPos = GetZZWorldPoint(_select_junction1.Position3D, _MousePosition, new Vector3(1, 1, 0)); |
| | | //getPointAndHeight(e, _select_junction1, out p, out z); |
| | | var mapPos= WorldPointToMapPoint(wPos); |
| | | bufferG.DrawLine(pen, WorldPointToMapPoint(_select_junction1), mapPos); |
| | | } |
| | | else |
| | | { |
| | | bufferG.DrawLine(pen, WorldPointToMapPoint(_select_junction1), _MousePosition); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | return new PointF3D(0, 0, 0); |
| | | var p2=MapPointToWorldPoint(mousePosition, position3D.Z); |
| | | var vector = new Vector2(p2.X - position3D.X, p2.Y - position3D.Y); |
| | | //判断二维向量vector在第几象限,距离哪个轴最近 |
| | | var x = vector.X; |
| | | var y = vector.Y; |
| | | var x1 = Math.Abs(x); |
| | | var y1 = Math.Abs(y); |
| | | if (x1 > y1) |
| | | { |
| | | if (x > 0) |
| | | { |
| | | //第一象限 |
| | | return new PointF3D(position3D.X + Math.Abs(x), position3D.Y, position3D.Z); |
| | | } |
| | | else |
| | | { |
| | | //第三象限 |
| | | return new PointF3D(position3D.X - Math.Abs(x), position3D.Y, position3D.Z); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (y > 0) |
| | | { |
| | | //第二象限 |
| | | return new PointF3D(position3D.X, position3D.Y + Math.Abs(y), position3D.Z); |
| | | } |
| | | else |
| | | { |
| | | //第四象限 |
| | | return new PointF3D(position3D.X, position3D.Y - Math.Abs(y), position3D.Z); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |