Class SoTouchManager
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.touch.SoTouchManager
-
public class SoTouchManager extends Inventor
Class for managing events from touch screen input devices. This is the base class for managing events from touch screen input devices. A touch manager has aSoTouchEvent
table and a finger ids table which are updated each time a finger moves. A touch manager has a list of gesture recognizers that generate events when the gesture is recognized. By default, the list is empty and recognizers must be added to generate the corresponding events. TheaddDefaultRecognizers()
method is provided for convenience.Note that all registered gesture recognizers are active simultaneously. During a gesture event, events may generated for a different gesture. The application is responsible for enforcing a "one gesture at a time" policy if appropriate.
Note: Unlike mouse and keyboard events, the application must explicitly register a touch screen device (e.g.
SoWinTouchScreen
) in order to get touch events.EXAMPLE Get the touch manager from the touch device to register gesture recognizers. Not available
- See Also:
SoQtTouchScreen
,SoWinTouchScreen
,SoTouchEvent
,SoGestureEvent
,SoGestureRecognizer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoTouchManager()
SoTouchManager(SoSceneManager sM)
Deprecated.As of Open Inventor 9.5.0.0.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDefaultRecognizers()
Add a default list of recognizers to the recognizer list.void
addRecognizer(SoGestureRecognizer recognizer)
Add a gesture recognizer to the recognizer list.long[]
getAllFingerIds()
Get the table with ids of all fingers touching the screen.SoTouchEvent
getEventById(long id)
Get the corresponding event for the finger id, NULL if id is incorrect.SoTouchEvent
getEventbyIndex(int index)
Get the corresponding event for the index, NULL if index is incorrect.int
getFingerNumber()
Get the current number of fingers touching the screen.int
getMaxSimultaneousFingers()
Get the maximum number of simultaneous fingers supported by the device.java.util.ArrayList<SoGestureRecognizer>
getRecognizerList()
Returns the gesture recognizers list.float
getThreshold()
Get the detection threshold (in pixels).java.util.ArrayList<SoEvent>
getTouchDownEvent(long fingerId, SbVec2f fingerPos, SbTime time)
Translate the given touch down event into a list ofSoEvent
.java.util.ArrayList<SoEvent>
getTouchMoveEvent(long fingerId, SbVec2f fingerPos, SbTime time)
Translate the given touch move event into a list ofSoEvent
.java.util.ArrayList<SoEvent>
getTouchUpEvent(long fingerId, SbVec2f fingerPos, SbTime time)
Translate the given touch up event into a list ofSoEvent
.boolean
isTouchScreenAvailable()
Returns true if the touch screen device is available, false otherwise.void
removeDefaultRecognizers()
Remove the default recognizers from the recognizer list.void
removeRecognizer(SoGestureRecognizer gesture)
Remove a gesture recognizer from the recognizer list.void
setMaxSimultaneousFingers(int fingers)
Set the maximum number of simultaneous fingers supported by the device.void
setThreshold(float t)
Set the detection threshold (0.0001 pixels by default).void
setTouchScreenAvailability(boolean available)
Set the touch screen availability.SoTouchEvent
updateAndProcessTouchEvent(long id, SoTouchEvent.States state, SbVec2f position, SbTime time)
Deprecated.As of Open Inventor 9.5.0.0.-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Constructor Detail
-
SoTouchManager
@Deprecated(since="9.5.0.0") public SoTouchManager(SoSceneManager sM)
Deprecated.As of Open Inventor 9.5.0.0. Scene manager argument is useless.Warning Deprecated since Open Inventor 9500. Scene manager argument is useless.
-
SoTouchManager
public SoTouchManager()
-
-
Method Detail
-
addRecognizer
public void addRecognizer(SoGestureRecognizer recognizer)
Add a gesture recognizer to the recognizer list.
-
removeRecognizer
public void removeRecognizer(SoGestureRecognizer gesture)
Remove a gesture recognizer from the recognizer list.
-
getEventbyIndex
public SoTouchEvent getEventbyIndex(int index)
Get the corresponding event for the index, NULL if index is incorrect. UsegetFingerNumber()
to know the number of fingers touching the screen.
-
getTouchMoveEvent
public java.util.ArrayList<SoEvent> getTouchMoveEvent(long fingerId, SbVec2f fingerPos, SbTime time)
Translate the given touch move event into a list ofSoEvent
. This list may contain some recognizedSoGestureEvent
.- Parameters:
fingerId
- id of the finger used.fingerPos
- position of the finger in pixels.time
- timestamp of the touch event in seconds.- Returns:
- this list.
-
getAllFingerIds
public long[] getAllFingerIds()
Get the table with ids of all fingers touching the screen.
-
setTouchScreenAvailability
public void setTouchScreenAvailability(boolean available)
Set the touch screen availability.
-
updateAndProcessTouchEvent
@Deprecated(since="9.5.0.0") public SoTouchEvent updateAndProcessTouchEvent(long id, SoTouchEvent.States state, SbVec2f position, SbTime time)
Deprecated.As of Open Inventor 9.5.0.0. Use getTouchDownEvent, getTouchUpEvent or getTouchMoveEvent instead. Process the events by using SoRenderAreaCore instead.Update finger's id of the event identified by id and process it with the scene manager. Events are also analyzed by every recognizer in the recognizers list. Position is in pixels and time is in seconds.Warning Deprecated since Open Inventor 9500. Use getTouchDownEvent, getTouchUpEvent or getTouchMoveEvent instead. Process the events by using
SoRenderAreaCore
instead.
-
getEventById
public SoTouchEvent getEventById(long id)
Get the corresponding event for the finger id, NULL if id is incorrect.
-
getFingerNumber
public int getFingerNumber()
Get the current number of fingers touching the screen.
-
removeDefaultRecognizers
public void removeDefaultRecognizers()
Remove the default recognizers from the recognizer list. It removes all the recognizers previously added byaddDefaultRecognizers()
.
-
setThreshold
public void setThreshold(float t)
Set the detection threshold (0.0001 pixels by default). This is the minimum difference between previous and current event positions to consider that the finger has moved.
-
getThreshold
public float getThreshold()
Get the detection threshold (in pixels).
-
isTouchScreenAvailable
public boolean isTouchScreenAvailable()
Returns true if the touch screen device is available, false otherwise.
-
addDefaultRecognizers
public void addDefaultRecognizers()
Add a default list of recognizers to the recognizer list. The following recognizers are added:
-
getMaxSimultaneousFingers
public int getMaxSimultaneousFingers()
Get the maximum number of simultaneous fingers supported by the device.
-
getTouchUpEvent
public java.util.ArrayList<SoEvent> getTouchUpEvent(long fingerId, SbVec2f fingerPos, SbTime time)
Translate the given touch up event into a list ofSoEvent
. This list may contain some recognizedSoGestureEvent
.- Parameters:
fingerId
- id of the finger used.fingerPos
- position of the finger in pixels.time
- timestamp of the touch event in seconds.- Returns:
- this list.
-
getTouchDownEvent
public java.util.ArrayList<SoEvent> getTouchDownEvent(long fingerId, SbVec2f fingerPos, SbTime time)
Translate the given touch down event into a list ofSoEvent
. This list may contain some recognizedSoGestureEvent
.- Parameters:
fingerId
- id of the finger used.fingerPos
- position of the finger in pixels.time
- timestamp of the touch event in seconds.- Returns:
- this list.
-
getRecognizerList
public java.util.ArrayList<SoGestureRecognizer> getRecognizerList()
Returns the gesture recognizers list.
-
setMaxSimultaneousFingers
public void setMaxSimultaneousFingers(int fingers)
Set the maximum number of simultaneous fingers supported by the device.
-
-