Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
  • interface
undoredocommand.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2008-2009 Mj Mendoza IV
6Copyright (C) 2012-2020 Matthew Chiawen Chang
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; version 2 of the License.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17*/
18
19#ifndef UNDOREDOCOMMAND_H
20#define UNDOREDOCOMMAND_H
21
22#include <QUndoCommand>
23#include <QRectF>
24
25#include "bitmapimage.h"
26#include "vectorimage.h"
27
28class Editor;
29class UndoRedoManager;
30class PreferenceManager;
31class SoundClip;
32class Camera;
33class Layer;
34class KeyFrame;
35class TransformCommand;
36
37class UndoRedoCommand : public QUndoCommand
38{
39public:
40 explicit UndoRedoCommand(Editor* editor, QUndoCommand* parent = nullptr);
41 ~UndoRedoCommand() override;
42
43protected:
44 Editor* editor() { return mEditor; }
45
46 bool isFirstRedo() const { return mIsFirstRedo; }
47 void setFirstRedo(const bool state) { mIsFirstRedo = state; }
48
49private:
50 Editor* mEditor = nullptr;
51 bool mIsFirstRedo = true;
52};
53
54class BitmapReplaceCommand : public UndoRedoCommand
55{
56
57public:
58 BitmapReplaceCommand(const BitmapImage* backupBitmap,
59 const int undoLayerId,
60 const QString& description,
61 Editor* editor,
62 QUndoCommand* parent = nullptr);
63
64 void undo() override;
65 void redo() override;
66
67private:
68 int undoLayerId = 0;
69 int redoLayerId = 0;
70
71 BitmapImage undoBitmap;
72 BitmapImage redoBitmap;
73};
74
75class VectorReplaceCommand : public UndoRedoCommand
76{
77public:
78 VectorReplaceCommand(const VectorImage* undoVector,
79 const int undoLayerId,
80 const QString& description,
81 Editor* editor,
82 QUndoCommand* parent = nullptr);
83
84 void undo() override;
85 void redo() override;
86
87private:
88 int undoLayerId = 0;
89 int redoLayerId = 0;
90
91 VectorImage undoVector;
92 VectorImage redoVector;
93};
94
95class TransformCommand : public UndoRedoCommand
96
97{
98public:
99 TransformCommand(const QRectF& undoSelectionRect,
100 const QPointF& undoTranslation,
101 const qreal undoRotationAngle,
102 const qreal undoScaleX,
103 const qreal undoScaleY,
104 const QPointF& undoTransformAnchor,
105 const bool roundPixels,
106 const QString& description,
107 Editor* editor,
108 QUndoCommand* parent = nullptr);
109
110 void undo() override;
111 void redo() override;
112
113private:
114 void apply(const QRectF& selectionRect,
115 const QPointF& translation,
116 const qreal rotationAngle,
117 const qreal scaleX,
118 const qreal scaleY,
119 const QPointF& selectionAnchor,
120 const bool roundPixels);
121
122 QRectF undoSelectionRect;
123 QRectF redoSelectionRect;
124
125 QPointF undoAnchor;
126 QPointF redoAnchor;
127
128 QPointF undoTranslation;
129 QPointF redoTranslation;
130
131 qreal undoScaleX;
132 qreal undoScaleY;
133
134 qreal redoScaleX;
135 qreal redoScaleY;
136
137 qreal undoRotationAngle;
138 qreal redoRotationAngle;
139
140 bool roundPixels;
141};
142
143#endif // UNDOREDOCOMMAND_H
BitmapImage
Definition: bitmapimage.h:28
BitmapReplaceCommand
Definition: undoredocommand.h:55
Camera
Definition: camera.h:25
Editor
Definition: editor.h:71
KeyFrame
Definition: keyframe.h:30
Layer
Definition: layer.h:33
PreferenceManager
Definition: preferencemanager.h:28
SoundClip
Definition: soundclip.h:27
TransformCommand
Definition: undoredocommand.h:97
UndoRedoCommand
Definition: undoredocommand.h:38
UndoRedoManager
Definition: undoredomanager.h:91
VectorImage
Definition: vectorimage.h:32
VectorReplaceCommand
Definition: undoredocommand.h:76
QPointF
QRectF
QString
QUndoCommand
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39