evaherbst
(Eva C. Herbst)
January 26, 2025, 7:30pm
1
Hello,
I am called the ModeltoModel distance module in Slicer with Python to batch run the distance calculations of several pairs of models.
Is there a way in Python automatically turn on visibility of the scalars from the model-to-model distance and also the heat map bars?
Thank you!
cpinter
(Csaba Pinter)
January 29, 2025, 11:17am
2
You need to get the display node of the model node and apply the settings you want on the display node. For example for turning on scalar visibility you can call this function:
/// Set the shading mode (None, Gouraud, Flat) of the display node.
/// \sa Shading, GetShading()
vtkSetMacro(Shading, int);
/// Get the shading of the display node.
/// \sa Shading, SetShading()
vtkGetMacro(Shading, int);
/// Set the scalar visibility of the display node.
/// \sa ScalarVisibility, GetScalarVisibility(), ScalarVisibilityOn(),
/// ScalarVisibilityOff()
vtkSetMacro(ScalarVisibility, int);
/// Get the scalar visibility of the display node.
/// \sa ScalarVisibility, SetScalarVisibility(), ScalarVisibilityOn(),
/// ScalarVisibilityOff()
vtkGetMacro(ScalarVisibility, int);
/// Set the scalar visibility of the display node.
/// \sa ScalarVisibility, SetScalarVisibility(), GetScalarVisibility
vtkBooleanMacro(ScalarVisibility, int);
/// Set the vector visibility of the display node.
/// \sa VectorVisibility, GetVectorVisibility(), VectorVisibilityOn(),
This snippet is for showing scalar bar for volumes. I don’t know if this works for model scalars, but I’d start here
https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#show-color-legend-for-a-volume-node
evaherbst
(Eva C. Herbst)
February 11, 2025, 9:34am
3
Thank you very much! I will test this