Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerSubjectHierarchyPluginHandler.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 __qSlicerSubjectHierarchyPluginHandler_h
24 #define __qSlicerSubjectHierarchyPluginHandler_h
25 
26 // SubjectHierarchy includes
27 #include "qSlicerSubjectHierarchyModuleWidgetsExport.h"
28 
29 // MRML includes
30 #include <vtkMRMLScene.h>
32 
33 // VTK includes
34 #include <vtkSmartPointer.h>
35 #include <vtkWeakPointer.h>
36 
37 // Qt includes
38 #include <QDateTime>
39 #include <QList>
40 #include <QObject>
41 #include <QString>
42 
43 class vtkMRMLScene;
44 class vtkCallbackCommand;
48 class qSlicerSubjectHierarchyPluginHandlerCleanup;
49 
50 
55 class Q_SLICER_MODULE_SUBJECTHIERARCHY_WIDGETS_EXPORT qSlicerSubjectHierarchyPluginHandler : public QObject
56 {
57  Q_OBJECT
58 
63  Q_PROPERTY (bool autoDeleteSubjectHierarchyChildren READ autoDeleteSubjectHierarchyChildren WRITE setAutoDeleteSubjectHierarchyChildren)
67  Q_PROPERTY (bool displayPatientIDInSubjectHierarchyItemName READ displayPatientIDInSubjectHierarchyItemName WRITE setDisplayPatientIDInSubjectHierarchyItemName)
71  Q_PROPERTY (bool displayPatientBirthDateInSubjectHierarchyItemName READ displayPatientBirthDateInSubjectHierarchyItemName WRITE setDisplayPatientBirthDateInSubjectHierarchyItemName)
75  Q_PROPERTY (bool displayStudyIDInSubjectHierarchyItemName READ displayStudyIDInSubjectHierarchyItemName WRITE setDisplayStudyIDInSubjectHierarchyItemName)
79  Q_PROPERTY (bool displayStudyDateInSubjectHierarchyItemName READ displayStudyDateInSubjectHierarchyItemName WRITE setDisplayStudyDateInSubjectHierarchyItemName)
80 
81 public:
84  Q_INVOKABLE static qSlicerSubjectHierarchyPluginHandler* instance();
85 
87  Q_INVOKABLE vtkMRMLSubjectHierarchyNode* subjectHierarchyNode()const;
89  void setMRMLScene(vtkMRMLScene* scene);
91  Q_INVOKABLE vtkMRMLScene* mrmlScene()const;
92 
94  Q_INVOKABLE qSlicerSubjectHierarchyPluginLogic* pluginLogic();
96  Q_INVOKABLE void setPluginLogic(qSlicerSubjectHierarchyPluginLogic* pluginLogic);
97 
101  Q_INVOKABLE void setCurrentItem(vtkIdType itemID);
102 
109  Q_INVOKABLE vtkIdType currentItem();
110 
114  Q_INVOKABLE void setCurrentItems(QList<vtkIdType> items);
115 
119  Q_INVOKABLE QList<vtkIdType> currentItems();
120  Q_INVOKABLE void currentItems(vtkIdList* selectedItems);
121 
122  Q_INVOKABLE bool autoDeleteSubjectHierarchyChildren()const;
123  Q_INVOKABLE void setAutoDeleteSubjectHierarchyChildren(bool flag);
124  Q_INVOKABLE bool displayPatientIDInSubjectHierarchyItemName()const;
125  Q_INVOKABLE void setDisplayPatientIDInSubjectHierarchyItemName(bool on);
126  Q_INVOKABLE bool displayPatientBirthDateInSubjectHierarchyItemName()const;
127  Q_INVOKABLE void setDisplayPatientBirthDateInSubjectHierarchyItemName(bool on);
128  Q_INVOKABLE bool displayStudyIDInSubjectHierarchyItemName()const;
129  Q_INVOKABLE void setDisplayStudyIDInSubjectHierarchyItemName(bool on);
130  Q_INVOKABLE bool displayStudyDateInSubjectHierarchyItemName()const;
131  Q_INVOKABLE void setDisplayStudyDateInSubjectHierarchyItemName(bool on);
132 
133 public:
136  Q_INVOKABLE bool registerPlugin(qSlicerSubjectHierarchyAbstractPlugin* plugin);
137 
139  Q_INVOKABLE QList<qSlicerSubjectHierarchyAbstractPlugin*> registeredPlugins() { return m_RegisteredPlugins; };
140 
142  Q_INVOKABLE qSlicerSubjectHierarchyDefaultPlugin* defaultPlugin();
143 
145  Q_INVOKABLE QList<qSlicerSubjectHierarchyAbstractPlugin*> allPlugins();
146 
149  Q_INVOKABLE qSlicerSubjectHierarchyAbstractPlugin* pluginByName(QString name);
150 
157  QList<qSlicerSubjectHierarchyAbstractPlugin*> pluginsForAddingNodeToSubjectHierarchy(
158  vtkMRMLNode* node,
159  vtkIdType parentItemID=vtkMRMLSubjectHierarchyNode::INVALID_ITEM_ID );
160 
166  QList<qSlicerSubjectHierarchyAbstractPlugin*> pluginsForReparentingItemInSubjectHierarchy(
167  vtkIdType itemID, vtkIdType parentItemID );
168 
173  qSlicerSubjectHierarchyAbstractPlugin* findOwnerPluginForSubjectHierarchyItem(vtkIdType itemID);
174 
178  qSlicerSubjectHierarchyAbstractPlugin* findAndSetOwnerPluginForSubjectHierarchyItem(vtkIdType itemID);
179 
182  Q_INVOKABLE qSlicerSubjectHierarchyAbstractPlugin* getOwnerPluginForSubjectHierarchyItem(vtkIdType itemID);
183 
190  qSlicerSubjectHierarchyAbstractPlugin* selectPluginFromDialog(QString textToDisplay, QList<qSlicerSubjectHierarchyAbstractPlugin*> candidatePlugins);
191 
195  void observeSubjectHierarchyNode(vtkMRMLSubjectHierarchyNode* shNode);
196 
198  Q_INVOKABLE void showItemsInView(vtkIdList* itemIDsToShow, vtkMRMLAbstractViewNode* viewNode);
199 
202  Q_INVOKABLE QString dumpContextMenuActions();
203 
204 protected:
206  static void onSubjectHierarchyNodeEvent(vtkObject* caller, unsigned long event, void* clientData, void* callData);
207 
208 protected:
211 
215 
219 
221  vtkWeakPointer<vtkMRMLScene> m_MRMLScene;
222 
224  qSlicerSubjectHierarchyPluginLogic* m_PluginLogic{nullptr};
225 
227  vtkSmartPointer<vtkCallbackCommand> m_CallBack;
228 
229 public:
232 
233 private:
235  static void cleanup();
236 
237 private:
238  qSlicerSubjectHierarchyPluginHandler(QObject* parent=nullptr);
240 
241  Q_DISABLE_COPY(qSlicerSubjectHierarchyPluginHandler);
242  friend class qSlicerSubjectHierarchyPluginHandlerCleanup;
243  friend class PythonQtWrapper_qSlicerSubjectHierarchyPluginHandler; // Allow Python wrapping without enabling direct instantiation
244 
245 private:
247  static qSlicerSubjectHierarchyPluginHandler* m_Instance;
248 };
249 
250 #endif
QDateTime LastPluginRegistrationTime
Timestamp of the last plugin registration. Used to allow context menus be repopulated if needed...
QList< qSlicerSubjectHierarchyAbstractPlugin * > m_RegisteredPlugins
List of registered plugin instances.
vtkSmartPointer< vtkCallbackCommand > m_CallBack
Callback handling deletion of the subject hierarchy node.
vtkWeakPointer< vtkMRMLScene > m_MRMLScene
MRML scene (to get new subject hierarchy node if the stored one is deleted)
Default Subject Hierarchy plugin to exercise features of the abstract plugin. This plugin must not be...
qSlicerSubjectHierarchyDefaultPlugin * m_DefaultPlugin
Abstract plugin for handling Subject Hierarchy items.
MRML node to represent a complete subject hierarchy tree.
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D...
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
Qt-based logic class to exercise Qt-related logic functions. The Subject hierarchy plugin mechanism a...
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
Singleton class managing Subject Hierarchy plugins.