Disabling Rotate and Zoom in vtkInteractorStyleImage

I’m working on a C# window forms project and trying to disable the zoom and rotate methods of my rendered window. I’m currently using the vtkInteractorStyleImage for my interactor, but haven’t been successful in overriding the inherited methods. Any easy ways to just turn zoom and rotate off so that I’m only able to pan?

What have you tried so far? It should be possible to override the interaction by adding observers for RightButtonPressEvent, LeftButtonPressEvent, and MiddleButtonPressEvent.

I’ve tried to make a derived class from vtkInteractorStyleImage and then initialize from that class.

For Example:
class DerivedClass : vtkInteractorStyleImage
public override void OnLeftButtonDown()

    public override void OnMiddleButtonDown()

    public override void OnRightButtonDown()

The initialize doing:
vtkInteractorStyleImage interactorstyle = new DerivedClass();

I just tried following your suggestion partly where I was able to disable the scrolling zoom by doing:
interactorstyle.MouseWheelForwardEvt += new vtkObject.vtkObjectEventHandler(DoNothing);
interactorstyle.MouseWheelBackwardEvt += new vtkObject.vtkObjectEventHandler(DoNothing);
where DoNothing is an empty method.

However, what would I do for the mouse press events? The shift key and control key are both still needed when the left button is down to pan and rotate, respectively.

To disable certain events by adding event handlers, your handler needs to do this:

  1. call intertactorstyle.GetInteractor() to check whether shift or control was used
  2. if the button and modifiers are for an action you want to cancel, then return without doing anything
  3. if the button and modifiers are for an action you want to keep, then call interactorstyle.OnLeftButtonDown() (or Middle or Right) and the action will be taken

Thanks a lot, this mostly works. Here’s the code that I have set up:

In the interactor style definition:
interactorstyle.LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(DoSomething);

where DoSomething is:
private void DoSomething(vtkObject sender, vtkObjectEventArgs e)
vtkRenderWindow window = renderWindowControl1.RenderWindow;
vtkRenderWindowInteractor interactor = window.GetInteractor();


        vtkInteractorStyleImage interactorstyle = (vtkInteractorStyleImage)interactor.GetInteractorStyle();

This mostly works, because it lets me pan by just left click and drag and no other features are enabled. However, I occasionally get the following error:

An unhandled exception of type ‘System.Exception’ occurred in Kitware.mummy.Runtime.dll
Additional information: error: could not get registered type - mteIndex=‘4294967295’ classNameKey=’’

Any idea as to something I should be doing differently?

Oh, definitely do not call SetAltKey(), SetControlKey(), SetShiftKey(). Instead, call GetAltKey(), GetControlKey() and GetShiftKey(). The goal is to check the values of these modifiers, not to set them.

Yes, that’s originally what I had to only check if GetShiftKey() was != 0 to call OnLeftButtonDown(). However, an even better solution would be to have the pan happen anytime the left button was used regardless of key press, which is why I chose to set the keys.

I guess it’s okay if that’s what you want to do. As for me, I would worry about changing the state variables of the interactor while an event is still ongoing.

For the exception I can only make a wild guess, since I’m not a C# programmer.