|
|
@ -29,8 +29,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "core/memcheck.h" |
|
|
|
#include "core/memcheck.h" |
|
|
|
|
|
|
|
|
|
|
|
qreal const UBGraphicsDelegateFrame::mAngleTolerance = 6; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelegate, QRectF pRect, qreal pFrameWidth, bool respectRatio) |
|
|
|
UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelegate, QRectF pRect, qreal pFrameWidth, bool respectRatio) |
|
|
|
: QGraphicsRectItem(), QObject(pDelegate) |
|
|
|
: QGraphicsRectItem(), QObject(pDelegate) |
|
|
|
, mCurrentTool(None) |
|
|
|
, mCurrentTool(None) |
|
|
@ -51,6 +49,8 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega |
|
|
|
, mMirrorX(false) |
|
|
|
, mMirrorX(false) |
|
|
|
, mMirrorY(false) |
|
|
|
, mMirrorY(false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
mAngleTolerance = UBSettings::settings()->angleTolerance->get().toReal(); |
|
|
|
|
|
|
|
|
|
|
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
|
|
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
|
|
|
|
|
|
|
|
|
|
|
setAcceptedMouseButtons(Qt::LeftButton); |
|
|
|
setAcceptedMouseButtons(Qt::LeftButton); |
|
|
@ -90,11 +90,14 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega |
|
|
|
positionHandles(); |
|
|
|
positionHandles(); |
|
|
|
|
|
|
|
|
|
|
|
this->setAcceptHoverEvents(true); |
|
|
|
this->setAcceptHoverEvents(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
angleWidget = new UBAngleWidget(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBGraphicsDelegateFrame::~UBGraphicsDelegateFrame() |
|
|
|
UBGraphicsDelegateFrame::~UBGraphicsDelegateFrame() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
delete angleWidget; |
|
|
|
// NOOP
|
|
|
|
// NOOP
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -372,7 +375,9 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
QLineF startLine(sceneBoundingRect().center(), event->lastScenePos()); |
|
|
|
QLineF startLine(sceneBoundingRect().center(), event->lastScenePos()); |
|
|
|
QLineF currentLine(sceneBoundingRect().center(), event->scenePos()); |
|
|
|
QLineF currentLine(sceneBoundingRect().center(), event->scenePos()); |
|
|
|
mAngle += startLine.angleTo(currentLine); |
|
|
|
mAngle += startLine.angleTo(currentLine); |
|
|
|
if ((int)mAngle % 45 >= 45 - mAngleTolerance || (int)mAngle % 45 <= mAngleTolerance) |
|
|
|
|
|
|
|
|
|
|
|
if ((int)mAngle % 45 >= 45 - mAngleTolerance
|
|
|
|
|
|
|
|
|| (int)mAngle % 45 <= mAngleTolerance) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mAngle = qRound(mAngle / 45) * 45; |
|
|
|
mAngle = qRound(mAngle / 45) * 45; |
|
|
|
mAngleOffset += startLine.angleTo(currentLine); |
|
|
|
mAngleOffset += startLine.angleTo(currentLine); |
|
|
@ -382,6 +387,23 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
mAngleOffset = 0; |
|
|
|
mAngleOffset = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if ((int)mAngle % 30 >= 30 - mAngleTolerance |
|
|
|
|
|
|
|
|| (int)mAngle % 30 <= mAngleTolerance) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mAngle = qRound(mAngle / 30) * 30; |
|
|
|
|
|
|
|
mAngleOffset += startLine.angleTo(currentLine); |
|
|
|
|
|
|
|
if ((int)mAngleOffset % 360 > mAngleTolerance && (int)mAngleOffset % 360 < 360 - mAngleTolerance) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mAngle += mAngleOffset; |
|
|
|
|
|
|
|
mAngleOffset = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!angleWidget->isVisible()) |
|
|
|
|
|
|
|
angleWidget->show(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
angleWidget->setText(QString::number((int)mAngle % 360)); |
|
|
|
|
|
|
|
angleWidget->update(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (moving()) |
|
|
|
else if (moving()) |
|
|
@ -451,6 +473,9 @@ QTransform UBGraphicsDelegateFrame::buildTransform() |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (angleWidget->isVisible()) |
|
|
|
|
|
|
|
angleWidget->hide(); |
|
|
|
|
|
|
|
|
|
|
|
updateResizeCursors(); |
|
|
|
updateResizeCursors(); |
|
|
|
|
|
|
|
|
|
|
|
mDelegate->commitUndoStep(); |
|
|
|
mDelegate->commitUndoStep(); |
|
|
|