SwipeGestureΒΆ

The SwipeGesture class represents a swiping motion a finger or tool. More...

Inherits Gesture.

Public Types

enum  State
 The possible gesture states. More...
 
enum  Type
 The supported types of gestures. More...
 

Public Member Functions

Vector direction () const
 The unit direction vector parallel to the swipe motion. More...
 
int64_t duration () const
 The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds. More...
 
float durationSeconds () const
 The elapsed duration in seconds. More...
 
Frame frame () const
 The Frame containing this Gesture instance. More...
 
HandList hands () const
 The list of hands associated with this Gesture, if any. More...
 
int32_t id () const
 The gesture ID. More...
 
bool isValid () const
 Reports whether this Gesture instance represents a valid Gesture. More...
 
bool operator!= (const Gesture &rhs) const
 Compare Gesture object inequality. More...
 
bool operator== (const Gesture &rhs) const
 Compare Gesture object equality. More...
 
Pointable pointable () const
 The finger performing the swipe gesture. More...
 
PointableList pointables () const
 The list of fingers and tools associated with this Gesture, if any. More...
 
Vector position () const
 The current position of the swipe. More...
 
float speed () const
 The swipe speed in mm/second. More...
 
Vector startPosition () const
 The position where the swipe began. More...
 
State state () const
 The gesture state. More...
 
 SwipeGesture ()
 
 SwipeGesture (const Gesture &rhs)
 Constructs a SwipeGesture object from an instance of the Gesture class. More...
 
std::string toString () const
 A string containing a brief, human-readable description of this Gesture. More...
 
Type type () const
 The gesture type. More...
 

Static Public Member Functions

static Type classType ()
 The swipe gesture type. More...
 
static const Gestureinvalid ()
 Returns an invalid Gesture object. More...
 

Detailed Description

The SwipeGesture class represents a swiping motion a finger or tool.

controller.enableGesture(Leap::Gesture::TYPE_SWIPE);
Deprecated:
3.0

Member Enumeration Documentation

enum State
inherited

The possible gesture states.

Deprecated:
3.0
Enumerator
STATE_INVALID 

An invalid state.

Deprecated:
3.0
STATE_START 

The gesture is starting.

Just enough has happened to recognize it.

Deprecated:
3.0
STATE_UPDATE 

The gesture is in progress.

(Note: not all gestures have updates).

Deprecated:
3.0
STATE_STOP 

The gesture has completed or stopped.

Deprecated:
3.0
enum Type
inherited

The supported types of gestures.

Deprecated:
3.0
Enumerator
TYPE_INVALID 

An invalid type.

Deprecated:
3.0
TYPE_SWIPE 

A straight line movement by the hand with fingers extended.

Deprecated:
3.0
TYPE_CIRCLE 

A circular movement by a finger.

Deprecated:
3.0
TYPE_SCREEN_TAP 

A forward tapping movement by a finger.

Deprecated:
3.0
TYPE_KEY_TAP 

A downward tapping movement by a finger.

Deprecated:
3.0

Constructor & Destructor Documentation

SwipeGesture ( const Gesture rhs)

Constructs a SwipeGesture object from an instance of the Gesture class.

if(gesture.type() == Leap::Gesture::TYPE_SWIPE)
swipeGesture = Leap::SwipeGesture(gesture);
Parameters
rhsThe Gesture instance to specialize. This Gesture instance must be a SwipeGesture object.
Deprecated:
3.0

Member Function Documentation

static Type classType ( )
inlinestatic

The swipe gesture type.

if(gesture.type() == Leap::SwipeGesture::classType())
swipeGesture = Leap::SwipeGesture(gesture);
Returns
Type The type value designating a swipe gesture.
Deprecated:
3.0
Vector direction ( ) const

The unit direction vector parallel to the swipe motion.

Leap::Vector swipeDirection = swipe.direction();

You can compare the components of the vector to classify the swipe as appropriate for your application. For example, if you are using swipes for two dimensional scrolling, you can compare the x and y values to determine if the swipe is primarily horizontal or vertical.

Returns
Vector The unit direction vector representing the swipe motion.
Deprecated:
3.0
int64_t duration ( ) const
inherited

The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds.

float microseconds = gesture.duration();

The duration reported for the first Gesture in the sequence (with the STATE_START state) will typically be a small positive number since the movement must progress far enough for the Leap Motion software to recognize it as an intentional gesture.

Returns
int64_t the elapsed duration in microseconds.
Deprecated:
3.0
float durationSeconds ( ) const
inherited

The elapsed duration in seconds.

float seconds = gesture.durationSeconds();
See also
duration()
Returns
float the elapsed duration in seconds.
Deprecated:
3.0
Frame frame ( ) const
inherited

The Frame containing this Gesture instance.

Leap::Frame frameOfGesture = gesture.frame();
Returns
Frame The parent Frame object.
Deprecated:
3.0
HandList hands ( ) const
inherited

The list of hands associated with this Gesture, if any.

Leap::HandList handsForGesture = gesture.hands();

If no hands are related to this gesture, the list is empty.

Returns
HandList the list of related Hand objects.
Deprecated:
3.0
int32_t id ( ) const
inherited

The gesture ID.

All Gesture objects belonging to the same recognized movement share the same ID value. Use the ID value with the Frame::gesture() method to find updates related to this Gesture object in subsequent frames.

int32_t gestureOfInterest = gesture.id();
Leap::GestureList manyGestures = frame.gestures(olderFrame);
for(Leap::GestureList::const_iterator gl = manyGestures.begin(); gl != manyGestures.end(); gl++)
{
if ((*gl).id() == gestureOfInterest) {
//Process it...
}
}
Returns
int32_t the ID of this Gesture.
Deprecated:
3.0
static const Gesture& invalid ( )
staticinherited

Returns an invalid Gesture object.

Leap::Gesture trackedGesture = frame.gesture(gestureID);
if (trackedGesture != Leap::Gesture::invalid()) {
//Process it...
}
Returns
The invalid Gesture instance.
Deprecated:
3.0
bool isValid ( ) const
inherited

Reports whether this Gesture instance represents a valid Gesture.

if (gesture.isValid()) {
// Process it...
}
Returns
bool True, if this is a valid Gesture instance; false, otherwise.
Deprecated:
3.0
bool operator!= ( const Gesture rhs) const
inherited

Compare Gesture object inequality.

thisGesture != thatGesture;

Two Gestures are equal only if they represent the same snapshot of the same recognized movement.

Deprecated:
3.0
bool operator== ( const Gesture rhs) const
inherited

Compare Gesture object equality.

thisGesture == thatGesture;

Two Gestures are equal if they represent the same snapshot of the same recognized movement.

Deprecated:
3.0
Pointable pointable ( ) const

The finger performing the swipe gesture.

Leap::Pointable swiper = swipe.pointable();
Returns
Pointable A Pointable object representing the swiping finger.
Deprecated:
3.0
PointableList pointables ( ) const
inherited

The list of fingers and tools associated with this Gesture, if any.

If no Pointable objects are related to this gesture, the list is empty.

Leap::PointableList pointablesForGesture = gesture.pointables();
Returns
PointableList the list of related Pointable objects.
Deprecated:
3.0
Vector position ( ) const

The current position of the swipe.

Leap::Vector currentSwipePosition = swipe.position();
Returns
Vector The current swipe position within the Leap Motion frame of reference, in mm.
Deprecated:
3.0
float speed ( ) const

The swipe speed in mm/second.

float currentSwipeSpeed = swipe.speed();
Returns
float The speed of the finger performing the swipe gesture in millimeters per second.
Deprecated:
3.0
Vector startPosition ( ) const

The position where the swipe began.

Leap::Vector swipeStart = swipe.startPosition();
Returns
Vector The starting position within the Leap Motion frame of reference, in mm.
Deprecated:
3.0
State state ( ) const
inherited

The gesture state.

Recognized movements occur over time and have a beginning, a middle, and an end. The 'state()' attribute reports where in that sequence this Gesture object falls.

Leap::GestureList gestures = frame.gestures();
for(Leap::GestureList::const_iterator gl = gestures.begin(); gl != gestures.end(); gl++)
{
switch ((*gl).state()) {
//Handle starting gestures
break;
//Handle continuing gestures
break;
//Handle ending gestures
break;
default:
//Handle unrecognized states
break;
}
}
Returns
Gesture::State A value from the Gesture::State enumeration.
Deprecated:
3.0
std::string toString ( ) const
inlineinherited

A string containing a brief, human-readable description of this Gesture.

Leap::GestureList gestures = frame.gestures();
for(Leap::GestureList::const_iterator gl = gestures.begin(); gl != gestures.end(); gl++)
std::cout << (*gl).toString() << std::endl;
Deprecated:
3.0
Type type ( ) const
inherited

The gesture type.

Leap::GestureList gestures = frame.gestures();
for(Leap::GestureList::const_iterator gl = gestures.begin(); gl != frame.gestures().end(); gl++)
{
switch ((*gl).type()) {
//Handle circle gestures
break;
//Handle key tap gestures
break;
//Handle screen tap gestures
break;
//Handle swipe gestures
break;
default:
//Handle unrecognized gestures
break;
}
}
Returns
Gesture::Type A value from the Gesture::Type enumeration.
Deprecated:
3.0