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
12#include "KoShape.h"
13
14#include <QList>
15#include <QTransform>
16
17#include <FlakeDebug.h>
18
27
29 : KUndo2Command(parent),
30 d(new Private(shapes))
31{
32 Q_ASSERT(shapes.count() == oldState.count());
33 Q_ASSERT(shapes.count() == newState.count());
34 d->oldState = oldState;
35 d->newState = newState;
36}
37
42
44{
46
47 KoShapeBulkActionLock lock(d->shapes);
48
49 const int shapeCount = d->shapes.count();
50 for (int i = 0; i < shapeCount; ++i) {
51 KoShape * shape = d->shapes[i];
52 shape->setTransformation(d->newState[i]);
53 }
54
56}
57
59{
61
62 KoShapeBulkActionLock lock(d->shapes);
63
64 const int shapeCount = d->shapes.count();
65 for (int i = 0; i < shapeCount; ++i) {
66 KoShape * shape = d->shapes[i];
67 shape->setTransformation(d->oldState[i]);
68 }
69
71}
72
77
79{
80 const KoShapeTransformCommand *other = dynamic_cast<const KoShapeTransformCommand*>(command);
81
82 if (!other ||
83 other->d->shapes != d->shapes ||
84 other->text() != text()) {
85
86 return false;
87 }
88
89 d->newState = other->d->newState;
90 return true;
91}
virtual void undo()
KUndo2MagicString text() const
virtual void redo()
static void bulkShapesUpdate(const UpdatesList &updates)
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
void setTransformation(const QTransform &matrix)
Definition KoShape.cpp:374