Hi,
My question is, is there a way to display slice views from currently selected Volume in qMRMLNodeComboBox. I have a small loadable module c++ script in which I’m using qMRMLNodeComboBox copied from “volumes” module. The combobox does get populated when adding volumes from “add data” script. I would like the slice views display to get updated with currently selected Volume in combo box. Right now I have to go to “Data” module and click on “show/hide branch node”. Thanks
See several solutions in the script repository: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Iterate_over_current_visible_slice_views.2C_and_set_foreground_and_background_images
Hi Lassoan,
Thanks for pointing out, at first I wasn’t if sure if there is c++ based alternative for these scripts but I have figured it out. So I’m using push button to get the volumeNode and displaying it in this way. This is called after we select the volume from qMRMLComboBox and click on push button
qSlicerLayoutManager* layoutManager = getLayout();
if (layoutManager != NULL) {
vtkMRMLVolumeNode* currentVolume = vtkMRMLVolumeNode::SafeDownCast(d->ActiveVolumeNodeSelector->currentNode());
std::array<std::string, 3> color = {"Red", "Yellow", "Green"};
for(const auto& color : color) {
QString Color=QString::fromStdString(color);
vtkMRMLSliceCompositeNode* compositeNode = layoutManager->sliceWidget(Color)->sliceLogic()->GetSliceCompositeNode();
compositeNode->SetBackgroundVolumeID(currentVolume->GetID());
compositeNode->SetForegroundVolumeID(currentVolume->GetID());
}
layoutManager->resetSliceViews();
Thanks for your help, appreciate it. Closing this thread
1 Like