NDEVR
API Documentation
LibraryManager.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: LibraryManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/QTModelManager.h>
34#include <NDEVR/TranslatedString.h>
35namespace NDEVR
36{
41 class NDEVR_API LibraryManager : public QObject
42 {
43 Q_OBJECT
44 public:
50 LibraryManager(QTModelManager* manager, const File& library_folder);
56 String getIcon(const UUID& id) const;
62 TranslatedString getName(const UUID& id) const
63 {
64 return m_names.get(id);
65 }
66
71 String getType(const UUID& id) const
72 {
73 return m_types.get(id);
74 }
75
81 {
82 return m_search_terms.get(id);
83 }
84
89 Model findObject(const UUID& id);
94 void centerModel(Model& model);
100 bool hasID(const UUID& id) const;
110 Buffer<UUID> getIDs() const { return m_ids; }
136 void addToLibrary(const UUID& object, UUID library_object);
143 bool assignToModel(UUID id, Model& model);
148 void removeFromLibrary(const Buffer<UUID>& object);
153 void removeFromLibrary(const UUID& object);
164 void saveToArchiveFile(const Buffer<UUID>& ids, File file);
180 void saveImagesToFolder(const Buffer<UUID>& ids, File folder);
185 void addLayer(Model& model);
190 std::function<bool(UUID, Model&)> getModelCallback();
210 protected:
215 void updateFromArchive(const UUID& file);
220 void updateFromArchive(const File& file);
227 bool writeToLibrary(const UUID& object_to_write, UUID library_id);
228 signals:
233 void modelAdded(UUID id);
239 protected:
248 };
249}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core class where all Design Objects including models, materials, and geometries are stored.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
void saveAllImagesToFolder(File folder)
Saves all library model images to the specified folder.
void pullFromArchiveFile(File file)
Imports library models from an archive file.
bool assignToModel(UUID id, Model &model)
Assigns a library model to an existing scene model.
Model findObject(const UUID &id)
Finds and returns a Model object for the given library ID.
File m_archive_path
The root folder containing library archives.
void saveToArchiveFile(const Buffer< UUID > &ids, File file)
Saves specific library models to an archive file.
void modelRemoved(UUID id)
Emitted when a model is removed from the library.
void removeFromLibrary(const Buffer< UUID > &object)
Removes multiple models from the library.
uint04 modelCount() const
Returns the total number of models in the library.
void updateFromArchive()
Reloads the library from the archive folder on disk.
void removeFromLibrary(const UUID &object)
Removes a single model from the library.
void recomputeObject(UUID)
Recomputes the cached data for a single library object.
LibraryManager(QTModelManager *manager, const File &library_folder)
Constructs a LibraryManager that loads models from the given folder.
QTModelManager * m_manager
The model manager providing scene data.
void updateFromArchive(const UUID &file)
Reloads a single library entry from its archive by UUID.
TranslatedString getSearchTerms(const UUID &id) const
Returns the search terms associated with the given library model.
Dictionary< UUID, TranslatedString > m_names
Maps model UUIDs to display names.
String getType(const UUID &id) const
Returns the type string for the given library model.
void modelAdded(UUID id)
Emitted when a model is added to the library.
TranslatedString getName(const UUID &id) const
Returns the display name for the given library model.
void updateFromArchive(const File &file)
Reloads library entries from the specified archive file.
Buffer< UUID > m_ids
All model UUIDs in the library.
Buffer< TranslatedString > getCategories() const
Returns all unique category names across library models.
Buffer< UUID > getIDsByCategory(const TranslatedString &category)
Returns all model UUIDs belonging to the given category.
void recomputeAll()
Recomputes the cached data for all library objects.
String getIcon(const UUID &id) const
Returns the icon name for the given library model.
Buffer< UUID > getIDs() const
Returns all model UUIDs in the library.
void centerModel(Model &model)
Centers the given model at the origin.
Dictionary< UUID, String > m_types
Maps model UUIDs to type strings.
DesignObjectLookup m_library_lookup
Lookup table for library design objects.
void saveImagesToFolder(const Buffer< UUID > &ids, File folder)
Saves images for specific library models to the specified folder.
Dictionary< UUID, TranslatedString > m_categories
Maps model UUIDs to category names.
void recomputeObjects(const Buffer< UUID > &ids)
Recomputes the cached data for multiple library objects.
QTModelManager * manager()
Returns the model manager backing this library.
Dictionary< UUID, TranslatedString > m_search_terms
Maps model UUIDs to search terms.
std::function< bool(UUID, Model &)> getModelCallback()
Returns a callback function for resolving library models by UUID.
void saveToArchiveFile(File file)
Saves the entire library to an archive file.
bool hasID(const UUID &id) const
Returns whether the library contains a model with the given ID.
bool writeToLibrary(const UUID &object_to_write, UUID library_id)
Writes a scene object into the library storage.
void addToLibrary(const UUID &object, UUID library_object)
Adds an existing scene object to the library under the given library ID.
Buffer< String > getTypes() const
Returns all unique type strings across library models.
void addLayer(Model &model)
Adds a layer to the given model from the library.
A core class that represents a node on model hierarchy.
Definition Model.h:292
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...