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

Helper class to ease the managing of virtual input and injecting it to the touchscreen samples. More...

#include <MultiWidgets/VirtualInput.hpp>

Public Member Functions

void addObject (VirtualObjectPtr object)
 Adds new VirtualObject to the managed objects. More...
 
void clear ()
 Removes all the objects managed by this instance.
 
void clearHands ()
 Removes all the hands managed by this instance.
 
void clearMarkers ()
 Removes all the markers managed by this instance.
 
void clearPens ()
 Removes all the pens managed by this instance.
 
bool empty () const
 Is there any managed objects. More...
 
long fingerDown (Nimble::Vector2f loc)
 Part of the simple API for generating and managing hands with single finger. More...
 
void fingerUp (long id)
 Part of the simple API for generating and managing hands with single finger. More...
 
VirtualHandPtr getHand (long id)
 Gets the managed VirtualHand that has given id. More...
 
VirtualMarkerPtr getMarker (long id)
 Gets the managed VirtualMarker that has given id. More...
 
VirtualObjectPtr getObject (long id)
 Gets the managed VirtualObject has given id. More...
 
VirtualPenPtr getPen (long id)
 Gets the managed VirtualPen that has given id. More...
 
void injectToSamples (MultiTouch::Screen &touchScreen, size_t sampleBegin, size_t sampleEnd)
 Injects data of the VirtualObject's that are managed by this instance to the given touchscreen's samples. More...
 
long markerDown (Nimble::Vector2f loc, uint64_t code)
 Part of the simple API for generating and managing markers. More...
 
void markerUp (long id)
 Part of the simple API for generating and managing markers. More...
 
long penDown (Nimble::Vector2f loc)
 Part of the simple API for generating and managing pens. More...
 
void penUp (long id)
 Part of the simple API for generating and managing pens. More...
 
void removeObject (long id)
 Removes the managed object with given id from internal data structures. More...
 
void updateFinger (long id, Nimble::Vector2f loc)
 Part of the simple API for generating and managing hands with single finger. More...
 
void updateMarker (long id, Nimble::Vector2f loc)
 Part of the simple API for generating and managing markers. More...
 
void updatePen (long id, Nimble::Vector2f loc)
 Part of the simple API for generating and managing pens. More...
 
 VirtualInput (bool autoSynthesize=true)
 Constructs new VirtualInput class. More...
 
 ~VirtualInput ()
 Destructor.
 

Detailed Description

Helper class to ease the managing of virtual input and injecting it to the touchscreen samples.

Keeps track of a collection of VirtualObject's. Does not accept VirtualFinger because they are handled by keeping track to the VirtualHand's owning the fingers.

Examples:
VirtualInputExample.cpp.

Constructor & Destructor Documentation

MultiWidgets::VirtualInput::VirtualInput ( bool  autoSynthesize = true)
explicit

Constructs new VirtualInput class.

Parameters
autoSynthesizeIf set to true injects the data of the managed VirtualObject's to the Application's touchscreen's samples by calling injectToSamples of each VirtualObject this manages. Otherwise user needs to inject the data of virtual objects manually into the samples.

Member Function Documentation

void MultiWidgets::VirtualInput::addObject ( VirtualObjectPtr  object)

Adds new VirtualObject to the managed objects.

Parameters
objectObject to add.
Examples:
VirtualInputExample.cpp.
bool MultiWidgets::VirtualInput::empty ( ) const

Is there any managed objects.

Returns
True if this contains some managed VirtualObjects.
long MultiWidgets::VirtualInput::fingerDown ( Nimble::Vector2f  loc)

Part of the simple API for generating and managing hands with single finger.

Creates hand with single finger so that the finger is placed in the given location.

Parameters
locLocation for the finger.
Returns
Id of the finger that is used as a key in updateFinger- and fingerUp-functions.
See Also
updateFinger, fingerUp
void MultiWidgets::VirtualInput::fingerUp ( long  id)

Part of the simple API for generating and managing hands with single finger.

Removes the finger created by fingerDown.

Parameters
idId of the finger (the one returned by fingerDown).
See Also
fingerDown, fingerUp
VirtualHandPtr MultiWidgets::VirtualInput::getHand ( long  id)

Gets the managed VirtualHand that has given id.

Parameters
idId of the queried hand
Returns
Shared pointer to the hand. nullptr if there does not exist hand with the given id.
VirtualMarkerPtr MultiWidgets::VirtualInput::getMarker ( long  id)

Gets the managed VirtualMarker that has given id.

Parameters
idId of the queried marker
Returns
Shared pointer to the marker. nullptr if there does not exist marker with the given id.
VirtualObjectPtr MultiWidgets::VirtualInput::getObject ( long  id)

Gets the managed VirtualObject has given id.

Parameters
idId of the queried object
Returns
Shared pointer to the object. nullptr if there does not exist object with the given id.
VirtualPenPtr MultiWidgets::VirtualInput::getPen ( long  id)

Gets the managed VirtualPen that has given id.

Parameters
idId of the queried pen
Returns
Shared pointer to the pen. nullptr if there does not exist pen with the given id.
void MultiWidgets::VirtualInput::injectToSamples ( MultiTouch::Screen touchScreen,
size_t  sampleBegin,
size_t  sampleEnd 
)

Injects data of the VirtualObject's that are managed by this instance to the given touchscreen's samples.

Calls injectToSamples for each managed object.

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
Note
All the objects that are at the moment managed by this class are injected into samples of touchscreen.
long MultiWidgets::VirtualInput::markerDown ( Nimble::Vector2f  loc,
uint64_t  code 
)

Part of the simple API for generating and managing markers.

Creates marker that is placed in the given location.

Parameters
locLocation for the marker.
codeCode of the marker.
Returns
Id of the marker that is used as a key in updateMarker- and markerUp-functions.
See Also
updateMarker, markerUp
void MultiWidgets::VirtualInput::markerUp ( long  id)

Part of the simple API for generating and managing markers.

Updates the location of the marker created by markerDown.

Parameters
idId of the marker (the one returned by markerDown).
See Also
markerDown, markerUp
long MultiWidgets::VirtualInput::penDown ( Nimble::Vector2f  loc)

Part of the simple API for generating and managing pens.

Creates pen that is placed in the given location.

Parameters
locLocation for the pen.
Returns
Id of the pen that is used as a key in updatePen- and penUp-functions.
See Also
updatePen, penUp
void MultiWidgets::VirtualInput::penUp ( long  id)

Part of the simple API for generating and managing pens.

Removes the pen created by penDown.

Parameters
idId of the pen (the one returned by penDown).
See Also
penDown, penUp
void MultiWidgets::VirtualInput::removeObject ( long  id)

Removes the managed object with given id from internal data structures.

Parameters
odId of the object to be removed
Examples:
VirtualInputExample.cpp.
void MultiWidgets::VirtualInput::updateFinger ( long  id,
Nimble::Vector2f  loc 
)

Part of the simple API for generating and managing hands with single finger.

Updates the location of the finger created by fingerDown.

Parameters
idId of the finger (the one returned by fingerDown).
locNew location for the finger.
See Also
fingerDown, fingerUp
void MultiWidgets::VirtualInput::updateMarker ( long  id,
Nimble::Vector2f  loc 
)

Part of the simple API for generating and managing markers.

Updates the location of the marker created by markerDown.

Parameters
idId of the marker (the one returned by markerDown).
locNew location for the marker.
See Also
markerDown, markerUp
void MultiWidgets::VirtualInput::updatePen ( long  id,
Nimble::Vector2f  loc 
)

Part of the simple API for generating and managing pens.

Updates the location of the pen created by penDown.

Parameters
idId of the pen (the one returned by penDown).
locNew location for the pen.
See Also
penDown, penUp