Slicer 5.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
43class vtkMRMLScene;
44class vtkCallbackCommand;
49class qSlicerSubjectHierarchyPluginHandlerCleanup;
50
51
55class 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
81public:
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()const;
110
114 Q_INVOKABLE void setCurrentItems(QList<vtkIdType> items);
115
119 Q_INVOKABLE QList<vtkIdType> currentItems()const;
120 Q_INVOKABLE void currentItems(vtkIdList* selectedItems)const;
121
124 Q_INVOKABLE void setCurrentTreeView(qMRMLSubjectHierarchyTreeView* treeView);
126 Q_INVOKABLE qMRMLSubjectHierarchyTreeView* currentTreeView()const;
127
128 Q_INVOKABLE bool autoDeleteSubjectHierarchyChildren()const;
129 Q_INVOKABLE void setAutoDeleteSubjectHierarchyChildren(bool flag);
130 Q_INVOKABLE bool displayPatientIDInSubjectHierarchyItemName()const;
131 Q_INVOKABLE void setDisplayPatientIDInSubjectHierarchyItemName(bool on);
132 Q_INVOKABLE bool displayPatientBirthDateInSubjectHierarchyItemName()const;
133 Q_INVOKABLE void setDisplayPatientBirthDateInSubjectHierarchyItemName(bool on);
134 Q_INVOKABLE bool displayStudyIDInSubjectHierarchyItemName()const;
135 Q_INVOKABLE void setDisplayStudyIDInSubjectHierarchyItemName(bool on);
136 Q_INVOKABLE bool displayStudyDateInSubjectHierarchyItemName()const;
137 Q_INVOKABLE void setDisplayStudyDateInSubjectHierarchyItemName(bool on);
138
139public:
142 Q_INVOKABLE bool registerPlugin(qSlicerSubjectHierarchyAbstractPlugin* plugin);
143
145 Q_INVOKABLE QList<qSlicerSubjectHierarchyAbstractPlugin*> registeredPlugins() { return m_RegisteredPlugins; };
146
149
151 Q_INVOKABLE QList<qSlicerSubjectHierarchyAbstractPlugin*> allPlugins();
152
156
163 QList<qSlicerSubjectHierarchyAbstractPlugin*> pluginsForAddingNodeToSubjectHierarchy(
164 vtkMRMLNode* node,
165 vtkIdType parentItemID=vtkMRMLSubjectHierarchyNode::INVALID_ITEM_ID );
166
172 QList<qSlicerSubjectHierarchyAbstractPlugin*> pluginsForReparentingItemInSubjectHierarchy(
173 vtkIdType itemID, vtkIdType parentItemID );
174
180
185
189
196 qSlicerSubjectHierarchyAbstractPlugin* selectPluginFromDialog(QString textToDisplay, QList<qSlicerSubjectHierarchyAbstractPlugin*> candidatePlugins);
197
202
204 Q_INVOKABLE void showItemsInView(vtkIdList* itemIDsToShow, vtkMRMLAbstractViewNode* viewNode);
205
208 Q_INVOKABLE QString dumpContextMenuActions();
209
210protected:
212 static void onSubjectHierarchyNodeEvent(vtkObject* caller, unsigned long event, void* clientData, void* callData);
213
214protected:
216 QList<qSlicerSubjectHierarchyAbstractPlugin*> m_RegisteredPlugins;
217
221
224 QList<vtkIdType> m_CurrentItems;
225
227 qMRMLSubjectHierarchyTreeView* m_CurrentTreeView{nullptr};
228
230 vtkWeakPointer<vtkMRMLScene> m_MRMLScene;
231
233 qSlicerSubjectHierarchyPluginLogic* m_PluginLogic{nullptr};
234
236 vtkSmartPointer<vtkCallbackCommand> m_CallBack;
237
238public:
241
242private:
244 static void cleanup();
245
246private:
247 qSlicerSubjectHierarchyPluginHandler(QObject* parent=nullptr);
249
251 friend class qSlicerSubjectHierarchyPluginHandlerCleanup;
252 friend class PythonQtWrapper_qSlicerSubjectHierarchyPluginHandler; // Allow Python wrapping without enabling direct instantiation
253
254private:
256 static qSlicerSubjectHierarchyPluginHandler* m_Instance;
257};
258
259#endif
Abstract plugin for handling Subject Hierarchy items.
Default Subject Hierarchy plugin to exercise features of the abstract plugin. This plugin must not be...
Singleton class managing Subject Hierarchy plugins.
Q_INVOKABLE void showItemsInView(vtkIdList *itemIDsToShow, vtkMRMLAbstractViewNode *viewNode)
Show a list of items in a selected view (used for drag&drop of items into a view node)
QList< qSlicerSubjectHierarchyAbstractPlugin * > pluginsForReparentingItemInSubjectHierarchy(vtkIdType itemID, vtkIdType parentItemID)
Q_INVOKABLE QString dumpContextMenuActions()
qSlicerSubjectHierarchyAbstractPlugin * findAndSetOwnerPluginForSubjectHierarchyItem(vtkIdType itemID)
Q_INVOKABLE QList< qSlicerSubjectHierarchyAbstractPlugin * > allPlugins()
Returns all plugins (registered plugins and default plugin)
vtkSmartPointer< vtkCallbackCommand > m_CallBack
Callback handling deletion of the subject hierarchy node.
Q_INVOKABLE qSlicerSubjectHierarchyAbstractPlugin * pluginByName(QString name)
Q_INVOKABLE qSlicerSubjectHierarchyDefaultPlugin * defaultPlugin()
Get default plugin instance.
qSlicerSubjectHierarchyAbstractPlugin * findOwnerPluginForSubjectHierarchyItem(vtkIdType itemID)
qSlicerSubjectHierarchyDefaultPlugin * m_DefaultPlugin
static void onSubjectHierarchyNodeEvent(vtkObject *caller, unsigned long event, void *clientData, void *callData)
Handle subject hierarchy node events.
QList< qSlicerSubjectHierarchyAbstractPlugin * > pluginsForAddingNodeToSubjectHierarchy(vtkMRMLNode *node, vtkIdType parentItemID=vtkMRMLSubjectHierarchyNode::INVALID_ITEM_ID)
Q_INVOKABLE qSlicerSubjectHierarchyAbstractPlugin * getOwnerPluginForSubjectHierarchyItem(vtkIdType itemID)
qSlicerSubjectHierarchyAbstractPlugin * selectPluginFromDialog(QString textToDisplay, QList< qSlicerSubjectHierarchyAbstractPlugin * > candidatePlugins)
QDateTime LastPluginRegistrationTime
Timestamp of the last plugin registration. Used to allow context menus be repopulated if needed.
void observeSubjectHierarchyNode(vtkMRMLSubjectHierarchyNode *shNode)
vtkWeakPointer< vtkMRMLScene > m_MRMLScene
MRML scene (to get new subject hierarchy node if the stored one is deleted)
QList< qSlicerSubjectHierarchyAbstractPlugin * > m_RegisteredPlugins
List of registered plugin instances.
Qt-based logic class to exercise Qt-related logic functions. The Subject hierarchy plugin mechanism a...
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D,...
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
MRML node to represent a complete subject hierarchy tree.