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 29 of file ShapeShearStrategy.cpp.
32{
39
42 }
43
44
45 switch (direction) {
62 default:
63 Q_UNREACHABLE();
64 ;
65 }
68
73 }
78 }
79
81
82 QPointF edge;
83 qreal angle = 0.0;
86 angle = 180.0;
89 angle = 0.0;
92 angle = 90.0;
95 angle = 270.0;
96 }
97 qreal currentAngle =
atan2(edge.y(), edge.x()) /
M_PI * 180;
99
100
101
104 m_isMirrored = (top.x() * left.y() - top.y() * left.x()) < 0.0;
105}
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 107 of file ShapeShearStrategy.cpp.
108{
109 Q_UNUSED(modifiers);
110 QPointF shearVector = point -
m_start;
111
112 QTransform m;
114 shearVector = m.map(shearVector);
115
116 qreal shearX = 0, shearY = 0;
117
119 shearVector = - shearVector;
120 }
123 }
126 }
127
128
130 shearX *= -1.0;
131 shearY *= -1.0;
132 }
133
134 const qreal maxSaneShear = 1e6;
135 if ((qAbs(shearX) == 0.0 && qAbs(shearY) == 0.0) ||
136 qAbs(shearX) > maxSaneShear ||
137 qAbs(shearY) > maxSaneShear) {
138
139 return;
140 }
141
142 QTransform matrix;
145 matrix.shear(shearX, shearY);
148
150
152
155 }
156
158
160}
static void bulkShapesUpdate(const UpdatesList &updates)
void applyAbsoluteTransformation(const QTransform &matrix)
References KoShape::applyAbsoluteTransformation(), KoShapeBulkActionLock::bulkShapesUpdate(), m_bottom, m_initialSelectionAngle, m_initialSize, m_isMirrored, m_left, m_right, m_shearMatrix, m_solidPoint, m_start, m_top, m_transformedShapesAndSelection, and KoShapeBulkActionLock::unlock().