[ITK] [ITK-users] Interaction of keyboard

Jon Haitz Legarreta jhlegarreta at vicomtech.org
Thu Apr 7 17:18:08 EDT 2016


Hi Abdelkhalek,
ITK does not involve any Graphical User Interface, and thus, user
interaction does not fit in ITK's framework.

The issue (and the code) you describe are related to VTK.

I am sure that you will be able to find useful examples concerning this on
VTK's wiki [1].

HTH,
JON HAITZ


[1] http://www.vtk.org/Wiki/VTK/Examples



On 7 April 2016 at 22:34, Abdelkhalek Bakkari <
bakkari.abdelkhalek at hotmail.fr> wrote:

> Hi !
>
> I would like to interact the button of my keyboard in order to modify the
> position of a 3D object (translation) using up or down or left or right
> buttons.
>
> I created the following piece of code but it does not give results :
>
> ------------------------------------------------------------------------------------------------------------
> class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera {
> public: static KeyPressInteractorStyle* New();
> vtkTypeMacro(KeyPressInteractorStyle, vtkInteractorStyleTrackballCamera);
> virtual void OnKeyPress() { double handpos[3]={8.0,2.0, 0.0}; // Get the
> keypress vtkRenderWindowInteractor *rwi = this->Interactor; // vtkRenderer
> *rend=new(vtkRenderer); std::string key = rwi->GetKeySym(); // Output the
> key that was pressed std::cout << "Pressed " << key << std::endl; // Handle
> an arrow key if(key == "Up") { std::cout << "The up arrow was pressed." <<
> std::endl; // act->SetPosition(handpos[0]+1, handpos[1], handpos[2]);
> myTrans->Translate(handpos[0]+1, handpos[1], handpos[2]); handpos[0]++;
> act->SetPosition(handpos[0], handpos[1], handpos[2]); renderer->Render();
> renderWindow->Render(); } // Handle a "normal" key if(key == "Down") {
> std::cout << "The a key was pressed." << std::endl; handpos[0]++;
> act->SetPosition(handpos[0], handpos[1], handpos[2]); renderer->Render();
> renderWindow->Render(); } // Handle a "normal" key if(key == "Right") {
> std::cout << "The Right key was pressed." << std::endl; handpos[2]++;
> act->SetPosition(handpos[0], handpos[1], handpos[2]); renderer->Render();
> renderWindow->Render(); } if(key== "Left") { std::cout << "The left key was
> pressed." << std::endl; handpos[2]++; act->SetPosition(handpos[0],
> handpos[1], handpos[2]); renderer->Render(); renderWindow->Render(); } //
> Forward events vtkInteractorStyleTrackballCamera::OnKeyPress(); } };
>
>
> ------------------------------------------------------------------------------------------------------------------
>
> Best regards,
>
>
> Abdelkhalek Bakkari
> Ph.D candidate in Computer Science
> Institute of Applied Computer Science
> Lodz University of Technology, Poland
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160407/32feb35a/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list