uiacceltk/hitchcock/Client/src/alftransformation.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Transformation class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alf/alftransformation.h"
       
    21 #include "alftransformationsubsession.h"
       
    22 #include "alf/alfenv.h"
       
    23 #include "alfclient.h"
       
    24 
       
    25 // Provate data
       
    26 struct CAlfTransformation::TPrivateData
       
    27     {
       
    28     CAlfEnv* iEnv;              // Not owned.
       
    29     RAlfTransformationSubSession iSubSession;     // Owned
       
    30     };
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // Constructor
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CAlfTransformation::CAlfTransformation()
       
    39     {
       
    40     }
       
    41 
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // ConstructL
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 void CAlfTransformation::ConstructL(CAlfEnv& aEnv)
       
    48     {
       
    49     iData = new (ELeave) TPrivateData;
       
    50     
       
    51     iData->iEnv = &aEnv;
       
    52     User::LeaveIfError( iData->iSubSession.Open( aEnv.Client() ) );
       
    53     }
       
    54 
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // NewL
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 EXPORT_C CAlfTransformation* CAlfTransformation::NewL(CAlfEnv& aEnv)
       
    61     {
       
    62     CAlfTransformation* self = CAlfTransformation::NewLC(aEnv);
       
    63     CleanupStack::Pop( self );
       
    64     return self;
       
    65     }
       
    66 
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // NewLC
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 EXPORT_C CAlfTransformation* CAlfTransformation::NewLC(CAlfEnv& aEnv)
       
    73     {
       
    74     CAlfTransformation* self = new( ELeave ) CAlfTransformation;
       
    75     CleanupStack::PushL( self );
       
    76     self->ConstructL(aEnv);
       
    77     return self;
       
    78     }
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // Destrucotr
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 EXPORT_C CAlfTransformation::~CAlfTransformation()
       
    86     {
       
    87     if ( iData )
       
    88         {
       
    89         iData->iSubSession.Close();
       
    90         }
       
    91     delete iData;
       
    92     iData = NULL;
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // Return server handle
       
    97 // ---------------------------------------------------------------------------
       
    98 //  
       
    99 TInt CAlfTransformation::ServerHandle() const
       
   100     {
       
   101     return iData->iSubSession.SubSessionHandle();
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // Load identity
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 EXPORT_C void CAlfTransformation::LoadIdentity()
       
   109     {
       
   110     iData->iSubSession.LoadIdentity();
       
   111     }
       
   112  
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // 
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 EXPORT_C TInt CAlfTransformation::Count() const
       
   119     {
       
   120     return iData->iSubSession.Count();                            
       
   121     }
       
   122     
       
   123 // ---------------------------------------------------------------------------
       
   124 // 
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 EXPORT_C TInt CAlfTransformation::NonIdentityCount() const
       
   128     {
       
   129     return iData->iSubSession.NonIdentityCount();                    
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // 
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C CAlfTransformation::TTransform CAlfTransformation::Step(TInt aIndex)
       
   137     {
       
   138     return iData->iSubSession.Step(aIndex);            
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // 
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 EXPORT_C void CAlfTransformation::ReplaceStep(TInt aIndex, 
       
   146     CAlfTransformation::TTransform aTransformationStep)
       
   147     {
       
   148     iData->iSubSession.ReplaceStep(aIndex,aTransformationStep);    
       
   149     }
       
   150 
       
   151     
       
   152 // ---------------------------------------------------------------------------
       
   153 // 
       
   154 // ---------------------------------------------------------------------------
       
   155 //
       
   156 EXPORT_C void CAlfTransformation::Rotate(TReal32 aAngle) __SOFTFP
       
   157     {
       
   158     TAlfTimedValue timedAngle;
       
   159     timedAngle.SetTarget(aAngle,0);
       
   160     Rotate(timedAngle);        
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // Rotate
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 EXPORT_C void CAlfTransformation::Rotate(const TAlfTimedValue& aAngle)
       
   168     {
       
   169     Rotate(aAngle, 0.f, 0.f, -1.f);
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // 
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 EXPORT_C void CAlfTransformation::Rotate(TReal32 aAngle, TReal32 aAxisX, 
       
   177     TReal32 aAxisY, TReal32 aAxisZ) __SOFTFP
       
   178     {
       
   179     TAlfTimedValue timedAngle;
       
   180     timedAngle.SetTarget(aAngle,0);
       
   181     Rotate(timedAngle, aAxisX, aAxisY, aAxisZ);        
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // 
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 EXPORT_C void CAlfTransformation::Rotate(const TAlfTimedValue& aAngle, 
       
   189                          TReal32 aAxisX, TReal32 aAxisY, TReal32 aAxisZ) __SOFTFP
       
   190     {
       
   191     iData->iSubSession.Rotate(aAngle,aAxisX,aAxisY,aAxisZ);            
       
   192     }
       
   193 
       
   194     
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // 
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 EXPORT_C void CAlfTransformation::Translate(const TAlfTimedValue& aX, 
       
   201     const TAlfTimedValue& aY)
       
   202     {
       
   203     iData->iSubSession.Translate(aX, aY);      
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // Tramslate
       
   208 // ---------------------------------------------------------------------------
       
   209 //   
       
   210 EXPORT_C void CAlfTransformation::Translate(TReal32 aX, TReal32 aY) __SOFTFP
       
   211     {
       
   212     iData->iSubSession.Translate( aX, aY );
       
   213     }
       
   214     
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // 
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 EXPORT_C void CAlfTransformation::Scale(TReal32 aX, TReal32 aY) __SOFTFP
       
   221     {
       
   222     Scale(aX, aY, 1.f);
       
   223     }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 // 
       
   227 // ---------------------------------------------------------------------------
       
   228 //
       
   229 EXPORT_C void CAlfTransformation::Scale(const TAlfTimedValue& aX, 
       
   230     const TAlfTimedValue& aY)
       
   231     {
       
   232     TAlfTimedValue timedZ;
       
   233     timedZ.SetTarget(1.f,0);
       
   234     Scale(aX, aY, timedZ);    
       
   235     }
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // 
       
   239 // ---------------------------------------------------------------------------
       
   240 //
       
   241 EXPORT_C void CAlfTransformation::Scale(TReal32 aX, TReal32 aY, TReal32 aZ) __SOFTFP
       
   242     {
       
   243     TAlfTimedValue timedX;
       
   244     TAlfTimedValue timedY;
       
   245     TAlfTimedValue timedZ;
       
   246     timedX.SetTarget(aX,0);
       
   247     timedY.SetTarget(aY,0);
       
   248     timedZ.SetTarget(aZ,0);
       
   249     Scale(timedX, timedY, timedZ);                
       
   250     }
       
   251 
       
   252 // ---------------------------------------------------------------------------
       
   253 // 
       
   254 // ---------------------------------------------------------------------------
       
   255 //
       
   256 EXPORT_C void CAlfTransformation::Scale(const TAlfTimedValue& aX, 
       
   257     const TAlfTimedValue& aY, const TAlfTimedValue& aZ)
       
   258     {
       
   259     iData->iSubSession.Scale(aX,aY,aZ);
       
   260     }
       
   261     
       
   262     
       
   263