All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
MultiWidgets::VirtualHand Class Reference

VirtualHand consists of group of fingers (1-5) and a palm location. More...

#include <MultiWidgets/VirtualInput.hpp>

Inheritance diagram for MultiWidgets::VirtualHand:
MultiWidgets::VirtualObject

Public Member Functions

void addFinger (Nimble::Vector2f location)
 Adds finger to the hand and places the finger to the given location. More...
 
VirtualFingerfinger (int index)
 Access to finger. More...
 
int fingers () const
 Number of fingers in hand. More...
 
virtual void injectToSamples (MultiTouch::Screen &touchScreen, int sampleBegin, int sampleEnd)
 Injects the hand and its fingers to the samples of given touchscreen. More...
 
virtual void move (Nimble::Vector2f v)
 Moves the fingers and the palm by given vector. More...
 
void removeFinger (int index)
 Removes the finger from the hand. More...
 
int searchFinger (long id) const
 Tries to find finger from the hand with given id. More...
 
void setLocationAboutFinger (size_t fingerIdx, Nimble::Vector2f location)
 Sets the location for the whole hand using some of its fingers as a reference point. More...
 
virtual VirtualInputType type () const
 Enum for the type of the hand. More...
 
 VirtualHand (Nimble::Vector2f location, int fingers)
 Creates a hand with given number of fingers (valid range from 1 to 5). More...
 
 VirtualHand (Nimble::Vector2f location, int fingers, long handId)
 Same as VirtualHand(Nimble::Vector2f location, int fingers) but sets the id of the hand manually. More...
 
virtual ~VirtualHand ()
 Destructor.
 
- Public Member Functions inherited from MultiWidgets::VirtualObject
int age () const
 Age (number of frames detected) of object. More...
 
long id () const
 Id of the virtual object. More...
 
Nimble::Vector2f location () const
 Location of the object, that is only updated using setLocation. More...
 
Nimble::Vector2f previousLocation () const
 Returns the previous location of the object. More...
 
void setLocation (Nimble::Vector2f location)
 Sets the location of the object. More...
 
 VirtualObject (Nimble::Vector2f loc)
 Constructs new virtual object with proper id. More...
 
 VirtualObject (long id, Nimble::Vector2 loc)
 Constructs new virtual object with given id. More...
 
virtual ~VirtualObject ()
 Destructor.
 

Static Public Member Functions

static VirtualHandPtr fingerDown (Nimble::Vector2f fingerLocation)
 Creates the hand with single finger. More...
 

Additional Inherited Members

- Protected Member Functions inherited from MultiWidgets::VirtualObject
void increaseAge (int frames=1)
 Increases the age of the virtual object. More...
 
void setPreviousLocation (Nimble::Vector2f loc)
 Sets the previous location of the object. More...
 

Detailed Description

VirtualHand consists of group of fingers (1-5) and a palm location.

It always owns the fingers it has. Fingers can't be shared among the hands Only way to get access to the fingers is through the virtual hand that owns it (except simple API of VirtualInput (VirtualInput::fingerUp, VirtualInput::updateFinger and VirtualInput::fingerUp)).

Constructor & Destructor Documentation

MultiWidgets::VirtualHand::VirtualHand ( Nimble::Vector2f  location,
int  fingers 
)

Creates a hand with given number of fingers (valid range from 1 to 5).

Places the fingers on the circle that has center at the location of hand palm and radius of 100. Generates the id automatically.

Parameters
locationLocation of the hand palm.
fingersNumber of fingers to generate.
MultiWidgets::VirtualHand::VirtualHand ( Nimble::Vector2f  location,
int  fingers,
long  handId 
)

Same as VirtualHand(Nimble::Vector2f location, int fingers) but sets the id of the hand manually.

Parameters
handIdId for the hand.

Member Function Documentation

void MultiWidgets::VirtualHand::addFinger ( Nimble::Vector2f  location)

Adds finger to the hand and places the finger to the given location.

The finger that was added last will be having the largest index (used with removeFinger- and finger-functions) among the fingers.

Parameters
locationLocation for the finger.
VirtualFinger& MultiWidgets::VirtualHand::finger ( int  index)

Access to finger.

Parameters
indexIndex number of the finger
Returns
Reference to finger
static VirtualHandPtr MultiWidgets::VirtualHand::fingerDown ( Nimble::Vector2f  fingerLocation)
static

Creates the hand with single finger.

The finger of the hand is placed to the given location.

Parameters
fingerLocationLocation of the finger
Returns
Shared pointer to the created hand
Examples:
VirtualInputExample.cpp.
int MultiWidgets::VirtualHand::fingers ( ) const

Number of fingers in hand.

Returns
Number of fingers owned by hand
virtual void MultiWidgets::VirtualHand::injectToSamples ( MultiTouch::Screen touchScreen,
int  sampleBegin,
int  sampleEnd 
)
virtual

Injects the hand and its fingers to the samples of given touchscreen.

Note
If this function is called, there is no separate need to call VirtualFinger::injectToSamples of the fingers that are owned by this hand.
Parameters
touchScreenThe synthesized input is injected to this touchscreen's samples
sampleBeginIndex of the first sample to handle
sampleEndIndex of the last sample (inclusive) to handle
See Also
VirtualObject::injectToSamples

Implements MultiWidgets::VirtualObject.

virtual void MultiWidgets::VirtualHand::move ( Nimble::Vector2f  v)
virtual

Moves the fingers and the palm by given vector.

Parameters
vVector to apply to the locations of fingers and palm

Reimplemented from MultiWidgets::VirtualObject.

void MultiWidgets::VirtualHand::removeFinger ( int  index)

Removes the finger from the hand.

Parameters
indexIndex of the finger that is removed
See Also
finger
int MultiWidgets::VirtualHand::searchFinger ( long  id) const

Tries to find finger from the hand with given id.

Parameters
idId of the searched finger.
Returns
Index of the finger. -1 is returned if finger was not found.
void MultiWidgets::VirtualHand::setLocationAboutFinger ( size_t  fingerIdx,
Nimble::Vector2f  location 
)

Sets the location for the whole hand using some of its fingers as a reference point.

The reference point finger is moved to the given location and the rest of the hand (palm and other fingers) are moved to locations so that the form of the whole hand stays the same.

Parameters
fingerIdxIndex of the finger that is used as a reference point
locationLocation for the reference point finger
virtual VirtualInputType MultiWidgets::VirtualHand::type ( ) const
virtual

Enum for the type of the hand.

Returns
VirtualInputType::VIRTUAL_INPUT_HAND

Implements MultiWidgets::VirtualObject.