Fixed scaling of rotated and mirrored images.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent 370e5b37d0
commit c4f4343be8
  1. 27
      src/domain/UBGraphicsDelegateFrame.cpp

@ -477,29 +477,20 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QTransform tr = buildTransform(); QTransform tr = buildTransform();
//TODO UB 4.x: Could find a better solution ?
if (resizingRight() || resizingBottom() || resizingBottomRight()) if (resizingRight() || resizingBottom() || resizingBottomRight())
{ {
QPointF ref; QPointF ref;
if(!mMirrorX && !mMirrorY){
ref = delegated()->boundingRect().topLeft();
}else if(mMirrorX && !mMirrorY){
ref = delegated()->boundingRect().topLeft();
}else if(!mMirrorX && mMirrorY){
ref = delegated()->boundingRect().topLeft();
}else if(mMirrorX && mMirrorY){
ref = delegated()->boundingRect().topRight();
}
// Map the item topleft point to the current mouse move transform
QPointF topLeft = tr.map(ref);
// Map the item topleft point to the mouse press transform // we just detects coordinates of corner before and after scaling and then moves object at diff between them.
QPointF fixedPoint = mInitialTransform.map(ref); if (resizingBottomRight() && mMirrorX)
mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x();
else
mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x();
// Update the translation coordinates if (resizingBottomRight() && mMirrorY)
mTranslateX += fixedPoint.x() - topLeft.x(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y();
mTranslateY += fixedPoint.y() - topLeft.y(); else
mTranslateY += mInitialTransform.map(delegated()->boundingRect().topLeft()).y() - tr.map(delegated()->boundingRect().topLeft()).y();
// Update the transform // Update the transform
tr = buildTransform(); tr = buildTransform();

Loading…
Cancel
Save