private void SetControlsByStyle(GSOStyle style) { GSOMarkerStyle3D markerStyle = style as GSOMarkerStyle3D; if (markerStyle != null) { if (markerStyle.IconPath != "") { textBoxIconPath.Text = markerStyle.IconPath; try { if (File.Exists(markerStyle.IconPath)) { Bitmap bitmap1 = (Bitmap)Bitmap.FromFile(markerStyle.IconPath); pictureBoxIconPath.SizeMode = PictureBoxSizeMode.StretchImage; pictureBoxIconPath.Image = bitmap1; } } catch (System.Exception exp) { Log.PublishTxt(exp); } } pictureBoxIconColor.BackColor = Color.FromArgb(255, markerStyle.IconColor); numericUpDownIconOpaque.Value = markerStyle.IconColor.A; try { numericUpDownIconScale.Value = Convert.ToDecimal(markerStyle.IconScale); } catch (System.Exception exp) { Log.PublishTxt(exp); } GSOTextStyle geoTextStyle = (GSOTextStyle)markerStyle.TextStyle; if (geoTextStyle != null) { pictureBoxTextColor.BackColor = Color.FromArgb(255, geoTextStyle.ForeColor); numericUpDownTextOpaque.Value = geoTextStyle.ForeColor.A; try { numericUpDownTextScale.Value = Convert.ToDecimal(geoTextStyle.Scale); } catch (System.Exception exp) { Log.PublishTxt(exp); } } } }
public GSOHudButtonInfo() { GSOTextStyle textStyle = new GSOTextStyle(); textStyle.ForeColor = Color.White; textStyle.FontSize = 9; this.TextAlign = EnumAlign.BottomCenter; this.TextStyle = textStyle; this.TextOffset = new GSOPoint2d(0, -10); this.MinOpaque = 1; this.MaxOpaque = 1; this.Align = EnumAlign.BottomCenter; }
private void buttonOk_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; } Color fontColor = textBoxFontColor.BackColor; string strFontSize = comboBoxFontSize.Text; double fontSize = 12; bool blIsFontSize = double.TryParse(strFontSize, out fontSize); GSOFeatures features = layer.GetAllFeatures(); for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; if (feature.Geometry != null) { switch (feature.Geometry.Type) { case EnumGeometryType.GeoMarker: GSOGeoMarker marker = (GSOGeoMarker)feature.Geometry; GSOMarkerStyle3D style = (marker.Style == null ? new GSOMarkerStyle3D() : (GSOMarkerStyle3D)marker.Style); GSOTextStyle textStyle = (style.TextStyle == null ? new GSOTextStyle() : style.TextStyle); textStyle.ForeColor = fontColor; textStyle.FontSize = fontSize; style.TextStyle = textStyle; marker.Style = style; break; } } mGlobeControl.Globe.Refresh(); } //layer.Save(); this.Close(); }
/// <summary> /// 文字图层 /// </summary> /// <param name="text">显示的文字</param> private void TextTitle(string text) { if (layerScreenText != null) { //清除其中所有要素 layerScreenText.RemoveAllFeature(); GSOGeoScreenText overlayTextTitle = new GSOGeoScreenText(); //创建屏幕文字 GSOTextStyle textStyle = new GSOTextStyle(); //设置属性 textStyle.ForeColor = Color.White; textStyle.FontSize = 36; overlayTextTitle.TextStyle = textStyle; overlayTextTitle.Align = EnumAlign.TopLeft; //设置文字对齐方式 overlayTextTitle.PosAlign = EnumAlign.BottomRight; //设置文字位置 overlayTextTitle.Name = "ScreenTextTitle"; overlayTextTitle.SetOffset(180, 60); //设置文字偏移量 overlayTextTitle.Text = text; //设置文字 GSOFeature feature_ScreenTextTitle = new GSOFeature(); //创建要素 feature_ScreenTextTitle.Geometry = overlayTextTitle; //赋予要素 layerScreenText.AddFeature(feature_ScreenTextTitle); layerScreenText.Save(); } }
/// <summary> /// 跟随鼠标图层 /// </summary> /// <param name="text">显示文字</param> private void SetScreenText(string text) { //如果要素存在就删除 if (feature_ScreenText != null) { feature_ScreenText.Delete(); } if (text != "" && layerScreenText != null) { overlayText = new GSOGeoScreenText(); //创建对象 GSOTextStyle textStyle = new GSOTextStyle(); //创建样式 textStyle.ForeColor = Color.White; //字体颜色 textStyle.FontSize = 9; //字体大小 overlayText.TextStyle = textStyle; //赋予字体样式 overlayText.Align = EnumAlign.TopLeft; //字体对其方式 overlayText.Name = "ScreenText"; //字体对象名称 overlayText.SetOffset(20, 0); //字体偏移量 overlayText.Text = text; //显示文字 feature_ScreenText = new GSOFeature(); //创建要素 feature_ScreenText.Geometry = overlayText; //赋予要素 layerScreenText.AddFeature(feature_ScreenText); //添加要素到图层 } }
public GSOHudButtonInfo(string name, EnumAction3D action, string imagePath, string bigImagePath, int offesetX, int offsetY, string toolTip) { GSOTextStyle textStyle = new GSOTextStyle(); textStyle.ForeColor = Color.White; textStyle.FontSize = 9; this.TextAlign = EnumAlign.BottomCenter; this.TextStyle = textStyle; this.TextOffset = new GSOPoint2d(0, -10); this.MinOpaque = 1; this.MaxOpaque = 1; this.Align = EnumAlign.BottomCenter; this.Name = name; this.imagePath = imagePath; this.SetImage(Application.StartupPath + imagePath); this.SetOffset(offesetX, offsetY); this.toolTip = toolTip; this.action = action; this.bigImagePath = bigImagePath; }
private void 管线间距分析ToolStripMenuItem_Click(object sender, EventArgs e) { if (globeControl1.Globe.SelObjectCount < 2) { MessageBox.Show("请选中至少两个管线!!"); return; } if (disFeature.ID != 0) { globeControl1.Globe.MemoryLayer.RemoveFeatureByID(disFeature.ID); } if (featureDis.ID != 0) { globeControl1.Globe.MemoryLayer.RemoveFeatureByID(featureDis.ID); } GSOLayer reslayer; globeControl1.Globe.GetSelectObject(0, out m_DisAnalysisFirstFeature, out reslayer); globeControl1.Globe.GetSelectObject(1, out m_DisAnalysisSecondFeature, out reslayer); if (m_DisAnalysisSecondFeature != null && m_DisAnalysisSecondFeature != null) { GSOGeoPolyline3D line1 = m_DisAnalysisFirstFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolyline3D line2 = m_DisAnalysisSecondFeature.Geometry as GSOGeoPolyline3D; if (line1 == null || line2 == null) { MessageBox.Show("请选择管线!!"); return; } GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null || pipeStyle2 == null) { MessageBox.Show("请选择管线!!"); return; } GSOPoint3d pntIntersect1; GSOPoint3d pntIntersect2; double dHonLen; double dVerLen; double dNoIntersectStartRatio = 0; // 计算两条线的距离和交点,若果失败返回-1 // 若在同一直线上,并且有交点,返回0 // 若不在同一平面,返回最近两点的距离,并且计算最近两点 double dDist = globeControl1.Globe.Analysis3D.ComputeTwoGeoPolylineDistance(line1, line2, out pntIntersect1, out pntIntersect2, out dHonLen, out dVerLen, false, false, dNoIntersectStartRatio); if (dDist > -1) { if (dDist == 0) { MessageBox.Show("管线在同一水平面,距离为0"); return; } else { dDist = dDist - pipeStyle1.Radius - pipeStyle2.Radius; GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); GSOPoint3ds point3ds = new GSOPoint3ds(); point3ds.Add(pntIntersect1); point3ds.Add(pntIntersect2); disline.AddPart(point3ds); GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 style.LineColor = Color.GreenYellow; style.LineWidth = 3; //设置线的宽度为3 style.VertexVisible = true; //显示线的节点 disline.Style = style; //把风格添加到线上 disline.AltitudeMode = EnumAltitudeMode.Absolute; disFeature.Geometry = disline; GSOGeoMarker markerDis = new GSOGeoMarker(); markerDis.X = pntIntersect1.X; markerDis.Y = pntIntersect1.Y; markerDis.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; markerDis.Text = dDist.ToString().Substring(0, dDist.ToString().IndexOf(".") + 3) + "米"; markerDis.AltitudeMode = EnumAltitudeMode.Absolute; GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); GSOTextStyle styleText = new GSOTextStyle(); styleText.IsSizeFixed = true; styleText.ForeColor = Color.White; styleText.FontSize = 20; styleMarker.TextStyle = styleText; markerDis.Style = styleMarker; featureDis.Geometry = markerDis; layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); layerTemp.AddFeature(featureDis); layerTemp.AddFeature(disFeature); globeControl1.Refresh(); } } else { MessageBox.Show("没有交点!!"); return; } } }
private void MainFrm_Load(object sender, EventArgs e) { this.KeyPreview = true; this.Text = m_strFormTitle; globeControl1.MouseDoubleClick += new MouseEventHandler(sceneControl1_MouseDoubleClick); globeControl1.MouseMove += new MouseEventHandler(sceneControl1_MouseMove); globeControl1.MouseClick += new MouseEventHandler(sceneControl1_MouseClick); globeControl1.MouseDown += new MouseEventHandler(sceneControl1_MouseDown); globeControl1.MouseUp += new MouseEventHandler(sceneControl1_MouseUp); globeControl1.AfterLayerAddEvent += new AfterLayerAddEventHandler(globeControl1_AfterLayerAddEvent); globeControl1.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(sceneControl1_FeatureMouseClick); globeControl1.FeatureMouseHoverEvent += new FeatureMouseHoverEventHandler(sceneControl1_FeatureMouseHover); globeControl1.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(sceneControl1_CameraBeginMove); globeControl1.DrawAddFeatureEvent += new DrawAddFeatureEventHandler(sceneControl1_DrawAddFeature); globeControl1.AfterKeyDownDeleteFeatureEvent += new AfterKeyDownDeleteFeatureEventHandler(sceneControl1_AfterKeyDownDeleteFeatureEvent); globeControl1.TrackPolylineEndEvent += new TrackPolylineEndEventHandler(sceneControl1_TrackPolylineAnalysisEndEvent); globeControl1.TrackPolygonEndEvent += new TrackPolygonEndEventHandler(sceneControl1_TrackPolygonAnalysisEndEvent); globeControl1.AfterNetLayerAddEvent += new AfterNetLayerAddEventHandler(globeControl1_AfterNetLayerAddEvent); globeControl1.KeyDown += new KeyEventHandler(globeControl1_KeyDown); //地面透明背景色 globeControl1.Globe.UserBackgroundColorValid = true; globeControl1.Globe.UserBackgroundColor = Color.White; //globeControl1.Globe.OverviewControl.Visible = false;//鹰眼 globeControl1.Globe.ScalerControl.Visible = false; //比例尺 //自定义工具栏 GSOTextStyle textStyle = new GSOTextStyle(); textStyle.ForeColor = Color.White; textStyle.FontSize = 9; navigate = new GSOHudButton(); navigate.Name = "navigate"; navigate.TextAlign = EnumAlign.BottomCenter; navigate.TextStyle = textStyle; navigate.TextOffset = new GSOPoint2d(0, -10); navigate.SetImage(Application.StartupPath + "/Resource/images/hand36.png"); navigate.MinOpaque = 1; navigate.MaxOpaque = 1; navigate.Align = EnumAlign.BottomCenter; navigate.SetOffset(-270, 30); globeControl1.Globe.AddHudControl(navigate); select = new GSOHudButton(); select.Name = "select"; select.TextAlign = EnumAlign.BottomCenter; select.TextStyle = textStyle; select.TextOffset = new GSOPoint2d(0, -10); select.SetImage(Application.StartupPath + "/Resource/images/select36.png"); select.MinOpaque = 1; select.MaxOpaque = 1; select.Align = EnumAlign.BottomCenter; select.SetOffset(-210, 30); globeControl1.Globe.AddHudControl(select); move = new GSOHudButton(); move.Name = "move"; move.TextAlign = EnumAlign.BottomCenter; move.TextStyle = textStyle; move.TextOffset = new GSOPoint2d(0, -10); move.SetImage(Application.StartupPath + "/Resource/images/move36.png"); move.MinOpaque = 1; move.MaxOpaque = 1; move.Align = EnumAlign.BottomCenter; move.SetOffset(-150, 30); globeControl1.Globe.AddHudControl(move); rotate = new GSOHudButton(); rotate.Name = "rotate"; rotate.TextAlign = EnumAlign.BottomCenter; rotate.TextStyle = textStyle; rotate.TextOffset = new GSOPoint2d(0, -10); rotate.SetImage(Application.StartupPath + "/Resource/images/rotate36.png"); rotate.MinOpaque = 1; rotate.MaxOpaque = 1; rotate.Align = EnumAlign.BottomCenter; rotate.SetOffset(-90, 30); globeControl1.Globe.AddHudControl(rotate); elevate = new GSOHudButton(); elevate.Name = "elevate"; elevate.TextAlign = EnumAlign.BottomCenter; elevate.TextStyle = textStyle; elevate.TextOffset = new GSOPoint2d(0, -10); elevate.SetImage(Application.StartupPath + "/Resource/images/elevate36.png"); elevate.MinOpaque = 1; elevate.MaxOpaque = 1; elevate.Align = EnumAlign.BottomCenter; elevate.SetOffset(-30, 30); globeControl1.Globe.AddHudControl(elevate); line = new GSOHudButton(); line.Name = "line"; line.TextAlign = EnumAlign.BottomCenter; line.TextStyle = textStyle; line.TextOffset = new GSOPoint2d(0, -10); line.SetImage(Application.StartupPath + "/Resource/images/line36.png"); line.MinOpaque = 1; line.MaxOpaque = 1; line.Align = EnumAlign.BottomCenter; line.SetOffset(30, 30); globeControl1.Globe.AddHudControl(line); measure = new GSOHudButton(); measure.Name = "measure"; measure.TextAlign = EnumAlign.BottomCenter; measure.TextStyle = textStyle; measure.TextOffset = new GSOPoint2d(0, -10); measure.SetImage(Application.StartupPath + "/Resource/images/measure36.png"); measure.MinOpaque = 1; measure.MaxOpaque = 1; measure.Align = EnumAlign.BottomCenter; measure.SetOffset(90, 30); globeControl1.Globe.AddHudControl(measure); marker = new GSOHudButton(); marker.Name = "marker"; marker.TextAlign = EnumAlign.BottomCenter; marker.TextStyle = textStyle; marker.TextOffset = new GSOPoint2d(0, -10); marker.SetImage(Application.StartupPath + "/Resource/images/marker36.png"); marker.MinOpaque = 1; marker.MaxOpaque = 1; marker.Align = EnumAlign.BottomCenter; marker.SetOffset(150, 30); globeControl1.Globe.AddHudControl(marker); model = new GSOHudButton(); model.Name = "model"; model.TextAlign = EnumAlign.BottomCenter; model.TextStyle = textStyle; model.TextOffset = new GSOPoint2d(0, -10); model.SetImage(Application.StartupPath + "/Resource/images/model36.png"); model.MinOpaque = 1; model.MaxOpaque = 1; model.Align = EnumAlign.BottomCenter; model.SetOffset(210, 30); globeControl1.Globe.AddHudControl(model); //给工具栏绑定事件 globeControl1.HudControlMouseDownEvent += new HudControlMouseDownEventHandler(globeControl1_HudControlMouseDownEvent); globeControl1.HudControlMouseIntoEvent += new HudControlMouseIntoEventHandler(globeControl1_HudControlMouseIntoEvent); globeControl1.HudControlMouseOutEvent += new HudControlMouseOutEventHandler(globeControl1_HudControlMouseOutEvent); globeControl1.Globe.StatusBar.Visible = true; globeControl1.Globe.LatLonGrid.Visible = GridMenue.Checked = false; MarbleSurfaceMenuItem.Checked = globeControl1.Globe.MarbleVisible; underGroundLockedMenuItem.Checked = globeControl1.Globe.IsUnderGroundLocked; globeControl1.Globe.UnderGroundFloor.Visible = false; globeControl1.Globe.Object2DMouseOverEnable = true; 地下网格ToolStripMenuItem.Checked = false; MenuItem2DObjMouseOverEnable.Checked = true; AtmospherMenue.Checked = true; StatusMenu.Checked = true; NavigationControlMenu.Checked = true; MainToolBarShowMenu.Checked = true; dataManagerNode = new TreeNode(); dataManagerNode.ImageIndex = 0; dataManagerNode.SelectedImageIndex = 0; dataManagerNode.Checked = true; dataManagerNode.Text = "数据管理"; layerTree.Nodes.Add(dataManagerNode); myPlaceNode = new TreeNode(); myPlaceNode.ImageIndex = 0; myPlaceNode.SelectedImageIndex = 0; myPlaceNode.Checked = true; myPlaceNode.Tag = globeControl1.Globe.MemoryLayer; myPlaceNode.Text = "我的地标"; myPlaceNode.NodeFont = new Font(layerTree.Font ,FontStyle.Bold); layerTree.Nodes.Add(myPlaceNode); layerManagerNode = new TreeNode(); layerManagerNode.ImageIndex = 0; layerManagerNode.SelectedImageIndex = 0; layerManagerNode.Checked = true; layerManagerNode.Text = "图层管理"; layerTree.Nodes.Add(layerManagerNode); terrainManagerNode = new TreeNode(); terrainManagerNode.ImageIndex = 0; terrainManagerNode.SelectedImageIndex = 0; terrainManagerNode.Checked = true; terrainManagerNode.Text = "地形管理"; layerTree.Nodes.Add(terrainManagerNode); ReadKmlToMemoryLayer(Path.GetDirectoryName(Application.ExecutablePath) + "/MyPlace.kml"); RefreshDataTree(); globeControl1.Globe.FlyAlongLineSpeed = m_dFlyAlongLineSpeed; globeControl1.Globe.FlyAlongLineRotateSpeed = m_dFlyAlongLineRotateSpeed; ActionToolMenuChecked(); //修改状态栏 globeControl1.Globe.StatusBar.SetTextVisible(EnumStatusBarText.ProCoord, false); globeControl1.Globe.StatusBar.SetTextVisible(EnumStatusBarText.TerrainHeight, false); // 加上这句Mouseover、MouseInto、MouseOut才会有反应 globeControl1.Globe.FeatureMouseOverEnable = true; MenuItemMouseOverEventEnable.Checked = true; globeControl1.Globe.FeatureMouseOverHighLight=false; EnableMouseOverHighLightMenu.Checked = false; CameraNavigationMenu.Checked = true; AntiAntialiasingMenuItem.Checked = globeControl1.Globe.Antialiasing; globeControl1.Globe.ModelRenderDetail = EnumRenderDetail.Texture; ModelTextureMenuItem.Checked = true; globeControl1.Globe.HighlightEntityStyle3D.EntityColor = Color.FromArgb(255, 255, 255, 0); // 沿线飞行 globeControl1.Globe.FlyAlongLineSpeed = 50; //单位:m/s globeControl1.Globe.FlyAlongLineRotateSpeed = 50; // 单位:度/s globeControl1.Globe.FlyToPointSpeed = 2 * globeControl1.Globe.FlyToPointSpeed; //状态栏的显示内容 statusStrip1.Items[1].Text = "当前目标图层:" + "我的地标"; }