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;
60 /**--------------------------------------------------------------------------------------------------
61 \brief A core class where all Design Objects including models, materials, and geometries are stored.
62 Contains the logic necessary to build or display any number of Scenes simultaniously
63 **/
65 {
66 public:
70 RLock readLock() const;
72
73 WLock writeLock(const std::function<void()>& wait_callback);
74 RLock readLock(const std::function<void()>& wait_callback) const;
75
76 WLock tryWriteLock(uint08 milliseconds = 10);
77 RLock tryReadLock(uint08 milliseconds = 10) const;
78
80 RLock tryReadLock(const TimeSpan& span) const;
81
84 bool isCommandLocked() const;
85 const void* lockPtr() const;
88
89 virtual void addScene(Scene scene, bool ignore_application_scene = false);
90 virtual void addMaterial(Material object);
91 virtual void addGeometry(Geometry object);
92 virtual void addEffect(Effect object);
93 virtual void addModel(Model object);
94 virtual void addCameraModel(const UUID& camera, const Model& object);
95 virtual void addLayer(Model layer);
96 virtual void addSelection(const DesignSelection& object);
97 virtual void clearSelected();
98 virtual void setSelected(Buffer<UUID> ids);
99 virtual void appendSelected(Buffer<UUID> ids);
100 virtual void refreshScene(UUID scene_id, bool ignore_application_scene);
101 virtual void refreshModel(const Model& object);
102
103 virtual void updateModelTopLevel(const Model& object);
105 virtual void deleteObject(UUID id);
106 virtual void eraseModel(UUID id);
108 virtual void setActiveLayer(UUID layer_id);
109 virtual void setActiveProject(UUID layer_id);
110 virtual UUID activeProject() const { return m_active_project; }
112 void ensureLayerExistsInScene(const UUID& layer_id, const UUID& scene_id);
115 Geometry geometry(const UUID& id, bool allow_deleted = false) const;
116 Material material(const UUID& id, bool allow_deleted = false) const;
117 Scene scene(const UUID& id, bool allow_deleted = false) const;
118 Model modelOrLayer(const UUID& id, bool allow_deleted = false) const;
119 Model model(const UUID& id, bool allow_deleted = false) const;
120 Effect effect(const UUID& id, bool allow_deleted = false) const;
121 Model layer(const UUID& id, bool allow_deleted = false) const;
122 Model layer(const UUID& layer_id, const UUID& scene_id, bool allow_deleted = false) const;
123 Model findLayer(const String& layer, bool use_translation = true) const;
124 Model findLayer(const TranslatedString& layer) const;
125#if NDEVR_VIEWPORT
126 DynamicPointer<Camera> createCamera(Model& parent, const ViewportFormat& format);
127 DynamicPointer<Camera> createCamera(const ViewportFormat& format);
128 bool hasCamera(const UUID& id) const;
129 virtual void addCamera(const DynamicPointer<Camera>& object);
130 const DynamicPointer<Camera>& getCamera(const UUID& id);
131 const ConstPointer<Camera>& getCamera(const UUID& id) const;
132 Bounds<3, fltp08> boundsOfVisible(const Camera& camera) const;
133 virtual CameraManager* cameraManager();
134 virtual const CameraManager* cameraManager() const;
135 virtual SelectionController* selectionController();
136 virtual ModelEditController* editManager();
137 virtual SelectionEffect* selectionEffect();
138 void setViewportFocus(AutoZoomFocus focus);
139#endif
143
144 bool hasModelID(const UUID& id, bool allow_deleted = false) const;
145 bool hasSceneID(const UUID& id, bool allow_deleted = false) const;
146 bool hasObjectID(const UUID& id, bool allow_deleted = false) const;
147 bool hasMaterialID(const UUID& id) const;
148 bool hasGeometryID(const UUID& id) const;
149 bool hasEffect(const UUID& id) const;
150 bool hasSelectionInfo(const UUID& id) const;
151 bool hasLayerID(const UUID& id, bool allow_deleted = false) const;
152 bool hasLayerID(const UUID& id, const UUID& scene_id) const;
154
155 DesignObject object(const UUID& id) const;
156 Buffer<UUID> getRootObjectIDs(bool include_app_owned = false) const;
157 Buffer<UUID> getRootObjectIDs(UUID camera_id, bool include_app_owned = false) const;
158 Buffer<Model> getRootObjects(bool include_app_owned = false) const;
159 Buffer<Model> getRootObjects(UUID camera_id, bool include_app_owned = false) const;
161 void colorByChannel(UUID target, const DesignParameter& channel);
164
165
166 virtual LogManager* logManager() const;
168 virtual void postCommand(const DynamicPointer<DesignCommand>& command);
169 virtual void runCommand(const DynamicPointer<DesignCommand>& command);
170 virtual void finishCommand(const DynamicPointer<DesignCommand>& command);
171 //virtual void addCameraObject(UUID camera, const Model& object);
180
181 const Scene& defaultScene() { return m_default_scene; }
184 const Dictionary<UUID, Scene>& sceneObjects() { return m_scene_objects; };
185 const Dictionary<UUID, Model>& modelObjects() { return m_model_objects; };
186 const Dictionary<UUID, Dictionary<UUID, Model>>& layerObjects() { return m_layer_objects; };
187 const Dictionary<UUID, Material>& materialObjects() { return m_material_objects; };
188 const Dictionary<UUID, Geometry>& geometryObjects() { return m_geometry_objects; };
189 const Dictionary<UUID, DesignObject>& objects() { return m_design_objects; };
190 const Dictionary<UUID, Effect>& effectObjects() { return m_effect_objects; };
191 const Dictionary<UUID, DesignObject>& deletedObjects() { return m_deleted_objects; };
192 void removeDeletedObject(UUID id) { m_deleted_objects.erase(id); };
198 void invalidateStationVisuals(bool invalidate_visuals, bool invalidate_font);
200
201 virtual void clearAll();
202#if NDEVR_SUPPORTS_THREADING
203 void startUpdateThread(const TimeSpan& span, std::function<void(const Exception&)> exception_callback);
205#endif
206 void cleanupMemory(Buffer<UUID> deleted_objects);
207 virtual void update(const Time& time, const std::function<void()>& wait_callback);
208 virtual void requestAutoSave();
210 virtual Buffer<UUID> getInverseOf(const Buffer<UUID>& model_ids);
211 virtual Buffer<UUID> getDescendentsOf(const Buffer<UUID>& model_ids);
212 void selectEnclosed(UUID selection_id);
215 DesignParameterAccumulator accumulateDesignParameter(const DesignParameter& channel, const BitFlag& accumulation_flags) const;
216 public:
222 protected:
223#if NDEVR_SUPPORTS_THREADING
224 Thread* m_update_thread = nullptr;
225 std::function<void(const Exception&)> m_exception_callback = nullptr;
226#endif
227 void updateEffects(const Time& time, const std::function<void()>& wait_callback);
228 //virtual void refreshObject(UUID object);
231 Scene m_default_scene;//This is constant to the application (Does not get written to files)
232 SelectionController* m_selection_controller;
233 ModelEditController* m_edit_controller;
235#if NDEVR_VIEWPORT
236 CameraManager* m_camera_controller;
237#endif
264 };
265
266}
267
268
269
270
#define NDEVR_DESIGN_API
Definition DLLInfo.h:55
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:52
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition GraphicsPipeline.h:42
Stores logic for performing, undoing, or redoing DesignCommands.
Definition DesignCommandManager.h:14
A low-level database object that can be used to access general stored properties within the NDEVR Mod...
Definition DesignObject.h:67
A core class where all Design Objects including models, materials, and geometries are stored....
Definition DesignObjectLookup.h:65
Bounds< 3, fltp08 > boundsOfVisible() const
UUID m_active_layer
Definition DesignObjectLookup.h:229
Model createCameraModel(UUID camera)
void selectEnclosed(UUID selection_id)
Dictionary< UUID, Geometry > m_geometry_objects
Definition DesignObjectLookup.h:252
virtual void updateModelTopLevel(const Model &object)
bool hasLayerID(const UUID &id, bool allow_deleted=false) const
bool hasObjectID(const UUID &id, bool allow_deleted=false) const
ResourceListener * m_language_change_listener
Definition DesignObjectLookup.h:256
virtual void appendSelected(Buffer< UUID > ids)
RDesignLock readLock(UUID id)
virtual void refreshScene(UUID scene_id, bool ignore_application_scene)
bool m_update_language
Definition DesignObjectLookup.h:262
void processSelection(SelectionInfo &info) const
virtual void deleteObject(UUID id)
WDesignLock writeLock(UUID id)
const Dictionary< UUID, DesignObject > & objects()
Definition DesignObjectLookup.h:189
Dictionary< UUID, DynamicPointer< DesignSelection > > m_selection_info
Definition DesignObjectLookup.h:254
bool m_update_station_visuals
Definition DesignObjectLookup.h:260
Scene scene(const UUID &id, bool allow_deleted=false) const
Dictionary< UUID, Scene > m_all_scene_objects
Definition DesignObjectLookup.h:242
virtual void setSelected(Buffer< UUID > ids)
const DynamicPointer< DesignSelection > & getSelectionInfo(const UUID &id)
void ensureLayerExistsInScene(const UUID &layer_id, const UUID &scene_id)
Buffer< Model > getModelsByType(const Buffer< String > &types) const
Dictionary< UUID, Model > m_application_root_objects
Definition DesignObjectLookup.h:249
void updateEffects(const Time &time, const std::function< void()> &wait_callback)
void addUpdateTarget(DesignObjectUpdateTarget *target)
RLock tryReadLock(uint08 milliseconds=10) const
Resource< Time > autosave_checkpoint_request_time
Definition DesignObjectLookup.h:221
Dictionary< UUID, Model > m_model_root_objects
Definition DesignObjectLookup.h:248
Model findLayer(const TranslatedString &layer) const
virtual Model restoreModel(UUID id)
Model layer(const UUID &layer_id, const UUID &scene_id, bool allow_deleted=false) const
const Dictionary< UUID, DesignObject > & deletedObjects()
Definition DesignObjectLookup.h:191
const Dictionary< UUID, Effect > & effectObjects()
Definition DesignObjectLookup.h:190
Model findLayer(const String &layer, bool use_translation=true) const
Scene m_default_scene
Definition DesignObjectLookup.h:231
virtual void setActiveProject(UUID layer_id)
const Dictionary< UUID, Geometry > & geometryObjects()
Definition DesignObjectLookup.h:188
const Scene & defaultScene()
Definition DesignObjectLookup.h:181
bool hasModelID(const UUID &id, bool allow_deleted=false) const
void cleanupMemory(Buffer< UUID > deleted_objects)
bool hasGeometryID(const UUID &id) const
virtual void addGeometry(Geometry object)
Model modelOrLayer(const UUID &id, bool allow_deleted=false) const
virtual UUID activeProject() const
Definition DesignObjectLookup.h:110
virtual void eraseModel(UUID id)
const Dictionary< UUID, Model > & getAllSceneLayers(const UUID &id) const
void setSelectionEffect(SelectionEffect *effect)
void removeUpdateTarget(DesignObjectUpdateTarget *target)
virtual DesignTaskManager * taskManager() const
Resource< Time > modified_time
Definition DesignObjectLookup.h:219
Effect effect(const UUID &id, bool allow_deleted=false) const
virtual void addCameraModel(const UUID &camera, const Model &object)
Material createCameraMaterial(UUID camera)
const Dictionary< UUID, Model > & modelObjects()
Definition DesignObjectLookup.h:185
Resource< UUID > current_layer
Definition DesignObjectLookup.h:218
Resource< RGBColor > focus_color
Definition DesignObjectLookup.h:217
const void * lockPtr() const
Buffer< Model > getLayersByType(const String &type) const
virtual void addSelection(const DesignSelection &object)
Buffer< Model > getRootObjects(bool include_app_owned=false) const
Geometry geometry(const UUID &id, bool allow_deleted=false) const
bool m_update_station_font
Definition DesignObjectLookup.h:261
bool hasMaterialID(const UUID &id) const
Buffer< DesignParameter, uint04, ObjectAllocator< false > > designParameters() const
virtual void update(const Time &time, const std::function< void()> &wait_callback)
virtual void clearSelected()
Buffer< UUID > getModelIDsByType(const String &type) const
TimeSpan m_prefered_update_timespan
Definition DesignObjectLookup.h:259
Buffer< Model > getLayersByType(const Buffer< String > &types) const
RLock readLock(const std::function< void()> &wait_callback) const
virtual void runCommand(const DynamicPointer< DesignCommand > &command)
DesignTaskManager * m_task_controller
Definition DesignObjectLookup.h:240
Dictionary< UUID, Material > m_material_objects
Definition DesignObjectLookup.h:251
Buffer< Model > getRootObjects(UUID camera_id, bool include_app_owned=false) const
virtual void refreshModel(const Model &object)
Buffer< UUID > visibleModels() const
Model model(const UUID &id, bool allow_deleted=false) const
DesignParameterAccumulator accumulateDesignParameter(const DesignParameter &channel, const BitFlag &accumulation_flags) const
void invalidateStationVisuals(bool invalidate_visuals, bool invalidate_font)
const Dictionary< UUID, Scene > & sceneObjects()
Definition DesignObjectLookup.h:184
ResourceListener * m_invalidate_station_visuals_listener
Definition DesignObjectLookup.h:255
Dictionary< UUID, Dictionary< UUID, Model > > m_layer_objects
Definition DesignObjectLookup.h:250
Buffer< UUID > getRootObjectIDs(UUID camera_id, bool include_app_owned=false) const
void startUpdateThread(const TimeSpan &span, std::function< void(const Exception &)> exception_callback)
SelectionEffect * m_selection_effect
Definition DesignObjectLookup.h:238
virtual void addModel(Model object)
bool isCommandLocked() const
Dictionary< UUID, DesignObject > m_deleted_objects
Definition DesignObjectLookup.h:246
virtual void addMaterial(Material object)
WLock writeLock(const std::function< void()> &wait_callback)
UUID m_active_project
Definition DesignObjectLookup.h:230
Buffer< Model > getModelsByName(const String &name) const
Model layer(const UUID &id, bool allow_deleted=false) const
virtual void requestAutoSaveCheckpoint()
virtual DesignCommandManager * commandManager()
Buffer< DesignObjectUpdateTarget * > m_update_targets
Definition DesignObjectLookup.h:257
Bounds< 3, fltp08 > bounds() const
WLock tryWriteLock(uint08 milliseconds=10)
bool hasSceneID(const UUID &id, bool allow_deleted=false) const
Buffer< Model > getModelsByID(const Buffer< UUID > &ids) const
Dictionary< UUID, Model > m_model_objects
Definition DesignObjectLookup.h:244
bool hasLayerID(const UUID &id, const UUID &scene_id) const
ModelEditController * m_edit_controller
Definition DesignObjectLookup.h:233
virtual void addEffect(Effect object)
const ConstPointer< DesignSelection > & getSelectionInfo(const UUID &id) const
virtual Buffer< UUID > getInverseOf(const Buffer< UUID > &model_ids)
Material material(const UUID &id, bool allow_deleted=false) const
bool hasSelectionInfo(const UUID &id) const
Dictionary< UUID, Model > m_camera_root
Definition DesignObjectLookup.h:241
virtual void executePendingCommands()
Dictionary< UUID, Effect > m_effect_objects
Definition DesignObjectLookup.h:253
Buffer< Model > getModelsByType(const String &type) const
Time m_last_update_time
Definition DesignObjectLookup.h:258
virtual void postCommand(const DynamicPointer< DesignCommand > &command)
Resource< Time > autosave_request_time
Definition DesignObjectLookup.h:220
RLock tryReadLock(const TimeSpan &span) const
const Dictionary< UUID, Dictionary< UUID, Model > > & layerObjects()
Definition DesignObjectLookup.h:186
bool hasEffect(const UUID &id) const
Dictionary< UUID, UUID > m_erased_objects
Definition DesignObjectLookup.h:247
Buffer< DesignParameterAccumulator, uint04, ObjectAllocator< false > > accumulateDesignParameters(const BitFlag &accumulation_flags) const
virtual Project activeProjectModel() const
virtual void addLayer(Model layer)
virtual LogManager * logManager() const
void removeDeletedObject(UUID id)
Definition DesignObjectLookup.h:192
virtual void requestAutoSave()
LogManager * m_log_manager
Definition DesignObjectLookup.h:239
virtual void setActiveLayer(UUID layer_id)
const Dictionary< UUID, Material > & materialObjects()
Definition DesignObjectLookup.h:187
virtual void finishCommand(const DynamicPointer< DesignCommand > &command)
Buffer< UUID > getRootObjectIDs(bool include_app_owned=false) const
Dictionary< UUID, DesignObject > m_design_objects
Definition DesignObjectLookup.h:245
UUID m_uuid
Definition DesignObjectLookup.h:263
DesignObject object(const UUID &id) const
virtual Buffer< UUID > getDescendentsOf(const Buffer< UUID > &model_ids)
Dictionary< UUID, Scene > m_scene_objects
Definition DesignObjectLookup.h:243
virtual void addScene(Scene scene, bool ignore_application_scene=false)
DesignCommandManager * m_command_controller
Definition DesignObjectLookup.h:234
SelectionController * m_selection_controller
Definition DesignObjectLookup.h:232
WLock tryWriteLock(const TimeSpan &span)
void colorByChannel(UUID target, const DesignParameter &channel)
An object that will be call update, each time the lookup is updated.
Definition DesignObjectUpdateTarget.h:10
Searches a model heirarchy and pulls all parameter data based on the AccumationMode settings.
Definition DesignParameterAccumulator.h:67
A definition of data that is logically stored in the Model heirarchy. Data could be a property of a M...
Definition DesignParameter.h:46
A simple structure for storing a collection of data.
Definition DesignSelection.h:26
Manages all active and inactive tasks for a DesignObjectLookup.
Definition DesignTask.h:28
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
A core class that provides a dynamic effect to an object in a model heirarchy.
Definition Effect.h:45
Provides consistent interface to handle errors through the throw expression. All exceptions generated...
Definition Exception.hpp:47
A core class within the model heirarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:64
A class that has any number of children that also feed into the log. Can be used to easily collect lo...
Definition LogManager.h:14
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:51
A core class that represents a node on model heirarchy. This node may contain a Geometry or one or mo...
Definition Model.h:58
A Model which represents a user-project. A project is a series of Scenes grouped together within a so...
Definition Project.h:41
Used to lock a particular model for editing (DEPRECIATED)
Definition DesignLock.h:43
Used to lock a particular variable for reading. Any number of readers can be created when no write lo...
Definition RWLock.h:91
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Definition Toggle.h:41
A class that can subscribe to any number of Resources which will get updates when the Resource(s) hav...
Definition ResourceListener.h:62
The root Model that is responsible for storing the underlying data for all Scene Models.
Definition Model.h:492
Applies certain effects to a model that has been selected.
Definition SelectionEffect.h:12
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
Definition Selector.h:50
The core String class for the NDEVR API.
Definition String.h:69
A thread is a single sequence stream within the software.
Definition Thread.h:67
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
Stores information for how to construct a viewport.
Definition ViewportLayout.h:13
Used to lock a particular model for editing (DEPRECIATED)
Definition DesignLock.h:55
Used to lock a particular variable for writing. Only one write lock can be created when no read locks...
Definition RWLock.h:115
Definition ACIColor.h:37
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Definition BaseValues.hpp:106
Logic for automatically zooming a Camera or Viewport to a certain location or having certain objects ...
Definition ViewportAutoZoomFocus.h:14