javauis/amms_qt/ammscontrol/audio3D/src/cammslocationcontrolgroup.cpp
changeset 23 98ccebc37403
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Group for location controls
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "cammslocationcontrolgroup.h"
       
    22 #include "cammslocationcontrol.h"
       
    23 #include "ammsutil.h"
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CAMMSLocationControlGroup::NewLC
       
    29 // Two-phased constructor.
       
    30 // -----------------------------------------------------------------------------
       
    31 CAMMSLocationControlGroup* CAMMSLocationControlGroup::NewLC(
       
    32     TAMMSControlTypes aControlType)
       
    33 {
       
    34     CAMMSLocationControlGroup* self = new(ELeave) CAMMSLocationControlGroup(
       
    35         aControlType);
       
    36 
       
    37     CleanupStack::PushL(self);
       
    38     self->ConstructL();
       
    39 
       
    40     return self;
       
    41 
       
    42 }
       
    43 
       
    44 // Destructor
       
    45 CAMMSLocationControlGroup::~CAMMSLocationControlGroup()
       
    46 {
       
    47 }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CAMMSLocationControlGroup::Cartesian
       
    51 // Gets the coordinates of the current location
       
    52 // (other items were commented in a header).
       
    53 // -----------------------------------------------------------------------------
       
    54 void CAMMSLocationControlGroup::CartesianL(
       
    55     TInt aLocation[ KAMMSVectorComponents ])
       
    56 {
       
    57     for (TInt i = 0; i < KAMMSVectorComponents; i++)
       
    58     {
       
    59         aLocation[ i ] = iCommited.iLocation[ i ];
       
    60     }
       
    61 }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CAMMSLocationControlGroup::SetCartesianL
       
    65 // Moves the object to the new location
       
    66 // (other items were commented in a header).
       
    67 // -----------------------------------------------------------------------------
       
    68 void CAMMSLocationControlGroup::SetCartesianL(TInt aX, TInt aY, TInt aZ)
       
    69 {
       
    70     iUncommited.iLocation[ EComponentX ] = aX;
       
    71     iUncommited.iLocation[ EComponentY ] = aY;
       
    72     iUncommited.iLocation[ EComponentZ ] = aZ;
       
    73 
       
    74     UpdateL(ELocation);
       
    75 }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CAMMSLocationControlGroup::SetSphericalL
       
    79 // Moves the object to the new location
       
    80 // (other items were commented in a header).
       
    81 // -----------------------------------------------------------------------------
       
    82 void CAMMSLocationControlGroup::SetSphericalL(
       
    83     TInt aAzimuth,
       
    84     TInt aElevation,
       
    85     TInt aRadius)
       
    86 {
       
    87     __ASSERT_DEBUG(aRadius >= 0, User::Invariant());
       
    88 
       
    89     TInt sphericalVector[] = { aAzimuth, aElevation, aRadius };
       
    90 
       
    91     // Convert to cartesian.
       
    92     AMMSUtil::FromSphericalToCartesianL(sphericalVector,
       
    93                                         iUncommited.iLocation);
       
    94 
       
    95     UpdateL(ELocation);
       
    96 }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CAMMSLocationControlGroup::TypeSafeControl
       
   100 // Gets control. Ownership is not tranferred.
       
   101 // (other items were commented in a header).
       
   102 // -----------------------------------------------------------------------------
       
   103 CAMMSLocationControl*
       
   104 CAMMSLocationControlGroup::TypeSafeControl(TInt aIndex) const
       
   105 {
       
   106     return static_cast<CAMMSLocationControl*>(Control(aIndex));
       
   107 }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CAMMSLocationControlGroup::ClassName
       
   111 // Returns class name that identifies this control group.
       
   112 // (other items were commented in a header).
       
   113 // -----------------------------------------------------------------------------
       
   114 const TDesC16& CAMMSLocationControlGroup::ClassName()
       
   115 {
       
   116     return KAMMSLocationControlClassName;
       
   117 }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CAMMSLocationControlGroup::CommitL
       
   121 // Transfers all the pending parameters to the audio processing system.
       
   122 // (other items were commented in a header).
       
   123 // -----------------------------------------------------------------------------
       
   124 void CAMMSLocationControlGroup::CommitL(TInt aCommit)
       
   125 {
       
   126     if (aCommit & ELocation)
       
   127     {
       
   128         TInt controls = ControlCount();
       
   129         for (TInt i = 0; i < controls; i++)
       
   130         {
       
   131             CAMMSLocationControl* control = TypeSafeControl(i);
       
   132 
       
   133             control->SetLocationCartesianL(
       
   134                 iUncommited.iLocation[ EComponentX ],
       
   135                 iUncommited.iLocation[ EComponentY ],
       
   136                 iUncommited.iLocation[ EComponentZ ]);
       
   137         }
       
   138 
       
   139         iCommited = iUncommited;
       
   140     }
       
   141 }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CAMMSLocationControlGroup::NotifyPlayerAddedL
       
   145 // Called by when a new player is added
       
   146 // (other items were commented in a header).
       
   147 // -----------------------------------------------------------------------------
       
   148 void CAMMSLocationControlGroup::NotifyPlayerAddedL(
       
   149     CMMAPlayer* aPlayer,
       
   150     CMMAControl* aControl)
       
   151 {
       
   152     CAMMSAudio3DControlGroup::NotifyPlayerAddedL(aPlayer, aControl);
       
   153 
       
   154     CAMMSLocationControl* control =
       
   155         static_cast<CAMMSLocationControl*>(aControl);
       
   156 
       
   157     // set the current parameters
       
   158     control->SetLocationCartesianL(
       
   159         iCommited.iLocation[ EComponentX ],
       
   160         iCommited.iLocation[ EComponentY ],
       
   161         iCommited.iLocation[ EComponentZ ]);
       
   162 }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CAMMSLocationControlGroup::CAMMSLocationControlGroup
       
   166 // C++ default constructor can NOT contain any code, that
       
   167 // might leave.
       
   168 // -----------------------------------------------------------------------------
       
   169 CAMMSLocationControlGroup::CAMMSLocationControlGroup(
       
   170     TAMMSControlTypes aControlType):
       
   171         CAMMSAudio3DControlGroup(KAMMSLocationControl, aControlType)
       
   172 {
       
   173 }
       
   174 
       
   175 //  End of File