From 759fe210a7930ba42c93382f28f28a633d4de5c0 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Fri, 18 May 2012 13:13:45 +0300 Subject: [PATCH] SANKORE-599 When it rotates with the tool bracket gestures to change its size are not consistent. The parameters of size change does not take into account the position of the bracket. SANKORE-598 Changing the size of the bracket using the angles opposite the right angle does not work all the time, we must rotate the bracket so you can change its size --- src/board/UBBoardView.cpp | 2 ++ src/tools/UBGraphicsTriangle.cpp | 9 ++------- src/tools/UBGraphicsTriangle.h | 2 ++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 282c6f7d..9fa69084 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -54,6 +54,7 @@ #include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCache.h" +#include "tools/UBGraphicsTriangle.h" #include "core/memcheck.h" @@ -430,6 +431,7 @@ UBBoardView::mousePressEvent (QMouseEvent *event) || movingItem->type() == UBGraphicsCompass::Type || movingItem->type() == UBGraphicsPDFItem::Type || movingItem->type() == UBGraphicsPolygonItem::Type + || movingItem->type() == UBGraphicsTriangle::Type || movingItem->type() == UBGraphicsCache::Type || scene()->isBackgroundObject(movingItem)) { diff --git a/src/tools/UBGraphicsTriangle.cpp b/src/tools/UBGraphicsTriangle.cpp index e5c7fdeb..36f50015 100644 --- a/src/tools/UBGraphicsTriangle.cpp +++ b/src/tools/UBGraphicsTriangle.cpp @@ -586,7 +586,7 @@ QCursor UBGraphicsTriangle::flipCursor() const void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event) { lastRect = rect().toRect(); - lastPos = event->screenPos(); + lastPos = transform().inverted().map(event->screenPos()); if (resize1Polygon().containsPoint(event->pos().toPoint(), Qt::OddEvenFill)) { @@ -620,18 +620,13 @@ void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - QPoint currPos = event->screenPos(); -// qDebug() << QString(" X: %1 ").arg(currPos.x()); -// qDebug() << QString(" Y: %1 ").arg(currPos.y()); - if (!mResizing1 && !mResizing2 && !mRotating) { QGraphicsItem::mouseMoveEvent(event); } else { - - //-----------------------------------------------// + QPoint currPos = transform().inverted().map(event->screenPos()); if (mResizing1) { diff --git a/src/tools/UBGraphicsTriangle.h b/src/tools/UBGraphicsTriangle.h index da12bd0c..c7d8a54c 100644 --- a/src/tools/UBGraphicsTriangle.h +++ b/src/tools/UBGraphicsTriangle.h @@ -131,6 +131,8 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt bool mResizing2; bool mRotating; QRect lastRect; + + // Coordinates are transformed.... QPoint lastPos; QGraphicsSvgItem* mHFlipSvgItem;