Пример #1
0
        public override void SetGripPointAt(int index, GripPoint gripPoint, CADPoint newPosition)
        {
            if (index == 0)
            {
                _center = newPosition;
            }
            else if (index >= 1 && index <= 3)
            {
                CADPoint startPoint  = this.startPoint;
                CADPoint endPoint    = this.endPoint;
                CADPoint middlePoint = this.middlePoint;

                if (index == 1)
                {
                    startPoint  = newPosition;
                    middlePoint = (CADPoint)gripPoint.xData1;
                }
                else if (index == 2)
                {
                    endPoint    = newPosition;
                    middlePoint = (CADPoint)gripPoint.xData1;
                }
                else if (index == 3)
                {
                    middlePoint = newPosition;
                }

                Circle2 newCircle = Circle2.From3Points(
                    startPoint, middlePoint, endPoint);
                if (newCircle.radius > 0)
                {
                    CADVector xPositive  = new CADVector(1, 0);
                    double    startAngle = CADVector.SignedAngleInRadian(xPositive,
                                                                         startPoint - newCircle.center);
                    double endAngle = CADVector.SignedAngleInRadian(xPositive,
                                                                    endPoint - newCircle.center);
                    double middleAngle = CADVector.SignedAngleInRadian(xPositive,
                                                                       middlePoint - newCircle.center);
                    startAngle  = MathUtils.NormalizeRadianAngle(startAngle);
                    endAngle    = MathUtils.NormalizeRadianAngle(endAngle);
                    middleAngle = MathUtils.NormalizeRadianAngle(middleAngle);

                    _center = newCircle.center;
                    _radius = newCircle.radius;
                    if (AngleInArcRange(middleAngle, startAngle, endAngle))
                    {
                        this.startAngle = startAngle;
                        this.endAngle   = endAngle;
                    }
                    else
                    {
                        this.startAngle = endAngle;
                        this.endAngle   = startAngle;
                    }
                }
            }
        }