<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<STYLE>.hmmessage P {
        PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
}
BODY.hmmessage {
        FONT-FAMILY: Verdana; FONT-SIZE: 10pt
}
</STYLE>
<META name=GENERATOR content="MSHTML 8.00.6001.18812"></HEAD>
<BODY class=hmmessage bgColor=#ffffff>
<DIV><FONT face=Arial>Hi,</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>After rendering each frame, allow any queued messages to
be processed -</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff
size=2>case</FONT></FONT><FONT size=2> vtkCommand::AnimationCueTickEvent:</P>
<P>{</P><FONT size=2>
<P> .....</P>
<P> </P>
<P> self->Render();</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000
size=2> // Allow interaction with the scene and
UI.</P></FONT></FONT><FONT size=2>
<P> self->Pump();</P><FONT size=2>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff
size=2>break</FONT></FONT><FONT size=2>;</FONT></P>
<P><FONT size=2 face=Arial></FONT> </P>
<P><FONT face=Arial>This is an MFC implementation of Pump() -</FONT></P>
<P><FONT face=Arial></FONT> </P><FONT size=2><FONT size=2>
<P>BOOL Pump()</P></FONT><FONT size=2>
<P>{</P></FONT><FONT size=2>
<P> MSG msg;</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff
size=2> while</FONT></FONT><FONT size=2> ( ::PeekMessage(
&msg, NULL, 0, 0, PM_NOREMOVE ) )</P>
<P> {</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff
size=2> if</FONT></FONT><FONT size=2> ( !
AfxGetThread()->PumpMessage() )</P>
<P> {</P>
<P> ::PostQuitMessage( 0
);</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff
size=2>
return</FONT></FONT><FONT size=2> FALSE;</P>
<P> }</P>
<P> }</P></FONT><FONT size=2>
<P> LONG lIdle = 0;</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff
size=2> while</FONT></FONT><FONT size=2> (
AfxGetThread()->OnIdle( lIdle++ ) );</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff
size=2> return</FONT></FONT><FONT size=2> TRUE;</P>
<P>}</P>
<P><FONT face=Arial></FONT> </P>
<P><FONT face=Arial>This seems to works OK on Windows.</FONT></P>
<P><FONT face=Arial></FONT> </P>
<P><FONT face=Arial>HTH</FONT></P>
<P><FONT face=Arial></FONT> </P>
<P><FONT face=Arial>John.</FONT></P></FONT></FONT></FONT></FONT></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=guidorodriguez1952@hotmail.com
href="mailto:guidorodriguez1952@hotmail.com">Guido Rodriguez</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=mark.gooding@gmail.com
href="mailto:mark.gooding@gmail.com">mark.gooding@gmail.com</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Cc:</B> <A title=vtkusers@vtk.org
href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, September 11, 2009 8:57
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [vtkusers] Animation without
polling?</DIV>
<DIV><BR></DIV>Mark, thank you.<BR>I have found an example, how
vtkAnimationCues and vtkAnimationScenes can be used, at <A
href="http://www.vtk.org/pipermail/vtkusers/2005-April/079340.html">http://www.vtk.org/pipermail/vtkusers/2005-April/079340.html</A>.
I didn't know these animation classes before, and find them very
helpful.<BR><BR>But for the specific problem, how to run an animation parallel
to listening to mouse/key events, I don't see how this helps, yet.<BR>The
example above starts animation with<BR> scene->Play();<BR>How can
this coexist with a call to vtkRenderWindowInteractor::Start()?<BR>Both calls
run their own event loop, the one handling animation events, the other
handling interaction events.<BR><BR>I'm looking forward to your more detailed
information.<BR><BR>Regards,<BR>Guido<BR><BR>> Date: Thu, 10 Sep 2009
17:06:39 +0100<BR>> Subject: Re: [vtkusers] Animation without
polling?<BR>> From: mark.gooding@gmail.com<BR>> To:
guidorodriguez1952@hotmail.com<BR>> CC: vtkusers@vtk.org<BR>> <BR>>
you shouldn't have to write a complete vtkRenderWindowInteractor, just<BR>>
add an observe to handle AnimationCueTickEvents<BR>> <BR>>
http://www.vtk.org/doc/nightly/html/classvtkCommand.html<BR>> <BR>> i'll
try to send you more detailed information later. I don't have my<BR>>
software which did animation to hand right now.<BR>> <BR>> Mark<BR>>
<BR>> <BR>> 2009/9/10 Guido Rodriguez
<guidorodriguez1952@hotmail.com>:<BR>> > Dear VTK
users/developers,<BR>> > I ask for guidance, how animated visualization
is done right with VTK. What<BR>> > I have in mind is an application
which calculates, let's say, a temperature<BR>> > field, which changes
in time. Whenever the field is completely calculated<BR>> > for the next
time step, the visualization should be updated. In parallel,<BR>> > the
user should be able to work with the mouse/key controls to rotate the<BR>>
> view, zoom, interact with 3D widgets, etc.<BR>> ><BR>> > The
obvious way would be to run VTK in one thread, and the calculation in<BR>>
> another. Each finished calculation step would notify VTK to update. But
it<BR>> > doesn't work like this. At least not with the X windows
system. When I call<BR>> > some pipeline's Update() function from a
different thread, I get an "invalid<BR>> > thread access".<BR>>
><BR>> > Next attempt. I implement an event buffer, which is written
to by the<BR>> > calculation thread, and which is read from by the VTK
thread. This works<BR>> > like a charm. Now VTK can check whether an
update is necessary and get the<BR>> > required data from the event
buffer. But _when_ does VTK check for updates?<BR>> > I can't seem to
find a solution which sets VTK to sleep until either a<BR>> > mouse/key
event happens or until the calculation thread releases some lock,<BR>> >
simply because any VTK callback waiting for notification from a
different<BR>> > thread would stop VTK from reacting to mouse/key events
during this period.<BR>> ><BR>> > The only solution I can see is
to add a timer event like every 10 ms, which<BR>> > checks the event
buffer for updates. This works, but is it recommended?<BR>> > Threading
libraries have introduced locks and notification to avoid the<BR>> >
overhead from polling at interactive rates for events that may occur
only<BR>> > every few seconds. How can good multithreading programming
styles be applied<BR>> > to VTK?<BR>> ><BR>> > I hope the
problem is clear. Can a different thread trigger pipeline updates<BR>> >
under X windows? Or do I have to write my own
vtkRenderWindowInteractor?<BR>> ><BR>> > Regards,<BR>> >
Guido<BR>> > ________________________________<BR>> > With Windows
Live, you can organize, edit, and share your photos.<BR>> >
_______________________________________________<BR>> > Powered by
www.kitware.com<BR>> ><BR>> > Visit other Kitware open-source
projects at<BR>> >
http://www.kitware.com/opensource/opensource.html<BR>> ><BR>> >
Please keep messages on-topic and check the VTK FAQ at:<BR>> >
http://www.vtk.org/Wiki/VTK_FAQ<BR>> ><BR>> > Follow this link to
subscribe/unsubscribe:<BR>> >
http://www.vtk.org/mailman/listinfo/vtkusers<BR>> ><BR>> ><BR><BR>
<HR>
Share your memories online with anyone you want <A
href="http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1"
target=_new>anyone you want.</A>
<P>
<HR>
<P></P>_______________________________________________<BR>Powered by
www.kitware.com<BR><BR>Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html<BR><BR>Please keep messages
on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ<BR><BR>Follow this link to
subscribe/unsubscribe:<BR>http://www.vtk.org/mailman/listinfo/vtkusers<BR></BLOCKQUOTE></BODY></HTML>