//光照打开/关闭 private void btn_sunLight_Click(object sender, EventArgs e) { if (_glbControl.Globe.Sun.Visible) { this.btn_sunLight.Text = "打开日照"; //设置日照不可见 _glbControl.Globe.Sun.Visible = false; //关闭阴影效果 _glbControl.Globe.ShadowVisible = false; _glbControl.Refresh(); } else { datetime = System.DateTime.Now; this.btn_sunLight.Text = "关闭日照"; //设置日照可见 _glbControl.Globe.Sun.Visible = true; //设置为当前实时时间 _glbControl.Globe.Sun.IsRealTimePos = true; //重要:要打开阴影效果才能看到光照的阴影 _glbControl.Globe.ShadowVisible = true; //刷新球 _glbControl.Refresh(); } }
private void buttonDelAttribute_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要删除该属性字段?", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { GSOFeatureLayer pFeatureLayer = geoLayer as GSOFeatureLayer; if (pFeatureLayer == null) { return; } GSOFeatureDataset dataset = pFeatureLayer.Dataset as GSOFeatureDataset; dataset.DeleteField(listBoxAttribute.SelectedItem.ToString()); if (listBoxAttribute.SelectedItem != null) { listBoxAttribute.Items.Remove(listBoxAttribute.SelectedItem); dataset.SaveAs(@"F:\新建文件夹"); MessageBox.Show("删除字段成功!", "提示!"); } if (m_globeControl != null) { m_globeControl.Refresh(); } } catch (System.Exception exp) { Log.PublishTxt(exp); } } }
/// <summary> /// 模型替换 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_ReplaceModel_Click(object sender, EventArgs e) { if (_trackPressPolygon.Count < 1) { MessageBox.Show("请先绘制压平模型。"); return; } foreach (var trackPolygon in _trackPressPolygon) { //创建模型 GSOGeoModel model = new GSOGeoModel(); //给定模型路径 model.FilePath = _modelPath; //模型加载 model.Load(); //模型位置 model.Position = trackPolygon.GeoCenterPoint; //将模型放置于模型表面 model.AltitudeMode = EnumAltitudeMode.ClampToModel; //把几何体放到表面上 GSOFeature f = new GSOFeature(); //创建几何要素 f.Geometry = model; f.Name = "模型 01"; //把几何要素添加到内存图层中 GSOFeature newFeature = _glbControl.Globe.MemoryLayer.AddFeature(f); _glbControl.Refresh(); //刷新场景 } }
private void buttonCancel_Click(object sender, EventArgs e) { mLayer.RemoveAllFeature(); mLayer.AddFeatures(mFeaturesOld); mGlobeControl.Refresh(); this.Close(); }
private void lstValvesName_DoubleClick(object sender, EventArgs e) { int i = this.lstValvesName.SelectedIndex; if (i < 0) { return; } GSOFeature m_CloseValvesAnalyresFeature = m_CloseValvesAnalyResFeatures[i]; globeControl1.Globe.FlyToFeature(m_CloseValvesAnalyresFeature, 1, 45, 5); GSOLabel newLabel = new GSOLabel(); newLabel.Text = "关闭此阀门"; newLabel.Style = new GSOLabelStyle(); newLabel.Style.Opaque = 0.8; newLabel.Style.OutlineColor = Color.Red; //newLabel.Style.TractionLineEndPos = new GSOPoint2d(150, 120); newLabel.Style.OutlineWidth = 1; newLabel.Style.TracktionLineWidth = 1; newLabel.Style.BackBeginColor = Color.Orange; newLabel.Style.BackEndColor = Color.PaleGreen; m_CloseValvesAnalyresFeature.Label = newLabel; m_CloseValvesList.Add(m_CloseValvesAnalyresFeature); globeControl1.Refresh(); }
private void btnRemovePoint_Click(object sender, EventArgs e) { //在球上查找后删除,可用Name,ID,Description等查找。 GeoScene.Data.GSOFeature feature = globeControl1.Globe.MemoryLayer.GetFeatureByName("中科图新", false)[0]; feature.Delete(); globeControl1.Refresh(); }
private void buttonCancel_Click(object sender, EventArgs e) { // 如果取消的话,将备份的拷贝回来 if (m_Style != null) { mfeature.Geometry.Style = m_OldStyle; m_GlobeControl.Refresh(); } this.Close(); }
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 buttonCancel_Click(object sender, EventArgs e) { // 如果取消的话,将备份的拷贝回来 if (m_OldStyle != null) { ((GSOSimplePolygonStyle3D)mpolygon.Style).OutlineStyle = m_OldStyle; if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } this.Close(); }
private void lineColorChanged() { if (m_Geometry != null) { if (simpleLineStyle3D != null) { simpleLineStyle3D.LineColor = Color.FromArgb(Convert.ToByte(numericUpDownLineOpaque.Value), pictureBoxLineColor.BackColor); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } } }
private void checkBoxFill_CheckedChanged(object sender, EventArgs e) { if (m_Geometry != null) { GSOSimplePolygonStyle3D geoStyle3d = m_Geometry.Style as GSOSimplePolygonStyle3D; if (geoStyle3d != null) { geoStyle3d.Fill = checkBoxFill.Checked; if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } } }
protected override void OnHandleDestroyed(EventArgs e) { base.OnHandleDestroyed(e); if (m_FeatureSelPoint != null) { m_FeatureSelPoint.Delete(); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } }
private void btn_Model_Click(object sender, EventArgs e) { GSOGeoModel model = new GSOGeoModel(); //创建模型 GSOPoint3d pt = new GSOPoint3d(); //创建点 pt.X = 120; pt.Y = 30; pt.Z = 0; GSOModelPointStyle3D style = new GSOModelPointStyle3D(); //创建模型的风格 model.Style = style; //设置模型 model.FilePath = _modelPath; model.Position = pt; model.AltitudeMode = EnumAltitudeMode.ClampToGround; //把几何体放到地面上 GSOFeature f = new GSOFeature(); //创建几何要素 f.Geometry = model; f.Name = "模型 01"; f.Description = "模型 01"; //设置feature description的值,这个值将在tooltip上显示 //把几何要素添加到内存图层中 GSOFeature newFeature = _glbControl.Globe.MemoryLayer.AddFeature(f); _glbControl.Globe.FlyToFeature(f); //飞行到模型所在的位置 _glbControl.Refresh(); //刷新场景 }
private void ParamChanged() { geoRangeEllipFrustumEntity = m_Geometry as GSOGeoRangeEllipFrustumEntity; if (geoRangeEllipFrustumEntity != null) { try { geoRangeEllipFrustumEntity.TopXRadius = Convert.ToDouble(textBoxTopXRadius.Text); geoRangeEllipFrustumEntity.TopYRadius = Convert.ToDouble(textBoxTopYRadius.Text); geoRangeEllipFrustumEntity.BottomXRadius = Convert.ToDouble(textBoxBottomXRadius.Text); geoRangeEllipFrustumEntity.BottomYRadius = Convert.ToDouble(textBoxBottomYRadius.Text); geoRangeEllipFrustumEntity.Length = Convert.ToDouble(textBoxLength.Text); geoRangeEllipFrustumEntity.Slices = Convert.ToInt32(textBoxSlices.Text); geoRangeEllipFrustumEntity.StartAngle = Convert.ToDouble(textBoxStartAngle.Text); geoRangeEllipFrustumEntity.EndAngle = Convert.ToDouble(textBoxEndAngle.Text); GSOEntityStyle3D style = new GSOEntityStyle3D(); style.UsingSingleColor = true; geoRangeEllipFrustumEntity.Style = style; if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } catch (System.Exception exp) { Log.PublishTxt(exp); } } }
//加载shp文件并显示管线 private void btn_LoadLayer_Click(object sender, EventArgs e) { if (_layerAdded) { return; } _shpLayer = _glbControl.Globe.Layers.Add(_testShpPath); _shpLayer.Editable = true; //设置样式 GSOPipeLineStyle3D style = new GSOPipeLineStyle3D(); style.LineColor = Color.Green; //管线半径 style.Radius = _radius; //获得默认图层的要素 var features = _shpLayer.GetAllFeatures(); //遍历要素 for (int i = 0; i < features.Length; i++) { GSOGeoPolyline3D geometry = features[i].Geometry as GSOGeoPolyline3D; geometry.Style = style; //将高度抬高到管径高度 geometry.MoveZ(style.Radius); //重要,要将高度模式设置成相对地表,如果为依附地面则无渲染效果 geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; } _glbControl.Refresh(); FlyToLayer(_shpLayer); }
private void ParamChanged() { geoRangeEllipsoidEntity = m_Geometry as GSOGeoRangeEllipsoidEntity; if (geoRangeEllipsoidEntity != null) { try { geoRangeEllipsoidEntity.XRadius = Convert.ToDouble(textBoxXRadius.Text); geoRangeEllipsoidEntity.YRadius = Convert.ToDouble(textBoxYRadius.Text); geoRangeEllipsoidEntity.ZRadius = Convert.ToDouble(textBoxZRadius.Text); geoRangeEllipsoidEntity.Stacks = Convert.ToInt32(textBoxStacks.Text); geoRangeEllipsoidEntity.Slices = Convert.ToInt32(textBoxSlices.Text); geoRangeEllipsoidEntity.StartLat = Convert.ToDouble(textBoxStartLat.Text); geoRangeEllipsoidEntity.EndLat = Convert.ToDouble(textBoxEndLat.Text); geoRangeEllipsoidEntity.StartLon = Convert.ToDouble(textBoxStartLon.Text); geoRangeEllipsoidEntity.EndLon = Convert.ToDouble(textBoxEndLon.Text); GSOEntityStyle3D style = new GSOEntityStyle3D(); style.UsingSingleColor = true; geoRangeEllipsoidEntity.Style = style; if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } catch (System.Exception exp) { Log.PublishTxt(exp); } } }
private void Apply() { label.Style = new GSOLabelStyle(); label.Style.TextStyle.Italic = chkItalic.Checked; label.Style.Opaque = trackBarOpaque.Value / 10.0; label.Style.TextStyle.FontHeight = (double)numFontsize.Value; label.Style.TractionLineEndPos = new GSOPoint2d((double)numOffsetX.Value, (double)numOffsetY.Value); label.Style.OutlineColor = labelBorderColor.BackColor; if (chkHasTrackLine.Checked) { label.Style.TractionLineColor = Color.FromArgb(255, labelBorderColor.BackColor); } else { label.Style.TractionLineColor = Color.FromArgb(0, labelBorderColor.BackColor); } label.Style.BackFillEffect = EnumLabelBackEffect.EFFECT_VGRADIENT; label.Style.TracktionLineWidth = (double)numTrackWidth.Value; label.Style.OutlineWidth = (double)numBorderWidth.Value; Color beginColor = Color.FromArgb(255, Color.Transparent); Color endColor = Color.FromArgb(255, Color.Transparent); label.Style.BackBeginColor = labelFrom.BackColor; label.Style.BackEndColor = labelTo.BackColor; label.Style.MaxVisibleDistance = (double)numMaxdistance.Value; label.Style.MinVisibleDistance = (double)numMinDistance.Value; switch (comboBox1.SelectedIndex) { case 0: label.Style.TracktionLineType = EnumTracktionLineType.Solid; break; default: label.Style.TracktionLineType = EnumTracktionLineType.Dot; break; } label.Text = txtInfo.Text; if (txtImagePath.Text != "") { label.BKImage = txtImagePath.Text; } GSOFeature feature = globeControl.Globe.SelectedObject as GSOFeature; //new GSOFeature(); feature.Label = label; // globeControl.Globe.MemoryLayer.AddFeature(feature); globeControl.Refresh(); }
/// <summary> /// 挖坑事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { //绘制面 globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.GroundTrack; TracPolygonType = "挖坑"; globeControl1.Refresh(); }
/// <summary> /// 打开工程一 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, System.EventArgs e) { //获得文件地址 string path = Application.StartupPath + "/Resource/GWS/1.gws"; //先关闭当前工程 if (!CloseWorkSpace()) { return; } //打开工程文件 globeControl1.Globe.OpenWorkSpace(path); //刷新球 globeControl1.Refresh(); //将图层写入list中,方便查看不同 AddLayerToComobBox(); }
private void checkBoxUseStyle_CheckedChanged(object sender, EventArgs e) { bool bChecked = checkBoxUseStyle.Checked; if (!bChecked) { // 清除风格 if (m_feature.Geometry != null) { m_feature.Geometry.Style = null; } } else { if (m_feature.Geometry != null && m_feature.Geometry.Style == null) { m_feature.Geometry.Style = new GSOEntityStyle3D(); SetControlsByStyle(m_feature.Geometry.Style); } } CheckControlsEnable(bChecked); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } }
private void RefreshGlobe(GSOArrowStyle m_Style) { ((GSOLineStyle3D)mfeature.Geometry.Style).ArrowVisible = true; ((GSOLineStyle3D)mfeature.Geometry.Style).ArrowStyle = m_Style; if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } }
void globeControl1_MouseMove(object sender, MouseEventArgs e) { if (overlayText != null && overlayText.Text != "" && feature_ScreenText != null) { overlayText.SetOffset(e.X + 20, e.Y); feature_ScreenText.Geometry = overlayText; globeControl1.Refresh(); } }
private void pictureBoxIconPath_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "图标(*.ico)|*.ico|(*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { textBoxIconPath.Text = dlg.FileName; try { if (File.Exists(dlg.FileName)) { Bitmap bitmap1 = (Bitmap)Bitmap.FromFile(dlg.FileName); pictureBoxIconPath.SizeMode = PictureBoxSizeMode.StretchImage; pictureBoxIconPath.Image = bitmap1; } } catch (System.Exception exp) { Log.PublishTxt(exp); } if (m_Geometry != null) { GSOMarkerStyle3D markerStyle = m_Geometry.Style as GSOMarkerStyle3D; if (markerStyle != null) { markerStyle.IconVisible = true; markerStyle.IconPath = dlg.FileName; } else { markerStyle = new GSOMarkerStyle3D(); markerStyle.IconPath = dlg.FileName; m_Geometry.Style = markerStyle; } if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } } }
/// <summary> /// 窗口关闭事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DigFillAnalysisDlg_FormClosed(object sender, FormClosedEventArgs e) { if (m_AltFeature != null) { globeControl1.Globe.MemoryLayer.RemoveFeatureByID(m_AltFeature.ID); globeControl1.Globe.ClearLastTrackPolygon(); m_AltFeature = null; globeControl1.Refresh(); } }
private void textBoxWaveSpeedX_TextChanged(object sender, EventArgs e) { GSOGeoWater geoWater = m_Geometry as GSOGeoWater; if (geoWater != null) { try { geoWater.WaveSpeedX = Convert.ToDouble(textBoxWaveSpeedX.Text); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } catch (System.Exception exp) { Log.PublishTxt(exp); } } }
private void checkBoxUseStyle_CheckedChanged(object sender, EventArgs e) { if (m_Geometry != null) { bool bChecked = checkBoxUseStyle.Checked; if (!bChecked) { // 清除风格 m_Geometry.Style = m_OldStyle; } else { CheckControlsEnable(bChecked); } if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } }
private void buttonOk_Click(object sender, EventArgs e) { if (m_Feature != null) { if (m_Feature.Geometry != null) { m_Feature.Geometry.Name = textBoxName.Text; // 交换数据 if (m_Feature.Geometry.Type != EnumGeometryType.GeoPolyline3D) { m_CtrlFeatureAttribute.ExchangeData(); m_CtrlGeometryCameraState.ExchangeData(); } } m_Feature.Name = textBoxName.Text; m_GlobeControl.Refresh(); } this.Close(); }
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 positionChanged() { GSOGeoEntity geoEntity = m_feature.Geometry as GSOGeoEntity; if (geoEntity != null) { try { geoEntity.PositionX = Convert.ToDouble(textBoxLon.Text); geoEntity.PositionY = Convert.ToDouble(textBoxLat.Text); geoEntity.PositionZ = Convert.ToDouble(textBoxAlt.Text); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } catch (System.Exception exp) { Log.PublishTxt(exp); } } }
private void positionChanged() { GSOGeoPoint3D geoPoint3D = m_Geometry as GSOGeoPoint3D; if (geoPoint3D != null) { try { geoPoint3D.X = Convert.ToDouble(textBoxLon.Text); geoPoint3D.Y = Convert.ToDouble(textBoxLat.Text); geoPoint3D.Z = Convert.ToDouble(textBoxAlt.Text); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } catch (System.Exception exp) { Log.PublishTxt(exp); } } }