Managed Interaction¶
Introduction¶
Managed Interaction is a framework for handling interactions - mouse gestures, keyboard presses, etc. - that was introduced to the OpenInventor framework in the MeVisLab context. It builds on the conventional input event handling system and replaces it with more abstract interaction objects. This way it tries to solve some of the shortcomings of conventional event handling:
- It protects against the involuntary use of the same input event by different entities through a shared controller object.
- It provides proper phase handling for mouse dragging gestures.
- It handles the display of the correct cursor shape for mouse actions in an easy way.
- It allows to discover the provided interactions in an Inventor scene.
- It allows to override the mouse/keyboard binding of these interactions at a central location.
To achieve this discrete interactions are encapsulated into interaction objects. There are currently three different types of interactions:
- Pointing actions (class SoPointingAction) represent mouse dragging actions, i.e., the action of pressing a mouse button at one position, moving the mouse to another position, and releasing the mouse button again. This could conceivably also be achieved with a different input device, therefore the more generic name.
- Command actions (class SoCommandAction) may be bound to a keyboard shortcut, but could, e.g., also be triggered from a context menu. They simply represent a trigger without any parameters.
- Offset actions (class SoOffsetAction) take a numeric offset value in one or two directions. They are most naturally mapped to the rotation of the mouse wheel, but can also be mapped to keyboard shortcuts or even mouse button dragging. A mapping to a joystick is also conceivable but currently not supported. Since only a relative offset is passed to this type of actions each input mapping may have a different sensitivity value.
Each interaction type can be enabled or disabled. Disabled interactions can be discovered but do not react on input events.
Each interaction also has an identifying name. This name consists of the ID of the Inventor node providing this interaction (usually the name of the node, but this can be overridden), and the individual ID of the interaction, separated by a dot from its provider’s ID. This name is, e.g., used to centrally override the input mappings for interactions.
Using Managed Interaction¶
Not all Inventor modules in MeVisLab support Managed Interaction yet. Besides it being some work to switch to a Managed Interaction implementation, there are also some backwards compatibility considerations, since the rigidly defined approach of Managed Interaction does not allow to emulate every quirk of an old classic-event-handling based implementation. That is also the reason why some modules have a useManagedInteraction
flag to switch to the new behavior.
Note
There is also the caveat that mixing Managed Interaction and classic style modules invalidates some of the guarantees that Managed Interaction normally gives: That only one interaction can ever react to an input, and that the methods of a SoPointingAction are called in a defined order.
Some of the main modules to support Managed Interaction are listed here:
SoInteractionInfo
can be used to find the interactions defined in an Inventor scene.SoInteractionMapping
can be used to override the mouse/keyboard bindings of interactions in an Inventor scene.SoCameraInteraction
was one of the first modules to use Managed Interaction and provides a camera handling that is otherwise provided by theSoExaminerViewer
.SoView2D
and the most standard SoView2DExtensions have been adapted, but for compatibility reasons Managed Interaction is only used whenSoView2D.useManagedInteraction
is set. The same applies toView2D
,SoOrthoView2D
andOrthoView2D
. Note that for the purpose ofSoInteractionInfo
andSoInteractionMapping
the interactions act as if they were provided bySoView2D
instead of the extensions - and only ifSoView2D.useManagedInteraction
is set.SoDiagram2D
and its extensions have been adapted to use Managed Interaction. Note that like withSoView2D
the interactions act as if they were provided bySoDiagram2D
instead of the extensions. UnlikeSoView2D
there is nouseManagedInteraction
field for backwards compatibility.SoGenericCommandAction
provides a dummy SoCommandAction whose action can be implemented with a FieldListener.SoGenericOffsetAction
does the same for SoOffsetAction.- And
GenericPointingAction
andGenericSoView2DPointingAction
do this for SoPointingAction. Since SoPointingAction requires immediate updates in some cases, these modules are ML modules that wrap the real Inventor nodes, since ML field updates are always immediate whereas Inventor field updates default to delayed notification. SoExecuteCommandAction
can be used to execute a SoCommandAction with a known ID.
Documentation for C++ developers¶
If you want to implement managed interactions for your own Inventor node, have a look at the documentation in the toolbox reference: