Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qMRMLSubjectHierarchyTreeView.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
6 Queen's University, Kingston, ON, Canada. All Rights Reserved.
7
8 See COPYRIGHT.txt
9 or http://www.slicer.org/copyright/copyright.txt for details.
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 This file was originally developed by Csaba Pinter, PerkLab, Queen's University
18 and was supported through the Applied Cancer Research Unit program of Cancer Care
19 Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
20
21==============================================================================*/
22
23#ifndef __qMRMLSubjectHierarchyTreeView_h
24#define __qMRMLSubjectHierarchyTreeView_h
25
26// Qt includes
27#include <QTreeView>
28
29// CTK includes
30#include <ctkVTKObject.h>
31
32// SubjectHierarchy includes
33#include "qSlicerSubjectHierarchyModuleWidgetsExport.h"
34
35class qMRMLSubjectHierarchyTreeViewPrivate;
38class vtkMRMLNode;
39class vtkMRMLScene;
41class vtkIdList;
42
43class Q_SLICER_MODULE_SUBJECTHIERARCHY_WIDGETS_EXPORT qMRMLSubjectHierarchyTreeView : public QTreeView
44{
45 Q_OBJECT
46 QVTK_OBJECT
47
52 Q_PROPERTY(bool showRootItem READ showRootItem WRITE setShowRootItem)
67 Q_PROPERTY(QStringList levelFilter READ levelFilter WRITE setLevelFilter)
68 Q_PROPERTY(QString nameFilter READ nameFilter WRITE setNameFilter)
69 Q_PROPERTY(QStringList nodeTypes READ nodeTypes WRITE setNodeTypes)
76 Q_PROPERTY(QStringList pluginAllowList READ pluginAllowList WRITE setPluginAllowList)
77 Q_PROPERTY(QStringList pluginBlockList READ pluginBlockList WRITE setPluginBlockList)
78
81 Q_PROPERTY(bool noneEnabled READ noneEnabled WRITE setNoneEnabled)
85 Q_PROPERTY(QString noneDisplay READ noneDisplay WRITE setNoneDisplay)
86
97
107
110
111public:
112 typedef QTreeView Superclass;
113 qMRMLSubjectHierarchyTreeView(QWidget *parent=nullptr);
115
116public:
117 Q_INVOKABLE vtkMRMLScene* mrmlScene()const;
118
122
124 Q_INVOKABLE vtkIdType currentItem()const;
126 QList<vtkIdType> currentItems();
129 Q_INVOKABLE void currentItems(vtkIdList* selectedItems);
130
132 virtual vtkMRMLNode* currentNode()const;
133
135 Q_INVOKABLE vtkIdType rootItem()const;
137 bool showRootItem()const;
138
141
144
149 QString attributeValueFilter()const;
150 QString attributeNameFilter()const;
155 Q_INVOKABLE void setAttributeFilter(const QString& attributeName, const QVariant& attributeValue=QVariant());
157 Q_INVOKABLE void removeAttributeFilter();
165 Q_INVOKABLE void addItemAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true);
167 Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, QVariant attributeValue, bool include);
169 Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, bool include);
178 Q_INVOKABLE void addNodeAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true, QString className=QString());
180 Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, QVariant attributeValue, bool include, QString className);
182 Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, bool include);
183
184
186 void setLevelFilter(QStringList &levelFilter);
187 QStringList levelFilter()const;
188
190 void setNameFilter(QString &nameFilter);
191 QString nameFilter()const;
192
194 void setNodeTypes(const QStringList& types);
195 QStringList nodeTypes()const;
196
201 void setBaseName(const QString& baseName, const QString& nodeType = "");
202 QString baseName(const QString& nodeType = "")const;
203
208 Q_INVOKABLE void setNodeTypeLabel(const QString& label, const QString& nodeType);
209 Q_INVOKABLE QString nodeTypeLabel(const QString& nodeType)const;
210
213 void setHideChildNodeTypes(const QStringList& types);
214 QStringList hideChildNodeTypes()const;
215
218
220 Q_INVOKABLE int displayedItemCount()const;
221
226 bool noneEnabled()const;
227 QString noneDisplay()const;
228
230 void setVisibilityColumnVisible(bool visible);
233 void setIdColumnVisible(bool visible);
236 void setColorColumnVisible(bool visible);
239 void setTransformColumnVisible(bool visible);
242 void setDescriptionColumnVisible(bool visible);
244
248
251 QStringList pluginAllowList()const;
254 QStringList pluginBlockList()const;
255
258 Q_INVOKABLE vtkMRMLNode* findFirstNodeByClass(const QString& className)const;
259
260public slots:
262 virtual void setMRMLScene(vtkMRMLScene* scene);
263
265 virtual void setCurrentItem(vtkIdType itemID);
267 virtual void setCurrentItems(QList<vtkIdType> items);
269 virtual void setCurrentItems(vtkIdList* items);
271 virtual void setCurrentNode(vtkMRMLNode* node);
272
274 virtual void setRootItem(vtkIdType itemID);
276 void setShowRootItem(bool show);
277
280
292 virtual void editCurrentItem();
293
303 virtual vtkMRMLNode* addNode(QString nodeType);
304
306 virtual void expandItem(vtkIdType itemID);
308 virtual void collapseItem(vtkIdType itemID);
309
312
318
320 virtual void setMultiSelection(bool multiSelectionOn);
321
325 void setPluginAllowList(QStringList allowlist);
327 void setPluginAllowlist(QStringList allowlist) { this->setPluginAllowList(allowlist); }
331 void setPluginBlockList(QStringList blocklist);
333 void setPluginBlocklist(QStringList blocklist) { this->setPluginBlockList(blocklist); }
336 void disablePlugin(QString plugin);
337
339 void setPluginWhitelist(QStringList allowlist)
340 {
341 qWarning("qMRMLSubjectHierarchyTreeView::setPluginWhitelist is deprecated. Use setPluginAllowlist instead.");
342 this->setPluginAllowlist(allowlist);
343 }
344
345 void setPluginBlacklist(QStringList blocklist)
346 {
347 qWarning("qMRMLSubjectHierarchyTreeView::setPluginBlacklist is deprecated. Use setPluginBlocklist instead.");
348 this->setPluginBlocklist(blocklist);
349 }
350
354 bool showContextMenuHint(bool visibility=false);
355
356 void setHighlightReferencedItems(bool highlightOn);
357 void setContextMenuEnabled(bool enabled);
358 void setEditMenuActionVisible(bool visible);
359 void setSelectRoleSubMenuVisible(bool visible);
360 void setNoneEnabled(bool enable);
361 void setNoneDisplay(const QString& displayName);
362
365
366 void setIncludeItemAttributeNamesFilter(QStringList filter);
367 void setIncludeNodeAttributeNamesFilter(QStringList filter);
368 void setExcludeItemAttributeNamesFilter(QStringList filter);
369 void setExcludeNodeAttributeNamesFilter(QStringList filter);
370 void setAttributeNameFilter(QString& filter);
371 void setAttributeValueFilter(QString& filter);
372
375
376signals:
377 void currentItemChanged(vtkIdType);
380 void currentItemModified(vtkIdType);
381
384
385protected slots:
386 virtual void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
387
389 virtual void onItemExpanded(const QModelIndex &expandedItemIndex);
391 virtual void onItemCollapsed(const QModelIndex &collapsedItemIndex);
392
395 virtual void updateRootItem();
396
398 virtual void onSubjectHierarchyItemModified(vtkObject *caller, void *callData);
400 virtual void onSubjectHierarchyItemTransformModified(vtkObject *caller, void *callData);
401
403 virtual void onMRMLSceneStartClose(vtkObject* sceneObject);
405 virtual void onMRMLSceneEndClose(vtkObject* sceneObject);
407 virtual void onMRMLSceneStartBatchProcess(vtkObject* sceneObject);
409 virtual void onMRMLSceneEndBatchProcess(vtkObject* sceneObject);
410
411 void onCustomContextMenu(const QPoint& point);
412
413 virtual void addNode();
414
415protected:
418
423 virtual void populateContextMenuForItem(vtkIdType itemID);
425 virtual void populateVisibilityContextMenuForItem(vtkIdType itemID);
427 virtual void populateTransformContextMenuForItem(vtkIdType itemID);
428
432 virtual bool clickDecoration(QMouseEvent* e);
434 void mousePressEvent(QMouseEvent* e) override;
436 void keyPressEvent(QKeyEvent* e) override;
437
441
444 vtkIdType firstSelectedSubjectHierarchyItemInBranch(vtkIdType itemID);
445
446 void changeEvent(QEvent* e) override;
447
448protected:
449 QScopedPointer<qMRMLSubjectHierarchyTreeViewPrivate> d_ptr;
450
451private:
452 Q_DECLARE_PRIVATE(qMRMLSubjectHierarchyTreeView);
453 Q_DISABLE_COPY(qMRMLSubjectHierarchyTreeView);
455};
456
457#endif
Item model for subject hierarchy.
void setIncludeNodeAttributeNamesFilter(QStringList filter)
void setTransformColumnVisible(bool visible)
Set transform column visibility.
Q_INVOKABLE qMRMLSortFilterSubjectHierarchyProxyModel * sortFilterProxyModel() const
void setNoneDisplay(const QString &displayName)
virtual void setRootItem(vtkIdType itemID)
Set subject hierarchy item to be the root in the shown tree.
Q_INVOKABLE vtkIdType rootItem() const
Get root item of the tree.
void currentNodeChanged(vtkMRMLNode *)
Q_INVOKABLE void setNodeTypeLabel(const QString &label, const QString &nodeType)
virtual void setCurrentItems(QList< vtkIdType > items)
Set current (=selected) subject hierarchy items.
void setAddNodeMenuActionVisible(bool show)
Set whether to show the "Create node" actions in the context menu of the scene.
void setExcludeNodeAttributeNamesFilter(QStringList filter)
void setPluginWhitelist(QStringList allowlist)
Deprecated. Use setPluginAllowlist instead.
virtual void onMRMLSceneStartBatchProcess(vtkObject *sceneObject)
Called when batch processing starts. Makes sure stored selection does not get emptied before restorin...
void currentItemsChanged(QList< vtkIdType >)
void setPluginAllowlist(QStringList allowlist)
Deprecated. Use setPluginAllowList instead.
void setExcludeItemAttributeNamesFilter(QStringList filter)
Q_INVOKABLE void removeAttributeFilter()
Remove item attribute filtering.
Q_INVOKABLE vtkMRMLSubjectHierarchyNode * subjectHierarchyNode() const
QStringList includeItemAttributeNamesFilter
Filter to show only items that contain any of the given attributes with this name....
void keyPressEvent(QKeyEvent *e) override
Handle key press event.
void currentItemChanged(vtkIdType)
void setPluginBlockList(QStringList blocklist)
Q_INVOKABLE void addNodeAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true, QString className=QString())
void onCustomContextMenu(const QPoint &point)
virtual void onSubjectHierarchyItemModified(vtkObject *caller, void *callData)
Propagate item modified event.
virtual void editCurrentItem()
Edit properties of current item.
virtual void setMultiSelection(bool multiSelectionOn)
Set multi-selection.
vtkIdType firstSelectedSubjectHierarchyItemInBranch(vtkIdType itemID)
Q_INVOKABLE qMRMLSubjectHierarchyModel * model() const
virtual void setCurrentItem(vtkIdType itemID)
Set current (=selected) subject hierarchy item.
void applyReferenceHighlightForItems(QList< vtkIdType > itemIDs)
bool selectRoleSubMenuVisible
This property controls whether the Select role context menu sub-menu is visible. Visible by default.
virtual void setCurrentNode(vtkMRMLNode *node)
Convenience method to set current item by associated data node.
void setIdColumnVisible(bool visible)
Set ID column visibility.
virtual void onMRMLSceneEndBatchProcess(vtkObject *sceneObject)
Called when batch processing ends. Restores selection, which is lost when the hierarchy is rebuilt.
virtual bool clickDecoration(QMouseEvent *e)
bool editMenuActionVisible
This property controls whether the Edit properties context menu action is visible....
Q_INVOKABLE QString nodeTypeLabel(const QString &nodeType) const
QStringList includeNodeAttributeNamesFilter
Filter to show only items for data nodes that contain any of the given attributes with this name....
void toggleVisibilityOfSelectedItems()
Toggle visibility of selected subject hierarchy items.
void changeEvent(QEvent *e) override
void setNameFilter(QString &nameFilter)
Set name filter that allows showing only items containing a specified string (case-insensitive)....
Q_INVOKABLE vtkIdType currentItem() const
Get current (=selected) item. If there are multiple items selected, then the first one is returned.
void setPluginBlacklist(QStringList blocklist)
Deprecated. Use setPluginBlocklist instead.
void mousePressEvent(QMouseEvent *e) override
Handle mouse press event.
bool addNodeMenuActionVisible
This property controls whether the add node context menu of the scene is visible for node types speci...
void setHideChildNodeTypes(const QStringList &types)
void setUseTerminologySelector(bool useTerminologySelector)
Set if standard terminologies are used for choosing segment name and color.
void setNodeTypes(const QStringList &types)
Set node type filter that allows showing only data nodes of a certain type. Show all data nodes if em...
bool contextMenuEnabled
Flag determining whether context menu is enabled.
bool showContextMenuHint(bool visibility=false)
void setIncludeItemAttributeNamesFilter(QStringList filter)
void setBaseName(const QString &baseName, const QString &nodeType="")
virtual void onMRMLSceneStartClose(vtkObject *sceneObject)
Called when scene close is started.
QList< vtkIdType > currentItems()
Get current (=selected) items.
void hideSelectedItems()
Hide selected subject hierarchy items.
void setVisibilityColumnVisible(bool visible)
Set visibility column visibility.
virtual void populateContextMenuForItem(vtkIdType itemID)
virtual void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, QVariant attributeValue, bool include, QString className)
Remove single node attribute filter specifying each attribute.
virtual void setSubjectHierarchyNode(vtkMRMLSubjectHierarchyNode *shNode)
Set the subject hierarchy node found in the given scene. Called only internally.
void deleteSelectedItems()
Delete selected subject hierarchy items and associated data nodes.
void resetColumnSizesToDefault()
Resets column sizes and size policies to default.
void currentItemModified(vtkIdType)
virtual void updateSelectPluginActions()
virtual void populateVisibilityContextMenuForItem(vtkIdType itemID)
Populate visibility context menu for given subject hierarchy item.
virtual vtkMRMLNode * addNode(QString nodeType)
Creates a node of the same type as in the "node types" property.
void setPluginBlocklist(QStringList blocklist)
Deprecated. Use setPluginBlockList instead.
void setPluginAllowList(QStringList allowlist)
virtual void expandItem(vtkIdType itemID)
Handle expand item requests in the subject hierarchy tree. Expands branch.
virtual vtkMRMLNode * currentNode() const
Convenience method to set current item by associated data node.
Q_INVOKABLE void setAttributeFilter(const QString &attributeName, const QVariant &attributeValue=QVariant())
qMRMLSubjectHierarchyTreeView(QWidget *parent=nullptr)
void setContextMenuEnabled(bool enabled)
void showSelectedItems()
Show selected subject hierarchy items.
void setEditMenuActionVisible(bool visible)
void disablePlugin(QString plugin)
Q_INVOKABLE vtkMRMLNode * findFirstNodeByClass(const QString &className) const
bool useTerminologySelector
Double-clicking the color will show a standard terminology selector if true, otherwise show simple co...
Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, QVariant attributeValue, bool include)
Remove single item attribute filter specifying each attribute.
Q_INVOKABLE vtkMRMLScene * mrmlScene() const
QScopedPointer< qMRMLSubjectHierarchyTreeViewPrivate > d_ptr
virtual void onItemCollapsed(const QModelIndex &collapsedItemIndex)
Updates subject hierarchy item expanded property when item is collapsed.
bool multiSelection
Flag determining whether multiple items can be selected.
void setColorColumnVisible(bool visible)
Set color column visibility.
virtual void selectPluginForCurrentItem()
Handle manual selection of a plugin as the new owner of a subject hierarchy node.
void renameCurrentItem()
Rename currently selected one item by popping up a dialog.
virtual void collapseItem(vtkIdType itemID)
Handle collapse item requests in the subject hierarchy tree. Collapses branch.
void nodeAddedByUser(vtkMRMLNode *node)
Signal emitted when node is added by the user.
virtual void setMRMLScene(vtkMRMLScene *scene)
Set MRML scene.
void setShowRootItem(bool show)
Set root item visibility.
Q_INVOKABLE int displayedItemCount() const
Determine the number of shown items.
virtual void onItemExpanded(const QModelIndex &expandedItemIndex)
Updates subject hierarchy item expanded property when item is expanded.
void setDescriptionColumnVisible(bool visible)
Set description column visibility.
virtual void onSubjectHierarchyItemTransformModified(vtkObject *caller, void *callData)
Propagate item transform modified event.
virtual void onMRMLSceneEndClose(vtkObject *sceneObject)
Called when scene close is finished. Hierarchy is cleared in that case.
void setNoneEnabled(bool enable)
Q_INVOKABLE void addItemAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true)
void setAttributeValueFilter(QString &filter)
void setLevelFilter(QStringList &levelFilter)
Set level filter that allows showing only items at a specified level and their parents....
QString baseName(const QString &nodeType="") const
void setAttributeNameFilter(QString &filter)
void setSelectRoleSubMenuVisible(bool visible)
void setHighlightReferencedItems(bool highlightOn)
virtual void populateTransformContextMenuForItem(vtkIdType itemID)
Populate transform context menu for given subject hierarchy item.
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
MRML node to represent a complete subject hierarchy tree.