<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
David,<br>
that's exactly what I was looking for.<br>
Thanks a lot.<br>
Pof<br>
<br>
Le 12/02/2010 18:49, David Doria a &eacute;crit&nbsp;:
<blockquote
 cite="mid:c19fcadc1002120949m21d492d3ma5c08755aa5cc87b@mail.gmail.com"
 type="cite">
  <div class="gmail_quote">On Fri, Dec 11, 2009 at 7:35 PM, pof <span
 dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:jd379252@gmail.com">jd379252@gmail.com</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
I'm using a vtkInteractorStyleTerrain, and I would like to use the
mousewheel to do some zoom in/out towards the scene focal point,
actually pretty much like what is obtained using a 'L' keypress.<br>
I've tried to change the mousewheelfactor with SetMouseWheelFactor(2),
but still nothing happen at rendering (i.e. the camera does not move).<br>
I 've obviously missed something. Does anybody has an idea ?<br>
Thanks<br>
Pof<br>
    <br>
  </blockquote>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">You can subclass the interactor and change
any behaviors you like. Here, you'd be&nbsp;interested&nbsp;in
OnMouseWheelForward and OnMouseWheelBackward</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">Here is a demo:</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">
  <div class="gmail_quote">#include &lt;vtkSmartPointer.h&gt;</div>
  <div class="gmail_quote">#include &lt;vtkPolyDataMapper.h&gt;</div>
  <div class="gmail_quote">#include &lt;vtkActor.h&gt;</div>
  <div class="gmail_quote">#include &lt;vtkRenderWindow.h&gt;</div>
  <div class="gmail_quote">#include &lt;vtkRenderer.h&gt;</div>
  <div class="gmail_quote">#include &lt;vtkRenderWindowInteractor.h&gt;</div>
  <div class="gmail_quote">#include &lt;vtkPolyData.h&gt;</div>
  <div class="gmail_quote">#include &lt;vtkSphereSource.h&gt;</div>
  <div class="gmail_quote">#include &lt;vtkInteractorStyleTerrain.h&gt;</div>
  <div class="gmail_quote">#include &lt;vtkObjectFactory.h&gt;</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">class MyInteractorStyle : public
vtkInteractorStyleTerrain</div>
  <div class="gmail_quote">{</div>
  <div class="gmail_quote">&nbsp;&nbsp;public:</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;static MyInteractorStyle* New();</div>
  <div class="gmail_quote">&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;virtual void OnMouseWheelForward()&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;{</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;cout &lt;&lt; "Wheel forward" &lt;&lt;
endl;</div>
  <div class="gmail_quote">&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;vtkRenderWindowInteractor *rwi =
this-&gt;Interactor;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;
&nbsp;this-&gt;FindPokedRenderer(rwi-&gt;GetEventPosition()[0],</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;rwi-&gt;GetEventPosition()[1]);</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;this-&gt;CreateLatLong();</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;if (this-&gt;LatLongLines)&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;LatLongLinesOff();</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;else&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;double bounds[6];</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;this-&gt;CurrentRenderer-&gt;ComputeVisiblePropBounds( bounds );</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;double radius =
sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
(bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
(bounds[5]-bounds[4])*(bounds[5]-bounds[4])) /2.0;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;this-&gt;LatLongSphere-&gt;SetRadius( radius );</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;this-&gt;LatLongSphere-&gt;SetCenter((bounds[0]+bounds[1])/2.0,</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
(bounds[2]+bounds[3])/2.0,</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
(bounds[4]+bounds[5])/2.0); &nbsp; &nbsp; &nbsp; &nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;LatLongLinesOn();</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;this-&gt;SelectRepresentation();</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;rwi-&gt;Render();</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;// forward events</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;
&nbsp;vtkInteractorStyleTerrain::OnMouseWheelForward();</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;}</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;virtual void OnMouseWheelBackward()&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;{</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;cout &lt;&lt; "Wheel backward"
&lt;&lt; endl;</div>
  <div class="gmail_quote">&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;// forward events</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;
&nbsp;vtkInteractorStyleTerrain::OnMouseWheelBackward();</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;}</div>
  <div class="gmail_quote">&nbsp;</div>
  <div class="gmail_quote">};</div>
  <div class="gmail_quote">vtkStandardNewMacro(MyInteractorStyle);</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">int main (int argc, char *argv[])</div>
  <div class="gmail_quote">{</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">&nbsp;&nbsp;vtkSmartPointer&lt;vtkSphereSource&gt;
sphereSource =&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;
&nbsp;vtkSmartPointer&lt;vtkSphereSource&gt;::New();</div>
  <div class="gmail_quote">&nbsp;&nbsp;sphereSource-&gt;Update();</div>
  <div class="gmail_quote">&nbsp;&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp;//create a mapper and actor</div>
  <div class="gmail_quote">&nbsp;&nbsp;vtkSmartPointer&lt;vtkPolyDataMapper&gt;
mapper =&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;
&nbsp;vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();</div>
  <div class="gmail_quote">&nbsp;&nbsp;mapper-&gt;SetInputConnection(sphereSource-&gt;GetOutputPort());</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">&nbsp;&nbsp;vtkSmartPointer&lt;vtkActor&gt; actor =&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp; &nbsp;vtkSmartPointer&lt;vtkActor&gt;::New();</div>
  <div class="gmail_quote">&nbsp;&nbsp;actor-&gt;SetMapper(mapper);</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">&nbsp;&nbsp;// a renderer and render window</div>
  <div class="gmail_quote">&nbsp;&nbsp;vtkSmartPointer&lt;vtkRenderer&gt;
renderer =&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;
&nbsp;vtkSmartPointer&lt;vtkRenderer&gt;::New();</div>
  <div class="gmail_quote">&nbsp;&nbsp;vtkSmartPointer&lt;vtkRenderWindow&gt;
renderWindow =&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;
&nbsp;vtkSmartPointer&lt;vtkRenderWindow&gt;::New();</div>
  <div class="gmail_quote">&nbsp;&nbsp;renderWindow-&gt;AddRenderer(renderer);</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">&nbsp;&nbsp;// an interactor</div>
  <div class="gmail_quote">&nbsp;&nbsp;vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;
renderWindowInteractor =&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; &nbsp;
&nbsp;vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();</div>
  <div class="gmail_quote">&nbsp;&nbsp;renderWindowInteractor-&gt;SetRenderWindow(renderWindow);</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">&nbsp;&nbsp;// add the actors to the scene</div>
  <div class="gmail_quote">&nbsp;&nbsp;renderer-&gt;AddActor(actor);</div>
  <div class="gmail_quote">&nbsp;&nbsp;renderer-&gt;SetBackground(1,1,1); //
Background color white</div>
  <div class="gmail_quote">&nbsp;&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp;renderWindow-&gt;Render();</div>
  <div class="gmail_quote"><br>
  </div>
  <div class="gmail_quote">&nbsp;//
vtkSmartPointer&lt;vtkInteractorStyleTerrain&gt; style =&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp; // &nbsp;
vtkSmartPointer&lt;vtkInteractorStyleTerrain&gt;::New();</div>
  <div class="gmail_quote">&nbsp;&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp;vtkSmartPointer&lt;MyInteractorStyle&gt;
style =&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp;
&nbsp;vtkSmartPointer&lt;MyInteractorStyle&gt;::New();</div>
  <div class="gmail_quote">&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp;renderWindowInteractor-&gt;SetInteractorStyle(
style );</div>
  <div class="gmail_quote">&nbsp;&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp;renderWindowInteractor-&gt;Start();</div>
  <div class="gmail_quote">&nbsp;&nbsp;</div>
  <div class="gmail_quote">&nbsp;&nbsp;return EXIT_SUCCESS;</div>
  <div class="gmail_quote">}</div>
  </div>
  <br clear="all">
Thanks,<br>
  <br>
  <div>David&nbsp;</div>
  </div>
</blockquote>
<br>
</body>
</html>