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

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