<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v = 
"urn:schemas-microsoft-com:vml" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:w = 
"urn:schemas-microsoft-com:office:word"><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18828"><!--[if !mso]>
<STYLE>v\:* {
        BEHAVIOR: url(#default#VML)
}
o\:* {
        BEHAVIOR: url(#default#VML)
}
w\:* {
        BEHAVIOR: url(#default#VML)
}
.shape {
        BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]-->
<STYLE>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</STYLE>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-US link=blue bgColor=#ffffff vLink=blue>
<DIV><FONT size=2 face=Arial>Hi Steve,</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>You may find it simpler to check for an interrupt 
after rendering each frame. There has been some discussion on this recently in 
the list.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>HTH</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2 face=Arial>John.</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=stevec@renci.org href="mailto:stevec@renci.org">Steve Chall</A> 
</DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=jerome.velut@gmail.com 
  href="mailto:jerome.velut@gmail.com">'Jérôme'</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> Thursday, October 29, 2009 5:31 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [vtkusers] Starting an 
  animation with a keypress,terminating with another keypress</DIV>
  <DIV><BR></DIV>
  <DIV class=Section1>
  <P class=MsoNormal><FONT size=2 face=Tahoma><SPAN 
  style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt">Jérôme,<o:p></o:p></SPAN></FONT></P>
  <P class=MsoNormal><FONT size=2 face=Tahoma><SPAN 
  style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt">Yes, precisely: I need to create 
  a new thread to do the animation, and interrupt that thread on the appropriate 
  keypress.&nbsp; Googling “vtk thread” now.&nbsp; 
  Thanks.<o:p></o:p></SPAN></FONT></P>
  <P class=MsoNormal><FONT size=2 face=Tahoma><SPAN 
  style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P class=MsoNormal><FONT size=2 face=Tahoma><SPAN 
  style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt">-Steve<o:p></o:p></SPAN></FONT></P>
  <P class=MsoNormal><FONT color=navy size=2 face=Arial><SPAN 
  style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <DIV>
  <DIV style="TEXT-ALIGN: center" class=MsoNormal align=center><FONT size=3 
  face="Times New Roman"><SPAN style="FONT-SIZE: 12pt">
  <HR tabIndex=-1 align=center SIZE=3 width="100%">
  </SPAN></FONT></DIV>
  <P class=MsoNormal><B><FONT size=2 face=Tahoma><SPAN 
  style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt; FONT-WEIGHT: bold">From:</SPAN></FONT></B><FONT 
  size=2 face=Tahoma><SPAN style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt"> Jérôme 
  [mailto:jerome.velut@gmail.com] <BR><B><SPAN 
  style="FONT-WEIGHT: bold">Sent:</SPAN></B> Thursday, October 29, 2009 12:47 
  PM<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Steve 
  Chall<BR><B><SPAN style="FONT-WEIGHT: bold">Cc:</SPAN></B> <A 
  href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</A><BR><B><SPAN 
  style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [vtkusers] Starting an 
  animation with a keypress, terminating with another 
  keypress</SPAN></FONT><o:p></o:p></P></DIV>
  <P class=MsoNormal><FONT size=3 face="Times New Roman"><SPAN 
  style="FONT-SIZE: 12pt"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P style="MARGIN-BOTTOM: 12pt" class=MsoNormal><FONT size=3 
  face="Times New Roman"><SPAN style="FONT-SIZE: 12pt">Hi, <BR>I think that the 
  source of your problem is that when you press 'a', you enter an infinite loop 
  from your main thread. You should call your Animate() function from another 
  thread. I remember that VTK has built-in thread manager classes. It could be a 
  solution.<BR><BR>Hope that helps.<BR>Jerome<o:p></o:p></SPAN></FONT></P>
  <DIV>
  <P class=MsoNormal><FONT size=3 face="Times New Roman"><SPAN 
  style="FONT-SIZE: 12pt">2009/10/29 Steve Chall &lt;<A 
  href="mailto:stevec@renci.org">stevec@renci.org</A>&gt;<o:p></o:p></SPAN></FONT></P>
  <P class=MsoNormal><FONT size=3 face="Times New Roman"><SPAN 
  style="FONT-SIZE: 12pt">Dear fellow VTK enthusiasts:<BR>I'd like to trigger an 
  animation from a keypress event, and then stop the<BR>animation with the same 
  keypress event. &nbsp;I've subclassed<BR>vtkInteractorStyleTrackballCamera 
  with an OnKeyPress() method that looks a<BR>lot like what's included below. 
  &nbsp;When the user presses a 
  key,<BR>myInteractorStyleTrackballCamera::OnKeyPress() is invoked, which (for 
  the<BR>selected key, say 'a') toggles myObject's isAnimating Boolean flag. 
  &nbsp;If<BR>after toggling the flag is true, I want to start an animation 
  loop. &nbsp;If<BR>after toggling it's false, I want to stop that same loop. 
  &nbsp;But once I start<BR>the loop I can't penetrate with another 'a' keypress 
  (or anything else other<BR>than a &lt;Ctrl-C&gt;) to change the flag back to 
  false and thus stop the loop.<BR>How can I interrupt the "while (isAnimating)" 
  loop once it starts?<BR><BR>(I've also subclassed vtkRenderWindowInteractor 
  because its Start() function<BR>seems like a place for interrupts, but I don't 
  know what to do with it.)<BR><BR>Thanks for any help you may be able to 
  provide.<BR><BR>-Steve Chall<BR>&nbsp;Senior Research Software 
  Developer<BR>&nbsp;Renaissance Computing Institute<BR>&nbsp;Phone: 
  919-515-0051<BR>&nbsp;Email: <A 
  href="mailto:stevec@renci.org">stevec@renci.org</A><BR><BR>// Pseudo C++ 
  source code segments 
  follow:<BR><BR>...<BR>myClass::Animate()<BR>{<BR>&nbsp;while 
  (isAnimating)<BR>&nbsp;{<BR>&nbsp; 
  &nbsp;this-&gt;RenderNextFrame();<BR>&nbsp;}<BR>}<BR>...<BR><BR>myClass 
  *myObject = new myClass;<BR><BR>...<BR>void 
  myInteractorStyleTrackballCamera::OnKeyPress()<BR>{<BR>&nbsp;switch 
  (this-&gt;Interactor-&gt;GetKeyCode())<BR>&nbsp;{<BR>&nbsp; &nbsp;case 
  'a':<BR>&nbsp; &nbsp;case 'A':<BR>&nbsp; &nbsp; &nbsp;if (myObject)<BR>&nbsp; 
  &nbsp; &nbsp;{<BR>&nbsp; &nbsp; &nbsp; &nbsp;myObject-&gt;isAnimating = 
  !(myObject-&gt;isAnimating);<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp;if 
  (myObject-&gt;isAnimating)<BR>&nbsp; &nbsp; &nbsp; &nbsp;{<BR>&nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp;myObject-&gt;Animate();<BR>&nbsp; &nbsp; &nbsp; 
  &nbsp;}<BR>/* This is sort of what I'd like to do:<BR>&nbsp; &nbsp; &nbsp; 
  &nbsp;else<BR>&nbsp; &nbsp; &nbsp; &nbsp;{<BR>&nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp;myObject-&gt;StopAnimating();<BR>&nbsp; &nbsp; &nbsp; &nbsp;}<BR>&nbsp; 
  &nbsp; &nbsp;}<BR>*/<BR>&nbsp; &nbsp; &nbsp;break;<BR><BR>&nbsp; 
  &nbsp;default:<BR>&nbsp; &nbsp; 
  &nbsp;break;<BR>&nbsp;}<BR><BR>&nbsp;vtkInteractorStyleTrackballCamera::OnKeyPress();<BR>}<BR><BR><BR><BR><BR>_______________________________________________<BR>Powered 
  by <A href="http://www.kitware.com" 
  target=_blank>www.kitware.com</A><BR><BR>Visit other Kitware open-source 
  projects at <A href="http://www.kitware.com/opensource/opensource.html" 
  target=_blank>http://www.kitware.com/opensource/opensource.html</A><BR><BR>Please 
  keep messages on-topic and check the VTK FAQ at: <A 
  href="http://www.vtk.org/Wiki/VTK_FAQ" 
  target=_blank>http://www.vtk.org/Wiki/VTK_FAQ</A><BR><BR>Follow this link to 
  subscribe/unsubscribe:<BR><A 
  href="http://www.vtk.org/mailman/listinfo/vtkusers" 
  target=_blank>http://www.vtk.org/mailman/listinfo/vtkusers</A><o:p></o:p></SPAN></FONT></P></DIV>
  <P class=MsoNormal><FONT size=3 face="Times New Roman"><SPAN 
  style="FONT-SIZE: 12pt"><o:p>&nbsp;</o:p></SPAN></FONT></P></DIV>
  <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>