Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerSubjectHierarchyAbstractPlugin.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 __qSlicerSubjectHierarchyAbstractPlugin_h
24 #define __qSlicerSubjectHierarchyAbstractPlugin_h
25 
26 // Qt includes
27 #include <QObject>
28 #include <QMap>
29 #include <QStringList>
30 #include <QIcon>
31 #include <QVariant>
32 
33 // MRML includes
35 
36 #include "qSlicerSubjectHierarchyModuleWidgetsExport.h"
37 
38 class QStandardItem;
39 class QAction;
40 class QColor;
43 
65 class Q_SLICER_MODULE_SUBJECTHIERARCHY_WIDGETS_EXPORT qSlicerSubjectHierarchyAbstractPlugin : public QObject
66 {
67  Q_OBJECT
68  Q_ENUMS(ActionSectionType)
69 
70 
71  Q_PROPERTY(QString name READ name WRITE setName)
74 
75 public:
76  typedef QObject Superclass;
77  qSlicerSubjectHierarchyAbstractPlugin(QObject* parent = nullptr);
79 
80 // Role-related virtual methods
81 // If the subclass plugin does not offer a role, these do not need to be overridden
82 public:
89  Q_INVOKABLE virtual double canOwnSubjectHierarchyItem(vtkIdType itemID)const;
90 
93  Q_INVOKABLE virtual const QString roleForPlugin()const;
94 
96  virtual const QString helpText()const;
97 
100  virtual QIcon icon(vtkIdType itemID);
101 
103  Q_INVOKABLE virtual QIcon visibilityIcon(int visible);
104 
106  Q_INVOKABLE virtual bool canEditProperties(vtkIdType itemID);
107 
109  Q_INVOKABLE virtual void editProperties(vtkIdType itemID);
110 
113  virtual QString displayedItemName(vtkIdType itemID)const;
114 
116  Q_INVOKABLE virtual QString tooltip(vtkIdType itemID)const;
117 
119  Q_INVOKABLE virtual void setDisplayVisibility(vtkIdType itemID, int visible);
120 
123  Q_INVOKABLE virtual int getDisplayVisibility(vtkIdType itemID)const;
124 
132  Q_INVOKABLE virtual void setDisplayColor(vtkIdType itemID, QColor color, QMap<int, QVariant> terminologyMetaData);
133 
140  Q_INVOKABLE virtual QColor getDisplayColor(vtkIdType itemID, QMap<int, QVariant> &terminologyMetaData)const;
141 
142  // Function related virtual methods
143 public:
146  Q_INVOKABLE virtual QList<QAction*> itemContextMenuActions()const;
147 
152  Q_INVOKABLE virtual QList<QAction*> sceneContextMenuActions()const;
153 
156  Q_INVOKABLE virtual void showContextMenuActionsForItem(vtkIdType itemID) { Q_UNUSED(itemID); };
157 
160  Q_INVOKABLE virtual QList<QAction*> visibilityContextMenuActions()const;
161 
164  Q_INVOKABLE virtual void showVisibilityContextMenuActionsForItem(vtkIdType itemID) { Q_UNUSED(itemID); };
165 
169  Q_INVOKABLE virtual QList<QAction*> viewContextMenuActions()const;
170 
174  Q_INVOKABLE virtual void showViewContextMenuActionsForItem(vtkIdType itemID, QVariantMap eventData) { Q_UNUSED(itemID); Q_UNUSED(eventData); };
175 
176 // Parenting related virtual methods with default implementation
177 public:
187  virtual double canAddNodeToSubjectHierarchy(
188  vtkMRMLNode* node, vtkIdType parentItemID=vtkMRMLSubjectHierarchyNode::INVALID_ITEM_ID )const;
189 
195  virtual bool addNodeToSubjectHierarchy(vtkMRMLNode* node, vtkIdType parentItemID);
196 
205  virtual double canReparentItemInsideSubjectHierarchy(vtkIdType itemID, vtkIdType parentItemID)const;
206 
209  virtual bool reparentItemInsideSubjectHierarchy(vtkIdType itemID, vtkIdType parentItemID);
210 
215  virtual bool showItemInView(vtkIdType itemID, vtkMRMLAbstractViewNode* viewNode, vtkIdList* allItemsToShow);
216 
217 // Utility functions
218 public:
220  Q_INVOKABLE bool isThisPluginOwnerOfItem(vtkIdType itemID)const;
221 
224  Q_INVOKABLE static qSlicerAbstractModuleWidget* switchToModule(QString moduleName);
225 
226 public:
228  virtual QString name()const;
229 
232  virtual void setName(QString name);
233 
235  {
236  SectionTop = -400,
237  SectionInteraction = -300,
238  SectionComponent = -200,
239  SectionNode = -100,
240  SectionDefault = 0,
241  SectionFolder = 100,
242  SectionBottom = 200,
243  };
244 
254  Q_INVOKABLE static void setActionPosition(QAction* action, int section, int weight = 0, double weightAdjustment = 0.0);
255 
256 signals:
258  void requestExpandItem(vtkIdType itemID);
259 
262  void requestInvalidateFilter()const;
263 
264 protected:
269  void hideAllContextMenuActions()const;
270 
271 protected:
273  QString m_Name;
274 
275 private:
277  void operator=(const qSlicerSubjectHierarchyAbstractPlugin&); // Not implemented
280 };
281 
282 #endif
Abstract plugin for handling Subject Hierarchy items.
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D...
Qt-based logic class to exercise Qt-related logic functions. The Subject hierarchy plugin mechanism a...
virtual Q_INVOKABLE void showContextMenuActionsForItem(vtkIdType itemID)
virtual Q_INVOKABLE void showViewContextMenuActionsForItem(vtkIdType itemID, QVariantMap eventData)
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
virtual Q_INVOKABLE void showVisibilityContextMenuActionsForItem(vtkIdType itemID)