More unified API. Each Volume, Model, Markups or any other displayable node now can have an individual color legend by means of vtkMRMLColorLegendDisplayNode.
Displayed LUT is in sync with range of displayed values of primary display node;
Resizable title of color legend;
Control of visibility of color legend on each slice or 3D view.
Color legend can by added to any displayable node (if the node has a primary display node) by means of Color module logic and AddDefaultColorLegendDisplayNode method.
The access to a low level vtkScalarBarActor for developers and experienced users is described here.
There are still some features that must be added. Issue to check the progress is here.
Any other required or recommended features can added to the issue or in this topic.
Thank you for your development about color scalar bar
I try to plot the scalar bar on “View1” (i.e., 3D view).
“View1” was selected in the View panel, but the color bar is not displayed in the 3D view as shown in the example above.
For what data are you trying to display color legend in 3D: scalar volume, model or something else? Currently there is a limitation of showing color legends in 3D.
@Mik submitted a pull request that will allow displaying color legend of volumes shown slice views to be shown in 3D views as well. It’ll be available in the Slicer Preview Release within a few days.
If you enable “Synchronize with Volumes module” in Volume rendering module’s Advanced / Volume Properties section then the same color legend applies to volume rendering and slice views. However, if you use any other volume rendering preset then there is no GUI for making the volume rendering’s Scalar Color Mapping appear as a color legend, but you can achieve it by copy-pasting this Python script into the Python console in Slicer:
# Get colormap from first volume rendering property node
colorMapOfVolumeRendering = getNode('*Prop*').GetColor()
# Add color node
colorNode = slicer.mrmlScene.CreateNodeByClass("vtkMRMLProceduralColorNode")
colorNode.UnRegister(None) # to prevent memory leaks
colorNode.SetHideFromEditors(False)
slicer.mrmlScene.AddNode(colorNode)
colorMap = colorNode.GetColorTransferFunction()
colorMap.DeepCopy(colorMapOfVolumeRendering)
# Add an empty displayable node (you can only show a color legend if it belongs to a displayable node)
displayableNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLModelNode", "volume")
displayableNode.CreateDefaultDisplayNodes()
displayNode = displayableNode.GetDisplayNode()
# Display color legend
displayNode.SetAndObserveColorNodeID(colorNode.GetID())
colorLegendDisplayNode = slicer.modules.colors.logic().AddDefaultColorLegendDisplayNode(displayableNode)
@mik if you have time you might consider adding display of color legend for volume rendering (but instead of creating a separate color node, take the colormap from the volume property node). However, I’m not sure how often users want to display color legend for volume rendering.