[vtkusers] How to abort a vtkBoxWidget

Serge Lalonde serge at infolytica.com
Mon Jul 21 11:38:52 EDT 2008


I'm would like it if the vtkBoxWidget aborted the current interaction if 
the user hits the Escape key.
I can't seem to find a built-in way to do this (please correct me if I'm 
wrong). So I'm trying to add it myself. This is what I've tried so far.

Adding an observer to the vtkBoxWidget to handle the CharEvent. My 
callback never gets called (why?).
Adding an observer to the vtkBoxWidget's interactor to handle the 
CharEvent. This does get called, but now I have to add a check to make 
sure that I am actually interacting with the widget because it always 
gets called.

 took the second approach. Then in the CharEvent, check the interactor's 
KeyCode for the escape key. So far so good. The problem now is forcing 
the interaction to abort. I can't find a clean way to do it. The best I 
could to is this:

            m_box_widget.Off();
            m_box_widget.On();
            m_box_widget.SetTransform(m_old_transform);
            m_box_widget.GetProp3D().SetUserTransform(m_old_transform);
            m_box_widget.GetInteractor().GetRenderWindow().Render();

But the other observers continue to be called (I have another observer 
attached to force a uniform scaling). What I really want is to make th 
vtkBoxWidget release the mouse and stop interacting altogether.

Any suggestions would be appreciated. Thanks.





More information about the vtkusers mailing list