Example #1
0
        private ICircularArc method_8(IPoint point, double num, bool flag)
        {
            IConstructCircularArc constructCircularArc = new CircularArc() as IConstructCircularArc;

            constructCircularArc.ConstructCircle(point, num, flag);
            return((ICircularArc)constructCircularArc);
        }
Example #2
0
        public override void OnMouseDown(int button, int Shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }
            if (this._context.ActiveView is IPageLayout)
            {
                IPoint location = this._context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                IMap   map      = this._context.ActiveView.HitTestMap(location);
                if (map == null)
                {
                    return;
                }
                if (map != this._context.FocusMap)
                {
                    this._context.ActiveView.FocusMap = map;
                    this._context.ActiveView.Refresh();
                }
            }
            IPoint point = ((IActiveView)this._context.FocusMap).ScreenDisplay.DisplayTransformation.ToMapPoint(x,
                                                                                                                y);

            frmInputText frm = new frmInputText();

            frm.txtText.Properties.EditFormat.FormatType = FormatType.Numeric;
            frm.Label = "输入半径";
            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            try
            {
                double radius = Convert.ToDouble(frm.txtText.EditValue);
                IConstructCircularArc2 arc2 = new CircularArc() as IConstructCircularArc2;
                arc2.ConstructCircle(point, radius, false);
                IPolygon polygon = new Polygon() as IPolygon;
                object   value   = Missing.Value;
                (polygon as ISegmentCollection).AddSegment(arc2 as ISegment, ref value, ref value);
                _plugin.FireFenceAdded(new FenceAddedArgs((IGeometry)polygon));
                IActiveView activeView = this._context.FocusMap as IActiveView;
                activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, polygon.Envelope);
            }
            catch (Exception ex)
            {
                MessageService.Current.Warn("半径必须为数字!");
            }
        }
Example #3
0
        public bool Snap(IGeometry igeometry_0, IPoint ipoint_0, double double_0)
        {
            ILine  lineClass;
            double length     = 0;
            int    num        = 0;
            int    num1       = 0;
            bool   flag       = true;
            IPoint pointClass = new ESRI.ArcGIS.Geometry.Point();
            double num2       = 1000;
            bool   flag1      = false;
            object value      = Missing.Value;
            IPoint ipoint0    = ipoint_0;
            IPoint point      = null;

            point = (!(igeometry_0 is IPoint) ? ((IPointCollection)igeometry_0).Point[0] : (IPoint)igeometry_0);
            for (int i = 0; i < this.ifeatureCache_0.Count; i++)
            {
                IHitTest shape = (IHitTest)this.ifeatureCache_0.Feature[i].Shape;
                if (shape.HitTest(ipoint0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary, pointClass,
                                  ref length, ref num, ref num1, ref flag))
                {
                    IGeometryCollection geometryCollection = shape as IGeometryCollection;
                    if (geometryCollection != null)
                    {
                        ISegmentCollection geometry = geometryCollection.Geometry[num] as ISegmentCollection;
                        if (geometry != null)
                        {
                            ISegment segment = geometry.Segment[num1];
                            if (segment is ICircularArc)
                            {
                                IPoint centerPoint = ((ICircularArc)segment).CenterPoint;
                                ILine  line        = new Line();
                                line.PutCoords(point, centerPoint);
                                double length1 = line.Length;
                                IConstructCircularArc circularArcClass = new CircularArc() as IConstructCircularArc;
                                circularArcClass.ConstructCircle(point, length1, true);
                                IGeometryCollection polylineClass = new Polyline() as IGeometryCollection;
                                ISegmentCollection  pathClass     = new ESRI.ArcGIS.Geometry.Path() as ISegmentCollection;
                                pathClass.AddSegment((ISegment)circularArcClass, ref value, ref value);
                                polylineClass.AddGeometry((IGeometry)pathClass, ref value, ref value);
                                ((ITopologicalOperator)polylineClass).Simplify();
                                IGeometryCollection polylineClass1    = new Polyline() as IGeometryCollection;
                                ISegmentCollection  segmentCollection = new Path() as ISegmentCollection;
                                segmentCollection.AddSegment(segment, ref value, ref value);
                                polylineClass1.AddGeometry((IGeometry)segmentCollection, ref value, ref value);
                                ((ITopologicalOperator)polylineClass1).Simplify();
                                IGeometry geometry1 =
                                    ((ITopologicalOperator)polylineClass).Intersect((IGeometry)polylineClass1,
                                                                                    esriGeometryDimension.esriGeometry0Dimension);
                                if (geometry1 != null)
                                {
                                    if (!(geometry1 is IPointCollection))
                                    {
                                        lineClass = new Line();
                                        lineClass.PutCoords((IPoint)geometry1, ipoint0);
                                        if (num2 > length)
                                        {
                                            num2       = length;
                                            pointClass = ((IPointCollection)geometry1).Point[0];
                                            ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                                            flag1 = true;
                                        }
                                    }
                                    else
                                    {
                                        lineClass = new Line();
                                        ILine lineClass1 = new Line();
                                        lineClass.PutCoords(((IPointCollection)geometry1).Point[0], ipoint0);
                                        lineClass1.PutCoords(((IPointCollection)geometry1).Point[1], ipoint0);
                                        if (lineClass.Length <= lineClass1.Length)
                                        {
                                            length     = lineClass.Length;
                                            pointClass = ((IPointCollection)geometry1).Point[0];
                                        }
                                        else
                                        {
                                            length     = lineClass1.Length;
                                            pointClass = ((IPointCollection)geometry1).Point[1];
                                        }
                                        if (num2 > length)
                                        {
                                            num2       = length;
                                            pointClass = ((IPointCollection)geometry1).Point[0];
                                            ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                                            flag1 = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(flag1);
        }
        private void drawCircleGraphic(double Size)
        {
            IMxDocument pMxDoc = m_pDoc;
            IActiveView pActiveView;
            IScreenDisplay pScreenDisplay;

            IEnvelope pEnv;
            IPoint pCenterPoint;
            IDisplayTransformation pTransform;

            pActiveView = pMxDoc.FocusMap as IActiveView;
            pScreenDisplay = pActiveView.ScreenDisplay;

            pTransform = pScreenDisplay.DisplayTransformation;
            pEnv = pTransform.FittedBounds;
            pCenterPoint = new Point();
            pCenterPoint.PutCoords((pEnv.XMax + pEnv.XMin) / 2, (pEnv.YMax + pEnv.YMin) / 2);

            IConstructCircularArc pCircle = new CircularArc() as IConstructCircularArc;
            ISegmentCollection pPolygon = new Polygon() as ISegmentCollection;

            Size *= 10000;
            Size = Math.Sqrt(Size / 3.1416);
            pCircle.ConstructCircle(pCenterPoint, Size, true);

            pPolygon.AddSegment(pCircle as ISegment);

            IPolygon pFinalPolygon;
            pFinalPolygon = pPolygon as IPolygon;
            pFinalPolygon.Close();

            IRgbColor pLineColor = new RgbColor();
            pLineColor.Red = 255; // A CHANGER!!!

            addGraphicToMap(pMxDoc.FocusMap, pFinalPolygon, pLineColor, pLineColor);
        }
Example #5
0
        public List <IPrintPageInfo> CreateStripMapPageInfos(IPolyline stripLine)
        {
            IPolyline             pPolyline;
            IPoint                pCenterPoint;
            IPolygon              pCirclePoly;
            IPolygon              pGridPoly;
            IConstructCircularArc pCircularArc;
            ISegmentCollection    pSegmentCollection;
            ITopologicalOperator  pTopoOpt;
            IGeometryCollection   pGeoCol;
            IPoint                pIntersectPoint;
            ICurve                pArc;
            IPoint                pIntersectPointPrev;
            bool      bFirstRun;
            int       lLoop2;
            double    dHighest = 0;
            int       lHighestRef;
            double    dHighestPrev;
            ICurve    pCurve;
            ILine     pLine;
            IPolyline pPLine;
            bool      bContinue;
            bool      bReducedRadius;
            double    dGridAngle;
            double    dHighestThisTurn;
            int       lCounter = 0;

            List <IPrintPageInfo> pages = new List <IPrintPageInfo>();

            pPolyline    = stripLine;
            pCenterPoint = pPolyline.FromPoint;
            double m_GridWidth  = _mapTemplate.Width * _scale / 100.0;
            double m_GridHeight = _mapTemplate.Height * _scale / 100.0;

            double        dCircleRadius;
            List <double> colIntersects = new List <double>();
            double        dIntersect;

            dHighestPrev = -1;
            bFirstRun    = true;
            pArc         = pPolyline;
            bContinue    = false;

            bool   isLoop1 = true;
            object missing = Missing.Value;

            do
            {
                if (bFirstRun)
                {
                    dCircleRadius = m_GridWidth / 2.0;
                }
                else
                {
                    dCircleRadius = m_GridWidth;
                }
                bReducedRadius = false;
                do
                {
                    //! 创建搜索圆
                    pCircularArc = new CircularArc() as IConstructCircularArc;
                    pCircularArc.ConstructCircle(pCenterPoint, dCircleRadius, false);
                    pCirclePoly        = new Polygon() as IPolygon;
                    pSegmentCollection = pCirclePoly as ISegmentCollection;
                    pSegmentCollection.AddSegment(pCircularArc as ISegment, ref missing, ref missing);

                    pTopoOpt = pPolyline as ITopologicalOperator;
                    pGeoCol  = new GeometryBag() as IGeometryCollection;
                    pGeoCol  = pTopoOpt.Intersect(pCirclePoly, esriGeometryDimension.esriGeometry0Dimension) as IGeometryCollection;
                    if (pGeoCol.GeometryCount == 0)
                    {
                        //! 需要检查,没有交点的的时候的处理

                        return(null);
                    }

                    pArc             = pPolyline;
                    lHighestRef      = -1;
                    dHighestThisTurn = 102;
                    for (lLoop2 = 0; lLoop2 < pGeoCol.GeometryCount; lLoop2++)
                    {
                        pIntersectPoint = pGeoCol.Geometry[lLoop2] as IPoint;
                        dIntersect      = ReturnPercentageAlong(pPolyline, pIntersectPoint);
                        if (dIntersect > (dHighestPrev * 1.001) && dIntersect < dHighestThisTurn)
                        {
                            dHighest         = dIntersect;
                            dHighestThisTurn = dIntersect;
                            lHighestRef      = lLoop2;
                        }
                    }

                    if (lHighestRef < 0)
                    {
                        dHighest            = 101;
                        pIntersectPoint     = IntersectPointExtendedTo(pPolyline, pCirclePoly);
                        pIntersectPointPrev = pCenterPoint;
                    }
                    else
                    {
                        pIntersectPoint = pGeoCol.Geometry[lHighestRef] as IPoint;
                        if (bFirstRun)
                        {
                            pIntersectPointPrev = new Point();
                            pIntersectPointPrev.PutCoords(pCenterPoint.X - (pIntersectPoint.X - pCenterPoint.X),
                                                          pCenterPoint.Y - (pIntersectPoint.Y - pCenterPoint.Y));
                        }
                        else
                        {
                            pIntersectPointPrev = pCenterPoint;
                        }
                    }

                    if (bReducedRadius)
                    {
                        IPolyline pTmpPLine;
                        IPolygon  pTmpCPoly;
                        IPoint    pTmpIntPoint;
                        pCircularArc = new CircularArc() as IConstructCircularArc;
                        if (bFirstRun)
                        {
                            pCircularArc.ConstructCircle(pCenterPoint, m_GridWidth / 2.0, false);
                        }
                        else
                        {
                            pCircularArc.ConstructCircle(pCenterPoint, m_GridWidth, false);
                        }
                        pTmpCPoly          = new Polygon() as IPolygon;
                        pSegmentCollection = pTmpCPoly as ISegmentCollection;
                        pSegmentCollection.AddSegment((ISegment)pCircularArc, ref missing, ref missing);
                        pTmpPLine           = new Polyline() as IPolyline;
                        pTmpPLine.FromPoint = pIntersectPointPrev;
                        pTmpPLine.ToPoint   = pIntersectPoint;
                        pTmpIntPoint        = IntersectPointExtendedTo(pTmpPLine, pTmpCPoly);
                        CreateAngledGridPolygon(pIntersectPointPrev, pTmpIntPoint, out pGridPoly, out dGridAngle);
                    }
                    else
                    {
                        CreateAngledGridPolygon(pIntersectPointPrev, pIntersectPoint, out pGridPoly, out dGridAngle);
                    }

                    pTopoOpt  = pGridPoly as ITopologicalOperator;
                    pGeoCol   = new GeometryBag() as IGeometryCollection;
                    pGeoCol   = pTopoOpt.Intersect(pPolyline, esriGeometryDimension.esriGeometry0Dimension) as IGeometryCollection;
                    bContinue = true;
                    if (pGeoCol.GeometryCount > 2)
                    {
                        colIntersects = new List <double>();
                        for (lLoop2 = 2; lLoop2 < pGeoCol.GeometryCount; lLoop2++)
                        {
                            colIntersects.Add(ReturnPercentageAlong(pArc, pGeoCol.Geometry[lLoop2] as IPoint));
                        }
                        for (lLoop2 = 0; lLoop2 < colIntersects.Count; lLoop2++)
                        {
                            if (colIntersects[lLoop2] > (dHighestPrev * 1.001) &&
                                colIntersects[lLoop2] < (dHighestPrev * 0.999))
                            {
                                bContinue      = false;
                                dHighest       = dHighestPrev;
                                dCircleRadius  = dCircleRadius - m_GridWidth * 0.1;
                                bReducedRadius = true;
                                if (dCircleRadius < 0)
                                {
                                    bContinue = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (bContinue && bReducedRadius)
                    {
                        double dTmpHighest;
                        pArc        = pPolyline;
                        lHighestRef = -1;
                        dTmpHighest = -1;
                        for (lLoop2 = 0; lLoop2 < pGeoCol.GeometryCount; lLoop2++)
                        {
                            pIntersectPoint = pGeoCol.Geometry[lLoop2] as IPoint;
                            dIntersect      = ReturnPercentageAlong(pArc, pIntersectPoint);
                            if (dIntersect > dTmpHighest)
                            {
                                dTmpHighest = dIntersect;
                                lHighestRef = lLoop2;
                            }
                        }
                        if (lHighestRef >= 0)
                        {
                            pIntersectPoint = pGeoCol.Geometry[lHighestRef] as IPoint;
                        }
                        dHighest = dTmpHighest;
                    }
                } while (!bContinue);
                bFirstRun    = false;
                dHighestPrev = dHighest;
                lCounter++;

                IPrintPageInfo page = new PrintPageInfo();
                page.Boundary = pGridPoly;
                page.PageID   = lCounter;
                page.Angle    = dGridAngle;
                page.PageName = "带状图(" + lCounter.ToString() + ")";
                page.Scale    = _scale;
                pages.Add(page);

                pCenterPoint = pIntersectPoint;
            } while (dHighest < 100);

            foreach (IPrintPageInfo pageInfo in pages)
            {
                pageInfo.TotalCount = pages.Count;
            }
            return(pages);
        }