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

Manage finger and hand focus/grab information. More...

#include <MultiWidgets/GrabManager.hpp>

Inheritance diagram for MultiWidgets::GrabManager:
Luminous::Transformer

Public Member Functions

Nimble::Vector2 averageTrackedObjectLocation (const TrackedObjectIds &ids, bool searchHistory, bool *ok=0) const
 Calculates the average location of a set of tracked objects. More...
 
size_t clippedObjectCount () const
 Get the number of objects available Returns the number of objects that have not been clipped away by the clipping regions. More...
 
size_t clippedObjectCount (MultiTouch::TrackedObjectType type) const
 Get the number of objects with given type available Returns the number of objects that have not been clipped away by the clipping regions. More...
 
int currentSampleNumber () const
 Get the current input sample index. More...
 
Radiant::TimeStamp currentTime () const
 Get absolute time-stamp for currently processed input sample. More...
 
MultiTouch::Finger findFinger (MultiTouch::TrackedObject::Id id, bool searchHistory=false) const
 Find the finger with given id from the current input sample. More...
 
MultiTouch::Hand findHand (MultiTouch::TrackedObject::Id id, bool searchHistory=false) const
 Find the hand with given id from the current input sample. More...
 
MultiTouch::Marker findMarker (MultiTouch::TrackedObject::Id id, bool searchHistory=false) const
 Find the marker with given id from the current input sample. More...
 
MultiTouch::Pen findPen (MultiTouch::TrackedObject::Id id, bool searchHistory=false) const
 Find the pen with given id from the current input sample. More...
 
MultiTouch::TrackedObject findTrackedObject (MultiTouch::TrackedObject::Id id, bool searchHistory=false) const
 Find the tracked object with given id from the current input sample. More...
 
MultiWidgets::TrackedObjectArray findTrackedObjects (const MultiWidgets::TrackedObjectIds &ids, bool searchHistory=false) const
 Find tracked objects with given ids. More...
 
virtual void finish ()
 Finish should be called after passing this input frame to your Widgets. More...
 
MultiTouch::TrackedObject getClippedObject (int index) const
 Returns the ith tracked object after clipping.
 
void grab (MultiTouch::TrackedObject::Id id, InputGrabber *grabber)
 Notifies the GrabManager that something has grabbed a tracked object.
 
InputGrabbergrabber (MultiTouch::TrackedObject::Id id) const
 Finds InputGrabbed for given TrackedObject. More...
 
 GrabManager (MultiTouch::Screen &screen)
 Constructs a new GrabManager for the given touchscreen.
 
Nimble::Vector2f initFingerTipLocation (MultiTouch::TrackedObject::Id fingerId, bool *found=0)
 Finds the initial finger tip location, i.e. More...
 
Nimble::Vector2f latestFingerTipLocation (MultiTouch::TrackedObject::Id fingerId, bool *found=0) const
 Finds the latest finger tip location. More...
 
Nimble::Vector2f latestTrackedObjectLocation (MultiTouch::TrackedObject::Id trackedObjectId, bool *found=0) const
 Finds the latest tracked object location. More...
 
void popClipRegion ()
 Pops a clip region from the clip stack.
 
void popWidget (ViewWidget *w)
 Removes the top-most ViewWidget from the view widget path. More...
 
void popWidget (Widget *w)
 Pop a Widget from the widget path. More...
 
virtual void prepare ()
 Prepare should be called for each input frame after the current sample has been set and before actually passing the input to any Widget. More...
 
MultiTouch::Sample prevSample () const
 Returns the previous touchscreen sample.
 
void pushClipRegion (Nimble::SizeF size)
 Push a clip-rectangle into the clip stack. More...
 
void pushWidget (ViewWidget *w)
 Push a ViewWidget into the view widget path. More...
 
void pushWidget (Widget *w)
 Push a Widget into the widget path. More...
 
size_t recursionDepth () const
 Returns the current recursion depth. More...
 
size_t recursionLimit () const
 Returns the recursion limit. More...
 
MultiTouch::Sample sample () const
 Returns the current touchscreen sample.
 
void setRecursionDepth (size_t depth)
 Sets the recursion depth. More...
 
void setRecursionLimit (size_t limit)
 Set the maximum recursion depth for input processing. More...
 
void setSample (int sample)
 Sets the current touchscreen sample number.
 
long sinceLastDetection (MultiTouch::TrackedObject::Id id) const
 Calculate when a tracked object was last detected. More...
 
MultiTouch::ScreentouchScreen () const
 Returns a reference to the touch-screen input.
 
void ungrab (MultiTouch::TrackedObject::Id id, InputGrabber *grabber)
 Notifies the GrabManager that something has ungrabbed a tracked object.
 
const WidgetPathviewWidgetPath () const
 Returns the current view widget path. More...
 
const WidgetPathwidgetPath () const
 Returns the current widget path. More...
 
- Public Member Functions inherited from Luminous::Transformer
void leftMul (const Nimble::Matrix4 &m)
 Multiply the top matrix from the left with the given matrix The end result is equivalent to: More...
 
void popTransform ()
 Pops the top matrix from the stack.
 
Nimble::Vector2 project (const Nimble::Vector2 &) const
 Apply the current transformation matrix on a 2D vector.
 
void pushTransform ()
 Push a new matrix to the stack, just copying the current top.
 
void pushTransform (const Nimble::Matrix4 &m)
 Push the given matrix to the stack pushTransform(m) has the same effect as: More...
 
void pushTransform (const Nimble::Matrix3 &m)
 
void pushTransformLeftMul (const Nimble::Matrix4 &m)
 Multiply the top matrix from the left with the given matrix and push the result into the stack.
 
void pushTransformLeftMul (const Nimble::Matrix3 &m)
 
void pushTransformRightMul (const Nimble::Matrix4 &m)
 Multiply the top matrix from the right with the given matrix and push the result into the stack.
 
void pushTransformRightMul (const Nimble::Matrix3 &m)
 
void resetTransform ()
 Clears the stack so it only contains an identity matrix.
 
void rightMul (const Nimble::Matrix4 &m)
 Multiply the top matrix from the right with the given matrix The end result is equivalent to: More...
 
void setTransform (const Nimble::Matrix4 &m)
 Replaces the top matrix with the given matrix. More...
 
size_t stackSize () const
 Get the size of the transform stack. More...
 
const Nimble::Matrix4transform () const
 Get the top matrix of the stack.
 
Nimble::Matrix3 transform3 () const
 Get the top matrix of the stack as 3x3-matrix.
 
 Transformer ()
 Creates an empty transformation stack.
 
Nimble::Vector2 unproject (const Nimble::Vector2 &) const
 Apply inverse of the current transformation matrix on a 2D vector.
 
virtual ~Transformer ()
 Deletes the transformation stack.
 

Additional Inherited Members

- Protected Member Functions inherited from Luminous::Transformer
virtual void beforeTransformChange ()
 This function gets called just before the transformation matrix is changed. More...
 
- Protected Attributes inherited from Luminous::Transformer
std::stack< Nimble::Matrix4,
std::vector< Nimble::Matrix4 > > 
m_stack
 The transformation stack.
 

Detailed Description

Manage finger and hand focus/grab information.

GrabManager handles all the things that are needed to keep track of which fingers and hands have been grabbed by widgets.

It also handles input clipping that is required by MultiWidgets::ViewWidget.

Examples:
AnimatorExample.cpp, CustomInputWidgetExample.cpp, MarkerExample.cpp, PenExample.cpp, PositionalSoundsExample.cpp, and Widget3DExample.cpp.

Member Function Documentation

Nimble::Vector2 MultiWidgets::GrabManager::averageTrackedObjectLocation ( const TrackedObjectIds ids,
bool  searchHistory,
bool *  ok = 0 
) const

Calculates the average location of a set of tracked objects.

Parameters
idsThe list of object ids to be looked at
searchHistoryGo through the history if the object is no longer present
okIf non-null, then the boolean is set to true if at least one object was found
size_t MultiWidgets::GrabManager::clippedObjectCount ( ) const

Get the number of objects available Returns the number of objects that have not been clipped away by the clipping regions.

Returns
number of objects
size_t MultiWidgets::GrabManager::clippedObjectCount ( MultiTouch::TrackedObjectType  type) const

Get the number of objects with given type available Returns the number of objects that have not been clipped away by the clipping regions.

Returns
number of objects
int MultiWidgets::GrabManager::currentSampleNumber ( ) const

Get the current input sample index.

Returns
current sample index
Radiant::TimeStamp MultiWidgets::GrabManager::currentTime ( ) const

Get absolute time-stamp for currently processed input sample.

Returns
time-stamp of the currently processed input sample
MultiTouch::Finger MultiWidgets::GrabManager::findFinger ( MultiTouch::TrackedObject::Id  id,
bool  searchHistory = false 
) const

Find the finger with given id from the current input sample.

Parameters
idfinger id to search for
searchHistoryif true, searches the input history for latest occurrence
Returns
finger with matching id or null finger
MultiTouch::Hand MultiWidgets::GrabManager::findHand ( MultiTouch::TrackedObject::Id  id,
bool  searchHistory = false 
) const

Find the hand with given id from the current input sample.

Parameters
idhand id to search for
searchHistoryif true, searches the input history for latest occurrence
Returns
hand with matching id or null hand
MultiTouch::Marker MultiWidgets::GrabManager::findMarker ( MultiTouch::TrackedObject::Id  id,
bool  searchHistory = false 
) const

Find the marker with given id from the current input sample.

Parameters
idmarker id to search for
searchHistoryif true, searches the input history for latest occurrence
Returns
marker with matching id or null marker
MultiTouch::Pen MultiWidgets::GrabManager::findPen ( MultiTouch::TrackedObject::Id  id,
bool  searchHistory = false 
) const

Find the pen with given id from the current input sample.

Parameters
idpen id to search for
searchHistoryif true, searches the input history for latest occurrence
Returns
pen with matching id or null pen
MultiTouch::TrackedObject MultiWidgets::GrabManager::findTrackedObject ( MultiTouch::TrackedObject::Id  id,
bool  searchHistory = false 
) const

Find the tracked object with given id from the current input sample.

Parameters
idobject id to search for
searchHistoryif true, searches the input history for latest occurrence
Returns
object with matching id or null object
MultiWidgets::TrackedObjectArray MultiWidgets::GrabManager::findTrackedObjects ( const MultiWidgets::TrackedObjectIds ids,
bool  searchHistory = false 
) const

Find tracked objects with given ids.

Parameters
idsids to search for
searchHistoryif true, searches the input history for latest occurrence
Returns
objects with matching ids
virtual void MultiWidgets::GrabManager::finish ( )
virtual

Finish should be called after passing this input frame to your Widgets.

InputGrabber* MultiWidgets::GrabManager::grabber ( MultiTouch::TrackedObject::Id  id) const

Finds InputGrabbed for given TrackedObject.

Parameters
idid of TrackedObject
Returns
object that has grabbed the TrackedObject, or null if the TrackedObject isn't grabbed
Nimble::Vector2f MultiWidgets::GrabManager::initFingerTipLocation ( MultiTouch::TrackedObject::Id  fingerId,
bool *  found = 0 
)

Finds the initial finger tip location, i.e.

the point where the finger was first detected. The returned coordinate value is multiplied by the current transformation matrix. If the finger is not found, then 0,0 is returned.

Parameters
fingerIdfinger id
[out]foundindicates if the finger was found
Returns
finger location
Nimble::Vector2f MultiWidgets::GrabManager::latestFingerTipLocation ( MultiTouch::TrackedObject::Id  fingerId,
bool *  found = 0 
) const

Finds the latest finger tip location.

The returned coordinate value is multiplied by the current transformation matrix. If the finger is not found, then 0,0 is returned.

Parameters
fingerIdfinger id
[out]foundindicates if the finger was found
Returns
finger location
Nimble::Vector2f MultiWidgets::GrabManager::latestTrackedObjectLocation ( MultiTouch::TrackedObject::Id  trackedObjectId,
bool *  found = 0 
) const

Finds the latest tracked object location.

The returned coordinate value is multiplied by the current transformation matrix. If the object is not found, then 0,0 is returned.

Parameters
trackedObjectIdobject id
[out]foundindicates if the object was found
Returns
object location
void MultiWidgets::GrabManager::popWidget ( ViewWidget w)

Removes the top-most ViewWidget from the view widget path.

Parameters
wshould be the view widget currently on top
void MultiWidgets::GrabManager::popWidget ( Widget w)

Pop a Widget from the widget path.

Parameters
wshould be the view widget currently on top
virtual void MultiWidgets::GrabManager::prepare ( )
virtual

Prepare should be called for each input frame after the current sample has been set and before actually passing the input to any Widget.

void MultiWidgets::GrabManager::pushClipRegion ( Nimble::SizeF  size)

Push a clip-rectangle into the clip stack.

The rect spans the coordinates [0,0]-[size] and is transformed to screen coordinates by the inverse of the matrix stack in GrabManager.

Parameters
sizesize of the clip region
void MultiWidgets::GrabManager::pushWidget ( ViewWidget w)

Push a ViewWidget into the view widget path.

See Also
widgetPath
Parameters
wview widget to push
void MultiWidgets::GrabManager::pushWidget ( Widget w)

Push a Widget into the widget path.

Parameters
wwidget to push
size_t MultiWidgets::GrabManager::recursionDepth ( ) const

Returns the current recursion depth.

Returns
current recursion depth
size_t MultiWidgets::GrabManager::recursionLimit ( ) const

Returns the recursion limit.

Returns
recursion limit
void MultiWidgets::GrabManager::setRecursionDepth ( size_t  depth)

Sets the recursion depth.

See Also
recursionDepth
Parameters
depthnew recursion depth
void MultiWidgets::GrabManager::setRecursionLimit ( size_t  limit)

Set the maximum recursion depth for input processing.

Recursive processing may occur when MultiWidgets::ViewWidget is used to create recursive loops in the widget hierarchy. The limit is used to prevent infinite recursion.

Parameters
limitmaximum recursion depth
long MultiWidgets::GrabManager::sinceLastDetection ( MultiTouch::TrackedObject::Id  id) const

Calculate when a tracked object was last detected.

Parameters
idid to search for
Returns
number of samples since the object was last detected or -1 if not found
const WidgetPath& MultiWidgets::GrabManager::viewWidgetPath ( ) const

Returns the current view widget path.

The path contains all ViewWidgets through which input has been propagated. This path is used to avoid feeding input more than once to a single widget when there are multiple views in a scene.

Returns
current view widget path
const WidgetPath& MultiWidgets::GrabManager::widgetPath ( ) const

Returns the current widget path.

This path contains all widgets through which input has been propagated. This path is used by Widget::bringToTop to determine which depths to modify when a widget must be brought on top.

Returns
current widget path