Integrates into the VTK event mechanism to generate MITK specific events. This class is NON-QT dependent pandon to the current MITK event handling code in QmitkRenderWindow. More...
#include <mitkVtkEventProvider.h>

Public Member Functions | |
| vtkTypeRevisionMacro (vtkEventProvider, vtkInteractorObserver) | |
| virtual void | SetEnabled (int) |
| virtual void | SetInteractor (vtkRenderWindowInteractor *iren) |
| virtual void | SetMitkRenderWindow (mitk::RenderWindow *renWin) |
| mitk::RenderWindow * | GetRenderWindow () |
Static Public Member Functions | |
| static vtkEventProvider * | New () |
Protected Types | |
| typedef std::vector< unsigned long > | InteractionEventsVectorType |
Protected Member Functions | |
| vtkEventProvider () | |
| ~vtkEventProvider () | |
| void | AddInteractionEvent (unsigned long ievent) |
| void | RemoveInteractionEvent (unsigned long ievent) |
Static Protected Member Functions | |
| static void | ProcessEvents (vtkObject *object, unsigned long event, void *clientdata, void *calldata) |
Protected Attributes | |
| mitk::RenderWindow * | m_RenderWindow |
| InteractionEventsVectorType | m_InteractionEventsVector |
Integrates into the VTK event mechanism to generate MITK specific events. This class is NON-QT dependent pandon to the current MITK event handling code in QmitkRenderWindow.
Definition at line 36 of file mitkVtkEventProvider.h.
typedef std::vector<unsigned long> mitk::vtkEventProvider::InteractionEventsVectorType [protected] |
Definition at line 64 of file mitkVtkEventProvider.h.
| mitk::vtkEventProvider::vtkEventProvider | ( | ) | [protected] |
Definition at line 38 of file mitkVtkEventProvider.cpp.
References AddInteractionEvent(), and ProcessEvents().
{
// priority of the observer/command; we want MITK events processed in the very beginning
this->Priority = 99999.99;
//take over the processing of delete and keypress events from the superclass
this->EventCallbackCommand->SetCallback(
vtkEventProvider::ProcessEvents);
// Set/Get the passive observer flag. If this is set to true, this
// indicates that this command does not change the state of the
// system in any way. Passive observers are processed first, and
// are not called even when another command has focus.
this->EventCallbackCommand->SetPassiveObserver(1); // get events first
// mouse move
AddInteractionEvent(vtkCommand::MouseMoveEvent);
// mouse press
AddInteractionEvent(vtkCommand::LeftButtonPressEvent);
AddInteractionEvent(vtkCommand::MiddleButtonPressEvent);
AddInteractionEvent(vtkCommand::RightButtonPressEvent);
// mouse release
AddInteractionEvent(vtkCommand::LeftButtonReleaseEvent);
AddInteractionEvent(vtkCommand::MiddleButtonReleaseEvent);
AddInteractionEvent(vtkCommand::RightButtonReleaseEvent);
// wheel event
AddInteractionEvent(vtkCommand::MouseWheelBackwardEvent);
AddInteractionEvent(vtkCommand::MouseWheelForwardEvent);
// key press event
AddInteractionEvent(vtkCommand::KeyPressEvent);
// window resize event
AddInteractionEvent(vtkCommand::WidgetModifiedEvent);
}
| mitk::vtkEventProvider::~vtkEventProvider | ( | ) | [protected] |
Definition at line 72 of file mitkVtkEventProvider.cpp.
{
this->SetInteractor(0);
}
| void mitk::vtkEventProvider::AddInteractionEvent | ( | unsigned long | ievent ) | [protected] |
Definition at line 250 of file mitkVtkEventProvider.cpp.
Referenced by vtkEventProvider().
{
// Remove event if it already exists
RemoveInteractionEvent(ievent);
m_InteractionEventsVector.push_back(ievent);
}| mitk::RenderWindow * mitk::vtkEventProvider::GetRenderWindow | ( | ) |
Definition at line 82 of file mitkVtkEventProvider.cpp.
{
return m_RenderWindow;
}
| static vtkEventProvider* mitk::vtkEventProvider::New | ( | ) | [static] |
| static void mitk::vtkEventProvider::ProcessEvents | ( | vtkObject * | object, |
| unsigned long | event, | ||
| void * | clientdata, | ||
| void * | calldata | ||
| ) | [static, protected] |
Referenced by vtkEventProvider().
| void mitk::vtkEventProvider::RemoveInteractionEvent | ( | unsigned long | ievent ) | [protected] |
Definition at line 236 of file mitkVtkEventProvider.cpp.
{
InteractionEventsVectorType::iterator it;
if(m_InteractionEventsVector.size() > 0)
{
it = std::find(m_InteractionEventsVector.begin(),m_InteractionEventsVector.end(),ievent);
if(it != m_InteractionEventsVector.end())
{
m_InteractionEventsVector.erase(it);
return;
}
}
}
| void mitk::vtkEventProvider::SetEnabled | ( | int | enabling ) | [virtual] |
Definition at line 87 of file mitkVtkEventProvider.cpp.
References VTKEVENTPROVIDER_DEBUG, and VTKEVENTPROVIDER_ERROR.
Referenced by mitk::RenderWindow::RenderWindow().
{
if ( ! this->Interactor )
{
VTKEVENTPROVIDER_ERROR <<"The interactor must be set prior to enabling/disabling widget";
return;
}
if ( enabling ) //----------------------------------------------------------
{
VTKEVENTPROVIDER_DEBUG << "Enabling widget";
if ( this->Enabled ) //already enabled, just return
{
return;
}
this->Enabled = 1;
// listen to all event types specified in m_InteractionEventsVector
vtkRenderWindowInteractor *i = this->Interactor;
InteractionEventsVectorType::iterator it;
for(it = m_InteractionEventsVector.begin(); it != m_InteractionEventsVector.end(); it++)
{
i->AddObserver((vtkCommand::EventIds) (*it), this->EventCallbackCommand,
this->Priority);
}
this->InvokeEvent(vtkCommand::EnableEvent,NULL);
}
else //disabling-----------------------------------------------------------
{
VTKEVENTPROVIDER_DEBUG <<"Disabling widget";
if ( ! this->Enabled ) //already disabled, just return
{
return;
}
this->Enabled = 0;
// don't listen for events any more
this->Interactor->RemoveObserver(this->EventCallbackCommand);
//this->Interactor->HandleEventLoop = 0;
this->InvokeEvent(vtkCommand::DisableEvent,NULL);
}
}
| void mitk::vtkEventProvider::SetInteractor | ( | vtkRenderWindowInteractor * | iren ) | [virtual] |
Definition at line 140 of file mitkVtkEventProvider.cpp.
Referenced by mitk::RenderWindow::RenderWindow().
{
if (i == this->Interactor)
{
return;
}
// if we already have an Interactor then stop observing it
if (this->Interactor)
this->SetEnabled(0); //disable the old interactor
this->Interactor = i;
this->Modified();
}
| void mitk::vtkEventProvider::SetMitkRenderWindow | ( | mitk::RenderWindow * | renWin ) | [virtual] |
Definition at line 77 of file mitkVtkEventProvider.cpp.
Referenced by mitk::RenderWindow::RenderWindow().
{
m_RenderWindow = renWin;
}
| mitk::vtkEventProvider::vtkTypeRevisionMacro | ( | vtkEventProvider | , |
| vtkInteractorObserver | |||
| ) |
Definition at line 65 of file mitkVtkEventProvider.h.
mitk::RenderWindow* mitk::vtkEventProvider::m_RenderWindow [protected] |
Definition at line 58 of file mitkVtkEventProvider.h.
1.7.2