22#include <pointerevent.h>
25#include "layercamera.h"
27#include "strokeinterpolator.h"
28#include "viewmanager.h"
29#include "scribblearea.h"
36void HandTool::loadSettings()
38 properties.width = -1;
39 properties.feather = -1;
40 properties.useFeather =
false;
41 properties.stabilizerLevel = -1;
42 properties.useAA = -1;
44 mDeltaFactor = mEditor->preference()->isOn(SETTING::INVERT_DRAG_ZOOM_DIRECTION) ? -1 : 1;
45 connect(mEditor->preference(), &PreferenceManager::optionChanged,
this, &HandTool::updateSettings);
48void HandTool::updateSettings(
const SETTING setting)
52 case SETTING::INVERT_DRAG_ZOOM_DIRECTION:
54 mDeltaFactor = mEditor->preference()->isOn(SETTING::INVERT_DRAG_ZOOM_DIRECTION) ? -1 : 1;
69 mLastPixel =
event->viewportPos();
70 mStartPoint =
event->canvasPos();
73 mScribbleArea->updateToolCursor();
83 transformView(
event->modifiers(),
event->viewportPos(),
event->buttons());
84 mLastPixel =
event->viewportPos();
91 mScribbleArea->updateToolCursor();
94void HandTool::pointerDoubleClickEvent(
PointerEvent* event)
98 mEditor->view()->resetView();
112 QPointF d = viewMgr->mapScreenToCanvas(pos) - viewMgr->mapScreenToCanvas(mLastPixel);
113 QPointF offset = viewMgr->translation() + d;
114 viewMgr->translate(offset);
119 QVector2D startV(mLastPixel - centralPixel);
122 qreal angleOffset =
static_cast<qreal
>(std::atan2(curV.y(), curV.x()) - std::atan2(startV.y(), startV.x()));
123 angleOffset = qRadiansToDegrees(angleOffset);
125 const float delta = viewMgr->isFlipHorizontal() == !viewMgr->isFlipVertical()
126 ?
static_cast<float>(angleOffset * -1) :
static_cast<float>(angleOffset);
127 viewMgr->rotateRelative(delta);
131 const float delta = (
static_cast<float>(pos.
y() - mLastPixel.
y())) / 100.f;
132 const qreal scaleValue = viewMgr->scaling() * (1 + (delta * mDeltaFactor));
133 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