I’m using Vtk 9.1 on Linux.
I’ve been trying to get a vtkScalarBarWidget to orient horizontally. I’ve found that the vtkScalarBar will, but I can’t figure out how to do this with the widget.
From the online example:
The vtkScalarBar is set to horizontal with
but the widget is always vertical.
I can move the widget with the mouse and when it is near the bottom of the viewport, it changes to horizontal.
How can I set this in my program to be horizontal by default?
SetOrientationToHorizontal() is a
vtkScalarBarActor method. It is an actor, that is, the thing that appears in the scene inside the widget, which is a
vtkScalarBarWidget. So, you need to act upon the widget, not the actor.
vtkScalarBarWidget has a
GetScalarBarRepresentation() method which returns a pointer to a
vtkScalarBarRepresentation object. Maybe you want to try exploring its API to achieve the effect you want: https://vtk.org/doc/nightly/html/classvtkScalarBarRepresentation.html. Perhaps its
SetPostion() methods will do.
I was able to use the following to set the orientation to horizontal:
auto rep = scalarBarWidget->GetScalarBarRepresentation();
I was able to use the following to set the position:
auto bord = scalarBarWidget->GetBorderRepresentation();
What I haven’t been able to figure out is how to change the font properties.
Please, post another question for that.