23#include <pointerevent.h>
26#include "layercamera.h"
28#include "strokemanager.h"
29#include "viewmanager.h"
30#include "scribblearea.h"
37void HandTool::loadSettings()
39 properties.width = -1;
40 properties.feather = -1;
41 properties.useFeather =
false;
42 properties.stabilizerLevel = -1;
43 properties.useAA = -1;
45 mDeltaFactor = mEditor->preference()->isOn(SETTING::INVERT_DRAG_ZOOM_DIRECTION) ? -1 : 1;
46 connect(mEditor->preference(), &PreferenceManager::optionChanged,
this, &HandTool::updateSettings);
49void HandTool::updateSettings(
const SETTING setting)
53 case SETTING::INVERT_DRAG_ZOOM_DIRECTION:
55 mDeltaFactor = mEditor->preference()->isOn(SETTING::INVERT_DRAG_ZOOM_DIRECTION) ? -1 : 1;
70 mLastPixel = getCurrentPixel();
71 mStartPoint = mEditor->view()->mapScreenToCanvas(mLastPixel);
74 mScribbleArea->updateToolCursor();
84 transformView(
event->modifiers(),
event->buttons());
85 mLastPixel = getCurrentPixel();
92 mScribbleArea->updateToolCursor();
95void HandTool::pointerDoubleClickEvent(
PointerEvent* event)
99 mEditor->view()->resetView();
113 QPointF d = getCurrentPoint() - getLastPoint();
114 QPointF offset = viewMgr->translation() + d;
115 viewMgr->translate(offset);
120 QVector2D startV(getLastPixel() - centralPixel);
121 QVector2D curV(getCurrentPixel() - centralPixel);
123 qreal angleOffset =
static_cast<qreal
>(std::atan2(curV.y(), curV.x()) - std::atan2(startV.y(), startV.x()));
124 angleOffset = qRadiansToDegrees(angleOffset);
126 const float delta = viewMgr->isFlipHorizontal() == !viewMgr->isFlipVertical()
127 ?
static_cast<float>(angleOffset * -1) :
static_cast<float>(angleOffset);
128 viewMgr->rotateRelative(delta);
132 const float delta = (
static_cast<float>(getCurrentPixel().
y() - mLastPixel.
y())) / 100.f;
133 const qreal scaleValue = viewMgr->scaling() * (1 + (delta * mDeltaFactor));
134 viewMgr->scaleAtOffset(scaleValue, mStartPoint);
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
virtual bool event(QEvent *e)
typedef KeyboardModifiers