A strategy for the KoInteractionTool. This strategy is invoked when the user starts a shear of a selection of objects, the strategy will then shear the objects interactively and provide a command afterwards.
Definition at line 26 of file ShapeShearStrategy.h.
Constructor that starts to rotate the objects.
- Parameters
-
| tool | the parent tool which controls this strategy |
| clicked | the initial point that the user depressed (in pt). |
| direction | the handle that was grabbed |
The outline of the selection should look as if it is also sheared, so we add it to the transformed shapes list.
Definition at line 28 of file ShapeShearStrategy.cpp.
31{
38
41 }
42
43
44 switch (direction) {
61 default:
62 Q_UNREACHABLE();
63 ;
64 }
67
72 }
77 }
78
80
81 QPointF edge;
82 qreal angle = 0.0;
85 angle = 180.0;
88 angle = 0.0;
91 angle = 90.0;
94 angle = 270.0;
95 }
96 qreal currentAngle =
atan2(edge.y(), edge.x()) /
M_PI * 180;
98
99
100
103 m_isMirrored = (top.x() * left.y() - top.y() * left.x()) < 0.0;
104}
KoInteractionStrategy(KoToolBase *parent)
constructor
KoToolBase * tool() const
const QList< KoShape * > selectedEditableShapes() const
QTransform transformation() const
Returns the shapes local transformation matrix.
qreal m_initialSelectionAngle
QList< KoShape * > m_transformedShapesAndSelection
QList< QTransform > m_oldTransforms
KRITAIMAGE_EXPORT qreal atan2(qreal y, qreal x)
atan2 replacement
@ 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.
References KoShape::absolutePosition(), KoShape::absoluteTransformation(), KoFlake::BottomLeft, KoFlake::BottomLeftHandle, KoFlake::BottomMiddleHandle, KoFlake::BottomRight, KoFlake::BottomRightHandle, KoFlake::LeftMiddleHandle, m_bottom, m_initialSelectionAngle, m_initialSize, m_isMirrored, m_left, m_oldTransforms, M_PI, m_right, m_solidPoint, m_top, m_transformedShapesAndSelection, KoSelection::outlineRect(), KoFlake::RightMiddleHandle, KoSelection::selectedEditableShapes(), KoSelection::size(), KoFlake::TopLeft, KoFlake::TopLeftHandle, KoFlake::TopMiddleHandle, KoFlake::TopRight, KoFlake::TopRightHandle, and KoShape::transformation().
| void ShapeShearStrategy::handleMouseMove |
( |
const QPointF & | mouseLocation, |
|
|
Qt::KeyboardModifiers | modifiers ) |
|
overridevirtual |
Extending classes should implement this method to update the selectedShapes based on the new mouse position.
- Parameters
-
| mouseLocation | the new location in pt |
| modifiers | OR-ed set of keys pressed. |
Implements KoInteractionStrategy.
Definition at line 106 of file ShapeShearStrategy.cpp.
107{
108 Q_UNUSED(modifiers);
109 QPointF shearVector = point -
m_start;
110
111 QTransform m;
113 shearVector = m.map(shearVector);
114
115 qreal shearX = 0, shearY = 0;
116
118 shearVector = - shearVector;
119 }
122 }
125 }
126
127
129 shearX *= -1.0;
130 shearY *= -1.0;
131 }
132
133 const qreal maxSaneShear = 1e6;
134 if ((qAbs(shearX) == 0.0 && qAbs(shearY) == 0.0) ||
135 qAbs(shearX) > maxSaneShear ||
136 qAbs(shearY) > maxSaneShear) {
137
138 return;
139 }
140
141 QTransform matrix;
144 matrix.shear(shearX, shearY);
147
149
154 }
156}
void applyAbsoluteTransformation(const QTransform &matrix)
virtual QRectF boundingRect() const
Get the bounding box of the shape.
virtual void updateAbsolute(const QRectF &rect) const
References KoShape::applyAbsoluteTransformation(), KoShape::boundingRect(), m_bottom, m_initialSelectionAngle, m_initialSize, m_isMirrored, m_left, m_right, m_shearMatrix, m_solidPoint, m_start, m_top, m_transformedShapesAndSelection, and KoShape::updateAbsolute().