NDEVR
API Documentation
DesignProperties.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/DesignObjectBase.h>
4namespace NDEVR
5{
12 class NDEVR_DESIGN_API DesignInfo
13 {
14 public:
15 template<class t_property_enum>
16 friend class PropertyInterface;
17 template<class t_property_enum>
18 friend class PropertyColumnInterface;
24 {
25 e_model = 0x01
26 , e_geometry = 0x02
27 , e_material = 0x04
28 , e_bone = 0x08
29 , e_effect = 0x10
30 , e_layer = 0x20
31 };
32 protected:
33 DesignInfo() = default;
43
53
59 void _setTransform(const Matrix<fltp08>& transform);
60
66 void _setDesignVisible(bool is_visible);
67 protected:
69#ifdef Q_OS_WASM
70 uint04 m_padding = 0;
71#endif
72 uint04 m_index = Constant<uint04>::Invalid;
73 uint04 m_design_index = Constant<uint04>::Invalid;
74 };
75
83 template<class t_property_enum>
85 {
86 public:
93 static TableColumn* column(const DesignInfo* object, t_property_enum property);
94
101 static uint04 index(const DesignInfo* object, t_property_enum property);
102 };
103
111 template<auto t_property>
113 {
114 };
115
123 template<class t_property_enum>
125 {
126 public:
133 static TableColumn* column(const DesignInfo* object, t_property_enum property)
134 {
136 }
137
144 static uint04 index(const DesignInfo* object, t_property_enum property)
145 {
147 }
148
156 template<class t_value_type>
157 static void Set(DesignInfo* object, t_property_enum property, const t_value_type& value)
158 {
159 column(object, property)->set(index(object, property), value);
160 }
161
169 template<t_property_enum t_property, class t_value_type>
170 static void Set(DesignInfo* object, const t_value_type& value)
171 {
172 column(object, t_property)->set(index(object, t_property), value);
173 }
174
182 template<class t_value_type>
183 static decltype(auto) Get(const DesignInfo* object, t_property_enum property)
184 {
185 return column(object, property)->template get<t_value_type>(index(object, property));
186 }
187
195 template<t_property_enum t_property, class t_value_type>
196 static decltype(auto) Get(const DesignInfo* object)
197 {
198 return column(object, t_property)->template get<t_value_type>(index(object, t_property));
199 }
200
207 template<t_property_enum t_property>
208 static decltype(auto) Get(const DesignInfo* object)
209 {
210 return column(object, t_property)->template get<typename PropertySpec<t_property>::type>(index(object, t_property));
211 }
212
221 template<class t_value_type>
222 static bool IsSame(const DesignInfo* object, t_value_type property, const StringView& value)
223 {
224 return column(object, property)->isSame(index(object, property), value);
225 }
226 };
227
278 template<> struct PropertySpec<NDPO::guid> { using type = UUID; };
279 template<> struct PropertySpec<NDPO::library_id> { using type = UUID; };
280 template<> struct PropertySpec<NDPO::design_type> { using type = uint01; };
281 template<> struct PropertySpec<NDPO::creation_time> { using type = Time; };
282 template<> struct PropertySpec<NDPO::modified_time> { using type = Time; };
283 template<> struct PropertySpec<NDPO::asc_modified_time> { using type = Time; };
284 template<> struct PropertySpec<NDPO::desc_modified_time> {using type = Time; };
285 template<> struct PropertySpec<NDPO::geometry_modified_time> { using type = Time; };
286 template<> struct PropertySpec<NDPO::transform> { using type = Matrix<fltp08>; };
287 template<> struct PropertySpec<NDPO::bounding_box> { using type = Bounds<3, fltp08>; };
288 template<> struct PropertySpec<NDPO::name> { using type = StringView; };
289 template<> struct PropertySpec<NDPO::description> { using type = StringView; };
290 template<> struct PropertySpec<NDPO::author> { using type = StringView; };
291 template<> struct PropertySpec<NDPO::creation_software> { using type = StringView; };
292 template<> struct PropertySpec<NDPO::icon> { using type = StringView; };
293 template<> struct PropertySpec<NDPO::file> { using type = StringView; };
294 template<> struct PropertySpec<NDPO::search_terms> { using type = StringView; };
295 template<> struct PropertySpec<NDPO::meta_data> { using type = StringView; };
296 template<> struct PropertySpec<NDPO::category> { using type = StringView; };
297 template<> struct PropertySpec<NDPO::applied_filters> { using type = StringView; };
298 template<> struct PropertySpec<NDPO::untranslated_string_data> { using type = StringView; };
299 template<> struct PropertySpec<NDPO::translated_string_data> { using type = TranslatedString; };
300 template<> struct PropertySpec<NDPO::uncompressed_data> { using type = StringView; };
301 template<> struct PropertySpec<NDPO::compressed_data> { using type = StringView; };
302 template<> struct PropertySpec<NDPO::editable_description> { using type = bool; };
303 template<> struct PropertySpec<NDPO::spacial_visible> { using type = bool; };
304 template<> struct PropertySpec<NDPO::tree_visible> { using type = bool; };
305 template<> struct PropertySpec<NDPO::is_selected> { using type = bool; };
306 template<> struct PropertySpec<NDPO::is_focused> { using type = bool; };
307 template<> struct PropertySpec<NDPO::allow_interactions> { using type = bool; };
308 template<> struct PropertySpec<NDPO::deletion_allowed> { using type = bool; };
309 template<> struct PropertySpec<NDPO::is_deleted> { using type = bool; };
310 template<> struct PropertySpec<NDPO::application_locked> { using type = bool; };
311 template<> struct PropertySpec<NDPO::is_application_owned> { using type = bool; };
312 template<> struct PropertySpec<NDPO::bounds_ignored> { using type = bool; };
313 template<> struct PropertySpec<NDPO::selection_ignored> { using type = bool; };
314 template<> struct PropertySpec<NDPO::is_frozen> { using type = bool; };
315
324 template<>
326 {
327 public:
335 template<class t_value_type>
336 static decltype(auto) Get(const DesignInfo* object, NDPO property)
337 {
338 return column(object, property)->get<t_value_type>(object->m_index);
339 }
340
348 template<NDPO t_property, class t_value_type>
349 static decltype(auto) Get(const DesignInfo* object)
350 {
351 return column(object, t_property)->get<t_value_type>(object->m_index);
352 }
353
364 template<class t_value_type>
365 static void Set(DesignInfo* object, NDPO property, const t_value_type& value)
366 {
367 switch (property)
368 {
370 object->m_base->design_properties[eint01(property)]->set(object->m_index, value);
371 break;
373 object->m_base->design_properties[eint01(property)]->set(object->m_index, value);
374 object->_setDesignVisible(Get<NDPO::spacial_visible, bool>(object));
375 break;
376 case NDPO::transform:
377 object->m_base->design_properties[eint01(property)]->set(object->m_index, value);
378 object->_setTransform(Get<NDPO::transform, Matrix<fltp08>>(object));
379 break;
380 default:
381 object->m_base->design_properties[eint01(property)]->set(object->m_index, value);
382 break;
383 }
384 }
385
396 template<NDPO t_property>
397 static inline void Set(DesignInfo* object, const typename PropertySpec<t_property>::type& value)
398 {
399 static_assert(t_property != NDPO::is_deleted, "cannot directly delete design object");
400 if constexpr (t_property == NDPO::design_type)
401 {
402 object->m_base->design_type[object->m_index] = value;
403 }
404 else if constexpr (t_property == NDPO::guid)
405 {
406 object->m_base->guid[object->m_index] = value;
407 }
408 else if constexpr (t_property == NDPO::modified_time)
409 {
410 object->m_base->modified_time[object->m_index] = rcast<uint08>(value);
411 }
412 else if constexpr (t_property == NDPO::desc_modified_time)
413 {
414 object->m_base->desc_modified_time[object->m_index] = rcast<uint08>(value);
415 }
416 else if constexpr (t_property == NDPO::asc_modified_time)
417 {
418 object->m_base->asc_modified_time[object->m_index] = rcast<uint08>(value);
419 }
420 else if constexpr (t_property == NDPO::name)
421 {
422 object->m_base->name[object->m_index] = value;
423 }
424 else if constexpr (t_property == NDPO::transform)
425 {
426 object->_setTransform(value);
427 lib_assert(IsValid(value), "Tried to set Invalid transform");
428 lib_assert(IsValid(value.invert()), "Tried to set to non-invertable transform");
429 }
430 else if constexpr (t_property == NDPO::bounding_box)
431 {
432 object->m_base->bounding_box[object->m_index] = rcast<Vector<6, fltp08>>(value);
433 }
434 else if constexpr (t_property == NDPO::spacial_visible)
435 {
436 object->_setDesignVisible(value);
437 }
438 else if constexpr (t_property == NDPO::tree_visible)
439 {
440 object->m_base->tree_visible[object->m_index] = value;
441 }
442 else if constexpr (t_property == NDPO::is_deleted)
443 {
444 object->m_base->is_deleted[object->m_index] = value;
445 }
446 else
447 {
448 object->m_base->design_properties[eint01(t_property)]->set(object->m_index, value);
449 }
450 }
451
458 static constexpr TableColumn* column(const DesignInfo* object, NDPO property)
459 {
460 return object->m_base->design_properties[eint01(property)];
461 }
462
470 static bool IsSame(const DesignInfo* object, NDPO property, const StringView& value)
471 {
472 return column(object, property)->isSame(object->m_index, value);
473 }
474
485 template<NDPO t_property>
486 static decltype(auto) Get(const DesignInfo* object)
487 {
488 if constexpr (t_property == NDPO::design_type)
489 return object->m_base->design_type[object->m_index];
490 else if constexpr (t_property == NDPO::guid)
491 return rcast<UUID>(object->m_base->guid[object->m_index]);
492 else if constexpr (t_property == NDPO::modified_time)
493 return rcast<Time>(object->m_base->modified_time[object->m_index]);
494 else if constexpr (t_property == NDPO::asc_modified_time)
495 return rcast<Time>(object->m_base->asc_modified_time[object->m_index]);
496 else if constexpr (t_property == NDPO::desc_modified_time)
497 return rcast<Time>(object->m_base->desc_modified_time[object->m_index]);
498 else if constexpr (t_property == NDPO::name)
499 return object->m_base->name[object->m_index];
500 else if constexpr (t_property == NDPO::transform)
501 return rcast<Matrix<fltp08>>(object->m_base->transform[object->m_index]);
502 else if constexpr (t_property == NDPO::bounding_box)
503 return rcast<Bounds<3, fltp08>>(object->m_base->bounding_box[object->m_index]);
504 else if constexpr (t_property == NDPO::tree_visible)
505 return object->m_base->tree_visible[object->m_index];
506 else if constexpr (t_property == NDPO::spacial_visible)
507 return object->m_base->spacial_visible[object->m_index];
508 else if constexpr (t_property == NDPO::is_deleted)
509 return object->m_base->is_deleted[object->m_index];
510 else
511 return column(object, t_property)->get<typename PropertySpec<t_property>::type>(object->m_index);
512 }
513 };
514 // not a true property, but allows for easy calculated get/set
531 template<> struct PropertySpec<NDPOC::name> { using type = TranslatedString; };
532 template<> struct PropertySpec<NDPOC::description> { using type = TranslatedString; };
533 template<> struct PropertySpec<NDPOC::creation_software> { using type = TranslatedString; };
534 template<> struct PropertySpec<NDPOC::category> { using type = TranslatedString; };
535 template<> struct PropertySpec<NDPOC::search_terms> { using type = TranslatedString; };
536 template<> struct PropertySpec<NDPOC::author> { using type = TranslatedString; };
537
544 template<>
546 {
547 public:
554 static constexpr TableColumn* column(const DesignInfo* object, NDPOC property)
555 {
556 switch (property)
557 {
558 case NDPOC::name:
559 return &object->m_base->name;
561 return object->m_base->design_properties[eint01(NDPO::description)];
563 return object->m_base->design_properties[eint01(NDPO::creation_software)];
564 case NDPOC::category:
565 return object->m_base->design_properties[eint01(NDPO::category)];
567 return object->m_base->design_properties[eint01(NDPO::search_terms)];
568 case NDPOC::author:
569 return object->m_base->design_properties[eint01(NDPO::author)];
570 default:
571 lib_assert(false, "Bad value");
572 return nullptr;
573 }
574 }
575
581 static constexpr uint04 index(const DesignInfo* object, NDPOC)
582 {
583 return object->m_index;
584 }
585 };
586}
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
Base information class for all design objects in the NDEVR property database.
uint04 m_index
Row index of this object within the property database.
DesignInfo(DesignObjectBase *base)
Creates an new design object within the given DesignObjectBase.
uint04 m_design_index
Index of the parent design that owns this object.
DesignInfo(uint04 index, DesignObjectBase *base)
Sets a DesignObject up to be a pointer to an existing object in the database.
void _setDesignVisible(bool is_visible)
Sets the spatial visibility of this design object and propagates the change through the design hierar...
void _setTransform(const Matrix< fltp08 > &transform)
Sets the 4x4 transform matrix for this design object and propagates the change through the design hie...
DesignObjectBase * m_base
Pointer to the owning DesignObjectBase property database.
Provides the underlying data storage for the NDEVR Scene Model hierarchy.
ColumnT< Time > asc_modified_time
Column storing the ascending-order modification timestamp.
ColumnT< String > name
Column storing the display name for each design object.
ColumnT< uint01 > design_type
Column storing the design object type identifier.
ColumnT< Time > desc_modified_time
Column storing the descending-order modification timestamp.
ColumnT< UUID > guid
Column storing the globally unique identifier for each design object.
ColumnT< Time > modified_time
Column storing the last modification timestamp.
ColumnT< bool > is_deleted
Column indicating whether the object has been soft-deleted.
ColumnT< bool > tree_visible
Column indicating whether the object is visible in the scene tree.
TableVectorType< 6, fltp08 > bounding_box
Column storing the axis-aligned bounding box (min XYZ, max XYZ).
ColumnT< Matrix< fltp08 > > transform
Column storing the local transformation matrix.
ColumnT< bool > spacial_visible
Column indicating whether the object is visible in the 3D viewport.
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
static constexpr TableColumn * column(const DesignInfo *object, NDPOC property)
Retrieves the TableColumn pointer for a given NDPOC property.
static constexpr uint04 index(const DesignInfo *object, NDPOC)
Retrieves the row index for a given NDPOC property on the specified design object.
Provides access to the TableColumn and row index for a given property enum value.
static TableColumn * column(const DesignInfo *object, t_property_enum property)
Retrieves the TableColumn pointer for a given property on the specified design object.
static uint04 index(const DesignInfo *object, t_property_enum property)
Retrieves the row index for a given property on the specified design object.
static decltype(auto) Get(const DesignInfo *object, NDPO property)
Gets the value of an NDPO property using a runtime property enum.
static decltype(auto) Get(const DesignInfo *object)
Gets the value of a compile-time NDPO property with the type deduced from PropertySpec.
static void Set(DesignInfo *object, NDPO property, const t_value_type &value)
Sets the value of an NDPO property using a runtime property enum.
static bool IsSame(const DesignInfo *object, NDPO property, const StringView &value)
Checks whether an NDPO property's stored value matches a given string representation.
static constexpr TableColumn * column(const DesignInfo *object, NDPO property)
Retrieves the TableColumn pointer for a given NDPO property.
static decltype(auto) Get(const DesignInfo *object)
Gets the value of a compile-time NDPO property with an explicit value type.
static void Set(DesignInfo *object, const typename PropertySpec< t_property >::type &value)
Sets the value of a compile-time NDPO property with optimized direct-member access.
Typed interface for getting and setting design object properties by enum.
static TableColumn * column(const DesignInfo *object, t_property_enum property)
Retrieves the TableColumn pointer for a given property on the specified design object.
static decltype(auto) Get(const DesignInfo *object, t_property_enum property)
Gets the value of a property from a design object using a runtime property enum.
static void Set(DesignInfo *object, t_property_enum property, const t_value_type &value)
Sets the value of a property on a design object using a runtime property enum.
static decltype(auto) Get(const DesignInfo *object)
Gets the value of a compile-time property, with the type deduced from PropertySpec.
static decltype(auto) Get(const DesignInfo *object)
Gets the value of a compile-time property from a design object with an explicit value type.
static bool IsSame(const DesignInfo *object, t_value_type property, const StringView &value)
Checks whether a property's stored value matches a given string representation.
static void Set(DesignInfo *object, const t_value_type &value)
Sets the value of a compile-time property on a design object.
static uint04 index(const DesignInfo *object, t_property_enum property)
Retrieves the row index for a given property on the specified design object.
The core String View class for the NDEVR API.
Definition StringView.h:58
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Definition TableColumn.h:86
virtual bool isSame(uint04 index, const StringView &value) const =0
Checks whether the stored string at the given row is exactly equal to the given value.
std::enable_if<!ObjectInfo< t_class >::Enum >::type set(uint04 index, const t_class &value)
Sets the value at the given row index from a non-enum type.
void get(uint04 index, Vector< 1, t_class > &vector) const
Retrieves a 1D vector value at the given row index by delegating to the scalar get.
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
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.
static constexpr bool IsValid(const Angle< t_type > &value)
Checks whether the given Angle holds a valid value.
Definition Angle.h:398
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
NDPOC
NDPOC - NDEVR Design Property Calculated: Values calculated then stored in the property database.
@ search_terms
The calculated/translated search terms.
@ author
The calculated/translated author name.
@ description
The calculated/translated description.
@ creation_software
The calculated/translated creation software name.
@ name
The calculated/translated display name.
@ category
The calculated/translated category.
constexpr t_to & rcast(t_from &value)
Casts the given value.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
NDPO
NDPO - NDEVR Design Property Object: Values stored in the property database.
@ search_terms
Additional search terms for finding this object.
@ author
The author or creator of the object.
@ desc_modified_time
Timestamp tracking descending-order modification.
@ deletion_allowed
Whether the user is allowed to delete this object.
@ translated_string_data
Translated string data storage.
@ creation_time
Timestamp when the object was created.
@ is_selected
Whether the object is currently selected.
@ guid
A 128-bit globally unique identifier for the object.
@ editable_description
Whether the user is allowed to modify the description of the object.
@ property_size
Sentinel value representing the total number of properties (always last).
@ tree_visible
Whether the object is visible in the design tree view.
@ modified_time
Timestamp when the object was last modified.
@ selection_ignored
Whether this object is excluded from selection operations.
@ description
The description text of the object.
@ geometry_modified_time
Timestamp when the geometry of the object was last modified.
@ bounding_box
The axis-aligned bounding box of the object in local space.
@ untranslated_string_data
Raw untranslated string data storage.
@ uncompressed_data
Uncompressed binary data storage.
@ applied_filters
Comma-separated list of filter identifiers applied to this object.
@ application_locked
Whether the application has locked this object from editing.
@ file
The source file path associated with this object.
@ library_id
UUID referencing a library item this object was created from.
@ creation_software
The software used to create the object.
@ name
The display name of the object.
@ compressed_data
Compressed binary data storage.
@ is_application_owned
Whether the object is owned and managed by the application.
@ icon
Icon identifier for the object.
@ allow_interactions
Whether user interactions with this object are allowed.
@ category
The category this object belongs to.
@ is_focused
Whether the object currently has focus.
@ bounds_ignored
Whether this object is excluded from bounding box calculations.
@ transform
A 4x4 transform matrix that maps local coordinates into global space.
@ meta_data
General-purpose metadata string for the object.
@ design_type
Bitflag storing what type of object this is (see DesignObjectType).
@ asc_modified_time
Timestamp tracking ascending-order modification.
@ is_frozen
Whether the object is frozen (cannot be modified by the user).
@ is_deleted
Whether the object has been soft-deleted.
@ spacial_visible
Whether the object is visible in the 3D spatial view.
Maps a compile-time property enum value to its corresponding C++ storage type.