How to set the fixed width/height for vtkScalarBarActor?

I am using vtkScalarBarActor in my application. However, the width/height of vtkScalarBarActor is changing when the render window is changed.

For example:

For example, the width of vtkScalarBarActor of second figure is much larger than that of first figure. And the large width of vtkScalarBarActor in second figure is ugly.

Is there any method to set fixed width for vtkScalarBarActor? I hope it is not changed when the window size is changed.

Hi,

The placement of those 2D widgets is a proportion of the viewport, so it expectedly changes as the latter’s aspect ratio changes. To have a fixed apparent width regardless of viewport aspect ratio, you have to change the scalar bar’s relative width on each viewport resize event.

Alternativelly, you can try SetMaximum[Width|Height]InPixels(value) to impose limits to avoid such undesirable effects. Calling AnnotationTextScalingOff() will switch of text resize so you won’t get huge characters in your scalar bar.

There are several other methods available in vtkScalarBarActor to control its appearance: https://vtk.org/doc/nightly/html/classvtkScalarBarActor.html .

take care,

Paulo

2 Likes

@Paulo_Carvalho Many thanks for such kindly reply.

1 Like