<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi everyone,<div class=""><br class=""></div><div class="">I try to use the mouse wheel on a <span class="">vtkResliceImageViewer in a Qt window.</span></div><span class=""><br class=""></span><div class="">I try to add a callback to the vtkImageInteractorStyle like this:</div><div class=""><br class=""></div><div class="">
<pre style="margin-top: 0px; margin-bottom: 0px;" class="">
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><!--StartFragment--><span style=" color:#800080;" class="">QtVTKExample</span>::<span style=" font-weight:600; color:#00677c; background-color:#ffffff;" class="">QtVTKExample</span>(<span style=" color:#800080;" class="">QWidget</span><span style=" color:#c0c0c0;" class=""> </span>*<span style=" color:#092e64;" class="">parent</span>)<span style=" color:#c0c0c0;" class=""> </span>:<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">QWidget</span>(<span style=" color:#092e64;" class="">parent</span>)</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class="">{</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_layout</span><span style=" color:#c0c0c0;" class=""> </span><span style=" background-color:#ffffff;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#808000;" class="">new</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">QVBoxLayout</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_window</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#00677c; background-color:#ffffff;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkSmartPointer</span><<span style=" color:#800080;" class="">vtkGenericOpenGLRenderWindow</span>>::<span style=" color:#00677c;" class="">New</span>();</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_widget</span><span style=" color:#c0c0c0;" class=""> </span><span style=" background-color:#ffffff;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#808000;" class="">new</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">QVTKOpenGLWidget</span>(<span style=" color:#808000;" class="">this</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_widget</span>-><span style=" color:#00677c;" class="">SetRenderWindow</span>(<span style=" color:#800000;" class="">m_window</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_image</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#00677c; background-color:#ffffff;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkSmartPointer</span><<span style=" color:#800080;" class="">vtkImageData</span>>::<span style=" color:#00677c;" class="">New</span>();</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_mapper</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#00677c; background-color:#ffffff;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkSmartPointer</span><<span style=" color:#800080;" class="">vtkImageResliceMapper</span>>::<span style=" color:#00677c;" class="">New</span>();</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_mapper</span><span style=" color:#00677c; background-color:#ffffff;" class="">-></span><span style=" color:#00677c;" class="">SetInputData</span>(<span style=" color:#800000;" class="">m_image</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_viewer</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#00677c; background-color:#ffffff;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkSmartPointer</span><<span style=" color:#800080;" class="">vtkResliceImageViewer</span>>::<span style=" color:#00677c;" class="">New</span>();</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_viewer</span><span style=" color:#00677c; background-color:#ffffff;" class="">-></span><span style=" font-style:italic; color:#00677c;" class="">SetRenderWindow</span>(<span style=" color:#800000;" class="">m_window</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_viewer</span><span style=" color:#00677c; background-color:#ffffff;" class="">-></span><span style=" font-style:italic; color:#00677c;" class="">SetupInteractor</span>(<span style=" color:#800000;" class="">m_window</span><span style=" color:#00677c; background-color:#ffffff;" class="">-></span><span style=" font-style:italic; color:#00677c;" class="">GetInteractor</span>());</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_viewer</span><span style=" color:#00677c; background-color:#ffffff;" class="">-></span><span style=" font-style:italic; color:#00677c;" class="">GetImageActor</span>()-><span style=" color:#00677c;" class="">SetMapper</span>(<span style=" color:#800000;" class="">m_mapper</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#00677c;" class="">addObservers</span>();</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_layout</span>-><span style=" color:#00677c;" class="">addWidget</span>(<span style=" color:#800000;" class="">m_widget</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#00677c;" class="">setLayout</span>(<span style=" color:#800000;" class="">m_layout</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class="">}</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#808000;" class="">void</span><span style=" color:#c0c0c0;" class=""> </span><span style=" font-weight:600; color:#00677c; background-color:#ffffff;" class="">WheelBackwardFunction</span><span style=" color:#c0c0c0;" class=""> </span>(<span style=" color:#800080;" class="">vtkObject</span>*, <span style="color: rgb(128, 128, 0);" class="">long</span><span style="color: rgb(192, 192, 192);" class=""> </span><span style="color: rgb(128, 128, 0);" class="">unsigned</span><span style="color: rgb(192, 192, 192);" class=""> </span><span style="color: rgb(128, 128, 0);" class="">int</span>,<span style="color: rgb(192, 192, 192);" class=""> </span><span style="color: rgb(128, 128, 0);" class="">void</span>*,<span style="color: rgb(192, 192, 192);" class=""> </span><span style="color: rgb(128, 128, 0);" class="">void</span>*)</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class="">{</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>std::<span style=" color:#ce5c00;" class="">cout</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"wheel</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">backward"</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">std</span>::<span style=" color:#00677c;" class="">endl</span>;</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class="">}</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#808000;" class="">void</span><span style=" color:#c0c0c0;" class=""> </span><span style=" font-weight:600; color:#00677c; background-color:#ffffff;" class="">WheelForwardFunction</span><span style=" color:#c0c0c0;" class=""> </span>(<span style=" color:#800080;" class="">vtkObject</span>*, <span style="color: rgb(128, 128, 0);" class="">long</span><span style="color: rgb(192, 192, 192);" class=""> </span><span style="color: rgb(128, 128, 0);" class="">unsigned</span><span style="color: rgb(192, 192, 192);" class=""> </span><span style="color: rgb(128, 128, 0);" class="">int</span>, <span style="color: rgb(128, 128, 0);" class="">void</span>*,<span style="color: rgb(192, 192, 192);" class=""> </span><span style="color: rgb(128, 128, 0);" class="">void</span>*)</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class="">{</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>std::<span style=" color:#ce5c00;" class="">cout</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"wheel</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">forward"</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">std</span>::<span style=" color:#00677c;" class="">endl</span>;</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class="">}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#808000;" class="">void</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">QtVTKExample</span>::<span style=" font-weight:600; color:#00677c; background-color:#ffffff;" class="">addObservers</span>()</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class="">{</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_wheelForward</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#00677c; background-color:#ffffff;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkSmartPointer</span><<span style=" color:#800080;" class="">vtkCallbackCommand</span>>::<span style=" color:#00677c;" class="">New</span>();</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_wheelBackward</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#00677c; background-color:#ffffff;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkSmartPointer</span><<span style=" color:#800080;" class="">vtkCallbackCommand</span>>::<span style=" color:#00677c;" class="">New</span>();</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_wheelForward</span><span style=" color:#00677c; background-color:#ffffff;" class="">-></span><span style=" font-style:italic; color:#00677c;" class="">SetCallback</span>(<span style=" color:#00677c;" class="">WheelForwardFunction</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_wheelBackward</span><span style=" color:#00677c; background-color:#ffffff;" class="">-></span><span style=" font-style:italic; color:#00677c;" class="">SetCallback</span>(<span style=" color:#00677c;" class="">WheelBackwardFunction</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_viewer</span><span style=" color:#00677c; background-color:#ffffff;" class="">-></span><span style=" font-style:italic; color:#00677c;" class="">GetInteractorStyle</span>()-><span style=" color:#00677c;" class="">AddObserver</span>(<span style=" color:#800080;" class="">vtkCommand</span>::<span style=" color:#800080;" class="">MouseWheelForwardEvent</span>,<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_wheelForward</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_viewer</span><span style=" color:#00677c; background-color:#ffffff;" class="">-></span><span style=" font-style:italic; color:#00677c;" class="">GetInteractorStyle</span>()-><span style=" color:#00677c;" class="">AddObserver</span>(<span style=" color:#800080;" class="">vtkCommand</span>::<span style=" color:#800080;" class="">MouseWheelBackwardEvent</span>,<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800000;" class="">m_wheelBackward</span>);</pre><pre style="margin-top: 0px; margin-bottom: 0px;" class="">}<!--EndFragment--></pre><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The window opens, with no warnings but the callback function are never called.</div><div class=""><br class=""></div><div class="">What did I do wrong?</div><div class=""><br class=""></div><div class="">Thank you,</div><div class=""><br class=""></div><div class="">Romain</div></pre></div><div class=""><br class=""></div></body></html>