Can't display `vtkCubeAxesActor2D` in slice view

Hi,

In an attempt to display vtkCubeAxesActor2D I use the code:

# Get renderer and camera
layoutManager = slicer.app.layoutManager()
view = layoutManager.sliceWidget('Red').sliceView()
renderWindow = view.renderWindow()
renderers = renderWindow.GetRenderers()
renderer = renderers.GetItemAsObject(0)
camera = renderer.GetActiveCamera()

# Customize vtkCubeAxesActor2D
cubeAxesActor = vtk.vtkCubeAxesActor2D()
cubeAxesActor.SetBounds(-50, 50, -50, 50, -50, 50)    # some boundary points
cubeAxesActor.SetCamera(camera)
cubeAxesActor.SetXAxisVisibility(1)
cubeAxesActor.SetYAxisVisibility(1)
cubeAxesActor.SetZAxisVisibility(1)
cubeAxesActor.SetVisibility(1)
renderer.AddActor(cubeAxesActor)

# Update views
slicer.util.forceRenderAllViews()

this snippet of code doesn’t show anything.

I look to the vtkMRMLRulerDisplayableManager source code and I feel that I pretty understand how vtkMRMLRulerDisplayableManager works but it uses vtkAxisActor2D instead.

There is a thing that I can’t understand: what is layers in slice view? Is slice view is represented by somehow overlapping square planes and there is foreground layer and background?

I just figured out that I should have used boundary in range from 0 to 1:

cubeAxesActor.SetBounds(0.1, 0.9, 0.1, 0.9, 0.1, 0.9)

The question about slice’s layers is still actual…

Yes a slice view has layers including background volume, foreground volume and labelmap volume. This is why you can’t overlay say 4 volumes at once and see them all at the same time in the same slice viewer. See

https://slicer.readthedocs.io/en/latest/user_guide/user_interface.html?highlight=background%20layer#slice-view

1 Like

Thank you for the hint. Probably I need some time to understand