mulwidgets/gesturehelper/src/gesturerecogniser.h
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Algorithm to recognise gesture from a stream of points
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef _GESTURERECOGNISER_H_
       
    19 #define _GESTURERECOGNISER_H_
       
    20 
       
    21 #include <e32std.h>
       
    22 #include <gestureobserver.h>
       
    23 
       
    24 struct TPointerEvent;
       
    25 
       
    26 namespace GestureHelper
       
    27 {
       
    28 
       
    29 class TPointArray;
       
    30 
       
    31 /**
       
    32  * Note: Not a static class or a function pointer, just to make it sligthly 
       
    33  * easier to replace it with a heavier implementation
       
    34  */
       
    35 NONSHARABLE_CLASS( TGestureRecogniser )
       
    36     {
       
    37 public:
       
    38     /** 
       
    39      * Translates points into a gesture code
       
    40      * @param aPoints Points that form the gestures. Client is not required 
       
    41      *                to pass in repeated points (sequential points that are 
       
    42      *                almost in the same place)
       
    43      * @param aAxis Axis to filter the points
       
    44      * @return recognised gesture id or EUnknownGesture
       
    45      */
       
    46     TGestureCode GestureCode( const TPointArray& aPoints, MGestureEvent::TAxis aRelevantAxis ) const;
       
    47 
       
    48     /** 
       
    49      * Translates 2 sequences of points into a multitouch gesture code
       
    50      * @param aPoints Points that represent the first touch point variations. Client is not required 
       
    51      *                to pass in repeated points (sequential points that are 
       
    52      *                almost in the same place)
       
    53      * @param aSecondaryPoints Points that represent the second touch point variations.
       
    54      * @param aPreviousDistance distance between the two points when the pinch was recognized the last time.
       
    55      * @param aisFirstPinch, Is this the first pinch of teh current gesture. Required to decide which tolerance to use
       
    56      * @return recognised gesture id or EUnknownGesture if its not a valid multi touch gesture
       
    57      */
       
    58     TGestureCode MultiTouchGestureCode( const TPointArray& aPoints, const TPointArray& aSecondaryPoints, TInt aPreviousDistance,
       
    59             TBool aIsFirstPinch ) const;
       
    60     
       
    61     /** 
       
    62      * Validate the points to decide its a drag or not
       
    63      * @param aPoints Points that form the gestures. Client is not required 
       
    64      *                to pass in repeated points (sequential points that are 
       
    65      *                almost in the same place)
       
    66      * @param aAxis Axis to filter the points
       
    67      * @return EGestureDrag if valid else returns EUnknownGesture
       
    68      */    
       
    69     TGestureCode ValidateDrag( const TPointArray& aPoints, MGestureEvent::TAxis aRelevantAxis ) const;
       
    70     
       
    71     /** 
       
    72      * Validate the points to decide its a drag or not
       
    73      * @param aPoints Points that form the gestures. Client is not required 
       
    74      *                to pass in repeated points (sequential points that are 
       
    75      *                almost in the same place)
       
    76      * @param aAxis Axis to filter the points
       
    77      * @return EGestureDrag if valid else returns EUnknownGesture
       
    78      */    
       
    79     TInt Length( const TPoint aPoint, const TPoint aSecondaryPoint ) const;
       
    80 
       
    81     /** 
       
    82      * Return the pointer number from the given event
       
    83 	 *
       
    84      * @param aEvent, event for which the pointer number needs to be fetched
       
    85      * 
       
    86 	 * This function is added here only for simulating multiple pointer events
       
    87 	 * for testing UT, For simulation purpose we will have a custom implemetation
       
    88 	 * which will override this method and return our own pointer numbers
       
    89 	 * So that we can simulate multiple pointer event.
       
    90      * @return TInt pointer number
       
    91      */       
       
    92     TInt PointerNumber( const TPointerEvent& aEvent);
       
    93     
       
    94     };
       
    95     
       
    96 } // namespace GestureHelper
       
    97 
       
    98 #endif // _GESTURERECOGNISER_H_