19#include "overlaymanager.h"
27 mSinglePerspectivePoint =
QPointF(0.1, 0.1);
28 mLeftPerspectivePoint =
QPointF(-300.0, 0.0);
29 mRightPerspectivePoint =
QPointF(300.0, 0.0);
30 mMiddlePerspectivePoint =
QPointF(0.0, 200.0);
33OverlayManager::~OverlayManager()
37bool OverlayManager::init()
52void OverlayManager::workingLayerChanged(
Layer *)
56void OverlayManager::settingsUpdated(SETTING setting,
bool state)
59 case SETTING::OVERLAY_PERSPECTIVE1:
60 mSinglePerspectiveEnabled = state;
62 case SETTING::OVERLAY_PERSPECTIVE2:
63 mTwoPointPerspectiveEnabled = state;
65 case SETTING::OVERLAY_PERSPECTIVE3:
66 mThreePointPerspectiveEnabled = state;
74MoveMode OverlayManager::getMoveModeForPoint(
const QPointF& pos,
const QTransform& transform)
76 const double calculatedSelectionTol = selectionTolerance();
77 MoveMode mode = MoveMode::NONE;
79 if (mSinglePerspectiveEnabled &&
QLineF(pos, transform.
inverted().
map(mSinglePerspectivePoint)).
length() < calculatedSelectionTol)
81 mode = MoveMode::PERSP_SINGLE;
83 else if ((mTwoPointPerspectiveEnabled || mThreePointPerspectiveEnabled) &&
QLineF(pos, transform.
inverted().
map(mLeftPerspectivePoint)).
length() < calculatedSelectionTol)
85 mode = MoveMode::PERSP_LEFT;
87 else if ((mTwoPointPerspectiveEnabled || mThreePointPerspectiveEnabled) &&
QLineF(pos, transform.
inverted().
map(mRightPerspectivePoint)).
length() < calculatedSelectionTol)
89 mode = MoveMode::PERSP_RIGHT;
91 else if (mThreePointPerspectiveEnabled &&
QLineF(pos, transform.
inverted().
map(mMiddlePerspectivePoint)).
length() < calculatedSelectionTol)
93 mode = MoveMode::PERSP_MIDDLE;
99double OverlayManager::selectionTolerance()
101 return qAbs(mSelectionTolerance * mEditor->viewScaleInversed());
104void OverlayManager::updatePerspective(
const QPointF& point)
107 case MoveMode::PERSP_SINGLE:
108 mSinglePerspectivePoint = point;
110 case MoveMode::PERSP_LEFT:
111 mLeftPerspectivePoint = point;
112 mRightPerspectivePoint =
QPointF(getRightPerspectivePoint().x(), point.
y());
114 case MoveMode::PERSP_RIGHT:
115 mRightPerspectivePoint = point;
116 mLeftPerspectivePoint =
QPointF(getLeftPerspectivePoint().x(), point.
y());
118 case MoveMode::PERSP_MIDDLE:
119 mMiddlePerspectivePoint = point;
qreal length() const const