|
|
@ -243,7 +243,7 @@ void UBGraphicsDelegateFrame::setCursorFromAngle(QString angle) |
|
|
|
|
|
|
|
|
|
|
|
QSize cursorSize(45,30); |
|
|
|
QSize cursorSize(45,30); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QImage mask_img(cursorSize, QImage::Format_Mono); |
|
|
|
QImage mask_img(cursorSize, QImage::Format_Mono); |
|
|
|
mask_img.fill(0xff); |
|
|
|
mask_img.fill(0xff); |
|
|
|
QPainter mask_ptr(&mask_img); |
|
|
|
QPainter mask_ptr(&mask_img); |
|
|
@ -252,7 +252,7 @@ void UBGraphicsDelegateFrame::setCursorFromAngle(QString angle) |
|
|
|
QBitmap bmpMask = QBitmap::fromImage(mask_img); |
|
|
|
QBitmap bmpMask = QBitmap::fromImage(mask_img); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPixmap pixCursor(cursorSize);
|
|
|
|
QPixmap pixCursor(cursorSize); |
|
|
|
pixCursor.fill(QColor(Qt::white)); |
|
|
|
pixCursor.fill(QColor(Qt::white)); |
|
|
|
|
|
|
|
|
|
|
|
QPainter painter(&pixCursor); |
|
|
|
QPainter painter(&pixCursor); |
|
|
@ -293,12 +293,12 @@ QPointF UBGraphicsDelegateFrame::getFixedPointFromPos() |
|
|
|
QPointF fixedPoint; |
|
|
|
QPointF fixedPoint; |
|
|
|
if (!moving() && !rotating()) |
|
|
|
if (!moving() && !rotating()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (resizingTop())
|
|
|
|
if (resizingTop()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ((0 < mAngle) && (mAngle < 90)) |
|
|
|
if ((0 < mAngle) && (mAngle < 90)) |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().topLeft();
|
|
|
|
fixedPoint = delegated()->sceneBoundingRect().topLeft(); |
|
|
|
else |
|
|
|
else |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().topRight(); |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().topRight(); |
|
|
|
} |
|
|
|
} |
|
|
@ -310,12 +310,12 @@ QPointF UBGraphicsDelegateFrame::getFixedPointFromPos() |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().bottomLeft(); |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().bottomLeft(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (resizingLeft())
|
|
|
|
else if (resizingLeft()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ((0 < mAngle) && (mAngle < 90)) |
|
|
|
if ((0 < mAngle) && (mAngle < 90)) |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().bottomLeft();
|
|
|
|
fixedPoint = delegated()->sceneBoundingRect().bottomLeft(); |
|
|
|
else |
|
|
|
else |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().topLeft(); |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().topLeft(); |
|
|
|
} |
|
|
|
} |
|
|
@ -337,14 +337,14 @@ QSizeF UBGraphicsDelegateFrame::getResizeVector(qreal moveX, qreal moveY) |
|
|
|
qreal dPosX = 0; |
|
|
|
qreal dPosX = 0; |
|
|
|
qreal dPosY = 0; |
|
|
|
qreal dPosY = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (resizingTop())
|
|
|
|
if (resizingTop()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
dPosY = moveY; |
|
|
|
dPosY = moveY; |
|
|
|
else |
|
|
|
else |
|
|
|
dPosY = -moveY; |
|
|
|
dPosY = -moveY; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (resizingLeft())
|
|
|
|
else if (resizingLeft()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
dPosX = moveX; |
|
|
|
dPosX = moveX; |
|
|
@ -354,7 +354,7 @@ QSizeF UBGraphicsDelegateFrame::getResizeVector(qreal moveX, qreal moveY) |
|
|
|
|
|
|
|
|
|
|
|
else if (resizingRight()) |
|
|
|
else if (resizingRight()) |
|
|
|
dPosX = (mMirrorX) ? -moveX : moveX; |
|
|
|
dPosX = (mMirrorX) ? -moveX : moveX; |
|
|
|
else if (resizingBottom())
|
|
|
|
else if (resizingBottom()) |
|
|
|
dPosY = mMirrorY ? -moveY : moveY; |
|
|
|
dPosY = mMirrorY ? -moveY : moveY; |
|
|
|
|
|
|
|
|
|
|
|
return QSizeF(dPosX, dPosY); |
|
|
|
return QSizeF(dPosX, dPosY); |
|
|
@ -363,7 +363,7 @@ QSizeF UBGraphicsDelegateFrame::getResizeVector(qreal moveX, qreal moveY) |
|
|
|
QSizeF UBGraphicsDelegateFrame::resizeDelegate(qreal moveX, qreal moveY) |
|
|
|
QSizeF UBGraphicsDelegateFrame::resizeDelegate(qreal moveX, qreal moveY) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSizeF incVector; |
|
|
|
QSizeF incVector; |
|
|
|
mFixedPoint = getFixedPointFromPos();
|
|
|
|
mFixedPoint = getFixedPointFromPos(); |
|
|
|
|
|
|
|
|
|
|
|
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated()); |
|
|
|
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated()); |
|
|
|
if (resizableItem) |
|
|
|
if (resizableItem) |
|
|
@ -382,15 +382,10 @@ QSizeF UBGraphicsDelegateFrame::resizeDelegate(qreal moveX, qreal moveY) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsDelegateFrame::scaleByPos(qreal scaleX, qreal scaleY) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (None == mCurrentTool) |
|
|
|
if (None == mCurrentTool) |
|
|
|
return;
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
QLineF move = QLineF(mStartingPoint, event->scenePos()); |
|
|
|
QLineF move = QLineF(mStartingPoint, event->scenePos()); |
|
|
|
qreal moveX = move.length() * cos((move.angle() - mAngle) * PI / 180); |
|
|
|
qreal moveX = move.length() * cos((move.angle() - mAngle) * PI / 180); |
|
|
@ -399,7 +394,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
qreal height = delegated()->boundingRect().height() * mTotalScaleY; |
|
|
|
qreal height = delegated()->boundingRect().height() * mTotalScaleY; |
|
|
|
|
|
|
|
|
|
|
|
if (mOperationMode == Scaling) |
|
|
|
if (mOperationMode == Scaling) |
|
|
|
{
|
|
|
|
{ |
|
|
|
if(!rotating()) |
|
|
|
if(!rotating()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mTranslateX = moveX; |
|
|
|
mTranslateX = moveX; |
|
|
@ -504,7 +499,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (rotating()) |
|
|
|
if (rotating()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mTranslateX = 0; |
|
|
|
mTranslateX = 0; |
|
|
@ -597,7 +592,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
delegated()->setTransform(buildTransform()); |
|
|
|
delegated()->setTransform(buildTransform()); |
|
|
|
} |
|
|
|
} |
|
|
|
else // resizing/resizing horizontally
|
|
|
|
else // resizing/resizing horizontally
|
|
|
|
{
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if (resizingBottomRight()) |
|
|
|
if (resizingBottomRight()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -609,9 +604,9 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
else |
|
|
|
else |
|
|
|
mCurrentTool = ResizeBottom; |
|
|
|
mCurrentTool = ResizeBottom; |
|
|
|
|
|
|
|
|
|
|
|
incV = resizeDelegate(moveX, moveY);
|
|
|
|
incV = resizeDelegate(moveX, moveY); |
|
|
|
mOriginalSize += incV; |
|
|
|
mOriginalSize += incV; |
|
|
|
|
|
|
|
|
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
mCurrentTool = ResizeLeft; |
|
|
|
mCurrentTool = ResizeLeft; |
|
|
|
else |
|
|
|
else |
|
|
@ -623,7 +618,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
|
|
|
|
|
|
|
mFixedPoint = getFixedPointFromPos(); |
|
|
|
mFixedPoint = getFixedPointFromPos(); |
|
|
|
|
|
|
|
|
|
|
|
incH = resizeDelegate(moveX, moveY);
|
|
|
|
incH = resizeDelegate(moveX, moveY); |
|
|
|
|
|
|
|
|
|
|
|
mOriginalSize -= incV; |
|
|
|
mOriginalSize -= incV; |
|
|
|
mOriginalSize += incH; |
|
|
|
mOriginalSize += incH; |
|
|
@ -631,7 +626,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
mCurrentTool = ResizeBottomRight; |
|
|
|
mCurrentTool = ResizeBottomRight; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
resizeDelegate(moveX, moveY);
|
|
|
|
resizeDelegate(moveX, moveY); |
|
|
|
} |
|
|
|
} |
|
|
|
event->accept(); |
|
|
|
event->accept(); |
|
|
|
} |
|
|
|
} |
|
|
@ -660,11 +655,11 @@ void UBGraphicsDelegateFrame::prepareFramesToMove(QList<UBGraphicsDelegateFrame |
|
|
|
foreach (UBGraphicsDelegateFrame *frame, mLinkedFrames) |
|
|
|
foreach (UBGraphicsDelegateFrame *frame, mLinkedFrames) |
|
|
|
{ |
|
|
|
{ |
|
|
|
frame->prepareLinkedFrameToMove(); |
|
|
|
frame->prepareLinkedFrameToMove(); |
|
|
|
}
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsDelegateFrame::prepareLinkedFrameToMove() |
|
|
|
void UBGraphicsDelegateFrame::prepareLinkedFrameToMove() |
|
|
|
{
|
|
|
|
{ |
|
|
|
mDelegate->startUndoStep(); |
|
|
|
mDelegate->startUndoStep(); |
|
|
|
|
|
|
|
|
|
|
|
mStartingPoint = QPointF(0,0); |
|
|
|
mStartingPoint = QPointF(0,0); |
|
|
@ -685,12 +680,12 @@ void UBGraphicsDelegateFrame::prepareLinkedFrameToMove() |
|
|
|
void UBGraphicsDelegateFrame::moveLinkedItems(QLineF movingVector, bool bLinked) |
|
|
|
void UBGraphicsDelegateFrame::moveLinkedItems(QLineF movingVector, bool bLinked) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (bLinked) |
|
|
|
if (bLinked) |
|
|
|
{
|
|
|
|
{ |
|
|
|
mCurrentTool = Move; |
|
|
|
mCurrentTool = Move; |
|
|
|
|
|
|
|
|
|
|
|
mTranslateX = movingVector.dx(); |
|
|
|
mTranslateX = movingVector.dx(); |
|
|
|
mTranslateY = movingVector.dy(); |
|
|
|
mTranslateY = movingVector.dy(); |
|
|
|
|
|
|
|
|
|
|
|
delegated()->setTransform(buildTransform(), false); |
|
|
|
delegated()->setTransform(buildTransform(), false); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -777,7 +772,7 @@ void UBGraphicsDelegateFrame::setVisible(bool visible) |
|
|
|
void UBGraphicsDelegateFrame::positionHandles() |
|
|
|
void UBGraphicsDelegateFrame::positionHandles() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QRectF itemRect = delegated()->boundingRect(); |
|
|
|
QRectF itemRect = delegated()->boundingRect(); |
|
|
|
|
|
|
|
|
|
|
|
if (mDelegate->getToolBarItem() && mDelegate->getToolBarItem()->isVisibleOnBoard() |
|
|
|
if (mDelegate->getToolBarItem() && mDelegate->getToolBarItem()->isVisibleOnBoard() |
|
|
|
&& mDelegate->getToolBarItem()->isShifting()) |
|
|
|
&& mDelegate->getToolBarItem()->isShifting()) |
|
|
|
{ |
|
|
|
{ |
|
|
|