Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerSegmentEditorAbstractEffect.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4  Queen's University, Kingston, ON, Canada. All Rights Reserved.
5 
6  See COPYRIGHT.txt
7  or http://www.slicer.org/copyright/copyright.txt for details.
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 
15  This file was originally developed by Csaba Pinter, PerkLab, Queen's University
16  and was supported through the Applied Cancer Research Unit program of Cancer Care
17  Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
18 
19 ==============================================================================*/
20 
21 #ifndef __qSlicerSegmentEditorAbstractEffect_h
22 #define __qSlicerSegmentEditorAbstractEffect_h
23 
24 // Segmentations Editor Effects includes
25 #include "qSlicerSegmentationsEditorEffectsExport.h"
26 
27 // Qt includes
28 #include <QCursor>
29 #include <QIcon>
30 #include <QPoint>
31 #include <QList>
32 #include <QVector3D>
33 
34 class qSlicerSegmentEditorAbstractEffectPrivate;
35 
36 class vtkActor2D;
38 class vtkMRMLScene;
42 class vtkSegment;
43 class vtkRenderer;
44 class vtkRenderWindow;
45 class vtkRenderWindowInteractor;
47 class vtkProp3D;
48 class qMRMLWidget;
49 class qMRMLSliceWidget;
50 class QColor;
51 class QFormLayout;
52 class QFrame;
53 class QLayout;
54 
57 class Q_SLICER_SEGMENTATIONS_EFFECTS_EXPORT qSlicerSegmentEditorAbstractEffect : public QObject
58 {
59 public:
60  Q_OBJECT
61  Q_ENUMS(ModificationMode)
62 
63 
64  Q_PROPERTY(QString name READ name WRITE setName)
67 
68 
69  Q_PROPERTY(bool perSegment READ perSegment WRITE setPerSegment)
73 
74 
75  Q_PROPERTY(bool showEffectCursorInSliceView READ showEffectCursorInSliceView WRITE setShowEffectCursorInSliceView)
77 
78 
79  Q_PROPERTY(bool showEffectCursorInThreeDView READ showEffectCursorInThreeDView WRITE setShowEffectCursorInThreeDView)
81 
82 public:
83  typedef QObject Superclass;
84  qSlicerSegmentEditorAbstractEffect(QObject* parent = NULL);
86 
87 // API: Methods that are to be reimplemented in the effect subclasses
88 public:
89 
91  {
94  ModificationModeRemove
95  };
96 
98  virtual QIcon icon() { return QIcon(); };
99 
101  Q_INVOKABLE virtual const QString helpText()const { return QString(); };
102 
104  virtual qSlicerSegmentEditorAbstractEffect* clone() = 0;
105 
108  Q_INVOKABLE virtual void activate();
109 
112  Q_INVOKABLE virtual void deactivate();
113 
115  Q_INVOKABLE virtual bool active();
116 
117  Q_INVOKABLE virtual void modifySelectedSegmentByLabelmap(vtkOrientedImageData* modifierLabelmap, ModificationMode modificationMode, const int modificationExtent[6]);
118  Q_INVOKABLE virtual void modifySelectedSegmentByLabelmap(vtkOrientedImageData* modifierLabelmap, ModificationMode modificationMode);
119  Q_INVOKABLE virtual void modifySelectedSegmentByLabelmap(vtkOrientedImageData* modifierLabelmap, ModificationMode modificationMode, QList<int> extent);
120 
127  Q_INVOKABLE static void applyImageMask(vtkOrientedImageData* input, vtkOrientedImageData* mask, double fillValue, bool notMask = false);
128 
131  virtual void setupOptionsFrame() { };
132 
134  virtual QCursor createCursor(qMRMLWidget* viewWidget);
135 
141  virtual bool processInteractionEvents(vtkRenderWindowInteractor* callerInteractor, unsigned long eid, qMRMLWidget* viewWidget)
142  { Q_UNUSED(callerInteractor); Q_UNUSED(eid); Q_UNUSED(viewWidget); return false; };
143 
148  virtual void processViewNodeEvents(vtkMRMLAbstractViewNode* callerViewNode, unsigned long eid, qMRMLWidget* viewWidget)
149  { Q_UNUSED(callerViewNode); Q_UNUSED(eid); Q_UNUSED(viewWidget); };
150 
153  virtual void setMRMLDefaults() = 0;
154 
157  virtual void referenceGeometryChanged() { };
160  virtual void masterVolumeNodeChanged() { };
162  virtual void layoutChanged() { };
165  virtual void interactionNodeModified(vtkMRMLInteractionNode* interactionNode);
166 
167 public slots:
170  virtual void updateGUIFromMRML() = 0;
171 
174  virtual void updateMRMLFromGUI() = 0;
175 
176 // Get/set methods
177 public:
179  Q_INVOKABLE vtkMRMLSegmentEditorNode* parameterSetNode();
181  Q_INVOKABLE void setParameterSetNode(vtkMRMLSegmentEditorNode* node);
182 
184  Q_INVOKABLE vtkMRMLScene* scene();
185 
187  Q_INVOKABLE QFrame* optionsFrame();
188 
190  Q_INVOKABLE QFormLayout* optionsLayout();
191 
194  Q_INVOKABLE void addActor2D(qMRMLWidget* viewWidget, vtkActor2D* actor);
195 
197  Q_INVOKABLE void removeActor2D(qMRMLWidget* viewWidget, vtkActor2D* actor);
198 
201  Q_INVOKABLE void addActor3D(qMRMLWidget* viewWidget, vtkProp3D* actor);
202 
204  Q_INVOKABLE void removeActor3D(qMRMLWidget* viewWidget, vtkProp3D* actor);
205 
209  Q_INVOKABLE void addOptionsWidget(QWidget* newOptionsWidget);
210  Q_INVOKABLE void addOptionsWidget(QLayout* newOptionsWidget);
211 
212  Q_INVOKABLE QWidget* addLabeledOptionsWidget(QString label, QWidget* newOptionsWidget);
213  Q_INVOKABLE QWidget* addLabeledOptionsWidget(QString label, QLayout* newOptionsWidget);
214 
216  virtual QString name()const;
219  virtual void setName(QString name);
220 
222  virtual bool perSegment()const;
225  virtual void setPerSegment(bool perSegment);
226 
228  Q_INVOKABLE void cursorOff(qMRMLWidget* viewWidget);
230  Q_INVOKABLE void cursorOn(qMRMLWidget* viewWidget);
231 
234  Q_INVOKABLE void selectEffect(QString effectName);
235 
240  void setCallbackSlots(QObject* receiver, const char* selectEffectSlot, const char* updateVolumeSlot, const char* saveStateForUndoSlot);
241 
243  void setVolumes(vtkOrientedImageData* alignedMasterVolume, vtkOrientedImageData* modifierLabelmap,
244  vtkOrientedImageData* maskLabelmap, vtkOrientedImageData* selectedSegmentLabelmap, vtkOrientedImageData* referenceGeometryImage);
245 
246 // Effect parameter functions
247 public:
249  Q_INVOKABLE QString parameter(QString name);
250 
252  Q_INVOKABLE int integerParameter(QString name);
253 
255  Q_INVOKABLE double doubleParameter(QString name);
256 
260  Q_INVOKABLE void setParameter(QString name, QString value);
263  Q_INVOKABLE void setParameterDefault(QString name, QString value);
270  Q_INVOKABLE void setCommonParameter(QString name, QString value);
273  Q_INVOKABLE void setCommonParameterDefault(QString name, QString value);
274 
278  Q_INVOKABLE void setParameter(QString name, int value);
281  Q_INVOKABLE void setParameterDefault(QString name, int value);
283  Q_INVOKABLE void setCommonParameter(QString name, int value);
286  Q_INVOKABLE void setCommonParameterDefault(QString name, int value);
287 
291  Q_INVOKABLE void setParameter(QString name, double value);
294  Q_INVOKABLE void setParameterDefault(QString name, double value);
296  Q_INVOKABLE void setCommonParameter(QString name, double value);
299  Q_INVOKABLE void setCommonParameterDefault(QString name, double value);
300 
301 // Utility functions
302 public:
304  Q_INVOKABLE bool parameterDefined(QString name);
305 
307  Q_INVOKABLE bool commonParameterDefined(QString name);
308 
309  Q_INVOKABLE vtkOrientedImageData* modifierLabelmap();
310 
313  Q_INVOKABLE vtkOrientedImageData* defaultModifierLabelmap();
314 
315  Q_INVOKABLE vtkOrientedImageData* maskLabelmap();
316 
317  Q_INVOKABLE vtkOrientedImageData* selectedSegmentLabelmap();
318 
319  Q_INVOKABLE vtkOrientedImageData* referenceGeometryImage();
320 
321  void setShowEffectCursorInSliceView(bool show);
322  void setShowEffectCursorInThreeDView(bool show);
323 
324  bool showEffectCursorInSliceView();
325  bool showEffectCursorInThreeDView();
326 
329  Q_INVOKABLE vtkOrientedImageData* masterVolumeImageData();
330 
333  Q_INVOKABLE void saveStateForUndo();
334 
336  Q_INVOKABLE static vtkRenderWindow* renderWindow(qMRMLWidget* viewWidget);
338  Q_INVOKABLE static vtkRenderer* renderer(qMRMLWidget* viewWidget);
340  Q_INVOKABLE static vtkMRMLAbstractViewNode* viewNode(qMRMLWidget* viewWidget);
341 
343  static QPoint rasToXy(double ras[3], qMRMLSliceWidget* sliceWidget);
345  Q_INVOKABLE static QPoint rasToXy(QVector3D ras, qMRMLSliceWidget* sliceWidget);
350  static void xyzToRas(double inputXyz[3], double outputRas[3], qMRMLSliceWidget* sliceWidget);
352  Q_INVOKABLE static QVector3D xyzToRas(QVector3D inputXyz, qMRMLSliceWidget* sliceWidget);
354  static void xyToRas(QPoint xy, double outputRas[3], qMRMLSliceWidget* sliceWidget);
356  static void xyToRas(double xy[2], double outputRas[3], qMRMLSliceWidget* sliceWidget);
358  Q_INVOKABLE static QVector3D xyToRas(QPoint xy, qMRMLSliceWidget* sliceWidget);
360  static void xyzToIjk(double inputXyz[3], int outputIjk[3], qMRMLSliceWidget* sliceWidget, vtkOrientedImageData* image);
362  Q_INVOKABLE static QVector3D xyzToIjk(QVector3D inputXyz, qMRMLSliceWidget* sliceWidget, vtkOrientedImageData* image);
364  static void xyToIjk(QPoint xy, int outputIjk[3], qMRMLSliceWidget* sliceWidget, vtkOrientedImageData* image);
366  static void xyToIjk(double xy[2], int outputIjk[3], qMRMLSliceWidget* sliceWidget, vtkOrientedImageData* image);
368  Q_INVOKABLE static QVector3D xyToIjk(QPoint xy, qMRMLSliceWidget* sliceWidget, vtkOrientedImageData* image);
369 
370  Q_INVOKABLE static void forceRender(qMRMLWidget* viewWidget);
371  Q_INVOKABLE static void scheduleRender(qMRMLWidget* viewWidget);
372 
373  Q_INVOKABLE static double sliceSpacing(qMRMLSliceWidget* sliceWidget);
374 
375  Q_INVOKABLE bool segmentationDisplayableInView(vtkMRMLAbstractViewNode* viewNode);
376 
377 protected:
379  QString m_Name;
380  bool m_Active;
381 
387 
390 
391  double m_FillValue;
392  double m_EraseValue;
393 
394 protected:
395  QScopedPointer<qSlicerSegmentEditorAbstractEffectPrivate> d_ptr;
396 
397 private:
398  Q_DECLARE_PRIVATE(qSlicerSegmentEditorAbstractEffect);
399  Q_DISABLE_COPY(qSlicerSegmentEditorAbstractEffect);
400 };
401 
402 #endif
This class encapsulates a segment that is part of a segmentation.
Definition: vtkSegment.h:45
virtual bool processInteractionEvents(vtkRenderWindowInteractor *callerInteractor, unsigned long eid, qMRMLWidget *viewWidget)
virtual Q_INVOKABLE const QString helpText() const
Get help text for effect to be displayed in the help box.
Abstract class for segment editor effects.
Image data containing orientation information.
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:54
Parameter set node for the segment editor widget.
Base class for any widget that requires a MRML Scene.
Definition: qMRMLWidget.h:35
QScopedPointer< qSlicerSegmentEditorAbstractEffectPrivate > d_ptr
virtual void processViewNodeEvents(vtkMRMLAbstractViewNode *callerViewNode, unsigned long eid, qMRMLWidget *viewWidget)
virtual QIcon icon()
Get icon for effect to be displayed in segment editor.
virtual void layoutChanged()
Simple mechanism to let the effects know that the layout has changed.
MRML node containing segmentationsSegmentation node stores a set of segments (also known as contours ...