<div dir="ltr"><p><font size="1">(This message was also posted in StackOverflow, those who want to start using it as a platform for help, can answer in <a href="http://stackoverflow.com/questions/31075569/vtk-rotate-actor-programmatically-while-vtkrenderwindowinteractor-is-active">this link</a>)</font><br></p><p>Hi all,<br></p><p>I'm trying to rotate a <code>vtkActor</code> using <code>vtkActor::RotateZ</code> and then calling <code>vtkRenderWindow::Render</code>. It works fine (it rotates the actor) but I can't move, resize, or even focus the window.</p>
<p>I suspected this was caused due to something not catching operating system events, so I added a <code>vtkRenderWindowInteractor</code> to the mix. Now I can move, resize and focus the window, but the actor is not rotating anymore.</p>
<p>I've isolated the code in the snippet below, comment line 43 to see both effects:</p>
<pre style class=""><code><span class="">renderWindowInteractor</span><span class="">-></span><span class="">Start</span><span class="">();</span></code></pre>
<p>I'm compiling VTK 6.2 with mingw-w64 (GCC 4.9.1), running in Windows 8.1. I've uploaded the code in <a href="https://github.com/Blito/VTK-SFML/tree/stackoverflow-question" rel="nofollow">this repo</a> with a small CMake setup so you can test it easily.</p>
<p>Thanks for your help!</p><p>-------------------------------<br></p><pre style class=""><code><span class="">constexpr</span><span class=""> </span><span class="">float</span><span class=""> planeWidth </span><span class="">=</span><span class=""> </span><span class="">200.0f</span><span class="">;</span><span class="">
</span><span class="">constexpr</span><span class=""> </span><span class="">float</span><span class=""> planeHeight </span><span class="">=</span><span class=""> </span><span class="">100.0f</span><span class="">;</span><span class="">
</span><span class="">int</span><span class=""> main</span><span class="">()</span><span class="">
</span><span class="">{</span><span class="">
</span><span class="">auto</span><span class=""> renderer </span><span class="">=</span><span class=""> vtkRenderer</span><span class="">::</span><span class="">New</span><span class="">();</span><span class="">
</span><span class="">// Create render window</span><span class="">
</span><span class="">auto</span><span class=""> renWin </span><span class="">=</span><span class=""> vtkRenderWindow</span><span class="">::</span><span class="">New</span><span class="">();</span><span class="">
renWin</span><span class="">-></span><span class="">AddRenderer</span><span class="">(</span><span class="">renderer</span><span class="">);</span><span class="">
renWin</span><span class="">-></span><span class="">SetSize</span><span class="">(</span><span class="">600</span><span class="">,</span><span class="">600</span><span class="">);</span><span class="">
</span><span class="">// Create a plane</span><span class="">
</span><span class="">auto</span><span class=""> texturedPlane </span><span class="">=</span><span class=""> vtkActor</span><span class="">::</span><span class="">New</span><span class="">();</span><span class="">
</span><span class="">auto</span><span class=""> plane </span><span class="">=</span><span class=""> vtkPlaneSource</span><span class="">::</span><span class="">New</span><span class="">();</span><span class="">
plane</span><span class="">-></span><span class="">SetOrigin</span><span class="">(</span><span class="">0</span><span class="">,</span><span class=""> planeHeight</span><span class="">,</span><span class=""> </span><span class="">0</span><span class="">);</span><span class="">
plane</span><span class="">-></span><span class="">SetPoint1</span><span class="">(</span><span class="">planeWidth</span><span class="">,</span><span class=""> planeHeight</span><span class="">,</span><span class=""> </span><span class="">0</span><span class="">);</span><span class="">
plane</span><span class="">-></span><span class="">SetPoint2</span><span class="">(</span><span class="">0</span><span class="">,</span><span class=""> </span><span class="">0</span><span class="">,</span><span class=""> </span><span class="">0</span><span class="">);</span><span class="">
</span><span class="">auto</span><span class=""> planeMapper </span><span class="">=</span><span class=""> vtkPolyDataMapper</span><span class="">::</span><span class="">New</span><span class="">();</span><span class="">
planeMapper</span><span class="">-></span><span class="">SetInputConnection</span><span class="">(</span><span class="">plane</span><span class="">-></span><span class="">GetOutputPort</span><span class="">());</span><span class="">
texturedPlane</span><span class="">-></span><span class="">SetMapper</span><span class="">(</span><span class="">planeMapper</span><span class="">);</span><span class="">
texturedPlane</span><span class="">-></span><span class="">SetOrigin</span><span class="">(</span><span class="">planeWidth </span><span class="">/</span><span class=""> </span><span class="">2</span><span class="">,</span><span class=""> planeHeight</span><span class="">,</span><span class=""> </span><span class="">0</span><span class="">);</span><span class="">
renderer</span><span class="">-></span><span class="">AddActor</span><span class="">(</span><span class="">texturedPlane</span><span class="">);</span><span class="">
renderer</span><span class="">-></span><span class="">ResetCamera</span><span class="">();</span><span class="">
</span><span class="">// Create a RenderWindowInteractor</span><span class="">
</span><span class="">auto</span><span class=""> renderWindowInteractor </span><span class="">=</span><span class=""> vtkRenderWindowInteractor</span><span class="">::</span><span class="">New</span><span class="">();</span><span class="">
renderWindowInteractor</span><span class="">-></span><span class="">SetRenderWindow</span><span class="">(</span><span class="">renWin</span><span class="">);</span><span class="">
renderWindowInteractor</span><span class="">-></span><span class="">Start</span><span class="">();</span><span class=""> </span><span class="">// <-- Comment this line!</span><span class="">
</span><span class="">// Render</span><span class="">
</span><span class="">float</span><span class=""> rot </span><span class="">=</span><span class=""> </span><span class="">0.0f</span><span class="">;</span><span class="">
</span><span class="">while</span><span class="">(</span><span class="">true</span><span class="">)</span><span class="">
</span><span class="">{</span><span class="">
texturedPlane</span><span class="">-></span><span class="">SetOrientation</span><span class="">(</span><span class="">0</span><span class="">,</span><span class="">0</span><span class="">,</span><span class="">0</span><span class="">);</span><span class="">
texturedPlane</span><span class="">-></span><span class="">RotateZ</span><span class="">(</span><span class="">rot</span><span class="">++);</span><span class="">
renWin</span><span class="">-></span><span class="">Render</span><span class="">();</span><span class="">
</span><span class="">}</span><span class="">
</span><span class="">}</span></code></pre></div>