When I clone a volume node and then modify the array values, the “Volume Information” section shows outdated information and I can’t find a way to get it to update.
After this code, the newVolumeNode() has a maximum value of 0, but “Volume Information” still shows it to have a “Scalar Range” up to whatever value the original volNode had. The actual display of the volume in the slice views shows the modified voxel values, and in all other relevant ways the volume is updated, but there seems to be nothing which updates the “Volume Information”.
You need to call slicer.util.arrayFromVolumeModified(newVolNode) to indicate that you have finished with your modifications. See documentation for details.
Hello, i kind of have a similar problem but i use C++ and after a long search in the documentation I failed to find the C++ counterpart of slicer.util.arrayFromVolumeModified(newVolNode)
No, it doesn’t exist. You can just look at the corresponding python implementation and make the same calls. Usually it’s just one or two Modified() calls. Note you only need this if you change the array directly. If you work with VTK pipelines it’s typically automatic.
A great side-effect of Slicer (and libraries it uses) being open, along with all documentation, discussion, etc. is that all information is indexed by search engines. So, if you need documentation or source code then you can simply do a web search. For example if you google for arrayFromVolumeModified then for me the second hit in the search result is the source code.
And i would like that the volume information section update with his data.
So the node is selected (the eye icon is on) but it seems that the update of the volume information section is triggered by highlighting a node in the hierarchy tree. After some research on the vtkMRMLSelectionNode or vtkMRMLSubjectHierarchyNode i couldn’t find what i was looking for.
I also tried something like :
QString errorMsg;
qSlicerAbstractCoreModule* volumeModule = qSlicerCoreApplication::application()->moduleManager()->module("Volumes");
if (!volumeModule)
{
errorMsg += "VolumesModule module is not found. ";
qCritical() << "VolumesModule module is not found";
return;
}
vtkSlicerVolumesLogic* volumeLogic = vtkSlicerVolumesLogic::SafeDownCast(volumeModule->logic());
if (!volumeLogic)
{
errorMsg += "VolumesModule logic is not found. ";
qCritical() << "VolumesModule logic is not found";
return;
}
volumeLogic->SetActiveVolumeNode(node);
But it did’nt have any effect, i miss an update or something ? Any hint ?
This feature is used when you right-click on a node and choose “Edit node…”. This API should not be necessary for implementing a custom workflow. Instead, the recommended way to implement workflows is not to switch between modules at all, just put all the widgets that you need into your own module GUI.
For example, if you want to show volume information in your module, just add a qMRMLVolumeInfoWidget to your module GUI. You can try this easily from the Python console:
All the other parts of the Volumes module are widgets that you can reuse (and customize) in your module. For example, you can show/edit volume display options by adding a slicer.qSlicerScalarVolumeDisplayWidget() to your module GUI. Similarly, all other Slicer core module GUI is assembled from widgets that you can reuse in your own module. There could be some exceptions, where some shortcuts were taken and some parts of a module GUI is not a reusable widget. If you encounter anything like that then you can file a bug report.
It does what I described above: changes the currently selected node in Volumes module GUI.
You can use the Volumes module as an example. It displays this widget in its module GUI. The module GUI is designed in Qt Designer, so the best is to view/edit the GUI there.
Developing modules in C++ is for advanced users. It is recommended to first get to know Slicer using Python scripting.