Scene.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::gui-plugins::SceneEditor
19  * @date 2015
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 //Typedefs
27 #include "PointerDefinitions.h"
28 
29 //Manager
30 #include "SceneObjectManager.h"
31 #include "SceneGroupManager.h"
32 #include "SceneSelectionManager.h"
34 #include "PreviewGenerator.h"
35 
36 //Other classes
37 #include "../controller/Controller.h"
38 #include "../gui/ScenegraphWidget.h"
39 #include "../gui/MinimapWidget.h"
40 
41 //Inventor
42 #include <Inventor/nodes/SoSelection.h>
43 #include <Inventor/nodes/SoCamera.h>
44 
45 #include <mutex>
46 
47 
48 namespace controller
49 {
50  class Controller;
51 }
52 
53 namespace gui
54 {
55  class ScenegraphWidget;
56  class MinimapWidget;
57 }
58 
59 namespace scene3D
60 {
61  class Scene
62  {
63 
64  friend class SceneObjectManager;
65 
66  friend class SceneSelectionManager;
67 
69 
70  friend class gui::ScenegraphWidget;
71 
72  friend class gui::MinimapWidget;
73 
74  public:
75  /**
76  * Creates a new instance of the Scene
77  */
79 
80  ~Scene();
81 
82  /**
83  * Registers a new camera to the scene. Basically adds it on top of selection root node, which is head of
84  * our scene.
85  *
86  * @param camera The Camera to add to the scene.
87  * @return SoSeparator A Seperator which can now be used as root in scene in, for example, a viewer.
88  */
89  SoSeparator* registerCamera(SoCamera* camera);
90 
91  /**
92  * Returns the SceneObjectManager, which handles all objects displayed in scene.
93  *
94  * @see scene3D::SceneObjectManager
95  * @return SceneObjectManager The current SceneObjectManager
96  */
98 
99  /**
100  * Returns the SceneGroupManager, which handles all groups saved in scene.
101  *
102  * @see scene3D::SceneGroupManager
103  * @return SceneGroupManager The SceneGroupManager
104  */
106 
107  /**
108  * Returns the SelectionManager, which handles all selection actions in scene.
109  *
110  * @see scene3D::SceneSelectionManager
111  * @return SceneSelectionManager The SceneSelectionManager
112  */
114 
115  /**
116  * Returns the ManipulatorManager, which handles all manipulators and their callbacks.
117  *
118  * @see scene3D::SceneManipulationManager
119  * @return SceneManipulatorManager The SceneManipulationManager
120  */
122 
123  /**
124  * Returns the PreviewGenerator, which can generate preview images of objects.
125  *
126  * @see scene3D::PreviewGenerator
127  * @return PreviewGenerator The PreviewGenerator
128  */
130 
131  /**
132  * Returns the Controller for this scene.
133  *
134  * @see controller::controller
135  * @return controller::Controller The Controller
136  */
138 
139  /**
140  * Switch back to ViewerMode.
141  *
142  */
143  void enterViewerMode();
144 
145  /**
146  * Switch to EditorMode.
147  *
148  */
149  void enterEditorMode();
150 
151 
152  /**
153  * Any changes to the scene have to be synchronized. It is not allowed to change scenegraph
154  * while rendering
155  */
156  std::mutex execute_mutex;
157 
158  /**
159  * Make camera view all. Makes sure grid floor is not taken into account.
160  */
161  void makeCameraViewAll(SoCamera* camera, const SbViewportRegion& region);
162 
163  private:
164  /**
165  * Constructor, called by static create()
166  * Creates a new Scene. Also initializes all managers needed to manage the objects, the selection,
167  * the manipulators and groups. Adds a gridfloor to the scene.
168  *
169  * @param controller The controller used to execute operations and get access to other components of tool.
170  */
172  bool viewerMode;
173 
174  SoSelection* selectionRootNode;
175  SoSeparator* objectRootNode;
176 
177  SceneObjectManagerPtr sceneObjectManager;
178  SceneGroupManagerPtr sceneGroupManager;
179  SceneSelectionManagerPtr sceneSelectionManager;
180  SceneManipulatorManagerPtr sceneManipulatorManager;
181  PreviewGeneratorPtr scenePreviewGenerator;
183  };
184 }
185 
scene3D::SceneSelectionManagerPtr
std::shared_ptr< SceneSelectionManager > SceneSelectionManagerPtr
Definition: PointerDefinitions.h:62
scene3D::Scene
Definition: Scene.h:61
scene3D::Scene::execute_mutex
std::mutex execute_mutex
Any changes to the scene have to be synchronized.
Definition: Scene.h:156
scene3D::Scene::getController
controller::ControllerWeakPtr getController()
Returns the Controller for this scene.
Definition: Scene.cpp:234
scene3D::Scene::create
static ScenePtr create(controller::ControllerPtr controller)
Creates a new instance of the Scene.
Definition: Scene.cpp:34
scene3D::PreviewGeneratorPtr
std::shared_ptr< PreviewGenerator > PreviewGeneratorPtr
Definition: PointerDefinitions.h:68
scene3D::Scene::makeCameraViewAll
void makeCameraViewAll(SoCamera *camera, const SbViewportRegion &region)
Make camera view all.
Definition: Scene.cpp:195
scene3D::Scene::getObjectManager
SceneObjectManagerPtr getObjectManager()
Returns the SceneObjectManager, which handles all objects displayed in scene.
Definition: Scene.cpp:209
scene3D::ScenePtr
std::shared_ptr< Scene > ScenePtr
Definition: PointerDefinitions.h:36
SceneSelectionManager.h
controller::ControllerWeakPtr
std::weak_ptr< Controller > ControllerWeakPtr
Definition: ClassDefinitions.h:42
SceneManipulatorManager.h
SceneGroupManager.h
scene3D::Scene::getPreviewGenerator
PreviewGeneratorPtr getPreviewGenerator()
Returns the PreviewGenerator, which can generate preview images of objects.
Definition: Scene.cpp:229
scene3D::Scene::getSelectionManager
SceneSelectionManagerPtr getSelectionManager()
Returns the SelectionManager, which handles all selection actions in scene.
Definition: Scene.cpp:219
scene3D::SceneManipulatorManagerPtr
std::shared_ptr< SceneManipulatorManager > SceneManipulatorManagerPtr
Definition: PointerDefinitions.h:65
scene3D::Scene::~Scene
~Scene()
Definition: Scene.cpp:189
controller
Definition: AddOperation.h:39
controller::ControllerPtr
std::shared_ptr< Controller > ControllerPtr
Definition: ClassDefinitions.h:41
scene3D::Scene::getGroupManager
SceneGroupManagerPtr getGroupManager()
Returns the SceneGroupManager, which handles all groups saved in scene.
Definition: Scene.cpp:214
gui::ScenegraphWidget
This class provides a widget which holds a scene3D::SceneViewer in which the scene graph is rendered.
Definition: ScenegraphWidget.h:49
gui::MinimapWidget
This class is a widget which provides a scene3D::MinimapViewer to render the scene graph in bird pers...
Definition: MinimapWidget.h:42
scene3D::Scene::enterViewerMode
void enterViewerMode()
Switch back to ViewerMode.
Definition: Scene.cpp:251
scene3D::Scene::enterEditorMode
void enterEditorMode()
Switch to EditorMode.
Definition: Scene.cpp:239
scene3D::Scene::getManipulatorManager
SceneManipulatorManagerPtr getManipulatorManager()
Returns the ManipulatorManager, which handles all manipulators and their callbacks.
Definition: Scene.cpp:224
scene3D
Definition: ManipulatorMode.h:26
PointerDefinitions.h
SceneObjectManager.h
scene3D::SceneObjectManagerPtr
std::shared_ptr< SceneObjectManager > SceneObjectManagerPtr
Definition: PointerDefinitions.h:56
PreviewGenerator.h
scene3D::SceneObjectManager
Definition: SceneObjectManager.h:34
scene3D::SceneGroupManagerPtr
std::shared_ptr< SceneGroupManager > SceneGroupManagerPtr
Definition: PointerDefinitions.h:59
scene3D::SceneManipulatorManager
Definition: SceneManipulatorManager.h:34
scene3D::Scene::registerCamera
SoSeparator * registerCamera(SoCamera *camera)
Registers a new camera to the scene.
Definition: Scene.cpp:200
scene3D::SceneSelectionManager
Definition: SceneSelectionManager.h:37