Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Scene.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_VISUAL_SCENE_H_
21 #define OMNI_VISUAL_SCENE_H_
22 
23 #include <map>
24 #include <memory>
26 #include <omni/visual/Light.h>
28 #include <omni/LengthUnit.h>
29 #include <omni/visual/Grid.h>
30 
31 namespace omni {
32  namespace visual {
33  /// Enum class to determine which scene element is edited
34  enum class EditMode {
35  CAMERA,
36  MOVE,
37  ROTATE
38  };
39 
40  /// Which direction to move with mouse
41  enum class MoveMode {
42  MOVE_X,
43  MOVE_Y,
44  MOVE_Z,
45  MOVE_XY
46  };
47 
48  /// Rotate pitch, yaw, roll
49  enum class RotateMode {
50  PITCH,
51  YAW,
52  ROLL
53  };
54 
56  ALL, SELECTED, NONE
57  };
58 
59  /**@brief A class that holds settings and elements for session 3d
60  visualization
61  @detail Belongs to a session
62  **/
63  class Scene {
64  public:
65  typedef std::map<QString,std::unique_ptr<CameraInterface>> camera_map_type;
66 
67  Scene();
68 
69  /// Scene size (min, max dimensions)
70  float size() const;
71 
72  /// Set scene size
73  void setSize(float);
74 
75  /// Length unit for scene
76  LengthUnit const& unit() const;
77 
78  /// Set unit from string prefix
79  void setUnit(QString const&);
80 
81  /// Set unit from length unit type
82  void setUnit(LengthUnit const&);
83 
84  /// Input is shown on canvas
85  bool displayInput() const;
86 
87  /// Turn displaying of input on canvas on/off
88  void setDisplayInput(bool);
89 
90  /// Display line grid
91  bool displayGrid() const;
92 
93  /// Turn displaying of grid on/off
94  void setDisplayGrid(bool);
95 
96  /// Display projector frustra (selected projector is always shown)
98 
99  /// Turn displaying of projectors on/off
101 
102  /// Display projected areas
104 
105  /// Turn displaying of projector areas on/off
107 
108  /// Return scene element
109  EditMode editMode() const;
110 
111  /// Set mode which scene element is to be manipulated
112  void setEditMode(EditMode);
113 
114  RotateMode rotateMode() const;
116 
117  MoveMode moveMode() const;
118  void setMoveMode(MoveMode);
119 
120  /// Inside / outside transparency for 3D canvas view
121  float insideOutside() const;
122 
123  /* @brief Set inside / outside transparency for 3D canvas view
124  @param _insideOutside Value 0.0 means inside is only visible
125  1.0 means outside is visible.
126  */
127  void setInsideOutside(float _insideOutside);
128 
129  /// Opacity value for wireframe between 0.0 and 1.0
130  float wireframe() const;
131 
132  /* @brief Set wireframe opacity for canvas view
133  @param _wireframe Value 0.0 means wireframes are not drawn.
134  1.0 means wireframe is fully visible and thick.
135  */
136  void setWireframe(float _wireframe);
137 
138  /// Update light for use in OpenGL
139  void updateLights();
140 
141  /// Return reference to camera
143 
144  /// Return const reference to camera
145  visual::CameraInterface const* camera() const;
146 
147  /// Return current camera id
148  QString currentCameraId() const;
149 
150  /// Set id to current camera
151  void setCurrentCameraId(QString const&);
152 
154  camera_map_type const& cameras() const;
155 
156  /// Deserialize from stream
157  void fromStream(QDataStream&);
158 
159  /// Serialize to stream
160  void toStream(QDataStream&) const;
161 
162  /// Test for equality. ScreenSetup is ignored
163  friend bool operator==(Scene const&,
164  Scene const&);
165 
166  /// Draw grid with given scene size if it is to be displayed
167  void drawGrid() const;
168 
169  /// Update grid
170  void updateGrid();
171 
172 
173  private:
174  float insideOutside_ = 0.5;
175  float size_ = 10.0;
176  float wireframe_ = 0.0;
178  bool displayInput_ = true;
179  bool displayGrid_ = true;
185 
186  QString cameraId_;
187  std::vector<visual::Light> lights_;
188  std::map<QString,std::unique_ptr<visual::CameraInterface>> cameras_;
189  std::unique_ptr<visual::Grid> grid_;
190  };
191  }
192  using visual::Scene;
193 }
194 
199 
200 OMNI_DECL_STREAM_OPERATORS(omni::visual::Scene)
201 
202 #endif /* OMNI_VISUAL_SCENE_H_ */
void setCurrentCameraId(QString const &)
Set id to current camera.
Definition: Scene.cpp:181
A generic camera interface.
Definition: CameraInterface.h:29
Scene()
Definition: Scene.cpp:29
#define OMNI_DECL_ENUM_STREAM_OPERATORS(ENUM)
Definition: Interface.h:65
EditMode
Enum class to determine which scene element is edited.
Definition: Scene.h:34
void drawGrid() const
Draw grid with given scene size if it is to be displayed.
Definition: Scene.cpp:247
LengthUnit const & unit() const
Length unit for scene.
Definition: Scene.cpp:59
ProjectorSelectionMode displayProjectedAreas_
Definition: Scene.h:181
MoveMode moveMode() const
Definition: Scene.cpp:124
float insideOutside_
Definition: Scene.h:174
void setEditMode(EditMode)
Set mode which scene element is to be manipulated.
Definition: Scene.cpp:112
bool displayInput() const
Input is shown on canvas.
Definition: Scene.cpp:72
void setDisplayGrid(bool)
Turn displaying of grid on/off.
Definition: Scene.cpp:85
void setUnit(QString const &)
Set unit from string prefix.
Definition: Scene.cpp:63
void fromStream(QDataStream &)
Deserialize from stream.
Definition: Scene.cpp:196
MoveMode
Which direction to move with mouse.
Definition: Scene.h:41
visual::CameraInterface * camera()
Return reference to camera.
Definition: Scene.cpp:162
std::vector< visual::Light > lights_
Definition: Scene.h:187
void setDisplayProjectors(ProjectorSelectionMode)
Turn displaying of projectors on/off.
Definition: Scene.cpp:94
bool displayGrid() const
Display line grid.
Definition: Scene.cpp:81
An encapsulation for length units.
Definition: LengthUnit.h:28
QString currentCameraId() const
Return current camera id.
Definition: Scene.cpp:176
RotateMode rotateMode() const
Definition: Scene.cpp:116
LengthUnit unit_
Definition: Scene.h:177
void setSize(float)
Set scene size.
Definition: Scene.cpp:54
void updateGrid()
Update grid.
Definition: Scene.cpp:256
bool displayInput_
Definition: Scene.h:178
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
void setMoveMode(MoveMode)
Definition: Scene.cpp:128
void setDisplayProjectedAreas(ProjectorSelectionMode)
Turn displaying of projector areas on/off.
Definition: Scene.cpp:103
A class that holds settings and elements for session 3d visualization Belongs to a session...
Definition: Scene.h:63
EditMode editMode() const
Return scene element.
Definition: Scene.cpp:108
friend bool operator==(Scene const &, Scene const &)
Test for equality. ScreenSetup is ignored.
Definition: Scene.cpp:233
std::map< QString, std::unique_ptr< visual::CameraInterface > > cameras_
Definition: Scene.h:188
MoveMode moveMode_
Definition: Scene.h:184
float wireframe() const
Opacity value for wireframe between 0.0 and 1.0.
Definition: Scene.cpp:149
void setWireframe(float _wireframe)
Definition: Scene.cpp:157
std::map< QString, std::unique_ptr< CameraInterface > > camera_map_type
Definition: Scene.h:65
std::unique_ptr< visual::Grid > grid_
Definition: Scene.h:189
float size() const
Scene size (min, max dimensions)
Definition: Scene.cpp:50
QString cameraId_
Definition: Scene.h:186
float wireframe_
Definition: Scene.h:176
ProjectorSelectionMode displayProjectors() const
Display projector frustra (selected projector is always shown)
Definition: Scene.cpp:90
void updateLights()
Update light for use in OpenGL.
Definition: Scene.cpp:133
camera_map_type & cameras()
Definition: Scene.cpp:187
ProjectorSelectionMode
Definition: Scene.h:55
ProjectorSelectionMode displayProjectors_
Definition: Scene.h:180
bool displayGrid_
Definition: Scene.h:179
void toStream(QDataStream &) const
Serialize to stream.
Definition: Scene.cpp:215
void setDisplayInput(bool)
Turn displaying of input on canvas on/off.
Definition: Scene.cpp:76
ProjectorSelectionMode displayProjectedAreas() const
Display projected areas.
Definition: Scene.cpp:99
EditMode editMode_
Definition: Scene.h:182
float size_
Definition: Scene.h:175
void setRotateMode(RotateMode)
Definition: Scene.cpp:120
float insideOutside() const
Inside / outside transparency for 3D canvas view.
Definition: Scene.cpp:140
RotateMode rotateMode_
Definition: Scene.h:183
RotateMode
Rotate pitch, yaw, roll.
Definition: Scene.h:49
void setInsideOutside(float _insideOutside)
Definition: Scene.cpp:144