1 /* This file is part of the KDE project 2 * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef SHAPERESIZESTRATEGY_H 21 #define SHAPERESIZESTRATEGY_H 22 23 #include <KoInteractionStrategy.h> 24 #include <KoFlake.h> 25 26 #include <QScopedPointer> 27 #include <QPointF> 28 #include <QList> 29 #include <QTransform> 30 31 class KoToolBase; 32 class KoShape; 33 class KoShapeResizeCommand; 34 class KoSelection; 35 36 /** 37 * A strategy for the KoInteractionTool. 38 * This strategy is invoked when the user starts a resize of a selection of objects, 39 * the stategy will then resize the objects interactively and provide a command afterwards. 40 */ 41 class ShapeResizeStrategy : public KoInteractionStrategy 42 { 43 public: 44 /** 45 * Constructor 46 */ 47 ShapeResizeStrategy(KoToolBase *tool, KoSelection *selection, const QPointF &clicked, KoFlake::SelectionHandle direction, bool forceUniformScalingMode); 48 ~ShapeResizeStrategy() override; 49 50 void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override; 51 KUndo2Command *createCommand() override; 52 void finishInteraction(Qt::KeyboardModifiers modifiers) override; 53 void paint(QPainter &painter, const KoViewConverter &converter) override; 54 private: 55 void resizeBy(const QPointF &stillPoint, qreal zoomX, qreal zoomY); 56 57 QPointF m_start; 58 QList<KoShape *> m_selectedShapes; 59 60 QTransform m_postScalingCoveringTransform; 61 QSizeF m_initialSelectionSize; 62 QTransform m_unwindMatrix; 63 bool m_top, m_left, m_bottom, m_right; 64 65 QPointF m_globalStillPoint; 66 QPointF m_globalCenterPoint; 67 QScopedPointer<KoShapeResizeCommand> m_executedCommand; 68 69 bool m_forceUniformScalingMode = false; 70 }; 71 72 #endif 73 74