Пример #1
0
        private void DrawCircle3PMouseDown(IPoint pPoint, int shift)
        {
            IGeometry pGeom = null;
            IPolyline pPolyline;
            IPolygon  pPolygon;
            IPoint    pCenterPoint = new PointClass();

            if (!m_bFirst)           //如果命令没有使用
            {
                     m_pPoint1 = pPoint;
                m_bFirst  = true;
                m_bSecond = false;

                m_pFeedback         = new NewLineFeedbackClass();
                m_pLineFeed         = (INewLineFeedback)m_pFeedback;
                m_pLineFeed.Display = m_pActiveView.ScreenDisplay;
                m_pLineFeed.Start(pPoint);

                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint1);
            }
            else if (!m_bSecond)            //如果命令正在使用
            {
                m_pPoint2 = pPoint;
                m_bSecond = true;
                m_bThree  = false;
                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint2);

                m_pLineFeed.Stop();
                m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_pEnvelope);

                m_pFeedback = new NewCircleFeedbackClass();
            }
            else if (!m_bThree)
            {
                m_pPoint3 = m_pPoint;
                m_bFirst  = false;
                m_bThree  = true;

                m_pCenterPoint = CommonFunction.GetCenter_P123(m_pPoint1, m_pPoint2, pPoint);

                m_pCircleFeed         = (NewCircleFeedbackClass)m_pFeedback;
                m_pCircleFeed.Display = m_pActiveView.ScreenDisplay;

                m_pCircleFeed.Stop();
                m_pCircleFeed.Start(m_pCenterPoint);
                m_pFeedback.MoveTo(pPoint);

                ICircularArc pCircularArc = new CircularArcClass();
                pCircularArc = m_pCircleFeed.Stop();

                pCenterPoint = pCircularArc.CenterPoint;

                if (shift == 1)                //若果按住shift健弹出对话框,让用户修改圆周上的坐标值
                {
                    frmCircle3P formCircle3P = new frmCircle3P();
                    formCircle3P.ShowDialog();

                    if (m_bModify) //修改坐标值了
                    {
                                   //计算圆心坐标
                            pCenterPoint = CommonFunction.GetCenter_P123(m_pPoint1, m_pPoint2, m_pPoint3);
                        m_bModify = false;
                    }
                }

                switch (((IFeatureLayer)m_CurrentLayer).FeatureClass.ShapeType)
                {
                case  esriGeometryType.esriGeometryPolyline:
                    pPolyline = CommonFunction.ArcToPolyline(pCircularArc.FromPoint, pCircularArc.CenterPoint, pCircularArc.FromPoint, esriArcOrientation.esriArcClockwise);
                    pGeom     = pPolyline;
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    pPolyline = CommonFunction.ArcToPolyline(pCircularArc.FromPoint, pCircularArc.CenterPoint, pCircularArc.FromPoint, esriArcOrientation.esriArcClockwise);
                    pPolygon  = CommonFunction.PolylineToPolygon(pPolyline);
                    pGeom     = pPolygon;
                    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();
            }            // end if(!m_bThree)

            m_pLastPoint = pPoint;

            m_pSegment = null;
        }
Пример #2
0
        private void EndDrawArc3P(IPoint pPoint, int shift)
        {
            IGeometry pGeom = null;
            IPolyline pPolyline;
            IPolygon  pPolygon;

            pLineArray.Add(pPoint);

            m_pLineFeed = (INewLineFeedback)m_pFeedback;
            if (m_pLineFeed != null)
            {
                m_pLineFeed.Stop();
            }

            IPoint pFromPoint   = (IPoint)pLineArray.get_Element(0);
            IPoint pTempPoint   = ( IPoint)pLineArray.get_Element(2);
            IPoint pToPoint     = (IPoint)pLineArray.get_Element(pLineArray.Count - 1);
            IPoint pCenterPoint = CommonFunction.GetCenter_P123(pFromPoint, pTempPoint, pToPoint);

            m_pPoint1 = pFromPoint;
            m_pPoint2 = pTempPoint;
            m_pPoint3 = pToPoint;

            ICircularArc pArc = new CircularArcClass();

            pArc.PutCoords(pCenterPoint, pFromPoint, pToPoint, esriArcOrientation.esriArcMajor);

            if (m_bInUse)
            {
                if (shift == 1)                //若果按住shift健就弹出对话框,让用户修改圆周上的坐标值
                {
                    frmCircle3P formCircle3P = new frmCircle3P();
                    formCircle3P.ShowDialog();

                    if (m_bModify)                    //修改坐标值了
                    {
                               pFromPoint = m_pPoint1;
                        pToPoint     = m_pPoint3;
                        pCenterPoint = CommonFunction.GetCenter_P123(m_pPoint1, m_pPoint2, m_pPoint3);
                        m_bModify    = false;
                    }
                }

                if (m_Ca < Math.PI)                 //圆心角小于π
                {
                    pPolyline = CommonFunction.ArcToPolyline(pFromPoint, pCenterPoint, pToPoint, esriArcOrientation.esriArcMinor);
                }
                else                 //圆心角大于π
                {
                    pPolyline = CommonFunction.ArcToPolyline(pFromPoint, pCenterPoint, pToPoint, esriArcOrientation.esriArcMajor);
                }

                switch (((IFeatureLayer)m_CurrentLayer).FeatureClass.ShapeType)
                {
                case  esriGeometryType.esriGeometryPolyline:
                    pGeom = (IGeometry)pPolyline;

                    break;

                case  esriGeometryType.esriGeometryPolygon:
                    ILine pCenterToFormPointLine = new LineClass();
                    pCenterToFormPointLine.PutCoords(pCenterPoint, pToPoint);
                    ILine pToPointToCenterLine = new LineClass();
                    pToPointToCenterLine.PutCoords(pFromPoint, pCenterPoint);

                    ISegmentCollection pSegsPolyline;
                    pSegsPolyline = (ISegmentCollection)pPolyline;

                    object a = System.Reflection.Missing.Value;
                    object b = System.Reflection.Missing.Value;

                    pSegsPolyline.AddSegment((ISegment)pCenterToFormPointLine, ref a, ref b);
                    pSegsPolyline.AddSegment((ISegment)pToPointToCenterLine, ref a, ref b);

                    pPolygon = CommonFunction.PolylineToPolygon((IPolyline)pSegsPolyline);
                    pGeom    = (IGeometry)pPolygon;

                    break;
                }                //end switch

                m_pEnvelope = pGeom.Envelope;
                m_pEnvelope.Union(m_pCenterPoint.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();

                pLineArray.RemoveAll();
                m_bInUse = false;
            }            //end else if (m_bInUse)
        }