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->copy(); }
48 
49  int layer = 0;
50  int frame = 0;
51  BitmapImage bitmapImage;
52  int type() override { return BackupElement::BITMAP_MODIF; }
53  void restore(Editor*) override;
54 };
55 
57 {
58  Q_OBJECT
59 public:
60  explicit BackupVectorElement(VectorImage* vi) { vectorImage = *vi; }
61  int layer = 0;
62  int frame = 0;
63  VectorImage vectorImage;
64 
65  int type() override { return BackupElement::VECTOR_MODIF; }
66  void restore(Editor*) override;
67 };
68 
70 {
71  Q_OBJECT
72 public:
73  explicit BackupSoundElement(SoundClip* sound) { clip = *sound; }
74  int layer = 0;
75  int frame = 0;
76  SoundClip clip;
77  QString fileName;
78 
79  int type() override { return BackupElement::SOUND_MODIF; }
80  void restore( Editor* ) override;
81 };
82 
83 #endif // BACKUPELEMENT_H
Q_OBJECTQ_OBJECT
Definition: editor.h:51