TomographicImaging / CILViewer

A simple Viewer for 3D data built with VTK
Apache License 2.0
8 stars 6 forks source link

Allowed key bindings #332

Open paskino opened 1 year ago

paskino commented 1 year ago

A lot of keys trigger actions on the viewer. We should allow the user to set which ones are active or not.

paskino commented 5 months ago

Several CharEvents are also observed in the vtkRenderWindowInteractor.

We could consume the events as proposed in this thread The following code catches the CharEvent s or w and ~doesn't propagate it further~ changes the character so that it is not processed further.


def consumeCharEvent(interactor, event):
    if interactor.GetKeyCode() in ['s', 'w']:
        interactor.SetKeyCode("")

iren = vtk.vtkRenderWindowInteractor()
iren.AddObserver("CharEvent", consumeCharEvent, 10)

We could use this to add a list of CharEvents we want to discard or monitor.

Notice that the viewer styles observers observe KeyPressEvent rather than CharEvent. https://github.com/vais-ral/CILViewer/blob/b811547112352124c1d7d7b668488efd706f36ef/Wrappers/Python/ccpi/viewer/CILViewer2D.py#L38

https://github.com/vais-ral/CILViewer/blob/b811547112352124c1d7d7b668488efd706f36ef/Wrappers/Python/ccpi/viewer/CILViewer2D.py#L331-L397