GiTransformImpl(bool _ydown) : cxWnd(1), cyWnd(1), dpiX(96), dpiY(96), ydown(_ydown), viewScale(1) , zoomEnabled(true), tmpViewScale(1.f), zoomTimes(0) { minViewScale = 0.01f; // 最小显示比例为1% maxViewScale = 5.f; // 最大显示比例为500% rectLimitsW.set(Point2d::kOrigin(), 2e5f, 2e5f); updateTransforms(); }
void mgnear::moveRectHandle(Box2d& rect, int index, const Point2d& pt, bool lockCornerScale) { Point2d pts[4]; for (int i = 0; i < 4; i++) mgnear::getRectHandle(rect, index / 4 * 4 + i, pts[i]); pts[index % 4] = pt; if (index >= 0 && index < 4) { Point2d pt1(pt); if (lockCornerScale && !rect.isEmpty()) { Point2d& pt2 = pts[(index + 2) % 4]; float w = fabsf(pt2.x - pt.x); float h = fabsf(pt2.y - pt.y); if (w * rect.height() > h * rect.width()) h = w * rect.height() / rect.width(); else w = h * rect.width() / rect.height(); pt1.x = pt2.x + w * (pt2.x > pt.x ? -1.f : 1.f); pt1.y = pt2.y + h * (pt2.y > pt.y ? -1.f : 1.f); } if (index % 2 == 0) { pts[(index + 1) % 4].y = pt1.y; pts[(index + 3) % 4].x = pt1.x; } else { pts[(index + 1) % 4].x = pt1.x; pts[(index + 3) % 4].y = pt1.y; } rect.set(4, pts); } else if (index >= 4 && index < 8) { rect.set(pts[3].x, pts[2].y, pts[1].x, pts[0].y); } }