Slicer 5.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
41class vtkMRMLNode;
46class vtkObject;
47class QItemSelection;
48class QAbstractButton;
49class qMRMLSegmentEditorWidgetPrivate;
52
64class 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 sourceVolumeNodeSelectorVisible READ sourceVolumeNodeSelectorVisible WRITE setSourceVolumeNodeSelectorVisible)
70 Q_PROPERTY(bool maskingSectionVisible READ maskingSectionVisible WRITE setMaskingSectionVisible)
71 Q_PROPERTY(bool specifyGeometryButtonVisible READ specifyGeometryButtonVisible WRITE setSpecifyGeometryButtonVisible)
72 Q_PROPERTY(bool show3DButtonVisible READ show3DButtonVisible WRITE setShow3DButtonVisible)
73 Q_PROPERTY(bool addRemoveSegmentButtonsVisible READ addRemoveSegmentButtonsVisible WRITE setAddRemoveSegmentButtonsVisible)
74 Q_PROPERTY(bool autoShowSourceVolumeNode READ autoShowSourceVolumeNode WRITE setAutoShowSourceVolumeNode)
75 Q_PROPERTY(bool masterVolumeNodeSelectorVisible READ masterVolumeNodeSelectorVisible WRITE setMasterVolumeNodeSelectorVisible) // deprecated
76 Q_PROPERTY(bool autoShowMasterVolumeNode READ autoShowMasterVolumeNode WRITE setAutoShowMasterVolumeNode) // deprecated
77 Q_PROPERTY(bool switchToSegmentationsButtonVisible READ switchToSegmentationsButtonVisible WRITE setSwitchToSegmentationsButtonVisible)
78 Q_PROPERTY(bool undoEnabled READ undoEnabled WRITE setUndoEnabled)
79 Q_PROPERTY(int maximumNumberOfUndoStates READ maximumNumberOfUndoStates WRITE setMaximumNumberOfUndoStates)
80 Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly)
81 Q_PROPERTY(Qt::ToolButtonStyle effectButtonStyle READ effectButtonStyle WRITE setEffectButtonStyle)
82 Q_PROPERTY(int effectColumnCount READ effectColumnCount WRITE setEffectColumnCount)
83 Q_PROPERTY(bool unorderedEffectsVisible READ unorderedEffectsVisible WRITE setUnorderedEffectsVisible)
84 Q_PROPERTY(QString defaultTerminologyEntrySettingsKey READ defaultTerminologyEntrySettingsKey WRITE setDefaultTerminologyEntrySettingsKey)
85 Q_PROPERTY(QString defaultTerminologyEntry READ defaultTerminologyEntry WRITE setDefaultTerminologyEntry)
86 Q_PROPERTY(bool jumpToSelectedSegmentEnabled READ jumpToSelectedSegmentEnabled WRITE setJumpToSelectedSegmentEnabled)
87
88public:
91 explicit qMRMLSegmentEditorWidget(QWidget* parent = nullptr);
94
96 Q_INVOKABLE vtkMRMLSegmentEditorNode* mrmlSegmentEditorNode()const;
97
99 Q_INVOKABLE vtkMRMLNode* segmentationNode()const;
101 Q_INVOKABLE QString segmentationNodeID()const;
103 Q_INVOKABLE vtkMRMLNode* sourceVolumeNode()const;
105 Q_INVOKABLE QString sourceVolumeNodeID()const;
106
108 Q_INVOKABLE vtkMRMLNode* masterVolumeNode()const
109 {
110 qWarning("qMRMLSegmentEditorWidget::masterVolumeNode is deprecated, use sourceVolumeNode() method instead.");
111 return this->sourceVolumeNode();
112 };
114 Q_INVOKABLE QString masterVolumeNodeID()const
115 {
116 qWarning("qMRMLSegmentEditorWidget::masterVolumeNodeID is deprecated, use sourceVolumeNodeID() method instead.");
117 return this->sourceVolumeNodeID();
118 };
120 Q_INVOKABLE QString currentSegmentID()const;
121
128
132
134 Q_INVOKABLE QStringList availableEffectNames();
135
138 Q_INVOKABLE void setEffectNameOrder(const QStringList& effectNames);
139
143 Q_INVOKABLE QStringList effectNameOrder() const;
144
148 void setUnorderedEffectsVisible(bool visible);
149
153
156 Q_INVOKABLE int effectCount();
157
161
166 Q_INVOKABLE void setupViewObservations();
167
171 Q_INVOKABLE void removeViewObservations();
172
181
184 {
185 qWarning("qMRMLSegmentEditorWidget::masterVolumeNodeSelectorVisible is deprecated, use sourceVolumeNodeSelectorVisible() method instead.");
186 return this->sourceVolumeNodeSelectorVisible();
187 };
190 {
191 qWarning("qMRMLSegmentEditorWidget::autoShowMasterVolumeNode is deprecated, use autoShowSourceVolumeNode() method instead.");
192 return this->autoShowSourceVolumeNode();
193 };
194
197
200
203
206
210 bool undoEnabled() const;
214 bool readOnly() const;
215
218 Qt::ToolButtonStyle effectButtonStyle() const;
219
222 int effectColumnCount() const;
223
226 Q_INVOKABLE void segmentationNodeSelectorAddAttribute(const QString& nodeType,
227 const QString& attributeName,
228 const QVariant& attributeValue = QVariant());
231 Q_INVOKABLE void segmentationNodeSelectorRemoveAttribute(const QString& nodeType,
232 const QString& attributeName);
233
236 Q_INVOKABLE void sourceVolumeNodeSelectorAddAttribute(const QString& nodeType,
237 const QString& attributeName,
238 const QVariant& attributeValue = QVariant());
241 Q_INVOKABLE void sourceVolumeNodeSelectorRemoveAttribute(const QString& nodeType,
242 const QString& attributeName);
243
245 Q_INVOKABLE void masterVolumeNodeSelectorAddAttribute(const QString& nodeType,
246 const QString& attributeName,
247 const QVariant& attributeValue = QVariant())
248 {
249 qWarning("qMRMLSegmentEditorWidget::masterVolumeNodeSelectorAddAttribute is deprecated, use sourceVolumeNodeSelectorAddAttribute method instead.");
250 this->sourceVolumeNodeSelectorAddAttribute(nodeType, attributeName, attributeValue);
251 }
253 Q_INVOKABLE void masterVolumeNodeSelectorRemoveAttribute(const QString& nodeType,
254 const QString& attributeName)
255 {
256 qWarning("qMRMLSegmentEditorWidget::masterVolumeNodeSelectorRemoveAttribute is deprecated,"
257 " use sourceVolumeNodeSelectorRemoveAttribute instead.");
258 this->sourceVolumeNodeSelectorRemoveAttribute(nodeType, attributeName);
259 }
260
264
271 void setDefaultTerminologyEntrySettingsKey(const QString& terminologyEntrySettingsKey);
275
278 void setDefaultTerminologyEntry(const QString& terminologyEntry);
282
285
286public slots:
288 void setMRMLScene(vtkMRMLScene* newScene) override;
289
292
294 virtual void updateWidgetFromMRML();
295
299 void setSegmentationNodeID(const QString& nodeID);
305 void setSourceVolumeNodeID(const QString& nodeID);
306
309 {
310 qWarning("qMRMLSegmentEditorWidget::setMasterVolumeNode is deprecated, use setSourceVolumeNode method instead.");
311 this->setSourceVolumeNode(node);
312 }
314 void setMasterVolumeNodeID(const QString& nodeID)
315 {
316 qWarning("qMRMLSegmentEditorWidget::setMasterVolumeNodeID is deprecated, use setSourceVolumeNodeID method instead.");
317 this->setSourceVolumeNodeID(nodeID);
318 }
319
321 void setCurrentSegmentID(const QString segmentID);
322
324 void setActiveEffectByName(QString effectName);
325
329
331 void updateVolume(void* volumePtr, bool& success);
332
356 void setUndoEnabled(bool);
360 void setReadOnly(bool aReadOnly);
363
366 {
367 qWarning("qMRMLSegmentEditorWidget::setMasterVolumeNodeSelectorVisible is deprecated, use setSourceVolumeNodeSelectorVisible method instead.");
368 this->setSourceVolumeNodeSelectorVisible(visible);
369 }
371 void setAutoShowMasterVolumeNode(bool autoShow)
372 {
373 qWarning("qMRMLSegmentEditorWidget::setAutoShowMasterVolumeNode is deprecated, use setAutoShowSourceVolumeNode method instead.");
374 this->setAutoShowSourceVolumeNode(autoShow);
375 }
378 {
379 qWarning("qMRMLSegmentEditorWidget::toggleMasterVolumeIntensityMaskEnabled is deprecated, use toggleSourceVolumeIntensityMaskEnabled method instead.");
380 this->toggleSourceVolumeIntensityMaskEnabled();
381 }
382
384 void undo();
385
387 void redo();
388
392 void installKeyboardShortcuts(QWidget* parent = nullptr);
393
396
401
404
407 void setEffectButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
408
410 void setEffectColumnCount(int columnCount);
411
416
421 void showSourceVolumeInSliceViewers(bool forceShowInBackground = false, bool fitSlice = false);
422
423 // Deprecated. Use showSourceVolumeInSliceViewers method instead.
424 void showMasterVolumeInSliceViewers(bool forceShowInBackground = false, bool fitSlice = false)
425 {
426 qWarning("qMRMLSegmentEditorWidget::showMasterVolumeInSliceViewers is deprecated, use showSourceVolumeInSliceViewers method instead.");
427 this->showSourceVolumeInSliceViewers(forceShowInBackground, fitSlice);
428 }
429
433
437
440
443
447 void selectSegmentAtOffset (int offset);
448
452
455
456signals:
458 void currentSegmentIDChanged(const QString&);
459
463
466
470
471protected slots:
477 void onSegmentSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
478
481
483 void onEffectButtonClicked(QAbstractButton* button);
484
489
492
506 void onLayoutChanged(int layoutIndex);
509
512
516 void onSourceVolumeIntensityMaskRangeChanged(double low, double high);
517
520
523
526
529
532
535
540
543
546
549
550protected:
552 static void processEvents(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
553
557
561
564
565protected:
566 QScopedPointer<qMRMLSegmentEditorWidgetPrivate> d_ptr;
567
568private:
569 Q_DECLARE_PRIVATE(qMRMLSegmentEditorWidget);
570 Q_DISABLE_COPY(qMRMLSegmentEditorWidget);
571};
572
573#endif
Qt widget for editing a segment from a segmentation using Editor effects.
void setMasterVolumeNodeID(const QString &nodeID)
Deprecated. Use setSourceVolumeNodeID method instead.
int maximumNumberOfUndoStates() const
Get maximum number of saved undo/redo states.
void setMRMLScene(vtkMRMLScene *newScene) override
Set the MRML scene associated with the widget.
void onOverwriteModeChanged(int)
Changed selected overwritable segments.
void initializeParameterSetNode()
Set default parameters in parameter set node (after setting or closing scene)
void onMRMLSceneEndBatchProcessEvent()
Updates needed after batch processing is done.
int effectColumnCount() const
bool switchToSegmentationsButtonVisible() const
Show/hide the switch to Segmentations module button.
void updateWidgetFromSegmentationNode()
void setCurrentSegmentID(const QString segmentID)
Set selected segment by its ID.
QString defaultTerminologyEntry()
void updateVolume(void *volumePtr, bool &success)
Update modifierLabelmap, maskLabelmap, or alignedSourceVolumeNode.
bool maskingSectionVisible() const
Show/hide the masking section.
bool show3DButtonVisible() const
Show/hide the 3D button.
void setAddRemoveSegmentButtonsVisible(bool)
void setJumpToSelectedSegmentEnabled(bool enable)
Enables automatic jumping to current segment when selection is changed.
void toggleMasterVolumeIntensityMaskEnabled()
Deprecated. Use toggleSourceVolumeIntensityMaskEnabled method instead.
Q_INVOKABLE QString currentSegmentID() const
Get segment ID of selected segment.
bool specifyGeometryButtonVisible() const
Show/hide the specify geometry button.
void updateWidgetFromSourceVolumeNode()
void onSourceVolumeNodeChanged(vtkMRMLNode *node)
Handles changing of the current source volume MRML node.
void selectNextSegment()
Select the segment below the currently selected one in the table (skipping segments that are not visi...
Q_INVOKABLE QStringList effectNameOrder() const
void updateSliceRotateWarningButtonVisibility()
Show slice rotation warning button if slice views are rotated, hide otherwise.
void selectSegmentAtOffset(int offset)
QScopedPointer< qMRMLSegmentEditorWidgetPrivate > d_ptr
bool readOnly() const
Get whether widget is read-only.
void hideLabelLayer()
Unselect labelmap layer in all slice views in the active layout.
void setEffectColumnCount(int columnCount)
Request displaying effects in the grid layout with the specified column count.
void onSourceVolumeIntensityMaskChecked(bool checked)
Enable/disable threshold when checkbox is toggled.
void onSwitchToSegmentations()
Edit segmentation properties in Segmentations module.
Q_INVOKABLE void masterVolumeNodeSelectorRemoveAttribute(const QString &nodeType, const QString &attributeName)
Deprecated use sourceVolumeNodeSelectorRemoveAttribute method instead.
void setSourceVolumeNodeSelectorVisible(bool)
Show/hide the source volume node selector widget.
void setSourceVolumeNodeID(const QString &nodeID)
Set source volume MRML node by its ID.
void undo()
Restores previous saved state of the segmentation.
void onExportToFilesActionClicked()
Open Export to files dialog.
void onInteractionNodeModified()
Handles mouse mode changes (view / place markups)
void setSegmentationNodeSelectorVisible(bool)
Show/hide the segmentation node selector widget.
void segmentationNodeChanged(vtkMRMLSegmentationNode *)
bool jumpToSelectedSegmentEnabled() const
Returns true if automatic jump to current segment is enabled.
void redo()
Restores next saved state of the segmentation.
Q_INVOKABLE QStringList availableEffectNames()
Get list of all registered effect names that can be displayed in the widget.
void setMasterVolumeNode(vtkMRMLNode *node)
Deprecated. Use setSourceVolumeNode method instead.
void setMasterVolumeNodeSelectorVisible(bool visible)
Deprecated. Use setSourceVolumeNodeSelectorVisible method instead.
void showSourceVolumeInSliceViewers(bool forceShowInBackground=false, bool fitSlice=false)
void onSegmentationHistoryChanged()
Update GUI if segmentation history is changed (e.g., undo/redo button states)
void setReadOnly(bool aReadOnly)
Set whether the widget is read-only.
void jumpSlices()
Segment's center is determined as the center of bounding box.
bool setSourceRepresentationToBinaryLabelmap()
void sourceVolumeNodeChanged(vtkMRMLVolumeNode *)
bool undoEnabled() const
Undo/redo enabled.
void setMaskingSectionVisible(bool)
void setShow3DButtonVisible(bool)
bool sourceVolumeNodeSelectorVisible() const
Show/hide the source volume node selector widget.
void setSpecifyGeometryButtonVisible(bool)
void setActiveEffectByName(QString effectName)
Set active effect by name.
bool autoShowMasterVolumeNode() const
Deprecated. Use autoShowSourceVolumeNode() method instead.
void toggleSourceVolumeIntensityMaskEnabled()
Enable/disable masking using source volume intensity.
void onSelectSegmentShortcut()
Segment selection shortcut is activated.
void setUnorderedEffectsVisible(bool visible)
bool addRemoveSegmentButtonsVisible() const
Show/hide the add/remove segment buttons.
Q_INVOKABLE void sourceVolumeNodeSelectorAddAttribute(const QString &nodeType, const QString &attributeName, const QVariant &attributeValue=QVariant())
void onMRMLSceneEndCloseEvent()
Clean up when scene is closed.
bool segmentationNodeSelectorVisible() const
Show/hide the segmentation node selector widget.
Q_INVOKABLE void segmentationNodeSelectorAddAttribute(const QString &nodeType, const QString &attributeName, const QVariant &attributeValue=QVariant())
void onRemoveSegment()
Remove selected segment.
void onSourceVolumeImageDataModified()
Called if source volume image data is changed.
Q_INVOKABLE void setupViewObservations()
Q_INVOKABLE void segmentationNodeSelectorRemoveAttribute(const QString &nodeType, const QString &attributeName)
Q_INVOKABLE void removeViewObservations()
void currentSegmentIDChanged(const QString &)
Emitted if different segment is selected in the segment list.
void setSwitchToSegmentationsButtonVisible(bool)
Show/hide the switch to Segmentations module button.
void updateMaskingSection()
Update masking section on the UI.
QString defaultTerminologyEntrySettingsKey() const
void onAddSegment()
Add empty segment.
Qt::ToolButtonStyle effectButtonStyle() const
bool autoShowSourceVolumeNode() const
void installKeyboardShortcuts(QWidget *parent=nullptr)
Q_INVOKABLE void sourceVolumeNodeSelectorRemoveAttribute(const QString &nodeType, const QString &attributeName)
void onEffectButtonClicked(QAbstractButton *button)
Activate effect on clicking its button.
void setMRMLSegmentEditorNode(vtkMRMLSegmentEditorNode *newSegmentEditorNode)
Set the segment editor parameter set node.
void updateUndoRedoButtonsState()
Update undo/redo button states.
void selectPreviousSegment()
Select the segment above the currently selected one in the table (skipping segments that are not visi...
void onCreateSurfaceToggled(bool on)
Create/remove closed surface model for the segmentation that is automatically updated when editing.
void setSourceVolumeNode(vtkMRMLNode *node)
void uninstallKeyboardShortcuts()
Uninstall previously installed keyboard shortcuts.
void onSegmentationNodeChanged(vtkMRMLNode *node)
Handles changing of current segmentation MRML node.
void setInteractionNode(vtkMRMLInteractionNode *interactionNode)
virtual void updateWidgetFromMRML()
Update widget state from the MRML scene.
void setEffectButtonStyle(Qt::ToolButtonStyle toolButtonStyle)
bool masterVolumeNodeSelectorVisible() const
Deprecated. Use sourceVolumeNodeSelectorVisible() method instead.
Q_INVOKABLE QString masterVolumeNodeID() const
Deprecated. Use sourceVolumeNodeID() method instead.
bool unorderedEffectsVisible() const
void onLayoutChanged(int layoutIndex)
Handle layout changes.
void onSegmentSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Handles segment selection changes.
Q_INVOKABLE void setEffectNameOrder(const QStringList &effectNames)
void setAutoShowSourceVolumeNode(bool)
Q_INVOKABLE void masterVolumeNodeSelectorAddAttribute(const QString &nodeType, const QString &attributeName, const QVariant &attributeValue=QVariant())
Deprecated use sourceVolumeNodeSelectorAddAttribute method instead.
Q_INVOKABLE qSlicerSegmentEditorAbstractEffect * activeEffect() const
void setSegmentationNodeID(const QString &nodeID)
Set segmentation MRML node by its ID.
void setDefaultTerminologyEntrySettingsKey(const QString &terminologyEntrySettingsKey)
void onSegmentAddedRemoved()
Called if a segment or representation is added or removed.
void setMaximumNumberOfUndoStates(int)
Set maximum number of saved undo/redo states.
Q_INVOKABLE qSlicerSegmentEditorAbstractEffect * effectByIndex(int index)
Q_INVOKABLE qSlicerSegmentEditorAbstractEffect * effectByName(QString name)
void setUndoEnabled(bool)
Undo/redo enabled.
void setAutoShowMasterVolumeNode(bool autoShow)
Deprecated. Use setAutoShowSourceVolumeNode method instead.
void showSegmentationGeometryDialog()
Show segmentation geometry dialog to specify labelmap geometry.
void showMasterVolumeInSliceViewers(bool forceShowInBackground=false, bool fitSlice=false)
void onMaskModeChanged(int)
Changed selected editable segment area.
Q_INVOKABLE vtkMRMLInteractionNode * interactionNode() const
void setDefaultTerminologyEntry(const QString &terminologyEntry)
Q_INVOKABLE int effectCount()
Q_INVOKABLE void setActiveEffect(qSlicerSegmentEditorAbstractEffect *effect)
qSlicerAbstractModuleWidget * switchToSegmentationsModule()
Switches to Segmentations module and returns the module widget.
void onSourceVolumeIntensityMaskRangeChanged(double low, double high)
Handles threshold values changed event.
void masterVolumeNodeChanged(vtkMRMLVolumeNode *)
Deprecated. Use sourceVolumeNodeChanged signal instead.
void onSegmentationDisplayModified()
Handle display node view ID changes.
static void processEvents(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
Callback function invoked when interaction happens.
void setSegmentationNode(vtkMRMLNode *node)
Set segmentation MRML node.
void onImportExportActionClicked()
Switch to Segmentations module and jump to Import/Export section.
Base class for any widget that requires a MRML Scene.
Definition qMRMLWidget.h:36
Abstract class for segment editor effects.
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
Parameter set node for the segment editor widget.
MRML node containing segmentations.
MRML node for representing a volume (image stack).