private void checkBoxUseOutlineStyle_CheckedChanged(object sender, EventArgs e) { bool bChecked = checkBoxUseOutlineStyle.Checked; buttonSetLineStyle.Enabled = bChecked; GSOSimplePolygonStyle3D geoStyle3d = m_Style as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { if (!bChecked) { // 清除自定义的轮廓线风格 geoStyle3d.OutlineStyle = null; } else { if (geoStyle3d.OutlineStyle == null) { // 如果不存在就创建一个新的 geoStyle3d.OutlineStyle = new GSOSimpleLineStyle3D(); } } if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } }
private void SetControlsByStyle(GSOStyle style) { GSOSimplePolygonStyle3D geoStyle3d = style as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { // 这句要写到前面,不然下面Checked的时候要检查 pictureBoxFillColor.BackColor = geoStyle3d.FillColor; numericUpDownFillOpaque.Value = geoStyle3d.FillColor.A; checkBoxFill.Checked = geoStyle3d.Fill; checkBoxOutline.Checked = geoStyle3d.OutLineVisible; if (geoStyle3d.OutlineStyle != null) { checkBoxUseOutlineStyle.Checked = true; } else { checkBoxUseOutlineStyle.Checked = false; } checkBoxUseStyle.Checked = true; } else { checkBoxUseStyle.Checked = false; } CheckControlsEnable(checkBoxUseStyle.Checked); }
private void ShowWater() { if (m_WaterFeature == null || m_WaterFeature.IsDeleted) { m_dBaseAlt = m_pntMinAlt.Z; GSOGeoWater geoWater = m_polygon3D.ConvertToGeoWater(); GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); if (checkBoxExtrude.Checked) { extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; } else { extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeNone; } extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; extrudeStyle.TailPartVisible = false; GSOSimplePolygonStyle3D polygonStyle = new GSOSimplePolygonStyle3D(); polygonStyle.FillColor = Color.FromArgb(200, 0, 0, 255); extrudeStyle.BodyStyle = polygonStyle; geoWater.ExtrudeStyle = extrudeStyle; geoWater.AltitudeMode = EnumAltitudeMode.Absolute; geoWater.SetAltitude(m_dBaseAlt); geoWater.ReflectSky = false; geoWater.WaveWidth = 0.1; geoWater.Play(); m_WaterFeature = new GSOFeature(); m_WaterFeature.Geometry = geoWater; m_globe.MemoryLayer.AddFeature(m_WaterFeature); m_globe.Refresh(); trackBarAlt.Maximum = (int)m_pntMaxAlt.Z; trackBarAlt.Minimum = (int)m_pntMinAlt.Z; trackBarAlt.Value = trackBarAlt.Minimum; textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); } else { GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; geoWater.SetAltitude(m_dBaseAlt); m_globe.Refresh(); trackBarAlt.Maximum = (int)m_pntMaxAlt.Z; trackBarAlt.Minimum = (int)m_pntMinAlt.Z; } }
private void buttonAnalyse_Click(object sender, EventArgs e) { if (globeControl1.Globe != null && m_polygon3D != null) { double dAlt = Convert.ToDouble(textBoxDestAlt.Text); //交给系统处理,传入值为面,高度,返回为挖的高度,填的高度,挖的区域,填的区域,全部的面积,最高点,最低点,最后两项默认false,0 globeControl1.Globe.Analysis3D.DigFillAnalyse(m_polygon3D, dAlt, out m_dDigVolume, out m_dFillVolume, out m_dDigArea, out m_dFillArea, out m_dTotalArea, out m_pntMaxAlt, out m_pntMinAlt, false, 0); GSOFeature altFeature = null; //创建一个空要素 GSOFeatures tempFeatures = globeControl1.Globe.MemoryLayer.GetFeatureByName("DigFillAltPolygon", true); //要素从内存图层里获取 if (tempFeatures.Length > 0) //判断是否获取到 { altFeature = tempFeatures[0]; //获取到就直接赋值 } //把传进来的范围面复制一个 GSOGeoPolygon3D newPolygon = (GSOGeoPolygon3D)m_polygon3D.Clone(); newPolygon.SetAltitude(dAlt); //给这个面设置高度 newPolygon.AltitudeMode = EnumAltitudeMode.Absolute; //高度类型是相对地面 GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); //拉伸风格 extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; //拉伸方式 extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; //拉伸的值 extrudeStyle.TailPartVisible = false; //末端是否可见 //多边形风格,立面风格 GSOSimplePolygonStyle3D extrudePolygonStyle = new GSOSimplePolygonStyle3D(); extrudePolygonStyle.FillColor = Color.FromArgb(150, 0, 255, 0); //多边形填充颜色 extrudeStyle.BodyStyle = extrudePolygonStyle; //把风格赋给拉伸风格 //多边形风格,顶层风格 GSOSimplePolygonStyle3D polygonStyle = new GSOSimplePolygonStyle3D(); polygonStyle.FillColor = Color.FromArgb(200, 0, 0, 255); //设置颜色 newPolygon.Style = polygonStyle; //面的顶层风格 newPolygon.ExtrudeStyle = extrudeStyle; //棉的立面风格 //判断如果要素为空,或者被删除 if (m_AltFeature == null || m_AltFeature.IsDeleted) { //新建一个要素,并且把刚才配置的要素赋值给它 m_AltFeature = new GSOFeature(); m_AltFeature.Name = "DigFillAltPolygon"; m_AltFeature.Geometry = newPolygon; globeControl1.Globe.MemoryLayer.AddFeature(m_AltFeature); } else { //如果原来就有,就直接赋值 m_AltFeature.Geometry = newPolygon; } //刷新球 globeControl1.Globe.Refresh(); //设置文字 SetText(); } }
private void buttonAnalyse_Click(object sender, EventArgs e) { if (m_globe != null && m_polygon3D != null) { double dAlt=System.Convert.ToDouble(textBoxDestAlt.Text); m_globe.Analysis3D.DigFillAnalyse(m_polygon3D, dAlt, out m_dDigVolume, out m_dFillVolume, out m_dDigArea, out m_dFillArea, out m_dTotalArea, out m_pntMaxAlt, out m_pntMinAlt, false, 0); //double dTempArea = m_polygon3D.Area; //double dDiff = dTempArea - m_dTotalArea; //double dRadio = dDiff / dTempArea; GSOFeature altFeature = null; GSOFeatures tempFeatures= m_globe.MemoryLayer.GetFeatureByName("DigFillAltPolygon",true); if (tempFeatures.Length>0) { altFeature = tempFeatures[0]; } GSOGeoPolygon3D newPolygon = (GSOGeoPolygon3D)m_polygon3D.Clone(); newPolygon.SetAltitude(dAlt); newPolygon.AltitudeMode = EnumAltitudeMode.Absolute; GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; extrudeStyle.TailPartVisible = false; GSOSimplePolygonStyle3D extrudePolygonStyle = new GSOSimplePolygonStyle3D(); extrudePolygonStyle.FillColor = Color.FromArgb(150, 0, 255, 0); extrudeStyle.BodyStyle = extrudePolygonStyle; GSOSimplePolygonStyle3D polygonStyle = new GSOSimplePolygonStyle3D(); polygonStyle.FillColor = Color.FromArgb(200, 0, 0, 255); newPolygon.Style = polygonStyle; newPolygon.ExtrudeStyle = extrudeStyle; if (m_AltFeature == null || m_AltFeature.IsDeleted) { m_AltFeature = new GSOFeature(); m_AltFeature.Name = "DigFillAltPolygon"; m_AltFeature.Geometry = newPolygon; m_globe.MemoryLayer.AddFeature(m_AltFeature); } else { m_AltFeature.Geometry = newPolygon; } m_globe.Refresh(); SetText(); } }
private void buttonSetLineStyle_Click(object sender, EventArgs e) { GSOSimplePolygonStyle3D geoStyle3d = m_Style as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { FrmSetLineStyle dlg = new FrmSetLineStyle(geoStyle3d.OutlineStyle, m_GlobeControl); dlg.Show(this); } }
private void buttonSetLineStyle_Click(object sender, EventArgs e) { if (m_Geometry != null) { GSOSimplePolygonStyle3D geoStyle3d = m_Geometry.Style as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { FrmSetOutlineStyle dlg = new FrmSetOutlineStyle(geoStyle3d.OutlineStyle, (GSOGeoPolygon3D)m_Geometry, mfeature, m_GlobeControl); dlg.Show(this); } } }
private void buttonBodyPartStyle_Click(object sender, EventArgs e) { if (m_Geometry != null && m_Geometry.ExtrudeStyle != null) { GSOSimplePolygonStyle3D geoStyle3d = m_Geometry.ExtrudeStyle.BodyStyle as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { FrmSetPolygonStyle dlg = new FrmSetPolygonStyle(geoStyle3d, m_GlobeControl); dlg.Show(this); } } }
private void makeBuffer(GSOFeature feature) { double radius = (double)numericUpDownRadius.Value; //缓冲区宽度 double value = (double)numericUpDownFenDuan.Value; //圆角角度 bool isRoundCorner = CBRoundCorner.Checked; //拐角是否圆滑 bool isRoundEnds = CBRoundEnds.Checked; //两端是否圆滑 GSOGeoPolygon3D buffer = null; //创建缓冲面 if (feature.Geometry.Type == EnumGeometryType.GeoMarker) //如果要素为点 { GSOGeoMarker marker = feature.Geometry as GSOGeoMarker; buffer = marker.CreateBuffer(radius, value, false); //创建点的缓冲面(宽度,角度,false) } else if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; buffer = line.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false); //创建线的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false) } else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) { GSOGeoPolygon3D polygon = feature.Geometry as GSOGeoPolygon3D; buffer = polygon.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false); //创建面的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false) } if (buffer != null) { //缓冲面颜色 GSOSimplePolygonStyle3D style = new GSOSimplePolygonStyle3D(); style.FillColor = Color.FromArgb(122, Color.Yellow); //缓冲线颜色 GSOSimpleLineStyle3D outlineStyle = new GSOSimpleLineStyle3D(); outlineStyle.LineColor = Color.Red; style.OutlineStyle = outlineStyle; buffer.Style = style; GSOFeature featureBuffer = new GSOFeature(); featureBuffer.Geometry = buffer; featureBuffer.Name = feature.Name + "_" + radius + "米_Buffer"; globeControl1.Globe.MemoryLayer.AddFeature(featureBuffer); //重新创建原有要素,使得要素在缓冲面上方,可选择 if (feature != null && feature.Dataset.Type == EnumDatasetType.Memory && feature.Dataset.Caption == "" && feature.Dataset.Name == "") { GSOFeature featureSelectCopy = feature.Clone(); globeControl1.Globe.MemoryLayer.AddFeature(featureSelectCopy); feature.Delete(); } globeControl1.Refresh(); } }
// 矩形 private void btn_Rect_Click(object sender, System.EventArgs e) { GSOGeoRectangle rect = new GSOGeoRectangle(); rect.Position = GetCurrentViewPoint(); rect.Height = 0.001; //单位:度 rect.Width = 0.002; //单位:度 GSOSimplePolygonStyle3D style = new GSOSimplePolygonStyle3D(); style.FillColor = Color.FromArgb(100, Color.Gray); rect.Style = style; AddNewGeoToLayer(rect, "矩形"); }
private void checkBoxFill_CheckedChanged(object sender, EventArgs e) { GSOSimplePolygonStyle3D geoStyle3d = m_Style as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { geoStyle3d.Fill = checkBoxFill.Checked; if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } }
private void fillColorChanged() { GSOSimplePolygonStyle3D geoStyle3d = m_Style as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { geoStyle3d.FillColor = Color.FromArgb(Convert.ToByte(numericUpDownFillOpaque.Value), pictureBoxFillColor.BackColor); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } }
private void checkBoxOutline_CheckedChanged(object sender, EventArgs e) { GSOSimplePolygonStyle3D geoStyle3d = m_Style as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { geoStyle3d.OutLineVisible = checkBoxOutline.Checked; if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } }
// 椭圆 private void btn_Ellipse_Click(object sender, System.EventArgs e) { GSOGeoEllipse eclipse = new GSOGeoEllipse(); eclipse.Position = GetCurrentViewPoint(); //指定模型创建位置 eclipse.XRadius = 0.001; //X方向方向半径,单位:度 eclipse.YRadius = 0.002; //Y方向方向半径,单位:度 GSOSimplePolygonStyle3D style = new GSOSimplePolygonStyle3D(); //样式 //设置填充样式为透明度100,颜色为灰色 style.FillColor = Color.FromArgb(100, Color.Gray); eclipse.Style = style; AddNewGeoToLayer(eclipse, "椭圆"); }
private void AddPolygon() { GSOGeoPolygon3D geoPolygon = new GSOGeoPolygon3D(); //创建多边形对象 //创建节点对象 GSOPoint3ds polygonPnts = new GSOPoint3ds(); polygonPnts.Add(new GSOPoint3d(116.7, 39.8, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.9, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.7, 0)); polygonPnts.Add(new GSOPoint3d(116.7, 39.7, 0)); geoPolygon.AddPart(polygonPnts); //把节点添加到多边形对象上 GSOSimplePolygonStyle3D stylePolygon = new GSOSimplePolygonStyle3D(); //创建风格 stylePolygon.OutLineVisible = true; //显示多边形的边缘线 //设置多边形的填充颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 stylePolygon.FillColor = Color.FromArgb(100, 255, 255, 0); geoPolygon.Style = stylePolygon; //把风格添加到多边形上 //创建几何对象并设置属性 GSOFeature f = new GSOFeature(); f.Geometry = geoPolygon; f.Name = "多边形 01"; f.SetFieldValue("description", "a demo polygon"); #region 属性设置 f.Description = "<html>\r\n<head>\r\n<style>\r\n#tab-list {\r\nborder-collapse:collapse;\r\nfont-size:15px;\r\nmargin:20px;\r\ntext-align:left;\r\nwidth:280px;\r\n}\r\n\r\n#tab-list th {\r\nborder-bottom:2px solid #6678B1;\r\ncolor:#003399;\r\nfont-size:14px;\r\nfont-weight:normal;\r\npadding:10px 8px;\r\n}\r\n#tab-list td {\r\nborder-bottom:1px solid #CCCCCC;\r\ncolor:#666699;\r\npadding:6px 8px;\r\n}\r\n</style>\r\n</head>\r\n<body style=\"border:none\">\r\n<center>\r\n<table id=\"tab-list\">\r\n<thead><tr><th>属性名称</th><th>属性值</th></tr></thead>\r\n<tbody>$tablecontent</tbody></table>\r\n</center>\r\n</body>\r\n</html>\r\n"; GSOGeoPolyline3D line = new GSOGeoPolyline3D(); line.AddPart((f.Geometry as GSOGeoPolygon3D)[0]); double length = line.GetSpaceLength(true, 6378137) / 1000; Dictionary <string, string> property = new Dictionary <string, string>(); property.Add("面积", ((f.Geometry as GSOGeoPolygon3D).Area / 1000000).ToString("f4") + "平方千米"); property.Add("周长", length.ToString("f2") + "千米"); f.Description = f.Description.Replace("$tablecontent", maketable(property)); #endregion globeControl1.Globe.MemoryLayer.AddFeature(f); //把几何要素添加到内存图层中 }
// 面 private void btn_Polygon_Click(object sender, System.EventArgs e) { GSOGeoPolygon3D polygon = new GSOGeoPolygon3D(); //创建多边形对象 //创建节点对象 GSOPoint3ds polygonPnts = new GSOPoint3ds(); polygonPnts.Add(new GSOPoint3d(120.47, 31.3, 0)); polygonPnts.Add(new GSOPoint3d(120.48, 31.3, 0)); polygonPnts.Add(new GSOPoint3d(120.48, 31.25, 0)); polygonPnts.Add(new GSOPoint3d(120.47, 31.2, 0)); polygon.AddPart(polygonPnts); //把节点添加到多边形对象上 GSOSimplePolygonStyle3D style = new GSOSimplePolygonStyle3D(); style.FillColor = Color.FromArgb(255, Color.Gray); polygon.Style = style; AddNewGeoToLayer(polygon, "面"); }
/// <summary> /// 创建面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddPolygon_Click(object sender, EventArgs e) { GSOGeoPolygon3D geoPolygon = new GSOGeoPolygon3D(); //创建多边形对象 //创建节点对象 GSOPoint3ds polygonPnts = new GSOPoint3ds(); polygonPnts.Add(new GSOPoint3d(116.7, 39.8, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.9, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.7, 0)); polygonPnts.Add(new GSOPoint3d(116.7, 39.7, 0)); geoPolygon.AddPart(polygonPnts); //把节点添加到多边形对象上 GSOSimplePolygonStyle3D stylePolygon = new GSOSimplePolygonStyle3D(); //创建风格 stylePolygon.OutLineVisible = true; //显示多边形的边缘线 //设置多边形的填充颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 stylePolygon.FillColor = Color.FromArgb(100, 255, 255, 0); geoPolygon.Style = stylePolygon; //把风格添加到多边形上 //创建几何对象并设置属性 GSOFeature f = new GSOFeature(); f.Geometry = geoPolygon; f.Name = "多边形 01"; f.SetFieldValue("description", "a demo polygon"); //绑定数据 btnRemovePolygon.Tag = f; globeControl1.Globe.MemoryLayer.AddFeature(f); //把几何要素添加到内存图层中 //下面不属于工程内容,只是飞到点的位置 GSOCameraState cs = new GSOCameraState(); cs.Longitude = 116.75; cs.Latitude = 39.8; cs.Altitude = 50000; globeControl1.Globe.FlyToCameraState(cs); }
private void Form1_Load(object sender, EventArgs e) { #region 创建面要素和飞到面 GSOGeoPolygon3D geoPolygon = new GSOGeoPolygon3D(); //创建多边形对象 //创建节点对象 GSOPoint3ds polygonPnts = new GSOPoint3ds(); polygonPnts.Add(new GSOPoint3d(116.7, 39.8, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.9, 0)); polygonPnts.Add(new GSOPoint3d(116.8, 39.7, 0)); polygonPnts.Add(new GSOPoint3d(116.7, 39.7, 0)); geoPolygon.AddPart(polygonPnts); //把节点添加到多边形对象上 GSOSimplePolygonStyle3D stylePolygon = new GSOSimplePolygonStyle3D(); //创建风格 stylePolygon.OutLineVisible = true; //显示多边形的边缘线 //设置多边形的填充颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 stylePolygon.FillColor = Color.FromArgb(100, 255, 255, 0); geoPolygon.Style = stylePolygon; //把风格添加到多边形上 //下面不属于工程内容,只是飞到点的位置 GSOCameraState cs = new GSOCameraState(); cs.Longitude = 116.75; cs.Latitude = 39.8; cs.Altitude = 50000; globeControl1.Globe.FlyToCameraState(cs); #endregion //创建几何对象并设置属性 GSOFeature f = new GSOFeature(); f.Geometry = geoPolygon; f.Name = "多边形 01"; f.CustomID = 1; f.SetFieldValue("description", "a demo polygon"); f.Description = "这是一个多边形"; //将面添加到球中 feature = globeControl1.Globe.MemoryLayer.AddFeature(f); //添加的时候获取要素 }
private void buttonTailPartStyle_Click(object sender, EventArgs e) { if (m_Geometry != null) { if (m_Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOSimpleLineStyle3D geoStyle3d = m_Geometry.ExtrudeStyle.TailStyle as GSOSimpleLineStyle3D; if (geoStyle3d != null) { FrmSetLineStyle dlg = new FrmSetLineStyle(geoStyle3d, m_GlobeControl); dlg.Show(this); } } else { GSOSimplePolygonStyle3D geoStyle3d = m_Geometry.ExtrudeStyle.TailStyle as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { FrmSetPolygonStyle dlg = new FrmSetPolygonStyle(geoStyle3d, m_GlobeControl); dlg.Show(this); } } } }
private void buttonOK_Click(object sender, EventArgs e) { GSOFeatures features = mlayer.GetAllFeatures(); for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; switch (feature.Geometry.Type) { case EnumGeometryType.GeoPolyline3D: if (checkBoxLineStyle.Checked) { GSOSimpleLineStyle3D polylinestyle = null; if (feature.Geometry.Style == null) { polylinestyle = new GSOSimpleLineStyle3D(); polylinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericLineOpaque.Value), pictureBoxLineColor.BackColor); polylinestyle.LineType = getLineType(comboBoxLineType.SelectedIndex); if (textBoxLineWidth.Text != "") { string strwidth = textBoxLineWidth.Text; double dwidth = 0.0; if (double.TryParse(strwidth, out dwidth)) { polylinestyle.LineWidth = dwidth; } } feature.Geometry.Style = polylinestyle; } else { polylinestyle = (GSOSimpleLineStyle3D)feature.Geometry.Style; polylinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericLineOpaque.Value), pictureBoxLineColor.BackColor); polylinestyle.LineType = getLineType(comboBoxLineType.SelectedIndex); if (textBoxLineWidth.Text != "") { string strwidth = textBoxLineWidth.Text; double dwidth = 0.0; if (double.TryParse(strwidth, out dwidth)) { polylinestyle.LineWidth = dwidth; } } } } break; case EnumGeometryType.GeoPolygon3D: if (checkBoxPolygonStyle.Checked) { GSOSimplePolygonStyle3D polygonstyle = null; GSOSimpleLineStyle3D outlinestyle = null; if (checkBoxPolygonFillStyle.Checked) { if (feature.Geometry.Style == null) { polygonstyle = new GSOSimplePolygonStyle3D(); polygonstyle.FillColor = Color.FromArgb(Convert.ToByte(numericPolygonFillOpaque.Value), pictureBoxPolygonFillColor.BackColor); feature.Geometry.Style = polygonstyle; } else { polygonstyle = (GSOSimplePolygonStyle3D)feature.Geometry.Style; polygonstyle.FillColor = Color.FromArgb(Convert.ToByte(numericPolygonFillOpaque.Value), pictureBoxPolygonFillColor.BackColor); } } if (checkBoxPolygonOutlineStyle.Checked) { if (feature.Geometry.Style == null) { polygonstyle = new GSOSimplePolygonStyle3D(); outlinestyle = new GSOSimpleLineStyle3D(); outlinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericPolygonOutlineOpaque.Value), pictureBoxPolygonOutlineColor.BackColor); outlinestyle.LineType = getLineType(comboBoxPolygonOutlineType.SelectedIndex); if (textBoxPolygonOutlineWidth.Text != "") { string strwidth = textBoxPolygonOutlineWidth.Text; double dwidth = 0.0; if (double.TryParse(strwidth, out dwidth)) { outlinestyle.LineWidth = dwidth; } } polygonstyle.OutlineStyle = outlinestyle; feature.Geometry.Style = polygonstyle; } else { polygonstyle = (GSOSimplePolygonStyle3D)feature.Geometry.Style; if (polygonstyle.OutlineStyle == null) { outlinestyle = new GSOSimpleLineStyle3D(); outlinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericPolygonOutlineOpaque.Value), pictureBoxPolygonOutlineColor.BackColor); outlinestyle.LineType = getLineType(comboBoxPolygonOutlineType.SelectedIndex); if (textBoxPolygonOutlineWidth.Text != "") { string strwidth = textBoxPolygonOutlineWidth.Text; double dwidth = 0.0; if (double.TryParse(strwidth, out dwidth)) { outlinestyle.LineWidth = dwidth; } } polygonstyle.OutlineStyle = outlinestyle; feature.Geometry.Style = polygonstyle; } else { outlinestyle = (GSOSimpleLineStyle3D)polygonstyle.OutlineStyle; outlinestyle.LineColor = Color.FromArgb(Convert.ToByte(numericPolygonOutlineOpaque.Value), pictureBoxPolygonOutlineColor.BackColor); outlinestyle.LineType = getLineType(comboBoxPolygonOutlineType.SelectedIndex); if (textBoxPolygonOutlineWidth.Text != "") { string strwidth = textBoxPolygonOutlineWidth.Text; double dwidth = 0.0; if (double.TryParse(strwidth, out dwidth)) { outlinestyle.LineWidth = dwidth; } } feature.Geometry.Style = polygonstyle; } } } } break; } mGlobeControl.Refresh(); } this.Close(); }
private void ShowWater() { if (m_WaterFeature==null || m_WaterFeature.IsDeleted) { m_dBaseAlt = m_pntMinAlt.Z; GSOGeoWater geoWater = m_polygon3D.ConvertToGeoWater(); GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); if (checkBoxExtrude.Checked) { extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; } else { extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeNone; } extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; extrudeStyle.TailPartVisible = false; GSOSimplePolygonStyle3D polygonStyle = new GSOSimplePolygonStyle3D(); polygonStyle.FillColor = Color.FromArgb(200, 0, 0, 255); extrudeStyle.BodyStyle = polygonStyle; geoWater.ExtrudeStyle = extrudeStyle; geoWater.AltitudeMode = EnumAltitudeMode.Absolute; geoWater.SetAltitude(m_dBaseAlt); geoWater.ReflectSky = false; geoWater.WaveWidth = 0.1; geoWater.Play(); m_WaterFeature = new GSOFeature(); m_WaterFeature.Geometry = geoWater; m_globe.MemoryLayer.AddFeature(m_WaterFeature); m_globe.Refresh(); trackBarAlt.Maximum = (int)m_pntMaxAlt.Z; trackBarAlt.Minimum = (int)m_pntMinAlt.Z; trackBarAlt.Value = trackBarAlt.Minimum; textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); } else { GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; geoWater.SetAltitude(m_dBaseAlt); m_globe.Refresh(); trackBarAlt.Maximum = (int)m_pntMaxAlt.Z; trackBarAlt.Minimum = (int)m_pntMinAlt.Z; } }
private void button2_Click(object sender, EventArgs e) { if (comboBoxLayers.Text == "") { MessageBox.Show("请选择一个图层!"); return; } GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(comboBoxLayers.Text.Trim()); if (layer == null) { MessageBox.Show("您选择的图层不存在!"); return; } string iconPath = textBoxIconPath.Text.Trim(); if (iconPath == "") { iconPath = Application.StartupPath + "\\Resource\\DefaultIcon.png"; } Color lineColor = textBoxLineColor.BackColor; string strLineWidth = textBoxLineWidth.Text.Trim(); double lineWidth = 1; bool blIsLineWidth = double.TryParse(strLineWidth, out lineWidth); Color outlineColor = textBoxOutlineColor.BackColor; string strOutlineWidth = textBoxOutlineWidth.Text.Trim(); double outlineWidth = 1; bool blIsOutlineWidth = double.TryParse(strOutlineWidth, out outlineWidth); Color polygonColor = textBoxPolygonColor.BackColor; string strPolygonAlpha = textBoxPolygonAlpha.Text.Trim(); int polygonAlpha = 255; bool blIsPolygonAlpha = int.TryParse(strPolygonAlpha, out polygonAlpha); polygonColor = Color.FromArgb(polygonAlpha, polygonColor); for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (feature.Geometry != null) { switch (feature.Geometry.Type) { case EnumGeometryType.GeoPoint3D: if (panelPoints.Enabled) { GSOGeoPoint3D point = (GSOGeoPoint3D)feature.Geometry; GSOGeoMarker marker = new GSOGeoMarker(); marker.Position = point.Position; marker.Name = point.Name; marker.CameraState = point.CameraState; marker.Label = point.Label; GSOFeature newFeature = new GSOFeature(); newFeature.Name = feature.Name; newFeature.Geometry = marker; layer.RemoveAt(i); layer.AddFeature(newFeature); i--; } break; case EnumGeometryType.GeoMarker: if (panelPoints.Enabled) { GSOGeoMarker marker = (GSOGeoMarker)feature.Geometry; GSOMarkerStyle3D style = null; if (marker.Style == null) { style = new GSOMarkerStyle3D(); } else { style = (GSOMarkerStyle3D)marker.Style; } style.TextVisible = !checkBoxHideLabelOfMarker.Checked; style.IconPath = iconPath.Trim(); marker.Style = style; } break; case EnumGeometryType.GeoPolyline3D: if (panelLines.Enabled) { GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry; if (line.Label != null) { line.Label.Visible = !checkBoxHideLabelOfLine.Checked; } if (line.Style == null) { GSOSimpleLineStyle3D styleLine = new GSOSimpleLineStyle3D(); styleLine.LineColor = lineColor; styleLine.LineWidth = lineWidth; line.Style = styleLine; } else { GSOSimpleLineStyle3D styleLine = (GSOSimpleLineStyle3D)line.Style; if (styleLine == null) { GSOPipeLineStyle3D pipeStyle = (GSOPipeLineStyle3D)line.Style; if (pipeStyle != null) { pipeStyle.LineColor = lineColor; pipeStyle.Radius = lineWidth / 2; line.Style = pipeStyle; } } else { styleLine.LineColor = lineColor; styleLine.LineWidth = lineWidth; line.Style = styleLine; } } } break; case EnumGeometryType.GeoPolygon3D: if (panelPolygons.Enabled) { GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)feature.Geometry; if (polygon.Label != null) { polygon.Label.Visible = !checkBoxHideLabelOfPolygon.Checked; } GSOSimplePolygonStyle3D stylePolygon = (polygon.Style == null ? new GSOSimplePolygonStyle3D() : (GSOSimplePolygonStyle3D)polygon.Style); stylePolygon.FillColor = polygonColor; stylePolygon.OutLineVisible = true; GSOSimpleLineStyle3D styleOutline = (GSOSimpleLineStyle3D)stylePolygon.OutlineStyle; if (styleOutline == null) { styleOutline = new GSOSimpleLineStyle3D(); } styleOutline.LineWidth = outlineWidth; styleOutline.LineColor = outlineColor; stylePolygon.OutlineStyle = styleOutline; polygon.Style = stylePolygon; } break; } } } mGlobeControl.Globe.Refresh(); this.Close(); }
private void comboBoxLayers_TextChanged(object sender, EventArgs e) { string layerName = comboBoxLayers.Text; if (layerName.Trim().Equals("")) { return; } GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(layerName); if (layer == null) { return; } //清空上一个图层的style textBoxIconPath.Text = ""; textBoxLineColor.BackColor = this.BackColor; textBoxLineWidth.Text = ""; textBoxOutlineColor.BackColor = this.BackColor; textBoxPolygonColor.BackColor = this.BackColor; textBoxOutlineWidth.Text = ""; textBoxPolygonAlpha.Text = ""; bool markerExists = false; bool lineExists = false; bool polygonExists = false; GSOFeatures features = GetAllRealFeatures(layer); for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; if (feature == null) { continue; } if (feature.Geometry != null) { switch (feature.Geometry.Type) { case EnumGeometryType.GeoMarker: if (!markerExists) { GSOGeoMarker marker = (GSOGeoMarker)feature.Geometry; GSOMarkerStyle3D style = (GSOMarkerStyle3D)marker.Style; if (style != null) { textBoxIconPath.Text = style.IconPath; checkBoxHideLabelOfMarker.Checked = !style.TextVisible; markerExists = true; } } break; case EnumGeometryType.GeoPolyline3D: if (!lineExists) { GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry; if (line.Label != null) { checkBoxHideLabelOfPolygon.Checked = !line.Label.Visible; } if (line.Style != null) { GSOSimpleLineStyle3D simpleLineStyle = (GSOSimpleLineStyle3D)line.Style; if (simpleLineStyle != null) { textBoxLineColor.BackColor = simpleLineStyle.LineColor; textBoxLineWidth.Text = (simpleLineStyle.LineWidth == 0 ? "1".ToString() : simpleLineStyle.LineWidth.ToString()); lineExists = true; } else { GSOPipeLineStyle3D pipeLineStyle = (GSOPipeLineStyle3D)line.Style; if (pipeLineStyle != null) { textBoxLineColor.BackColor = pipeLineStyle.LineColor; textBoxLineWidth.Text = (pipeLineStyle.Radius * 2).ToString(); lineExists = true; } } } } break; case EnumGeometryType.GeoPolygon3D: if (!polygonExists) { GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)feature.Geometry; if (polygon.Label != null) { checkBoxHideLabelOfLine.Checked = !polygon.Label.Visible; } GSOSimplePolygonStyle3D stylePolygon = (GSOSimplePolygonStyle3D)polygon.Style; if (stylePolygon != null) { textBoxPolygonColor.BackColor = Color.FromArgb(stylePolygon.FillColor.R, stylePolygon.FillColor.G, stylePolygon.FillColor.B); textBoxPolygonAlpha.Text = stylePolygon.FillColor.A.ToString(); GSOSimpleLineStyle3D styleOutline = (GSOSimpleLineStyle3D)stylePolygon.OutlineStyle; if (styleOutline != null) { textBoxOutlineColor.BackColor = styleOutline.LineColor; textBoxOutlineWidth.Text = (styleOutline.LineWidth == 0 ? "1".ToString() : styleOutline.LineWidth.ToString()); } polygonExists = true; } } break; } } } }
private void buttonAnalyse_Click(object sender, EventArgs e) { if (m_globe != null && m_polygon3D != null) { double dAlt = System.Convert.ToDouble(textBoxDestAlt.Text); m_globe.Analysis3D.DigFillAnalyse(m_polygon3D, dAlt, out m_dDigVolume, out m_dFillVolume, out m_dDigArea, out m_dFillArea, out m_dTotalArea, out m_pntMaxAlt, out m_pntMinAlt, false, 0); //double dTempArea = m_polygon3D.Area; //double dDiff = dTempArea - m_dTotalArea; //double dRadio = dDiff / dTempArea; GSOFeature altFeature = null; GSOFeatures tempFeatures = m_globe.MemoryLayer.GetFeatureByName("DigFillAltPolygon", true); if (tempFeatures.Length > 0) { altFeature = tempFeatures[0]; } GSOGeoPolygon3D newPolygon = (GSOGeoPolygon3D)m_polygon3D.Clone(); newPolygon.SetAltitude(dAlt); newPolygon.AltitudeMode = EnumAltitudeMode.Absolute; GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; extrudeStyle.TailPartVisible = false; GSOSimplePolygonStyle3D extrudePolygonStyle = new GSOSimplePolygonStyle3D(); extrudePolygonStyle.FillColor = Color.FromArgb(150, 0, 255, 0); extrudeStyle.BodyStyle = extrudePolygonStyle; GSOSimplePolygonStyle3D polygonStyle = new GSOSimplePolygonStyle3D(); polygonStyle.FillColor = Color.FromArgb(200, 0, 0, 255); newPolygon.Style = polygonStyle; newPolygon.ExtrudeStyle = extrudeStyle; if (m_AltFeature == null || m_AltFeature.IsDeleted) { m_AltFeature = new GSOFeature(); m_AltFeature.Name = "DigFillAltPolygon"; m_AltFeature.Geometry = newPolygon; m_globe.MemoryLayer.AddFeature(m_AltFeature); } else { m_AltFeature.Geometry = newPolygon; } m_globe.Refresh(); SetText(); } }