API Documentation
Loading...
Searching...
No Matches
DesignObjectLookup.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: DesignObjectLookup
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/DesignObject.h>
35#include <NDEVR/Model.h>
36#include <NDEVR/Effect.h>
37#include <NDEVR/DesignSelection.h>
38#include <NDEVR/CameraManager.h>
39#include <NDEVR/LogManager.h>
40#include <NDEVR/DesignParameterAccumulator.h>
41
42namespace NDEVR
43{
44 class RDesignLock;
45 class WDesignLock;
46
47 class Log;
48 class WLock;
49 class RLock;
50 class SelectionController;
51 class ModelEditController;
52 class SelectionInfo;
53 class SelectionEffect;
54 class DesignCommandManager;
55 class ResourceListener;
56 class DesignTaskManager;
57 class Project;
58 class DesignObjectUpdateTarget;
59 class Thread;
61 {
62 public:
64 virtual ~DesignObjectLookup();
65 WLock writeLock();
66 RLock readLock() const;
67 void setupDefaultScene();
68
69 WLock writeLock(const std::function<void()>& wait_callback);
70 RLock readLock(const std::function<void()>& wait_callback) const;
71
72 WLock tryWriteLock(uint08 milliseconds = 10);
73 RLock tryReadLock(uint08 milliseconds = 10) const;
74
75 WLock tryWriteLock(const TimeSpan& span);
76 RLock tryReadLock(const TimeSpan& span) const;
77
78 WLock commandLock();
79 WLock tryCommandLock();
80 bool isCommandLocked() const;
81 const void* lockPtr() const;
82 RDesignLock readLock(UUID id);
83 WDesignLock writeLock(UUID id);
84
85 virtual void addScene(Scene scene, bool ignore_application_scene = false);
86 virtual void addMaterial(Material object);
87 virtual void addGeometry(Geometry object);
88 virtual void addEffect(Effect object);
89 virtual void addModel(Model object);
90 virtual void addCameraModel(const UUID& camera, const Model& object);
91 virtual void addLayer(Model layer);
92 virtual void addSelection(const DesignSelection& object);
93 virtual void clearSelected();
94 virtual void setSelected(Buffer<UUID> ids);
95 virtual void appendSelected(Buffer<UUID> ids);
96 virtual void refreshScene(UUID scene_id, bool ignore_application_scene);
97 virtual void refreshModel(const Model& object);
98
99 virtual void updateModelTopLevel(const Model& object);
100 virtual void executePendingCommands();
101 virtual void deleteObject(UUID id);
102 virtual void eraseModel(UUID id);
103 virtual Model restoreModel(UUID id);
104 virtual void setActiveLayer(UUID layer_id);
105 virtual void setActiveProject(UUID layer_id);
106 virtual UUID activeProject() const { return m_active_project; }
107 virtual Project activeProjectModel() const;
108 void ensureLayerExistsInScene(const UUID& layer_id, const UUID& scene_id);
109 void addUpdateTarget(DesignObjectUpdateTarget* target);
110 void removeUpdateTarget(DesignObjectUpdateTarget* target);
111 Geometry geometry(const UUID& id, bool allow_deleted = false) const;
112 Material material(const UUID& id, bool allow_deleted = false) const;
113 Scene scene(const UUID& id, bool allow_deleted = false) const;
114 Model modelOrLayer(const UUID& id, bool allow_deleted = false) const;
115 Model model(const UUID& id, bool allow_deleted = false) const;
116 Effect effect(const UUID& id, bool allow_deleted = false) const;
117 Model layer(const UUID& id, bool allow_deleted = false) const;
118 Model layer(const UUID& layer_id, const UUID& scene_id, bool allow_deleted = false) const;
119 Model findLayer(const String& layer, bool use_translation = true) const;
120 Model findLayer(const TranslatedString& layer) const;
121#if NDEVR_VIEWPORT
122 DynamicPointer<Camera> createCamera(Model& parent, const ViewportFormat& format);
123 DynamicPointer<Camera> createCamera(const ViewportFormat& format);
124 bool hasCamera(const UUID& id) const;
125 virtual void addCamera(const DynamicPointer<Camera>& object);
126 const DynamicPointer<Camera>& getCamera(const UUID& id);
127 const ConstPointer<Camera>& getCamera(const UUID& id) const;
128 Bounds<3, fltp08> boundsOfVisible(const Camera& camera) const;
129 virtual CameraManager* cameraManager();
130 virtual const CameraManager* cameraManager() const;
131 virtual SelectionController* selectionController();
132 virtual ModelEditController* editManager();
133 virtual SelectionEffect* selectionEffect();
134 void setViewportFocus(AutoZoomFocus focus);
135#endif
136 virtual DesignCommandManager* commandManager();
137 const DynamicPointer<DesignSelection>& getSelectionInfo(const UUID& id);
138 const ConstPointer<DesignSelection>& getSelectionInfo(const UUID& id) const;
139
140 bool hasModelID(const UUID& id, bool allow_deleted = false) const;
141 bool hasSceneID(const UUID& id, bool allow_deleted = false) const;
142 bool hasObjectID(const UUID& id, bool allow_deleted = false) const;
143 bool hasMaterialID(const UUID& id) const;
144 bool hasGeometryID(const UUID& id) const;
145 bool hasEffect(const UUID& id) const;
146 bool hasSelectionInfo(const UUID& id) const;
147 bool hasLayerID(const UUID& id, bool allow_deleted = false) const;
148 bool hasLayerID(const UUID& id, const UUID& scene_id) const;
149 const Dictionary<UUID, Model>& getAllSceneLayers(const UUID& id) const;
150
151 DesignObject object(const UUID& id) const;
152 Buffer<UUID> getRootObjectIDs(bool include_app_owned = false) const;
153 Buffer<UUID> getRootObjectIDs(UUID camera_id, bool include_app_owned = false) const;
154 Buffer<Model> getRootObjects(bool include_app_owned = false) const;
155 Buffer<Model> getRootObjects(UUID camera_id, bool include_app_owned = false) const;
156 void processSelection(SelectionInfo& info) const;
157 void colorByChannel(UUID target, const DesignParameter& channel);
158 Bounds<3, fltp08> bounds() const;
159 Bounds<3, fltp08> boundsOfVisible() const;
160
161
162 virtual LogManager* logManager() const;
163 virtual DesignTaskManager* taskManager() const;
164 virtual void postCommand(const DynamicPointer<DesignCommand>& command);
165 virtual void runCommand(const DynamicPointer<DesignCommand>& command);
166 virtual void finishCommand(const DynamicPointer<DesignCommand>& command);
167 //virtual void addCameraObject(UUID camera, const Model& object);
168 Buffer<UUID> getModelIDsByType(const String& type) const;
169 Buffer<Model> getModelsByType(const String& type) const;
170 Buffer<Model> getModelsByType(const Buffer<String>& types) const;
171 Buffer<Model> getLayersByType(const String& type) const;
172 Buffer<Model> getLayersByType(const Buffer<String>& types) const;
173 Buffer<Model> getModelsByID(const Buffer<UUID>& ids) const;
174 Buffer<Model> getModelsByName(const String& name) const;
175 void setSelectionEffect(SelectionEffect* effect);
176
177 const Scene& defaultScene() { return m_default_scene; }
178 Material createMaterial();
179 Material createCameraMaterial(UUID camera);
180 const Dictionary<UUID, Scene>& sceneObjects() { return m_scene_objects; };
181 const Dictionary<UUID, Model>& modelObjects() { return m_model_objects; };
182 const Dictionary<UUID, Dictionary<UUID, Model>>& layerObjects() { return m_layer_objects; };
183 const Dictionary<UUID, Material>& materialObjects() { return m_material_objects; };
184 const Dictionary<UUID, Geometry>& geometryObjects() { return m_geometry_objects; };
185 const Dictionary<UUID, DesignObject>& objects() { return m_design_objects; };
186 const Dictionary<UUID, Effect>& effectObjects() { return m_effect_objects; };
187 const Dictionary<UUID, DesignObject>& deletedObjects() { return m_deleted_objects; };
188 void removeDeletedObject(UUID id) { m_deleted_objects.erase(id); };
189 Buffer<UUID> visibleModels() const;
190 Geometry createMesh();
191 Model createModel();
192 Model createCameraModel(UUID camera);
193 Model createLayer();
194 void invalidateStationVisuals(bool invalidate_visuals, bool invalidate_font);
195 void updateTranslation();
196
197 virtual void clearAll();
198#if NDEVR_SUPPORTS_THREADING
199 void startUpdateThread(const TimeSpan& span, std::function<void(const Exception&)> exception_callback);
200 void stopUpdateThread();
201#endif
202 void cleanupMemory(Buffer<UUID> deleted_objects);
203 virtual void update(const Time& time, const std::function<void()>& wait_callback);
204 virtual void requestAutoSave();
205 virtual void requestAutoSaveCheckpoint();
206 virtual Buffer<UUID> getInverseOf(const Buffer<UUID>& model_ids);
207 virtual Buffer<UUID> getDescendentsOf(const Buffer<UUID>& model_ids);
208 void selectEnclosed(UUID selection_id);
210 Buffer<DesignParameterAccumulator, uint04, ObjectAllocator<false>> accumulateDesignParameters(const BitFlag& accumulation_flags) const;
211 DesignParameterAccumulator accumulateDesignParameter(const DesignParameter& channel, const BitFlag& accumulation_flags) const;
212 public:
218 protected:
219#if NDEVR_SUPPORTS_THREADING
220 Thread* m_update_thread = nullptr;
221 std::function<void(const Exception&)> m_exception_callback = nullptr;
222#endif
223 void updateEffects(const Time& time, const std::function<void()>& wait_callback);
224 //virtual void refreshObject(UUID object);
227 Scene m_default_scene;//This is constant to the application (Does not get written to files)
228 SelectionController* m_selection_controller;
229 ModelEditController* m_edit_controller;
231#if NDEVR_VIEWPORT
232 CameraManager* m_camera_controller;
233#endif
260 };
261
262}
263
264
265
266
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:68
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:57
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition GraphicsPipeline.h:42
Definition DesignCommandManager.h:11
Definition DesignObject.h:66
Definition DesignObjectLookup.h:61
UUID m_active_layer
Definition DesignObjectLookup.h:225
Dictionary< UUID, Geometry > m_geometry_objects
Definition DesignObjectLookup.h:248
ResourceListener * m_language_change_listener
Definition DesignObjectLookup.h:252
bool m_update_language
Definition DesignObjectLookup.h:258
const Dictionary< UUID, DesignObject > & objects()
Definition DesignObjectLookup.h:185
Dictionary< UUID, DynamicPointer< DesignSelection > > m_selection_info
Definition DesignObjectLookup.h:250
bool m_update_station_visuals
Definition DesignObjectLookup.h:256
Dictionary< UUID, Scene > m_all_scene_objects
Definition DesignObjectLookup.h:238
Dictionary< UUID, Model > m_application_root_objects
Definition DesignObjectLookup.h:245
Resource< Time > autosave_checkpoint_request_time
Definition DesignObjectLookup.h:217
Dictionary< UUID, Model > m_model_root_objects
Definition DesignObjectLookup.h:244
const Dictionary< UUID, DesignObject > & deletedObjects()
Definition DesignObjectLookup.h:187
const Dictionary< UUID, Effect > & effectObjects()
Definition DesignObjectLookup.h:186
Scene m_default_scene
Definition DesignObjectLookup.h:227
const Dictionary< UUID, Geometry > & geometryObjects()
Definition DesignObjectLookup.h:184
const Scene & defaultScene()
Definition DesignObjectLookup.h:177
virtual UUID activeProject() const
Definition DesignObjectLookup.h:106
Resource< Time > modified_time
Definition DesignObjectLookup.h:215
const Dictionary< UUID, Model > & modelObjects()
Definition DesignObjectLookup.h:181
Resource< UUID > current_layer
Definition DesignObjectLookup.h:214
Resource< RGBColor > focus_color
Definition DesignObjectLookup.h:213
bool m_update_station_font
Definition DesignObjectLookup.h:257
TimeSpan m_prefered_update_timespan
Definition DesignObjectLookup.h:255
DesignTaskManager * m_task_controller
Definition DesignObjectLookup.h:236
Dictionary< UUID, Material > m_material_objects
Definition DesignObjectLookup.h:247
const Dictionary< UUID, Scene > & sceneObjects()
Definition DesignObjectLookup.h:180
ResourceListener * m_invalidate_station_visuals_listener
Definition DesignObjectLookup.h:251
Dictionary< UUID, Dictionary< UUID, Model > > m_layer_objects
Definition DesignObjectLookup.h:246
SelectionEffect * m_selection_effect
Definition DesignObjectLookup.h:234
Dictionary< UUID, DesignObject > m_deleted_objects
Definition DesignObjectLookup.h:242
UUID m_active_project
Definition DesignObjectLookup.h:226
Buffer< DesignObjectUpdateTarget * > m_update_targets
Definition DesignObjectLookup.h:253
Dictionary< UUID, Model > m_model_objects
Definition DesignObjectLookup.h:240
ModelEditController * m_edit_controller
Definition DesignObjectLookup.h:229
Dictionary< UUID, Model > m_camera_root
Definition DesignObjectLookup.h:237
Dictionary< UUID, Effect > m_effect_objects
Definition DesignObjectLookup.h:249
Time m_last_update_time
Definition DesignObjectLookup.h:254
Resource< Time > autosave_request_time
Definition DesignObjectLookup.h:216
const Dictionary< UUID, Dictionary< UUID, Model > > & layerObjects()
Definition DesignObjectLookup.h:182
Dictionary< UUID, UUID > m_erased_objects
Definition DesignObjectLookup.h:243
void removeDeletedObject(UUID id)
Definition DesignObjectLookup.h:188
LogManager * m_log_manager
Definition DesignObjectLookup.h:235
const Dictionary< UUID, Material > & materialObjects()
Definition DesignObjectLookup.h:183
Dictionary< UUID, DesignObject > m_design_objects
Definition DesignObjectLookup.h:241
UUID m_uuid
Definition DesignObjectLookup.h:259
Dictionary< UUID, Scene > m_scene_objects
Definition DesignObjectLookup.h:239
DesignCommandManager * m_command_controller
Definition DesignObjectLookup.h:230
SelectionController * m_selection_controller
Definition DesignObjectLookup.h:228
Definition DesignObjectUpdateTarget.h:8
Definition DesignParameterAccumulator.h:57
Definition DesignParameter.h:42
Definition DesignSelection.h:19
Definition DesignTask.h:21
Definition Dictionary.h:48
Definition Pointer.hpp:303
Definition Effect.h:42
Definition Exception.hpp:56
Definition Geometry.h:64
Definition LogManager.h:10
Definition Material.h:45
Definition Model.h:54
Definition Project.h:37
Definition DesignLock.h:39
Definition RWLock.h:80
Definition Toggle.h:41
Definition ResourceListener.h:55
Definition Model.h:491
Definition SelectionEffect.h:8
Definition Selector.h:46
Definition String.h:40
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
Definition TimeSpan.h:40
Definition TranslatedString.h:9
Definition UUID.h:66
Definition ViewportLayout.h:10
Definition DesignLock.h:47
Definition RWLock.h:99
Definition ACIColor.h:37
void addCamera(const DynamicPointer< Camera > &camera, kmldom::DocumentPtr doc)
Definition KMLFactory.cpp:498
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer -Can represent exact integer values 0 thro...
Definition BaseValues.hpp:132
Logic for automatically zooming a Camera or Viewport to a certain location or having certain objects ...
Definition ViewportAutoZoomFocus.h:16