File indexing completed on 2024-06-23 04:28:12

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2006-2007 Thomas Zander <zander@kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #ifndef SHAPESHEARSTRATEGY_H
0008 #define SHAPESHEARSTRATEGY_H
0009 
0010 #include <KoInteractionStrategy.h>
0011 #include <KoFlake.h>
0012 
0013 #include <QPointF>
0014 #include <QSizeF>
0015 #include <QTransform>
0016 
0017 class KoToolBase;
0018 class KoShape;
0019 class KoSelection;
0020 
0021 /**
0022  * A strategy for the KoInteractionTool.
0023  * This strategy is invoked when the user starts a shear of a selection of objects,
0024  * the strategy will then shear the objects interactively and provide a command afterwards.
0025  */
0026 class ShapeShearStrategy : public KoInteractionStrategy
0027 {
0028 public:
0029     /**
0030      * Constructor that starts to rotate the objects.
0031      * @param tool the parent tool which controls this strategy
0032      * @param clicked the initial point that the user depressed (in pt).
0033      * @param direction the handle that was grabbed
0034      */
0035     ShapeShearStrategy(KoToolBase *tool, KoSelection *selection, const QPointF &clicked, KoFlake::SelectionHandle direction);
0036     ~ShapeShearStrategy() override {}
0037 
0038     void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
0039     KUndo2Command *createCommand() override;
0040     void finishInteraction(Qt::KeyboardModifiers modifiers) override
0041     {
0042         Q_UNUSED(modifiers);
0043     }
0044     void paint(QPainter &painter, const KoViewConverter &converter) override;
0045 
0046 private:
0047     QPointF m_start;
0048     QPointF m_solidPoint;
0049     QSizeF m_initialSize;
0050     bool m_top {false};
0051     bool m_left {false};
0052     bool m_bottom {false};
0053     bool m_right {false};
0054     qreal m_initialSelectionAngle {0.0};
0055     QTransform m_shearMatrix;
0056     bool m_isMirrored {false};
0057     QList<QTransform> m_oldTransforms;
0058     QList<KoShape *> m_transformedShapesAndSelection;
0059 };
0060 
0061 #endif
0062