Set vtkCubeAxesActor scale labels after vtkTransform


Hi,

I am applying a vtkTransform to different actors and a vtkCubeAxesActor but this is changing the scale of the dimension. I would like the scale to stay the same (from 0 to 1 in this example). A workaround would be to change the scale of the axis so I’m trying to get the scale array with the labels, cast them into number and divide by the z_scale that I’m applying.

Is this the best way to do it ? If so, I managed to do a SetAxisLabels for dumb values but I can’t get the initial values to transform.

Here is my code

cube_axes_actor = vtkCubeAxesActor()
transform = vtkTransform()
transform.Scale(1, 1, z_scale)

for actor in actors:
    actor.SetUserTransform(transform)
cube_axes_actor.SetUserTransform(transform)
print(cube_axes_actor.GetLabelTextProperty(2), flush=True)

Thanks in advance for your help !

2 Likes

Hello,

In my application, I use vtkCubeAxesActor2D, which I configure this way (C++):

        // add scaling to the edges of the cube.
        _axes = vtkSmartPointer<vtkCubeAxesActor2D>::New();
        _axes->SetViewProp( spectrogramActor.GetPointer() );
        _axes->SetCamera( _renderer->GetActiveCamera() );
        _axes->SetLabelFormat("%6.4g");
        _axes->SetFlyModeToClosestTriad();
        _axes->ScalingOff();
        _axes->SetNumberOfLabels( 5 );
        _axes->SetZLabel("Feature Size");
        _axes->SetAxisTitleTextProperty( tprop.GetPointer() );
        _axes->SetAxisLabelTextProperty( tprop.GetPointer() );

You may notice the ScalingOff() method but it doesn’t do what you need :slight_smile: . I belive the trick is to try vtkCubeAxesActor2D instead of vtkCubeAxesActor.

best,

PC