using GeoScene.Globe; using GeoScene.Data; using System.Drawing; namespace Cyberpipe { class ClassAddMakerToGlobel { public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { if (pntIntersect1 == null || pntIntersect2 == null) return; GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); GSOPoint3ds point3ds = new GSOPoint3ds(); point3ds.Add(pntIntersect1); point3ds.Add(pntIntersect2); disline.AddPart(point3ds); GSOGeoMarker dismarker = new GSOGeoMarker(); GSOFeature marker = null; GSOFeature line = null; createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); line.Visible = marker.Visible = markerVisible; globeControl1.Globe.MemoryLayer.AddFeature(line); globeControl1.Globe.MemoryLayer.AddFeature(marker); globeControl2.Globe.MemoryLayer.AddFeature(line); globeControl2.Globe.MemoryLayer.AddFeature(marker); } public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, double distance, bool markerVisible, GSOGlobeControl globeControl, string label) { if (pntIntersect1 == null || pntIntersect2 == null) return; GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); GSOPoint3ds point3ds = new GSOPoint3ds(); point3ds.Add(pntIntersect1); point3ds.Add(pntIntersect2); disline.AddPart(point3ds); GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); style.LineColor = Color.GreenYellow; style.LineWidth = 3; style.VertexVisible = true; disline.Style = style; disline.AltitudeMode = EnumAltitudeMode.Absolute; GSOFeature line = new GSOFeature(); line.Geometry = disline; GSOGeoMarker dismarker = new GSOGeoMarker(); dismarker.X = pntIntersect1.X; dismarker.Y = pntIntersect1.Y; dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; dismarker.Text = label + distance.ToString("0.00") + "米"; dismarker.AltitudeMode = EnumAltitudeMode.Absolute; GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); GSOTextStyle styleText = new GSOTextStyle(); styleText.IsSizeFixed = true; styleText.ForeColor = Color.White; styleText.FontSize = 20; styleMarker.TextStyle = styleText; dismarker.Style = styleMarker; GSOFeature marker = new GSOFeature(); marker.Geometry = dismarker; line.Visible = marker.Visible = markerVisible; globeControl.Globe.MemoryLayer.AddFeature(line); globeControl.Globe.MemoryLayer.AddFeature(marker); } public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) { GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 style.LineColor = Color.Red; style.LineWidth = 5; //设置线的宽度为5 style.VertexVisible = true; //显示线的节点 disline.Style = style; //把风格添加到线上 disline.AltitudeMode = EnumAltitudeMode.Absolute; line = new GSOFeature(); line.Geometry = disline; dismarker.X = pntIntersect1.X; dismarker.Y = pntIntersect1.Y; dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; dismarker.Text = label + distance.ToString("0.00") + "米"; dismarker.AltitudeMode = EnumAltitudeMode.Absolute; GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); GSOTextStyle styleText = new GSOTextStyle(); styleText.IsSizeFixed = true; styleText.ForeColor = Color.Red; styleText.FontSize = 20; styleMarker.TextStyle = styleText; dismarker.Style = styleMarker; marker = new GSOFeature(); marker.Geometry = dismarker; } } }