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 "PreviewGenerator.h"
31#include "SceneGroupManager.h"
33#include "SceneObjectManager.h"
35
36//Other classes
40
41//Inventor
42#include <mutex>
43
44#include <Inventor/nodes/SoCamera.h>
45#include <Inventor/nodes/SoSelection.h>
46
47namespace controller
48{
49 class Controller;
50}
51
52namespace gui
53{
54 class ScenegraphWidget;
55 class MinimapWidget;
56} // namespace gui
57
58namespace scene3D
59{
60 class Scene
61 {
62
63 friend class SceneObjectManager;
64
66
68
70
71 friend class gui::MinimapWidget;
72
73 public:
74 /**
75 * Creates a new instance of the Scene
76 */
78
79 ~Scene();
80
81 /**
82 * Registers a new camera to the scene. Basically adds it on top of selection root node, which is head of
83 * our scene.
84 *
85 * @param camera The Camera to add to the scene.
86 * @return SoSeparator A Seperator which can now be used as root in scene in, for example, a viewer.
87 */
88 SoSeparator* registerCamera(SoCamera* camera);
89
90 /**
91 * Returns the SceneObjectManager, which handles all objects displayed in scene.
92 *
93 * @see scene3D::SceneObjectManager
94 * @return SceneObjectManager The current SceneObjectManager
95 */
97
98 /**
99 * Returns the SceneGroupManager, which handles all groups saved in scene.
100 *
101 * @see scene3D::SceneGroupManager
102 * @return SceneGroupManager The SceneGroupManager
103 */
105
106 /**
107 * Returns the SelectionManager, which handles all selection actions in scene.
108 *
109 * @see scene3D::SceneSelectionManager
110 * @return SceneSelectionManager The SceneSelectionManager
111 */
113
114 /**
115 * Returns the ManipulatorManager, which handles all manipulators and their callbacks.
116 *
117 * @see scene3D::SceneManipulationManager
118 * @return SceneManipulatorManager The SceneManipulationManager
119 */
121
122 /**
123 * Returns the PreviewGenerator, which can generate preview images of objects.
124 *
125 * @see scene3D::PreviewGenerator
126 * @return PreviewGenerator The PreviewGenerator
127 */
129
130 /**
131 * Returns the Controller for this scene.
132 *
133 * @see controller::controller
134 * @return controller::Controller The Controller
135 */
137
138 /**
139 * Switch back to ViewerMode.
140 *
141 */
142 void enterViewerMode();
143
144 /**
145 * Switch to EditorMode.
146 *
147 */
148 void enterEditorMode();
149
150
151 /**
152 * Any changes to the scene have to be synchronized. It is not allowed to change scenegraph
153 * while rendering
154 */
155 std::mutex execute_mutex;
156
157 /**
158 * Make camera view all. Makes sure grid floor is not taken into account.
159 */
160 void makeCameraViewAll(SoCamera* camera, const SbViewportRegion& region);
161
162 private:
163 /**
164 * Constructor, called by static create()
165 * Creates a new Scene. Also initializes all managers needed to manage the objects, the selection,
166 * the manipulators and groups. Adds a gridfloor to the scene.
167 *
168 * @param controller The controller used to execute operations and get access to other components of tool.
169 */
171 bool viewerMode;
172
173 SoSelection* selectionRootNode;
174 SoSeparator* objectRootNode;
175
176 SceneObjectManagerPtr sceneObjectManager;
177 SceneGroupManagerPtr sceneGroupManager;
178 SceneSelectionManagerPtr sceneSelectionManager;
179 SceneManipulatorManagerPtr sceneManipulatorManager;
180 PreviewGeneratorPtr scenePreviewGenerator;
182 };
183} // namespace scene3D
A class to execute Operations, maintain the execution history and initialize Scene and MemoryXControl...
Definition Controller.h:56
This class is a widget which provides a scene3D::MinimapViewer to render the scene graph in bird pers...
This class provides a widget which holds a scene3D::SceneViewer in which the scene graph is rendered.
SceneGroupManagerPtr getGroupManager()
Returns the SceneGroupManager, which handles all groups saved in scene.
Definition Scene.cpp:223
controller::ControllerWeakPtr getController()
Returns the Controller for this scene.
Definition Scene.cpp:247
void makeCameraViewAll(SoCamera *camera, const SbViewportRegion &region)
Make camera view all.
Definition Scene.cpp:201
void enterEditorMode()
Switch to EditorMode.
Definition Scene.cpp:253
SoSeparator * registerCamera(SoCamera *camera)
Registers a new camera to the scene.
Definition Scene.cpp:207
void enterViewerMode()
Switch back to ViewerMode.
Definition Scene.cpp:266
friend class SceneObjectManager
Definition Scene.h:63
SceneObjectManagerPtr getObjectManager()
Returns the SceneObjectManager, which handles all objects displayed in scene.
Definition Scene.cpp:217
SceneSelectionManagerPtr getSelectionManager()
Returns the SelectionManager, which handles all selection actions in scene.
Definition Scene.cpp:229
friend class SceneSelectionManager
Definition Scene.h:65
std::mutex execute_mutex
Any changes to the scene have to be synchronized.
Definition Scene.h:155
PreviewGeneratorPtr getPreviewGenerator()
Returns the PreviewGenerator, which can generate preview images of objects.
Definition Scene.cpp:241
static ScenePtr create(controller::ControllerPtr controller)
Creates a new instance of the Scene.
Definition Scene.cpp:35
SceneManipulatorManagerPtr getManipulatorManager()
Returns the ManipulatorManager, which handles all manipulators and their callbacks.
Definition Scene.cpp:235
friend class SceneManipulatorManager
Definition Scene.h:67
std::weak_ptr< Controller > ControllerWeakPtr
std::shared_ptr< Controller > ControllerPtr
std::shared_ptr< SceneManipulatorManager > SceneManipulatorManagerPtr
std::shared_ptr< SceneObjectManager > SceneObjectManagerPtr
std::shared_ptr< SceneGroupManager > SceneGroupManagerPtr
std::shared_ptr< Scene > ScenePtr
std::shared_ptr< SceneSelectionManager > SceneSelectionManagerPtr
std::shared_ptr< PreviewGenerator > PreviewGeneratorPtr