Slicer  5.3
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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 
35 class qMRMLSubjectHierarchyTreeViewPrivate;
38 class vtkMRMLNode;
39 class vtkMRMLScene;
41 class vtkIdList;
42 
44 class Q_SLICER_MODULE_SUBJECTHIERARCHY_WIDGETS_EXPORT qMRMLSubjectHierarchyTreeView : public QTreeView
45 {
46  Q_OBJECT
47  QVTK_OBJECT
48 
53  Q_PROPERTY(bool showRootItem READ showRootItem WRITE setShowRootItem)
57  Q_PROPERTY(bool highlightReferencedItems READ highlightReferencedItems WRITE setHighlightReferencedItems)
59  Q_PROPERTY(bool contextMenuEnabled READ contextMenuEnabled WRITE setContextMenuEnabled)
61  Q_PROPERTY(bool editMenuActionVisible READ editMenuActionVisible WRITE setEditMenuActionVisible)
63  Q_PROPERTY(bool selectRoleSubMenuVisible READ selectRoleSubMenuVisible WRITE setSelectRoleSubMenuVisible)
65  Q_PROPERTY(bool multiSelection READ multiSelection WRITE setMultiSelection)
66  Q_PROPERTY(QStringList levelFilter READ levelFilter WRITE setLevelFilter)
67  Q_PROPERTY(QString nameFilter READ nameFilter WRITE setNameFilter)
68  Q_PROPERTY(QStringList nodeTypes READ nodeTypes WRITE setNodeTypes)
69  Q_PROPERTY(QStringList hideChildNodeTypes READ hideChildNodeTypes WRITE setHideChildNodeTypes)
70  Q_PROPERTY(bool visibilityColumnVisible READ visibilityColumnVisible WRITE setVisibilityColumnVisible)
71  Q_PROPERTY(bool idColumnVisible READ idColumnVisible WRITE setIdColumnVisible)
72  Q_PROPERTY(bool colorColumnVisible READ colorColumnVisible WRITE setColorColumnVisible)
73  Q_PROPERTY(bool transformColumnVisible READ transformColumnVisible WRITE setTransformColumnVisible)
74  Q_PROPERTY(bool descriptionColumnVisible READ descriptionColumnVisible WRITE setDescriptionColumnVisible)
75 
78  Q_PROPERTY(bool noneEnabled READ noneEnabled WRITE setNoneEnabled)
82  Q_PROPERTY(QString noneDisplay READ noneDisplay WRITE setNoneDisplay)
83 
85  Q_PROPERTY(QStringList includeItemAttributeNamesFilter READ includeItemAttributeNamesFilter WRITE setIncludeItemAttributeNamesFilter)
87  Q_PROPERTY(QStringList includeNodeAttributeNamesFilter READ includeNodeAttributeNamesFilter WRITE setIncludeNodeAttributeNamesFilter)
90  Q_PROPERTY(QStringList excludeItemAttributeNamesFilter READ excludeItemAttributeNamesFilter WRITE setExcludeItemAttributeNamesFilter)
93  Q_PROPERTY(QStringList excludeNodeAttributeNamesFilter READ excludeNodeAttributeNamesFilter WRITE setExcludeNodeAttributeNamesFilter)
94 
97  Q_PROPERTY(QString attributeNameFilter READ attributeNameFilter WRITE setAttributeNameFilter)
102  Q_PROPERTY(QString attributeValueFilter READ attributeValueFilter WRITE setAttributeValueFilter)
103 
104 public:
105  typedef QTreeView Superclass;
106  qMRMLSubjectHierarchyTreeView(QWidget *parent=nullptr);
107  ~qMRMLSubjectHierarchyTreeView() override;
108 
109 public:
110  Q_INVOKABLE vtkMRMLScene* mrmlScene()const;
111  Q_INVOKABLE vtkMRMLSubjectHierarchyNode* subjectHierarchyNode()const;
112 
114  Q_INVOKABLE vtkIdType currentItem()const;
116  QList<vtkIdType> currentItems();
119  Q_INVOKABLE void currentItems(vtkIdList* selectedItems);
120 
122  virtual vtkMRMLNode* currentNode()const;
123 
125  Q_INVOKABLE vtkIdType rootItem()const;
127  bool showRootItem()const;
128 
130  bool multiSelection();
131 
132  QStringList includeItemAttributeNamesFilter()const;
133  QStringList includeNodeAttributeNamesFilter()const;
134  QStringList excludeItemAttributeNamesFilter()const;
135  QStringList excludeNodeAttributeNamesFilter()const;
136  QString attributeValueFilter()const;
137  QString attributeNameFilter()const;
142  Q_INVOKABLE void setAttributeFilter(const QString& attributeName, const QVariant& attributeValue=QVariant());
144  Q_INVOKABLE void removeAttributeFilter();
152  Q_INVOKABLE void addItemAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true);
154  Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, QVariant attributeValue, bool include);
156  Q_INVOKABLE void removeItemAttributeFilter(QString attributeName, bool include);
165  Q_INVOKABLE void addNodeAttributeFilter(QString attributeName, QVariant attributeValue=QString(), bool include=true, QString className=QString());
167  Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, QVariant attributeValue, bool include, QString className);
169  Q_INVOKABLE void removeNodeAttributeFilter(QString attributeName, bool include);
170 
171 
173  void setLevelFilter(QStringList &levelFilter);
174  QStringList levelFilter()const;
175 
177  void setNameFilter(QString &nameFilter);
178  QString nameFilter()const;
179 
181  void setNodeTypes(const QStringList& types);
182  QStringList nodeTypes()const;
183 
186  void setHideChildNodeTypes(const QStringList& types);
187  QStringList hideChildNodeTypes()const;
188 
189  Q_INVOKABLE qMRMLSortFilterSubjectHierarchyProxyModel* sortFilterProxyModel()const;
190  Q_INVOKABLE qMRMLSubjectHierarchyModel* model()const;
191 
193  Q_INVOKABLE int displayedItemCount()const;
194 
195  bool highlightReferencedItems()const;
196  bool contextMenuEnabled()const;
197  bool editMenuActionVisible()const;
198  bool selectRoleSubMenuVisible()const;
199  bool noneEnabled()const;
200  QString noneDisplay()const;
201 
203  void setVisibilityColumnVisible(bool visible);
204  bool visibilityColumnVisible();
206  void setIdColumnVisible(bool visible);
207  bool idColumnVisible();
209  void setColorColumnVisible(bool visible);
210  bool colorColumnVisible();
212  void setTransformColumnVisible(bool visible);
213  bool transformColumnVisible();
215  void setDescriptionColumnVisible(bool visible);
216  bool descriptionColumnVisible();
217 
218 public slots:
220  virtual void setMRMLScene(vtkMRMLScene* scene);
221 
223  virtual void setCurrentItem(vtkIdType itemID);
225  virtual void setCurrentItems(QList<vtkIdType> items);
227  virtual void setCurrentItems(vtkIdList* items);
229  virtual void setCurrentNode(vtkMRMLNode* node);
230 
232  virtual void setRootItem(vtkIdType itemID);
234  void setShowRootItem(bool show);
235 
237  void renameCurrentItem();
239  void deleteSelectedItems();
241  void toggleVisibilityOfSelectedItems();
243  virtual void editCurrentItem();
244 
246  virtual void expandItem(vtkIdType itemID);
248  virtual void collapseItem(vtkIdType itemID);
249 
251  virtual void selectPluginForCurrentItem();
252 
257  virtual void updateSelectPluginActions();
258 
260  virtual void setMultiSelection(bool multiSelectionOn);
261 
265  void setPluginAllowlist(QStringList allowlist);
269  void setPluginBlocklist(QStringList blocklist);
272  void disablePlugin(QString plugin);
273 
275  void setPluginWhitelist(QStringList allowlist)
276  {
277  qWarning("qMRMLSubjectHierarchyTreeView::setPluginWhitelist is deprecated. Use setPluginAllowlist instead.");
278  this->setPluginAllowlist(allowlist);
279  }
281  void setPluginBlacklist(QStringList blocklist)
282  {
283  qWarning("qMRMLSubjectHierarchyTreeView::setPluginBlacklist is deprecated. Use setPluginBlocklist instead.");
284  this->setPluginBlocklist(blocklist);
285  }
286 
290  bool showContextMenuHint(bool visibility=false);
291 
292  void setHighlightReferencedItems(bool highlightOn);
293  void setContextMenuEnabled(bool enabled);
294  void setEditMenuActionVisible(bool visible);
295  void setSelectRoleSubMenuVisible(bool visible);
296  void setNoneEnabled(bool enable);
297  void setNoneDisplay(const QString& displayName);
298 
300  void resetColumnSizesToDefault();
301 
302  void setIncludeItemAttributeNamesFilter(QStringList filter);
303  void setIncludeNodeAttributeNamesFilter(QStringList filter);
304  void setExcludeItemAttributeNamesFilter(QStringList filter);
305  void setExcludeNodeAttributeNamesFilter(QStringList filter);
306  void setAttributeNameFilter(QString& filter);
307  void setAttributeValueFilter(QString& filter);
308 
309 signals:
310  void currentItemChanged(vtkIdType);
311  void currentItemsChanged(QList<vtkIdType>);
312  void currentItemModified(vtkIdType);
313 
314 protected slots:
315  virtual void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
316 
318  virtual void onItemExpanded(const QModelIndex &expandedItemIndex);
320  virtual void onItemCollapsed(const QModelIndex &collapsedItemIndex);
321 
323  virtual void expandToDepthFromContextMenu();
324 
327  virtual void updateRootItem();
328 
330  virtual void onSubjectHierarchyItemModified(vtkObject *caller, void *callData);
332  virtual void onSubjectHierarchyItemTransformModified(vtkObject *caller, void *callData);
333 
335  virtual void onMRMLSceneStartClose(vtkObject* sceneObject);
337  virtual void onMRMLSceneEndClose(vtkObject* sceneObject);
339  virtual void onMRMLSceneStartBatchProcess(vtkObject* sceneObject);
341  virtual void onMRMLSceneEndBatchProcess(vtkObject* sceneObject);
342 
343  void onCustomContextMenu(const QPoint& point);
344 
345  virtual void onTransformActionSelected();
346  virtual void onTransformInteractionInViewToggled(bool show);
347  virtual void onTransformEditProperties();
348  virtual void onCreateNewTransform();
349 
350 protected:
352  virtual void setSubjectHierarchyNode(vtkMRMLSubjectHierarchyNode* shNode);
353 
355  void toggleSubjectHierarchyItemVisibility(vtkIdType itemID);
356 
361  virtual void populateContextMenuForItem(vtkIdType itemID);
363  virtual void populateVisibilityContextMenuForItem(vtkIdType itemID);
365  virtual void populateTransformContextMenuForItem(vtkIdType itemID);
366 
370  virtual bool clickDecoration(QMouseEvent* e);
372  void mousePressEvent(QMouseEvent* e) override;
374  void keyPressEvent(QKeyEvent* e) override;
375 
378  void applyReferenceHighlightForItems(QList<vtkIdType> itemIDs);
379 
382  vtkIdType firstSelectedSubjectHierarchyItemInBranch(vtkIdType itemID);
383 
384  void changeEvent(QEvent* e) override;
385 
386 protected:
387  QScopedPointer<qMRMLSubjectHierarchyTreeViewPrivate> d_ptr;
388 
389 private:
390  Q_DECLARE_PRIVATE(qMRMLSubjectHierarchyTreeView);
391  Q_DISABLE_COPY(qMRMLSubjectHierarchyTreeView);
393 };
394 
395 #endif
MRML node to represent a complete subject hierarchy tree.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
void setPluginBlacklist(QStringList blocklist)
Deprecated. Use setPluginBlocklist instead.
Item model for subject hierarchy.
QScopedPointer< qMRMLSubjectHierarchyTreeViewPrivate > d_ptr
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167