|
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: Sub-session for transformation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "alftransformationsubsession.h" |
|
21 #include "alf/alfconstants.h" |
|
22 #include "alflogger.h" |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // Opens subsession |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 TInt RAlfTransformationSubSession::Open( RAlfClient& aSession ) |
|
31 { |
|
32 TAlfImplementationInformation info(EAlfTransformationSubSessionOpen); |
|
33 TPckgC<TAlfImplementationInformation> infoBuf(info); |
|
34 |
|
35 |
|
36 return CreateSubSession( |
|
37 aSession, |
|
38 EAlfCreateSubSession, |
|
39 TIpcArgs(&infoBuf) ); |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // Closes subsession |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 void RAlfTransformationSubSession::Close() |
|
47 { |
|
48 CloseSubSession( EAlfCloseSubSession ); |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // Loads identity matrix i.e. resets. |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 void RAlfTransformationSubSession::LoadIdentity() |
|
56 { |
|
57 Send/*Receive*/( |
|
58 EAlfDoSubSessionCmd, |
|
59 TIpcArgs( EAlfTransformationLoadIdentity ) ); |
|
60 __ALFLOGSTRING( "RAlfTransformationSubSession::LoadIdentity sent" ) |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // 2D translate. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void RAlfTransformationSubSession::Translate( |
|
68 TReal32 aX, |
|
69 TReal32 aY ) |
|
70 { |
|
71 TPckg<TReal32> xRealPckg(aX); |
|
72 TPckg<TReal32> yRealPckg(aY); |
|
73 TInt err = SendReceive( |
|
74 EAlfDoSubSessionCmd, |
|
75 TIpcArgs( EAlfTransformationTranslate, &xRealPckg, &yRealPckg ) ); |
|
76 |
|
77 if ( err ) |
|
78 { |
|
79 __ALFLOGSTRING1( "RAlfTransformationSubSession::Translate ignore error %d", err ) |
|
80 } |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // 2D rotation. |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void RAlfTransformationSubSession::Rotate( const TAlfTimedValue& aAngle ) |
|
88 { |
|
89 TPckgC<TAlfTimedValue> anglePckg(aAngle); |
|
90 TInt err = SendReceive( |
|
91 EAlfDoSubSessionCmd, |
|
92 TIpcArgs(EAlfTransformationRotate, &anglePckg ) ); |
|
93 if ( err ) |
|
94 { |
|
95 __ALFLOGSTRING1( "RAlfTransformationSubSession::Rotate ignore error %d", err ) |
|
96 } |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 TInt RAlfTransformationSubSession::Count() const |
|
104 { |
|
105 TInt retVal = 0; |
|
106 TPckg<TInt> retValPckg(retVal); |
|
107 TInt err = SendReceive( |
|
108 EAlfDoSubSessionCmd, |
|
109 TIpcArgs(EAlfTransformationCount, &retValPckg ) ); |
|
110 if ( err ) |
|
111 { |
|
112 __ALFLOGSTRING1( "RAlfTransformationSubSession::Count ignore error %d", err ) |
|
113 } |
|
114 return retVal; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 TInt RAlfTransformationSubSession::NonIdentityCount() const |
|
122 { |
|
123 TInt retVal = 0; |
|
124 TPckg<TInt> retValPckg(retVal); |
|
125 TInt err = SendReceive( |
|
126 EAlfDoSubSessionCmd, |
|
127 TIpcArgs(EAlfTransformationNonIdentityCount, &retValPckg ) ); |
|
128 if ( err ) |
|
129 { |
|
130 __ALFLOGSTRING1( "RAlfTransformationSubSession::NonIdentityCount ignore error %d", err ) |
|
131 } |
|
132 return retVal; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 CAlfTransformation::TTransform RAlfTransformationSubSession::Step(TInt aIndex) |
|
140 { |
|
141 CAlfTransformation::TTransform retVal; |
|
142 TPckg<CAlfTransformation::TTransform> retValPckg(retVal); |
|
143 TInt err = SendReceive( |
|
144 EAlfDoSubSessionCmd, |
|
145 TIpcArgs(EAlfTransformationStep, aIndex, &retValPckg) ); |
|
146 if ( err ) |
|
147 { |
|
148 __ALFLOGSTRING1( "RAlfTransformationSubSession::Step ignore error %d", err ) |
|
149 } |
|
150 return retVal; |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void RAlfTransformationSubSession::ReplaceStep(TInt aIndex, |
|
158 CAlfTransformation::TTransform aTransformationStep) |
|
159 { |
|
160 TPckg<CAlfTransformation::TTransform> inputValPckg(aTransformationStep); |
|
161 TInt err = SendReceive( |
|
162 EAlfDoSubSessionCmd, |
|
163 TIpcArgs(EAlfTransformationReplaceStep, aIndex, &inputValPckg ) ); |
|
164 if ( err ) |
|
165 { |
|
166 __ALFLOGSTRING1( "RAlfTransformationSubSession::ReplaceStep ignore error %d", err ) |
|
167 } |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void RAlfTransformationSubSession::Rotate(const TAlfTimedValue& aAngle, |
|
175 TReal32 aAxisX, TReal32 aAxisY, TReal32 aAxisZ) |
|
176 { |
|
177 TAlfTransformationRotateParams params; |
|
178 params.iAngle = aAngle; |
|
179 params.iAxisX = aAxisX; |
|
180 params.iAxisY = aAxisY; |
|
181 params.iAxisZ = aAxisZ; |
|
182 |
|
183 TPckg<TAlfTransformationRotateParams> inputValPckg(params); |
|
184 TInt err = SendReceive( |
|
185 EAlfDoSubSessionCmd, |
|
186 TIpcArgs(EAlfTransformationRotate3D, &inputValPckg ) ); |
|
187 if ( err ) |
|
188 { |
|
189 __ALFLOGSTRING1( "RAlfTransformationSubSession::Rotate ignore error %d", err ) |
|
190 } |
|
191 |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 void RAlfTransformationSubSession::Translate(const TAlfTimedValue& aX, |
|
199 const TAlfTimedValue& aY) |
|
200 { |
|
201 TAlfTransformationTimedParams params; |
|
202 params.iX = aX; |
|
203 params.iY = aY; |
|
204 |
|
205 TPckg<TAlfTransformationTimedParams> inputValPckg(params); |
|
206 TInt err = SendReceive( |
|
207 EAlfDoSubSessionCmd, |
|
208 TIpcArgs(EAlfTransformationTranslate2D, &inputValPckg ) ); |
|
209 if ( err ) |
|
210 { |
|
211 __ALFLOGSTRING1( "RAlfTransformationSubSession::Translate ignore error %d", err ) |
|
212 } |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 void RAlfTransformationSubSession::Scale(const TAlfTimedValue& aX, |
|
220 const TAlfTimedValue& aY, const TAlfTimedValue& aZ) |
|
221 { |
|
222 TAlfTransformationTimedParams params; |
|
223 params.iX = aX; |
|
224 params.iY = aY; |
|
225 params.iZ = aZ; |
|
226 |
|
227 TPckg<TAlfTransformationTimedParams> inputValPckg(params); |
|
228 TInt err = SendReceive( |
|
229 EAlfDoSubSessionCmd, |
|
230 TIpcArgs(EAlfTransformationScale, &inputValPckg ) ); |
|
231 if ( err ) |
|
232 { |
|
233 __ALFLOGSTRING1( "RAlfTransformationSubSession::Scale ignore error %d", err ) |
|
234 } |
|
235 |
|
236 } |