[vtkusers] vtkWin32OpenGLRenderWindow GetEventPending Bug

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Wed Aug 27 16:51:38 EDT 2003


Nicholas

I've just committed a fix (of sorts) for this.
All I've added is an extra PeekMessage with REMOVE set to true if the
message waiting is a MOUSEMOVE one. It seems that the Mousedown/up never get
to us because there's always a mousemove first. Once the mousemove gets in
there...it jams the pipe as it were and we can't move on. Flushing it out
seems to dramatically improve things.

JB

RPD - A Graphical Pipeline Editor for VTK
http://www.skippingmouse.co.uk



----- Original Message ----- 
From: "Nicholas Schwarz" <schwarz at evl.uic.edu>
To: <vtkusers at vtk.org>
Sent: Wednesday, August 20, 2003 4:12 AM
Subject: [vtkusers] vtkWin32OpenGLRenderWindow GetEventPending Bug


> Hi,
>
> I attempted to stop a long render when the user interacts with an object
> by using a callback and the AbortCheckMethod of vtkRenderWindow. Below is
> my C++ adaptation of the Tcl code on pages 257-258 of "The VTK User's
> Guide" for VTK 4.2.
>
> First, I made a callback class like this:
>
> class InteractionCallBack : public vtkCommand {
>
> public:
>
>   static InteractionCallBack* New() {
>     return new InteractionCallBack;
>   }
>
>   virtual void Execute(vtkObject* caller, unsigned long, void* data) {
>     vtkRenderWindow* renWin = vtkRenderWindow::SafeDownCast(caller);
>     if (renWin -> GetEventPending()) {
>       renWin -> SetAbortRender(1);
>     }
>   }
>
> };
>
> Later on in my code I added an observer for AbortCheckEvent like this:
>
> InteractionCallBack* icb = InteractionCallBack::New();
> renWin -> AddObserver(vtkCommand::AbortCheckEvent, icb);
>
> Of course, I included vtkRenderWindow.h, vtkCommand.h, and all the rest.
>
> This does not work in Windows. (It does work in Linux.) The render is not
> aborted when the user attempts to interact with the object. From testing I
> determined that the GetEventPending() method in my instance of
> vtkRenderWindow never returns 1; it always returns 0.
>
> I tested this code
>
> int vtkWin32OpenGLRenderWindow::GetEventPending()
> {
>   MSG msg;
>
>   if
(PeekMessage(&msg,this->WindowId,WM_MOUSEFIRST,WM_MOUSELAST,PM_NOREMOVE))
>     {
>       if ((msg.message == WM_LBUTTONDOWN) ||
>           (msg.message == WM_RBUTTONDOWN) ||
>           (msg.message == WM_MBUTTONDOWN))
>         {
>           return 1;
>         }
>     }
>
>   return 0;
> }
>
> from vtkWin32OpenGLRenderWindow (rev 1.115), and determined that the
> outside if statement does evaluate to true on the following events:
>
> WM_MOUSEFIRST,
> WM_MOUSEMOVE,
> WM_LBUTTONDOWN,
> WM_LBUTTONUP,
> WM_LBUTTONDBLCLK,
> WM_RBUTTONDOWN,
> WM_RBUTTONUP,
> WM_RBUTTONDBLCLK,
> WM_MBUTTONDOWN,
> WM_MBUTTONUP,
> WM_MBUTTONDBLCLK,
> WM_MOUSEWHEEL, and
> WM_MOUSELAST.
>
> That is what it should do. But, the inner if statement does not evaluate
> to true because 'msg.message' always evaluates to 0x0200, WM_MOUSEMOVE. It
> never evaluates to a mouse button down event, so it never returns 1.
>
> I noticed that the current GetEventPending() method was added in rev.
> 1.89, and replaces this (from rev. 1.88)
>
> int vtkWin32OpenGLRenderWindow::GetEventPending()
> {
>   MSG msg;
>
>   return
PeekMessage(&msg,this->WindowId,WM_LBUTTONDOWN,WM_MBUTTONDOWN,PM_NOREMOVE);
> }
>
> which DOES work properly.
>
> The way GetEventPending() is in rev. 1.115 should work, but it dosen't,
> and I don't know why. The current GetEventPending() implementation should
> also be better than 1.88's because it is only supposed to respond to
> button down events, but again, it dosen't work.
>
> Has anyone successfully gotten a revision newer than 1.88 to work
> properly, or has experienced this same problem?
>
> -------------------------------------------------------------------------
> Nicholas Schwarz
> Electronic Visualization Laboratory           E-Mail: schwarz at evl.uic.edu
> Department of Computer Science                Telephone: 312-996-3002
> University of Illinois at Chicago             Facsimile: 312-413-7585
> -------------------------------------------------------------------------
>
>
>
> _______________________________________________
> 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://www.vtk.org/mailman/listinfo/vtkusers
>




More information about the vtkusers mailing list