Objects rotation
preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent ab1b28e0b8
commit a5aa8996da
  1. 3
      src/core/UBSettings.cpp
  2. 3
      src/core/UBSettings.h
  3. 31
      src/domain/UBGraphicsDelegateFrame.cpp
  4. 7
      src/domain/UBGraphicsDelegateFrame.h
  5. 6
      src/domain/domain.pri

@ -377,6 +377,8 @@ void UBSettings::init()
KeyboardLocale = new UBSetting(this, "Board", "StartupKeyboardLocale", 0);
swapControlAndDisplayScreens = new UBSetting(this, "App", "SwapControlAndDisplayScreens", false);
angleTolerance = new UBSetting(this, "App", "AngleTolerance", 4);
}
@ -1139,3 +1141,4 @@ QString UBSettings::replaceWildcard(QString& path)
return result;
}

@ -98,7 +98,6 @@ class UBSettings : public QObject
void init();
//user directories
static QString userDataDirectory();
static QString userDocumentDirectory();
@ -326,6 +325,8 @@ class UBSettings : public QObject
UBSetting* KeyboardLocale;
UBSetting* swapControlAndDisplayScreens;
UBSetting* angleTolerance;
public slots:
void setPenWidthIndex(int index);

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

@ -18,6 +18,7 @@
#include <QtGui>
#include "core/UB.h"
#include "domain/UBAngleWidget.h"
class QGraphicsSceneMouseEvent;
class UBGraphicsItemDelegate;
@ -91,7 +92,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
qreal mTranslateY;
qreal mTotalTranslateX;
qreal mTotalTranslateY;
static const qreal mAngleTolerance;
qreal mAngleTolerance;
QRect mAngleRect;
QPointF mStartingPoint;
QTransform mInitialTransform;
@ -117,5 +119,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
bool mResizing;
bool mMirroredXAtStart;
bool mMirroredYAtStart;
UBAngleWidget *angleWidget;
};
#endif /* UBGRAPHICSDELEGATEFRAME_H_ */

@ -22,7 +22,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsMediaItem.h \
src/domain/UBGraphicsAudioItem.h \
src/domain/UBGraphicsAudioItemDelegate.h \
src/domain/UBAbstractUndoCommand.h
src/domain/UBAbstractUndoCommand.h\
src/domain/UBAngleWidget.h
HEADERS += src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsVideoItemDelegate.h \
@ -54,7 +55,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBGraphicsAudioItem.cpp \
src/domain/UBGraphicsAudioItemDelegate.cpp \
src/domain/UBAbstractUndoCommand.cpp
src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAngleWidget.cpp
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsVideoItemDelegate.cpp \

Loading…
Cancel
Save