Slicer 5.6: unable to change interactor style


In previous releases of Slicer (5.2 for example) it used to be possible to change interactor (from this post):

lm =
rw = lm.sliceWidget('Red').sliceView().renderWindow()
style = vtk.vtkInteractorStyleRubberBand2D()

and when you start dragging the coursor on Red slice with mouse 1 pressed on you should be able to see a selection rectangle.

In Slicer 5.6 it doesn’t work anymore :confused:

This is probably due to a vtk level change - maybe try to recreate it in pure vtk? Then posting to the vtk list may help identify the needed new code.

There have also been some interactor related developments to improve interactions in augmented/virtual reality, which may have changed the behavior. You can find details in the git log.

In general, I find interactor style a very primitive, limited way of translating GUI events to actions. A much more powerful and cleaner approach is what is implemented in Slicer: implement camera manipulation related actions in widgets - the same way as all other actions. Interaction style is probably a remnant from early VTK years when VTK widgets did not exist. Interaction style is also suitable for simple test and example applications, which may explain why it has not been removed from VTK. However, I would not consider using interaction style in full-fledged applications.

Yes I’ve tried to run it with pure VTK and the rubber band works:

That is very interesting opinion, thank you!
Can’t find any rubber band VTK widget to select rectangle on the screen. Are there any?

You can add your own displayable manager and widgets in your module.

1 Like

Alright, I think I have found the commits that disturb the possibility of changing interaction style (here is the link to PR) but I will follow your suggestion and implement my needs through the vtkSliderWidget 2D

That slider looks so ugly, like 20-30 years old technology. They also waste a lot of space (usually these kind of in-view controls only take up space as much as the size of a label when they are not interacted with, but a slider is much bigger). Do you really need it? What parameters do you want to modify with it?

Hi Andras,

Agree, it looks pretty old so I’ve found a better solution:
I added custom interaction to Displayabe Manager. Here is the idea of the solution.
So it is possible to zoom the slice using ctrl + right mouse button