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
3
Pencil2D - Traditional Animation Software
4
Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5
Copyright (C) 2008-2009 Mj Mendoza IV
6
Copyright (C) 2012-2020 Matthew Chiawen Chang
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; version 2 of the License.
11
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU 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
#include "soundclip.h"
28
#include "camera.h"
29
#include "layer.h"
30
31
class
Editor
;
32
class
UndoRedoManager
;
33
class
PreferenceManager
;
34
class
SoundClip
;
35
class
Camera
;
36
class
KeyFrame
;
37
class
TransformCommand
;
38
39
class
UndoRedoCommand
:
public
QUndoCommand
40
{
41
public
:
42
explicit
UndoRedoCommand
(
Editor
* editor,
QUndoCommand
* parent =
nullptr
);
43
~UndoRedoCommand
() =
default
;
44
45
protected
:
46
Editor
* editor()
const
{
return
mEditor; }
47
48
bool
isFirstRedo()
const
{
return
mIsFirstRedo; }
49
void
setFirstRedo(
const
bool
state) { mIsFirstRedo = state; }
50
51
private
:
52
Editor
* mEditor =
nullptr
;
53
bool
mIsFirstRedo =
true
;
54
};
55
56
class
KeyFrameRemoveCommand
:
public
UndoRedoCommand
57
{
58
public
:
59
KeyFrameRemoveCommand
(
const
KeyFrame
* undoKeyFrame,
60
int
undoLayerId,
61
const
QString
& description,
62
Editor
* editor,
63
QUndoCommand
* parent =
nullptr
64
);
65
~KeyFrameRemoveCommand
()
override
;
66
67
void
undo()
override
;
68
void
redo()
override
;
69
70
private
:
71
72
int
undoLayerId = 0;
73
int
redoLayerId = 0;
74
75
KeyFrame
* undoKeyFrame =
nullptr
;
76
int
redoPosition = 0;
77
};
78
79
class
KeyFrameAddCommand
:
public
UndoRedoCommand
80
{
81
public
:
82
KeyFrameAddCommand
(
int
undoPosition,
83
int
undoLayerId,
84
const
QString
& description,
85
Editor
* editor,
86
QUndoCommand
* parent =
nullptr
);
87
~KeyFrameAddCommand
() =
default
;
88
89
void
undo()
override
;
90
void
redo()
override
;
91
92
private
:
93
94
int
undoLayerId = 0;
95
int
redoLayerId = 0;
96
97
int
undoPosition = 0;
98
int
redoPosition = 0;
99
};
100
101
class
MoveKeyFramesCommand
:
public
UndoRedoCommand
102
{
103
public
:
104
MoveKeyFramesCommand
(
int
offset,
105
QList<int>
listOfPositions,
106
int
undoLayerId,
107
const
QString
& description,
108
Editor
* editor,
109
QUndoCommand
* parent =
nullptr
);
110
111
void
undo()
override
;
112
void
redo()
override
;
113
114
private
:
115
int
undoLayerId = 0;
116
int
redoLayerId = 0;
117
118
int
frameOffset = 0;
119
QList<int>
positions;
120
};
121
122
class
BitmapReplaceCommand
:
public
UndoRedoCommand
123
{
124
125
public
:
126
BitmapReplaceCommand
(
const
BitmapImage
* backupBitmap,
127
const
int
undoLayerId,
128
const
QString
& description,
129
Editor
* editor,
130
QUndoCommand
* parent =
nullptr
);
131
132
void
undo()
override
;
133
void
redo()
override
;
134
135
private
:
136
int
undoLayerId = 0;
137
int
redoLayerId = 0;
138
139
BitmapImage
undoBitmap;
140
BitmapImage
redoBitmap;
141
};
142
143
class
VectorReplaceCommand
:
public
UndoRedoCommand
144
{
145
public
:
146
VectorReplaceCommand
(
const
VectorImage
* undoVector,
147
const
int
undoLayerId,
148
const
QString
& description,
149
Editor
* editor,
150
QUndoCommand
* parent =
nullptr
);
151
152
void
undo()
override
;
153
void
redo()
override
;
154
155
private
:
156
int
undoLayerId = 0;
157
int
redoLayerId = 0;
158
159
VectorImage
undoVector;
160
VectorImage
redoVector;
161
};
162
163
class
TransformCommand
:
public
UndoRedoCommand
164
165
{
166
public
:
167
TransformCommand
(
const
QRectF
& undoSelectionRect,
168
const
QPointF
& undoTranslation,
169
const
qreal undoRotationAngle,
170
const
qreal undoScaleX,
171
const
qreal undoScaleY,
172
const
QPointF
& undoTransformAnchor,
173
const
bool
roundPixels,
174
const
QString
& description,
175
Editor
* editor,
176
QUndoCommand
* parent =
nullptr
);
177
178
void
undo()
override
;
179
void
redo()
override
;
180
181
private
:
182
void
apply(
const
QRectF
& selectionRect,
183
const
QPointF
& translation,
184
const
qreal rotationAngle,
185
const
qreal scaleX,
186
const
qreal scaleY,
187
const
QPointF
& selectionAnchor,
188
const
bool
roundPixels);
189
190
QRectF
undoSelectionRect;
191
QRectF
redoSelectionRect;
192
193
QPointF
undoAnchor;
194
QPointF
redoAnchor;
195
196
QPointF
undoTranslation;
197
QPointF
redoTranslation;
198
199
qreal undoScaleX;
200
qreal undoScaleY;
201
202
qreal redoScaleX;
203
qreal redoScaleY;
204
205
qreal undoRotationAngle;
206
qreal redoRotationAngle;
207
208
bool
roundPixels;
209
};
210
211
#endif
// UNDOREDOCOMMAND_H
BitmapImage
Definition:
bitmapimage.h:28
BitmapReplaceCommand
Definition:
undoredocommand.h:123
Camera
Definition:
camera.h:25
Editor
Definition:
editor.h:71
KeyFrameAddCommand
Definition:
undoredocommand.h:80
KeyFrame
Definition:
keyframe.h:30
KeyFrameRemoveCommand
Definition:
undoredocommand.h:57
MoveKeyFramesCommand
Definition:
undoredocommand.h:102
PreferenceManager
Definition:
preferencemanager.h:28
SoundClip
Definition:
soundclip.h:27
TransformCommand
Definition:
undoredocommand.h:165
UndoRedoCommand
Definition:
undoredocommand.h:40
UndoRedoManager
Definition:
undoredomanager.h:119
VectorImage
Definition:
vectorimage.h:32
VectorReplaceCommand
Definition:
undoredocommand.h:144
QList
QPointF
QRectF
QString
QUndoCommand