[vtkusers] Bug with picking in a vtkTkRenderWidget

Goodwin Lawlor goodwin.lawlor at ucd.ie
Thu Sep 5 13:29:04 EDT 2002


Hi,

I think I have a solution to the problem: (using CVS from 3 Sept). And its not just with picking... its with all key bindings in a vtkTkRenderWidget

In the vtkinteraction package (bindings.tcl), the Tcl events KeyPress and
KeyRelease are propagated both as a VTK CharEvent and as KeyPressEvent or
KeyReleaseEvent :
        $iren SetEventInformationFlipY $x $y $ctrl $shift $keysym 0 $keysym
        $iren Key${event}Event
        $iren SetEventInformationFlipY $x $y $ctrl $shift $keysym 0 $keysym
        $iren CharEvent

Since vtkInteractorStyle and vtkInteractorStyleSwitch don't implement
OnKeyPress() or OnKeyRelease the duplication doesn't matter. But when you
press and release a key in vtkTkRenderWidget two CharEvents are triggered
and OnChar() is called twice.

One easy solution/work around is in Tcl:

bind $vtkw <KeyPress> { }; # there's a space between the brackets

This just disables the binding for KeyPress so just KeyRelease will call
OnChar() once.

Alternatively, vtkInteractorStyle.cxx can be changed by renaming
vtkInteractorStyle::OnChar() to vtkInteractorStyle::OnKeyRelease(). So....

line860 changes from
void vtkInteractorStyle::OnChar()

to
void vtkInteractorStyle::OnKeyRelease

and change vtkInteractorStyle.h accordingly

virtual void OnChar(); --> virtual void OnChar() {};
virtual void OnKeyRelease() {}; --> virtual void OnKeyRelease();

I'd be gratefull if someone could have a look at this,

Goodwin


----- Original Message -----
From: "Goodwin Lawlor" <goodwin.lawlor at ucd.ie>
To: "VTK" <vtkusers at public.kitware.com>
Sent: Tuesday, September 03, 2002 6:57 PM
Subject: Re: [vtkusers] Bug with picking in a vtkTkRenderWidget


> Actually the problem is that one "pick" is performed when you press the
"p"
> key and another when you release the "p" key... any ideas where in the
> source code this could be corrected?
>
> Thanks,
> Goodwin
> University College Dublin
> ----- Original Message -----
> From: "Goodwin Lawlor" <goodwin.lawlor at ucd.ie>
> To: "VTK" <vtkusers at public.kitware.com>
> Sent: Tuesday, September 03, 2002 6:08 PM
> Subject: [vtkusers] Bug with picking in a vtkTkRenderWidget
>
>
> > Hi All,
> >
> > There seems to be a bug when picking in a vtkTkRenderWidget with vtk4.x.
> For
> > every one "p" key-press, there are two PickEvents being triggered (and I
> > think two Pick commands being performed). It could be I have
misunderstood
> > something with the new way of handling Tcl events in vtk4.x - I'd be
> > gratefull if you could point me in the right direction.
> >
> > My setup: WinXP/bcc32/cvs-28Aug2002
> >
> > Attached is an example Tcl script to illustrate the problem. Just run
the
> > script and press "p" a couple of times in the RenderWindow.
> >
> > Thanks,
> >
> > Goodwin
> > University College Dublin
> >
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020905/cce671d8/attachment.htm>


More information about the vtkusers mailing list