<!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>&nbsp;</DIV>
<DIV><FONT face=Arial>After rendering each frame, allow any queued messages to 
be processed -</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp;.....</P>
<P>&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp; self-&gt;Render();</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 
size=2>&nbsp;&nbsp;&nbsp; // Allow interaction with the scene and 
UI.</P></FONT></FONT><FONT size=2>
<P>&nbsp;&nbsp;&nbsp; self-&gt;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>&nbsp;</P>
<P><FONT face=Arial>This is an MFC implementation of Pump() -</FONT></P>
<P><FONT face=Arial></FONT>&nbsp;</P><FONT size=2><FONT size=2>
<P>BOOL Pump()</P></FONT><FONT size=2>
<P>{</P></FONT><FONT size=2>
<P>&nbsp;&nbsp;&nbsp; MSG msg;</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp; while</FONT></FONT><FONT size=2> ( ::PeekMessage( 
&amp;msg, NULL, 0, 0, PM_NOREMOVE ) )</P>
<P>&nbsp;&nbsp;&nbsp; {</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if</FONT></FONT><FONT size=2> ( ! 
AfxGetThread()-&gt;PumpMessage() )</P>
<P>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</P>
<P>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ::PostQuitMessage( 0 
);</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
return</FONT></FONT><FONT size=2> FALSE;</P>
<P>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; }</P></FONT><FONT size=2>
<P>&nbsp;&nbsp;&nbsp; LONG lIdle = 0;</P></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp; while</FONT></FONT><FONT size=2> ( 
AfxGetThread()-&gt;OnIdle( lIdle++ ) );</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>&nbsp;&nbsp;&nbsp; return</FONT></FONT><FONT size=2> TRUE;</P>
<P>}</P>
<P><FONT face=Arial></FONT>&nbsp;</P>
<P><FONT face=Arial>This seems to works OK on Windows.</FONT></P>
<P><FONT face=Arial></FONT>&nbsp;</P>
<P><FONT face=Arial>HTH</FONT></P>
<P><FONT face=Arial></FONT>&nbsp;</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>&nbsp; scene-&gt;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>&gt; Date: Thu, 10 Sep 2009 
  17:06:39 +0100<BR>&gt; Subject: Re: [vtkusers] Animation without 
  polling?<BR>&gt; From: mark.gooding@gmail.com<BR>&gt; To: 
  guidorodriguez1952@hotmail.com<BR>&gt; CC: vtkusers@vtk.org<BR>&gt; <BR>&gt; 
  you shouldn't have to write a complete vtkRenderWindowInteractor, just<BR>&gt; 
  add an observe to handle AnimationCueTickEvents<BR>&gt; <BR>&gt; 
  http://www.vtk.org/doc/nightly/html/classvtkCommand.html<BR>&gt; <BR>&gt; i'll 
  try to send you more detailed information later. I don't have my<BR>&gt; 
  software which did animation to hand right now.<BR>&gt; <BR>&gt; Mark<BR>&gt; 
  <BR>&gt; <BR>&gt; 2009/9/10 Guido Rodriguez 
  &lt;guidorodriguez1952@hotmail.com&gt;:<BR>&gt; &gt; Dear VTK 
  users/developers,<BR>&gt; &gt; I ask for guidance, how animated visualization 
  is done right with VTK. What<BR>&gt; &gt; I have in mind is an application 
  which calculates, let's say, a temperature<BR>&gt; &gt; field, which changes 
  in time. Whenever the field is completely calculated<BR>&gt; &gt; for the next 
  time step, the visualization should be updated. In parallel,<BR>&gt; &gt; the 
  user should be able to work with the mouse/key controls to rotate the<BR>&gt; 
  &gt; view, zoom, interact with 3D widgets, etc.<BR>&gt; &gt;<BR>&gt; &gt; The 
  obvious way would be to run VTK in one thread, and the calculation in<BR>&gt; 
  &gt; another. Each finished calculation step would notify VTK to update. But 
  it<BR>&gt; &gt; doesn't work like this. At least not with the X windows 
  system. When I call<BR>&gt; &gt; some pipeline's Update() function from a 
  different thread, I get an "invalid<BR>&gt; &gt; thread access".<BR>&gt; 
  &gt;<BR>&gt; &gt; Next attempt. I implement an event buffer, which is written 
  to by the<BR>&gt; &gt; calculation thread, and which is read from by the VTK 
  thread. This works<BR>&gt; &gt; like a charm. Now VTK can check whether an 
  update is necessary and get the<BR>&gt; &gt; required data from the event 
  buffer. But _when_ does VTK check for updates?<BR>&gt; &gt; I can't seem to 
  find a solution which sets VTK to sleep until either a<BR>&gt; &gt; mouse/key 
  event happens or until the calculation thread releases some lock,<BR>&gt; &gt; 
  simply because any VTK callback waiting for notification from a 
  different<BR>&gt; &gt; thread would stop VTK from reacting to mouse/key events 
  during this period.<BR>&gt; &gt;<BR>&gt; &gt; The only solution I can see is 
  to add a timer event like every 10 ms, which<BR>&gt; &gt; checks the event 
  buffer for updates. This works, but is it recommended?<BR>&gt; &gt; Threading 
  libraries have introduced locks and notification to avoid the<BR>&gt; &gt; 
  overhead from polling at interactive rates for events that may occur 
  only<BR>&gt; &gt; every few seconds. How can good multithreading programming 
  styles be applied<BR>&gt; &gt; to VTK?<BR>&gt; &gt;<BR>&gt; &gt; I hope the 
  problem is clear. Can a different thread trigger pipeline updates<BR>&gt; &gt; 
  under X windows? Or do I have to write my own 
  vtkRenderWindowInteractor?<BR>&gt; &gt;<BR>&gt; &gt; Regards,<BR>&gt; &gt; 
  Guido<BR>&gt; &gt; ________________________________<BR>&gt; &gt; With Windows 
  Live, you can organize, edit, and share your photos.<BR>&gt; &gt; 
  _______________________________________________<BR>&gt; &gt; Powered by 
  www.kitware.com<BR>&gt; &gt;<BR>&gt; &gt; Visit other Kitware open-source 
  projects at<BR>&gt; &gt; 
  http://www.kitware.com/opensource/opensource.html<BR>&gt; &gt;<BR>&gt; &gt; 
  Please keep messages on-topic and check the VTK FAQ at:<BR>&gt; &gt; 
  http://www.vtk.org/Wiki/VTK_FAQ<BR>&gt; &gt;<BR>&gt; &gt; Follow this link to 
  subscribe/unsubscribe:<BR>&gt; &gt; 
  http://www.vtk.org/mailman/listinfo/vtkusers<BR>&gt; &gt;<BR>&gt; &gt;<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>