17#ifndef SELECTIONMANAGER_H
18#define SELECTIONMANAGER_H
20#include "basemanager.h"
23#include "vectorselection.h"
60 void workingLayerChanged(
Layer*)
override;
69 void rotate(qreal angle, qreal lockedAngle);
70 void scale(qreal sX, qreal sY);
71 void maintainAspectRatio(
bool state) { mAspectRatioFixed = state; }
79 MoveMode getMoveMode()
const {
return mMoveMode; }
80 void setMoveMode(
const MoveMode moveMode) { mMoveMode = moveMode; }
82 bool somethingSelected()
const {
return mOriginalRect.
isValid() || mMoveMode != MoveMode::NONE; }
88 QTransform selectionTransform()
const {
return mSelectionTransform; }
89 void setSelectionTransform(
const QTransform& transform) { mSelectionTransform = transform; }
90 void resetSelectionTransform();
98 void resetSelectionProperties();
99 void deleteSelection();
101 bool isOutsideSelectionArea(
const QPointF& point)
const;
103 qreal selectionTolerance()
const;
105 qreal selectionWidth()
const {
return (mSelectionPolygon[1] - mSelectionPolygon[0]).x(); }
106 qreal selectionHeight()
const {
return (mSelectionPolygon[3] - mSelectionPolygon[0]).y(); }
108 QPointF currentTransformAnchor()
const {
return mAnchorPoint; }
109 QPointF getSelectionAnchorPoint()
const;
111 void setTransformAnchor(
const QPointF& point);
113 const QRectF& mySelectionRect()
const {
return mOriginalRect; }
114 const qreal& myRotation()
const {
return mRotatedAngle; }
115 const qreal& myScaleX()
const {
return mScaleX; }
116 const qreal& myScaleY()
const {
return mScaleY; }
117 const QPointF& myTranslation()
const {
return mTranslation; }
119 void setRotation(
const qreal& rotation) { mRotatedAngle = rotation; }
120 void setScale(
const qreal scaleX,
const qreal scaleY) { mScaleX = scaleX; mScaleY = scaleY; }
121 void setTranslation(
const QPointF& translation) { mTranslation = translation; }
123 qreal angleFromPoint(
const QPointF& point,
const QPointF& anchorPoint)
const;
141 void setCurves(
const QList<int>& curves) { mClosestCurves = curves; }
142 void setVertices(
const QList<VertexRef>& vertices) { mClosestVertices = vertices; }
144 void clearCurves() { mClosestCurves.
clear(); };
145 void clearVertices() { mClosestVertices.
clear(); };
151 const QList<int> closestCurves()
const {
return mClosestCurves; }
158 void selectionChanged();
159 void selectionReset();
160 void needDeleteSelection();
169 int constrainRotationToAngle(
const qreal rotatedAngle,
const int rotationIncrement)
const;
171 bool mAspectRatioFixed =
false;
172 bool mLockAxis =
false;
179 qreal mRotatedAngle = 0.0;
186 MoveMode mMoveMode = MoveMode::NONE;
188 const qreal mSelectionTolerance = 10.0;
The SelectionManager class acts as the "Brain" of the selection system.
void flipSelection(bool flipVertical)
ScribbleArea::flipSelection flip selection along the X or Y axis.
void resetSelectionTransformProperties()
SelectionManager::resetSelectionTransformProperties should be used whenever translate,...
void setDragOrigin(const QPointF point)
The point from where the dragging will be based of inside the selection area.
QPointF mapFromLocalSpace(const QPointF &point) const
Maps a point FROM the Selection's transformed space BACK to Canvas/Layer space.
void alignPositionToAxis(bool state)
Locks movement either horizontally or vertically depending on drag direction.
void setMoveModeForAnchorInRange(const QPointF &point)
Checks if the point is over a handle (corner) or body and sets the MoveMode accordingly.
QPointF mapToSelection(const QPointF &point) const
Maps a point from Canvas/Layer space INTO the Selection's transformed space.
void setSelection(QRectF rect, bool roundPixels=false)
Defines the selection area.
void adjustSelection(const QPointF ¤tPoint, const QPointF &offset, qreal rotationOffset, int rotationIncrement=0)
Updates the selection transform (move, scale, rotate) based on input delta.
void calculateSelectionTransformation()
This should be called to update the selection transform.
bool isValid() const const