Slicer  4.10
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 
67 public:
68  typedef QTreeView Superclass;
69  qMRMLSubjectHierarchyTreeView(QWidget *parent=0);
71 
72 public:
73  Q_INVOKABLE vtkMRMLScene* mrmlScene()const;
74  Q_INVOKABLE vtkMRMLSubjectHierarchyNode* subjectHierarchyNode()const;
75 
77  Q_INVOKABLE vtkIdType currentItem()const;
79  QList<vtkIdType> currentItems();
82  Q_INVOKABLE void currentItems(vtkIdList* selectedItems);
83 
85  Q_INVOKABLE vtkIdType rootItem()const;
87  bool showRootItem()const;
88 
90  bool multiSelection();
91 
96  Q_INVOKABLE void setAttributeFilter(const QString& attributeName, const QVariant& attributeValue=QVariant());
98  Q_INVOKABLE void removeAttributeFilter();
99 
101  Q_INVOKABLE void setLevelFilter(QString &levelFilter);
103  Q_INVOKABLE void setNameFilter(QString &nameFilter);
105  Q_INVOKABLE void setNodeTypes(const QStringList& types);
108  Q_INVOKABLE void setHideChildNodeTypes(const QStringList& types);
109 
110  Q_INVOKABLE qMRMLSortFilterSubjectHierarchyProxyModel* sortFilterProxyModel()const;
111  Q_INVOKABLE qMRMLSubjectHierarchyModel* model()const;
112 
114  Q_INVOKABLE int displayedItemCount()const;
115 
116  bool highlightReferencedItems()const;
117  bool contextMenuEnabled()const;
118  bool editMenuActionVisible()const;
119  bool selectRoleSubMenuVisible()const;
120 
121 public slots:
123  virtual void setMRMLScene(vtkMRMLScene* scene);
124 
126  virtual void setCurrentItem(vtkIdType itemID);
128  virtual void setCurrentItems(QList<vtkIdType> items);
130  virtual void setCurrentItems(vtkIdList* items);
132  virtual void setCurrentNode(vtkMRMLNode* node);
133 
135  virtual void setRootItem(vtkIdType itemID);
137  void setShowRootItem(bool show);
138 
140  void renameCurrentItem();
142  void deleteSelectedItems();
144  void toggleVisibilityOfSelectedItems();
146  virtual void editCurrentItem();
147 
149  virtual void expandItem(vtkIdType itemID);
151  virtual void collapseItem(vtkIdType itemID);
152 
154  virtual void selectPluginForCurrentItem();
155 
160  virtual void updateSelectPluginActions();
161 
163  virtual void setMultiSelection(bool multiSelectionOn);
164 
168  void setPluginWhitelist(QStringList whitelist);
172  void setPluginBlacklist(QStringList blacklist);
175  void disablePlugin(QString plugin);
176 
180  bool showContextMenuHint(bool visibility=false);
181 
182  void setHighlightReferencedItems(bool highlightOn);
183  void setContextMenuEnabled(bool enabled);
184  void setEditMenuActionVisible(bool visible);
185  void setSelectRoleSubMenuVisible(bool visible);
186 
187 signals:
188  void currentItemChanged(vtkIdType);
189  void currentItemModified(vtkIdType);
190 
191 protected slots:
192  virtual void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
193 
195  virtual void onItemExpanded(const QModelIndex &expandedItemIndex);
197  virtual void onItemCollapsed(const QModelIndex &collapsedItemIndex);
198 
200  virtual void expandToDepthFromContextMenu();
201 
204  virtual void updateRootItem();
205 
208  virtual void onSubjectHierarchyItemModified(vtkObject *caller, void *callData);
209 
211  virtual void onMRMLSceneCloseEnded(vtkObject* sceneObject);
213  virtual void onMRMLSceneStartBatchProcess(vtkObject* sceneObject);
215  virtual void onMRMLSceneEndBatchProcess(vtkObject* sceneObject);
216 
217 protected:
219  virtual void setSubjectHierarchyNode(vtkMRMLSubjectHierarchyNode* shNode);
220 
222  void toggleSubjectHierarchyItemVisibility(vtkIdType itemID);
223 
228  virtual void populateContextMenuForItem(vtkIdType itemID);
230  virtual void populateVisibilityContextMenuForItem(vtkIdType itemID);
231 
235  virtual bool clickDecoration(QMouseEvent* e);
237  virtual void mousePressEvent(QMouseEvent* e);
239  virtual void keyPressEvent(QKeyEvent* e);
240 
243  void applyReferenceHighlightForItems(QList<vtkIdType> itemIDs);
244 
247  vtkIdType firstSelectedSubjectHierarchyItemInBranch(vtkIdType itemID);
248 
249 protected:
250  QScopedPointer<qMRMLSubjectHierarchyTreeViewPrivate> d_ptr;
251 
252 private:
253  Q_DECLARE_PRIVATE(qMRMLSubjectHierarchyTreeView);
254  Q_DISABLE_COPY(qMRMLSubjectHierarchyTreeView);
256 };
257 
258 #endif
MRML node to represent a complete subject hierarchy tree.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
Item model for subject hierarchy.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138