NDEVR
API Documentation
QTModelManager.h
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: NDEVR
28File: QTModelManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/SoftwareService.h>
35#include <NDEVR/PopupInfo.h>
36#include <NDEVR/SelectionTreeManager.h>
37#include <NDEVR/Model.h>
38#include <NDEVR/DesignObjectLookup.h>
39#include <NDEVR/SnapLocation.h>
40
41#include <NDEVR/ApplicationOption.h>
42#include <NDEVR/UUID.h>
43#include <NDEVR/Dictionary.h>
44#include <QTimer>
45class QMenu;
46class QMimeData;
47namespace NDEVR
48{
49 struct FileRequest;
50 struct ExportRequest;
53 class QTDesignObject;
54 class WindowManager;
55 class VulkanSession;
56 class QCaptureManager;
58 class FileFormat;
59 class LibraryManager;
61 class BasicThread;
62 class Thread;
63 class Project;
64 struct FactoryParameters;
65 class QTModelManager;
68 class DesignCommand;
69 class GraphicsSession;
70 class GraphicsDevice;
71 struct CaptureRequest;
75 class NDEVR_API GraphicsManagerBase : public QObject, public SoftwareService
76 {
77 Q_OBJECT
78 public:
84 virtual bool hasGraphicsSession(const DynamicPointer<GraphicsDevice>& device) = 0;
96 virtual void addGraphicsSession(DynamicPointer<GraphicsSession> session, bool add_cameras = true) = 0;
101 virtual bool requestHandleManagerUpdating() const = 0;
107 virtual void updateActive(const DynamicPointer<GraphicsSession>& session, bool add_cameras = true) = 0;
112 virtual void addRequest(const ConstPointer<CaptureRequest>& request) = 0;
122 virtual void executeRequest(const ConstPointer<CaptureRequest>& request) = 0;
127 virtual void removeRequest(const ConstPointer<CaptureRequest>& request) = 0;
131 virtual void clearAll() = 0;
136 virtual bool canServiceCaptureRequests() const = 0;
137 signals:
140 };
141
145 {
146 public:
153 public:
158 static NDEVR_API void SetDefaultFactory(GraphicsManagerFactory* factory);
164 protected:
166 };
167
171 class NDEVR_API QTModelManager : public QObject, public DesignObjectLookup
172 {
173 Q_OBJECT
174 public:
175 QTModelManager();
176 QTModelManager(const QTModelManager& manager) = delete;
177 virtual ~QTModelManager();
183 virtual void addScene(Scene object, bool add_all_objects = true) override;
188 virtual void addGeometry(Geometry object) override;
193 virtual void addModel(Model object) override;
198 virtual void addLayer(Model object) override;
203 virtual void addMaterial(Material object) override;
208 virtual LogManager* logManager() const override;
209#if NDEVR_VIEWPORT
215 virtual void addCamera(const DynamicPointer<Camera>& object, bool generate_decorations = true) override;
216#endif
221 void deleteObject(UUID id) override;
226 virtual void eraseModel(UUID id) override;
232 virtual Model restoreModel(UUID id) override;
238
244 virtual void addCameraModel(const UUID& camera, const Model& object) override;
245
258
263 virtual void ShowProperties(const ShowPropertiesSettings& settings);
273 virtual void setWindowManager(WindowManager* manager) { m_window_manager = manager; }
283 virtual void updateModelTopLevel(const Model& object) override;
289 virtual void update(const Time& time, const std::function<void()>& wait_callback) override;
294 virtual void setActiveProject(UUID project_id) override;
300
306 virtual bool canProcessMimeData(const QMimeData* data) const;
312 virtual void processMimeData(const QMimeData* data, PopupInfo origin = PopupInfo());
317 virtual void exportModels(ExportRequest request);
323 virtual void saveModel(FactoryParameters& file, bool is_blocking = false);
324 //virtual void loadModel(Buffer<FactoryParameters, uint04, ObjectAllocator<false>>& files, bool is_blocking = false);
329 virtual void setActiveLayer(UUID layer_id) override;
334 virtual void startQTUpdate(const TimeSpan& interval);
338 virtual void stopQTUpdate();
342 virtual void stopAll();
346 virtual void clearSelected() override;
351 virtual void setSelected(Buffer<UUID> ids) override;
356 virtual void appendSelected(Buffer<UUID> ids) override;
361 virtual void removeSelected(const Buffer<UUID>& ids);
366 virtual void removeSelected(UUID id);
386 virtual DesignTaskManager* taskManager() const override;
391 virtual bool hasBeenModified() const;
395 virtual void requestQTUpdate();
399 virtual void clearAll() override;
404 virtual bool hasUserSavedProject() const;
408 virtual void setProjectTimeZone();
414 void popSelected(const UUID& id, bool signal = true);
420 void addSelected(const UUID& id, bool signal = true);
426 void setRequestDeploymentCallback(const StringView& callback_name, const std::function<void(const UUID&)>& callback);
431 const Dictionary<String, std::function<void(const UUID&)>>& requestDeploymentCallbacks();
436 virtual bool useProjectFolders() const;
441 virtual void postDesignCommand(const DynamicPointer<DesignCommand>& command) override;
446 virtual void runDesignCommand(const DynamicPointer<DesignCommand>& command) override;
447 private:
448 virtual void _qtUpdate(const Time& time);
449 virtual void _qtUpdateDeleted(UUID model);
450 virtual void _qtUpdateDeleted();
451 virtual void _qtUpdateAdded();
452 virtual void _qtUpdateModified();
453 virtual void _qtUpdateModelModified(UUID model);
454 virtual void _qtUpdateObject(UUID object);
455 void appendToAddQueue(UUID id);
456
457 public slots:
459 void popFocus();
466 void setFocus(UUID id);
467 protected slots:
469 void qtUpdate();
470 signals:
471 void canExitApplicationSignal(bool can_exit);
472 void canOpenProjectSignal(bool can_open_project);
473 void canImportFileSignal(bool can_import_file);
478 void onAddCamera(UUID id);
485 void onAddViewportObject(UUID camera, UUID object);
497
502
507 void onSwapSelectedSignal(Buffer<UUID> old_selected, Buffer<UUID> new_selected);
508 void onUpdateFocus(UUID id, bool focussed);
509 private slots:
510 void _performDeletion();
511 void _refreshModelList();
512 private:
513 void finishCommand(const DynamicPointer<DesignCommand>& command) override;
514 protected:
521#if NDEVR_VIEWPORT
523#endif
542#if NDEVR_SUPPORTS_THREADING
544#endif
547 Dictionary<String, std::function<void(const UUID&)>> m_request_deployment_callbacks;
548 };
549
550}
A thread that executes a user-provided callback function concurrently.
Definition BasicThread.h:47
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A thread designed to read and write files using the FactoryIO interface.
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
Manages setting up the context menu that is shown when the user right-clicks or accesses the ContextM...
Forward declaration of the central design object registry.
DesignObjectLookup()
Constructs a new DesignObjectLookup with default-initialized members.
Model model(const UUID &id, bool allow_deleted=false) const
Retrieves a model by its UUID.
Buffer< UUID > selected() const
Returns the UUIDs of all currently selected objects.
Manages all active and inactive tasks for a DesignObjectLookup.
Definition DesignTask.h:29
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
Data that describes a particular file format and how to use the format with the program.
Definition FileFormat.h:45
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
A physical or virtual device used with the NDEVR Rendering Engine.
Used for interfacing with a Graphics engine, such as Vulkan or OpenGL.
virtual void clearAll()=0
Clears all sessions and pending requests.
virtual bool hasGraphicsSession(const DynamicPointer< GraphicsDevice > &device)=0
Checks whether a graphics session exists for the given device.
virtual bool requestHandleManagerUpdating() const =0
Checks whether this manager requests to handle its own updating.
virtual void removeRequest(const ConstPointer< CaptureRequest > &request)=0
Removes a capture request from the queue.
virtual void addGraphicsSession(DynamicPointer< GraphicsSession > session, bool add_cameras=true)=0
Adds a new graphics session to the manager.
virtual Buffer< DynamicPointer< GraphicsSession > > availableSessions() const =0
Retrieves all available graphics sessions.
virtual void executeRequest(const ConstPointer< CaptureRequest > &request)=0
Immediately executes a capture request.
virtual void updateActive(const DynamicPointer< GraphicsSession > &session, bool add_cameras=true)=0
Updates the active state of a graphics session.
virtual bool canServiceCaptureRequests() const =0
Checks whether the manager can service capture requests.
virtual void addRequest(const ConstPointer< CaptureRequest > &request)=0
Adds a capture request to the queue.
void captureManagerStateChangeSignal()
Emitted when the capture manager state changes.
void graphicsSessionChangeSignal()
Emitted when the set of graphics sessions changes.
virtual const DynamicPointer< GraphicsSession > & graphicsSession(const DynamicPointer< GraphicsDevice > &device)=0
Retrieves the graphics session associated with the given device.
Stores a default rendering engine to be used with the application.
static void SetDefaultFactory(GraphicsManagerFactory *factory)
Sets the default graphics manager factory for the application.
virtual GraphicsManagerBase * createManager(QTModelManager *manager)=0
Creates a new GraphicsManagerBase instance for the given model manager.
static GraphicsManagerFactory * s_factory
The singleton default factory instance.
static GraphicsManagerFactory * DefaultFactory()
Retrieves the default graphics manager factory.
A GraphicsPipeline that is responsible for setting up and rendering the resources of a DesignObjectLo...
Manages loading Models from a group that is stored either on a remote server or locally on the disk i...
A class that has any number of children that also feed into the log.
Definition LogManager.h:15
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
Takes user input in order to modify a model in real-time.
A core class that represents a node on model hierarchy.
Definition Model.h:292
Manages writing to the NDV file and any folder operations for projects.
A Model which represents a user-project.
Definition Project.h:41
An interface used to manage multiple CaptureRequests and scedule their completion.
A pointer to a DesignObject within a QTModelManager that receives and emits update signals based on t...
A Qt compatible ItemModel for interfacing with a DesignObjectLookup.
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
void setSelectedToFocus()
Sets the currently selected objects as the focus target.
bool m_is_updating
Whether an update cycle is currently in progress.
SelectionTreeManager m_selection_tree_manager
Manages the selection tree for viewport interactions.
void canImportFileSignal(bool can_import_file)
Emitted to indicate whether a file can be imported.
virtual DynamicPointer< LibraryManager > libraryManager()
Retrieves the library manager for asset and template management.
virtual void eraseModel(UUID id) override
Erases a model from the manager, keeping it available for restoration.
void onDeleteObject(UUID id)
Emitted when a design object is deleted.
void onCommandExecutedSignal(UUID id)
Emitted when a design command finishes execution.
void setFocus(UUID id)
Sets focus to a specific design object.
QTModelManagerView * m_manager_view
The Qt item model view for this manager.
void onAddMaterial(Buffer< UUID > id)
Emitted when materials are added.
ProjectFileManager * projectFileManager()
Retrieves the project file manager.
Buffer< UUID > m_material_update_cache
Cache of material UUIDs pending update notification.
void setRequestDeploymentCallback(const StringView &callback_name, const std::function< void(const UUID &)> &callback)
Registers a callback to be invoked when a deployment is requested.
ProjectFileManager * m_project_file_manager
Manages project file operations.
virtual void setSelected(Buffer< UUID > ids) override
Sets the selection to the given set of UUIDs, replacing any existing selection.
virtual DesignTaskManager * taskManager() const override
Retrieves the design task manager for background operations.
virtual DynamicPointer< QTDesignObject > getQTObject(UUID id)
Retrieves a Qt wrapper for a design object by its UUID.
virtual void setWindowManager(WindowManager *manager)
Sets the window manager used for dialog management.
WindowManager * windowManager()
Retrieves the window manager.
virtual void addCameraModel(const UUID &camera, const Model &object) override
Associates a model with a camera viewport.
void onAddCommand(UUID id)
Emitted when a design command is added.
void activeLayerChangedSignal(UUID id)
Emitted when the active layer changes.
virtual Model restoreModel(UUID id) override
Restores a previously erased model.
void onProjectUpdatedSignal()
Emitted when the active project is updated.
void onAddViewportObject(UUID camera, UUID object)
Emitted when a model is added to a camera viewport.
virtual void requestQTUpdate()
Requests a Qt update cycle to be scheduled.
virtual void removeSelected(UUID id)
Removes a single UUID from the current selection.
Buffer< UUID > m_top_level_change
Queue of models with top-level parent changes.
virtual void appendSelected(Buffer< UUID > ids) override
Appends the given UUIDs to the current selection.
virtual void clearAll() override
Clears all data from the manager, including scenes, models, and selections.
void canExitApplicationSignal(bool can_exit)
Emitted to indicate whether the application can safely exit.
void onCleanupRequestSignal()
Emitted when a cleanup cycle is requested.
void onAddCamera(UUID id)
Emitted when a camera is added.
void finishCommand(const DynamicPointer< DesignCommand > &command) override
Finalizes a design command after execution.
void qtUpdate()
Performs the periodic Qt update cycle.
virtual void stopAll()
Stops all active operations, including timers and background threads.
void canOpenProjectSignal(bool can_open_project)
Emitted to indicate whether a project can be opened.
Buffer< UUID > m_model_update_cache
Cache of model UUIDs pending update notification.
Dictionary< UUID, DynamicPointer< QTDesignObject > > m_qt_design_objects
Map of UUIDs to their Qt wrapper objects.
void onUpdateCommand(UUID id)
Emitted when a command is updated.
GraphicsManagerBase * graphicsManager()
Retrieves the graphics manager used for rendering.
void addSelected(const UUID &id, bool signal=true)
Adds a single object to the selection.
void onSelectedSignal(Buffer< UUID > ids, bool selected)
Emitted when object selection changes.
virtual void addGeometry(Geometry object) override
Adds a geometry object to the manager and emits appropriate signals.
void onAddScene(Buffer< UUID > id)
Emitted when scenes are added.
void onActiveProjectChanged(UUID id)
Emitted when the active project changes.
virtual void addLayer(Model object) override
Adds a layer to the manager and emits appropriate signals.
virtual void ShowProperties(const ShowPropertiesSettings &settings)
Shows a properties dialog for a design object.
virtual void setActiveProject(UUID project_id) override
Sets the active project by its UUID.
void onAddModel(Buffer< UUID > id)
Emitted when models are added.
DynamicPointer< LibraryManager > m_library_manager
The library manager for assets and templates.
virtual Buffer< DynamicPointer< QTDesignObject > > getQTObjectsByID(const Buffer< UUID > &ids)
Retrieves Qt wrappers for multiple design objects by their UUIDs.
void onDeleteGeometry(UUID id)
Emitted when a geometry is deleted.
void addLayerSignal(Buffer< UUID > id)
Emitted when layers are added.
Buffer< UUID > m_added_objects
Queue of recently added object UUIDs.
void popSelected(const UUID &id, bool signal=true)
Removes a single object from the selection.
virtual void setProjectTimeZone()
Sets the project time zone based on current project settings.
GraphicsManagerBase * m_graphics_manager
The graphics rendering manager.
virtual LogManager * logManager() const override
Retrieves the log manager used for diagnostic output.
WindowManager * m_window_manager
The window manager for dialog and UI management.
virtual void saveModel(FactoryParameters &file, bool is_blocking=false)
Saves a model to a file.
virtual void updateModelTopLevel(const Model &object) override
Notifies that a model's top-level parent has changed.
void onSwapSelectedSignal(Buffer< UUID > old_selected, Buffer< UUID > new_selected)
Emitted when the entire selection is swapped.
virtual void processMimeData(const QMimeData *data, PopupInfo origin=PopupInfo())
Processes incoming MIME data, typically from a drag-and-drop operation.
virtual void runDesignCommand(const DynamicPointer< DesignCommand > &command) override
Immediately runs a design command.
void onDeleteObjects(Buffer< UUID > ids)
Emitted when objects are deleted.
void onDeleteMaterial(UUID id)
Emitted when a material is deleted.
Buffer< UUID > m_geometry_update_cache
Cache of geometry UUIDs pending update notification.
virtual void update(const Time &time, const std::function< void()> &wait_callback) override
Performs an update cycle at the given time.
Buffer< UUID > m_objects_to_remove
Queue of objects pending removal.
QTimer m_launch_timer
Timer used for periodic Qt updates.
virtual void addCamera(const DynamicPointer< Camera > &object, bool generate_decorations=true) override
Adds a camera to the manager and emits appropriate signals.
void onUpdateFocus(UUID id, bool focussed)
Emitted when focus changes for an object.
virtual bool hasBeenModified() const
Checks whether the project has been modified since the last save.
void materialsUpdatedSignal(const Buffer< UUID > &ids)
Emitted when materials are updated.
void setGraphicsManager(GraphicsManagerBase *graphics_manager)
Sets the graphics manager used for rendering.
void onClearAllSignal()
Emitted when all data is cleared.
virtual bool useProjectFolders() const
Checks whether the manager uses project folders for file organization.
virtual void exportModels(ExportRequest request)
Exports models to a file based on the given export request.
void captureManagerStateChangeSignal()
Emitted when the capture manager state changes.
Dictionary< String, std::function< void(const UUID &)> > m_request_deployment_callbacks
Registered deployment request callbacks.
void onDeleteModel(UUID id)
Emitted when a model is deleted.
void onModelTopLevelChange(Buffer< UUID > id)
Emitted when models change their top-level parent.
ContextMenuManager * contextMenuManager()
Retrieves the context menu manager.
void onDeleteCommand(UUID id)
Emitted when a command is deleted.
Time m_last_qt_update_time
Timestamp of the last Qt update cycle.
const Dictionary< String, std::function< void(const UUID &)> > & requestDeploymentCallbacks()
Retrieves all registered deployment request callbacks.
virtual void setActiveLayer(UUID layer_id) override
Sets the active layer by its UUID.
Buffer< UUID > m_scene_update_cache
Cache of scene UUIDs pending update notification.
virtual void startQTUpdate(const TimeSpan &interval)
Starts the periodic Qt update timer.
void graphicsSessionChangeSignal()
Emitted when graphics sessions change.
void deleteObject(UUID id) override
Marks a design object for deletion by its UUID.
void popFocus()
Removes the current focus object from the focus stack.
virtual void addModel(Model object) override
Adds a model to the manager and emits appropriate signals.
virtual void clearSelected() override
Clears all selected objects and emits the corresponding signal.
Time m_last_tree_create_time
Timestamp of the last tree creation.
virtual QTModelManagerView * modelManagerView()
Retrieves the QTModelManagerView associated with this manager.
virtual bool hasUserSavedProject() const
Checks whether the user has explicitly saved the current project.
virtual void stopQTUpdate()
Stops the periodic Qt update timer.
void layersUpdatedSignal(const Buffer< UUID > &ids)
Emitted when layers are updated.
CachedFactoryIOThread * m_write_thread
Background thread for file write operations.
ContextMenuManager * m_context_menu_manager
Manages right-click context menus.
virtual bool canProcessMimeData(const QMimeData *data) const
Checks whether the given MIME data can be processed (e.g., drag and drop).
Buffer< UUID > m_erased_objects
Queue of recently erased object UUIDs.
void modelsUpdatedSignal(const Buffer< UUID > &ids)
Emitted when models are updated.
virtual void addMaterial(Material object) override
Adds a material to the manager and emits appropriate signals.
virtual void removeSelected(const Buffer< UUID > &ids)
Removes the given UUIDs from the current selection.
Time m_last_audit_time
Timestamp of the last data audit.
void objectsUpdatedSignal(const Buffer< UUID > &ids)
Emitted when design objects are updated.
Buffer< UUID > m_camera_update_cache
Cache of camera UUIDs pending update notification.
Buffer< UUID > m_layer_update_cache
Cache of layer UUIDs pending update notification.
QTimer m_auto_save_timer
Timer used for auto-saving the project.
void onDeleteCamera(UUID id)
Emitted when a camera is deleted.
virtual void postDesignCommand(const DynamicPointer< DesignCommand > &command) override
Posts a design command for asynchronous execution.
virtual void addScene(Scene object, bool add_all_objects=true) override
Adds a scene to the manager and emits appropriate signals.
UUID m_focused_object
The UUID of the currently focused object.
bool m_needs_cleanup
Whether a cleanup pass is needed.
Buffer< UUID > m_deleted_objects
Queue of recently deleted object UUIDs.
void onShowPropertiesRequested(UUID object)
Emitted when a properties dialog is requested for an object.
void onAddGeometry(Buffer< UUID > id)
Emitted when geometry objects are added.
The root Model that is responsible for storing the underlying data for all Scene Models.
Definition Scene.h:52
Manages selection trees, which optimize the process of selecting data within large Geometry objects.
Software Service Managers take a Software service to modify the behavior of the software.
Base interface for services that extend or modify software behavior through modules.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
The default thread class for executing concurrent sequences in the NDEVR API.
Definition Thread.h:113
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
Creates and manages the resources necessary for converting a DesignObjectLookup into 3D rendered data...
Manages all windows and logic surrounding dialogs and views for displaying and managing any environme...
The primary namespace for the NDEVR SDK.
A request to capture the 3D view as a 2D image.
Stores information related to exporting specific data from the software.
A container of input information that is to be filled with output information by an IOFactory.
Definition IOFactory.h:105
A FileRequest bundles format data as well as a particular file.
Definition FileFormat.h:101
Class which is used to pass arguments and requests for creating a popup dialog or widget.
Definition PopupInfo.h:16
Stores settings for setting up and displaying a DesignObjectDialog such as whether the dialog is part...