NDEVR
API Documentation
SceneTreeModelDelegate.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: SceneTree
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/UUID.h>
35#include <NDEVR/Dictionary.h>
36#include <NDEVR/SoftwareService.h>
37#include <QItemDelegate>
38 class QPropertyAnimation;
39namespace NDEVR
40{
41 class SceneTree;
44 class Button;
46 class UUID;
47 class QCustomLabel;
53 {
54 public:
61 virtual void setTreeWidgetsForSelection(const UUID& id, Buffer<QWidget*>& widgets, SceneTree* tree) = 0;
66 virtual UUID id() const = 0;
67 };
68
71 class SceneTreeModelDelegate : public QItemDelegate, public SoftwareServiceManager
72 {
73 Q_OBJECT
74 Q_PROPERTY(double selected_size READ selectedSize WRITE setSelectedSize)
75 public:
82 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
83 void drawDecoration(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, const QPixmap& pixmap) const override;
84 void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
85 void setEditorData(QWidget* editor, const QModelIndex& index) const override;
86 bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override;
87 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
98 UUID selected() const { return m_selected; }
103 static NDEVR_API void AddWidgetCallback(CustomTreeWidgets* delegate);
108 static NDEVR_API void RemoveWidgetCallback(const UUID& id);
114 void selectAllBetween(QModelIndex a, QModelIndex b);
115 protected:
122 public slots:
127 void indexSelected(const QModelIndex& index);
128 public:
133 fltp08 selectedSize() const { return m_grow_size; }
144 protected:
147 QModelIndex m_last_index;
149 QPropertyAnimation* m_grow_animation;
150 QPropertyAnimation* m_shrink_animation;
152 QWidget* m_button_popup;
155 Button* m_properties = nullptr;
156 Button* m_zoom_to = nullptr;
159#if NDEVR_VIEWPORT
161#endif
162 UUID m_selected = Constant<UUID>::Invalid;
163 UUID m_last_selected = Constant<UUID>::Invalid;
164 UUID m_current_model = Constant<UUID>::Invalid;
165 UUID m_last_model = Constant<UUID>::Invalid;
167 };
168}
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
Sets up a button to be a combobox with the various snap locations of a camera.
Allows for modification or addition of the widgets shown when an object is selected by the user in th...
virtual UUID id() const =0
Retrieves the unique identifier for this widget provider.
virtual void setTreeWidgetsForSelection(const UUID &id, Buffer< QWidget * > &widgets, SceneTree *tree)=0
Populates the widget list shown when an object is selected in the tree view.
A class for easily showing or hiding a Model in 3D space.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Filters and sorts Models from a ModelManager for views such as in a table or in a tree view.
Displays translated text.
Button * m_context_menu
Button for opening the context menu.
fltp08 m_grow_size
The current animated grow size for the selection row.
QWidget * m_button_popup
The popup widget containing action buttons.
int selectionBoxHeight() const
Calculates the height of the selection box for the selected item.
static void AddWidgetCallback(CustomTreeWidgets *delegate)
Registers a custom tree widget callback.
QPropertyAnimation * m_grow_animation
Animation for expanding the selection row.
SceneTreeModelDelegate(ProxyModelViewFilter *manager, SceneTree *parent)
Constructs a scene tree model delegate.
UUID m_selected
UUID of the currently selected object.
fltp08 selectedSize() const
Retrieves the current animated selection size.
QCustomLabel * m_property_name
Label showing the property name.
UUID m_last_selected
UUID of the previously selected object.
QPropertyAnimation * m_shrink_animation
Animation for shrinking the previously selected row.
void selectAllBetween(QModelIndex a, QModelIndex b)
Selects all items between two model indices.
CameraLocationCombo * m_zoom_combo
Combo for camera zoom presets.
Button * m_save_button
Button for saving the selected object.
SceneTree * m_parent
The parent scene tree widget.
UUID m_last_model
UUID of the last painted model.
UUID m_current_model
UUID of the model being painted.
void setSelectedSize(fltp08 o)
Sets the animated selection size.
Buffer< QWidget * > m_last_widgets
Widgets from the last selection popup.
QModelIndex m_last_index
The last selected model index.
DesignObjectVisibleButton * m_visible
Button for toggling object visibility.
Buffer< QWidget * > defaultWidgets(UUID selected)
Creates the default set of action widgets for a selected object.
QWidget * setupPopup(UUID selected)
Creates and returns the popup widget displayed when an item is selected.
Button * m_properties
Button for opening the properties dialog.
ProxyModelViewFilter * m_view
The proxy filter model for the tree.
Button * m_zoom_to
Button for zooming to the selected object.
UUID selected() const
Retrieves the UUID of the currently selected object.
static Dictionary< UUID, CustomTreeWidgets * > s_custom_widget_callbacks
Registered custom widget providers.
void indexSelected(const QModelIndex &index)
Handles selection of an index in the tree.
static void RemoveWidgetCallback(const UUID &id)
Removes a custom tree widget callback.
Shows all objects in a QTModelManager in a tree hierarchy view that allows for user interaction.
Definition SceneTree.h:54
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.
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.
double fltp08
Defines an alias representing an 8 byte floating-point number.