Disable X,Y,and Z in vtkInteractorStyleImage

I would like to disable this key events because it rotates me one image that it has one single slice. So it does not make sense.

What I did was to try:

auto widget = std::make_unique<QVTKResliceImageWidget>
  (parent);
auto  oblique_reslice_image_viewer_ = widget->viewer();
 vtkSmartPointer<vtkRenderWindowInteractor> interactor =
  oblique_reslice_image_viewer_->GetInteractor();
interactor->GetInteractorStyle()->
RemoveObserver(vtkCommand::CharEvent)

But it did not work. Then I tried to override the OnChar function from the vtkInteractorStyleImage and it worked.

But the problem is that if I override the interactor style all the observers that i had in the style stopped working.

Then i found a trick to remap the key (X Y or Z) with another that it does not have any behavour linked

 case vtkCommand::KeyPressEvent:
{
 const int c = int(interactor->GetKeyCode());
 std::cout << "KEY=" << c;
     //Disable the keys X Y Z of the style
 if (c == 'X' || c == 'x' || c == 'Y' || c == 'y' || c == 'Z' || c == 'z') {
    interactor->SetKeyEventInformation(0, 0, '0', 0);
 }
  break;
 }

This works. But the problem is when the mouse is pressed the key event is not triggered by my observer. And then i have the same issue rotating a 2d image so it becomes a black screen.

Any other way to disable X,Y and Z in the vtkInteractorStyleImage?

Thanks

Hi, this link can solve the problem.