Change the font size of the title of the scalar bar in SlicerRT Isodose module

Isodose module in SlicerRT uses vtkScalarBar to show isodose palette and values.

image

I have tried to change the title’s font size of the scalar bar actor, but it didn’t change anything.

For example

  // Update all scalar bar actors
  for (vtkScalarBarWidget* scalarBarWidget : d->ScalarBarWidgets)
  {
    vtkSlicerRTScalarBarActor* actor = vtkSlicerRTScalarBarActor::SafeDownCast( scalarBarWidget->GetScalarBarActor() );

    // Update actor
    actor->SetTitle(scalarBarTitle.c_str());

    if (vtkTextProperty* textProp = actor->GetTitleTextProperty())
    {
      textProp->SetFontSize(8);
    }
    scalarBarWidget->Render();
  }

How to do this correctly?

Update scalar bar actor original code

The text is auto-scaled to the widget size. You can make the text larger by making the widget larger.

How can i make it more customized? Make it smaller, both title, labels and scalar bar itself, without modifying scalar bar actor class.

You can access some properties of the scalar bar, but maybe not all that you need. Unfortunately, the scalar bars are implemented very poorly. It would be awesome if you could help with implementing it properly. Most importantly, it would need to use a displayable manager class, which would display a scalar bar for each display node. Appearance of the scalar bar could be modified by changing the display node properties.

I can try to help.

I have checked the source code and have found ScalarBarDisplayableManager class. Can it be used as a basis for the future implementation? I have also found that some modules (Colors, Isodose, DataProbe) use nearly identical versions of ScalarBarActor class. Is that the absent of universal solution of that problem?

Awesome!

We should improve the scalar bar implementation in the Slicer core and then slightly modified versions in extensions will be no longer needed. You can modify the scalar bar any way you see fit. It is also very important to support multiple scalar bars and manage them (add them to the renderer) in a displayable manager.