コード例 #1
0
 /// <summary>
 /// 显示轮廓线   张琪  20110629
 /// </summary>
 /// <param name="pPolygon"></param>
 private void ShowCountour(IPolygon pPolygon)
 {
     SysCommon.CProgress vProgress = new SysCommon.CProgress("进度条");
     try
     {
         Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, ContourName);
         if (!chkShowContour.Checked)
         {
             m_pCurrentSceneControl.SceneGraph.RefreshViewers();
             return;
         }
         vProgress.EnableCancel    = false;//设置进度条
         vProgress.ShowDescription = true;
         vProgress.FakeProgress    = true;
         vProgress.TopMost         = true;
         vProgress.ShowProgress();
         vProgress.SetProgress("正在绘制轮廓线");
         ITopologicalOperator pTopo     = pPolygon as ITopologicalOperator;
         IGeometry            pPolyLine = new PolylineClass();
         pPolyLine = pTopo.Boundary;
         object StepSize = Type.Missing;;
         m_SurFace.InterpolateShape(pPolyLine as IGeometry, out pPolyLine, ref StepSize);
         IGroupElement pGroup = null;
         //用于绘制三维效果
         Cls3DMarkDraw.AddSimpleGraphic(pPolyLine as IGeometry, Cls3DMarkDraw.getRGB(30, 255, 255), 4, ContourName, m_pCurrentSceneControl.Scene, pGroup);
         m_pCurrentSceneControl.SceneGraph.RefreshViewers();
         vProgress.Close();
     }
     catch
     {
         vProgress.Close();
     }
 }
コード例 #2
0
ファイル: frm3DSection.cs プロジェクト: siszoey/geosufan
 private void frm3DSection_FormClosing(object sender, FormClosingEventArgs e)
 {
     Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, sPolyOutlineName);//清除绘制的要素
     m_SurFace = null;
     m_pCurrentSceneControl.CurrentTool = null;
     this.Dispose();
 }
コード例 #3
0
 private void frm3DVolumeAreaSta_FormClosing(object sender, FormClosingEventArgs e)
 {
     Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, sRefPlaneName);
     Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, ContourName);
     m_pCurrentSceneControl.CurrentTool = null;//释放使用工具
     m_ScenePoly  = null;
     m_StaPolygon = null;
     m_SurFace    = null;
     this.Dispose();
 }
コード例 #4
0
 /// <summary>
 /// 显示参考面     张琪    20110629
 /// </summary>
 /// <param name="pPoly">参考多边形</param>
 private void ShowRefPlane(IPolygon pPoly)
 {
     SysCommon.CProgress vProgress = new SysCommon.CProgress("进度条");
     try
     {
         IGeometry pBoundary = new PolylineClass();
         pBoundary = null;
         IGeometry pPolygon = new PolygonClass();
         pPolygon = null;
         object StepSize = Type.Missing;
         m_SurFace.InterpolateShape(pPoly as IGeometry, out pPolygon, ref StepSize);
         Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, sRefPlaneName); //清除已有的参考面
         if (!chkShowLWRP.Checked)                                                             //当为false时不显示参考面
         {
             m_pCurrentSceneControl.SceneGraph.RefreshViewers();
             return;
         }
         vProgress.EnableCancel    = false;//设置进度条
         vProgress.ShowDescription = true;
         vProgress.FakeProgress    = true;
         vProgress.TopMost         = true;
         vProgress.ShowProgress();
         vProgress.SetProgress("正在绘制参考面");
         ITopologicalOperator pTopo = pPolygon as ITopologicalOperator;
         pBoundary = pTopo.Boundary as IPolyline;
         //设置Z值方向显示
         IZAware pZAware = pBoundary as IZAware;
         pZAware.ZAware = true;
         m_SurFace.InterpolateShape(pBoundary as IGeometry, out pBoundary, ref StepSize);
         m_SurFace.InterpolateShape(pPoly as IGeometry, out pPolygon, ref StepSize);
         IExtrude pExtrude = new GeometryEnvironmentClass();
         //获取参考面的多面体
         IMultiPatch pMultiPatchRefPlaneWall = pExtrude.ExtrudeAbsolute(Convert.ToDouble(txtPlaneHeight.Text), pBoundary as IGeometry) as IMultiPatch;
         pMultiPatchRefPlaneWall.SpatialReference = m_pCurrentSceneControl.Scene.SpatialReference;
         IZ pZ;
         pZAware        = pPolygon as IZAware;
         pZAware.ZAware = true;
         pZ             = pPolygon as IZ;
         pZ.SetConstantZ(Convert.ToDouble(txtPlaneHeight.Text));
         //用于绘制三维效果
         IGroupElement pGroup = null;
         Cls3DMarkDraw.AddSimpleGraphic(pMultiPatchRefPlaneWall as IGeometry, Cls3DMarkDraw.getRGB(71, 61, 255), 1, sRefPlaneName, m_pCurrentSceneControl.Scene, pGroup);
         Cls3DMarkDraw.AddSimpleGraphic(pPolygon as IGeometry, Cls3DMarkDraw.getRGB(71, 61, 255), 1, sRefPlaneName, m_pCurrentSceneControl.Scene, pGroup);
         m_pCurrentSceneControl.SceneGraph.RefreshViewers();
         vProgress.Close();
     }
     catch
     {
         vProgress.Close();
     }
 }
コード例 #5
0
ファイル: frm3DSection.cs プロジェクト: siszoey/geosufan
        private void DrawGeo_Click(object sender, EventArgs e)
        {
            //新建三维绘制工具
            Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, sPolyOutlineName);
            m_pCurrentSceneControl.SceneGraph.RefreshViewers();
            pTool3DDrawGeo.EndDtrawd   += new myEventHandler(pTool3DDrawGeo_EndDtrawd);
            pTool3DDrawGeo.GeometryType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryLine;
            pTool3DDrawGeo.pSurface     = m_SurFace;
            ICommand pCommad = pTool3DDrawGeo;

            pCommad.OnCreate(m_pCurrentSceneControl.Object);
            m_pCurrentSceneControl.CurrentTool = pCommad as ITool;
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog("两点间剖面分析,表面集为:" + comboBoxOpen.Text);//xisheng 日志记录07.08
            }
        }
コード例 #6
0
        /// <summary>
        /// 实例化绘制范围工具
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DrawGeo_Click(object sender, EventArgs e)
        {
            btncount.Enabled = false;
            Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, sRefPlaneName);
            Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, ContourName);
            m_pCurrentSceneControl.SceneGraph.RefreshViewers();
            //pTool3DDrawGeo.BeginDrawed += new myEventHandler(pTool3DDrawGeo_BeginDrawed);
            pTool3DDrawGeo.EndDtrawd   += new myEventHandler(pTool3DDrawGeo_EndDtrawd);
            pTool3DDrawGeo.GeometryType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon;
            pTool3DDrawGeo.pSurface     = m_SurFace;
            ICommand pCommad = pTool3DDrawGeo;

            pCommad.OnCreate(m_pCurrentSceneControl.Object);
            m_pCurrentSceneControl.CurrentTool = pCommad as ITool;
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog("局部填挖方分析,表面集为:" + comboBoxOpen.Text + ",基准面高度为:" + txtPlaneHeight.Text);
            }
        }
コード例 #7
0
        /// <summary>
        /// 双击表示绘制对象结束
        /// </summary>
        public override void OnDblClick()
        {
            ITopologicalOperator pTopoOp;

            if (m_pPointColl != null)
            {
                switch (m_DrawType.ToString())
                {
                case "esriGeometryLine":
                    IPointCollection pPolyLine = new PolylineClass();
                    pPolyLine.AddPointCollection(m_pPointColl);
                    pTopoOp = pPolyLine as ITopologicalOperator;
                    pTopoOp.Simplify();
                    m_Geometry = pPolyLine as IGeometry;
                    m_Geometry.SpatialReference = m_sceneHookHelper.Scene.SpatialReference;
                    Cls3DMarkDraw.DeleteAllElementsWithName(m_sceneHookHelper.Scene, sPolyOutlineName);
                    EndDtrawd(true);    //触发结束事件
                    break;

                case "esriGeometryPolygon":
                    if (m_pPointColl.PointCount < 3)
                    {
                        return;
                    }
                    IPointCollection pPolygon = new PolygonClass();
                    pPolygon.AddPointCollection(m_pPointColl);
                    pTopoOp = pPolygon as ITopologicalOperator;
                    pTopoOp.Simplify();
                    m_Geometry = pPolygon as IGeometry;
                    m_Geometry.SpatialReference = m_sceneHookHelper.Scene.SpatialReference;
                    Cls3DMarkDraw.DeleteAllElementsWithName(m_sceneHookHelper.Scene, sPolyOutlineName);
                    EndDtrawd(true);  //触发结束事件
                    break;
                }
                m_pPointColl = null;
            }
            //Cls3DMarkDraw.DeleteAllElementsWithName(m_sceneHookHelper.Scene, sPolyOutlineName);
            m_sceneHookHelper.SceneGraph.RefreshViewers();
        }
コード例 #8
0
        /// <summary>
        /// 获取点击地图上的点
        /// </summary>
        /// <param name="Button"></param>
        /// <param name="Shift"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            try
            {
                ESRI.ArcGIS.Geometry.IPoint pMapPoint = new ESRI.ArcGIS.Geometry.PointClass();;
                ISceneGraph pSceneGraph = m_sceneHookHelper.SceneGraph;
                object      pOwner;
                object      pObject;
                object      before   = Type.Missing;
                object      after    = Type.Missing;
                object      StepSize = Type.Missing;
                IDisplay3D  pDisplay;
                pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out pMapPoint, out pOwner, out pObject); //获取鼠标点击的位置并转化为地理坐标
                if (pMapPoint == null)
                {
                    return;
                }
                pMapPoint.Z = pMapPoint.Z / m_sceneHookHelper.Scene.ExaggerationFactor;
                pMapPoint.Z = m_psurface.GetElevation(pMapPoint);
                pMapPoint.SpatialReference = pSceneGraph.Scene.SpatialReference;
                pDisplay = m_sceneHookHelper.SceneGraph as IDisplay3D;
                pDisplay.FlashLocation(pMapPoint);//闪烁显示被点击的位置
                IGeometry pGeom = null;
                Cls3DMarkDraw.DeleteAllElementsWithName(m_sceneHookHelper.Scene, sPolyOutlineName);
                //根据绘制对象类型的不同定义不同的类型
                switch (m_DrawType.ToString())
                {
                case "esriGeometryPoint":
                    m_Geometry = pMapPoint;
                    break;

                case "esriGeometryLine":
                    if (m_pPointColl == null)
                    {
                        m_pPointColl = new PolylineClass();
                        pGeom        = new PolylineClass();
                    }
                    m_pPointColl.AddPoint(pMapPoint, ref before, ref after);
                    break;

                case "esriGeometryPolygon":
                    if (m_pPointColl == null)
                    {
                        m_pPointColl = new PolygonClass();
                        pGeom        = new PolygonClass();
                    }
                    m_pPointColl.AddPoint(pMapPoint, ref before, ref after);
                    break;
                }

                //BeginDrawed(true);

                IGroupElement pGroup = null;
                if (m_pPointColl.PointCount == 1)
                {
                    //当为一个点时绘制点
                    Cls3DMarkDraw.AddSimpleGraphic(pMapPoint, Cls3DMarkDraw.getRGB(71, 61, 255), 4, sPolyOutlineName, m_sceneHookHelper.Scene, pGroup);
                }
                else if (m_DrawType.ToString() == "esriGeometryLine")
                {
                    pGeom = m_pPointColl as IGeometry;
                    pGeom.SpatialReference = pMapPoint.SpatialReference;
                    m_psurface.InterpolateShape(pGeom, out pGeom, ref StepSize);
                    Cls3DMarkDraw.AddSimpleGraphic(pGeom, Cls3DMarkDraw.getRGB(71, 61, 255), 4, sPolyOutlineName, m_sceneHookHelper.Scene, pGroup);
                    m_pPointColl = pGeom as IPointCollection;
                }
                else
                {
                    ITopologicalOperator pTopo = m_pPointColl as ITopologicalOperator;
                    pGeom = pTopo.Boundary;
                    pGeom.SpatialReference = pMapPoint.SpatialReference;
                    m_psurface.InterpolateShape(pGeom, out pGeom, ref StepSize);
                    Cls3DMarkDraw.AddSimpleGraphic(pGeom, Cls3DMarkDraw.getRGB(71, 61, 255), 4, sPolyOutlineName, m_sceneHookHelper.Scene, pGroup);
                }

                m_sceneHookHelper.SceneGraph.RefreshViewers();
            }
            catch
            {
                return;
            }
        }
コード例 #9
0
        /// <summary>
        /// 获取分析图层及Surfer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBoxOpen_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxOpen.Items.Count > 0)
                {
                    label.Text = "";
                    Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, sRefPlaneName);
                    Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, ContourName);
                    m_pCurrentSceneControl.SceneGraph.RefreshViewers();
                    m_ScenePoly         = null;
                    m_StaPolygon        = null;
                    m_SurFace           = null;
                    txtArea2DSel.Text   = "";
                    txtAreaAbove.Text   = "";
                    txtAreaBelow.Text   = "";
                    txtPara.Text        = "";
                    txtPlaneHeight.Text = "";
                    txtVolumeAbove.Text = "";
                    txtVolumeBelow.Text = "";

                    DrawGeo.Enabled        = false;
                    sldPlaneHeight.Enabled = false;
                    btncount.Enabled       = false;
                    string LayerName = comboBoxOpen.SelectedItem.ToString();
                    ILayer pLayer    = GetLayerByName(ref LayerName);

                    if (pLayer is IRasterLayer)//读取Raster数据的ISurface
                    {
                        IRasterLayer      pRasterLayer = pLayer as IRasterLayer;
                        IGeoDataset       pDataset     = pRasterLayer as IGeoDataset;
                        ISpatialReference psr          = pDataset.SpatialReference;

                        if (!(psr is IProjectedCoordinateSystem))
                        {
                            label.Text = "该数据为地理坐标,计算结果无效仅供参考!";
                        }

                        IRasterSurface pRasterSurface = new RasterSurfaceClass();
                        pRasterSurface.PutRaster(pRasterLayer.Raster, 0);
                        m_SurFace       = pRasterSurface as ISurface;
                        DrawGeo.Enabled = false;
                        m_IsTin         = false;
                    }
                    else if (pLayer is ITinLayer)//读取TIN数据的ISurface
                    {
                        ITinLayer         pTinLayer = pLayer as ITinLayer;
                        IGeoDataset       pDataset  = pTinLayer as IGeoDataset;
                        ISpatialReference psr       = pDataset.SpatialReference;

                        if (!(psr is IProjectedCoordinateSystem))
                        {
                            label.Text = "该数据为地理坐标,计算结果无效仅供参考!";
                        }

                        m_SurFace       = pTinLayer.Dataset as ISurface;
                        m_IsTin         = true;
                        DrawGeo.Enabled = true;
                    }
                    if (m_SurFace == null)
                    {
                        MessageBox.Show("请选择需要进行分析的DEM数据", "提示!");
                        return;
                    }
                    if (m_StaPolygon == null)
                    {
                        if (m_SurFace is ITin)
                        {
                            ITin pTin = m_SurFace as ITin;
                            sldPlaneHeight.Maximum = Convert.ToInt32(pTin.Extent.ZMax);
                            sldPlaneHeight.Minimum = Convert.ToInt32(pTin.Extent.ZMin);
                        }
                        else
                        {
                            IRasterSurface    pRasterSurface   = m_SurFace as IRasterSurface;
                            IRasterStatistics pRasterStatistic = pRasterSurface.RasterBand.Statistics;
                            sldPlaneHeight.Maximum = Convert.ToInt32(pRasterStatistic.Maximum);
                            sldPlaneHeight.Minimum = Convert.ToInt32(pRasterStatistic.Minimum);
                        }
                        double Vale = sldPlaneHeight.Maximum + sldPlaneHeight.Minimum;
                        Vale = Vale / 2;
                        txtPlaneHeight.Text = Vale.ToString();
                        Vale = Convert.ToDouble(txtPlaneHeight.Text);
                        sldPlaneHeight.Value = Convert.ToInt32(Vale);
                    }
                    else
                    {
                        double zrange;
                        zrange = m_StaPolygon.Envelope.ZMax - m_StaPolygon.Envelope.ZMin;
                        sldPlaneHeight.Maximum = Convert.ToInt32(m_StaPolygon.Envelope.ZMax + zrange);
                        sldPlaneHeight.Minimum = Convert.ToInt32(m_StaPolygon.Envelope.ZMin);
                        sldPlaneHeight.Value   = Convert.ToInt32(Math.Round(m_StaPolygon.Envelope.ZMin + (zrange * 0.5)));
                        txtPlaneHeight.Text    = sldPlaneHeight.Value.ToString();
                    }
                    sldPlaneHeight.Enabled = true;
                    btncount.Enabled       = true;
                }
            }
            catch
            {
                return;
            }
        }
コード例 #10
0
ファイル: frm3DSection.cs プロジェクト: siszoey/geosufan
        private void DrawSectionPart()
        {
            try
            {
                if (m_SectionLine == null)
                {
                    return;
                }
                if (m_SurFace == null)
                {
                    return;
                }

                IGeometry pGeometry = new PolylineClass();
                object    pObject   = 1;
                m_SurFace.InterpolateShape(m_SectionLine, out pGeometry, ref pObject);
                IGroupElement pGroup = null;
                //用于绘制三维效果
                Cls3DMarkDraw.AddSimpleGraphic(pGeometry, Cls3DMarkDraw.getRGB(71, 61, 255), 4, sPolyOutlineName, m_pCurrentSceneControl.Scene, pGroup);
                m_pCurrentSceneControl.SceneGraph.RefreshViewers();

                double dblLength;
                object StepSize = Type.Missing;;
                m_SurFace.QuerySurfaceLength(pGeometry, out dblLength, ref StepSize);
                txtSurfaceLengh.Text = dblLength.ToString();
                IPolyline pLine = pGeometry as IPolyline;
                txtPreject.Text = pLine.Length.ToString();
                txtZmax.Text    = pLine.Envelope.ZMax.ToString();
                txtZmin.Text    = pLine.Envelope.ZMin.ToString();
                IPointCollection pPointCol = pLine as IPointCollection;
                IPolyline        pPolyline2;
                IPointCollection pPointCol2 = new PolylineClass();
                int    lLOOP;
                double dblminY, dblPery, dblPerx, dblMaxY;
                dblminY = pLine.Envelope.ZMin;
                dblMaxY = pLine.Envelope.ZMax;
                if ((pLine.Envelope.ZMax - pLine.Envelope.ZMin) == 0)
                {
                    return;
                }
                if (pLine.Length == 0)
                {
                    return;
                }

                //重新绘制底图
                Image    pImage  = new Bitmap(442, 230);
                Graphics m_mouse = Graphics.FromImage(pImage);
                //m_mouse.FillRectangle(Brushes.White,0,0,460,240);
                Pen pen1 = new Pen(Color.Black, 1);

                //绘制横坐标、纵坐标及其他两条边
                m_mouse.DrawLine(pen1, new PointF(55, 210), new PointF(55, 6));
                m_mouse.DrawLine(pen1, new PointF(55, 210), new PointF(431, 210));
                m_mouse.DrawLine(pen1, new PointF(55, 6), new PointF(431, 6));
                m_mouse.DrawLine(pen1, new PointF(431, 6), new PointF(431, 210));

                //Brush pBrush = new HatchBrush(HatchStyle.Percent70, Color.WhiteSmoke);
                m_mouse.FillRectangle(Brushes.White, 56, 7, 375, 203);       //填充区域及背景图
                //
                dblPery = 200 / (pLine.Envelope.ZMax - pLine.Envelope.ZMin); //将纵坐标的高度分线段的高程差段
                dblPerx = 368 / pLine.Length;                                //将横坐标的宽度分成线段长度份
                double x, y, x1, y1;
                x = 0;
                y = 0;
                object before = Type.Missing;
                object after  = Type.Missing;
                Pen    pen3   = new Pen(Color.Red, 2);

                Font         drawFont   = new Font("宋体", 8.0f, FontStyle.Regular);
                StringFormat drawFormat = new StringFormat();
                Brush        drawBrush  = new SolidBrush(Color.Black);

                drawFormat.FormatFlags = StringFormatFlags.DisplayFormatControl;
                //绘制横坐标刻度值
                for (int i = 0; i <= 4; i++)
                {
                    if (i == 0)
                    {
                        m_mouse.DrawString(i.ToString(), drawFont, Brushes.Black, new PointF(52, 214), drawFormat);
                    }
                    else
                    {
                        Single Lenvlae = Convert.ToSingle((pLine.Length / 4) * i);
                        m_mouse.DrawLine(pen1, new PointF(55 + 92 * i, 210), new PointF(55 + 92 * i, 214));
                        m_mouse.DrawString(Lenvlae.ToString(), drawFont, drawBrush, new PointF(20 + 92 * i, 215), drawFormat);
                    }
                }

                //绘制纵坐标刻度值
                for (int i = 1; i <= 10; i++)
                {
                    m_mouse.DrawLine(pen1, new PointF(55, 210 - 20 * i), new PointF(51, 210 - 20 * i));
                    Pen pen = new Pen(Color.Black, 1);
                    pen.DashStyle = DashStyle.Dot;
                    m_mouse.DrawLine(pen, new PointF(55, 210 - 20 * i), new PointF(431, 210 - 20 * i));
                    Single Lenvlae = Convert.ToSingle((((dblMaxY - dblminY) / 10) * i) + dblminY);
                    m_mouse.DrawString(Lenvlae.ToString(), drawFont, Brushes.Black, new PointF(1, 210 - 21 * i), drawFormat);
                }

                for (lLOOP = 0; lLOOP < pPointCol.PointCount; lLOOP++)
                {
                    pPointCol2.AddPoint(pPointCol.get_Point(lLOOP), ref before, ref after);
                    pPolyline2 = pPointCol2 as IPolyline;
                    x1         = pPolyline2.Length * dblPerx + 57; //37为坐标图在pictureBox1中离左边的距离
                    y1         = 210 - ((pPointCol.get_Point(lLOOP).Z - pLine.Envelope.ZMin) * dblPery);
                    if (lLOOP == 0)                                //绘制起点
                    {
                        SolidBrush pSolidBrush = new SolidBrush(Color.Blue);
                        m_mouse.FillEllipse(pSolidBrush, Convert.ToSingle(x1 - 2), Convert.ToSingle(y1 - 2), 6, 6);
                    }
                    if (lLOOP > 0)
                    {
                        //绘制沿线高程变化线
                        m_mouse.DrawLine(pen3, new PointF(Convert.ToSingle(x), Convert.ToSingle(y)), new PointF(Convert.ToSingle(x1), Convert.ToSingle(y1)));
                    }

                    if (lLOOP == pPointCol.PointCount - 1)//绘制终点
                    {
                        SolidBrush pSolidBrush = new SolidBrush(Color.Green);
                        m_mouse.FillEllipse(pSolidBrush, Convert.ToSingle(x1 - 2), Convert.ToSingle(y1 - 2), 6, 6);
                    }
                    x = x1;
                    y = y1;
                }

                pictureBox1.Image = pImage;
                m_mouse.Dispose();
                drawFont.Dispose();
                drawBrush.Dispose();
            }
            catch
            {
                return;
            }
        }
コード例 #11
0
ファイル: Tool3DLineOfSight.cs プロジェクト: siszoey/geosufan
        /// <summary>
        /// 通过鼠标点击获取观察点与被观察点同时进行两点间通视分析
        /// </summary>
        /// <param name="Button"></param>
        /// <param name="Shift"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (m_frm3DLineOfSight.m_Layer == null || m_frm3DLineOfSight.m_Surface == null)
            {
                MessageBox.Show("请设置有效的表面数据", "提示!");
                return;
            }
            if (m_frm3DLineOfSight.txtObsOffset.Text == "" || m_frm3DLineOfSight.txtTarOffset.Text == "")
            {
                MessageBox.Show("观察点高度和被观察点高度不能为空", "提示!");
                return;
            }
            m_frm3DLineOfSight.TopMost = true;
            ISceneGraph pSceneGraph = m_sceneHookHelper.SceneGraph;

            m_pNewLineFeedback = new NewLineFeedbackClass();
            IPolyline       pPolyline        = m_pNewLineFeedback.Stop(); //用于判断是否已经获取两点
            ISceneControl   pSceneControl    = m_sceneHookHelper.Hook as ISceneControl;
            Cls3DModulsefun pCls3DModulsefun = new Cls3DModulsefun();     //用于绘制通视分析结果的方法
            object          pOwner;
            object          pObject;

            ESRI.ArcGIS.Geometry.IPoint pPoint = new ESRI.ArcGIS.Geometry.PointClass();
            pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickGeography, true, out pPoint, out pOwner, out pObject);//获取鼠标点击的位置并转化为地理坐标
            if (pPoint == null)
            {
                return;
            }
            ESRI.ArcGIS.Geometry.IPoint pFlashPoint = new ESRI.ArcGIS.Geometry.PointClass();
            IClone pClone = pPoint as IClone;

            pFlashPoint   = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint;
            pFlashPoint.Z = pFlashPoint.Z / pSceneGraph.VerticalExaggeration;
            pFlashPoint.SpatialReference = pSceneGraph.Scene.SpatialReference;
            IDisplay3D pDisplay = pSceneGraph as IDisplay3D;

            pDisplay.FlashLocation(pFlashPoint);//闪烁显示被点击的位置
            IGeometry pGeometry = null;

            if (m_pScenePoints == null)
            {
                m_pScenePoints             = new PolylineClass();
                pGeometry                  = m_pScenePoints as IGeometry;
                pGeometry.SpatialReference = pSceneGraph.Scene.SpatialReference;
            }
            object before = Type.Missing;
            object after  = Type.Missing;

            m_pScenePoints.AddPoint(pPoint, ref before, ref after);//添加获取的点到点集合中
            if (m_pScenePoints.PointCount == 2)
            {
                pClone         = m_pScenePoints as IClone;
                pPolyline      = pClone.Clone() as  ESRI.ArcGIS.Geometry.IPolyline;//当点集合中点数达到两个时生成一条线用于判断观察点与被观察点是否确定
                m_pScenePoints = null;
            }
            if (pPolyline != null)
            {
                m_pScenePoints = null;
                ISurface pSurface = m_SurFace;
                ESRI.ArcGIS.Geometry.IPoint fPoint = pPolyline.FromPoint; //获取观察点
                fPoint.Z = pSurface.GetElevation(fPoint);                 //获取观察点的高程
                ESRI.ArcGIS.Geometry.IPoint tPoint = pPolyline.ToPoint;
                tPoint.Z = pSurface.GetElevation(tPoint);
                if (pSurface.IsVoidZ(fPoint.Z) || pSurface.IsVoidZ(tPoint.Z))
                {
                    return;
                }
                fPoint.Z = fPoint.Z + Convert.ToDouble(m_frm3DLineOfSight.txtObsOffset.Text);//观察者的高度加上观察者所在的高程才是观察点实际的高程
                tPoint.Z = tPoint.Z + Convert.ToDouble(m_frm3DLineOfSight.txtTarOffset.Text);
                ESRI.ArcGIS.Geometry.IPoint pObstruct;
                IPolyline pVisPolyline;
                IPolyline pInVisPolyline;
                bool      bIsVis;
                object    pRefractionFactor = Type.Missing;
                //进行两点间的通视分析
                pSurface.GetLineOfSight(fPoint, tPoint, out pObstruct, out pVisPolyline, out pInVisPolyline, out bIsVis, m_frm3DLineOfSight.checkBoxCurv.Checked, m_frm3DLineOfSight.checkBoxCurv.Checked, ref pRefractionFactor);

                ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
                pSimpleLineSymbol.Width = 2;
                pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                //绘制可视与不可视的沿地表线要素
                if (pVisPolyline != null)
                {
                    pSimpleLineSymbol.Color = Cls3DMarkDraw.getRGB(0, 255, 0);
                    pCls3DModulsefun.AddGraphic(pSceneControl, pVisPolyline as IGeometry, pSimpleLineSymbol as ISymbol);
                }
                if (pInVisPolyline != null)
                {
                    pSimpleLineSymbol.Color = Cls3DMarkDraw.getRGB(255, 0, 0);
                    pCls3DModulsefun.AddGraphic(pSceneControl, pInVisPolyline as IGeometry, pSimpleLineSymbol as ISymbol);
                }
                IGeometryCollection pVisPatch = new MultiPatchClass();//用于存储可视域的要素
                pGeometry = pVisPatch as IGeometry;
                pGeometry.SpatialReference = pSceneGraph.Scene.SpatialReference;
                double              dTargetHeightForVis = 0;
                ISimpleFillSymbol   pSimpleFillSymbol   = new SimpleFillSymbolClass();
                IGeometryCollection pInVisPatch         = new MultiPatchClass();//存储不可视域的要素
                pGeometry = pInVisPatch as IGeometry;
                pGeometry.SpatialReference = pSceneGraph.Scene.SpatialReference;
                IGeometryCollection pPathGeo = pInVisPolyline as IGeometryCollection;
                if (pPathGeo != null)
                {
                    //下面的作用是将不可视域线每段path生成线要素进行绘制       张琪  20110623
                    for (int i = 0; i < pPathGeo.GeometryCount; i++)
                    {
                        IGeometryCollection pInPolyline = new PolylineClass();
                        IPath path = pPathGeo.get_Geometry(i) as IPath;
                        pInPolyline.AddGeometry(path as IGeometry, ref before, ref after);
                        pCls3DModulsefun.CreateVerticalLOSPatches(bIsVis, fPoint, tPoint, pVisPolyline, pInPolyline as IPolyline, pVisPatch, pInVisPatch, dTargetHeightForVis);
                    }
                }
                else//当不可视域为空时,直接分析生成可视域与不可视域
                {
                    pCls3DModulsefun.CreateVerticalLOSPatches(bIsVis, fPoint, tPoint, pVisPolyline, pInVisPolyline, pVisPatch, pInVisPatch, dTargetHeightForVis);
                }
                //
                // 对可视域与不可视域要素在场景中绘制出来
                if (pInVisPatch != null)
                {
                    pSimpleFillSymbol.Color = Cls3DMarkDraw.getRGB(255, 0, 0);
                    pCls3DModulsefun.AddGraphic(pSceneControl, pInVisPatch as IGeometry, pSimpleFillSymbol as ISymbol);
                }
                if (pVisPatch != null)
                {
                    pSimpleFillSymbol.Color = Cls3DMarkDraw.getRGB(0, 255, 0);
                    pCls3DModulsefun.AddGraphic(pSceneControl, pVisPatch as IGeometry, pSimpleFillSymbol as ISymbol);
                }
            }
        }