API Documentation
Loading...
Searching...
No Matches
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
43/**--------------------------------------------------------------------------------------------------
44Namespace: std
45*-----------------------------------------------------------------------------------------------**/
46
47namespace std
48{
49
50 /**--------------------------------------------------------------------------------------------------
51 Struct: hash<NDEVR::UUID>
52
53 Used to make this item work with standard hash tables.
54
55 Author: Tyler Parke
56
57 Date: 2017-11-17
58 *-----------------------------------------------------------------------------------------------**/
59 template<>
60 struct hash<std::pair<NDEVR::UUID, NDEVR::UUID>>
61 {
62 /**--------------------------------------------------------------------------------------------------
63 Fn: size_t operator()(const UUID& value) const
64
65 Function call operator. Used to make this item work with standard hash tables.
66
67 Author: Tyler Parke
68
69 Date: 2017-11-17
70
71 Parameters:
72 value - The value.
73
74 Returns: The result of the operation.
75 *-----------------------------------------------------------------------------------------------**/
76
77 size_t operator()(const std::pair<NDEVR::UUID, NDEVR::UUID>& value) const
78 {
79 hash<NDEVR::UUID> hasher;
80 return hasher(value.first) ^ hasher(value.second);
81 }
82 };
83
84 /**--------------------------------------------------------------------------------------------------
85 Struct: equal_to<NDEVR::UUID>
86
87 An uuid>.
88
89 Author: Tyler Parke
90
91 Date: 2017-11-17
92 *-----------------------------------------------------------------------------------------------**/
93 template <>
94 struct equal_to<std::pair<NDEVR::UUID, NDEVR::UUID>>
95 {
96 /**--------------------------------------------------------------------------------------------------
97 Fn: bool operator()(const NDEVR::UUID& x, const NDEVR::UUID& y) const
98
99 Function call operator.
100
101 Author: Tyler Parke
102
103 Date: 2017-11-17
104
105 Parameters:
106 x - A NDEVR::UUID to process.
107 y - A NDEVR::UUID to process.
108
109 Returns: The result of the operation.
110 *-----------------------------------------------------------------------------------------------**/
111
112 bool operator()(const std::pair<NDEVR::UUID, NDEVR::UUID>& x, const std::pair<NDEVR::UUID, NDEVR::UUID>& y) const
113 {
114 return x == y;
115 }
116 };
117};
118namespace NDEVR
119{
120 class KeyControllerBase;
121 class MouseControllerBase;
122 class MouseController;
123 class KeyController;
124 class SnapsManager;
125 class Skybox;
126 class NDEVR_DESIGN_API CameraManager
127 {
128 private:
129 class CameraOrientationSync;
130 class CameraOffsetSync;
131 public:
132 CameraManager(DesignObjectBase& base);
133 ~CameraManager();
134 void addCamera(DynamicPointer<Camera> camera);
135 const ConstPointer<SnapsManager>& snapsManager() const
136 {
137 return m_snap_manager;
138 }
139 const DynamicPointer<SnapsManager>& snapsManager()
140 {
141 return m_snap_manager;
142 }
143 void update(const Time& time, const DesignObjectLookup* lookup);
144 const DynamicPointer<MouseController>& mouseController(UUID id)
145 {
146 return m_mouse_controllers.get(id);
147 }
148 const DynamicPointer<KeyController>& keyController(UUID id)
149 {
150 return m_key_controllers.get(id);
151 }
152 DynamicPointer<Camera> createCamera(Model& parent, ViewportFormat format);
153 void updateCamera(const ViewportFormat& format);
154 bool hasCamera(UUID id) const;
155 const DynamicPointer<Camera>& getCamera(UUID id) const
156 {
157 return m_cameras.get(id);
158 }
159 const DynamicPointer<Camera>& getCamera(UUID id)
160 {
161 return m_cameras.get(id);
162 }
163 uint04 cameraCount() const
164 {
165 return m_cameras.size();
166 }
167 void clearAll();
168 uint04 userCameraCount() const;
169 DynamicPointer<Camera> selectedCamera() const;
170 Buffer<DynamicPointer<Camera>> userCameras() const;
171 Buffer<UUID> userCameraIDs() const;
172 Buffer<UUID> cameraIDs() const;
173 void setSkybox(UUID camera, Skybox* skybox);
174 Skybox* getSkybox(UUID camera_id) const;
175 const DynamicPointer<Camera>& getCameraFromIndex(uint04 id)
176 {
177 return m_index_cameras[id];
178 }
179 const ConstPointer<Camera>& getCameraFromIndex(uint04 id) const
180 {
181 return m_index_cameras[id];
182 }
183 void deleteCamera(UUID id);
184 void linkCameraOrientation(UUID a, UUID b);
185 void selectCamera(UUID camera);
186 void delinkCameraOrientation(UUID a, UUID b);
187 void addKeyController(UUID camera, UUID id, KeyControllerBase* actions);
188 void removeKeyController(UUID camera, UUID id);
189 void addKeyController(UUID id, KeyControllerBase* actions);
190 void removeKeyController(UUID id);
191 void addMouseController(UUID camera, UUID id, MouseControllerBase* actions);
192 void removeMouseController(UUID camera, UUID id);
193 void addMouseController(UUID id, MouseControllerBase* actions);
194 void removeMouseController(UUID id);
195 void setThemeCameraBackgroundColor(const RGBColor& color);//used if no default
196 void updateCameraBackgrounds();
197 void setCameraShowGrid(bool show_grid);
198 void setCameraShowEnvironment(bool show_grid);
199 void addMouseCursor(UUID id, const String& cursor);
200 void removeMouseCursor(UUID id);
201 void addViewportLayout(const ViewportLayout& layout);
202 void updateViewportLayout(const ViewportLayout& layout);
203 void setDefaultLayoutTheme(ViewportLayoutTheme theme);
204 void removeViewportLayout(const UUID& id);
205 RGBColor defaultCameraBackgroundColor() const;
206 Resource<ViewportLayout> current_layout;
207 Resource<bool> camera_show_grid;
208 Resource<bool> camera_show_environment;
209 protected:
210 Buffer<ViewportLayout> m_viewport_layout_stack;
211 DynamicPointer<SnapsManager> m_snap_manager;
212 Dictionary<UUID, Skybox*> m_skyboxes;
213 Dictionary<std::pair<UUID, UUID>, CameraOrientationSync*> m_camera_orientation_syncs;
214 Dictionary<std::pair<UUID, UUID>, CameraOffsetSync*> m_camera_offset_syncs;
215 Buffer<DynamicPointer<Camera>> m_index_cameras;
216 Dictionary<UUID, DynamicPointer<Camera>> m_cameras;
217 Dictionary<UUID, DynamicPointer<MouseController>> m_mouse_controllers;
218 Dictionary<UUID, DynamicPointer<KeyController>> m_key_controllers;
219 Buffer<UUID> m_global_mouse_actions;
220 Dictionary<UUID, MouseControllerBase*> m_global_mouse_action_lookup;
221 Buffer<UUID> m_global_key_actions;
222 Dictionary<UUID, KeyControllerBase*> m_global_key_action_lookup;
223 DesignObjectBase& m_base;
224 RGBColor m_theme_camera_background_color;//used if no default camera color
225 Buffer<std::pair<UUID, String>> m_global_mouse_cursors;
226 Dictionary<UUID, String> m_global_mouse_cursor_lookup;
227 UUID m_active_camera;
228 BasicResourceListener* m_color_theme_listener;
229 };
230}
231#endif
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
Definition ACIColor.h:37
void addCamera(const DynamicPointer< Camera > &camera, kmldom::DocumentPtr doc)
Definition KMLFactory.cpp:498
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
Definition File.h:213