NDEVR
API Documentation
ModelTileTable.h
1#pragma once
2#include <NDEVR/DesignPropertyTable.h>
3#include <NDEVR/ModelTileGroup.h>
4#include <NDEVR/QTTools.h>
5#include <NDEVR/QTModelManager.h>
6#include <NDEVR/QTDesignObject.h>
7#include <NDEVR/ShowPropertiesSettings.h>
8namespace NDEVR
9{
15 {
16 public:
21 ModelTileTable(QWidget* parent = nullptr)
22 : DesignPropertyTable(parent)
23 {
24 init();
25 }
26
31 ModelTileTable(const DynamicPointer<QTDesignObject>& target, QWidget* parent = nullptr)
32 : DesignPropertyTable(target->manager(), parent)
33 , m_object_parent(target)
34 {
35 init();
36 setTarget(target);
37 }
38
43 {
44 m_object_parent = target;
45 if (target.isNull())
46 return;
47 Model model = target->getAs<Model>();
49 setModels(desc);
50 }
51
54 void init()
55 {
56 setWindowTitle(_tqs("Symbol"));
57 addColumn(NDPO::icon, false);
58 addColumn(NDPO::name, true);
60
61 setAddedFilter([this](const Model& model)->bool
62 {
63 if (!m_object_parent.isNull())
64 {
65 Model parent = model.getParent();
66 if (!parent.isValid() || parent.get<NDPO::guid>() != m_object_parent->uuid())
67 return false;
68 }
69 return model.is<NDPN::type>(ModelTileGroup::TypeName());
70 });
71 setEditable(true);
72 m_table_view->sortByColumn(0, Qt::SortOrder::DescendingOrder);
73 addNewButton([this](Button* b)
74 {
75 if (!m_object_parent.isNull())
76 {
77 WLock lock = m_object_parent->manager()->writeLock();
78 ModelTileGroup tile_group(m_object_parent->getAs<Model>().createChild());
79 m_object_parent->manager()->addModel(tile_group);
80 ShowPropertiesSettings settings(tile_group.get<NDPO::guid>(), b);
82 m_object_parent->manager()->ShowProperties(settings);
83 }
84 });
85 }
87 };
88}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
constexpr decltype(auto) get(t_property_type property) const
Retrieves a property value from the database, cast to the requested type.
bool isValid() const
Checks whether this design object has a valid index into the database.
bool is(t_property_type property, const StringView &value) const
Checks whether a string property matches the given StringView value.
A definition of data that is logically stored in the Model hierarchy.
DesignPropertyTableView * m_table_view
The table view displaying design object properties.
void setEditable(bool editable)
Sets whether the entire table is editable.
uint04 addColumn(NDPO property, bool is_editable=true)
Adds a column displaying the given NDPO property.
void setAddedFilter(const std::function< bool(const Model &)> &callback)
Sets a custom filter callback applied when objects are added.
Button * addNewButton(std::function< void(Button *)> callback, const TranslatedString &new_title=_t("Add New"), const StringView &add_icon="plus")
Adds an "Add New" button to the bottom button bar.
DesignPropertyTable(QWidget *parent=nullptr)
Constructs a DesignPropertyTable without a model manager.
void setModels(const Buffer< Model > &models)
Sets the table contents from a buffer of Models.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
A Model subclass that manages tiling (repeating) a source model along a path or surface.
static constexpr StringView TypeName()
Returns the type name identifier for this model type.
void setTarget(const DynamicPointer< QTDesignObject > &target)
Sets the target design object and populates the table with its tile group descendants.
void init()
Initializes columns, filters, sorting, and the new-item button.
DynamicPointer< QTDesignObject > m_object_parent
The parent design object whose tile group children are displayed.
ModelTileTable(QWidget *parent=nullptr)
Constructs the tile table with no initial target.
ModelTileTable(const DynamicPointer< QTDesignObject > &target, QWidget *parent=nullptr)
Constructs the tile table bound to the given design object.
A core class that represents a node on model hierarchy.
Definition Model.h:292
Model getParent() const
Returns the parent model of this model.
Model createChild()
Creates a new child model and appends it to this model's child list.
ModelBuffer getDescendantsByType(const StringView &type, uint04 max_count=Constant< uint04 >::Max) const
Recursively searches all descendants for models matching the given type.
Used to lock a particular variable for writing.
Definition RWLock.h:272
The primary namespace for the NDEVR SDK.
@ type
The type identifier string for this model node.
Definition Model.h:58
@ guid
A 128-bit globally unique identifier for the object.
@ name
The display name of the object.
@ icon
Icon identifier for the object.
@ spacial_visible
Whether the object is visible in the 3D spatial view.
@ e_object_creation
Dialog for creating a new object.
Stores settings for setting up and displaying a DesignObjectDialog such as whether the dialog is part...
void setupForStyle(DesignDialogStyle style)
Configures the button titles and icons based on the given dialog style.