InteractorStyles

John Biddiscombe j.biddiscombe at rl.ac.uk
Sat Sep 18 08:20:12 EDT 1999


>Would anyone care explain the new InteractorStyle objects?  How do they
>improve on the old interactors?

The single biggest improvement is that previously there was code to
implement the rotations/pans/rolls etc etc in
vtkWin32RenderWindowInteractor, and then again in vtkXWindowInteractor etc
etc. If a slight change was made to the way the code behaved, it was
necessary to track down all the implementations and change them all.

Secondly, the code for the interactions looked a lot like this

If Leftbutton
  if Cameramode
    if Trackball then do all this stuff
    if joystick ....
  If actormode
....
if RightButton

etc etc

and it was a bit of a mess. Suppose you want to implement a different type
of interaction, you really have to intercept all the mouse/key events and
insert code inside all the routines. then you'd have to go through the
other platform dependent versions and do it again if desired.

The style approach uses a single entry point

OnKeyDown
OnLButtonDown
OnLButtonUp
etc etc

and routes them (from the RenderwindowInteractor which is platform
DEpendent) through a single set of entry points to the style class
(platform independent). Meaning that if you now want to create a new type
of interaction (eg flight controls) you ....
create a new style class
intercept the key and mouse calls
do what you want to camera etc etc
finish.

It's possible to override picking behaviour, actor/camera mode, mouse and
key responses using a single entry point that just wasn't possible before.
It removes platform dependent niggles....(and one more subtle result is
that it encourages the developer to create new style classes, rather than
directly control the vtk internals from the GUI - because its easier to
override the interactor behaviour from inside the style class where access
to various params is straightforward  and not so easy from the GUI itself).
Many developers may implement their own controls from the GUI, but if new
style classes appear, they'll benefit all.

Many of the interactor variables were intimately tied to the interactor
code, consider implementing flight mode. Actor/Camera mode just might not
be relevant, picking may be different, and wading through the code
inserting new functions just wasn't realistic.

One surprise to me was that InteractorStyleTrackball has a joystick mode
built in!!!
The reason was simply that the code for doing both trackball and joystick
mode was already so tightly coupled that it was pointless to split it up as
they used the same rotate/pan/zoom functions etc etc.

In the current inplementation many of the useful routines like
FindPokedCamera, RotateCamera, SpinCamera, PanCamera, DollyCamera etc are
in the InteractorStyle base class, making it relatively straightforward to
create new interactor behaviours by subclassing.

---

My single biggest complaint is that the interactors are controlled by 
OnKeyDown, OnLButtonDown etc etc and if you wish to put a slider bar on a
window and have the screen respond to changes in the slider, its easier to
just move the camera directly than use an interactor to achieve the same
result.

Rambling on pointlessly......

John B




-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list