Ejemplo n.º 1
0
        public void CanTest2SegmentCircle()
        {
            IFeatureClass fc = CreateLineClass(_testWs, "CanTest2SegmentCircle");

            IFeature row1 = fc.CreateFeature();

            IConstructCircularArc arc = new CircularArcClass();

            arc.ConstructCircle(GeometryFactory.CreatePoint(0, 0, 0), 3, false);

            IPolyline polyline = CreatePolyLine((ISegment)arc);

            int  segmentIndex;
            int  newPartIndex;
            bool splitHappened;

            polyline.SplitAtDistance(0.5, true, false,
                                     out splitHappened,
                                     out newPartIndex,
                                     out segmentIndex);
            Assert.True(splitHappened);

            row1.Shape = polyline;
            row1.Store();

            var test = new QaMinSegAngle(fc, 0.1, true);

            var runner = new QaContainerTestRunner(1000, test);

            runner.Execute();

            // assert that two segment closed curve does not always report two
            // errors when using linearized segments
            Assert.AreEqual(0, runner.Errors.Count);
        }
        private int AddCepGraphic(IPoint point, IList <double> circleRadii)
        {
            //Create a new center point graphic
            IMarkerSymbol symbol = new SimpleMarkerSymbolClass();

            symbol.Color = EsriColor(Defaults.CepCenterPointColor);
            symbol.Size  = Defaults.CepCenterPointSize;
            IElement centerPoint = new MarkerElementClass();

            ((IMarkerElement)centerPoint).Symbol = symbol;
            centerPoint.Geometry = point;

            //Create a graphic group and add the center point graphic
            IGroupElement group = new GroupElementClass();

            group.AddElement(centerPoint);

            //Add the circles to the group
            for (int i = 0; i < circleRadii.Count; i++)
            {
                IConstructCircularArc arc = new CircularArcClass();
                arc.ConstructCircle(point, circleRadii[i], false);
                IGeometry polygon = new PolygonClass();
                ((ISegmentCollection)polygon).AddSegment((ISegment)arc);
                IElement circle = new CircleElementClass();
                circle.Geometry = polygon;
                Color circleColor = Defaults.CepCircleOutlineColors.Length > i
                                  ? Defaults.CepCircleOutlineColors[i]
                                  : Defaults.CepCircleOutlineColors[Defaults.CepCircleOutlineColors.Length - 1];
                double circleWidth = Defaults.CepCircleOutlineWidths.Length > i
                                   ? Defaults.CepCircleOutlineWidths[i]
                                   : Defaults.CepCircleOutlineWidths[Defaults.CepCircleOutlineWidths.Length - 1];
                ((IFillShapeElement)circle).Symbol = GetCircleSymbol(circleColor, circleWidth);
                group.AddElement(circle);
            }

            //Give it the group an id number and add it to the graphics layer
            _elementId++;
            ((IElementProperties)group).CustomProperty = _elementId;
            ((IGraphicsContainer)GraphicsLayer).AddElement((IElement)group, 0);
            return(_elementId);
        }
Ejemplo n.º 3
0
        public void CanTestCircle()
        {
            IFeatureClass fc = CreateLineClass(_testWs, "CanTestCircle");

            IFeature row1 = fc.CreateFeature();

            IConstructCircularArc arc = new CircularArcClass();

            arc.ConstructCircle(GeometryFactory.CreatePoint(0, 0, 0), 3, false);

            row1.Shape = CreatePolyLine((ISegment)arc);
            row1.Store();

            var test = new QaMinSegAngle(fc, 0.1, true);

            var runner = new QaContainerTestRunner(1000, test);

            runner.Execute();

            Assert.AreEqual(0, runner.Errors.Count);
        }
Ejemplo n.º 4
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolCreateCircle.OnMouseDown implementation
            if ((m_pMapCtl = ClsGlobal.GetMapControl(m_hookHelper)) == null)
            {
                return;
            }
            IPoint pPoint = m_pMapCtl.ToMapPoint(X, Y);

            if (Button == 1)
            {
                if (m_NewCircleFeedback == null)
                {
                    m_NewCircleFeedback         = new NewCircleFeedbackClass();
                    m_NewCircleFeedback.Display = m_pMapCtl.ActiveView.ScreenDisplay;

                    m_NewCircleFeedback.Start(pPoint);
                    m_CenterPoint = pPoint;
                }
                else
                {
                    try
                    {
                        object       Miss = Type.Missing;
                        ICircularArc pArc = m_NewCircleFeedback.Stop();
                        //IGeometry geometry = new PolygonClass();
                        //geometry = m_pMapCtl.TrackCircle();
                        IPolygon           pPolygon = new PolygonClass();
                        ISegment           pArcC    = pArc as ISegment;
                        ISegmentCollection pArcP    = pPolygon as ISegmentCollection;
                        pArcP.AddSegment(pArcC, ref Miss, ref Miss);
                        pPolygon.Close();
                        IFeature pFeature = m_FLayer.FeatureClass.CreateFeature();
                        pFeature.Shape = pPolygon;
                        pFeature.Store();
                        m_pMapCtl.Refresh();
                        m_NewCircleFeedback = null;
                    }
                    catch (System.Exception ex)
                    {
                    }
                }
            }
            if (Button == 2)
            {
                double                radius        = Math.Sqrt((pPoint.X - m_CenterPoint.X) * (pPoint.X - m_CenterPoint.X) + (pPoint.Y - m_CenterPoint.Y) * (pPoint.Y - m_CenterPoint.Y));
                FrmDrawCircle         frm           = new FrmDrawCircle(radius);
                IConstructCircularArc pArcConstruct = null;
                if (m_NewCircleFeedback == null)
                {
                    return;
                }

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        pArcConstruct = new CircularArcClass();
                        pArcConstruct.ConstructCircle(m_CenterPoint, frm.m_radius, false);
                        if (pArcConstruct != null)
                        {
                            IPolygon           pPolygon = new PolygonClass();
                            ISegment           pArcC    = pArcConstruct as ISegment;
                            ISegmentCollection pArcP    = pPolygon as ISegmentCollection;
                            pArcP.AddSegment(pArcC);
                            pPolygon.Close();
                            IFeature pFeature = m_FLayer.FeatureClass.CreateFeature();
                            pFeature.Shape = pPolygon;
                            pFeature.Store();
                            m_pMapCtl.Refresh();
                            m_NewCircleFeedback.Stop();
                            m_NewCircleFeedback = null;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        if (m_NewCircleFeedback != null)
                        {
                            m_NewCircleFeedback.Stop();
                        }
                        m_NewCircleFeedback = null;
                    }
                }
            }
        }