API Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
CameraManager.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: CameraManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Camera.h>
35#include <NDEVR/MouseController.h>
36#include <NDEVR/ViewportLayout.h>
37#include <NDEVR/KeyController.h>
38#include <NDEVR/UUID.h>
39#include <NDEVR/Pointer.h>
40#include <NDEVR/Buffer.h>
41#include <NDEVR/Dictionary.h>
42#if NDEVR_VIEWPORT
43namespace std
44{
45
46 /**--------------------------------------------------------------------------------------------------
47 Struct: hash<NDEVR::UUID>
48
49 Used to make this item work with standard hash tables.
50
51 Author: Tyler Parke
52
53 Date: 2017-11-17
54 **/
55 template<>
56 struct hash<std::pair<NDEVR::UUID, NDEVR::UUID>>
57 {
58 /**--------------------------------------------------------------------------------------------------
59 Function call operator. Used to make this item work with standard hash tables.
60
61 Author: Tyler Parke
62
63 Date: 2017-11-17
64
65 Parameters:
66 value - The value.
67
68 \returns The result of the operation.
69 **/
70
71 size_t operator()(const std::pair<NDEVR::UUID, NDEVR::UUID>& value) const
72 {
73 hash<NDEVR::UUID> hasher;
74 return hasher(value.first) ^ hasher(value.second);
75 }
76 };
77
78 /**--------------------------------------------------------------------------------------------------
79 Struct: equal_to<NDEVR::UUID>
80
81 An uuid>.
82
83 Author: Tyler Parke
84
85 Date: 2017-11-17
86 **/
87 template <>
88 struct equal_to<std::pair<NDEVR::UUID, NDEVR::UUID>>
89 {
90 /**--------------------------------------------------------------------------------------------------
91 Function call operator.
92
93 Author: Tyler Parke
94
95 Date: 2017-11-17
96
97 Parameters:
98 x - A NDEVR::UUID to process.
99 y - A NDEVR::UUID to process.
100
101 \returns The result of the operation.
102 **/
103
104 bool operator()(const std::pair<NDEVR::UUID, NDEVR::UUID>& x, const std::pair<NDEVR::UUID, NDEVR::UUID>& y) const
105 {
106 return x == y;
107 }
108 };
109};
110namespace NDEVR
111{
112 class KeyControllerBase;
113 class MouseControllerBase;
114 class MouseController;
115 class KeyController;
116 class SnapsManager;
117 class Skybox;
118 /**--------------------------------------------------------------------------------------------------
119 \brief Used to store or create Cameras or Viewports as well as manage interactions between them
120 **/
121 class NDEVR_DESIGN_API CameraManager
122 {
123 private:
124 class CameraOrientationSync;
125 class CameraOffsetSync;
126 public:
127 CameraManager(DesignObjectBase& base);
128 ~CameraManager();
129 void addCamera(DynamicPointer<Camera> camera);
130 const ConstPointer<SnapsManager>& snapsManager() const
131 {
132 return m_snap_manager;
133 }
134 const DynamicPointer<SnapsManager>& snapsManager()
135 {
136 return m_snap_manager;
137 }
138 void update(const Time& time, const DesignObjectLookup* lookup);
139 const DynamicPointer<MouseController>& mouseController(UUID id)
140 {
141 return m_mouse_controllers.get(id);
142 }
143 const DynamicPointer<KeyController>& keyController(UUID id)
144 {
145 return m_key_controllers.get(id);
146 }
147 DynamicPointer<Camera> createCamera(Model& parent, ViewportFormat format);
148 void updateCamera(const ViewportFormat& format);
149 bool hasCamera(UUID id) const;
150 const DynamicPointer<Camera>& getCamera(UUID id) const
151 {
152 return m_cameras.get(id);
153 }
154 const DynamicPointer<Camera>& getCamera(UUID id)
155 {
156 return m_cameras.get(id);
157 }
158 uint04 cameraCount() const
159 {
160 return m_cameras.size();
161 }
162 void clearAll();
163 uint04 userCameraCount() const;
164 DynamicPointer<Camera> selectedCamera() const;
165 Buffer<DynamicPointer<Camera>> userCameras() const;
166 Buffer<UUID> userCameraIDs() const;
167 Buffer<UUID> cameraIDs() const;
168 void setSkybox(UUID camera, Skybox* skybox);
169 Skybox* getSkybox(UUID camera_id) const;
170 const DynamicPointer<Camera>& getCameraFromIndex(uint04 id)
171 {
172 return m_index_cameras[id];
173 }
174 const ConstPointer<Camera>& getCameraFromIndex(uint04 id) const
175 {
176 return m_index_cameras[id];
177 }
178 void deleteCamera(UUID id);
179 void linkCameraOrientation(UUID a, UUID b);
180 void selectCamera(UUID camera);
181 void delinkCameraOrientation(UUID a, UUID b);
182 void addKeyController(UUID camera, UUID id, KeyControllerBase* actions);
183 void removeKeyController(UUID camera, UUID id);
184 void addKeyController(UUID id, KeyControllerBase* actions);
185 void removeKeyController(UUID id);
186 void addMouseController(UUID camera, UUID id, MouseControllerBase* actions);
187 void removeMouseController(UUID camera, UUID id);
188 void addMouseController(UUID id, MouseControllerBase* actions);
189 void removeMouseController(UUID id);
190 void setThemeCameraBackgroundColor(const RGBColor& color);//used if no default
191 void updateCameraBackgrounds();
192 void setCameraShowGrid(bool show_grid);
193 void setCameraShowEnvironment(bool show_grid);
194 void addMouseCursor(UUID id, const String& cursor);
195 void removeMouseCursor(UUID id);
196 void addViewportLayout(const ViewportLayout& layout);
197 void updateViewportLayout(const ViewportLayout& layout);
198 void setDefaultLayoutTheme(ViewportLayoutTheme theme);
199 void removeViewportLayout(const UUID& id);
200 RGBColor defaultCameraBackgroundColor() const;
201 Resource<ViewportLayout> current_layout;
202 Resource<bool> camera_show_grid;
203 Resource<bool> camera_show_environment;
204 private:
205 Buffer<ViewportLayout> m_viewport_layout_stack;
206 DynamicPointer<SnapsManager> m_snap_manager;
207 Dictionary<UUID, Skybox*> m_skyboxes;
208 Dictionary<std::pair<UUID, UUID>, CameraOrientationSync*> m_camera_orientation_syncs;
209 Dictionary<std::pair<UUID, UUID>, CameraOffsetSync*> m_camera_offset_syncs;
210 Buffer<DynamicPointer<Camera>> m_index_cameras;
211 Dictionary<UUID, DynamicPointer<Camera>> m_cameras;
212 Dictionary<UUID, DynamicPointer<MouseController>> m_mouse_controllers;
213 Dictionary<UUID, DynamicPointer<KeyController>> m_key_controllers;
214 Buffer<UUID> m_global_mouse_actions;
215 Dictionary<UUID, MouseControllerBase*> m_global_mouse_action_lookup;
216 Buffer<UUID> m_global_key_actions;
217 Dictionary<UUID, KeyControllerBase*> m_global_key_action_lookup;
218 DesignObjectBase& m_base;
219 RGBColor m_theme_camera_background_color;//used if no default camera color
220 Buffer<std::pair<UUID, String>> m_global_mouse_cursors;
221 Dictionary<UUID, String> m_global_mouse_cursor_lookup;
222 UUID m_active_camera;
223 BasicResourceListener* m_color_theme_listener;
224 };
225}
226#endif
#define NDEVR_DESIGN_API
Definition DLLInfo.h:55
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Definition File.h:211