uiacceltk/hitchcock/coretoolkit/inc/HuiMatrixStack.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-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:   Definition of CHuiMatrixStack. CHuiMatrixStack is a stack of 
       
    15 *                2D transformation matrices.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __HUIMATRIXSTACK_H__
       
    22 #define __HUIMATRIXSTACK_H__
       
    23 
       
    24 
       
    25 #include <e32base.h>
       
    26 #include "uiacceltk/HuiRealPoint.h"
       
    27 
       
    28 
       
    29 /**
       
    30  * Stack of 2D transformation matrices.
       
    31  */
       
    32 NONSHARABLE_CLASS(CHuiMatrixStack) : public CBase
       
    33     {
       
    34 public:
       
    35 
       
    36     /** 2D transformation matrix. */
       
    37     struct TMatrix
       
    38         {   
       
    39     public:        
       
    40         TReal32 iMatrix[9];       
       
    41 
       
    42         /** Matrix is an identity matrix. Multiplication can be skipped. */
       
    43         TBool iIsIdentity;
       
    44 
       
    45     public:
       
    46         /** Constructor that initializes the matrix as an identity matrix. */
       
    47         IMPORT_C TMatrix();
       
    48 
       
    49         /**
       
    50          * Multiplies this matrix with another one. Result is stored in this
       
    51          * matrix.
       
    52          *
       
    53          * @param aOther  Matrix to multiply with.
       
    54          */
       
    55         void Multiply(const TMatrix& aOther);
       
    56 
       
    57         /**
       
    58          * Multiplies a point with the matrix.
       
    59          *
       
    60          * @param aPoint  2D point. Modified.
       
    61          */
       
    62         IMPORT_C void Multiply(THuiRealPoint& aPoint) const;
       
    63         };
       
    64     
       
    65     
       
    66 public:
       
    67 
       
    68     /* Constructors and destructor. */
       
    69     
       
    70     IMPORT_C static CHuiMatrixStack* NewL();
       
    71     
       
    72     static CHuiMatrixStack* NewLC();
       
    73     
       
    74     
       
    75     /**
       
    76      * Destructor.
       
    77      */
       
    78     virtual ~CHuiMatrixStack();
       
    79     
       
    80     
       
    81     /* Methods. */
       
    82     
       
    83     IMPORT_C TInt Count() const;
       
    84 
       
    85     IMPORT_C TMatrix& Current();
       
    86 
       
    87     /**
       
    88      * @return  Error code.
       
    89      */
       
    90     IMPORT_C TInt Push();
       
    91 
       
    92     IMPORT_C void Pop();
       
    93     
       
    94     IMPORT_C void LoadIdentity();
       
    95     
       
    96     IMPORT_C void Multiply(const TMatrix& aMatrix);    
       
    97     
       
    98     
       
    99 protected:
       
   100 
       
   101     /* Constructors. */
       
   102     
       
   103     CHuiMatrixStack();
       
   104     
       
   105     void ConstructL();    
       
   106         
       
   107     
       
   108 private:
       
   109 
       
   110     // Typedef for convenience.
       
   111     typedef RArray<TMatrix> RMatrixStack;
       
   112             
       
   113     RMatrixStack iStack;            
       
   114     };
       
   115 
       
   116 
       
   117 #endif // __HUIMATRIXSTACK_H__