21#include <klocalizedstring.h>
30 m_forceUniformScalingMode(forceUniformScalingMode)
39 const qreal w = shape->
size().width();
40 const qreal h = shape->
size().height();
109 bool keepAspect = modifiers & Qt::ShiftModifier;
115 if (startWidth < std::numeric_limits<qreal>::epsilon()) {
116 startWidth = std::numeric_limits<qreal>::epsilon();
119 if (startHeight < std::numeric_limits<qreal>::epsilon()) {
120 startHeight = std::numeric_limits<qreal>::epsilon();
134 const bool scaleFromCenter = modifiers & Qt::ControlModifier;
135 if (scaleFromCenter) {
139 qreal newWidth = startWidth;
140 qreal newHeight = startHeight;
143 newWidth = startWidth -
distance.x();
145 newWidth = startWidth +
distance.x();
149 newHeight = startHeight -
distance.y();
151 newHeight = startHeight +
distance.y();
159 QSizeF minViewSize(1.0, 1.0);
162 if (qAbs(newWidth) < minDocSize.width()) {
166 if (qAbs(newHeight) < minDocSize.height()) {
170 qreal zoomX = qAbs(startWidth) >= minDocSize.width() ? newWidth / startWidth : 1.0;
171 qreal zoomY = qAbs(startHeight) >= minDocSize.height() ? newHeight / startHeight : 1.0;
176 if (startWidth < startHeight) {
qreal distance(const QPointF &p1, const QPointF &p2)
virtual const KoViewConverter * viewConverter() const =0
KoToolBase * tool() const
int count() const
return the selection count, i.e. the number of all selected shapes
const QList< KoShape * > selectedEditableShapes() const
virtual QSizeF size() const
Get the size of the shape in pt.
virtual QRectF outlineRect() const
QPointF absolutePosition(KoFlake::AnchorPosition anchor=KoFlake::Center) const
QTransform absoluteTransformation() const
static QList< KoShape * > linearizeSubtree(const QList< KoShape * > &shapes)
QTransform transformation() const
Returns the shapes local transformation matrix.
bool keepAspectRatio() const
void reset()
Resets the snap guide.
QPointF snap(const QPointF &mousePosition, Qt::KeyboardModifiers modifiers)
snaps the mouse position, returns if mouse was snapped
void setIgnoredShapes(const QList< KoShape * > &ignoredShapes)
Sets list of ignored shapes.
virtual QPointF viewToDocument(const QPointF &viewPoint) const
bool m_forceUniformScalingMode
KUndo2Command * createCommand() override
QList< KoShape * > m_selectedShapes
QPointF m_globalCenterPoint
~ShapeResizeStrategy() override
void finishInteraction(Qt::KeyboardModifiers modifiers) override
QPointF m_globalStillPoint
void resizeBy(const QPointF &stillPoint, qreal zoomX, qreal zoomY)
QTransform m_unwindMatrix
void paint(QPainter &painter, const KoViewConverter &converter) override
QSizeF m_initialSelectionSize
QTransform m_postScalingCoveringTransform
QScopedPointer< KoShapeResizeCommand > m_executedCommand
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
ShapeResizeStrategy(KoToolBase *tool, KoSelection *selection, const QPointF &clicked, KoFlake::SelectionHandle direction, bool forceUniformScalingMode)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
SelectionHandle
Enum determining which handle is meant, used in KoInteractionTool.
@ BottomRightHandle
The handle that is at the bottom right of a selection.
@ BottomLeftHandle
The handle that is at the bottom left of a selection.
@ RightMiddleHandle
The handle that is at the right - center of a selection.
@ TopRightHandle
The handle that is at the top - right of a selection.
@ TopLeftHandle
The handle that is at the top left of a selection.
@ LeftMiddleHandle
The handle that is at the left center of a selection.
@ TopMiddleHandle
The handle that is at the top - center of a selection.
@ BottomMiddleHandle
The handle that is at the bottom center of a selection.