<div class="gmail_quote">On Wed, Mar 10, 2010 at 6:36 AM, Sebastian Gatzka <span dir="ltr">&lt;<a href="mailto:sebastian.gatzka@stud.tu-darmstadt.de">sebastian.gatzka@stud.tu-darmstadt.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">






<div bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Helvetica, Arial, sans-serif">Hello world.<br>
<br>
I have found the example for the catching of keys:
<a href="http://vtk.org/Wiki/VTK/Examples/Interaction/KeypressEvents" target="_blank">http://vtk.org/Wiki/VTK/Examples/Interaction/KeypressEvents</a><br>
This is great news to me, but I want to link different things:<br>
</font></font>
<ul>
  <li><small><font face="Helvetica, Arial, sans-serif">Wait for a key
to be pressed</font></small></li>
  <li><small><font face="Helvetica, Arial, sans-serif">On one special
key press change the normal direction of a vtkImplicitPlaneWidget2
representation</font></small></li>
  <li><small><font face="Helvetica, Arial, sans-serif">On a different
special key press change the center point of a vtkImplicitPlaneWidget2
representation</font></small></li>
  <li><small><font face="Helvetica, Arial, sans-serif">Write the new
normal direction and center point of the vtkImplicitPlaneWidget2
representation to a textActor to display the new values</font></small></li>
</ul>
<small><font face="Helvetica, Arial, sans-serif">So I think I will have
to link key press events and callbacks?<br>
I&#39;m really not sure how to handle this on my own<br>
<br>
You will notice that my previous posts are somhow related to the topic.<br>
This here is the final requirement to the code and include the steps I
have asked before.<br>
<br>
Sebastian</font></small><br>
</div><div bgcolor="#ffffff" text="#000000"><small><font face="Helvetica, Arial, sans-serif"><br></font></small></div></blockquote><div><br></div><div>You need to create a member variable of type vtkImplicitPlaneWidget2* in the interactor style subclass:</div>
<div><br></div><div>class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera</div><div><div>{</div><div>  public:</div><div>    static KeyPressInteractorStyle* New();</div><div> </div><div>    virtual void OnKeyPress() </div>
<div>    {</div><div>      //get the keypress</div><div>      vtkRenderWindowInteractor *rwi = this-&gt;Interactor;</div><div>      std::string key = rwi-&gt;GetKeySym();</div><div> </div><div>      //handle a &quot;normal&quot; key</div>
<div>      if(key.compare(&quot;a&quot;) == 0)</div><div>        {</div><div>        cout &lt;&lt; &quot;The a key was pressed.&quot; &lt;&lt; endl;</div><div>        }</div><div> </div><div>      // forward events</div><div>
      vtkInteractorStyleTrackballCamera::OnKeyPress();</div><div>    }</div><div> vtkImplicitPlaneWidget2* PlaneWidget;</div><div>  </div><div>};</div><div><br></div><div><br></div><div>Then from main:</div><div><br></div>
<div>vtkImplicitPlaneWidget2* planeWidget = vtkImplicitPlaneWidget2::New();</div><div>KeyPressInteractorStyle* style = KeyPressInteractorStyle::New();</div><div>style.PlaneWidget = planeWidget;</div><div><br></div><div>Then you can do whatever you want to the PlaneWidget from inside</div>
<div><br></div><div><div>      if(key.compare(&quot;a&quot;) == 0)</div><div>        {</div><div>//do something to the PlaneWidget when &#39;a&#39; is pressed</div><div>        }</div><div><br></div></div></div>Thanks,<br>
<br><div>David </div></div>