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
28
class
Editor
;
29
class
UndoRedoManager
;
30
class
PreferenceManager
;
31
class
SoundClip
;
32
class
Camera
;
33
class
Layer
;
34
class
KeyFrame
;
35
class
TransformCommand
;
36
37
class
UndoRedoCommand
:
public
QUndoCommand
38
{
39
public
:
40
explicit
UndoRedoCommand
(
Editor
* editor,
QUndoCommand
* parent =
nullptr
);
41
~UndoRedoCommand
()
override
;
42
43
protected
:
44
Editor
* editor() {
return
mEditor; }
45
46
bool
isFirstRedo()
const
{
return
mIsFirstRedo; }
47
void
setFirstRedo(
const
bool
state) { mIsFirstRedo = state; }
48
49
private
:
50
Editor
* mEditor =
nullptr
;
51
bool
mIsFirstRedo =
true
;
52
};
53
54
class
BitmapReplaceCommand
:
public
UndoRedoCommand
55
{
56
57
public
:
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
67
private
:
68
int
undoLayerId = 0;
69
int
redoLayerId = 0;
70
71
BitmapImage
undoBitmap;
72
BitmapImage
redoBitmap;
73
};
74
75
class
VectorReplaceCommand
:
public
UndoRedoCommand
76
{
77
public
:
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
87
private
:
88
int
undoLayerId = 0;
89
int
redoLayerId = 0;
90
91
VectorImage
undoVector;
92
VectorImage
redoVector;
93
};
94
95
class
TransformCommand
:
public
UndoRedoCommand
96
97
{
98
public
:
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
113
private
:
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:29
BitmapReplaceCommand
Definition:
undoredocommand.h:55
Camera
Definition:
camera.h:25
Editor
Definition:
editor.h:70
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