All Classes Namespaces Functions Variables Enumerations Properties Pages
backupelement.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 
18 #ifndef BACKUPELEMENT_H
19 #define BACKUPELEMENT_H
20 
21 #include <QObject>
22 #include "vectorimage.h"
23 #include "bitmapimage.h"
24 #include "soundclip.h"
25 
26 class Editor;
27 
28 class BackupElement : public QObject
29 {
30  Q_OBJECT
31 public:
32  enum types { UNDEFINED, BITMAP_MODIF, VECTOR_MODIF, SOUND_MODIF };
33 
34  QString undoText;
35  bool somethingSelected = false;
36  qreal rotationAngle = 0.0;
37  QRectF mySelection, myTransformedSelection, myTempTransformedSelection;
38 
39  virtual int type() { return UNDEFINED; }
40  virtual void restore(Editor*) { Q_ASSERT(false); }
41 };
42 
44 {
45  Q_OBJECT
46 public:
47  explicit BackupBitmapElement(BitmapImage* bi) { bitmapImage = *bi; }
48 
49  int layerId = 0;
50 
51  int layer = 0;
52  int frame = 0;
53  BitmapImage bitmapImage;
54  int type() override { return BackupElement::BITMAP_MODIF; }
55  void restore(Editor*) override;
56 };
57 
59 {
60  Q_OBJECT
61 public:
62  explicit BackupVectorElement(VectorImage* vi) { vectorImage = *vi; }
63  int layerId = 0;
64 
65  int layer = 0;
66  int frame = 0;
67  VectorImage vectorImage;
68 
69  int type() override { return BackupElement::VECTOR_MODIF; }
70  void restore(Editor*) override;
71 };
72 
74 {
75  Q_OBJECT
76 public:
77  explicit BackupSoundElement(SoundClip* sound) { clip = *sound; }
78  int layerId = 0;
79 
80  int layer = 0;
81  int frame = 0;
82  SoundClip clip;
83  QString fileName, originalName;
84 
85  int type() override { return BackupElement::SOUND_MODIF; }
86  void restore( Editor* ) override;
87 };
88 
89 #endif // BACKUPELEMENT_H
Q_OBJECTQ_OBJECT
Definition: editor.h:55