Skip to content

Commit

Permalink
BUG: fix crash issue 77
Browse files Browse the repository at this point in the history
  • Loading branch information
Punzo committed Feb 9, 2018
1 parent e6c550d commit d34feae
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
14 changes: 13 additions & 1 deletion AstroVolume/Widgets/qSlicerAstroVolumeModuleWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ void qSlicerAstroVolumeModuleWidget::setMRMLScene(vtkMRMLScene* scene)
vtkMRMLScene *presetsScene = astroVolumeLogic->GetPresetsScene();
d->PresetsNodeComboBox->setMRMLScene(presetsScene);
d->PresetsNodeComboBox->setCurrentNodeIndex(-1);
this->onMRMLVolumeNodeDisplayThresholdModified(true);
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -3701,8 +3702,14 @@ void qSlicerAstroVolumeModuleWidget::onMRMLDisplayROINodeModified(vtkObject* sen
{
return;
}

vtkMRMLAnnotationROINode* ROINode =
vtkMRMLAnnotationROINode::SafeDownCast(sender);
if (!ROINode)
{
return;
}

if(ROINode->GetDisplayVisibility())
{
d->ROICropDisplayCheckBox->setChecked(true);
Expand Down Expand Up @@ -4787,7 +4794,12 @@ void qSlicerAstroVolumeModuleWidget::onMRMLVolumeNodeModified()
d->DegreeUnitButton->blockSignals(DegreeState);
d->SexagesimalUnitButton->blockSignals(SexagesimalState);

vtkMRMLUnitNode* unitNode = d->selectionNode->GetUnitNode("intensity");
vtkMRMLUnitNode* unitNode = NULL;
if (d->selectionNode)
{
unitNode = d->selectionNode->GetUnitNode("intensity");
}

std::string MIN = d->astroVolumeNode->GetAttribute("SlicerAstro.DATAMIN");
std::string MAX = d->astroVolumeNode->GetAttribute("SlicerAstro.DATAMAX");
if (unitNode)
Expand Down
23 changes: 22 additions & 1 deletion AstroVolume/qSlicerAstroVolumeModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,22 @@ void qSlicerAstroVolumeModule::setup()
qSlicerSegmentEditorEffectFactory::instance()->registerEffect(new qSlicerSegmentEditorAstroCloudLassoEffect());
qSlicerSegmentEditorEffectFactory::instance()->registerEffect(new qSlicerSegmentEditorAstroContoursEffect());

// Find DarkBrightChartColorsID
// Set Default ColorNodeTable
defaultNode = vtkMRMLColorTableNode::SafeDownCast
(this->mrmlScene()->GetDefaultNodeByClass("vtkMRMLPlotChartNode"));
if (!defaultNode)
{
vtkMRMLNode *foo = this->mrmlScene()->CreateNodeByClass("vtkMRMLColorTableNode");
defaultNode.TakeReference(foo);
this->mrmlScene()->AddDefaultNode(defaultNode);
}
vtkMRMLColorTableNode *colorTableDefaultNode = vtkMRMLColorTableNode::SafeDownCast(defaultNode);
colorTableDefaultNode->SetAttribute("SlicerAstro.AddFunctions", "on");
colorTableDefaultNode->SetAttribute("SlicerAstro.Reverse", "on");
colorTableDefaultNode->SetAttribute("SlicerAstro.Inverse", "on");
colorTableDefaultNode->SetAttribute("SlicerAstro.Log", "on");

// Modify ColorNodeTable already allocated and find DarkBrightChartColorsID
std::string DarkBrightChartColorsID;
vtkSmartPointer<vtkCollection> ColorTableNodeCol = vtkSmartPointer<vtkCollection>::Take(
this->mrmlScene()->GetNodesByClass("vtkMRMLColorTableNode"));
Expand All @@ -438,6 +453,12 @@ void qSlicerAstroVolumeModule::setup()
{
continue;
}

tempColorTableNode->SetAttribute("SlicerAstro.AddFunctions", "on");
tempColorTableNode->SetAttribute("SlicerAstro.Reverse", "on");
tempColorTableNode->SetAttribute("SlicerAstro.Inverse", "on");
tempColorTableNode->SetAttribute("SlicerAstro.Log", "on");

if (!strcmp(tempColorTableNode->GetName(), "DarkBrightChartColors"))
{
DarkBrightChartColorsID = tempColorTableNode->GetID();
Expand Down

0 comments on commit d34feae

Please sign in to comment.