Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeTransformCommand.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net>
3 * SPDX-FileCopyrightText: 2007 Thomas Zander <zander@kde.org>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8#include "kis_command_ids.h"
9
11#include "KoShape.h"
12
13#include <QList>
14#include <QTransform>
15
16#include <FlakeDebug.h>
17
26
28 : KUndo2Command(parent),
29 d(new Private(shapes))
30{
31 Q_ASSERT(shapes.count() == oldState.count());
32 Q_ASSERT(shapes.count() == newState.count());
33 d->oldState = oldState;
34 d->newState = newState;
35}
36
41
43{
45
46 const int shapeCount = d->shapes.count();
47 for (int i = 0; i < shapeCount; ++i) {
48 KoShape * shape = d->shapes[i];
49 const QRectF oldDirtyRect = shape->boundingRect();
50 shape->setTransformation(d->newState[i]);
51 shape->updateAbsolute(oldDirtyRect | shape->boundingRect());
52 }
53}
54
56{
58
59 const int shapeCount = d->shapes.count();
60 for (int i = 0; i < shapeCount; ++i) {
61 KoShape * shape = d->shapes[i];
62 const QRectF oldDirtyRect = shape->boundingRect();
63 shape->setTransformation(d->oldState[i]);
64 shape->updateAbsolute(oldDirtyRect | shape->boundingRect());
65 }
66}
67
72
74{
75 const KoShapeTransformCommand *other = dynamic_cast<const KoShapeTransformCommand*>(command);
76
77 if (!other ||
78 other->d->shapes != d->shapes ||
79 other->text() != text()) {
80
81 return false;
82 }
83
84 d->newState = other->d->newState;
85 return true;
86}
virtual void undo()
KUndo2MagicString text() const
virtual void redo()
void undo() override
revert the actions done in redo
void redo() override
redo the command
KoShapeTransformCommand(const QList< KoShape * > &shapes, const QList< QTransform > &oldState, const QList< QTransform > &newState, KUndo2Command *parent=0)
Private(const QList< KoShape * > &list)
bool mergeWith(const KUndo2Command *command) override
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:335
void setTransformation(const QTransform &matrix)
Definition KoShape.cpp:417
virtual void updateAbsolute(const QRectF &rect) const
Definition KoShape.cpp:616