<div dir="ltr">I think you are missing the setting of the interactor in the render window, e.g.,<div><br></div><div><span style="font-size:12.8px">renderWindow->SetInteractor(renderWindowInteractor);</span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 7, 2016 at 11:07 AM, aria dob <span dir="ltr"><<a href="mailto:minaninina1@gmail.com" target="_blank">minaninina1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">this is my program<br>
<div><div class="h5"><br>
<br>
#include "stdafx.h"<br>
#include <vtkPolyData.h><br>
#include <vtkArrowSource.h><br>
#include <vtkSmartPointer.h><br>
#include <vtkPolyDataMapper.h><br>
#include <vtkActor.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderer.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkPolyDataReader.h><br>
#include <vtkProperty.h><br>
#include <vtkTextActor.h><br>
#include <vtkTextProperty.h><br>
#include <vtkTriangleFilter.h><br>
#include <vtkTriangleFilter.h><br>
#include <vtkOBBTree.h><br>
#include <vtkCellArray.h><br>
#include <vtkPoints.h><br>
#include <vtkDataSet.h><br>
#include <vtkInteractorStyleTrackballCamera.h><br>
#include<vtkObjectFactory.h><br>
<br>
vtkSmartPointer<vtkActor> act =vtkSmartPointer<vtkActor>::New();<br>
 vtkSmartPointer<vtkRenderer> renderer =vtkSmartPointer<vtkRenderer>::New();<br>
  vtkSmartPointer<vtkRenderWindow> renderWindow<br>
=vtkSmartPointer<vtkRenderWindow>::New();<br>
<br>
     vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor<br>
=vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
<br>
class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera<br>
{<br>
public:<br>
        static KeyPressInteractorStyle* New();<br>
        vtkTypeMacro(KeyPressInteractorStyle, vtkInteractorStyleTrackballCamera);<br>
<br>
        virtual void OnKeyPress()<br>
        {    double handpos[3] = {0.7,-1.2,2.6};<br>
<br>
       // Get the keypress<br>
                vtkRenderWindowInteractor *rwi = this->Interactor;<br>
                std::string key = rwi->GetKeySym();<br>
<br>
                // Output the key that was pressed<br>
                std::cout << "Pressed " << key << std::endl;<br>
<br>
                // Handle an arrow key<br>
                if (key == "Up")<br>
                {<br>
                        std::cout << "The up arrow was pressed." << std::endl;<br>
                        handpos[0]++;<br>
                        act->SetPosition(handpos[0], handpos[1], handpos[2]);<br>
                        renderer->Render();<br>
                        renderWindow->Render();<br>
                }<br>
<br>
                if (key == "a")<br>
                {<br>
                        std::cout << "The up arrow was pressed." << std::endl;<br>
                        handpos[1]++;<br>
                        act->SetPosition(handpos[0], handpos[1], handpos[2]);<br>
                        renderer->Render();<br>
                        renderWindow->Render();<br>
                }<br>
                if (key == "h")<br>
                {<br>
                        std::cout << "The up arrow was pressed." << std::endl;<br>
                        handpos[2]++;<br>
                        act->SetPosition(handpos[0], handpos[1], handpos[2]);<br>
                        renderer->Render();<br>
                        renderWindow->Render();<br>
                }<br>
                // Forward events<br>
                vtkInteractorStyleTrackballCamera::OnKeyPress();<br>
        }<br>
};<br>
vtkStandardNewMacro(KeyPressInteractorStyle);<br>
<br>
</div></div>int _tmain(int argc, _TCHAR* argv[])<br>
{<br>
// ajouter la main<br>
vtkPolyDataReader *read= vtkPolyDataReader::New ();<br>
read->SetFileName("C:/hand.vtk");<br>
read->Update();<br>
// Create a mapper and actor(la main)<br>
vtkSmartPointer<vtkPolyDataMapper> map<br>
=vtkSmartPointer<vtkPolyDataMapper>::New();<br>
map->SetInputConnection(read->GetOutputPort());<br>
//act->GetProperty()->SetColor(1.0,0.49,0.25);<br>
act->SetMapper(map);<br>
act->SetPosition(0.7,-1.2,2.6);<br>
act->SetScale(0.09);<br>
act->RotateX(0);<br>
act->GetProperty()->SetColor(1.0,0.49,0.25);<br>
 // act->GetProperty()->SetEdgeColor(0,0,0);<br>
act->GetProperty()->EdgeVisibilityOn();<br>
renderWindow->AddRenderer(renderer);<br>
  renderWindowInteractor->SetRenderWindow(renderWindow);<br>
<br>
    vtkSmartPointer<KeyPressInteractorStyle> style =<br>
vtkSmartPointer<KeyPressInteractorStyle>::New();<br>
  renderWindowInteractor->SetInteractorStyle(style);<br>
  style->SetCurrentRenderer(renderer);<br>
<br>
 renderer->AddActor(act);<br>
  renderer->SetBackground(.1, .2, .3); // Background color dark blue<br>
<br>
  renderWindow->SetSize(1300,700);<br>
<br>
         renderWindow->Render();<br>
  renderWindowInteractor->Start();<br>
<br>
<br>
        return(0)}<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/vtk-keyboard-keys-tp5737565p5737577.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/vtk-keyboard-keys-tp5737565p5737577.html</a><br>
<div class="HOEnZb"><div class="h5">Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" 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="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>