[vtk-developers] vtkGenericRenderWindowInteractor

Bill Hoffman bill.hoffman at kitware.com
Thu Apr 11 14:43:51 EDT 2002


I have just checked in the new class vtkGenericRenderWindowInteractor.
This class will allow wrapped languages to use the new 
vtkInteractorObserver, 3D widgets, and old vtkInteractorStyles without 
needing a C++ class like vtkXRenderWindowTclInteractor.

I have done a version for tcl/tk (attached), and will integrate
it into the vtk tcl/tk stuff.  (replace BindTkRenderWidget)

Are there any volunteers for Java and Python?



Here is an example for tcl/tk:
(assume renWin is a vtkRenderWindow and $vtkw is a vtkTkRenderWidget)


# create a generic render window to translate events to vtk from tcl/tk
vtkGenericRenderWindowInteractor iren
iren SetRenderWindow renWin

# set up the timer events
iren AddObserver CreateTimerEvent { after 10 { iren TimerEvent} }

# Perhaps enter event should set focus

bind $vtkw <Motion> { iren SetEventInformationFlipY %x %y 0 0 0 0 0; iren MouseMoveEvent }
# button one
bind $vtkw <ButtonPress-1>                 { iren SetEventInformationFlipY %x %y 0 0 0 0 0 ; iren LeftButtonPressEvent }
bind $vtkw <Control-ButtonPress-1>         { iren SetEventInformationFlipY %x %y 1 0 0 0 0 ; iren LeftButtonPressEvent }
bind $vtkw <Shift-ButtonPress-1>           { iren SetEventInformationFlipY %x %y 0 1 0 0 0 ; iren LeftButtonPressEvent }
bind $vtkw <Control-Shift-ButtonPress-1>   { iren SetEventInformationFlipY %x %y 1 1 0 0 0 ; iren LeftButtonPressEvent }
bind $vtkw <ButtonRelease-1>               { iren SetEventInformationFlipY %x %y 0 0 0 0 0 ; iren LeftButtonReleaseEvent }
bind $vtkw <Control-ButtonRelease-1>       { iren SetEventInformationFlipY %x %y 1 0 0 0 0 ; iren LeftButtonReleaseEvent }
bind $vtkw <Shift-ButtonRelease-1>         { iren SetEventInformationFlipY %x %y 0 1 0 0 0 ; iren LeftButtonReleaseEvent }
bind $vtkw <Control-Shift-ButtonRelease-1> { iren SetEventInformationFlipY %x %y 1 1 0 0 0 ; iren LeftButtonReleaseEvent }
# button two
bind $vtkw <ButtonPress-2>                 { iren SetEventInformationFlipY %x %y 0 0 0 0 0 ; iren MiddleButtonPressEvent }
bind $vtkw <Control-ButtonPress-2>         { iren SetEventInformationFlipY %x %y 1 0 0 0 0 ; iren MiddleButtonPressEvent }
bind $vtkw <Shift-ButtonPress-2>           { iren SetEventInformationFlipY %x %y 0 1 0 0 0 ; iren MiddleButtonPressEvent }
bind $vtkw <Control-Shift-ButtonPress-2>   { iren SetEventInformationFlipY %x %y 1 1 0 0 0 ; iren MiddleButtonPressEvent }
bind $vtkw <ButtonRelease-2>               { iren SetEventInformationFlipY %x %y 0 0 0 0 0; iren MiddleButtonReleaseEvent }
bind $vtkw <Control-ButtonRelease-2>       { iren SetEventInformationFlipY %x %y 1 0 0 0 0; iren MiddleButtonReleaseEvent }
bind $vtkw <Shift-ButtonRelease-2>         { iren SetEventInformationFlipY %x %y 0 1 0 0 0; iren MiddleButtonReleaseEvent }
bind $vtkw <Control-Shift-ButtonRelease-2> { iren SetEventInformationFlipY %x %y 1 1 0 0 0; iren MiddleButtonReleaseEvent }
# button 3
bind $vtkw <ButtonPress-3>                 { iren SetEventInformationFlipY %x %y 0 0 0 0 0; iren RightButtonPressEvent }
bind $vtkw <Control-ButtonPress-3>        { iren SetEventInformationFlipY %x %y 1 0 0 0 0; iren RightButtonPressEvent }
bind $vtkw <Shift-ButtonPress-3> { iren SetEventInformationFlipY %x %y 0 1 0 0 0; iren RightButtonPressEvent }
bind $vtkw <Control-Shift-ButtonPress-3> { iren SetEventInformationFlipY %x %y 1 1 0 0 0; iren RightButtonPressEvent }
bind $vtkw <ButtonRelease-3> { iren SetEventInformationFlipY %x %y 0 0 0 0 0; iren RightButtonReleaseEvent }
bind $vtkw <Control-ButtonRelease-3> { iren SetEventInformationFlipY %x %y 1 0 0 0 0; iren RightButtonReleaseEvent }
bind $vtkw <Shift-ButtonRelease-3> { iren SetEventInformationFlipY %x %y 0 1 0 0 0; iren RightButtonReleaseEvent }
bind $vtkw <Control-Shift-ButtonRelease-3> { iren SetEventInformationFlipY %x %y 1 1 0 0 0; iren RightButtonReleaseEvent }
# set focus follow mouse to get key events
tk_focusFollowsMouse

bind $vtkw <Configure> { iren SetSize %w %h ; iren ConfigureEvent }
bind $vtkw <Enter> { iren SetEventInformationFlipY %x %y 0 0 0 0 0; iren EnterEvent }
bind $vtkw <Leave> { iren SetEventInformationFlipY %x %y 0 0 0 0 0; iren LeaveEvent }
bind $vtkw <KeyPress> { iren SetEventInformationFlipY %x %y 0 0 %k 0 %K; iren KeyPressEvent; iren CharEvent }
bind $vtkw <Control-KeyPress> { iren SetEventInformationFlipY %x %y 1 0 %k 0 %K; iren KeyPressEvent; iren CharEvent }
bind $vtkw <Shift-KeyPress> { iren SetEventInformationFlipY %x %y 0 1 %k 0 %K; iren KeyPressEvent; iren CharEvent }
bind $vtkw <Control-Shift-KeyPress> { iren SetEventInformationFlipY %x %y 1 1 %k 0 %K; iren KeyPressEvent; iren CharEvent }
bind $vtkw <KeyRelease> { iren SetEventInformationFlipY %x %y 0 0 %k 0 %K; iren KeyReleaseEvent }
bind $vtkw <Control-KeyRelease> { iren SetEventInformationFlipY %x %y 1 0 %k 0 %K; iren KeyReleaseEvent }
bind $vtkw <Shift-KeyRelease> { iren SetEventInformationFlipY %x %y 0 1 %k 0 %K; iren KeyReleaseEvent }
bind $vtkw <Control-Shift-KeyRelease> { iren SetEventInformationFlipY %x %y 1 1 %k 0 %K; iren KeyReleaseEvent }




-Bill




More information about the vtk-developers mailing list