public void Add(Polygon polygon) { polygon.Visible = IsRenderableVisible(polygon.ParentRenderable); m_polygons.Add(polygon); LastUpdate = System.DateTime.Now; m_oBounds.Union(polygon.GetGeographicBoundingBox()); }
public void Add(Polygon polygon) { if(polygon.ParentRenderable == null) Log.Write(Log.Levels.Error, "null null null"); polygon.Visible = IsRenderableVisible(polygon.ParentRenderable); m_polygons.Add(polygon); LastUpdate = System.DateTime.Now; }
private void drawPolygon(Polygon polygon, Graphics g, GeographicBoundingBox dstBB, Size imageSize) { if(polygon.innerBoundaries != null && polygon.innerBoundaries.Length > 0) { if(polygon.Fill) { using(SolidBrush brush = new SolidBrush(polygon.PolgonColor)) { g.FillPolygon(brush, getScreenPoints(polygon.outerBoundary.Points, 0, polygon.outerBoundary.Points.Length, dstBB, imageSize)); } } if(polygon.Outline) { using(Pen p = new Pen(polygon.OutlineColor, polygon.LineWidth)) { g.DrawPolygon(p, getScreenPoints(polygon.outerBoundary.Points, 0, polygon.outerBoundary.Points.Length, dstBB, imageSize)); } } if(polygon.Fill) { using(SolidBrush brush = new SolidBrush(System.Drawing.Color.Black)) { for(int i = 0; i < polygon.innerBoundaries.Length; i++) { g.FillPolygon(brush, getScreenPoints(polygon.innerBoundaries[i].Points, 0, polygon.innerBoundaries[i].Points.Length, dstBB, imageSize) ); } } } } else { if(polygon.Fill) { using(SolidBrush brush = new SolidBrush(polygon.PolgonColor)) { g.FillPolygon(brush, getScreenPoints(polygon.outerBoundary.Points, 0, polygon.outerBoundary.Points.Length, dstBB, imageSize)); } } if(polygon.Outline) { using(Pen p = new Pen(polygon.OutlineColor, polygon.LineWidth)) { g.DrawPolygon(p, getScreenPoints(polygon.outerBoundary.Points, 0, polygon.outerBoundary.Points.Length, dstBB, imageSize)); } } } }
public override void Dispose() { if(m_polygon != null) { m_polygon.Remove = true; m_polygon = null; } if(m_lineFeature != null) { for(int i = 0; i < m_lineFeature.Length; i++) { if(m_lineFeature[i] != null) m_lineFeature[i].Dispose(); } m_lineFeature = null; } }
private void UpdateVertices() { m_verticalExaggeration = World.Settings.VerticalExaggeration; if(m_altitudeMode == AltitudeMode.ClampedToGround) { if(m_polygon != null) { m_polygon.Remove = true; m_polygon = null; } m_polygon = new Polygon(); m_polygon.outerBoundary = m_outerRing; m_polygon.innerBoundaries = m_innerRings; m_polygon.PolgonColor = m_polygonColor; m_polygon.Fill = m_fill; m_polygon.ParentRenderable = this; this.World.ProjectedVectorRenderer.Add(m_polygon); if(m_vertices != null) m_vertices = null; if(m_lineFeature != null) { m_lineFeature[0].Dispose(); m_lineFeature = null; } return; } getTessellation(); if(m_extrude || m_outline) { m_lineFeature = new LineFeature[1 + (m_innerRings != null && m_innerRings.Length > 0 ? m_innerRings.Length : 0)]; Point3d[] linePoints = new Point3d[m_outerRing.Points.Length + 1]; for(int i = 0; i < m_outerRing.Points.Length; i++) { linePoints[i] = m_outerRing.Points[i]; } linePoints[linePoints.Length - 1] = m_outerRing.Points[0]; m_lineFeature[0] = new LineFeature(Name, World, linePoints, m_polygonColor); m_lineFeature[0].DistanceAboveSurface = m_distanceAboveSurface; m_lineFeature[0].MinimumDisplayAltitude = m_minimumDisplayAltitude; m_lineFeature[0].MaximumDisplayAltitude = m_maximumDisplayAltitude; m_lineFeature[0].AltitudeMode = AltitudeMode; m_lineFeature[0].Opacity = Opacity; m_lineFeature[0].Outline = m_outline; m_lineFeature[0].LineColor = m_outlineColor; m_lineFeature[0].Extrude = m_extrude; if(m_innerRings != null && m_innerRings.Length > 0) { for(int i = 0; i < m_innerRings.Length; i++) { Point3d[] innerPoints = new Point3d[m_innerRings[i].Points.Length + 1]; for(int j = 0; j < m_innerRings[i].Points.Length; j++) { innerPoints[j] = m_innerRings[i].Points[j]; } innerPoints[innerPoints.Length - 1] = m_innerRings[i].Points[0]; m_lineFeature[1 + i] = new LineFeature(Name, World, innerPoints, m_polygonColor); m_lineFeature[1 + i].DistanceAboveSurface = m_distanceAboveSurface; m_lineFeature[1 + i].MinimumDisplayAltitude = m_minimumDisplayAltitude; m_lineFeature[1 + i].MaximumDisplayAltitude = m_maximumDisplayAltitude; m_lineFeature[1 + i].AltitudeMode = AltitudeMode; m_lineFeature[1 + i].Opacity = Opacity; m_lineFeature[1 + i].Outline = m_outline; m_lineFeature[1 + i].LineColor = m_outlineColor; m_lineFeature[1 + i].Extrude = m_extrude; } } } else { if(m_lineFeature != null && m_lineFeature.Length > 0) { for(int i = 0; i < m_lineFeature.Length; i++) { if(m_lineFeature[i] != null) { m_lineFeature[i].Dispose(); m_lineFeature[i] = null; } } m_lineFeature = null; } } }
private static RenderableObject Construct(String strRelativeDirectory, KMLObject oSource, World oWorld, GeographicBoundingBox oBounds, ProjectedVectorRenderer oPVR, Icons oIcons) { if (oSource is KMLContainer) { KMLContainer oCastSource = oSource as KMLContainer; KMLRenderableObjectList result = new KMLRenderableObjectList(oCastSource.Name); if (oPVR == null) { oPVR = new ProjectedVectorRenderer("Polygons and LineStrings", oWorld); result.Add(oPVR); } if (oIcons == null) { oIcons = new Icons("Icons"); result.Add(oIcons); } for (int count = 0; count < oCastSource.Count; count++) { if (oCastSource[count].Visibility == true) { RenderableObject oLayer = Construct(strRelativeDirectory, oCastSource[count], oWorld, oBounds, oPVR, oIcons); if (oLayer != null) { result.Add(oLayer); } } } return result; } else if (oSource is KMLPlacemark) { KMLPlacemark oCastSource = oSource as KMLPlacemark; return Construct(strRelativeDirectory, oCastSource.Geometry, oWorld, oBounds, oPVR, oIcons); } else if (oSource is KMLMultiGeometry) { KMLMultiGeometry oCastSource = oSource as KMLMultiGeometry; KMLRenderableObjectList result = new KMLRenderableObjectList("MultiGeometry"); for (int count = 0; count < oCastSource.Count; count++) { RenderableObject oLayer = Construct(strRelativeDirectory, oCastSource[count], oWorld, oBounds, oPVR, oIcons); if (oLayer != null) { result.Add(oLayer); } } return result; } else if (oSource is KMLPoint) { KMLPoint oCastSource = oSource as KMLPoint; KMLIcon result = new KMLIcon(oCastSource.Owner.Name, oCastSource.Coordinates.Latitude, oCastSource.Coordinates.Longitude, oCastSource.Coordinates.Altitude); result.DrawGroundStick = oCastSource.Extrude; result.Rotation = WorldWind.Angle.FromDegrees(oCastSource.Style.NormalStyle.IconStyle.Heading); result.IsRotated = oCastSource.Style.NormalStyle.IconStyle.Heading != 0.0f; result.NormalColor = oCastSource.Style.NormalStyle.LabelStyle.Color; result.HotColor = oCastSource.Style.HighlightStyle.LabelStyle.Color; oIcons.Add(result); oBounds.Union(oCastSource.Coordinates.Longitude, oCastSource.Coordinates.Latitude, oCastSource.Coordinates.Altitude); return null; } else if (oSource is KMLPolygon) { KMLPolygon oCastSource = oSource as KMLPolygon; Polygon oTool = new Polygon(); oTool.outerBoundary = new WorldWind.LinearRing(GetPoints(oCastSource.OuterBoundary)); oTool.innerBoundaries = GetInnerBoundaries(oCastSource); oTool.PolgonColor = oCastSource.Style.NormalStyle.PolyStyle.Color; oTool.Fill = oCastSource.Style.NormalStyle.PolyStyle.Fill; oTool.LineWidth = oCastSource.Style.NormalStyle.LineStyle.Width; oTool.Outline = oCastSource.Style.NormalStyle.PolyStyle.Outline; oTool.OutlineColor = oCastSource.Style.NormalStyle.LineStyle.Color; oPVR.Add(oTool); oBounds.Union(oTool.GetGeographicBoundingBox()); return null; } else if (oSource is KMLLineString) { KMLLineString oCastSource = oSource as KMLLineString; LineString oTool = new LineString(); oTool.Coordinates = GetPoints(oCastSource); oTool.Color = oCastSource.Style.NormalStyle.LineStyle.Color; oTool.LineWidth = oCastSource.Style.NormalStyle.LineStyle.Width; oPVR.Add(oTool); oBounds.Union(oTool.GetGeographicBoundingBox()); return null; } else if (oSource is KMLGroundOverlay) { KMLGroundOverlay oCastSource = oSource as KMLGroundOverlay; KMLGroundOverlayRenderable result = new KMLGroundOverlayRenderable(oCastSource, strRelativeDirectory); oBounds.Union(new GeographicBoundingBox(oCastSource.LatLonBox.North, oCastSource.LatLonBox.South, oCastSource.LatLonBox.West, oCastSource.LatLonBox.East)); return result; } else { return null; } }