Example #1
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     try
     {
         ClsMarkDraw.DeleteAllElementsWithName(m_hookHelper.FocusMap, sPolyOutlineName);
         ESRI.ArcGIS.Geometry.IPoint pMapPoint = new ESRI.ArcGIS.Geometry.PointClass();
         m_hookHelper.FocusMap.SpatialReference = m_psurface.Domain.SpatialReference;
         pMapPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
         if (pMapPoint == null)
         {
             return;
         }
         pMapPoint.Project(m_psurface.Domain.SpatialReference);
         pMapPoint.Z = m_psurface.GetElevation(pMapPoint);
         IGroupElement pGroup = null;
         ClsMarkDraw.AddSimpleGraphic(pMapPoint, ClsMarkDraw.getRGB(71, 61, 255), 3, sPolyOutlineName, m_hookHelper.FocusMap, pGroup);
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
         m_Geometry = pMapPoint;
         EndDtrawd(true);
     }
     catch
     {
         return;
     }
 }
Example #2
0
 private void frmQuerySlope_FormClosing(object sender, FormClosingEventArgs e)
 {
     ClsMarkDraw.DeleteAllElementsWithName(m_pMapControlDefault.Map, sPolyOutlineName);//清除绘制的要素
     if (m_SpatialReference != null)
     {
         m_pMapControlDefault.SpatialReference = m_SpatialReference;
     }
     m_pMapControlDefault.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
     m_SurFace = null;
     m_pMapControlDefault.CurrentTool = null;
     this.Dispose();
 }
Example #3
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     ClsMarkDraw.DeleteAllElementsWithName(m_pMapControlDefault.Map, sPolyOutlineName);//清除绘制的要素
     if (m_SpatialReference != null)
     {
         m_pMapControlDefault.Map.SpatialReference = m_SpatialReference;
     }
     m_pMapControlDefault.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
     m_SurFace = null;
     m_pMapControlDefault.CurrentTool = null;
     this.DialogResult = DialogResult.Cancel;
     this.Close();
 }
Example #4
0
        private void DrawGeo_Click(object sender, EventArgs e)
        {
            //新建三维绘制工具
            ClsMarkDraw.DeleteAllElementsWithName(m_pMapControlDefault.Map, sPolyOutlineName);
            m_pMapControlDefault.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
            pToolDrawGeo.EndDtrawd   += new myEventHandler(pToolDrawGeo_EndDtrawd);
            pToolDrawGeo.GeometryType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryLine;
            pToolDrawGeo.pSurface     = m_SurFace;
            ICommand pCommad = pToolDrawGeo;

            pCommad.OnCreate(m_pMapControlDefault.Object);
            m_pMapControlDefault.CurrentTool = pCommad as ITool;
        }
Example #5
0
        private void DrawGeo_Click(object sender, EventArgs e)
        {
            //新建三维绘制工具
            ClsMarkDraw.DeleteAllElementsWithName(m_pMapControlDefault.Map, sPolyOutlineName);
            m_pMapControlDefault.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
            pToolQuerySlope.EndDtrawd += new myEventHandlerSlope(pToolQuerySlope_EndDtrawd);
            pToolQuerySlope.pSurface   = m_SurFace;
            ICommand pCommad = pToolQuerySlope;

            pCommad.OnCreate(m_pMapControlDefault.Object);
            m_pMapControlDefault.CurrentTool = pCommad as ITool;
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog(this.Text);
            }
        }
Example #6
0
        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;
                    //ZQ   20110809
                    m_Geometry.SpatialReference = m_psurface.Domain.SpatialReference;
                    //m_Geometry.SpatialReference = m_hookHelper.FocusMap.SpatialReference;
                    ClsMarkDraw.DeleteAllElementsWithName(m_hookHelper.FocusMap, 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;
                    //ZQ   20110809
                    m_Geometry.SpatialReference = m_psurface.Domain.SpatialReference;
                    //m_Geometry.SpatialReference = m_hookHelper.FocusMap.SpatialReference;
                    ClsMarkDraw.DeleteAllElementsWithName(m_hookHelper.FocusMap, sPolyOutlineName);
                    EndDtrawd(true);    //触发结束事件
                    break;
                }
                m_pPointColl = null;
            }
            //Cls3DMarkDraw.DeleteAllElementsWithName(m_sceneHookHelper.Scene, sPolyOutlineName);

            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Example #7
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            try
            {
                ESRI.ArcGIS.Geometry.IPoint pMapPoint = new ESRI.ArcGIS.Geometry.PointClass();;
                object before   = Type.Missing;
                object after    = Type.Missing;
                object StepSize = Type.Missing;
                m_hookHelper.FocusMap.SpatialReference = m_psurface.Domain.SpatialReference;
                pMapPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                if (pMapPoint == null)
                {
                    return;
                }
                pMapPoint.Project(m_psurface.Domain.SpatialReference);
                pMapPoint.Z = m_psurface.GetElevation(pMapPoint);

                //pMapPoint.SpatialReference = m_hookHelper.FocusMap.SpatialReference;
                //pDisplay = m_sceneHookHelper.SceneGraph as IDisplay3D;
                //pDisplay.FlashLocation(pMapPoint);//闪烁显示被点击的位置

                IGeometry pGeom = null;
                ClsMarkDraw.DeleteAllElementsWithName(m_hookHelper.FocusMap, 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)
                {
                    //当为一个点时绘制点
                    ClsMarkDraw.AddSimpleGraphic(pMapPoint, ClsMarkDraw.getRGB(71, 61, 255), 3, sPolyOutlineName, m_hookHelper.FocusMap, pGroup);
                }
                else if (m_DrawType.ToString() == "esriGeometryLine")
                {
                    pGeom = m_pPointColl as IGeometry;
                    pGeom.SpatialReference = pMapPoint.SpatialReference;
                    m_psurface.InterpolateShape(pGeom, out pGeom, ref StepSize);
                    ClsMarkDraw.AddSimpleGraphic(pGeom, ClsMarkDraw.getRGB(71, 61, 255), 2, sPolyOutlineName, m_hookHelper.FocusMap, 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);
                    ClsMarkDraw.AddSimpleGraphic(pGeom, ClsMarkDraw.getRGB(71, 61, 255), 2, sPolyOutlineName, m_hookHelper.FocusMap, pGroup);
                }

                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
            catch
            {
                return;
            }
        }
Example #8
0
        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;
                ////用于绘制三维效果
                ClsMarkDraw.AddSimpleGraphic(pGeometry, ClsMarkDraw.getRGB(71, 61, 255), 2, sPolyOutlineName, m_pMapControlDefault.Map, pGroup);
                m_pMapControlDefault.Refresh(esriViewDrawPhase.esriViewBackground, null, null);

                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;
            }
        }