Skip to content

Commit

Permalink
ENH: Allow hiding parts of segment editor widget
Browse files Browse the repository at this point in the history
Custom modules may want to simplify the user interface. For this, some more parts of the segment editor widget can now be hidden by
maskingSectionVisible, specifyGeometryButtonVisible, show3DButtonVisible, addRemoveSegmentButtonsVisible properties.
  • Loading branch information
lassoan committed Dec 23, 2024
1 parent 59dce47 commit 0d9b350
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ class qMRMLSegmentEditorWidgetPrivate: public Ui_qMRMLSegmentEditorWidget
bool UnorderedEffectsVisible;
int EffectColumnCount;

bool MaskingSectionVisible{ true };
bool SpecifyGeometryButtonVisible{ true };

/// List of registered effect instances
QList<qSlicerSegmentEditorAbstractEffect*> RegisteredEffects;

Expand Down Expand Up @@ -297,6 +300,10 @@ class qMRMLSegmentEditorWidgetPrivate: public Ui_qMRMLSegmentEditorWidget
QString DefaultTerminologyEntry;
};

//-----------------------------------------------------------------------------
CTK_GET_CPP(qMRMLSegmentEditorWidget, bool, maskingSectionVisible, MaskingSectionVisible);
CTK_GET_CPP(qMRMLSegmentEditorWidget, bool, specifyGeometryButtonVisible, SpecifyGeometryButtonVisible);

//-----------------------------------------------------------------------------
qMRMLSegmentEditorWidgetPrivate::qMRMLSegmentEditorWidgetPrivate(qMRMLSegmentEditorWidget& object)
: q_ptr(&object)
Expand Down Expand Up @@ -1696,7 +1703,7 @@ void qMRMLSegmentEditorWidget::updateEffectsSectionFromMRML()
d->OptionsGroupBox->show();
d->OptionsGroupBox->setTitle(activeEffect->title());
d->EffectHelpBrowser->setCollapsibleText(activeEffect->helpText());
d->MaskingGroupBox->show();
d->MaskingGroupBox->setVisible(d->MaskingSectionVisible);
}
else
{
Expand Down Expand Up @@ -3028,7 +3035,7 @@ void qMRMLSegmentEditorWidget::setSourceVolumeNodeSelectorVisible(bool visible)
Q_D(qMRMLSegmentEditorWidget);
d->SourceVolumeNodeComboBox->setVisible(visible);
d->SourceVolumeNodeLabel->setVisible(visible);
d->SpecifyGeometryButton->setVisible(visible);
d->SpecifyGeometryButton->setVisible(visible && d->SpecifyGeometryButtonVisible);
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -3852,3 +3859,48 @@ bool qMRMLSegmentEditorWidget::jumpToSelectedSegmentEnabled()const
Q_D(const qMRMLSegmentEditorWidget);
return d->SegmentsTableView->jumpToSelectedSegmentEnabled();
}

// --------------------------------------------------------------------------
void qMRMLSegmentEditorWidget::setMaskingSectionVisible(bool visible)
{
Q_D(qMRMLSegmentEditorWidget);
d->MaskingSectionVisible = visible;
this->updateEffectsSectionFromMRML();
}

// --------------------------------------------------------------------------
void qMRMLSegmentEditorWidget::setSpecifyGeometryButtonVisible(bool visible)
{
Q_D(qMRMLSegmentEditorWidget);
d->SpecifyGeometryButtonVisible = visible;
d->SpecifyGeometryButton->setVisible(d->SourceVolumeNodeComboBox->isVisible() && d->SpecifyGeometryButtonVisible);
}

// --------------------------------------------------------------------------
void qMRMLSegmentEditorWidget::setShow3DButtonVisible(bool visible)
{
Q_D(qMRMLSegmentEditorWidget);
d->Show3DButton->setVisible(visible);
}

// --------------------------------------------------------------------------
bool qMRMLSegmentEditorWidget::show3DButtonVisible()const
{
Q_D(const qMRMLSegmentEditorWidget);
return d->Show3DButton->isVisible();
}

// --------------------------------------------------------------------------
void qMRMLSegmentEditorWidget::setAddRemoveSegmentButtonsVisible(bool visible)
{
Q_D(qMRMLSegmentEditorWidget);
d->AddSegmentButton->setVisible(visible);
d->RemoveSegmentButton->setVisible(visible);
}

// --------------------------------------------------------------------------
bool qMRMLSegmentEditorWidget::addRemoveSegmentButtonsVisible()const
{
Q_D(const qMRMLSegmentEditorWidget);
return d->AddSegmentButton->isVisible() && d->RemoveSegmentButton->isVisible();
}
28 changes: 28 additions & 0 deletions Modules/Loadable/Segmentations/Widgets/qMRMLSegmentEditorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_EXPORT qMRMLSegmentEditorWidget : pu
QVTK_OBJECT
Q_PROPERTY(bool segmentationNodeSelectorVisible READ segmentationNodeSelectorVisible WRITE setSegmentationNodeSelectorVisible)
Q_PROPERTY(bool sourceVolumeNodeSelectorVisible READ sourceVolumeNodeSelectorVisible WRITE setSourceVolumeNodeSelectorVisible)
Q_PROPERTY(bool maskingSectionVisible READ maskingSectionVisible WRITE setMaskingSectionVisible)
Q_PROPERTY(bool specifyGeometryButtonVisible READ specifyGeometryButtonVisible WRITE setSpecifyGeometryButtonVisible)
Q_PROPERTY(bool show3DButtonVisible READ show3DButtonVisible WRITE setShow3DButtonVisible)
Q_PROPERTY(bool addRemoveSegmentButtonsVisible READ addRemoveSegmentButtonsVisible WRITE setAddRemoveSegmentButtonsVisible)
Q_PROPERTY(bool autoShowSourceVolumeNode READ autoShowSourceVolumeNode WRITE setAutoShowSourceVolumeNode)
Q_PROPERTY(bool masterVolumeNodeSelectorVisible READ masterVolumeNodeSelectorVisible WRITE setMasterVolumeNodeSelectorVisible) // deprecated
Q_PROPERTY(bool autoShowMasterVolumeNode READ autoShowMasterVolumeNode WRITE setAutoShowMasterVolumeNode) // deprecated
Expand Down Expand Up @@ -188,6 +192,18 @@ class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_EXPORT qMRMLSegmentEditorWidget : pu
return this->autoShowSourceVolumeNode();
};

/// Show/hide the masking section
bool maskingSectionVisible() const;

/// Show/hide the specify geometry button
bool specifyGeometryButtonVisible() const;

/// Show/hide the 3D button
bool show3DButtonVisible() const;

/// Show/hide the add/remove segment buttons
bool addRemoveSegmentButtonsVisible() const;

/// Show/hide the switch to Segmentations module button
bool switchToSegmentationsButtonVisible() const;
/// Undo/redo enabled.
Expand Down Expand Up @@ -322,6 +338,18 @@ public slots:
/// displayed in slice views when a new source volume is selected or layout is changed.
/// Enabled by default.
void setAutoShowSourceVolumeNode(bool);
/// Set masking section visible
/// If set to false then masking section always remains hidden.
void setMaskingSectionVisible(bool);
/// Show/hide the specify geometry button
/// If set to false then the button is always hidden.
void setSpecifyGeometryButtonVisible(bool);
/// Show/hide the 3D button
/// If set to false then the button is always hidden.
void setShow3DButtonVisible(bool);
/// Show/hide the add/remove segment buttons
/// If set to false then the buttons are always hidden.
void setAddRemoveSegmentButtonsVisible(bool);
/// Show/hide the switch to Segmentations module button
void setSwitchToSegmentationsButtonVisible(bool);
/// Undo/redo enabled.
Expand Down

0 comments on commit 0d9b350

Please sign in to comment.