[vtkusers] How do I modify the interaction behavior for the vtkContourWidget?

kent williams nkwmailinglists at gmail.com
Fri Dec 14 14:47:28 EST 2007

Really, I only ask these dumb questions after I poke around the
documentation and code examples and google for answers ;-)

I have made some good progress on my 3D Image tracer application.  The
program now can load a 3D volume, and allow a user to trace anatomical
features slice by slice, with one or more contours.

I currently hook the vtkContourWidgets to a vtkViewImage2D widget
(from the vtkinria3d toolkit:

Everything works great EXCEPT -- the vtkContourWidget reacts to some
of the same events as the vtkViewImage2D widget.   I'm able to turn
off all but the essential event handling in the View -- zoom and pan,
which is bound to the right mouse button.

So first off I want to move the AddFinalPointAction binding from the
right mouse button, or change it to Control->RightMouseButton.

Secondly the vtkContourWidget::DeleteAction method is bound thusly in

                                          vtkEvent::NoModifier, 47, 1, NULL,
                                          this, vtkContourWidget::DeleteAction);
                                          vtkEvent::NoModifier, 47, 1, NULL,
                                          this, vtkContourWidget::DeleteAction);

What this ends up doing, as I've discovered from experimentation, is
that any time the Ctrl, (Alt/Option) (OpenApple/Cloverleaf), or Shift
keys is pressed, the last point of an open contour, or the currently
selected point of a closed contour, gets deleted.  This seems to me to
be pretty end-user-confusing.  Those are all buttons that can get
pressed accidentally, and normally, being pressed by themselves has
null effect.  Where by 'normally' I mean 'in nearly every other
program that runs on a computer.'  Furthermore the DART Man Page for
vtkContourWidget says that the vtkContourWidget::DeleteAction is bound
to the 'Delete' key.

So I'd like to have something like 'F1' or 'Alt-something-or-other'
mapped to the vtkContourWidget::AddFinalPointAction action, and
'Delete' or 'Ctrl-something-or-Other'  I kind of see how to do this by
messing with the vtkWidgetEventTranslator, but I'm a little baffled by
how exactly what the magic incantation to do this is.  Pointers to
examples, or discussion, is welcome.  Thanks!

More information about the vtkusers mailing list