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

        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);
            }
        }
示例#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);
            }
        }
        //--------------------------------------------------------------------------------------------------

        void _UpdateHints()
        {
            if (Entity?.Body?.Shape != Entity)
            {
                return;
            }

            var axis = Entity?.GetRotationAxis()?.Transformed(Entity.Body.GetTransformation());

            if (axis == null)
            {
                _ClearHints();
                return;
            }

            if (_HintCircle == null)
            {
                _HintCircle = new HintCircle(WorkspaceController, HintStyle.Solid);
            }

            _HintCircle.Set(new gp_Circ(axis.Value.ToAx2(), Entity.Radius));
            var(startAngle, endAngle) = Entity.GetStartEndAngles();
            _HintCircle.SetRange(startAngle, endAngle);

            if (_HintAngles == null)
            {
                _HintAngles    = new HintLine[3];
                _HintAngles[0] = new HintLine(WorkspaceController, HintStyle.ThinDashed);
                _HintAngles[1] = new HintLine(WorkspaceController, HintStyle.Solid);
                _HintAngles[2] = new HintLine(WorkspaceController, HintStyle.Dashed);
            }

            var centerPoint  = axis.Value.Location;
            var mainVec      = axis.Value.XDirection.ToVec() * Entity.Radius;
            var localRotAxis = new Ax1(Pnt.Origin, axis.Value.Axis.Direction);

            _HintAngles[0].Set(centerPoint, centerPoint.Translated(mainVec));
            _HintAngles[1].Set(centerPoint, centerPoint.Translated(mainVec.Rotated(localRotAxis, startAngle.ToRad())));
            _HintAngles[2].Set(centerPoint, centerPoint.Translated(mainVec.Rotated(localRotAxis, endAngle.ToRad())));

            WorkspaceController.Invalidate();
        }
        //--------------------------------------------------------------------------------------------------

        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);
            }
        }