| | |
| | | |
| | | public SGWorld74 SG; |
| | | |
| | | private bool isAngle; |
| | | |
| | | private int angleCount; |
| | | |
| | | private double angleSize; |
| | | |
| | | private ITerrainLabel74 angleLabel; |
| | | |
| | | private ITerrainPolyline74 angleLine; |
| | | |
| | | private string angleGroupName = "角量算"; |
| | | |
| | | public FrmWin() |
| | | { |
| | | InitializeComponent(); |
| | |
| | | } |
| | | |
| | | #region 角量算+空间统计+空间分析+osgblab |
| | | public void AngleMeasurement() |
| | | private void AngleMeasurement() |
| | | { |
| | | // |
| | | if (isAngle) |
| | | { |
| | | DeleteGroup(angleGroupName); |
| | | RmAngleEvent(); |
| | | isAngle = false; |
| | | return; |
| | | } |
| | | |
| | | public void SpaceStatistics() |
| | | isAngle = true; |
| | | AddAngleEvent(); |
| | | } |
| | | |
| | | private string GetGroupId(string groupName) |
| | | { |
| | | string gid = SG.ProjectTree.FindItem(groupName); |
| | | if (!string.IsNullOrEmpty(gid)) return gid; |
| | | |
| | | return SG.ProjectTree.CreateLockedGroup(groupName); |
| | | } |
| | | |
| | | private void DeleteGroup(string groupName) |
| | | { |
| | | try |
| | | { |
| | | string gid = SG.ProjectTree.FindItem(groupName); |
| | | if (!string.IsNullOrEmpty(gid)) |
| | | { |
| | | SG.ProjectTree.DeleteItem(gid); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); |
| | | } |
| | | } |
| | | |
| | | private void AddAngleEvent() |
| | | { |
| | | RmAngleEvent(); |
| | | |
| | | SG.OnFrame += Angle_OnFrame; |
| | | SG.OnLButtonDown += Angle_OnLButtonDown; |
| | | SG.OnRButtonUp += Angle_OnRButtonUp; |
| | | SG.Window.SetInputMode(MouseInputMode.MI_COM_CLIENT); |
| | | } |
| | | |
| | | private void RmAngleEvent() |
| | | { |
| | | SG.OnFrame -= Angle_OnFrame; |
| | | SG.OnLButtonDown -= Angle_OnLButtonDown; |
| | | SG.OnRButtonUp -= Angle_OnRButtonUp; |
| | | SG.Window.SetInputMode(MouseInputMode.MI_FREE_FLIGHT); |
| | | } |
| | | |
| | | void Angle_OnFrame() |
| | | { |
| | | if (null == angleLine) return; |
| | | |
| | | try |
| | | { |
| | | var mouseInfo = SG.Window.GetMouseInfo(); |
| | | var CursorCoord = SG.Window.PixelToWorld(mouseInfo.X, mouseInfo.Y, WorldPointType.WPT_DEFAULT); |
| | | if (CursorCoord == null) return; |
| | | |
| | | ILineString line = (ILineString)(angleLine.Geometry); |
| | | IPoint p = (IPoint)line.Points[line.Points.Count - 1]; |
| | | p.X = CursorCoord.Position.X; |
| | | p.Y = CursorCoord.Position.Y; |
| | | p.Z = 0; |
| | | |
| | | if (angleCount % 3 == 2) |
| | | { |
| | | IPoint firstPoint = (IPoint)line.Points[line.Points.Count - 3]; |
| | | IPoint secondPoint = (IPoint)line.Points[line.Points.Count - 2]; |
| | | IPoint nowPoint = (IPoint)line.Points[line.Points.Count - 1]; |
| | | var firstPosition = SG.Creator.CreatePosition(firstPoint.X, firstPoint.Y); |
| | | var secondPosition = SG.Creator.CreatePosition(secondPoint.X, secondPoint.Y); |
| | | var nowPosition = SG.Creator.CreatePosition(nowPoint.X, nowPoint.Y); |
| | | |
| | | nowPosition = SG.CoordServices.GetAimingAngles(nowPosition, secondPosition); |
| | | secondPosition = SG.CoordServices.GetAimingAngles(firstPosition, secondPosition); |
| | | if (secondPosition.Yaw > nowPosition.Yaw) |
| | | { |
| | | angleSize = secondPosition.Yaw - nowPosition.Yaw; |
| | | if (angleSize > 180) angleSize = 360 - secondPosition.Yaw + nowPosition.Yaw; |
| | | } |
| | | else |
| | | { |
| | | angleSize = nowPosition.Yaw - secondPosition.Yaw; |
| | | if (angleSize > 180) angleSize = 360 + secondPosition.Yaw - nowPosition.Yaw; |
| | | } |
| | | angleSize = Math.Round(angleSize, 2); |
| | | angleLabel.Text = angleSize.ToString() + "°"; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); |
| | | } |
| | | } |
| | | |
| | | bool Angle_OnLButtonDown(int Flags, int X, int Y) |
| | | { |
| | | try |
| | | { |
| | | var CursorCoord = SG.Window.PixelToWorld(X, Y, WorldPointType.WPT_DEFAULT); |
| | | if (CursorCoord == null) return false; |
| | | |
| | | var gid = GetGroupId(angleGroupName); |
| | | if (angleLine == null) |
| | | { |
| | | IList<double> lineVertex = new List<double>(); |
| | | lineVertex.Add(CursorCoord.Position.X); |
| | | lineVertex.Add(CursorCoord.Position.Y); |
| | | lineVertex.Add(0); |
| | | lineVertex.Add(CursorCoord.Position.X); |
| | | lineVertex.Add(CursorCoord.Position.Y); |
| | | lineVertex.Add(0); |
| | | |
| | | double[] px = new double[lineVertex.Count]; |
| | | lineVertex.CopyTo(px, 0); |
| | | var myGeometry = SG.Creator.GeometryCreator.CreateLineStringGeometry(px); |
| | | |
| | | angleLine = SG.Creator.CreatePolyline(myGeometry, SG.Creator.CreateColor(255, 255, 0, 255), AltitudeTypeCode.ATC_TERRAIN_RELATIVE, gid, angleCount.ToString()); |
| | | angleLine.LineStyle.Width = -2; |
| | | angleLine.Geometry.StartEdit(); |
| | | angleCount++; |
| | | |
| | | return true; |
| | | } |
| | | |
| | | if (angleCount % 3 == 1) |
| | | { |
| | | angleLabel = SG.Creator.CreateLabel(CursorCoord.Position, angleSize.ToString(), "", null, gid, angleCount.ToString()); |
| | | var LableColor = SG.Creator.CreateColor(); |
| | | LableColor.FromHTMLColor("#FFFF00"); |
| | | LableColor.SetAlpha(0.6); |
| | | angleLabel.Style.TextColor = LableColor; |
| | | angleLabel.Style.Bold = true; |
| | | angleLabel.Style.FontName = "黑体"; |
| | | angleLabel.Style.FontSize = 12; |
| | | // angleLabel.Style.LineToGround = true; |
| | | angleLabel.Style.LineToGroundType = LineType.LINE_TYPE_TO_GROUND; |
| | | angleLabel.Style.Scale = 5000; |
| | | } |
| | | |
| | | if (angleCount % 3 == 2) angleLabel.Text = angleSize.ToString() + "°"; |
| | | angleCount++; |
| | | |
| | | ILineString line = (ILineString)(angleLine.Geometry); |
| | | IPoint p = (IPoint)line.Points[line.Points.Count - 1]; |
| | | p.X = CursorCoord.Position.X; ; |
| | | p.Y = CursorCoord.Position.Y; |
| | | p.Z = 0; |
| | | line.Points.AddPoint(CursorCoord.Position.X, CursorCoord.Position.Y, 0); |
| | | if (angleCount == 3) |
| | | { |
| | | angleSize = 0; |
| | | angleCount = 0; |
| | | angleLine = null; |
| | | angleLabel = null; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.Message + "\r\n" + ex.StackTrace); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | bool Angle_OnRButtonUp(int Flags, int X, int Y) |
| | | { |
| | | DeleteGroup(angleGroupName); |
| | | RmAngleEvent(); |
| | | angleCount = 0; |
| | | angleSize = 0; |
| | | isAngle = false; |
| | | |
| | | return true; |
| | | } |
| | | |
| | | private void SpaceStatistics() |
| | | { |
| | | // |
| | | } |
| | |
| | | this.ShowHtml("空间分析", mainUrl + @"\Resources\SpatialQuery\SpatialQuery.html", 20, 20, 420, 285); |
| | | } |
| | | |
| | | public void InvokeOsgbLab() |
| | | private void InvokeOsgbLab() |
| | | { |
| | | // |
| | | } |