Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Optimize processing Segment Editor updates during Batch Processing #6395

Merged
merged 1 commit into from Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1178,7 +1178,7 @@ void qMRMLSegmentEditorWidget::updateEffectList()
void qMRMLSegmentEditorWidget::updateWidgetFromMRML()
{
Q_D(qMRMLSegmentEditorWidget);
if (!this->mrmlScene() || this->mrmlScene()->IsClosing())
if (!this->mrmlScene() || this->mrmlScene()->IsClosing() || this->mrmlScene()->IsBatchProcessing())
{
return;
}
Expand Down Expand Up @@ -1777,6 +1777,7 @@ void qMRMLSegmentEditorWidget::setMRMLScene(vtkMRMLScene* newScene)

// observe close event so can re-add a parameters node if necessary
this->qvtkConnect(this->mrmlScene(), vtkMRMLScene::EndCloseEvent, this, SLOT(onMRMLSceneEndCloseEvent()));
this->qvtkConnect(this->mrmlScene(), vtkMRMLScene::EndBatchProcessEvent, this, SLOT(onMRMLSceneEndBatchProcessEvent()));
}

//-----------------------------------------------------------------------------
Expand All @@ -1786,6 +1787,28 @@ void qMRMLSegmentEditorWidget::onMRMLSceneEndCloseEvent()
this->updateWidgetFromMRML();
}

//-----------------------------------------------------------------------------
void qMRMLSegmentEditorWidget::onMRMLSceneEndBatchProcessEvent()
{
Q_D(qMRMLSegmentEditorWidget);
if (!this->mrmlScene())
{
return;
}
if (d->ParameterSetNode->GetSegmentationNode() != d->SegmentationNodeComboBox->currentNode())
{
this->setSegmentationNode(d->SegmentationNodeComboBox->currentNode());
}

if (d->ParameterSetNode->GetSourceVolumeNode() != d->SourceVolumeNodeComboBox->currentNode())
{
this->setSourceVolumeNode(d->SourceVolumeNodeComboBox->currentNode());
}

// force update (clear GUI if no node is selected anymore)
jamesobutler marked this conversation as resolved.
Show resolved Hide resolved
this->updateWidgetFromMRML();
}

//-----------------------------------------------------------------------------
void qMRMLSegmentEditorWidget::onInteractionNodeModified()
{
Expand Down Expand Up @@ -2003,6 +2026,10 @@ QString qMRMLSegmentEditorWidget::sourceVolumeNodeID()const
void qMRMLSegmentEditorWidget::onSegmentationNodeChanged(vtkMRMLNode* node)
{
Q_D(qMRMLSegmentEditorWidget);
if (!this->mrmlScene() || this->mrmlScene()->IsBatchProcessing())
jamesobutler marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}
this->setSegmentationNode(node);
}

Expand Down Expand Up @@ -2066,6 +2093,10 @@ void qMRMLSegmentEditorWidget::setCurrentSegmentID(const QString segmentID)
void qMRMLSegmentEditorWidget::onSourceVolumeNodeChanged(vtkMRMLNode* node)
{
Q_D(qMRMLSegmentEditorWidget);
if (!this->mrmlScene() || this->mrmlScene()->IsBatchProcessing())
jamesobutler marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}
this->setSourceVolumeNode(node);
}

Expand Down
Expand Up @@ -494,6 +494,9 @@ protected slots:
/// Clean up when scene is closed
void onMRMLSceneEndCloseEvent();

/// Updates needed after batch processing is done
void onMRMLSceneEndBatchProcessEvent();

/// Set default parameters in parameter set node (after setting or closing scene)
void initializeParameterSetNode();

Expand Down