[vtkusers] A Brief guide on how to define Custom Interaction in VTK
Deepak Roy
cdeepakroy at yahoo.com
Mon Nov 14 11:30:12 EST 2005
Hello everybody,
The default vtk interactor styles are not convenient for many applications, atleast for a few of mine, and they need some customization.
I have had some hard time figuring this out, as i did not find any sort of documented help for this problem. I dont want others to go through the same thing again. So here is a brief startup solution guide to this problem.
If you are working in C++, I would suggest you to write a custom class derived from vtkInteractorStyle ( the base class of all the interactor style classes in VTK ). You may also choose to derive any of the subclasses of vtkInteractorStyle, namely :
---- vtkInteractorStyleTrackballCamera
---- vtkInteractorStyleJoystickCamera
---- and there are a bunch of other classes from which you can choose one.
These subclasses have some interaction functionality already implemented, and you can derive your class from them and build upon the existing implementation.
Once you derive on the vtk interactor style classes, it finally boils down to overriding the virtual functions for keyboard and mouse events, similar to the way you might have done in any of the GUI libraries.
The virtual functions you may want to override with custom implementation are as follows:
---- OnLeftButtonDown()
---- OnLeftButtonUp()
---- OnRightButtonDown()
----- OnRightButtonUp()
----- OnMouseMove()
----- OnChar()
----- and many other event callbacks are available..... you can check them in the VTK documentation and source code for the vtkInteractorStyle.cxx
If you want to know more about what is happening internally, you can go check the source code for the subclasses of vtkInteractorstyle too.
You can use the above mentioned procedure, for example if you want to pick some points in your vtkRenderWindow with the mouse, rather than using the keyboard key "P".
If you have anymore doubts, regarding this problem. I will be pleased to help as far as i can.
Any comments on this solution are welcome, I am always in search for better solutions. If you have found a better solution, please let the community know.
Bye
Deepak Roy
---------------------------------
Yahoo! FareChase - Search multiple travel sites in one click.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20051114/1cc0dabd/attachment.htm>
More information about the vtkusers
mailing list