NDEVR
API Documentation
LayerCombo.h
1#pragma once
2#include <NDEVR/QCustomComboBox.h>
3#include <QAbstractItemModel>
4namespace NDEVR
5{
10 {
11 QIcon icon;
12 QString name;
13 QString description;
14 RGBColor color = Constant<RGBColor>::Invalid;
15 bool is_visible = false;
16 bool is_selected = false;
17 };
18 class QTModelManager;
22 class LayerModel : public QAbstractItemModel
23 {
24 Q_OBJECT
25 public:
38 QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
44 QModelIndex parent(const QModelIndex& child) const override;
50 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
56 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
62 bool hasChildren(const QModelIndex& parent = QModelIndex()) const override;
68 QVector<int> cacheObject(UUID id);
73 const Buffer<UUID>& layers() const { return m_layers; }
80 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
85 QTModelManager* manager() const { return m_manager; }
93 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
94 protected slots:
109 protected:
113 };
114
118 {
119 public:
124 LayerCombo(QWidget* parent = nullptr);
130 LayerCombo(QTModelManager* manager, QWidget* parent = nullptr);
155 protected:
156 LayerModel* m_model = nullptr;
157 };
158}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
QTModelManager * manager() const
Returns the model manager backing this combo box.
void setManager(QTModelManager *manager)
Sets the model manager used to populate the layer list.
void setSelected(UUID id)
Sets the currently selected layer by UUID.
LayerCombo(QWidget *parent=nullptr)
Constructs a LayerCombo with an optional parent widget.
LayerCombo(QTModelManager *manager, QWidget *parent=nullptr)
Constructs a LayerCombo with a model manager and optional parent widget.
void clearSelected()
Clears the current selection so no layer is selected.
UUID currentSelection() const
Returns the UUID of the currently selected layer.
LayerModel * m_model
The layer data model driving the combo box.
Definition LayerCombo.h:156
Used for showing Layers in a table using the QAbstractItemModel interface.
Definition LayerCombo.h:23
QTModelManager * m_manager
The model manager providing layer data.
Definition LayerCombo.h:111
Buffer< UUID > m_layers
The list of layer UUIDs in this model.
Definition LayerCombo.h:110
QVector< int > cacheObject(UUID id)
Updates the cached display data for the given layer and returns changed roles.
const Buffer< UUID > & layers() const
Returns the list of layer UUIDs managed by this model.
Definition LayerCombo.h:73
void layerUpdatedSlot(Buffer< UUID > objects)
Slot called when existing layers are updated.
QModelIndex parent(const QModelIndex &child) const override
Returns the parent index of the given child index.
LayerModel(QTModelManager *manager)
Constructs a LayerModel backed by the given model manager.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the model index for the given row, column, and parent.
void onClearAllSlot()
Slot called when all layers are cleared from the scene.
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
Returns whether the given parent has any children.
Dictionary< UUID, LayerCacheObject > m_layer_cache
Cached display data for each layer.
Definition LayerCombo.h:112
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
void layerAddedSlot(Buffer< UUID > layer)
Slot called when new layers are added to the scene.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets data for the given index and role.
QTModelManager * manager() const
Returns the model manager backing this layer model.
Definition LayerCombo.h:85
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the display data for the given index and role.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns for the given parent.
QCustomComboBox(QWidget *parent=nullptr)
Constructs a QCustomComboBox with the given parent widget.
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
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.
Stores cached information for the LayerModel.
Definition LayerCombo.h:10
bool is_selected
Whether the layer is currently selected.
Definition LayerCombo.h:16
QIcon icon
The icon representing the layer.
Definition LayerCombo.h:11
bool is_visible
Whether the layer is currently visible.
Definition LayerCombo.h:15
QString name
The display name of the layer.
Definition LayerCombo.h:12
RGBColor color
The color associated with the layer.
Definition LayerCombo.h:14
QString description
A brief description of the layer.
Definition LayerCombo.h:13