[vtk-developers] vtkWidgetEventTranslator -- care and feeding?

kent williams nkwmailinglists at gmail.com
Mon Dec 17 10:09:40 EST 2007


Hi, first time poster, long time archive browser.

I'm developing a 3D volume tracing application -- a user loads a brain
volume scan, and then manually traces an anatomical feature a slice at
a time.

I'm using the vtkContourWidget.  This widget is a real improvement in
terms of user interaction over the vtkImageTracerWidget in terms of
user interaction, but I find some of the even bindings to be a little
counter-intuitive, and I would like to modify them.

In particular, the AddFinalPoint binding collides with the image
viewer's binding for zooming and panning.  Not only that, tracing
anatomy with open contours doesn't make sense.  So I'd like to move
AddFinalPoint away from the right mouse button.

Also, the Delete Point binding is really strange.  In the CVS version
of the widget, hitting 'Ctrl', 'Shift', and on Mac, the CloverLeaf Key
deletes the last point during contour definition, and the currently
selected point after a contour is closed.  This appears to be a bug,
since the Doxygen documentation says that the 'Delete' key is bound to
this action.

So I tried what it seems like I should be doing to redefine the event
handling for the vtkContour Widget -- thusly:

 vtkWidgetEventTranslator *xlat = this->m_ContourWidget->GetEventTranslator();

 xlat->SetTranslation(vtkCommand::KeyPressEvent,
                      vtkEvent::ControlModifier,
                      101,1,NULL,vtkWidgetEvent::AddFinalPoint);
 xlat->SetTranslation(vtkCommand::NoEvent,
                      vtkEvent::NoModifier,
                      47,1,NULL,vtkWidgetEvent::Delete);

I was trying to do two things: 1) change the event binding of the
AddFinalPoint event to Control-e (101 being decimal for ASCII e).
2) Turn off handling the 'delete point' behavior entirely.

The documentation says any call to SetTranslation will override any
previous call to SetTranslation.  This appears not to be the case, or
maybe I haven't yet figured out the magic incantation yet.



More information about the vtk-developers mailing list