Slicer
5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
|
#include <Libs/MRML/Widgets/qMRMLSceneModel.h>
Public Types | |
enum | ItemDataRole { UIDRole = Qt::UserRole + 1, PointerRole, ExtraItemsRole, VisibilityRole, LastRole } |
enum | NodeTypes { NoNodes = 0, AllNodes, OnlyVisibleNodes } |
typedef QStandardItemModel | Superclass |
Properties | |
int | checkableColumn |
int | extraItemColumn |
int | idColumn |
bool | lazyUpdate |
NodeTypes | listenNodeModifiedEvent |
int | nameColumn |
int | toolTipNameColumn |
int | visibilityColumn |
Signals | |
void | aboutToReparentByDragAndDrop (vtkMRMLNode *node, vtkMRMLNode *newParent) |
void | reparentedByDragAndDrop (vtkMRMLNode *node, vtkMRMLNode *newParent) |
void | sceneAboutToBeUpdated () |
This signal is sent when the scene is about to be updated. More... | |
void | sceneUpdated () |
This signal is sent after the scene is updated. More... | |
Public Member Functions | |
virtual bool | canBeAChild (vtkMRMLNode *node) const |
fast function that only check the type of the node to know if it can be a child. More... | |
virtual bool | canBeAParent (vtkMRMLNode *node) const |
int | checkableColumn () const |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
int | extraItemColumn () const |
int | idColumn () const |
QModelIndexList | indexes (vtkMRMLNode *node) const |
QModelIndex | indexFromNode (vtkMRMLNode *node, int column=0) const |
bool | isAffiliatedNode (vtkMRMLNode *nodeA, vtkMRMLNode *nodeB) const |
bool | isParentNode (vtkMRMLNode *child, vtkMRMLNode *parent) const |
QStandardItem * | itemFromNode (vtkMRMLNode *node, int column=0) const |
bool | lazyUpdate () const |
NodeTypes | listenNodeModifiedEvent () const |
QMimeData * | mimeData (const QModelIndexList &indexes) const override |
vtkMRMLNode * | mrmlNodeFromIndex (const QModelIndex &nodeIndex) const |
vtkMRMLNode * | mrmlNodeFromItem (QStandardItem *nodeItem) const |
Q_INVOKABLE vtkMRMLScene * | mrmlScene () const |
QModelIndex | mrmlSceneIndex () const |
invalid until a valid scene is set More... | |
QStandardItem * | mrmlSceneItem () const |
0 until a valid scene is set More... | |
int | nameColumn () const |
virtual int | nodeIndex (vtkMRMLNode *node) const |
virtual void | observeNode (vtkMRMLNode *node) |
virtual vtkMRMLNode * | parentNode (vtkMRMLNode *node) const |
QStringList | postItems (QStandardItem *parent) const |
QStringList | preItems (QStandardItem *parent) const |
qMRMLSceneModel (QObject *parent=nullptr) | |
virtual bool | reparent (vtkMRMLNode *node, vtkMRMLNode *newParent) |
void | setCheckableColumn (int column) |
void | setExtraItemColumn (int column) |
void | setIDColumn (int column) |
void | setLazyUpdate (bool lazy) |
void | setListenNodeModifiedEvent (NodeTypes nodesToListen) |
virtual Q_INVOKABLE void | setMRMLScene (vtkMRMLScene *scene) |
0 by default More... | |
void | setNameColumn (int column) |
void | setPostItems (const QStringList &extraItems, QStandardItem *parent) |
void | setPreItems (const QStringList &extraItems, QStandardItem *parent) |
void | setToolTipNameColumn (int column) |
void | setVisibilityColumn (int column) |
Qt::DropActions | supportedDropActions () const override |
int | toolTipNameColumn () const |
int | visibilityColumn () const |
~qMRMLSceneModel () override | |
Protected Slots | |
virtual void | delayedItemChanged () |
virtual void | onItemChanged (QStandardItem *item) |
void | onMRMLNodeIDChanged (vtkObject *node, void *callData) |
void | onMRMLNodeModified (vtkObject *node) |
virtual void | onMRMLSceneAboutToBeClosed (vtkMRMLScene *scene) |
virtual void | onMRMLSceneAboutToBeImported (vtkMRMLScene *scene) |
virtual void | onMRMLSceneClosed (vtkMRMLScene *scene) |
void | onMRMLSceneDeleted (vtkMRMLScene *scene) |
virtual void | onMRMLSceneEndBatchProcess (vtkMRMLScene *scene) |
virtual void | onMRMLSceneImported (vtkMRMLScene *scene) |
virtual void | onMRMLSceneNodeAboutToBeAdded (vtkMRMLScene *scene, vtkMRMLNode *node) |
virtual void | onMRMLSceneNodeAboutToBeRemoved (vtkMRMLScene *scene, vtkMRMLNode *node) |
virtual void | onMRMLSceneNodeAdded (vtkMRMLScene *scene, vtkMRMLNode *node) |
virtual void | onMRMLSceneNodeRemoved (vtkMRMLScene *scene, vtkMRMLNode *node) |
virtual void | onMRMLSceneStartBatchProcess (vtkMRMLScene *scene) |
void | updateColumnCount () |
Protected Member Functions | |
virtual QStandardItem * | insertNode (vtkMRMLNode *node) |
virtual QStandardItem * | insertNode (vtkMRMLNode *node, QStandardItem *parent, int row=-1) |
virtual bool | isANode (const QStandardItem *item) const |
virtual int | maxColumnId () const |
Must be reimplemented in subclasses that add new column types. More... | |
virtual QFlags< Qt::ItemFlag > | nodeFlags (vtkMRMLNode *node, int column) const |
virtual void | populateScene () |
qMRMLSceneModel (qMRMLSceneModelPrivate *pimpl, QObject *parent=nullptr) | |
virtual void | updateItemDataFromNode (QStandardItem *item, vtkMRMLNode *node, int column) |
virtual void | updateItemFromNode (QStandardItem *item, vtkMRMLNode *node, int column) |
virtual void | updateNodeFromItem (vtkMRMLNode *node, QStandardItem *item) |
virtual void | updateNodeFromItemData (vtkMRMLNode *node, QStandardItem *item) |
void | updateNodeItems () |
You shouldn't need to call this function. More... | |
void | updateNodeItems (vtkMRMLNode *node, const QString &uid) |
Update the items associated with the node and uid. More... | |
virtual void | updateScene () |
Static Protected Member Functions | |
static void | onMRMLSceneEvent (vtkObject *vtk_obj, unsigned long event, void *client_data, void *call_data) |
Protected Attributes | |
QScopedPointer< qMRMLSceneModelPrivate > | d_ptr |
qMRMLSceneModel has at least 1 column with the scene as a top level item. See below an example of model when nameColumn = 0 (default) and idColumn = 1 with 1 postItem ("Add new node"):
/// Column 0 Column 1 /// /// - Scene /// |- ViewNode vtkMRMLViewNode1 /// |- CameraNode vtkMRMLCameraNode1 /// ... /// |- my_volume.nrrd vtkMRMLScalarVolumeNode1 /// |- Add new node ///
More columns can be added by setting the column index of the different columns: name, id, checkable, visibility, toolTip, extraItem and the ones defined in subclasses. Subclasses must reimplement maxColumnId if they add new column properties
Definition at line 57 of file qMRMLSceneModel.h.
typedef QStandardItemModel qMRMLSceneModel::Superclass |
Definition at line 97 of file qMRMLSceneModel.h.
Definition at line 107 of file qMRMLSceneModel.h.
Enumerator | |
---|---|
NoNodes | |
AllNodes | |
OnlyVisibleNodes |
Definition at line 101 of file qMRMLSceneModel.h.
|
readwrite |
Control in which column vtkMRMLNode::Selected are displayed (Qt::CheckStateRole). A value of -1 hides it. Hidden by default (value of -1).
Definition at line 86 of file qMRMLSceneModel.h.
|
readwrite |
Control in which column the extra items are displayed A value of -1 hides it (not tested). 0 by default
Definition at line 95 of file qMRMLSceneModel.h.
|
readwrite |
Control in which column vtkMRMLNode IDs are displayed (Qt::DisplayRole). A value of -1 hides it. Hidden by default (value of -1)
Definition at line 83 of file qMRMLSceneModel.h.
|
readwrite |
Control whether the model actively listens to the scene. If LazyUpdate is true, the model ignores added node events when the scene is importing/restoring, but synchronize with the scene once its imported/restored.
Definition at line 75 of file qMRMLSceneModel.h.
|
readwrite |
This property controls whether to observe or not the modified event of the node and update the node item data accordingly. It can be useful when the modified property is displayed (name, id, visibility...) OnlyVisibleNodes by default
Definition at line 69 of file qMRMLSceneModel.h.
|
readwrite |
Control in which column vtkMRMLNode names are displayed (Qt::DisplayRole). A value of -1 hides it. First column (0) by default. If no property is set in a column, nothing is displayed.
Definition at line 80 of file qMRMLSceneModel.h.
|
readwrite |
Control in which column tooltips are displayed (Qt::ToolTipRole). A value of -1 hides it. Hidden by default (value of -1).
Definition at line 92 of file qMRMLSceneModel.h.
|
readwrite |
Control in which column vtkMRMLNode::Visibility are displayed (Qt::DecorationRole). A value of -1 hides it. Hidden by default (value of -1).
Definition at line 89 of file qMRMLSceneModel.h.
qMRMLSceneModel::qMRMLSceneModel | ( | QObject * | parent = nullptr | ) |
|
override |
|
protected |
|
signal |
This signal is sent when a user is about to reparent a Node by a drag and drop
|
virtual |
fast function that only check the type of the node to know if it can be a child.
Reimplemented in qMRMLSceneDisplayableModel, qMRMLSceneHierarchyModel, and qMRMLSceneTransformModel.
|
virtual |
Must be reimplemented in derived classes Returns false in qMRMLSceneModel
Reimplemented in qMRMLSceneAnnotationModel, qMRMLSceneDisplayableModel, qMRMLSceneHierarchyModel, and qMRMLSceneTransformModel.
int qMRMLSceneModel::checkableColumn | ( | ) | const |
|
protectedvirtualslot |
|
override |
int qMRMLSceneModel::extraItemColumn | ( | ) | const |
int qMRMLSceneModel::idColumn | ( | ) | const |
QModelIndexList qMRMLSceneModel::indexes | ( | vtkMRMLNode * | node | ) | const |
QModelIndex qMRMLSceneModel::indexFromNode | ( | vtkMRMLNode * | node, |
int | column = 0 |
||
) | const |
|
protectedvirtual |
Reimplemented in qMRMLSceneCategoryModel.
|
protectedvirtual |
bool qMRMLSceneModel::isAffiliatedNode | ( | vtkMRMLNode * | nodeA, |
vtkMRMLNode * | nodeB | ||
) | const |
Utility method that returns true if 2 nodes are child/parent for each other. It can be grandchild, great grand child...
|
protectedvirtual |
Reimplemented in qMRMLSceneCategoryModel.
bool qMRMLSceneModel::isParentNode | ( | vtkMRMLNode * | child, |
vtkMRMLNode * | parent | ||
) | const |
Utility method that returns true if child has parent as parent, grandparent, great grandparent etc...
QStandardItem* qMRMLSceneModel::itemFromNode | ( | vtkMRMLNode * | node, |
int | column = 0 |
||
) | const |
bool qMRMLSceneModel::lazyUpdate | ( | ) | const |
NodeTypes qMRMLSceneModel::listenNodeModifiedEvent | ( | ) | const |
Get the types of nodes that are observed.
|
protectedvirtual |
Must be reimplemented in subclasses that add new column types.
Reimplemented in qMRMLSceneAnnotationModel, qMRMLSceneDisplayableModel, and qMRMLSceneHierarchyModel.
|
override |
|
inline |
Return the vtkMRMLNode associated to the node index. 0 if the node index is not a MRML node (i.e. vtkMRMLScene, extra item...)
Definition at line 341 of file qMRMLSceneModel.h.
vtkMRMLNode* qMRMLSceneModel::mrmlNodeFromItem | ( | QStandardItem * | nodeItem | ) | const |
Q_INVOKABLE vtkMRMLScene* qMRMLSceneModel::mrmlScene | ( | ) | const |
QModelIndex qMRMLSceneModel::mrmlSceneIndex | ( | ) | const |
invalid until a valid scene is set
QStandardItem* qMRMLSceneModel::mrmlSceneItem | ( | ) | const |
0 until a valid scene is set
int qMRMLSceneModel::nameColumn | ( | ) | const |
|
protectedvirtual |
Reimplemented in qMRMLSceneAnnotationModel, qMRMLSceneDisplayableModel, and qMRMLSceneHierarchyModel.
|
virtual |
Returns the row model index relative to its parent node independently of any filtering or proxy model. Must be reimplemented in derived classes
Reimplemented in qMRMLSceneHierarchyModel.
|
virtual |
Observe node and update item when the node is modified.
Reimplemented in qMRMLSceneDisplayableModel, and qMRMLSceneHierarchyModel.
|
protectedvirtualslot |
|
protectedslot |
The node has its ID changed. The scene model needs to update the UIDRole associated with the node in order to keep being in sync.
|
protectedslot |
|
protectedvirtualslot |
|
protectedvirtualslot |
|
protectedvirtualslot |
|
protectedslot |
|
protectedvirtualslot |
|
staticprotected |
|
protectedvirtualslot |
|
protectedvirtualslot |
|
protectedvirtualslot |
|
protectedvirtualslot |
|
protectedvirtualslot |
|
protectedvirtualslot |
|
virtual |
Returns the parent node of the node, 0 otherwise (the parent is the scene). Must be reimplemented in derived classes. If reimplemented, you might have to reimplement nodeIndex() as well. Returns 0 by default.
Reimplemented in qMRMLSceneAnnotationModel, qMRMLSceneDisplayableModel, qMRMLSceneHierarchyModel, and qMRMLSceneTransformModel.
|
protectedvirtual |
QStringList qMRMLSceneModel::postItems | ( | QStandardItem * | parent | ) | const |
QStringList qMRMLSceneModel::preItems | ( | QStandardItem * | parent | ) | const |
|
virtual |
Must be reimplemented in derived classes. Doesn't reparent and returns false by qMRMLSceneModel
Reimplemented in qMRMLSceneHierarchyModel, and qMRMLSceneTransformModel.
|
signal |
This signal is sent after a user dragged and dropped a Node in the qMRMLTreeView
|
signal |
This signal is sent when the scene is about to be updated.
|
signal |
This signal is sent after the scene is updated.
void qMRMLSceneModel::setCheckableColumn | ( | int | column | ) |
void qMRMLSceneModel::setExtraItemColumn | ( | int | column | ) |
void qMRMLSceneModel::setIDColumn | ( | int | column | ) |
void qMRMLSceneModel::setLazyUpdate | ( | bool | lazy | ) |
void qMRMLSceneModel::setListenNodeModifiedEvent | ( | NodeTypes | nodesToListen | ) |
Option that activates the expensive listening of the vtkMRMLNode Modified events. When listening, the signal itemDataChanged() is fired when a vtkMRMLNode is modified.
|
virtual |
0 by default
void qMRMLSceneModel::setNameColumn | ( | int | column | ) |
void qMRMLSceneModel::setPostItems | ( | const QStringList & | extraItems, |
QStandardItem * | parent | ||
) |
Extra items that are appended to the node list Warning, setPostItems() resets the model, the currently selected item is lost
void qMRMLSceneModel::setPreItems | ( | const QStringList & | extraItems, |
QStandardItem * | parent | ||
) |
Extra items that are prepended to the node list Warning, setPreItems() resets the model, the currently selected item is lost
void qMRMLSceneModel::setToolTipNameColumn | ( | int | column | ) |
void qMRMLSceneModel::setVisibilityColumn | ( | int | column | ) |
|
override |
Doesn't support drop actions, scene model subclasses can support drop actions though.
int qMRMLSceneModel::toolTipNameColumn | ( | ) | const |
|
protectedslot |
Recompute the number of columns in the model. To be called when a XXXColumn is set. Needs maxColumnId() to be reimplemented in subclasses
|
protectedvirtual |
To reimplement if you want custom display of the QStandardItem from the MRML node. Example:
Reimplemented in qMRMLSceneAnnotationModel, qMRMLSceneDisplayableModel, and qMRMLSceneHierarchyModel.
|
protectedvirtual |
Generic function that updates the item data and flags from the node. You probably want to reimplement updateItemDataFromNode() instead.
Reimplemented in qMRMLSceneCategoryModel, and qMRMLSceneColorTableModel.
|
protectedvirtual |
Generic function that updates the node from the item data and flags. You probably want to reimplement updateNodeFromItemData() instead.
Reimplemented in qMRMLSceneCategoryModel.
|
protectedvirtual |
To reimplement if you want to propagate user changes on QStandardItem into the MRML node. Example: void MySceneModel::updateNodeFromItemData(vtkMRMLNode* node, QStandardItem* item) if (column == 3) { node->SetFoo(item->text()); return; } this->Superclass::updateNodeFromItemData(node, item); }
Reimplemented in qMRMLSceneAnnotationModel, qMRMLSceneDisplayableModel, and qMRMLSceneHierarchyModel.
|
protected |
You shouldn't need to call this function.
|
protected |
Update the items associated with the node and uid.
|
protectedvirtual |
int qMRMLSceneModel::visibilityColumn | ( | ) | const |
|
protected |
Definition at line 330 of file qMRMLSceneModel.h.