cherish
EditEntityCommand.h
1 #ifndef EDITENTITYCOMMAND_H
2 #define EDITENTITYCOMMAND_H
3 
4 #include <vector>
5 
6 #include <QUndoCommand>
7 
8 #include <osg/observer_ptr>
9 
10 #include "UserScene.h"
11 #include "Canvas.h"
12 #include "Photo.h"
13 #include "Stroke.h"
14 #include "ShaderedEntity2D.h"
15 #include "Bookmarks.h"
16 #include "SceneState.h"
17 
18 namespace entity {
19 class UserScene;
20 class Bookmarks;
21 }
22 
23 namespace fur{
24 
28 class UndoCommand : public QUndoCommand
29 {
30 public:
31  UndoCommand(entity::UserScene* scene, entity::Canvas* canvas, QUndoCommand* parent = 0);
32 
33  virtual void undo() = 0;
34  virtual void redo() = 0;
35 
36 protected:
37  osg::observer_ptr<entity::UserScene> m_scene;
38  osg::observer_ptr<entity::Canvas> m_canvas;
39 
40 };
41 
45 class EditCanvasOffsetCommand : public QUndoCommand
46 {
47 public:
49  EditCanvasOffsetCommand(entity::UserScene* scene, const osg::Vec3f& translate, QUndoCommand* parent = 0);
50 
51 #ifndef DOXYGEN_SHOULD_SKIP_THIS
52  void undo() Q_DECL_OVERRIDE;
53  void redo() Q_DECL_OVERRIDE;
54 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
55 
56 protected:
57  osg::observer_ptr<entity::UserScene> m_scene;
58  osg::observer_ptr<entity::Canvas> m_canvas;
59  osg::Vec3f m_translate;
60 };
61 
65 class EditCanvasRotateCommand : public QUndoCommand
66 {
67 public:
69  EditCanvasRotateCommand(entity::UserScene* scene, const osg::Quat& rotate, QUndoCommand* parent = 0);
70 
71 #ifndef DOXYGEN_SHOULD_SKIP_THIS
72  void undo() Q_DECL_OVERRIDE;
73  void redo() Q_DECL_OVERRIDE;
74 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
75 
76 protected:
77  osg::observer_ptr<entity::UserScene> m_scene;
78  osg::observer_ptr<entity::Canvas> m_canvas;
79  osg::Quat m_rotate;
80  osg::Vec3f m_center;
81 };
82 
86 class EditCanvasDeleteCommand : public QUndoCommand
87 {
88 public:
90  EditCanvasDeleteCommand(entity::UserScene* scene, entity::Canvas* canvas, QUndoCommand* parent = 0);
91 
92 #ifndef DOXYGEN_SHOULD_SKIP_THIS
93  void undo() Q_DECL_OVERRIDE;
94  void redo() Q_DECL_OVERRIDE;
95 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
96 
97 protected:
98  osg::observer_ptr<entity::UserScene> m_scene;
99  osg::ref_ptr<entity::Canvas> m_canvas;
100  osg::observer_ptr<entity::Bookmarks> m_bookmarks;
101 };
102 
106 class EditPhotoDeleteCommand : public QUndoCommand
107 {
108 public:
110  EditPhotoDeleteCommand(entity::UserScene* scene, entity::Canvas* canvas, entity::Photo* photo, QUndoCommand* parent = 0);
111 
112 #ifndef DOXYGEN_SHOULD_SKIP_THIS
113  void undo() Q_DECL_OVERRIDE;
114  void redo() Q_DECL_OVERRIDE;
115 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
116 
117 protected:
118  osg::observer_ptr<entity::UserScene> m_scene;
119  osg::observer_ptr<entity::Canvas> m_canvas;
120  osg::ref_ptr<entity::Photo> m_photo;
121  osg::observer_ptr<entity::Bookmarks> m_bookmarks;
122 };
123 
125 {
126 public:
128 
129  void undo();
130  void redo();
131 
132 private:
133  osg::ref_ptr<entity::Entity2D> m_entity;
134 };
135 
137 {
138 public:
140  entity::Canvas* canvas,
141  const std::vector<osg::ref_ptr<entity::Entity2D>>& entities);
142 
143  void undo() Q_DECL_OVERRIDE;
144  void redo() Q_DECL_OVERRIDE;
145 
146 protected:
147  const std::vector<osg::ref_ptr<entity::Entity2D>> m_entities;
148 };
149 
153 class EditStrokesPushCommand : public QUndoCommand
154 {
155 public:
159  EditStrokesPushCommand(entity::UserScene* scene, const std::vector<entity::Entity2D*>& entities, entity::Canvas* current, entity::Canvas* target,
160  const osg::Vec3f& eye, QUndoCommand* parent = 0);
161 
162 #ifndef DOXYGEN_SHOULD_SKIP_THIS
163  void undo() Q_DECL_OVERRIDE;
164  void redo() Q_DECL_OVERRIDE;
165 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
166 
167 protected:
168  void doPushStrokes(entity::Canvas& source, entity::Canvas& target);
169 
170  osg::observer_ptr<entity::UserScene> m_scene;
171  const std::vector<entity::Entity2D*> m_entities;
172  osg::observer_ptr<entity::Canvas> m_canvasCurrent;
173  osg::observer_ptr<entity::Canvas> m_canvasTarget;
174  osg::Vec3f m_eye;
175 };
176 
180 class EditEntitiesMoveCommand : public QUndoCommand
181 {
182 public:
183  EditEntitiesMoveCommand(entity::UserScene* scene, const std::vector<entity::Entity2D*>& entities, entity::Canvas* canvas,
184  double du, double dv, QUndoCommand* parent = 0);
186 
187 #ifndef DOXYGEN_SHOULD_SKIP_THIS
188  void undo() Q_DECL_OVERRIDE;
189  void redo() Q_DECL_OVERRIDE;
190 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
191 
192 protected:
193  osg::observer_ptr<entity::UserScene> m_scene;
194  std::vector<entity::Entity2D*> m_entities;
195  osg::observer_ptr<entity::Canvas> m_canvas;
196  double m_du;
197  double m_dv;
198 };
199 
203 class EditEntitiesScaleCommand : public QUndoCommand
204 {
205 public:
206  EditEntitiesScaleCommand(entity::UserScene* scene, const std::vector<entity::Entity2D*>& entities,
207  entity::Canvas* canvas,
208  double scaleX, double scaleY,
209  osg::Vec3f center,
210  QUndoCommand* parent = 0);
212 
213 #ifndef DOXYGEN_SHOULD_SKIP_THIS
214  void undo() Q_DECL_OVERRIDE;
215  void redo() Q_DECL_OVERRIDE;
216 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
217 
218 protected:
219  osg::observer_ptr<entity::UserScene> m_scene;
220  std::vector<entity::Entity2D*> m_entities;
221  osg::observer_ptr<entity::Canvas> m_canvas;
222  double m_scaleX, m_scaleY;
223  osg::Vec3f m_center;
224 };
225 
229 class EditEntitiesRotateCommand : public QUndoCommand
230 {
231 public:
232  EditEntitiesRotateCommand(entity::UserScene* scene, const std::vector<entity::Entity2D*>& entities, entity::Canvas* canvas,
233  double theta, osg::Vec3f center, QUndoCommand* parent = 0);
235 
236 #ifndef DOXYGEN_SHOULD_SKIP_THIS
237  void undo() Q_DECL_OVERRIDE;
238  void redo() Q_DECL_OVERRIDE;
239 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
240 
241 protected:
242  osg::observer_ptr<entity::UserScene> m_scene;
243  std::vector<entity::Entity2D*> m_entities;
244  osg::observer_ptr<entity::Canvas> m_canvas;
245  double m_theta;
246  osg::Vec3f m_center;
247 };
248 
252 class EditStrokeDeleteCommand : public QUndoCommand
253 {
254 public:
255  EditStrokeDeleteCommand(entity::UserScene* scene, entity::Canvas* canvas, entity::Stroke* stroke, QUndoCommand* parent = 0);
256 
257 #ifndef DOXYGEN_SHOULD_SKIP_THIS
258  void undo() Q_DECL_OVERRIDE;
259  void redo() Q_DECL_OVERRIDE;
260 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
261 protected:
262  osg::observer_ptr<entity::UserScene> m_scene;
263  osg::observer_ptr<entity::Canvas> m_canvas;
264  osg::ref_ptr<entity::Stroke> m_stroke;
265 };
266 
270 class EditPasteCommand : public QUndoCommand
271 {
272 public:
274  const std::vector< osg::ref_ptr<entity::Entity2D> >& buffer, QUndoCommand* parent=0);
275 
276 #ifndef DOXYGEN_SHOULD_SKIP_THIS
277  void undo() Q_DECL_OVERRIDE;
278  void redo() Q_DECL_OVERRIDE;
279 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
280 
281 protected:
282  osg::observer_ptr<entity::UserScene> m_scene;
283  osg::observer_ptr<entity::Canvas> m_canvas;
284  std::vector<entity::Entity2D*> m_entities;
285 };
286 
290 class EditCutCommand : public QUndoCommand
291 {
292 public:
294  const std::vector<entity::Entity2D*>& selected,
295  std::vector< osg::ref_ptr<entity::Entity2D> >& buffer, QUndoCommand* parent=0);
296  ~EditCutCommand() {}
297 
298 #ifndef DOXYGEN_SHOULD_SKIP_THIS
299  void undo() Q_DECL_OVERRIDE;
300  void redo() Q_DECL_OVERRIDE;
301 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
302 
303 protected:
304  osg::observer_ptr<entity::UserScene> m_scene;
305  osg::observer_ptr<entity::Canvas> m_canvas;
306  std::vector< osg::ref_ptr<entity::Entity2D> >& m_buffer;
307  const std::vector<entity::Entity2D*>& m_selected;
308 };
309 
313 class EditPhotoPushCommand : public QUndoCommand
314 {
315 public:
317  entity::Photo* photo, QUndoCommand* parent=0);
319 
320 #ifndef DOXYGEN_SHOULD_SKIP_THIS
321  void undo() Q_DECL_OVERRIDE;
322  void redo() Q_DECL_OVERRIDE;
323 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
324 
325 protected:
326  osg::observer_ptr<entity::UserScene> m_scene;
327  osg::observer_ptr<entity::Canvas> m_source;
328  osg::observer_ptr<entity::Canvas> m_destination;
329  osg::observer_ptr<entity::Photo> m_photo;
330 };
331 
332 } // namespace fur
333 
334 #endif // EDITENTITYCOMMAND_H
QUndoCommand that performs deletion of a photo.
Definition: EditEntityCommand.h:106
Definition: Canvas.h:31
QUndoCommand that performs rotation of a canvas.
Definition: EditEntityCommand.h:65
Scene graph entities.
Definition: AddEntityCommand.h:17
Definition: EditEntityCommand.h:229
Definition: EditEntityCommand.h:136
Geometry class that defined strokes entered by a user. The creation and usage of this class must be f...
Definition: Stroke.h:62
Definition: EditEntityCommand.h:290
Definition: EditEntityCommand.h:203
Base virtual class for undo/redo commands.
Definition: EditEntityCommand.h:28
The UserScene class contains scene graph that was created by user, including the construction tools...
Definition: UserScene.h:86
Definition: Entity2D.h:13
Definition: EditEntityCommand.h:180
Definition: EditEntityCommand.h:252
QUndoCommand that performs offset of a canvas.
Definition: EditEntityCommand.h:45
Definition: EditEntityCommand.h:124
Definition: EditEntityCommand.h:270
Quad that uses texture to represent a 2D photo in 3D space.
Definition: Photo.h:22
Contains QUndoCommand - based classes that are defined within undo/redo framework. All these classes are made friend classes for entity::UserScene (protected) so that to access add and remove entity functionality.
QUndoCommand that performs push operation of a set of strokes.
Definition: EditEntityCommand.h:153
QUndoCommand that performs deletion of a canvas.
Definition: EditEntityCommand.h:86
Definition: EditEntityCommand.h:313