Slicer  4.8
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;
39 class vtkMRMLScene;
40 class vtkIdList;
41 
43 class 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)
56  Q_PROPERTY(bool highlightReferencedItems READ highlightReferencedItems WRITE setHighlightReferencedItems)
58  Q_PROPERTY(bool contextMenuEnabled READ contextMenuEnabled WRITE setContextMenuEnabled)
60  Q_PROPERTY(bool editMenuActionVisible READ editMenuActionVisible WRITE setEditMenuActionVisible)
62  Q_PROPERTY(bool multiSelection READ multiSelection WRITE setMultiSelection)
63 
64 public:
65  typedef QTreeView Superclass;
66  qMRMLSubjectHierarchyTreeView(QWidget *parent=0);
68 
69 public:
70  Q_INVOKABLE vtkMRMLScene* mrmlScene()const;
71  Q_INVOKABLE vtkMRMLSubjectHierarchyNode* subjectHierarchyNode()const;
72 
74  Q_INVOKABLE vtkIdType currentItem()const;
76  QList<vtkIdType> currentItems();
79  Q_INVOKABLE void currentItems(vtkIdList* selectedItems);
80 
82  Q_INVOKABLE vtkIdType rootItem()const;
84  bool showRootItem()const;
85 
87  bool multiSelection();
88 
93  Q_INVOKABLE void setAttributeFilter(const QString& attributeName, const QVariant& attributeValue=QVariant());
95  Q_INVOKABLE void removeAttributeFilter();
96 
98  Q_INVOKABLE void setLevelFilter(QString &levelFilter);
100  Q_INVOKABLE void setNameFilter(QString &nameFilter);
101 
102  Q_INVOKABLE qMRMLSortFilterSubjectHierarchyProxyModel* sortFilterProxyModel()const;
103  Q_INVOKABLE qMRMLSubjectHierarchyModel* model()const;
104 
106  Q_INVOKABLE int displayedItemCount()const;
107 
108  bool highlightReferencedItems()const;
109  bool contextMenuEnabled()const;
110  bool editMenuActionVisible()const;
111 
112 public slots:
114  virtual void setMRMLScene(vtkMRMLScene* scene);
115 
117  virtual void setCurrentItem(vtkIdType itemID);
119  virtual void setCurrentItems(QList<vtkIdType> items);
121  virtual void setCurrentItems(vtkIdList* items);
122 
124  virtual void setRootItem(vtkIdType itemID);
126  void setShowRootItem(bool show);
127 
129  void renameCurrentItem();
131  void deleteSelectedItems();
133  virtual void editCurrentItem();
134 
136  virtual void expandItem(vtkIdType itemID);
138  virtual void collapseItem(vtkIdType itemID);
139 
141  virtual void selectPluginForCurrentItem();
142 
147  virtual void updateSelectPluginActions();
148 
150  virtual void setMultiSelection(bool multiSelectionOn);
151 
155  bool showContextMenuHint(bool visibility=false);
156 
157  void setHighlightReferencedItems(bool highlightOn);
158  void setContextMenuEnabled(bool enabled);
159  void setEditMenuActionVisible(bool visible);
160 
161 signals:
162  void currentItemChanged(vtkIdType);
163  void currentItemModified(vtkIdType);
164 
165 protected slots:
166  virtual void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
167 
169  virtual void onItemExpanded(const QModelIndex &expandedItemIndex);
171  virtual void onItemCollapsed(const QModelIndex &collapsedItemIndex);
172 
174  virtual void expandToDepthFromContextMenu();
175 
178  virtual void updateRootItem();
179 
182  virtual void onSubjectHierarchyItemModified(vtkObject *caller, void *callData);
183 
185  virtual void onMRMLSceneCloseEnded(vtkObject* sceneObject);
187  virtual void onMRMLSceneStartBatchProcess(vtkObject* sceneObject);
189  virtual void onMRMLSceneEndBatchProcess(vtkObject* sceneObject);
190 
191 protected:
193  virtual void setSubjectHierarchyNode(vtkMRMLSubjectHierarchyNode* shNode);
194 
196  void toggleSubjectHierarchyItemVisibility(vtkIdType itemID);
197 
202  virtual void populateContextMenuForItem(vtkIdType itemID);
204  virtual void populateVisibilityContextMenuForItem(vtkIdType itemID);
205 
209  virtual bool clickDecoration(QMouseEvent* e);
211  virtual void mousePressEvent(QMouseEvent* e);
213  virtual void keyPressEvent(QKeyEvent* e);
214 
217  void applyReferenceHighlightForItems(QList<vtkIdType> itemIDs);
218 
221  vtkIdType firstSelectedSubjectHierarchyItemInBranch(vtkIdType itemID);
222 
223 protected:
224  QScopedPointer<qMRMLSubjectHierarchyTreeViewPrivate> d_ptr;
225 
226 private:
227  Q_DECLARE_PRIVATE(qMRMLSubjectHierarchyTreeView);
228  Q_DISABLE_COPY(qMRMLSubjectHierarchyTreeView);
230 };
231 
232 #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.