<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi John,<br>unfortunately I no hardly anything about MFC. I was hoping for a system independent solution.<br><br>But maybe somebody can help to apply your suggestion to the (linux) X windows system?<br>An equivalent of "<font style="font-size: 10pt;" size="2"><font style="font-size: 10pt;" size="2"><font style="font-size: 10pt;" size="2"><font style="font-size: 10pt;" size="2">::PeekMessage(
&msg, NULL, 0, 0, PM_NOREMOVE )" is readily available (XNextEvent or XCheckIfEvent).<br>But I have no idea, what </font></font></font></font><font style="font-size: 10pt;" size="2"><font style="font-size: 10pt;" size="2"><font style="font-size: 10pt;" size="2"><font style="font-size: 10pt;" size="2">AfxGetThread()->PumpMessage() and </font></font></font></font><font style="font-size: 10pt;" size="2"><font size="2"><font size="2"><font style="font-size: 10pt;" size="2">AfxGetThread()->OnIdle() are supposed to do exactly, not to speak about implementation with X.<br>Moreover, I don't see, which vtk object will handle the queued messages in your code snippet. My limited understanding of vtkAnimationScene is that it only handles animation events. You'd need a vtkRenderWindowInteractor in addition, which would be in charge of the mouse/key event, don't you?. Can I find a complete example somewhere, which shows your snippet in context?<br><br>Regards,<br>Guido<br><br></font></font></font></font><hr id="stopSpelling">From: jcplatt@dsl.pipex.com<br>To: guidorodriguez1952@hotmail.com<br>CC: vtkusers@vtk.org<br>Subject: Re: [vtkusers] Animation without polling?<br>Date: Fri, 11 Sep 2009 09:51:30 +0100<br><br>
<style>
.ExternalClass .EC_hmmessage P
{padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;}
.ExternalClass BODY.EC_hmmessage
{font-family:Verdana;font-size:10pt;}
</style>
<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">
</font><font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff">case</font></font><font size="2"> vtkCommand::AnimationCueTickEvent:</font><BR>
<font size="2">{</font><BR><font size="2"><font size="2">
</font></font><font size="2"><font size="2"> .....</font></font><BR>
<font size="2"><font size="2"> </font></font><BR>
<font size="2"><font size="2"> self->Render();</font></font><BR>
<font size="2"><font size="2"></font><font size="2" color="#008000"><font size="2" color="#008000"> // Allow interaction with the scene and
UI.</font></font></font><BR><font size="2"><font size="2" color="#008000"><font size="2" color="#008000"></font></font><font size="2">
self->Pump();<BR><font size="2">
</font><font size="2">}</font><BR>
<font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff">break</font></font><font size="2">;</font><BR>
<font size="2" face="Arial"></font> <BR>
<font face="Arial">This is an MFC implementation of Pump() -</font><BR>
<font face="Arial"></font> <BR><font size="2"><font size="2">
BOOL Pump()<BR></font><font size="2">
{<BR></font><font size="2">
</font><font size="2"> MSG msg;</font><BR>
<font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> while</font></font><font size="2"> ( ::PeekMessage(
&msg, NULL, 0, 0, PM_NOREMOVE ) )</font><BR>
<font size="2"> {</font><BR><font size="2"></font><font size="2">
</font><font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> if</font></font><font size="2"> ( !
AfxGetThread()->PumpMessage() )</font><BR>
<font size="2"> {</font><BR>
<font size="2"> ::PostQuitMessage( 0
);</font><BR>
<font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff">
return</font></font><font size="2"> FALSE;</font><BR>
<font size="2"> }</font><BR>
<font size="2"> }</font><BR><font size="2"></font><font size="2">
LONG lIdle = 0;<BR></font><font size="2">
</font><font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> while</font></font><font size="2"> (
AfxGetThread()->OnIdle( lIdle++ ) );</font><BR>
<font size="2"></font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> return</font></font><font size="2"> TRUE;</font><BR>
<font size="2">}</font><BR>
<font size="2"><font face="Arial"></font> </font><BR>
<font size="2"><font face="Arial">This seems to works OK on Windows.</font></font><BR>
<font size="2"><font face="Arial"></font> </font><BR>
<font size="2"><font face="Arial">HTH</font></font><BR>
<font size="2"><font face="Arial"></font> </font><BR>
<font size="2"><font face="Arial">John.</font></font><BR><font size="2"></font></font></font></font></div>
<blockquote style="border-left: 2px solid rgb(0, 0, 0); padding-left: 5px; padding-right: 0px; margin-left: 5px; margin-right: 0px;">
<div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">----- Original Message ----- </div>
<div style="background: rgb(228, 228, 228) none repeat scroll 0% 0%; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b>From:</b>
<a title="guidorodriguez1952@hotmail.com" href="mailto:guidorodriguez1952@hotmail.com">Guido Rodriguez</a> </div>
<div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><b>To:</b> <a title="mark.gooding@gmail.com" href="mailto:mark.gooding@gmail.com">mark.gooding@gmail.com</a> </div>
<div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><b>Cc:</b> <a title="vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a> </div>
<div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><b>Sent:</b> Friday, September 11, 2009 8:57
AM</div>
<div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><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">anyone you want.</a>
<BR><hr>
<BR>_______________________________________________<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><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></body>
</html>