Slicer  4.11
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  static void setInstance(qSlicerSubjectHierarchyPluginHandler* instance);
88 
90  Q_INVOKABLE vtkMRMLSubjectHierarchyNode* subjectHierarchyNode()const;
92  void setMRMLScene(vtkMRMLScene* scene);
94  Q_INVOKABLE vtkMRMLScene* mrmlScene()const;
95 
97  Q_INVOKABLE qSlicerSubjectHierarchyPluginLogic* pluginLogic();
99  Q_INVOKABLE void setPluginLogic(qSlicerSubjectHierarchyPluginLogic* pluginLogic);
100 
104  Q_INVOKABLE void setCurrentItem(vtkIdType itemID);
105 
112  Q_INVOKABLE vtkIdType currentItem();
113 
117  Q_INVOKABLE void setCurrentItems(QList<vtkIdType> items);
118 
122  Q_INVOKABLE QList<vtkIdType> currentItems();
123  Q_INVOKABLE void currentItems(vtkIdList* selectedItems);
124 
125  Q_INVOKABLE bool autoDeleteSubjectHierarchyChildren()const;
126  Q_INVOKABLE void setAutoDeleteSubjectHierarchyChildren(bool flag);
127  Q_INVOKABLE bool displayPatientIDInSubjectHierarchyItemName()const;
128  Q_INVOKABLE void setDisplayPatientIDInSubjectHierarchyItemName(bool on);
129  Q_INVOKABLE bool displayPatientBirthDateInSubjectHierarchyItemName()const;
130  Q_INVOKABLE void setDisplayPatientBirthDateInSubjectHierarchyItemName(bool on);
131  Q_INVOKABLE bool displayStudyIDInSubjectHierarchyItemName()const;
132  Q_INVOKABLE void setDisplayStudyIDInSubjectHierarchyItemName(bool on);
133  Q_INVOKABLE bool displayStudyDateInSubjectHierarchyItemName()const;
134  Q_INVOKABLE void setDisplayStudyDateInSubjectHierarchyItemName(bool on);
135 
136 public:
139  Q_INVOKABLE bool registerPlugin(qSlicerSubjectHierarchyAbstractPlugin* plugin);
140 
142  Q_INVOKABLE QList<qSlicerSubjectHierarchyAbstractPlugin*> registeredPlugins() { return m_RegisteredPlugins; };
143 
145  Q_INVOKABLE qSlicerSubjectHierarchyDefaultPlugin* defaultPlugin();
146 
148  Q_INVOKABLE QList<qSlicerSubjectHierarchyAbstractPlugin*> allPlugins();
149 
152  Q_INVOKABLE qSlicerSubjectHierarchyAbstractPlugin* pluginByName(QString name);
153 
160  QList<qSlicerSubjectHierarchyAbstractPlugin*> pluginsForAddingNodeToSubjectHierarchy(
161  vtkMRMLNode* node,
162  vtkIdType parentItemID=vtkMRMLSubjectHierarchyNode::INVALID_ITEM_ID );
163 
169  QList<qSlicerSubjectHierarchyAbstractPlugin*> pluginsForReparentingItemInSubjectHierarchy(
170  vtkIdType itemID, vtkIdType parentItemID );
171 
176  qSlicerSubjectHierarchyAbstractPlugin* findOwnerPluginForSubjectHierarchyItem(vtkIdType itemID);
177 
181  qSlicerSubjectHierarchyAbstractPlugin* findAndSetOwnerPluginForSubjectHierarchyItem(vtkIdType itemID);
182 
185  Q_INVOKABLE qSlicerSubjectHierarchyAbstractPlugin* getOwnerPluginForSubjectHierarchyItem(vtkIdType itemID);
186 
193  qSlicerSubjectHierarchyAbstractPlugin* selectPluginFromDialog(QString textToDisplay, QList<qSlicerSubjectHierarchyAbstractPlugin*> candidatePlugins);
194 
198  void observeSubjectHierarchyNode(vtkMRMLSubjectHierarchyNode* shNode);
199 
201  void showItemsInView(vtkIdList* itemIDsToShow, vtkMRMLAbstractViewNode* viewNode);
202 
203 protected:
205  static void onSubjectHierarchyNodeEvent(vtkObject* caller, unsigned long event, void* clientData, void* callData);
206 
207 protected:
210 
214 
218 
220  vtkWeakPointer<vtkMRMLScene> m_MRMLScene;
221 
223  qSlicerSubjectHierarchyPluginLogic* m_PluginLogic{nullptr};
224 
226  vtkSmartPointer<vtkCallbackCommand> m_CallBack;
227 
228 public:
231  qSlicerSubjectHierarchyPluginHandler(QObject* parent=nullptr);
232 
235 
238 
239 private:
240  Q_DISABLE_COPY(qSlicerSubjectHierarchyPluginHandler);
241  friend class qSlicerSubjectHierarchyPluginHandlerCleanup;
242 
243 private:
245  static qSlicerSubjectHierarchyPluginHandler* m_Instance;
246 };
247 
248 #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:61
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.