Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerSubjectHierarchyPluginLogic.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 __qSlicerSubjectHierarchyPluginLogic_h
24 #define __qSlicerSubjectHierarchyPluginLogic_h
25 
26 // Slicer includes
27 #include "qSlicerObject.h"
28 
29 // CTK includes
30 #include <ctkVTKObject.h>
31 
32 // Qt includes
33 #include <QObject>
34 
35 // MRML includes
36 #include <vtkMRMLScene.h>
38 
39 #include "qSlicerSubjectHierarchyModuleWidgetsExport.h"
40 
41 class QAction;
42 class QMenu;
43 class qSlicerSubjectHierarchyPluginLogicPrivate;
45 
49 class Q_SLICER_MODULE_SUBJECTHIERARCHY_WIDGETS_EXPORT qSlicerSubjectHierarchyPluginLogic :
50  public QObject, public virtual qSlicerObject
51 {
52  Q_OBJECT
53  QVTK_OBJECT
54 
57  Q_PROPERTY(QStringList allowedViewContextMenuActionNames READ allowedViewContextMenuActionNames WRITE setAllowedViewContextMenuActionNames)
59  Q_PROPERTY(QStringList registeredViewContextMenuActionNames READ registeredViewContextMenuActionNames)
60 
61 public:
62  typedef QObject Superclass;
63  qSlicerSubjectHierarchyPluginLogic(QObject *parent=nullptr);
65 
66 public:
68  void setMRMLScene(vtkMRMLScene* scene) override;
69 
71  Q_INVOKABLE qSlicerSubjectHierarchyAbstractPlugin* subjectHierarchyPluginByName(QString name)const;
72 
74  Q_INVOKABLE vtkIdType currentSubjectHierarchyItem()const;
75 
78  Q_INVOKABLE void setCurrentSubjectHierarchyItem(vtkIdType itemID);
79 
83  void registerCorePlugins();
84 
87  QStringList registeredViewContextMenuActionNames();
88 
94  void setAllowedViewContextMenuActionNames(QStringList actionObjectNames);
95 
97  QStringList allowedViewContextMenuActionNames() const;
98 
104  Q_INVOKABLE void setAllowedViewContextMenuActionNamesForItem(vtkIdType itemID, const QStringList& actionObjectNames);
105 
108  Q_INVOKABLE QStringList allowedViewContextMenuActionNamesForItem(vtkIdType itemID);
109 
116  static Q_INVOKABLE QString buildMenuFromActions(QMenu* menu, QList< QAction* > actions, const QStringList& allowedActions=QStringList());
117 
118 protected:
120  void observeNode(vtkMRMLNode* node);
121 
126  void addSupportedDataNodesToSubjectHierarchy();
127 
129  void registerViewContextMenuAction(QAction* action);
130 
131 protected slots:
133  void onNodeAdded(vtkObject* scene, vtkObject* nodeObject);
136  void onNodeAboutToBeRemoved(vtkObject* scene, vtkObject* nodeObject);
139  void onNodeRemoved(vtkObject* scene, vtkObject* nodeObject);
143  void onSceneImportEnded(vtkObject* sceneObject);
145  void onSceneCloseEnded(vtkObject* sceneObject);
148  void onSceneRestoreEnded(vtkObject* sceneObject);
151  void onSceneBatchProcessEnded(vtkObject* sceneObject);
152 
154  void onDisplayNodeModified(vtkObject*, vtkObject*);
156  void onDisplayMenuEvent(vtkObject*, vtkObject*);
158  void editProperties();
159 
160 protected:
161  QScopedPointer<qSlicerSubjectHierarchyPluginLogicPrivate> d_ptr;
162 
163 private:
164  Q_DECLARE_PRIVATE(qSlicerSubjectHierarchyPluginLogic);
165  Q_DISABLE_COPY(qSlicerSubjectHierarchyPluginLogic);
167 };
168 
169 #endif
Abstract plugin for handling Subject Hierarchy items.
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.