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

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 SHAPERESIZESTRATEGY_H
0008 #define SHAPERESIZESTRATEGY_H
0009 
0010 #include <KoInteractionStrategy.h>
0011 #include <KoFlake.h>
0012 
0013 #include <QScopedPointer>
0014 #include <QPointF>
0015 #include <QList>
0016 #include <QTransform>
0017 
0018 class KoToolBase;
0019 class KoShape;
0020 class KoShapeResizeCommand;
0021 class KoSelection;
0022 
0023 /**
0024  * A strategy for the KoInteractionTool.
0025  * This strategy is invoked when the user starts a resize of a selection of objects,
0026  * the strategy will then resize the objects interactively and provide a command afterwards.
0027  */
0028 class ShapeResizeStrategy : public KoInteractionStrategy
0029 {
0030 public:
0031     /**
0032      * Constructor
0033      */
0034     ShapeResizeStrategy(KoToolBase *tool, KoSelection *selection, const QPointF &clicked, KoFlake::SelectionHandle direction, bool forceUniformScalingMode);
0035     ~ShapeResizeStrategy() override;
0036 
0037     void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
0038     KUndo2Command *createCommand() override;
0039     void finishInteraction(Qt::KeyboardModifiers modifiers) override;
0040     void paint(QPainter &painter, const KoViewConverter &converter) override;
0041 private:
0042     void resizeBy(const QPointF &stillPoint, qreal zoomX, qreal zoomY);
0043 
0044     QPointF m_start;
0045     QList<KoShape *> m_selectedShapes;
0046 
0047     QTransform m_postScalingCoveringTransform;
0048     QSizeF m_initialSelectionSize;
0049     QTransform m_unwindMatrix;
0050     bool m_top {false};
0051     bool m_left{false};
0052     bool m_bottom {false};
0053     bool m_right {false};
0054 
0055     QPointF m_globalStillPoint;
0056     QPointF m_globalCenterPoint;
0057     QScopedPointer<KoShapeResizeCommand> m_executedCommand;
0058 
0059     bool m_forceUniformScalingMode {false};
0060 };
0061 
0062 #endif
0063