<div class="gmail_extra">WOW!!! This fix made a HUGE difference in memory consumption for my project. Thank you so much. The other memory leak is still present however. I don't know what other information I can provide for you to show you the leak is there. Is there anyway that you can run my test program on a Windows box? I could send you a series of screen shots if you'd like to see the memory increase.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Thanks again for that other fix, it makes a big difference.<br><br><div class="gmail_quote">On Wed, Apr 25, 2012 at 9:49 PM, Jonathan Morra <span dir="ltr"><<a href="mailto:jonmorra@gmail.com" target="_blank">jonmorra@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>Also please let me know if/when it goes into the release branch.</p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Apr 25, 2012 9:48 PM, "Jonathan Morra" <<a href="mailto:jonmorra@gmail.com" target="_blank">jonmorra@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>Thanks for looking into this, I appreciate it, I'll let you know how it goes.</p>
<div class="gmail_quote">On Apr 25, 2012 9:45 PM, "Clinton Stimpson" <<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><br></div><div>Here's a fix for the leaks from the mousePressEvent.</div><div><a href="http://review.source.kitware.com/#/c/5360/" target="_blank">http://review.source.kitware.com/#/c/5360/</a></div>
<div>Its based off the release branch in case there is time to merge it.</div><div><br></div><div>I'm still unable to reproduce leaks from your mouseMoveEvent() code, but you could try again after applying the patch to fix the other one.</div>
<div>Or maybe someone else can report whether they see that leak.</div><div><br></div><div>Clint</div><div><br><div><div>On Apr 25, 2012, at 7:44 PM, Jonathan Morra wrote:</div><br><blockquote type="cite"><span>I have posted a version of this program to the users mailing list before but got minimal response. Since I have discovered a different memory leak in rendering. These two memory leaks are making my program extremely unstable, as they get magnified when rendering large objects. I'm stuck in my development cycle until these rendering issues get resolved, as a result I am very motivated to provide any extra comments, data, work that I can to help fix this problem.</span><div>
<br></div><div>Reproduced below is a test program that causes 2 memory issues in Windows 7 (both x86 and x64). Please let me know if you can reproduce these problems or not, and if you can fix them. Currently I'm hooking in GDCM as well (although not in this test program), so I cannot easily move to VTK 6 as GDCM currently does not compile for VTK 6, so if these bugs can be fixed on the release branch, that would be amazing.</div>
<div><br></div><div>Again, please contact me if you have any questions or would like more information.</div><div><br></div><div>Thanks</div><div><br></div><div><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><QtGui/QApplication></span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><QMainWindow></span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><QVTKWidget2.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkImageViewer2.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkImageData.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkPointData.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkGenericOpenGLRenderWindow.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkSphereSource.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkPolyDataMapper.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkActor.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkRenderer.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><vtkRenderWindow.h></span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">This</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">program</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">shows</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">2</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">separate</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">bugs</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">with</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">rendering.</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">/**</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">First,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">if</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">you</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">run</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">program</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">as</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">provided,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">and</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">either</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">move</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouse</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">over</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">image</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">or</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">press</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouse,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">notice</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">that</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">memory</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">stays</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">constant.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">The</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">first</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">bug</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">involves</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">consuming</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">memory</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">on</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">a</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">render</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">command</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">when</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">we're</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">just</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">rendering</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">an</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">image.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">In</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">order</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">to</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">see</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">this,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">comment</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">in</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">commented</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">out</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">line</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">in</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouseMoveEvent</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">method.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">Notice</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">that</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">as</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">you</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouse</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">around</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">memory</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">now</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">increases.</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">The</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">second</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">bug</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">involves</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">rendering</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">after</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">an</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">actor</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">has</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">been</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">added.</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">If</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">you</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">comment</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">in</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">one</span><span style="color:rgb(192,192,192)"> </span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">commented</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">out</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">line</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">in</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mousePressEvent,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">you</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">now</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">see</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">the</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">memory</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">jump</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">significantly</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">after</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">each</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">mouse</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">press.</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">I'm</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">testing</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">these</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">on</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">Qt</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">4.8.0</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">x64</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">Windows</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">VS</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">2008,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">VTK</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">pulled</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">from</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">git</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">release</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">branch,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">tag</span><span style="color:rgb(192,192,192)"> </span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">5.10.0-rc1. I'm monitoring the memory using the Windows Task Manager.</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">*/</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">class</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MyQVTKWidget2</span><span style="color:rgb(192,192,192)"> </span>:<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">public</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QVTKWidget2</span><span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkRenderer</span>><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">renderer</span>;</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">public</span>:</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MyQVTKWidget2</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageViewer2</span>><span style="color:rgb(192,192,192)"> </span>imageViewer,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QWidget</span><span style="color:rgb(192,192,192)"> </span>*parent<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>)<span style="color:rgb(192,192,192)"> </span>:<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QVTKWidget2</span>(parent)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">this</span>-><span style="color:rgb(128,0,0)">imageViewer</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>imageViewer;</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">renderer</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkRenderer</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic">GetRenderWindow</span>()-><span style="font-style:italic">AddRenderer</span>(<span style="color:rgb(128,0,0)">renderer</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">virtual</span><span style="color:rgb(192,192,192)"> </span>~<span style="font-style:italic">MyQVTKWidget2</span>()<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic">mouseMoveEvent</span>(<span style="color:rgb(128,0,128)">QMouseEvent</span><span style="color:rgb(192,192,192)"> </span>*)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span>i=<span style="color:rgb(0,0,128)">0</span>;<span style="color:rgb(192,192,192)"> </span>i<<span style="color:rgb(0,0,128)">1000</span>;<span style="color:rgb(192,192,192)"> </span>++i)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//imageViewer->Render();</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic">mousePressEvent</span>(<span style="color:rgb(128,0,128)">QMouseEvent</span><span style="color:rgb(192,192,192)"> </span>*)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkSphereSource</span>><span style="color:rgb(192,192,192)"> </span>sphereSource<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkSphereSource</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>sphereSource-><span style="font-style:italic">Update</span>();</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span>i=<span style="color:rgb(0,0,128)">0</span>;<span style="color:rgb(192,192,192)"> </span>i<<span style="color:rgb(0,0,128)">1000</span>;<span style="color:rgb(192,192,192)"> </span>++i)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkPolyDataMapper</span>><span style="color:rgb(192,192,192)"> </span>mapper<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkPolyDataMapper</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>mapper->SetInput(sphereSource->GetOutput());</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>mapper-><span style="font-style:italic">Update</span>();</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkActor</span>><span style="color:rgb(192,192,192)"> </span>actor<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkActor</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>actor-><span style="font-style:italic">SetMapper</span>(mapper);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">renderer</span>->AddActor(actor);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//renderer->Render();</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">renderer</span>->RemoveActor(actor);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">private</span>:</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageViewer2</span>><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">imageViewer</span>;</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">};</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span>main(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span>argc,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">char</span><span style="color:rgb(192,192,192)"> </span>*argv[])<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QApplication</span><span style="color:rgb(192,192,192)"> </span>a(argc,<span style="color:rgb(192,192,192)"> </span>argv);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageData</span>><span style="color:rgb(192,192,192)"> </span>imageData<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageData</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageData-><span style="font-style:italic">SetExtent</span>(<span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">100</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">100</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">100</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageData-><span style="font-style:italic">SetOrigin</span>(<span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageData-><span style="font-style:italic">SetSpacing</span>(<span style="color:rgb(0,0,128)">1</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageData-><span style="font-style:italic">AllocateScalars</span>();</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>imageData->GetPointData()->GetScalars()-><span style="font-style:italic">FillComponent</span>(<span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageViewer2</span>><span style="color:rgb(192,192,192)"> </span>imageViewer<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageViewer2</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageViewer-><span style="font-style:italic">SetInput</span>(imageData);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MyQVTKWidget2</span><span style="color:rgb(192,192,192)"> </span>*widget<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">new</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">MyQVTKWidget2</span>(imageViewer);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageViewer-><span style="font-style:italic">SetRenderWindow</span>(widget-><span style="font-style:italic">GetRenderWindow</span>());</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QMainWindow</span><span style="color:rgb(192,192,192)"> </span>mainWindow;</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>mainWindow.setGeometry(<span style="color:rgb(0,0,128)">200</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">200</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">300</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">300</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>mainWindow.setCentralWidget(widget);</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>mainWindow.show();</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">return</span><span style="color:rgb(192,192,192)"> </span>a.exec();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">}</pre></div>
_______________________________________________<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>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br><br></blockquote></div><br></div></div>
</blockquote></div>
</blockquote></div>
</div></div></blockquote></div><br></div>