예제 #1
0
        /// <summary>
        /// 添加地标
        /// </summary>
        private bool AddMarker(string name, double lon, double lat, string path, string description, GSOLayer layer)
        {
            try
            {
                GSOFeature       newFeature = new GSOFeature();
                GSOGeoMarker     p          = new GSOGeoMarker();
                GSOMarkerStyle3D style      = new GSOMarkerStyle3D();

                style.IconPath         = path;
                p.Style                = style;
                p.X                    = lon;
                p.Y                    = lat;
                p.Text                 = name.Substring(0, name.Length - 4);
                p.AltitudeMode         = EnumAltitudeMode.ClampToGround;
                newFeature.Geometry    = p;
                newFeature.Name        = name;
                newFeature.Description = description + " ";
                layer.AddFeature(newFeature);
                return(true);
            }
            catch (Exception e)
            {
                e.GetType();
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 创建点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddPoint_Click(object sender, EventArgs e)
        {
            GSOGeoMarker point = new GSOGeoMarker();                                          //创建点对象

            point.X            = 120.417888231016;                                            //设置点X的值,单位为度
            point.Y            = 31.3283140323302;                                            //设置点Y的值,单位为度
            point.Z            = 20;                                                          //设置点Z的值,单位为米
            point.AltitudeMode = EnumAltitudeMode.RelativeToGround;                           //设置点的高程模式,设置为相对地面。则点的为(X,Y)处地面高程上方100米(point.Z = 100)
            point.Text         = "中科图新";                                                      //设置点对象显示的文字
            GSOMarkerStyle3D mstyle = new GSOMarkerStyle3D();                                 //新建点样式

            mstyle.IconPath = Application.StartupPath + "\\Resource\\image\\DefaultIcon.png"; //设置图标路径
            point.Style     = mstyle;                                                         //把显示风格
            GSOFeature feature = new GSOFeature();                                            //创建几何要素

            feature.Geometry = point;                                                         //把点赋予集合要素
            feature.Name     = point.Text;                                                    //赋予名字
            globeControl1.Globe.MemoryLayer.AddFeature(feature);                              //将要素添加到图层中

            //下面不属于工程内容,只是飞到点的位置
            GSOCameraState cs = new GSOCameraState();

            cs.Longitude = point.X;
            cs.Latitude  = point.Y;
            cs.Altitude  = 1000;
            globeControl1.Globe.FlyToCameraState(cs);
        }
예제 #3
0
        private void txtNewChange()
        {
            decimal x;
            decimal y;

            if (txtNewLon.Text.Trim() == "")
            {
                txtNewLon.Text = 0 + "";
            }
            bool bl = decimal.TryParse(txtNewLon.Text.Trim(), out x);

            if (!bl)
            {
                MessageBox.Show("数据不符合要求!");
                return;
            }

            if (txtNewLat.Text.Trim() == "")
            {
                txtNewLat.Text = 0 + "";
            }
            bl = decimal.TryParse(txtNewLat.Text.Trim(), out y);
            if (!bl)
            {
                MessageBox.Show("数据不符合要求!");
                return;
            }

            GSOPoint3d point = ctl.Globe.ScreenToScene((int)Math.Round(x), (int)Math.Round(y));

            if (endFeat == null || endFeat.IsDeleted)
            {
                endFeat = new GSOFeature();
                GSOGeoMarker     p     = new GSOGeoMarker();
                GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                p.Style        = style;
                p.AltitudeMode = EnumAltitudeMode.ClampToGround;

                endFeat.Name     = "目标点";
                endFeat.CustomID = 001;

                p.X = (double)Math.Round(x);
                p.Y = (double)Math.Round(y);
                p.Z = 0;
                endFeat.Geometry = p;
                endFeat          = ctl.Globe.MemoryLayer.AddFeature(endFeat);
            }
            else
            {
                GSOGeoPoint3D endpoint = endFeat.Geometry as GSOGeoPoint3D;
                if (endpoint != null)
                {
                    endpoint.X = (double)Math.Round(x);
                    endpoint.Y = (double)Math.Round(y);
                    endpoint.Z = 0;
                }
            }
            ctl.Refresh();
        }
예제 #4
0
        private void globeControl1_MouseUp(object sender, MouseEventArgs e)
        {
            if (MouseDown != e.Location)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (globeControl1.Globe.Action == EnumAction3D.NormalHit)
                {
                    GSOPoint3d point3d = new GSOPoint3d();

                    GSOFeature       newFeature = new GSOFeature();
                    GSOGeoMarker     p          = new GSOGeoMarker();
                    GSOMarkerStyle3D style      = new GSOMarkerStyle3D();
                    style.IconPath = Application.StartupPath + "/Resource/image/DefaultIcon.png";
                    p.Style        = style;
                    p.Z            = point3d.Z <= 0 ? 0 : point3d.Z;
                    if (point3d.Z <= 0.0)
                    {
                        point3d = globeControl1.Globe.ScreenToScene(e.X, e.Y);
                    }
                    p.X = point3d.X;
                    p.Y = point3d.Y;
                    p.Z = point3d.Z;
                    newFeature.Geometry = p;
                    newFeature.Name     = "我的地标";

                    globeControl1.Globe.MemoryLayer.AddFeature(newFeature);
                    globeControl1.Globe.Action = EnumAction3D.ActionNull;
                }
                //开始判断是否是缓冲区分析
                else if (globeControl1.Globe.Action == EnumAction3D.SelectObject)
                {
                    if (mouseClickType == "缓冲区创建")
                    {
                        //获取选中要素
                        GSOFeature feature = globeControl1.Globe.SelectedObject;
                        if (feature == null || feature.Geometry == null)
                        {
                            MessageBox.Show("请选择一个目标");
                            return;
                        }
                        if (feature.Geometry.Type != EnumGeometryType.GeoMarker &&
                            feature.Geometry.Type != EnumGeometryType.GeoPolyline3D &&
                            feature.Geometry.Type != EnumGeometryType.GeoPolygon3D)
                        {
                            MessageBox.Show("请选择一个点、线、面对象!", "提示");
                            return;
                        }
                        globeControl1.Globe.Action = EnumAction3D.ActionNull;
                        makeBuffer(feature);
                    }
                }
            }
        }
예제 #5
0
        public Form1()
        {
            InitializeComponent();

            globeControl1 = new GSOGlobeControl();
            panel1.Controls.Add(globeControl1);
            globeControl1.Dock = DockStyle.Fill;

            //鼠标按下事件,获取坐标
            globeControl1.MouseDown += (sender, e) =>
            {
                Location_MouseDown = e.Location;
            };

            globeControl1.MouseUp += (sender, e) =>
            {
                //鼠标抬起如果坐标不能对上,就认定为拖动球,不反应
                if (Location_MouseDown != e.Location)
                {
                    return;
                }

                if (e.Button == MouseButtons.Left)
                {
                    //如果按照上面示例按我们方法添加HUD,需要加上这个判断,判断是否点在HUD中
                    //if (isMouseInHudControl == false)
                    {
                        if (globeControl1.Globe.Action == EnumAction3D.NormalHit)
                        {
                            GSOPoint3d point3d = new GSOPoint3d();

                            GSOFeature       newFeature = new GSOFeature();
                            GSOGeoMarker     p          = new GSOGeoMarker();
                            GSOMarkerStyle3D style      = new GSOMarkerStyle3D();
                            style.IconPath = Application.StartupPath + "/Resource/image/DefaultIcon.png";
                            p.Style        = style;
                            p.Z            = point3d.Z <= 0 ? 0 : point3d.Z;
                            if (point3d.Z <= 0.0)
                            {
                                point3d = globeControl1.Globe.ScreenToScene(e.X, e.Y);
                            }
                            p.X = point3d.X;
                            p.Y = point3d.Y;
                            p.Z = point3d.Z;
                            newFeature.Geometry = p;
                            newFeature.Name     = "我的地标";

                            globeControl1.Globe.MemoryLayer.AddFeature(newFeature);
                            globeControl1.Globe.Action = EnumAction3D.ActionNull;
                        }
                    }
                }
            };
        }
        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);
                    }
                }
            }
        }
예제 #7
0
        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();
        }
        private void CheckSelFeaturePoint()
        {
            if (m_nCurSelected >= 0 && m_nCurSelected < listViewNodeList.Items.Count)
            {
                GSOGeoPoint3D geoPoint3D = null;
                if (m_FeatureSelPoint == null || m_FeatureSelPoint.IsDeleted)
                {
                    m_FeatureSelPoint = new GSOFeature();
                    geoPoint3D        = new GSOGeoMarker();
                    GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                    style.IconPath   = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                    geoPoint3D.Style = style;

                    m_FeatureSelPoint.Geometry = geoPoint3D;
                    if (m_GlobeControl != null)
                    {
                        m_GlobeControl.Globe.MemoryLayer.AddFeature(m_FeatureSelPoint);
                        m_GlobeControl.Refresh();
                    }
                }

                /*
                 * else
                 * {
                 *  geoPoint3D = m_FeatureSelPoint.Geometry as GSOGeoPoint3D;
                 * }
                 */


                geoPoint3D = m_FeatureSelPoint.Geometry as GSOGeoPoint3D;
                geoPoint3D.AltitudeMode = m_Geometry.AltitudeMode;

                try
                {
                    ListViewItem itemSel = listViewNodeList.Items[m_nCurSelected];
                    geoPoint3D.X = Double.Parse(itemSel.SubItems[1].Text);
                    geoPoint3D.Y = Double.Parse(itemSel.SubItems[2].Text);
                    geoPoint3D.Z = Double.Parse(itemSel.SubItems[3].Text);
                }
                catch (System.Exception exp)
                {
                    Log.PublishTxt(exp);
                }
                if (m_GlobeControl != null)
                {
                    m_GlobeControl.Refresh();
                }
            }
        }
 private void numericUpDownIconScale_ValueChanged(object sender, EventArgs e)
 {
     if (m_Geometry != null)
     {
         GSOMarkerStyle3D markerStyle = m_Geometry.Style as GSOMarkerStyle3D;
         if (markerStyle != null)
         {
             markerStyle.IconScale = Convert.ToDouble(numericUpDownIconScale.Value);
         }
         if (m_GlobeControl != null)
         {
             m_GlobeControl.Refresh();
         }
     }
 }
예제 #10
0
 private void iconColorChanged()
 {
     if (m_Geometry != null)
     {
         GSOMarkerStyle3D markerStyle = m_Geometry.Style as GSOMarkerStyle3D;
         if (markerStyle != null)
         {
             markerStyle.IconColor = Color.FromArgb(Convert.ToByte(numericUpDownIconOpaque.Value), pictureBoxIconColor.BackColor);;
         }
         if (m_GlobeControl != null)
         {
             m_GlobeControl.Refresh();
         }
     }
 }
예제 #11
0
        // 点
        private void btn_point_Click(object sender, System.EventArgs e)
        {
            GSOGeoMarker point = new GSOGeoMarker(); //创建点对象

            point.X            = 120.417888231016;   //设置点X的值
            point.Y            = 31.3283140323302;   //设置点Y的值
            point.Z            = 0;                  //设置点Z的值,单位为米
            point.AltitudeMode = EnumAltitudeMode.RelativeToGround;
            point.Text         = "中科图新";             //设置点对象显示的文字

            GSOMarkerStyle3D style = new GSOMarkerStyle3D();

            style.IconPath = IconPath;                  //设置图标
            point.Style    = style;

            AddNewGeoToLayer(point, "点");
        }
예제 #12
0
        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();
                    }
                }
            }
        }
예제 #13
0
 private void textColorChanged()
 {
     if (m_Geometry != null)
     {
         GSOMarkerStyle3D markerStyle = m_Geometry.Style as GSOMarkerStyle3D;
         if (markerStyle != null)
         {
             if (markerStyle.TextStyle == null)
             {
                 markerStyle.TextStyle = new GSOTextStyle();
             }
             markerStyle.TextStyle.ForeColor = Color.FromArgb(Convert.ToByte(numericUpDownTextOpaque.Value), pictureBoxTextColor.BackColor);;
         }
         if (m_GlobeControl != null)
         {
             m_GlobeControl.Refresh();
         }
     }
 }
예제 #14
0
        private void AddPoint()
        {
            GSOGeoMarker point = new GSOGeoMarker();                                          //创建点对象

            point.X            = 120.417888231016;                                            //设置点X的值,单位为度
            point.Y            = 31.3283140323302;                                            //设置点Y的值,单位为度
            point.Z            = 20;                                                          //设置点Z的值,单位为米
            point.AltitudeMode = EnumAltitudeMode.RelativeToGround;                           //设置点的高程模式,设置为相对地面。则点的为(X,Y)处地面高程上方100米(point.Z = 100)
            point.Text         = "中科图新";                                                      //设置点对象显示的文字
            GSOMarkerStyle3D mstyle = new GSOMarkerStyle3D();                                 //新建点样式

            mstyle.IconPath = Application.StartupPath + "\\Resource\\image\\DefaultIcon.png"; //设置图标路径
            point.Style     = mstyle;                                                         //把显示风格
            GSOFeature feature = new GSOFeature();                                            //创建几何要素

            feature.Geometry    = point;                                                      //把点赋予集合要素
            feature.Name        = point.Text;                                                 //赋予名字
            feature.Description = string.Format("<img src=\"{0}\">", Application.StartupPath + "\\Resource\\image\\Balloon\\Balloon.png");

            globeControl1.Globe.MemoryLayer.AddFeature(feature);//将要素添加到图层中
        }
예제 #15
0
        // 动态标注
        private void btn_DynamicMarker_Click(object sender, EventArgs e)
        {
            GSOGeoDynamicMarker marker = new GSOGeoDynamicMarker();

            //设置标注位置
            marker.Position = new GSOPoint3d(120.4178, 31.328, 0);
            //标注模式:依附模型表面
            marker.AltitudeMode  = EnumAltitudeMode.ClampToModel;
            marker.TimerInterval = 50000;
            marker.PlaySpeed     = 10; //运动速度
            marker.Play();             //播放
            //marker.Stop();//停止动画

            GSOMarkerStyle3D markerStyle = new GSOMarkerStyle3D();

            //设置显示图片位置(.gif动态图)
            markerStyle.IconPath
                = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "image/flag1.gif");
            markerStyle.IconScale = 4;           //图片显示缩放倍数
            marker.Style          = markerStyle; //将Style赋给marker

            AddNewGeoToLayer(marker, "动态标注");
        }
예제 #16
0
        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();
        }
예제 #17
0
        void ctl_MouseUp(object sender, MouseEventArgs e)
        {
            //判断鼠标为左键点击,并排除用左键移动球体的动作(通过MouseDown时与MouseUp时鼠标屏幕坐标比较)
            if (e.Button == MouseButtons.Left && e.Location == _locationPoint)
            {
                GSOLayer   layer;
                GSOPoint3d point;
                //获取三维空间鼠标点击事件的空间点坐标
                _glbControl.Globe.HitTest(e.X, e.Y, out layer, out point, false, false, 0);

                //有可能并没有点击到图层上,因此需要将点击的屏幕坐标转换成球面坐标
                if (point.X == 0.0 || point.Y == 0.0)
                {
                    point = this._glbControl.Globe.ScreenToScene(e.X, e.Y);
                }
                if (point.Z < 0)
                {
                    point.Z = 0;
                }
                //todo:还需要对获取的坐标值的范围进行判断(由于视角的原因,获取到的坐标有可能非法)
                //给当前激活textBox赋值
                _actX.Text = point.X.ToString();
                _actY.Text = point.Y.ToString();

                //新建Feature
                var featurePoint       = new GSOFeature();
                GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                GSOGeoMarker     p     = new GSOGeoMarker();
                style.IconPath = _pointImagePath;
                p.Style        = style;
                p.AltitudeMode = EnumAltitudeMode.Absolute;
                p.X            = point.X;
                p.Y            = point.Y;
                p.Z            = point.Z;

                if (_isBegin)
                {
                    _startFeat          = featurePoint;
                    p.Text              = "起点";
                    _startFeat.Name     = "起点";
                    _startFeat.Geometry = p;
                }
                else
                {
                    _endFeat          = featurePoint;
                    p.Text            = "终点";
                    _endFeat.Name     = "终点";
                    _endFeat.Geometry = p;
                }
                var features = _glbControl.Globe.MemoryLayer.GetFeatureByName(featurePoint.Name, true);
                if (features != null && features.Length > 0)
                {
                    for (int i = 0; i < features.Length; i++)
                    {
                        _glbControl.Globe.MemoryLayer.RemoveFeatureByID(features[i].ID);
                    }
                }
                _glbControl.Globe.MemoryLayer.AddFeature(featurePoint);
                _glbControl.Refresh();
                BackGlobState();
            }
        }
예제 #18
0
파일: MainFrm.cs 프로젝트: StarU/qkKL6Dgf12
        private void MenuItemAddDynamicMarker_Click(object sender, EventArgs e)
        {
            GSOFeature newFeature = new GSOFeature();
            GSOGeoDynamicMarker geoDynamicMarker = new GSOGeoDynamicMarker();
            GSOCameraState cameraState = globeControl1.Globe.CameraState;
            geoDynamicMarker.SetPosition(cameraState.Longitude, cameraState.Latitude, 0);
            geoDynamicMarker.TimerInterval = 20;
            geoDynamicMarker.Play();

            GSOMarkerStyle3D style3d = new GSOMarkerStyle3D();
            style3d.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/gif/flag1.gif";
            style3d.IconScale = 2;
            geoDynamicMarker.Style = style3d;
            newFeature.Geometry = geoDynamicMarker;
            newFeature.Name = "动态地标";

            ShowAddFeatureDlg(newFeature);
        }
        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;
                    }
                }
            }
        }
예제 #21
0
파일: MainFrm.cs 프로젝트: StarU/qkKL6Dgf12
        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;
                }
            }
        }
예제 #22
0
        private void CheckSelFeaturePoint()
        {
            if (m_nCurSelected >= 0 && m_nCurSelected < listViewNodeList.Items.Count)
            {
                GSOGeoPoint3D geoPoint3D = null;
                if (m_FeatureSelPoint == null || m_FeatureSelPoint.IsDeleted)
                {
                    m_FeatureSelPoint = new GSOFeature();
                    geoPoint3D = new GSOGeoMarker();
                    GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                    style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                    geoPoint3D.Style = style;

                    m_FeatureSelPoint.Geometry = geoPoint3D;
                    if (m_GlobeControl!=null)
                    {
                        m_GlobeControl.Globe.MemoryLayer.AddFeature(m_FeatureSelPoint);
                        m_GlobeControl.Refresh();
                    }
                }
                /*
                else
                {
                    geoPoint3D = m_FeatureSelPoint.Geometry as GSOGeoPoint3D;
                }
                */

                geoPoint3D = m_FeatureSelPoint.Geometry as GSOGeoPoint3D;
                geoPoint3D.AltitudeMode = m_Geometry.AltitudeMode;

                try
                {
                    ListViewItem itemSel = listViewNodeList.Items[m_nCurSelected];
                    geoPoint3D.X = Double.Parse(itemSel.SubItems[1].Text);
                    geoPoint3D.Y = Double.Parse(itemSel.SubItems[2].Text);
                    geoPoint3D.Z = Double.Parse(itemSel.SubItems[3].Text);
                }
                catch (System.Exception exp)
                {
                    Log.PublishTxt(exp);
                }
                if (m_GlobeControl != null)
                {
                    m_GlobeControl.Refresh();
                }

            }
        }
예제 #23
0
파일: MainFrm.cs 프로젝트: StarU/qkKL6Dgf12
 private void AddPlaceMarkMenu_Click(object sender, EventArgs e)
 {
     GSOFeature newFeature = new GSOFeature();
     GSOGeoMarker p = new GSOGeoMarker();
     GSOMarkerStyle3D style = new GSOMarkerStyle3D();
     style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/DefaultIcon.png";
     p.Style = style;
     p.X = globeControl1.Globe.CameraState.Longitude;
     p.Y = globeControl1.Globe.CameraState.Latitude;
     newFeature.Geometry = p;
     newFeature.Name = "我的地标";
     ShowAddFeatureDlg(newFeature);
 }
예제 #24
0
        private void btnCreateModel_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtModelLayer.Text))
                {
                    MessageBox.Show("文件路径无效!", "提示");
                    return;
                }
                if (File.Exists(txtModelLayer.Text))
                {
                    MessageBox.Show("文件已存在!", "提示");
                    return;
                }

                GSOLayer sourceLayer = ctl.Globe.Layers[cmbLayer.SelectedIndex];

                GSOLayer layer = ctl.Globe.Layers.Add(txtModelLayer.Text);
                lgdFilePath = txtModelLayer.Text;
                if (layer != null)
                {
                    GSOFeatures features = sourceLayer.GetAllFeatures();

                    for (int j = 0; j < features.Length; j++)
                    {
                        GSOFeature f = features[j];
                        GSOFeature newFeature = new GSOFeature();

                        string text = "";
                        if (combLabel.SelectedItem != null)
                        {
                            text = f.GetFieldAsString(combLabel.SelectedItem.ToString());
                        }
                        if (listFields.CheckedItems.Count > 0)
                        {
                            newFeature.Description = GetBubbleInfo(f, numWidth.Value.ToString(), numHeight.Value.ToString());
                        }

                        if (f.Geometry is GSOGeoPoint3D)
                        {
                            GSOGeoMarker marker = new GSOGeoMarker();
                            marker.Position = f.Geometry.GeoCenterPoint;
                            marker.Text = text;
                            GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                            style.IconPath = Application.StartupPath + "\\Resource\\ddd.png";
                            marker.Style = style;
                            newFeature.Geometry = marker;
                        }
                        else if(f.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                        {
                            GSOGeoPolyline3D line = (GSOGeoPolyline3D)f.Geometry.Clone();
                            GSOLabel label = new GSOLabel();
                            label.Text = text;
                            GSOLabelStyle style = new GSOLabelStyle();
                            style.HasTracktionLine = false;
                            style.OutlineColor = Color.Transparent;
                            style.MaxVisibleDistance = 100000;
                            label.Style = style;
                            line.Label = label;
                            newFeature.Geometry = line;
                        }
                        else if (f.Geometry.Type == EnumGeometryType.GeoPolygon3D)
                        {
                            GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)f.Geometry.Clone();
                            GSOLabel label = new GSOLabel();
                            label.Text = text;
                            GSOLabelStyle style = new GSOLabelStyle();
                            style.HasTracktionLine = false;
                            style.OutlineColor = Color.Transparent;
                            style.MaxVisibleDistance = 100000;
                            label.Style = style;
                            polygon.Label = label;
                            newFeature.Geometry = polygon;
                        }
                        newFeature.Name = text;
                        layer.AddFeature(newFeature);
                    }
                }
                ctl.Refresh();
                layer.Save();

                //ctl.Globe.Layers.Remove(layer);

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #25
0
        void ctl_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                GSOPoint3d point = ctl.Globe.ScreenToScene(e.X, e.Y);
                if (radioOld.Checked)
                {
                    txtOldLon.Text = point.X.ToString();
                    txtOldLat.Text = point.Y.ToString();

                    if (startFeat == null || startFeat.IsDeleted)
                    {
                        startFeat = new GSOFeature();
                        GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                        GSOGeoMarker p = new GSOGeoMarker();
                        style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                        p.Style = style;
                        p.AltitudeMode = EnumAltitudeMode.ClampToGround;
                        p.X = point.X;
                        p.Y = point.Y;
                        p.Z = point.Z;
                        startFeat.Name = "起点";
                        startFeat.CustomID = 000;
                        startFeat.Geometry = p;

                        startFeat = ctl.Globe.MemoryLayer.AddFeature(startFeat);
                    }
                    else
                    {
                        GSOGeoPoint3D startpoint = startFeat.Geometry as GSOGeoPoint3D;
                        if (startpoint != null)
                        {
                            startpoint.X = point.X;
                            startpoint.Y = point.Y;
                            startpoint.Z = 0;
                        }
                    }
                }
                else
                {
                    txtNewLon.Text = point.X.ToString();
                    txtNewLat.Text = point.Y.ToString();

                    if (endFeat == null || endFeat.IsDeleted)
                    {
                        endFeat = new GSOFeature();
                        GSOGeoMarker p = new GSOGeoMarker();
                        GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                        style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                        p.Style = style;
                        p.AltitudeMode = EnumAltitudeMode.ClampToGround;

                        endFeat.Name = "目标点";
                        endFeat.CustomID = 001;

                        p.X = point.X;
                        p.Y = point.Y;
                        p.Z = point.Z;
                        endFeat.Geometry = p;
                        endFeat = ctl.Globe.MemoryLayer.AddFeature(endFeat);
                    }
                    else
                    {
                        GSOGeoPoint3D endpoint = endFeat.Geometry as GSOGeoPoint3D;
                        if (endpoint != null)
                        {
                            endpoint.X = point.X;
                            endpoint.Y = point.Y;
                            endpoint.Z = 0;
                        }
                    }
                }
                ctl.Refresh();
            }
        }
예제 #26
0
파일: MainFrm.cs 프로젝트: StarU/qkKL6Dgf12
        private void ConnexityAnalysis()
        {
            GSODataset curCAYDataset = m_ConnexityAnalysisFirstLayer.Dataset;
            string srName = curCAYDataset.Name;
            GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset;
            if (curCAYNDataset == null)
            {
                MessageBox.Show("该图层没有创建网络拓扑,请先创建网络拓扑信息再进行分析!", "提示");
                return;
            }

            int[] arryResID;
            curCAYNDataset.ConnexityAnalysis(m_ConnexityAnalysisFirstFeature.ID, m_ConnexityAnaylsisSecondFeature.ID, out arryResID, false, true);
            m_ConnexityAnalyResFeatures = m_ConnexityAnalysisFirstLayer.GetFeaturesByIDs(arryResID);
            if (m_ConnexityAnalyResFeatures == null || m_ConnexityAnalyResFeatures.Length < 1)
            {
                String strLine1 = "管线:" + m_ConnexityAnalysisFirstFeature.ID;
                String strLine2 = "管线:" + m_ConnexityAnaylsisSecondFeature.ID;
                MessageBox.Show(strLine1 + " 与 " + strLine2 + " 不连通", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            else
            {
                int nCount = m_ConnexityAnalyResFeatures.Length;
                GSOGeoPolyline3D effectLine = new GSOGeoPolyline3D();
                GSOPoint3ds effectPart = new GSOPoint3ds();
                for (int i = 0; i < nCount; i++)
                {
                    m_ConnexityAnalyResFeatures[i].HighLight = true;
                    GSOGeoPolyline3D geoline = m_ConnexityAnalyResFeatures[i].Geometry as GSOGeoPolyline3D;
                    if (geoline != null)
                    {
                        //管线显示流动效果
                        for (int j = 0; j < geoline.PartCount; j++)
                        {
                            effectLine.AddPart(geoline[j]);
                        }
                    }
                }
                effectLine.SmoothToSpline();
                GSOFeature feature = new GSOFeature();
                feature.Geometry = effectLine;
                if (feature.Geometry.Style == null)
                {
                    feature.Geometry.Style = new GSOSimpleLineStyle3D();
                }
                feature.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround;
                ((GSOStyle3D)feature.Geometry.Style).UsingBlur = true;
                globeControl1.Globe.MemoryLayer.AddFeature(feature);

                GSOAniFeature featureAnimation = new GSOAniFeature();//动画的类型--要素动画
                featureAnimation.Feature = feature;                  //动画的关联对象

                GSOGeoMarker marker = new GSOGeoMarker(0, 0, 0,"");
                GSOMarkerStyle3D markerStyle = new GSOMarkerStyle3D();
                markerStyle.IconPath = Application.StartupPath + "/Resource/image/star4.bmp";
                marker.Style = markerStyle;
                marker.AltitudeMode = EnumAltitudeMode.RelativeToGround;
                GSOFeature markerFeature = new GSOFeature();
                markerFeature.Geometry = marker;

                GSOAniEffectLineGrow effect = new GSOAniEffectLineGrow();//动画效果-线增长动画
                effect.StartValue = 0;
                effect.EndValue = 1;
                effect.FrameCount = 1200;
                effect.RepeatCount = 1;
                effect.IsSmooth = false;
                effect.ActorFeature = markerFeature;

                GSOAniKeyFrame keyFream = new GSOAniKeyFrame(); //关键帧
                keyFream.Frame = 0;
                keyFream.AddEffect(effect);                     //给关键帧添加动画效果

                GSOAniObjTimeLine timeLine = new GSOAniObjTimeLine();//动画对象
                timeLine.Name = "线增长动画对象";
                timeLine.AniObject = featureAnimation;               //动画对象的动画类型
                timeLine.AddKeyFrame(keyFream);                      //给动画对象添加关键帧

                GSOAnimationPage page = new GSOAnimationPage();      //动画
                page.FPS = 60;                                       //动画--帧率
                page.FrameCount = 20 * 60; //动画时长 * 帧率         //动画--帧总数
                page.Name = "线增长动画";
                page.AddObjTimeLine(timeLine);                       //给动画添加动画对象

                globeControl1.Globe.AnimationPages.Add(page);

                globeControl1.Globe.AnimationPages.GetAt(globeControl1.Globe.AnimationPages.Length - 1).Play();

                globeControl1.Refresh();
            }
        }
예제 #27
0
        void ctl_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                GSOPoint3d point = ctl.Globe.ScreenToScene(e.X, e.Y);
                if (radioOld.Checked)
                {
                    txtOldLon.Text = point.X.ToString();
                    txtOldLat.Text = point.Y.ToString();

                    if (startFeat == null || startFeat.IsDeleted)
                    {
                        startFeat = new GSOFeature();
                        GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                        GSOGeoMarker     p     = new GSOGeoMarker();
                        style.IconPath     = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                        p.Style            = style;
                        p.AltitudeMode     = EnumAltitudeMode.ClampToGround;
                        p.X                = point.X;
                        p.Y                = point.Y;
                        p.Z                = point.Z;
                        startFeat.Name     = "起点";
                        startFeat.CustomID = 000;
                        startFeat.Geometry = p;

                        startFeat = ctl.Globe.MemoryLayer.AddFeature(startFeat);
                    }
                    else
                    {
                        GSOGeoPoint3D startpoint = startFeat.Geometry as GSOGeoPoint3D;
                        if (startpoint != null)
                        {
                            startpoint.X = point.X;
                            startpoint.Y = point.Y;
                            startpoint.Z = 0;
                        }
                    }
                }
                else
                {
                    txtNewLon.Text = point.X.ToString();
                    txtNewLat.Text = point.Y.ToString();

                    if (endFeat == null || endFeat.IsDeleted)
                    {
                        endFeat = new GSOFeature();
                        GSOGeoMarker     p     = new GSOGeoMarker();
                        GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                        style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                        p.Style        = style;
                        p.AltitudeMode = EnumAltitudeMode.ClampToGround;

                        endFeat.Name     = "目标点";
                        endFeat.CustomID = 001;

                        p.X = point.X;
                        p.Y = point.Y;
                        p.Z = point.Z;
                        endFeat.Geometry = p;
                        endFeat          = ctl.Globe.MemoryLayer.AddFeature(endFeat);
                    }
                    else
                    {
                        GSOGeoPoint3D endpoint = endFeat.Geometry as GSOGeoPoint3D;
                        if (endpoint != null)
                        {
                            endpoint.X = point.X;
                            endpoint.Y = point.Y;
                            endpoint.Z = 0;
                        }
                    }
                }
                ctl.Refresh();
            }
        }
예제 #28
0
        private void btnCreateModel_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtModelLayer.Text))
                {
                    MessageBox.Show("文件路径无效!", "提示");
                    return;
                }
                if (File.Exists(txtModelLayer.Text))
                {
                    MessageBox.Show("文件已存在!", "提示");
                    return;
                }

                GSOLayer sourceLayer = ctl.Globe.Layers[cmbLayer.SelectedIndex];

                GSOLayer layer = ctl.Globe.Layers.Add(txtModelLayer.Text);
                lgdFilePath = txtModelLayer.Text;
                if (layer != null)
                {
                    GSOFeatures features = sourceLayer.GetAllFeatures();

                    for (int j = 0; j < features.Length; j++)
                    {
                        GSOFeature f          = features[j];
                        GSOFeature newFeature = new GSOFeature();

                        string text = "";
                        if (combLabel.SelectedItem != null)
                        {
                            text = f.GetFieldAsString(combLabel.SelectedItem.ToString());
                        }
                        if (listFields.CheckedItems.Count > 0)
                        {
                            newFeature.Description = GetBubbleInfo(f, numWidth.Value.ToString(), numHeight.Value.ToString());
                        }

                        if (f.Geometry is GSOGeoPoint3D)
                        {
                            GSOGeoMarker marker = new GSOGeoMarker();
                            marker.Position = f.Geometry.GeoCenterPoint;
                            marker.Text     = text;
                            GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                            style.IconPath      = Application.StartupPath + "\\Resource\\ddd.png";
                            marker.Style        = style;
                            newFeature.Geometry = marker;
                        }
                        else if (f.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                        {
                            GSOGeoPolyline3D line  = (GSOGeoPolyline3D)f.Geometry.Clone();
                            GSOLabel         label = new GSOLabel();
                            label.Text = text;
                            GSOLabelStyle style = new GSOLabelStyle();
                            style.HasTracktionLine   = false;
                            style.OutlineColor       = Color.Transparent;
                            style.MaxVisibleDistance = 100000;
                            label.Style         = style;
                            line.Label          = label;
                            newFeature.Geometry = line;
                        }
                        else if (f.Geometry.Type == EnumGeometryType.GeoPolygon3D)
                        {
                            GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)f.Geometry.Clone();
                            GSOLabel        label   = new GSOLabel();
                            label.Text = text;
                            GSOLabelStyle style = new GSOLabelStyle();
                            style.HasTracktionLine   = false;
                            style.OutlineColor       = Color.Transparent;
                            style.MaxVisibleDistance = 100000;
                            label.Style         = style;
                            polygon.Label       = label;
                            newFeature.Geometry = polygon;
                        }
                        newFeature.Name = text;
                        layer.AddFeature(newFeature);
                    }
                }
                ctl.Refresh();
                layer.Save();

                //ctl.Globe.Layers.Remove(layer);

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #29
0
        private void txtOldChange()
        {
            decimal x;
            decimal y;
            if (txtOldLon.Text.Trim() == "")
            {
                txtOldLon.Text = 0 + "";
            }
            bool bl = decimal.TryParse(txtOldLon.Text.Trim(), out x);
            if (!bl)
            {
                MessageBox.Show("数据不符合要求!");
                return;
            }

            if (txtOldLat.Text.Trim() == "")
            {
                txtOldLat.Text = 0 + "";
            }
            bl = decimal.TryParse(txtOldLat.Text.Trim(), out y);
            if (!bl)
            {
                MessageBox.Show("数据不符合要求!");
                return;
            }

            if (startFeat == null || startFeat.IsDeleted)
            {
                startFeat = new GSOFeature();
                GSOMarkerStyle3D style = new GSOMarkerStyle3D();
                GSOGeoMarker p = new GSOGeoMarker();
                style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png";
                p.Style = style;
                p.AltitudeMode = EnumAltitudeMode.ClampToGround;
                p.X = (double)Math.Round(x);
                p.Y = (double)Math.Round(y);
                p.Z = 0;
                startFeat.Name = "起点";
                startFeat.CustomID = 000;
                startFeat.Geometry = p;

                startFeat = ctl.Globe.MemoryLayer.AddFeature(startFeat);
            }
            else
            {
                GSOGeoPoint3D startpoint = startFeat.Geometry as GSOGeoPoint3D;
                if (startpoint != null)
                {
                    startpoint.X = (double)Math.Round(x);
                    startpoint.Y = (double)Math.Round(y);
                    startpoint.Z = 0;
                }
            }
            ctl.Refresh();
        }
예제 #30
0
        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();
                     }

                 }

             }
        }