bool MgBaseRect::_setHandlePoint(UInt32 index, const Point2d& pt, float) { if (index < 4 && getFlag(kMgSquare)) { Point2d basept(getCenter()); Point2d pt2(pt * Matrix2d::rotation(-getAngle(), basept)); setRect(basept * 2.f - pt2.asVector(), pt2, getAngle(), basept); } else { Point2d pt2(pt * Matrix2d::rotation(-getAngle(), getCenter())); Box2d rect(getRect()); mgMoveRectHandle(rect, index, pt2); if (getFlag(kMgSquare) && (4 == index || 6 == index)) { rect = Box2d(rect.center(), rect.height(), rect.height()); } else if (getFlag(kMgSquare)) { rect = Box2d(rect.center(), rect.width(), rect.width()); } setRect(rect.leftTop(), rect.rightBottom(), getAngle(), getCenter()); } update(); return true; }
bool MgBaseShape::_rotateHandlePoint(int index, const Point2d& pt) { if (getFlag(kMgFixedLength)) { if (getFlag(kMgRotateDisnable)) { offset(pt - getHandlePoint(index), -1); } else { Point2d basept(_extent.center()); if (!getFlag(kMgSquare)) { int baseindex = index > 0 ? index - 1 : getHandleCount() - 1; while (baseindex > 0 && isHandleFixed(baseindex)) baseindex--; basept = (getHandlePoint(baseindex)); } float a1 = (pt - basept).angle2(); float a2 = (getHandlePoint(index) - basept).angle2(); transform(Matrix2d::rotation(a1 - a2, basept)); } return true; } return false; }