vtkInteractorStyleRubberBand2D inverted pan controls

Hi all!

I was experimenting with the vtkInteractorStyleRubberBand2D interactor and I have encountered a strange behavior. It seems that when changing the camera’s position to [0, 0, -1] (view from below), the the horizontal components controls the vertical panning and vice versa. As a result, when moving the mouse to pan on the left the view pans vertically upwards while moving the mouse on the right the view pans downwards (https://user-images.githubusercontent.com/22067021/212385412-44aa710f-db17-4d50-9f16-8d90aaf4785d.mov).

This is the code to reproduce the bug.

import vtk
# A renderer and render window
renderer = vtk.vtkRenderer()
renderer.SetBackground(.3, .4, .5)

renwin = vtk.vtkRenderWindow()
renwin.AddRenderer(renderer)

# An interactor
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renwin)

# add the custom style
style = vtk.vtkInteractorStyleRubberBand2D()
style.SetDefaultRenderer(renderer)
interactor.SetInteractorStyle(style)

camera = vtk.vtkCamera()
camera.SetParallelProjection(True)
camera.ParallelProjectionOn()
camera.SetPosition([0, 0, -1])
camera.SetViewUp([1, 0, 0])

renderer.SetActiveCamera(camera)

# Add spheres to play with
sphere = vtk.vtkSphereSource()

sphere.SetRadius(1)
sphere.SetCenter(0,0,0)
sphere.SetPhiResolution(11)
sphere.SetThetaResolution(21)

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(sphere.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer.AddActor(actor)

cube = vtk.vtkCubeSource()

cube.SetCenter(5,0,0)

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(cube.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer.AddActor(actor)
renderer.ResetCamera()

# Start
interactor.Initialize()
interactor.Start()

Have a good day!
Gabriele

1 Like