11.3. SoTouchManager

SoTouchManager( C++ | Java | .NET ) is the class for touch management in Open Inventor.

Every touch manager has an SoTouchEvent( C++ | Java | .NET ) table and every cell represents the state of one finger at a given time. SoTouchEvent( C++ | Java | .NET ) has a pointer on this class so if you are analyzing an event, you can access to the SoTouchEvent( C++ | Java | .NET ) table and know the state of other fingers. Several functions are implemented to use this table. Fingers are identified by an integer and SoTouchManager( C++ | Java | .NET ) allows you to find the event corresponding to an identifier with getCorrespondingEvent(). getFingerNumber() gives you the number of fingers touching the screen. getMaxSimultaneousFingers() returns the maximum number of inputs supported by your device.

In the Open Inventor model, touch events are released only if the position of the finger has changed. To determine if a finger has moved, there is a threshold which is the minimum difference between previous and current position. You can edit this value with setThreshold(). By default, the threshold is equal to 0.0001 to consider every movement. So, every time the monitor is touched, a series of events are released beginning with one DOWN event and finishing with one UP event. SoTouchManager( C++ | Java | .NET ) contains the table of current fingers identifiers. You can query them with getAllFingersId().

There are two environments supported in Open Inventor: SoWinTouchScreen( C++ | .NET ) for Windows and SoQtTouchScreen( C++ ) for Qt that represent touch devices. They respectively inherit from SoWinDevice( C++ | .NET ) and SoQtDevice( C++ ).

To add your own touch device, you must create a new class derived from the corresponding device and containing a SoTouchManager( C++ | Java | .NET ).

SoTouchManager:: updateAndProcessTouchEvent():

In each SoTouchEvent( C++ | Java | .NET ), fields are updated in a specific order because, to be calculated, some fields need information about previous event. For example, setPreviousSpeed() needs the previous displacement to be evaluated.

All SoTouchEvent( C++ | Java | .NET ) are updated but not necessarily sent to the render area. Each event contains the finger’s position and an event is released only if the position has changed according to the threshold.