MantisBT - VTK
View Issue Details
0010357VTK(No Category)public2010-03-02 23:162016-08-12 09:55
Sam Barnes 
Kitware Robot 
normalmajoralways
closedmoved 
 
 
0010357: KeyPressActivation for vtkImagePlaneWidget not working
KeyPressActivation for vtkImagePlaneWidget not working

The key press actication of the widget does not work (using version 5.4.2). I believe this is due to a change in revision 1.15 of vtkImagePlaneWidget.cxx.

Revision 1.15 introduced an implementation of OnChar(), this prevents the parent class implementation of OnChar() (in vtkInteractorObserver) from running. This is the one that provides the key press activation.

A fix is proposed below.
A simple fix is to combine the OnChar() code from vtkInteractorObserver and vtkImagePlaneWidget like this:

void vtkImagePlaneWidget::OnChar(void)
{
  //--------------
  //Code from vtkInteractorObserver::OnChar() version 5.4.2
  //--------------
  // catch additional keycodes otherwise
  if ( this->KeyPressActivation )
    {
    if (this->Interactor->GetKeyCode() == this->KeyPressActivationValue )
      {
      if ( !this->Enabled )
        {
        this->On();
        }
      else
        {
        this->Off();
        }
      this->KeyPressCallbackCommand->SetAbortFlag(1);
      return; //I Added this, not sure if necessary
      }
    }//if activation enabled
  

  //--------------
  //Original Code from vtkImagePlaneWidget::OnChar(void) version 5.4.2 (file revision 1.19)
  //--------------
  vtkRenderWindowInteractor *i = this->Interactor;
  if ( i->GetKeyCode() == 'r' || i->GetKeyCode() == 'R' )
    {
    if ( i->GetShiftKey() || i->GetControlKey() )
      {
      this->SetWindowLevel( this->OriginalWindow, this->OriginalLevel );
      double wl[2] = { this->CurrentWindow, this->CurrentLevel };

      this->EventCallbackCommand->SetAbortFlag(1);
      this->InvokeEvent(vtkCommand::ResetWindowLevelEvent, wl);
      }
    else
      {
      this->Interactor->GetInteractorStyle()->OnChar();
      }
    }
  else
    {
    this->Interactor->GetInteractorStyle()->OnChar();
    }
}

This restores proper functionality for this class. There is probably a more elegant solution though that will fix all inherited classes, but that is a little beyond me.
No tags attached.
Issue History
2010-03-02 23:16Sam BarnesNew Issue
2011-06-16 13:11Zack GalbreathCategory => (No Category)
2016-08-12 09:55Kitware RobotNote Added: 0037149
2016-08-12 09:55Kitware RobotStatusexpired => closed
2016-08-12 09:55Kitware RobotResolutionopen => moved
2016-08-12 09:55Kitware RobotAssigned To => Kitware Robot

Notes
(0037149)
Kitware Robot   
2016-08-12 09:55   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.