Thank you so much David for your help and your generous explanations :).<br>Well I follow the code to define a style to interact with the point cloud that I render. I made a simple example of a style class which if I press &#39;a&#39; button the camera parameters restores to default parameter, but I don&#39;t see any change :(, here is my class: <br>
<br><br>// Define interaction style<br>class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera<br>{<br>  public:<br>    static KeyPressInteractorStyle* New();<br>    vtkTypeMacro(KeyPressInteractorStyle, vtkInteractorStyleTrackballCamera);<br>
 <br>    virtual void OnKeyPress() <br>    {<br>      // Get the keypress<br>      vtkRenderWindowInteractor *rwi = this-&gt;Interactor;<br>      char key = rwi-&gt;GetKeyCode() ;<br> <br>     switch (key)<br>     {<br>             case &#39;a&#39;:<br>
                ren-&gt;ResetCamera();                            // To restore the camera parameters <br>                break;<br>     }<br> <br>      // Forward events<br>      vtkInteractorStyleTrackballCamera::OnKeyPress();<br>
    }<br> <br>};<br>vtkStandardNewMacro(KeyPressInteractorStyle);<br><br><br>int main()<br>{<br><br>//I use this class to define my style of interaction <br><br><br>}<br><br>Thank you so much<br><br><br><br><div class="gmail_quote">
On Tue, Mar 27, 2012 at 2:19 PM, David Doria-2-3 [via VTK] <span dir="ltr">&lt;<a href="/user/SendEmail.jtp?type=node&node=5597967&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">

        On Tue, Mar 27, 2012 at 5:08 AM, Jonas cv Fan
<br></div><div><div class="h5">&lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=5597676&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt; wrote:
<div><div class='shrinkable-quote'><br>&gt; Dear vtk users,
<br>&gt;
<br>&gt; I&#39;m newbie in VTK library. I decided to use it as a renderer of a content
<br>&gt; captured by the Kinect sensor. I grab first the depth maps using opencv
<br>&gt; after that I render it by VTK. All working fine until now. However I wanna
<br>&gt; add some keyboard buttons to interact easily with the displayed content (3D
<br>&gt; cloud): it&#39;s really basic:
<br>&gt;
<br>&gt; 1-Push &#39;*d*&#39; to display the 3D point cloud by VTK.
<br>&gt; 2-Push *&#39;k*&#39; to return to default camera settings.
<br>&gt; 3-Push &#39;*q*&#39; to quite.
<br>&gt;
<br>&gt; here is a snapping code that I wrote:
<br>&gt;
<br>&gt; // VTK headers
<br>&gt; *#include &lt;vtkSmartPointer.h&gt;
<br>&gt; .... etc*
<br>&gt; *int main()
<br>&gt; {*
<br>&gt;
<br>&gt; // 3D rendering rotines
<br>&gt;
<br>&gt;                //VTK Pipeline
<br>&gt;                *vtkSmartPointer&lt;vtkRenderer&gt; ren =
<br>&gt; vtkSmartPointer&lt;vtkRenderer&gt;::
<br>&gt; New();
<br>&gt;                renwin = vtkSmartPointer&lt;vtkRenderWindow&gt;::New();
<br>&gt;                renwin1 = vtkSmartPointer&lt;vtkRenderWindow&gt;::New();
<br>&gt;
<br>&gt;                vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; iren =
<br>&gt; vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();
<br>&gt;
<br>&gt;                renwin-&gt;AddRenderer(ren);
<br>&gt;                renwin-&gt;SetInteractor(iren);
<br>&gt;                renwin-&gt;SetSize(1280,800);
<br>&gt;                iren-&gt;Initialize();*
<br>&gt;
<br>&gt; // Main loop
<br>&gt;        while (1)
<br>&gt; // To capture the content from the kinect
<br>&gt; .....
<br>&gt; key= cvWaitKey(1);  // for opencv capture
<br>&gt;
<br>&gt; *if (key == &#39;q&#39;)* break;            // To quite
<br>&gt;                switch(key) {
<br>&gt;            /* &#39;1&#39; pressed, display the original image */
<br>&gt;          *  case &#39;d&#39;:*
<br>&gt;                cout&lt;&lt;&quot;The decomposition is running...&quot;&lt;&lt;endl;
<br>&gt;
<br>&gt;                        Display_cloud( renwin,pDepthMap);  // a function to
<br>&gt; display a cloud
<br>&gt; points
<br>&gt;                         renwin-&gt;Render();
<br>&gt;
<br>&gt;                        //Set up camera
<br>&gt;                        ren-&gt;ResetCamera();
<br>&gt;                        ren-&gt;GetActiveCamera()-&gt;Roll(180.0);
<br>&gt;                        ren-&gt;GetActiveCamera()-&gt;Azimuth(180.0);
<br>&gt;                        ren-&gt;GetActiveCamera()-&gt;Zoom(2.0);
<br>&gt;
<br>&gt;                        iren-&gt;Start();
<br>&gt;
<br>&gt;       *case &#39;k&#39;:*           //  to return to default camera settings.
<br>&gt;                ren-&gt;ResetCamera();
<br>&gt;                        ren-&gt;GetActiveCamera()-&gt;Roll(180.0);
<br>&gt;                        ren-&gt;GetActiveCamera()-&gt;Azimuth(180.0);
<br>&gt;                        ren-&gt;GetActiveCamera()-&gt;Zoom(2.0);
<br>&gt;
<br>&gt;                        iren-&gt;Start();
<br>&gt;                break;
<br>&gt; }
<br>&gt; }
<br>&gt;
<br>&gt; So I have two problems:
<br>&gt; 1-When I push *&#39;q&#39;* the program doesn&#39;t close correctly, visual studio send
<br>&gt; me to the vtkInformation.cxx to the line &quot; *i-&gt;first-&gt;Report(this,
<br>&gt; collector);*&quot;  in &quot;void
<br>&gt; *vtkInformation::ReportReferences(vtkGarbageCollector* collector)&quot;*
<br>&gt; function?!
<br>&gt; How can I avoid that?
<br>&gt;
<br>&gt; 2-When push &#39;k&#39; to return to default camera paramters it doesn&#39;t work..
<br>&gt; could you help me please?
<br>&gt; Thank you so much and sorry if my post is very long for you .
<br>&gt;
<br>&gt; Cheers for everyone
<br>&gt; Jo
</div></div></div></div><div class="im">I wrote something similar for a different time of flight camera:
<br><a href="https://github.com/daviddoria/vtkHokuyo" rel="nofollow" link="external" target="_blank">https://github.com/daviddoria/vtkHokuyo</a><br><br>I&#39;m not sure if there is any benefit of using a VTK timer like I did
<br>versus your while(1) loop.
<br><br>Also, it looks like you have taken a &quot;get the data, then draw it&quot;
<br>approach. In VTK the idea would change to &quot;display the data always,
<br>and update it when necessary&quot;. You use an &quot;InteractorStyle&quot; to handle
<br>the keypress events:
<br><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/KeypressEvents" rel="nofollow" link="external" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/KeypressEvents</a><br><br>To update the display once you get new data, you would just update the
<br>PolyData that is already attached to a mapper-&gt;actor-&gt;renderer (and
<br>call Modified() on it if necessary) and the renderer would
<br>automatically display the new points.
<br><br>Additionally, you could check out PCL (<a href="http://pointclouds.org" target="_blank" rel="nofollow" link="external">pointclouds.org</a>) - I think they
<br>already have this sort of thing written for the Kinect.
<br><br>Good luck,
<br><br>David
<br></div>_______________________________________________
<br>Powered by <a href="http://www.kitware.com" target="_blank" rel="nofollow" link="external">www.kitware.com</a>
<br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="nofollow" link="external" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br><br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="nofollow" link="external" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:
<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" rel="nofollow" link="external" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
        
        <br>
        <br>
        <hr color="#cccccc" noshade size="1">
        <div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://vtk.1045678.n5.nabble.com/using-VTK-with-keyboard-interaction-tp5597328p5597676.html" target="_blank" rel="nofollow" link="external">http://vtk.1045678.n5.nabble.com/using-VTK-with-keyboard-interaction-tp5597328p5597676.html</a>
        </div>
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from using VTK with keyboard interaction, <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>

                <a href="http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&amp;id=instant_html%21nabble%3Aemail.naml&amp;base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&amp;breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
        </div></blockquote></div><br>

        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/using-VTK-with-keyboard-interaction-tp5597328p5597967.html">Re: using VTK with keyboard interaction</a><br/>
Sent from the <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html">VTK - Users mailing list archive</a> at Nabble.com.<br/>