|
|
@ -49,6 +49,8 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega |
|
|
|
, mTotalTranslateX(0) |
|
|
|
, mTotalTranslateX(0) |
|
|
|
, mTotalTranslateY(0) |
|
|
|
, mTotalTranslateY(0) |
|
|
|
, mOperationMode(Scaling) |
|
|
|
, mOperationMode(Scaling) |
|
|
|
|
|
|
|
, mFlippedX(false) |
|
|
|
|
|
|
|
, mFlippedY(false) |
|
|
|
, mMirrorX(false) |
|
|
|
, mMirrorX(false) |
|
|
|
, mMirrorY(false) |
|
|
|
, mMirrorY(false) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -379,6 +381,12 @@ QSizeF UBGraphicsDelegateFrame::resizeDelegate(qreal moveX, qreal moveY) |
|
|
|
return incVector; |
|
|
|
return incVector; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsDelegateFrame::scaleByPos(qreal scaleX, qreal scaleY) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (None == mCurrentTool) |
|
|
|
if (None == mCurrentTool) |
|
|
@ -451,6 +459,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
scaleX = -2*mFrameWidth/width; |
|
|
|
scaleX = -2*mFrameWidth/width; |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
scaleX = -1; |
|
|
|
scaleX = -1; |
|
|
|
|
|
|
|
mFlippedX = !mFlippedX; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
mScaleX = scaleX; |
|
|
|
mScaleX = scaleX; |
|
|
@ -480,6 +489,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
scaleY = -2*mFrameWidth/width; |
|
|
|
scaleY = -2*mFrameWidth/width; |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
scaleY = -1; |
|
|
|
scaleY = -1; |
|
|
|
|
|
|
|
mFlippedY = !mFlippedY; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
mScaleY = scaleY; |
|
|
|
mScaleY = scaleY; |
|
|
@ -543,11 +553,34 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
QPointF ref; |
|
|
|
QPointF ref; |
|
|
|
|
|
|
|
|
|
|
|
// we just detects coordinates of corner before and after scaling and then moves object at diff between them.
|
|
|
|
// we just detects coordinates of corner before and after scaling and then moves object at diff between them.
|
|
|
|
if (resizingBottomRight() && mMirrorX) |
|
|
|
if (resizingBottomRight() && (mMirrorX || mMirrorY)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (mFlippedX && !mMirrorX && mFlippedY)// && !mMirrorY)
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomLeft()).x() - tr.map(delegated()->boundingRect().bottomLeft()).x(); |
|
|
|
|
|
|
|
mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomLeft()).y() - tr.map(delegated()->boundingRect().bottomLeft()).y(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if ((mFlippedX || mMirrorX) && (mFlippedY || mMirrorY)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x(); |
|
|
|
|
|
|
|
mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (mFlippedX || mMirrorX) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mTranslateX += mInitialTransform.map(delegated()->boundingRect().topRight()).x() - tr.map(delegated()->boundingRect().topRight()).x(); |
|
|
|
|
|
|
|
mTranslateY += mInitialTransform.map(delegated()->boundingRect().topRight()).y() - tr.map(delegated()->boundingRect().topRight()).y(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (mFlippedY || mMirrorY) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomLeft()).x() - tr.map(delegated()->boundingRect().bottomLeft()).x(); |
|
|
|
|
|
|
|
mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomLeft()).y() - tr.map(delegated()->boundingRect().bottomLeft()).y(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x(); |
|
|
|
mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x(); |
|
|
|
mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y(); |
|
|
|
mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x(); |
|
|
|
mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x(); |
|
|
|