MeVisLab Toolbox Reference
SoManagedInteraction Overview

The SoManagedInteraction library contains the basis of the Managed Interaction framework. Managed Interaction replaces the classic per-input-event handling of OpenInventor with interaction objects that are managed by a central controller instance.

Concept

Inventor nodes can provide abstract interaction objects that can be mapped naturally to one or more input devices. Each class has virtual methods that must be overridden to implement the functionality of the interaction:

  • SoPointingAction corresponds to mouse button presses and dragging.
  • SoCommandAction corresponds to keyboard key presses.
  • SoOffsetAction corresponds to mouse wheel rotation, but may also be mapped to mouse dragging or keyboard presses.

These interactions may provide default input device bindings, but these can always be overridden from a more central location. MeVisLab has modules for discovering interactions and overriding the bindings.

Main DCMTree Classes

There are only a few classes that a developer who wants to offer Managed Interactions needs to know:

  • SoInteractionNode is the usual base class for OpenInventor nodes that want to offer Managed Interactions. It manages the interactions and implements the necessary event handling. Some nodes like SoView2DExtension delegate the event handling and thus only derive from SoInteractionProviderNode. A developer might find uses for the methods SoInteractionProvider::pointerPosition and SoInteractionProvider::pointerLeftWindow, which can be used to keep track of the current cursor position.
  • SoPointingAction is the mouse interaction class. It has virtual methods for button down (SoPointingAction::startPressAt), mouse move (SoPointingAction::dragMoveTo), and button up (SoPointingAction::endPress). There are also virtual methods for which cursor shape to show, for highlighting of structures while hovering, and to enable different dragging modes through keyboard modifiers.
  • SoPointerPosition is the position information passed to SoPointingAction. Besides the usual OpenInventor position information it can also contain the pointer to additional position information. This is used for the SoView2D and SoDiagram2D libraries, where the extensions need information about the node through which they are displayed. In case of the SoView2D library this pointer has the type View2DPosition.
  • SoCommandAction is the keyboard interaction class. It has a virtual method to execute the desired action (SoCommandAction::execute). It also has support for automatic menu generation (which is currently unused).
  • SoOffsetAction is the mouse wheel (or joystick) interaction class. It has a virtual method to receive an (or two) offset value(s) for each change of the input device. There is also a virtual method to specify the cursor shape should this action be mapped to mouse button dragging.
  • SoInteraction is the base class for the interaction classes above. It stores basic information about the interaction like an ID string, some user-readable information (this feature is currently unused though) and whether the interaction is currently enabled. Interactions should always be disabled when they are currently not applicable; this gives other interactions with the same input binding the chance to get active.

Usage

Defining your own simple pointing action:

...
// use unnamed namespace to avoid name clashes
namespace {
// interactions don't need to be defined in the header file:
class MyPointingAction : public SoPointingAction
{
public:
MyPointingAction(MyProviderNode* node)
: SoPointingAction(node, "MyActionID", true) { _dragging = false; }
virtual bool isSensitiveAt(const SoPointerPosition& pos) {
return _myNode()->hasSomeMoveableObjectAt(pos);
}
}
virtual void startPressAt(const SoPointerPosition& pos) {
_myNode()->grabObjectAt(pos);
_dragging = true;
}
virtual void dragMoveTo(const SoPointerPosition& pos) {
_myNode()->moveGrabbedObjectTo(pos);
}
virtual SoPointingAction* endPress(int clickCount) {
_myNode()->releaseGrabbedObject(clickCount);
_dragging = false;
return NULL;
}
private:
MyProviderNode* _myNode() const { return static_cast<MyProviderNode*>(getOwner()); }
bool _dragging;
};
};
...
MyProviderNode::MyProviderNode()
{
...
_myPointingAction = new MyPointingAction(this);
// add a default trigger:
_myPointingAction->setTrigger(Button1Mask, AllModifiersMask);
addInteraction(_myPointingAction);
}
MyProviderNode::~MyProviderNode()
{
// no need to delete _myPointingAction
}
SoInteractionNode is the base class for normal interaction nodes in OpenInventor, that handle their i...
SoInteractionOwner * getOwner() const
Definition: SoInteraction.h:72
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
virtual int getCurrentCursor(SoViewerProxy *) const
Returns the cursor ID to display for this action, as defined in SoViewerProxy.h - this gets (at least...
virtual SoPointingAction * endPress(int clickCount)=0
Ends the drag at last device position.
virtual void startPressAt(const SoPointerPosition &pos)=0
Starts a drag at given device position.
virtual void dragMoveTo(const SoPointerPosition &pos)=0
Continues the drag to given device position.
virtual bool isSensitiveAt(const SoPointerPosition &pos)=0
Returns true if the gesture is startable at the given device position.
This class gives access to state of a viewer during scene graph traversal.
Definition: SoViewerProxy.h:30