23 #include "layercamera.h"
25 #include "viewmanager.h"
26 #include "scribblearea.h"
29 HandTool::HandTool(QObject *parent) :
34 void HandTool::loadSettings()
36 properties.width = -1;
37 properties.feather = -1;
38 properties.useFeather =
false;
39 properties.inpolLevel = -1;
40 properties.useAA = -1;
43 QCursor HandTool::cursor()
45 return mButtonsDown > 0 ? Qt::ClosedHandCursor : Qt::OpenHandCursor;
48 void HandTool::mousePressEvent( QMouseEvent* )
50 mLastPixel = getLastPressPixel();
52 mScribbleArea->updateToolCursor();
55 void HandTool::mouseReleaseEvent( QMouseEvent* event )
58 if ( event->button() == Qt::MidButton )
60 qDebug(
"[HandTool] Stop Hand Tool" );
61 mScribbleArea->setPrevTool();
64 mScribbleArea->updateToolCursor();
67 void HandTool::mouseMoveEvent( QMouseEvent* evt )
69 if ( evt->buttons() == Qt::NoButton )
74 bool isTranslate = evt->modifiers() == Qt::NoModifier;
75 bool isRotate = evt->modifiers() & Qt::AltModifier;
76 bool isScale = ( evt->modifiers() & Qt::ControlModifier ) || ( evt->buttons() & Qt::RightButton );
83 QPointF d = getCurrentPoint() - getLastPoint();
84 QPointF offset = viewMgr->translation() + d;
85 viewMgr->translate( offset );
89 QPoint centralPixel( mScribbleArea->width() / 2, mScribbleArea->height() / 2 );
90 QVector2D startV( getLastPixel() - centralPixel );
91 QVector2D curV( getCurrentPixel() - centralPixel );
93 float angleOffset = ( atan2( curV.y(), curV.x() ) - atan2( startV.y(), startV.x() ) ) * 180.0 / M_PI;
94 float newAngle = viewMgr->rotation() + angleOffset;
95 viewMgr->rotate(newAngle);
99 float delta = ( getCurrentPixel().y() - mLastPixel.y() ) / 100.f ;
100 float scaleValue = viewMgr->scaling() * (1.f + delta);
101 viewMgr->scale(scaleValue);
104 mLastPixel = getCurrentPixel();
107 void HandTool::mouseDoubleClickEvent( QMouseEvent *event )
109 if ( event->button() == Qt::RightButton )
111 mEditor->view()->resetView();