//--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                if (_Segment != null)
                {
                    _Points[1] = _PointAction.Point;
                    _Element.OnPointsChanged(_Points, null);
                    _SketchEditorTool.WorkspaceController.Invalidate();

                    if (_LabelHudElement == null)
                    {
                        _LabelHudElement = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <LabelHudElement>(this);
                    }
                    if (_LabelHudElement != null)
                    {
                        _LabelHudElement.Text = "Radius: " + _Segment.Radius(_Points).ToRoundedString();
                    }
                }

                if (_Coord2DHudElement != null)
                {
                    _Coord2DHudElement.CoordinateX = _PointAction.Point.X;
                    _Coord2DHudElement.CoordinateY = _PointAction.Point.Y;
                }
            }
        }
Пример #2
0
        //--------------------------------------------------------------------------------------------------

        void _AddCircleSegment(SketchSegmentCircle circleSegment)
        {
            var p1     = _Sketch.Points[circleSegment.CenterPoint];
            var radius = circleSegment.Radius(_Sketch.Points);

            var entity = new DxfDomCircle("0", p1, radius);

            _Document.Entities.Add(entity);
        }
        public void EqualCircles()
        {
            var sketch  = Sketch.Create();
            var p1      = sketch.AddPoint(new Pnt2d(0, -10));
            var p2      = sketch.AddPoint(new Pnt2d(0, 10));
            var circle1 = new SketchSegmentCircle(p1, p2);
            var s1      = sketch.AddSegment(circle1);
            var p3      = sketch.AddPoint(new Pnt2d(-5, -5));
            var p4      = sketch.AddPoint(new Pnt2d(5, 5));
            var circle2 = new SketchSegmentCircle(p3, p4);
            var s2      = sketch.AddSegment(circle2);
            var c1      = sketch.AddConstraint(new SketchConstraintEqual(s1, s2));

            Assert.IsTrue(sketch.SolveConstraints(true));
            Assert.AreEqual(circle1.Radius(sketch.Points), circle2.Radius(sketch.Points), MaxLengthDelta);
        }