mulwidgets/gesturehelper/src/pointarray.h
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     1 /*
       
     2 * Copyright (c) 2008 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:  Array of points
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef _POINTARRAY_H_
       
    19 #define _POINTARRAY_H_
       
    20 
       
    21 #include <e32std.h>
       
    22 
       
    23 namespace GestureHelper
       
    24 {
       
    25 
       
    26 /** 
       
    27  * Represents a single point given at certain time
       
    28  */
       
    29 struct TPointEntry 
       
    30     {
       
    31     /** constructor */
       
    32     inline TPointEntry( const TPoint& aPos, const TTime& aTime ) 
       
    33             : iPos( aPos ), iTime( aTime )
       
    34         {
       
    35         }
       
    36     
       
    37     TPoint iPos;
       
    38     TTime iTime;
       
    39     };
       
    40     
       
    41 /**
       
    42  * Array of points that wraps another point array
       
    43  * The purpose of this class is to allow deriving classes to override []
       
    44  * and in that member function adjust the point, e.g., by setting one
       
    45  * axis to always a constant value. This allows providing a sequence of
       
    46  * points to the recogniser in which the other axis is ignored.
       
    47  */
       
    48 NONSHARABLE_CLASS( TPointArray )
       
    49     {
       
    50 public:
       
    51     /** 
       
    52      * @param aPoints points array to wrap (and filter)
       
    53      */
       
    54     TPointArray( const RArray< TPointEntry >& aPoints ); 
       
    55     /** @returns length of the array */
       
    56     TInt Count() const;
       
    57     /** 
       
    58      * @returns a filtered point at aIndex. Default implementation same
       
    59      *          as Raw(...)
       
    60      * virtual so deriving classes can modify the point (e.g., filter one axis)
       
    61      */
       
    62     virtual TPoint operator[]( TInt aIndex ) const;
       
    63     /** @returns an raw, non-filtered point at aIndex */
       
    64     TPoint Raw( TInt aIndex ) const;
       
    65     
       
    66 private:
       
    67     const RArray< TPointEntry >& iPoints;
       
    68     };
       
    69 
       
    70 } // namespace GestureHelper
       
    71 
       
    72 #endif // _POINTARRAY_H_