cpinter
(Csaba Pinter)
August 2, 2024, 12:33pm
2
In the past we added similar code to certain setup steps of our modules, such as
//---------------------------------------------------------------------------
void vtkSlicerIsodoseModuleLogic::SetMRMLSceneInternal(vtkMRMLScene* newScene)
{
vtkNew<vtkIntArray> events;
events->InsertNextValue(vtkMRMLScene::NodeAddedEvent);
events->InsertNextValue(vtkMRMLScene::NodeRemovedEvent);
events->InsertNextValue(vtkMRMLScene::EndCloseEvent);
events->InsertNextValue(vtkMRMLScene::EndBatchProcessEvent);
this->SetAndObserveMRMLSceneEvents(newScene, events.GetPointer());
// Load (or create) default isodose color table
vtkMRMLColorTableNode* isodoseColorTableNode = nullptr;
if ( (isodoseColorTableNode = this->LoadDefaultIsodoseColorTable()) == nullptr )
{
isodoseColorTableNode = vtkSlicerIsodoseModuleLogic::GetDefaultIsodoseColorTable(newScene);
}
// Create a copy of default isodose color table. The copy can be edited.
if (isodoseColorTableNode)
{
// Create a copy of isodose color table with unique name
std::string uniqueName = this->GetMRMLScene()->GenerateUniqueName(vtkSlicerIsodoseModuleLogic::IsodoseColorNodeCopyUniqueName.c_str());
The advantage of this to your approach is that anyone using the extension will have the custom color tables without extra steps. Of course this only works if you already maintain some modules that your group uses.
1 Like