[vtkusers] Problem with vtkRenderWindowInteractor with more than one widget

Greg Ushomirsky gregus at gmail.com
Thu May 22 22:41:50 EDT 2008


Ken,

I posted a similar question to vtkusers about a month ago but never
got a reply. Here's what I understood since then:

1. when you press "i", the default interactor enables the first
vtk3DWidget that was registered with it. So it does not matter how
many vtk3DWidgets you have;  only the first one will get activated
when you press "i", regardless of where the mouse is pointing. You can
see that by tracing around the interactor code -- it never checks
where the mouse is pointing (unlike the case when you press "p" -- the
interactor then invokes a picker that checks the mouse pointer
location)

2. You can turn on any of the vtk3DWidgets you created by invoking
their EnabledOn() method. This will display the widget in the scene
and will let it receive mouse events.

3. A kludgey way of implementing what you need (doable from Python) is
to set up a callback such that you would first pick an actor whose
3DWidget you want to interact with (by pressing "p") and the act of
picking the actor would turn on the widget. In more detail, you need
to
 - Keep an array of actors that have associated 3DWidgets
 - register a callback for the renderer's EndPickEvent  event
 - in the callback, the interactor's vtkAbstractPropPicker will
already point to the actor that was picked, if any. So you check if
the picked actor is on your list, and, if so, you call its widget's
EnableOn() method, and you call all other widgets' EnableOff() method.
If no actor was picked, then you call everyone's EnableOff() method.

It's a kludge, but it works. The only undesirable side effect is that
I have not figured out how to not turn on the outline of the actor
that was picked. The real way to fix this would be to re-implement or
sublcass the interactor

Hope this helps
Greg

On Thu, May 22, 2008 at 12:43 PM, Kenneth Evans <evans at aps.anl.gov> wrote:
> I didn't get any replies, so I am resubmitting this.
>
>        -Ken
>
> -----Original Message-----
> From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
> Of Kenneth Evans
> Sent: Tuesday, May 13, 2008 2:53 PM
> To: vtkusers at vtk.org
> Subject: [vtkusers] Problem with vtkRenderWindowInteractor with more than
> one widget
>
> Hi,
>
> I would like to use vtkRenderWindowInteractorwith more than one widget.
> Attached is an example that is like cone6.py but with a sphere added.  The
> problem is that if I type "i" in the window, it only toggles the
> vtkBoxWidget on the cone and not on the sphere.
>
> In contrast, if I type "p" on either the cone or the sphere, it draws the
> pick box about that one --- the behavior I would think one would want.
>
> Is this a shortcoming of the vtkRenderWindowInteractor or am I doing
> something wrong?  It would be nice to be able to make a vtk3DWidget-type
> widget appear and disappear independently on _any_ so-equiped object in the
> scene.
>
> Is there a way around it?  (I would like to use this in Python or Java, so
> inheritance is not the way to go.  The fact that it happens in C++ indicates
> it is in the implementation, not in the wrappers.
>
> Thanks,
>
>        -Ken
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list