cherish
RootScene.h
1 #ifndef ROOTSCENE
2 #define ROOTSCENE
3 
4 #include <iostream>
5 #include <string>
6 #include <string>
7 
8 #include <osg/ref_ptr>
9 #include <osg/AutoTransform>
10 #include <osg/Node>
11 
12 #include "ProtectedGroup.h"
13 #include "Settings.h"
14 #include "../libGUI/hudcamera.h"
15 #include "UserScene.h"
16 #include "Entity2D.h"
17 #include "Stroke.h"
18 #include "Photo.h"
19 #include "Bookmarks.h"
20 #include "../libGUI/ListWidget.h"
21 #include "ToolGlobal.h"
22 #include "SceneState.h"
23 #include "SVMData.h"
24 #include "CamPoseData.h"
25 #include "DraggableWire.h"
26 
27 #include <QUndoStack>
28 #include <QModelIndex>
29 
30 namespace fur{
31 class AddStrokeCommand;
32 }
33 namespace entity{
34 class SceneState;
35 class UserScene;
36 class Bookmarks;
37 }
38 
47 public:
49  RootScene(QUndoStack* undoStack);
50 
52  entity::UserScene* getUserScene() const;
53 
55  QUndoStack* getUndoStack() const;
56 
58  void setFilePath(const std::string& name);
59 
61  bool isSetFilePath() const;
62 
64  bool isSavedToFile() const;
65 
67  void setSavedToFile(bool saved);
68 
70  bool isEmptyScene() const;
71 
73  void clearUserData();
74 
76  void setToolsVisibility(bool vis);
77 
79  bool getToolsVisibility() const;
80 
82  void setAxesVisibility(bool vis);
83 
85  bool getAxesVisibility() const;
86 
88  void setCanvasVisibilityAll(entity::Canvas* canvas, bool vis);
89 
91  bool getCanvasVisibilityAll(entity::Canvas* canvas) const;
92 
94  bool writeScenetoFile();
95 
98  bool exportSceneToFile(const std::string& name);
99 
101  bool loadSceneFromFile();
102 
104  int getStrokeLevel() const;
105 
107  int getCanvasLevel() const;
108 
110  int getPhotoLevel() const;
111 
113  void addCanvas(const osg::Matrix& R, const osg::Matrix& T);
114 
116  void addCanvas(const osg::Vec3f& normal, const osg::Vec3f& center);
117 
119  void addCanvas(const osg::Matrix& R, const osg::Matrix& T, const std::string& name);
120 
122  void addStroke(float u, float v, cher::EVENT event);
123 
125  void addPolygon(float u, float v, cher::EVENT event);
126 
128  void addLineSegment(float u, float v, cher::EVENT event);
129 
131  void selectAllEntities();
132 
134  void addPhoto(const std::string& fname);
135 
137  void addBookmark(BookmarkWidget* widget, const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, const double& fov);
138 
142  bool addSVMData();
143 
145  bool addPhotoScaleData();
146 
148  bool hidePhotoScaleData();
149 
151  bool removePhotoScaleData();
152 
154  const entity::SVMData* getPhotoScaleData() const;
155 
156  /* A method to supplement a last added entity::SceneState with entity::CamPoseData as a child.
157  * Used to create a new bookmark using user interaction. This method requires presense of at least
158  * one canvas on the scene. */
159  bool addCamPoseData();
160 
162  void hideAndUpdateSVMData();
163 
165  void hideAndUpdateCamPoseData();
166 
169  entity::SVMData* getSVMDataCurrent() const;
170 
173  entity::CamPoseData* getCamPoseDataCurrent() const;
174 
175  void addBookmarkTool(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up);
176  void updateBookmark(BookmarkWidget* widget, int row);
177  void deleteBookmark(BookmarkWidget* widget, const QModelIndex& index);
178  void deleteBookmarkTool(int first, int last);
179 
182  void resetBookmarks(BookmarkWidget* widget);
183 
187  void setBookmarkToolVisibility(bool vis);
188 
191  bool getBookmarkToolVisibility() const;
192 
193  void eraseStroke(entity::Stroke* stroke, int first, int last, cher::EVENT event);
194 
195  bool setCanvasCurrent(entity::Canvas* cnv);
196  bool setCanvasPrevious(entity::Canvas* cnv);
197 
200  void setCanvasesButCurrent(bool enable);
201 
204  void setAllCanvases(bool enable);
205 
206  entity::Canvas* getCanvasCurrent() const;
207  entity::Canvas* getCanvasPrevious() const;
208  entity::Bookmarks* getBookmarksModel() const;
209 
210  void editCanvasOffset(const osg::Vec3f& translate, cher::EVENT event);
211  void editCanvasRotate(const osg::Quat& rotation, const osg::Vec3f& center3d, cher::EVENT event);
212  void editCanvasClone(const osg::Vec3f& translate, cher::EVENT event);
213  void editCanvasSeparate(const osg::Vec3f& translate, cher::EVENT event);
214  void editCanvasDelete(entity::Canvas* canvas);
215 
216  void editPhotoDelete(entity::Photo* photo, entity::Canvas* canvas);
217  void editPhotoPush(entity::Photo* photo, entity::Canvas* source, entity::Canvas* destination);
218 
220  void editPolygonDelete(entity::Polygon* poly, entity::Canvas* canvas);
221 
222  void editStrokesPush(osg::Camera *camera);
223  void editStrokesMove(double u, double v, cher::EVENT event);
224  void editStrokesScale(double u, double v, cher::EVENT event);
225  void editStrokesRotate(double u, double v, cher::EVENT event);
226  void editStrokeDelete(entity::Stroke* stroke);
227 
228  void editEntity2DDelete(entity::Entity2D* entity);
229 
230  void copyToBuffer();
231  void cutToBuffer();
232  void pasteFromBuffer();
233 
234  const std::vector< osg::ref_ptr<entity::Entity2D> >& getBuffer() const;
235 
239  entity::SceneState* createSceneState() const;
240 
243  bool setSceneState(const entity::SceneState* state);
244 
247  entity::BookmarkTool* getBookmarkTool(int index);
248 
249 protected:
250 
251 private:
252  osg::ref_ptr<entity::UserScene> m_userScene;
253  osg::ref_ptr<entity::AxisGlobalTool> m_axisTool;
254  osg::ref_ptr<osg::Group> m_bookmarkTools;
255  std::vector< osg::ref_ptr<entity::Entity2D> > m_buffer; /* copy-paste buffer */
256  QUndoStack* m_undoStack;
257  bool m_saved;
258  bool m_visibilityBookmarkTool;
259 };
260 
261 #endif // SCENE
262 
Definition: SVMData.h:22
A proxy class that helps to connect scene graph camera positions (in format eye, center, up and name) with the corresponding BookmarkWidget.
Definition: Bookmarks.h:48
Definition: Canvas.h:31
Scene graph entities.
Definition: AddEntityCommand.h:17
EVENT
Definition: Settings.h:160
Geometry class that defined strokes entered by a user. The creation and usage of this class must be f...
Definition: Stroke.h:62
Contains all the entities that will appear on the scene: both user scene and utility entities (i...
Definition: RootScene.h:46
Geometry class that defines opacity polygons drawn by a user. The creation and usage of this class mu...
Definition: Polygon.h:47
The UserScene class contains scene graph that was created by user, including the construction tools...
Definition: UserScene.h:86
Definition: Entity2D.h:13
Settings is a configuration variables file for Cherish: enums, consts, defaults. Contains settings su...
Tool to depict the saved position of a camera and its associated scene state. The BookmarkTool has th...
Definition: ToolGlobal.h:93
Quad that uses texture to represent a 2D photo in 3D space.
Definition: Photo.h:22
A convinience class that inherits full functionality of osg::Group except the methods that allow dire...
Definition: ProtectedGroup.h:17
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.
Re-defined QListWidget that contains a method to obtain the corresponding delegate.
Definition: ListWidget.h:18
A class to describe the current state of the scene, e.g., state of switches.
Definition: SceneState.h:29
Definition: CamPoseData.h:21