[vtk-developers] vtkImagePlaneWidget windowlevel events

dean.inglis at camris.ca dean.inglis at camris.ca
Wed Feb 13 17:22:09 EST 2008


I am trying to add additional functionality to
vtkImagePlaneWidget.  A short while ago I revamped
how window level works in this widget.  In a GUI
environement, one has to add a callback to listen
to Start/End/Interaction events to query the widget's
window/level values.  VtkCommand has the events:
Start/End/Reset/WindowLevelEvents, and so I am
adding this->InvokeEvent(vtkCommand::_WindowLevelEvent)
where appropriate in this widget.  To do ResetWindowLevelEvent,
as is done in vtkInteractorStyleImage, I have added the
following method:
//----------------------------------------------------------------------------
void vtkImagePlaneWidget::OnChar()
{
  vtkRenderWindowInteractor *i = this->Interactor;

  if ( i->GetKeyCode() == 'r' || i->GetKeyCode() == 'R' )
    {
    if ( i->GetShiftKey() || i->GetControlKey() )
      {
      this->Interactor->GetInteractorStyle()->OnChar();
      }
    else
      {
      this->SetWindowLevel( this->OriginalWindow, this->OriginalLevel );
      double wl[2] = { this->CurrentWindow, this->CurrentLevel };
      this->InvokeEvent(vtkCommand::ResetWindowLevelEvent, wl);
      }
    }
  else
    {
    this->Interactor->GetInteractorStyle()->OnChar();
    }
}

the problem is that shift+r/contl+r will still reset the
camera view, but at the same time it will reset the window
level.  That is because first an OnChar is called for 
depressing the shift key or the control key and then is
called again for 'r'.   Im not sure how to make this
be a one or the other type of method.  Any ideas?

thanks,
Dean



More information about the vtk-developers mailing list