17#ifndef SELECTIONMANAGER_H
18#define SELECTIONMANAGER_H
20#include "basemanager.h"
23#include "vectorselection.h"
42 void workingLayerChanged(
Layer*)
override;
46 void setSelection(
QRectF rect,
bool roundPixels=
false);
49 void rotate(qreal angle, qreal lockedAngle);
50 void scale(qreal sX, qreal sY);
51 void maintainAspectRatio(
bool state) { mAspectRatioFixed = state; }
57 void setMoveModeForAnchorInRange(
const QPointF& point);
58 MoveMode getMoveMode()
const {
return mMoveMode; }
59 void setMoveMode(
const MoveMode moveMode) { mMoveMode = moveMode; }
61 bool somethingSelected()
const {
return mOriginalRect.
isValid(); }
63 void adjustSelection(
const QPointF& currentPoint,
const QPointF& offset, qreal rotationOffset,
int rotationIncrement = 0);
65 QTransform selectionTransform()
const {
return mSelectionTransform; }
66 void setSelectionTransform(
const QTransform& transform) { mSelectionTransform = transform; }
67 void resetSelectionTransform();
75 void resetSelectionProperties();
76 void deleteSelection();
78 bool isOutsideSelectionArea(
const QPointF& point)
const;
80 qreal selectionTolerance()
const;
82 qreal selectionWidth()
const {
return (mSelectionPolygon[1] - mSelectionPolygon[0]).x(); }
83 qreal selectionHeight()
const {
return (mSelectionPolygon[3] - mSelectionPolygon[0]).y(); }
85 QPointF currentTransformAnchor()
const {
return mAnchorPoint; }
86 QPointF getSelectionAnchorPoint()
const;
88 void setTransformAnchor(
const QPointF& point);
90 const QRectF& mySelectionRect()
const {
return mOriginalRect; }
91 const qreal& myRotation()
const {
return mRotatedAngle; }
92 const qreal& myScaleX()
const {
return mScaleX; }
93 const qreal& myScaleY()
const {
return mScaleY; }
94 const QPointF& myTranslation()
const {
return mTranslation; }
96 void setRotation(
const qreal& rotation) { mRotatedAngle = rotation; }
97 void setScale(
const qreal scaleX,
const qreal scaleY) { mScaleX = scaleX; mScaleY = scaleY; }
98 void setTranslation(
const QPointF& translation) { mTranslation = translation; }
100 qreal angleFromPoint(
const QPointF& point,
const QPointF& anchorPoint)
const;
102 QPointF mapToSelection(
const QPointF& point)
const {
return mSelectionTransform.
map(point); };
104 QPolygonF mapToSelection(
const QPolygonF& polygon)
const {
return mSelectionTransform.
map(polygon); }
110 void setCurves(
const QList<int>& curves) { mClosestCurves = curves; }
111 void setVertices(
const QList<VertexRef>& vertices) { mClosestVertices = vertices; }
113 void clearCurves() { mClosestCurves.
clear(); };
114 void clearVertices() { mClosestVertices.
clear(); };
120 const QList<int> closestCurves()
const {
return mClosestCurves; }
127 void selectionChanged();
128 void selectionReset();
129 void needDeleteSelection();
138 int constrainRotationToAngle(
const qreal rotatedAngle,
const int rotationIncrement)
const;
140 bool mAspectRatioFixed =
false;
141 bool mLockAxis =
false;
148 qreal mRotatedAngle = 0.0;
155 MoveMode mMoveMode = MoveMode::NONE;
157 const qreal mSelectionTolerance = 10.0;
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.
void alignPositionToAxis(bool state)
Locks movement either horizontally or vertically depending on drag direction.
void calculateSelectionTransformation()
This should be called to update the selection transform.
bool isValid() const const