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

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 0:
                    _Points.Add(0, _PointAction.Point);
                    _MergePointIndices[0] = _PointAction.MergeCandidateIndex;
                    _PointsCompleted++;

                    _SketchEditorTool.StatusText = "Select end point for circular arc.";

                    _PointAction.Reset();
                    break;

                case 1:
                    if (_Points[0].Distance(_PointAction.Point) < 0.001)
                    {
                        // Minimum length not met
                        _PointAction.Reset();
                        return;
                    }

                    _Points.Add(1, _PointAction.Point);
                    _MergePointIndices[1] = _PointAction.MergeCandidateIndex;
                    _PointsCompleted++;

                    _Points.Add(2, _PointAction.Point);
                    _Segment = new SketchSegmentArc(0, 1, 2);

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

                    _SketchEditorTool.StatusText = "Select rim point for circular arc.";

                    _PointAction.Reset();
                    break;

                case 2:
                    if (_Points[0].Distance(_PointAction.Point) < 0.001 ||
                        _Points[1].Distance(_PointAction.Point) < 0.001)
                    {
                        // Minimum length not met
                        _PointAction.Reset();
                        return;
                    }

                    _PointAction.Stop();

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

                    _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null);
                    break;
                }
            }
        }
コード例 #2
0
        //--------------------------------------------------------------------------------------------------

        void _SetSecondPoint(Pnt2d point, int mergeCandidateIndex)
        {
            if (Math.Abs(_Points[0].X - point.X) < 0.001 ||
                Math.Abs(_Points[0].Y - point.Y) < 0.001)
            {
                // Minimum length not met
                _PointAction.Reset();
                return;
            }

            _PointAction.Stop();

            _UpdateCornerPoints(point);
            _MergePointIndices[1] = -1;
            _MergePointIndices[2] = mergeCandidateIndex;
            _MergePointIndices[3] = -1;

            var constraints = new SketchConstraintPerpendicular[4];

            constraints[0] = new SketchConstraintPerpendicular(0, 1);
            constraints[1] = new SketchConstraintPerpendicular(1, 2);
            constraints[2] = new SketchConstraintPerpendicular(2, 3);
            constraints[3] = new SketchConstraintPerpendicular(3, 0);

            _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, _Segments, constraints);
        }
コード例 #3
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);

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

                    _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);
                }
            }
        }
コード例 #4
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 0:
                    _CenterPoint = _PointAction.Point;
                    _Points.Add(0, _PointAction.Point);
                    _MergePointIndices[0] = _PointAction.MergeCandidateIndex;
                    _PointsCompleted++;

                    _SketchEditorTool.StatusText = "Select start point for elliptical arc.";

                    _PointAction.Reset();
                    break;

                case 1:
                    if (_CenterPoint.Distance(_PointAction.Point) < 0.001)
                    {
                        // Minimum distance not met
                        _PointAction.Reset();
                        return;
                    }

                    _StartPoint           = _PointAction.Point;
                    _StartPointMergeIndex = _PointAction.MergeCandidateIndex;
                    _PointsCompleted++;

                    _Points.Add(1, _PointAction.Point);
                    _Points.Add(2, _PointAction.Point);
                    _Segment = new SketchSegmentEllipticalArc(1, 2, 0);

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

                    _SketchEditorTool.StatusText = "Select end point for elliptical arc.";

                    _PointAction.Reset();
                    break;

                case 2:
                    if (!_CalcArcRimPoints(_PointAction.Point, _PointAction.MergeCandidateIndex))
                    {
                        // Minimum length not met
                        _PointAction.Reset();
                        return;
                    }

                    _PointAction.Stop();

                    _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null);
                    break;
                }
            }
        }
コード例 #5
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                if (_Segments == null)
                {
                    _Points.Add(0, _PointAction.Point);
                    _MergePointIndices[0] = _PointAction.MergeCandidateIndex;
                    _SetSecondPoint(_PointAction.Point);

                    _Segments    = new SketchSegmentLine[4];
                    _Segments[0] = new SketchSegmentLine(0, 1);
                    _Segments[1] = new SketchSegmentLine(1, 2);
                    _Segments[2] = new SketchSegmentLine(2, 3);
                    _Segments[3] = new SketchSegmentLine(3, 0);

                    _Elements = new SketchEditorSegmentElement[4];
                    for (int i = 0; i < _Elements.Length; i++)
                    {
                        _Elements[i]            = new SketchEditorSegmentElement(_SketchEditorTool, -1, _Segments[i], _SketchEditorTool.Transform, _SketchEditorTool.Sketch.Plane);
                        _Elements[i].IsCreating = true;
                        _Elements[i].OnPointsChanged(_Points, null);
                    }

                    _SketchEditorTool.StatusText = "Select second corner or the rectangle.";

                    _PointAction.Reset();
                }
                else
                {
                    if (Math.Abs(_Points[0].X - _PointAction.Point.X) < 0.001 ||
                        Math.Abs(_Points[0].Y - _PointAction.Point.Y) < 0.001)
                    {
                        // Minimum length not met
                        _PointAction.Reset();
                        return;
                    }

                    _PointAction.Stop();

                    _SetSecondPoint(_PointAction.Point);
                    _MergePointIndices[1] = -1;
                    _MergePointIndices[2] = _PointAction.MergeCandidateIndex;
                    _MergePointIndices[3] = -1;

                    var constraints = new SketchConstraintPerpendicular[4];
                    constraints[0] = new SketchConstraintPerpendicular(0, 1);
                    constraints[1] = new SketchConstraintPerpendicular(1, 2);
                    constraints[2] = new SketchConstraintPerpendicular(2, 3);
                    constraints[3] = new SketchConstraintPerpendicular(3, 0);

                    _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, _Segments, constraints);
                }
            }
        }
コード例 #6
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 0:
                    _CenterPoint = _PointAction.Point;
                    _PointsCompleted++;

                    _SketchEditorTool.StatusText = "Select start point for circular arc.";

                    _PointAction.Reset();
                    break;

                case 1:
                    _SetStartPoint(_PointAction.Point, _PointAction.MergeCandidateIndex);
                    break;

                case 2:
                    if (!_CalcArcRimPoints(_PointAction.Point) ||
                        _Points[0].Distance(_Points[2]) < 0.001)
                    {
                        // Minimum length not met
                        _PointAction.Reset();
                        return;
                    }

                    _PointAction.Stop();

                    _MergePointIndices[1] = _PointAction.MergeCandidateIndex;
                    _MergePointIndices[2] = -1;

                    _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null);
                    break;
                }
            }
        }
コード例 #7
0
        //--------------------------------------------------------------------------------------------------

        void _SetSecondRimPoint(Pnt2d point, int mergeCandidateIndex)
        {
            if (_Points[0].Distance(point) < 0.001 ||
                _Points[1].Distance(point) < 0.001)
            {
                // Min distance not met
                _PointAction.Reset();
                return;
            }

            _Points[2]            = point;
            _MergePointIndices[2] = mergeCandidateIndex;

            _PointAction.Stop();

            _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null);
        }
コード例 #8
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (pointsFinished)
                {
                case 0:
                    // Start point
                    _Points[0]            = _PointAction.Point;
                    _MergePointIndices[0] = _PointAction.MergeCandidateIndex;

                    _HintLine = new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    _HintLine.Set(_PointAction.Point, _PointAction.Point, _SketchEditorTool.Sketch.Plane);

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

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

                    _PointAction.Reset();
                    pointsFinished++;
                    break;

                case 1:
                    _SetEndPoint(_PointAction.Point, _PointAction.MergeCandidateIndex);
                    break;

                case 2:
                    // Control point, finished
                    _PointAction.Stop();

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

                    _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null, _MergePointIndices[1] >= 0 ? -1 : 2);
                    pointsFinished++;
                    break;
                }
            }
        }
コード例 #9
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 SketchSegmentCircle(0, 1);

                    _Marker = new Marker(_SketchEditorTool.WorkspaceController, Marker.Styles.Bitmap | Marker.Styles.Topmost, Marker.BallImage);
                    _Marker.Set(_PointAction.Point, _SketchEditorTool.Sketch.Plane);

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

                    _SketchEditorTool.WorkspaceController.Invalidate();

                    _SketchEditorTool.StatusText = "Select any rim point of the circle.";

                    _PointAction.Reset();
                }
                else
                {
                    if (_Points[0].Distance(_PointAction.Point) < 0.001)
                    {
                        // Minimum length not met
                        _PointAction.Reset();
                        return;
                    }

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

                    _PointAction.Stop();

                    _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null);
                }
            }
        }
コード例 #10
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (pointsFinished)
                {
                case 0:
                    // Start point
                    _Points.Add(0, _PointAction.Point);
                    _MergePointIndices[0] = _PointAction.MergeCandidateIndex;

                    _HintLine = new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    _HintLine.Set(_PointAction.Point, _PointAction.Point, _SketchEditorTool.Sketch.Plane);

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

                    _PointAction.Reset();
                    pointsFinished++;
                    break;

                case 1:
                    // End point
                    if (_Points[0].Distance(_PointAction.Point) < 0.001)
                    {
                        // Minimum length not met
                        _PointAction.Reset();
                        return;
                    }

                    _Points.Add(1, _PointAction.Point);
                    _Points.Add(2, _PointAction.Point);
                    _MergePointIndices[2] = _PointAction.MergeCandidateIndex;

                    _Segment = new SketchSegmentBezier(0, 1, 2);

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

                    _HintLine.Remove();
                    _HintLine = null;

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

                    _PointAction.Reset();
                    pointsFinished++;
                    break;

                case 2:
                    // Control point, finished
                    _PointAction.Stop();

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

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

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 0:
                    _Points.Add(0, _PointAction.Point);
                    _MergePointIndices[0] = _PointAction.MergeCandidateIndex;
                    _PointsCompleted++;

                    _Marker[0] = new Marker(_SketchEditorTool.WorkspaceController, Marker.Styles.Bitmap | Marker.Styles.Topmost, Marker.BallImage);
                    _Marker[0].Set(_PointAction.Point, _SketchEditorTool.Sketch.Plane);

                    _SketchEditorTool.StatusText = "Select first rim point of the ellipse.";

                    _PointAction.Reset();
                    break;

                case 1:
                    if (_Points[0].Distance(_PointAction.Point) < 0.001)
                    {
                        // Min distance not met
                        _PointAction.Reset();
                        return;
                    }

                    if (_HintCircle != null)
                    {
                        _HintCircle.Remove();
                        _HintCircle = null;
                    }
                    if (_HintLine != null)
                    {
                        _HintLine.Remove();
                        _HintLine = null;
                    }

                    _Points.Add(1, _PointAction.Point);
                    _MergePointIndices[1] = _PointAction.MergeCandidateIndex;
                    _PointsCompleted++;

                    _Marker[1] = new Marker(_SketchEditorTool.WorkspaceController, Marker.Styles.Bitmap | Marker.Styles.Topmost, Marker.BallImage);
                    _Marker[1].Set(_PointAction.Point, _SketchEditorTool.Sketch.Plane);

                    _Points.Add(2, _PointAction.Point);
                    _Segment = new SketchSegmentEllipse(0, 1, 2);

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

                    _SketchEditorTool.StatusText = "Select second rim point of the ellipse.";

                    _PointAction.Reset();
                    break;

                case 2:
                    if (_Points[0].Distance(_PointAction.Point) < 0.001 ||
                        _Points[1].Distance(_PointAction.Point) < 0.001)
                    {
                        // Min distance not met
                        _PointAction.Reset();
                        return;
                    }

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

                    _PointAction.Stop();

                    _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null);
                    break;
                }
            }
        }