Managed Interaction¶
Introduction¶
Managed Interaction is a framework for handling interactions—mouse gestures, keyboard presses, etc.—that was introduced to the Open Inventor framework in the MeVisLab context. It builds on the conventional input event handling system and replaces it with more abstract interaction objects. In this way, it aims to address 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 for discovering the provided interactions in an Open Inventor scene.
- It allows for overriding the mouse/keyboard binding of these interactions at a central location.
To achieve this, discrete interactions are encapsulated into interaction objects. Currently, there are 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. This could conceivably also be achieved with a different input device; hence the more generic name. - Command actions (class
SoCommandAction
) may be bound to a keyboard shortcut but could also be triggered from a context menu, for example. 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 action, 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 to input events.
Each interaction also has an identifying name. This name consists of the ID of the Open Inventor node providing this interaction (usually the name of the node, though this can be overridden) and the individual ID of the interaction, separated by a dot from its provider’s ID. This name is, for example, used to centrally override the input mappings for interactions.
Using Managed Interaction¶
Not all Open Inventor modules in MeVisLab support Managed Interaction yet. Besides requiring some effort to switch to a Managed Interaction implementation, there are also backward compatibility considerations, as the rigidly defined approach of Managed Interaction does not allow for emulating 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 provides: 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 Open Inventor scene.SoInteractionMapping
can be used to override the mouse/keyboard bindings of interactions in an Open 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 similar toSoView2D
, the interactions act as if they were provided bySoDiagram2D
instead of the extensions. UnlikeSoView2D
, there is nouseManagedInteraction
field for backward 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 actual Open Inventor nodes, since ML field updates are always immediate whereas Open 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 Interaction for your own Open Inventor node, have a look at the documentation in the toolbox reference: