Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qMRMLSegmentEditorWidget.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 __qMRMLSegmentEditorWidget_h
24 #define __qMRMLSegmentEditorWidget_h
25 
26 // Segmentations includes
27 #include "qSlicerSegmentationsModuleWidgetsExport.h"
28 
29 // MRMLWidgets includes
30 #include "qMRMLWidget.h"
31 
32 // Qt includes
33 #include <QVariant>
34 
35 // CTK includes
36 #include <ctkVTKObject.h>
37 
38 // STD includes
39 #include <cstdlib>
40 
41 class vtkMRMLNode;
44 class vtkMRMLVolumeNode;
45 class vtkObject;
46 class QItemSelection;
47 class QAbstractButton;
48 class qMRMLSegmentEditorWidgetPrivate;
51 
64 class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_EXPORT qMRMLSegmentEditorWidget : public qMRMLWidget
65 {
66  Q_OBJECT
67  QVTK_OBJECT
68  Q_PROPERTY(bool segmentationNodeSelectorVisible READ segmentationNodeSelectorVisible WRITE setSegmentationNodeSelectorVisible)
69  Q_PROPERTY(bool masterVolumeNodeSelectorVisible READ masterVolumeNodeSelectorVisible WRITE setMasterVolumeNodeSelectorVisible)
70  Q_PROPERTY(bool autoShowMasterVolumeNode READ autoShowMasterVolumeNode WRITE setAutoShowMasterVolumeNode)
71  Q_PROPERTY(bool switchToSegmentationsButtonVisible READ switchToSegmentationsButtonVisible WRITE setSwitchToSegmentationsButtonVisible)
72  Q_PROPERTY(bool undoEnabled READ undoEnabled WRITE setUndoEnabled)
73  Q_PROPERTY(int maximumNumberOfUndoStates READ maximumNumberOfUndoStates WRITE setMaximumNumberOfUndoStates)
74  Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly)
75  Q_PROPERTY(Qt::ToolButtonStyle effectButtonStyle READ effectButtonStyle WRITE setEffectButtonStyle)
76  Q_PROPERTY(bool unorderedEffectsVisible READ unorderedEffectsVisible WRITE setUnorderedEffectsVisible)
77 
78 public:
81  explicit qMRMLSegmentEditorWidget(QWidget* parent = 0);
83  virtual ~qMRMLSegmentEditorWidget();
84 
86  Q_INVOKABLE vtkMRMLSegmentEditorNode* mrmlSegmentEditorNode()const;
87 
89  Q_INVOKABLE vtkMRMLNode* segmentationNode()const;
91  Q_INVOKABLE QString segmentationNodeID()const;
93  Q_INVOKABLE vtkMRMLNode* masterVolumeNode()const;
95  Q_INVOKABLE QString masterVolumeNodeID()const;
96 
98  Q_INVOKABLE QString currentSegmentID()const;
99 
102  Q_INVOKABLE qSlicerSegmentEditorAbstractEffect* activeEffect()const;
105  Q_INVOKABLE void setActiveEffect(qSlicerSegmentEditorAbstractEffect* effect);
106 
109  Q_INVOKABLE qSlicerSegmentEditorAbstractEffect* effectByName(QString name);
110 
112  Q_INVOKABLE QStringList availableEffectNames();
113 
116  Q_INVOKABLE void setEffectNameOrder(const QStringList& effectNames);
117 
121  Q_INVOKABLE QStringList effectNameOrder() const;
122 
126  void setUnorderedEffectsVisible(bool visible);
127 
130  bool unorderedEffectsVisible() const;
131 
134  Q_INVOKABLE int effectCount();
135 
138  Q_INVOKABLE qSlicerSegmentEditorAbstractEffect* effectByIndex(int index);
139 
144  Q_INVOKABLE void setupViewObservations();
145 
149  Q_INVOKABLE void removeViewObservations();
150 
152  bool segmentationNodeSelectorVisible() const;
154  bool masterVolumeNodeSelectorVisible() const;
158  bool autoShowMasterVolumeNode() const;
160  bool switchToSegmentationsButtonVisible() const;
162  bool undoEnabled() const;
164  int maximumNumberOfUndoStates() const;
166  bool readOnly() const;
167 
170  Qt::ToolButtonStyle effectButtonStyle() const;
171 
174  Q_INVOKABLE void segmentationNodeSelectorAddAttribute(const QString& nodeType,
175  const QString& attributeName,
176  const QVariant& attributeValue = QVariant());
179  Q_INVOKABLE void segmentationNodeSelectorRemoveAttribute(const QString& nodeType,
180  const QString& attributeName);
181 
184  Q_INVOKABLE void masterVolumeNodeSelectorAddAttribute(const QString& nodeType,
185  const QString& attributeName,
186  const QVariant& attributeValue = QVariant());
189  Q_INVOKABLE void masterVolumeNodeSelectorRemoveAttribute(const QString& nodeType,
190  const QString& attributeName);
191 
192 public slots:
194  virtual void setMRMLScene(vtkMRMLScene* newScene);
195 
197  void setMRMLSegmentEditorNode(vtkMRMLSegmentEditorNode* newSegmentEditorNode);
198 
200  virtual void updateWidgetFromMRML();
201 
203  void setSegmentationNode(vtkMRMLNode* node);
205  void setSegmentationNodeID(const QString& nodeID);
207  void setMasterVolumeNode(vtkMRMLNode* node);
209  void setMasterVolumeNodeID(const QString& nodeID);
210 
212  void setCurrentSegmentID(const QString segmentID);
213 
215  void setActiveEffectByName(QString effectName);
216 
219  void saveStateForUndo();
220 
222  void updateVolume(void* volumePtr, bool& success);
223 
225  void setSegmentationNodeSelectorVisible(bool);
227  void setMasterVolumeNodeSelectorVisible(bool);
231  void setAutoShowMasterVolumeNode(bool);
233  void setSwitchToSegmentationsButtonVisible(bool);
235  void setUndoEnabled(bool);
237  void setMaximumNumberOfUndoStates(int);
239  void setReadOnly(bool aReadOnly);
241  void toggleMasterVolumeIntensityMaskEnabled();
242 
244  void undo();
245 
247  void redo();
248 
252  void installKeyboardShortcuts(QWidget* parent = NULL);
253 
255  void uninstallKeyboardShortcuts();
256 
260  bool turnOffLightboxes();
261 
263  void hideLabelLayer();
264 
267  void setEffectButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
268 
270  void updateEffectLayouts();
271 
276  void showMasterVolumeInSliceViewers(bool forceShowInBackground = false, bool fitSlice = false);
277 
278 signals:
280  void currentSegmentIDChanged(const QString&);
281 
284  void masterVolumeNodeChanged(vtkMRMLVolumeNode*);
285 
288  void segmentationNodeChanged(vtkMRMLSegmentationNode*);
289 
290 protected slots:
292  void onSegmentationNodeChanged(vtkMRMLNode* node);
294  void onMasterVolumeNodeChanged(vtkMRMLNode* node);
296  void onSegmentSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
297 
299  void onInteractionNodeModified();
300 
302  void onEffectButtonClicked(QAbstractButton* button);
303 
307  void onSelectEffectShortcut();
308 
310  void onSelectSegmentShortcut();
311 
313  void onAddSegment();
315  void onRemoveSegment();
317  void onSwitchToSegmentations();
319  void onCreateSurfaceToggled(bool on);
321  void onSegmentAddedRemoved();
323  void onMasterVolumeImageDataModified();
325  void onLayoutChanged(int layoutIndex);
327  void onSegmentationDisplayModified();
328 
330  void onMaskModeChanged(int);
331 
333  void onMasterVolumeIntensityMaskChecked(bool checked);
335  void onMasterVolumeIntensityMaskRangeChanged(double low, double high);
336 
338  void onOverwriteModeChanged(int);
339 
341  void onMRMLSceneEndCloseEvent();
342 
344  void initializeParameterSetNode();
345 
347  void onSegmentationHistoryChanged();
348 
350  void anchorClicked(const QUrl &url);
351 
353  void onSetSurfaceSmoothingClicked();
355  void onImportExportActionClicked();
356 
358  void updateMaskingSection();
359 
360 protected:
362  static void processEvents(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
363 
364  void updateWidgetFromSegmentationNode();
365  void updateWidgetFromMasterVolumeNode();
366  void updateEffectsSectionFromMRML();
367 
370  bool setMasterRepresentationToBinaryLabelmap();
371 
373  qSlicerAbstractModuleWidget* switchToSegmentationsModule();
374 
375 protected:
376  QScopedPointer<qMRMLSegmentEditorWidgetPrivate> d_ptr;
377 
378 private:
379  Q_DECLARE_PRIVATE(qMRMLSegmentEditorWidget);
380  Q_DISABLE_COPY(qMRMLSegmentEditorWidget);
381 };
382 
383 #endif
Abstract class for segment editor effects.
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
QWidget Superclass
Definition: qMRMLWidget.h:40
MRML node for representing a volume (image stack).
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
MRML node containing segmentationsSegmentation node stores a set of segments (also known as contours ...
Qt widget for editing a segment from a segmentation using Editor effects.Widget for editing segmentat...