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

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 1:
                    _PreviewLine ??= new HintCircle(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    _HintLines[0] ??= new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    var circ = new gce_MakeCirc2d(_CenterPoint, _PointAction.Point).Value();
                    _PreviewLine.Set(circ, _SketchEditorTool.Sketch.Plane);
                    _HintLines[0].Set(_CenterPoint, _PointAction.Point, _SketchEditorTool.Sketch.Plane);

                    if (_ValueHudElement == null && _SketchEditorTool.WorkspaceController.HudManager != null)
                    {
                        _ValueHudElement               = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <ValueHudElement>(this);
                        _ValueHudElement.Label         = "Radius:";
                        _ValueHudElement.Units         = ValueUnits.Length;
                        _ValueHudElement.ValueEntered += _ValueHudElement_RadiusEntered;
                    }
                    _ValueHudElement?.SetValue(circ.Radius());
                    break;

                case 2:
                    _HintLines[1] ??= new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    _HintLines[1].Set(_CenterPoint, _PointAction.Point, _SketchEditorTool.Sketch.Plane);

                    if (_ValueHudElement == null && _SketchEditorTool.WorkspaceController.HudManager != null)
                    {
                        _ValueHudElement               = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <ValueHudElement>(this);
                        _ValueHudElement.Label         = "Angle:";
                        _ValueHudElement.Units         = ValueUnits.Degree;
                        _ValueHudElement.ValueEntered += _ValueHudElement_AngleEntered;
                    }

                    if (_Segment != null)
                    {
                        if (_CalcArcRimPoints(_PointAction.Point))
                        {
                            _Element.OnPointsChanged(_Points, null);
                            _ValueHudElement?.SetValue(_Segment.Angle(_Points).ToDeg());
                        }
                        else
                        {
                            _Element.Remove();
                            _ValueHudElement?.SetValue(0);
                        }
                    }
                    break;
                }

                _Coord2DHudElement?.SetValues(_PointAction.PointOnWorkingPlane.X, _PointAction.PointOnWorkingPlane.Y);
            }
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 1:
                    if (_PreviewLine == null)
                    {
                        _PreviewLine = new HintCircle(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    }
                    if (_HintLines[0] == null)
                    {
                        _HintLines[0] = new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    }
                    var p1   = _CenterPoint;
                    var p2   = _PointAction.Point;
                    var circ = new gce_MakeCirc2d(p1, p2).Value();
                    _PreviewLine.Set(circ, _SketchEditorTool.Sketch.Plane);
                    _HintLines[0].Set(_CenterPoint, _PointAction.Point, _SketchEditorTool.Sketch.Plane);

                    if (_LabelHudElement == null)
                    {
                        _LabelHudElement = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <LabelHudElement>(this);
                    }
                    _LabelHudElement?.SetValue("Radius: " + circ.Radius().ToRoundedString());
                    break;

                case 2:
                    if (_HintLines[1] == null)
                    {
                        _HintLines[1] = new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    }
                    _HintLines[1].Set(_CenterPoint, _PointAction.Point, _SketchEditorTool.Sketch.Plane);

                    if (_Segment != null)
                    {
                        _CalcArcRimPoints(_PointAction.Point);
                        _Element.OnPointsChanged(_Points, null);
                    }
                    break;
                }

                _Coord2DHudElement?.SetValues(_PointAction.Point.X, _PointAction.Point.Y);
            }
        }
Ejemplo n.º 3
0
        //--------------------------------------------------------------------------------------------------

        public gp_Circ2d GetCircle(Dictionary <int, Pnt2d> points, double[] parameter = null)
        {
            var start = points[Points[0]];
            var end   = points[Points[1]];
            var rim   = points[Points[2]];

            if ((start.Distance(end) <= 0) || (end.Distance(rim) <= 0) || (start.Distance(rim) <= 0))
            {
                return(null);
            }

            var circ = new gce_MakeCirc2d(start, rim, end).Value();

            if (circ != null && parameter != null)
            {
                Debug.Assert(parameter.Length == 2);
                parameter[0] = ElCLib.Parameter(circ, start);
                parameter[1] = ElCLib.Parameter(circ, end);
            }
            return(circ);
        }
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 1:
                    _HintCircle ??= new HintCircle(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    _HintLine ??= new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    var p1   = _Points[0];
                    var p2   = _PointAction.Point;
                    var circ = new gce_MakeCirc2d(p1, p2).Value();
                    _HintCircle.Set(circ, _SketchEditorTool.Sketch.Plane);
                    _HintLine.Set(p1, p2, _SketchEditorTool.Sketch.Plane);

                    if (_ValueHudElement == null && _SketchEditorTool.WorkspaceController.HudManager != null)
                    {
                        _ValueHudElement               = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <ValueHudElement>(this);
                        _ValueHudElement.Label         = "Distance:";
                        _ValueHudElement.Units         = ValueUnits.Length;
                        _ValueHudElement.ValueEntered += _ValueHudElement_ValueEntered;
                    }
                    _ValueHudElement?.SetValue(_Points[0].Distance(_PointAction.Point));
                    _Points[1] = p2;
                    break;

                case 2:
                    if (_Segment != null)
                    {
                        _Points[2] = _PointAction.Point;
                        _Element.OnPointsChanged(_Points, null);
                    }
                    _ValueHudElement?.SetValue(_Points[0].Distance(_PointAction.Point));
                    _Points[2] = _PointAction.Point;
                    break;
                }

                _Coord2DHudElement?.SetValues(_PointAction.PointOnWorkingPlane.X, _PointAction.PointOnWorkingPlane.Y);
            }
        }