Esempio n. 1
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt);
            if (m_newBezierCurveFeedback == null)
            {
                m_newBezierCurveFeedback         = new NewBezierCurveFeedbackClass();
                m_newBezierCurveFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
                m_newBezierCurveFeedback.Start(pt);
                fPoint = pt;
            }
            else
            {
                m_newBezierCurveFeedback.AddPoint(pt);
            }
        }
Esempio n. 2
0
        //更新m_pBezierCurveFeed
        public void UpdataBezierCurveFeed(IMapControl2 MapControl, ref IArray pUndoArray)
        {
            if (m_pBezierCurveFeed != null)
            {
                m_pBezierCurveFeed.Stop();
            }

            m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
            m_pActiveView.ScreenDisplay.UpdateWindow();

            m_pBezierCurveFeed.Start((IPoint)m_pUndoArray.get_Element(0));
            CommonFunction.DrawPointSMSSquareSymbol(MapControl, (IPoint)pUndoArray.get_Element(0));
            for (int i = 0; i < pUndoArray.Count; i++)
            {
                m_pBezierCurveFeed.AddPoint((IPoint)pUndoArray.get_Element(i));
                CommonFunction.DrawPointSMSSquareSymbol(MapControl, (IPoint)pUndoArray.get_Element(i));
            }
        }
Esempio n. 3
0
        private void EndDrawBezierCurve()
        {
            IGeometry        pGeom = null;
            IPolyline        pPolyline;
            IPolygon         pPolygon;
            IPointCollection pPointCollection;

            if (m_bInUse)
            {
                switch (((IFeatureLayer)m_CurrentLayer).FeatureClass.ShapeType)
                {
                case  esriGeometryType.esriGeometryPolyline:
                    m_pBezierCurveFeed = (INewBezierCurveFeedback)m_pFeedback;
                    m_pFeedback.MoveTo((IPoint)m_pUndoArray.get_Element(m_pUndoArray.Count - 1));;
                    pPolyline = m_pBezierCurveFeed.Stop();

                    ((ITopologicalOperator)pPolyline).Simplify();

                    pPointCollection = (IPointCollection)pPolyline;
                    if (pPointCollection.PointCount < 2)
                    {
                        MessageBox.Show("线上必须有两个点!");
                    }
                    else
                    {
                        pGeom = (IGeometry)pPointCollection;
                    }
                    break;

                case  esriGeometryType.esriGeometryPolygon:
                    m_pBezierCurveFeed = (INewBezierCurveFeedback)m_pFeedback;
                    m_pBezierCurveFeed.AddPoint((IPoint)m_pUndoArray.get_Element(0));
                    pPolyline = m_pBezierCurveFeed.Stop();
                    pPolygon  = CommonFunction.PolylineToPolygon((IPolyline)pPolyline);

                    ((ITopologicalOperator)pPolygon).Simplify();

                    pPointCollection = (IPointCollection)pPolygon;
                    pGeom            = (IGeometry)pPointCollection;

                    if (pPointCollection.PointCount < 3)
                    {
                        MessageBox.Show("面上必须有三个点!");
                    }
                    else
                    {
                        pGeom = (IGeometry)pPointCollection;
                    }
                    break;

                default:
                    break;
                }                //end switch

                m_pEnvelope = pGeom.Envelope;
                if (m_pEnvelope != null && !m_pEnvelope.IsEmpty)
                {
                    m_pEnvelope.Expand(10, 10, false);
                }
                ;

                CommonFunction.CreateFeature(m_App.Workbench, pGeom, m_FocusMap, m_CurrentLayer);
            }

            Reset();            //复位

            m_bInUse = false;
        }
Esempio n. 4
0
        private void DrawBezierCurveMouseDown(IPoint pPoint)
        {
            if (!m_bInUse)           //如果命令没有使用
            {
                m_bInUse = true;

                m_pUndoArray.Add(pPoint);

                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, pPoint);

                m_pFeedback        = new NewBezierCurveFeedbackClass();
                m_pBezierCurveFeed = (INewBezierCurveFeedback)m_pFeedback;
                m_pBezierCurveFeed.Start(pPoint);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                }

                if (((IFeatureLayer)m_CurrentLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                {
                     
                    //若当前图层是面层,则显示回馈开始点到鼠标点的线段
                        m_pLastFeedback = new NewLineFeedbackClass();
                    m_pLastLineFeed = (INewLineFeedback)m_pLastFeedback;
                    m_pLastLineFeed.Start(pPoint);
                    if (m_pLastFeedback != null)
                    {
                        m_pLastFeedback.Display = m_pActiveView.ScreenDisplay;
                    }
                }
            }
            else            //若果命令正使用中
            {
                m_pBezierCurveFeed = (INewBezierCurveFeedback)m_pFeedback;
                m_pBezierCurveFeed.AddPoint(pPoint);

                IPoint tempPoint = new PointClass();
                tempPoint.X = pPoint.X;
                tempPoint.Y = pPoint.Y;
                m_pUndoArray.Add(tempPoint);
                UpdataBezierCurveFeed(m_MapControl, ref m_pUndoArray);               //刷新屏幕

                if ((m_bFixLength == true) && (m_bFixDirection == false))            //可以给定一个长度值
                {
                    m_bFixLength = false;
                }
                else if ((m_bFixLength == false) && (m_bFixDirection == true))                 //可以给定一个固定方向值
                {
                    m_bFixDirection = false;
                }
                else if ((m_bFixLength == true) && (m_bFixDirection == true))
                {
                    m_bFixLength    = false;
                    m_bFixDirection = false;
                }

                if (m_bFixLeftCorner)
                {
                    m_bFixLeftCorner = false;
                }
            }

            m_pLastPoint = pPoint;

            if (m_bkeyCodeS == true)             //直角结束
            {
                m_bkeyCodeS = false;
                if (((IFeatureLayer)m_CurrentLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                {
                    m_pLastLineFeed.Stop();
                }
            }

            m_pSegment = null;            //清空捕捉到的片断
        }