コード例 #1
0
        //--------------------------------------------------------------------------------------------------

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

                case 2:
                    if (_Segment != null)
                    {
                        _Points[2] = _PointAction.Point;
                        _Element.OnPointsChanged(_Points, null);

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

                _Coord2DHudElement?.SetValues(_PointAction.Point.X, _PointAction.Point.Y);
            }
        }
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 1:
                    if (_HintCircle == null)
                    {
                        _HintCircle = new HintCircle(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    }
                    if (_HintLine == null)
                    {
                        _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 (_LabelHudElement == null)
                    {
                        _LabelHudElement = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <LabelHudElement>(this);
                    }
                    _LabelHudElement?.SetValue("Distance: " + _Points[0].Distance(_PointAction.Point).ToRoundedString());
                    break;

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

                _Coord2DHudElement?.SetValues(_PointAction.Point.X, _PointAction.Point.Y);
            }
        }
コード例 #3
0
        //--------------------------------------------------------------------------------------------------

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

                    _LabelHudElement?.SetValue("Length: " + _Segment.Length(_Points).ToRoundedString() + " mm");
                }

                _Coord2DHudElement?.SetValues(_PointAction.Point.X, _PointAction.Point.Y);
            }
        }
コード例 #4
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                if (_Segment == null)
                {
                    _Points.Add(0, _PointAction.Point);
                    _MergePointIndices[0] = _PointAction.MergeCandidateIndex;
                    _Points.Add(1, _PointAction.Point);
                    _Segment = new SketchSegmentLine(0, 1);

                    _Element            = new SketchEditorSegmentElement(_SketchEditorTool, -1, _Segment, _SketchEditorTool.Transform, _SketchEditorTool.Sketch.Plane);
                    _Element.IsCreating = true;
                    _Element.OnPointsChanged(_Points, null);

                    _LabelHudElement = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <LabelHudElement>(this);
                    _LabelHudElement?.SetValue("Length: " + _Segment.Length(_Points).ToRoundedString());

                    _SketchEditorTool.StatusText = "Select end point for line.";

                    _PointAction.Reset();
                }
                else
                {
                    if (_Points[0].Distance(_PointAction.Point) < 0.001)
                    {
                        _PointAction.Reset();
                        return;
                    }

                    _Points[1]            = _PointAction.Point;
                    _MergePointIndices[1] = _PointAction.MergeCandidateIndex;

                    // Accept point
                    _PointAction.Stop();

                    _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null, _MergePointIndices[1] >= 0 ? -1 : 1);
                }
            }
        }