|
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: General-purpose mapping functions. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HUIMAPPINGFUNCTIONS_H__ |
|
21 #define __HUIMAPPINGFUNCTIONS_H__ |
|
22 |
|
23 |
|
24 #include <uiacceltk/HuiTimedValue.h> |
|
25 |
|
26 /** |
|
27 * The parameters of each mapping function are declared and |
|
28 * accessed as public for convenience. To preserve binary |
|
29 * compatiblity, avoid making changes to these classes. |
|
30 */ |
|
31 |
|
32 /** |
|
33 * Constant value mapping function. |
|
34 * |
|
35 * Does not implement change flags, which means that if iValue is changed |
|
36 * while the mapping function is in use, timed values will not notify the |
|
37 * change. |
|
38 */ |
|
39 class THuiConstantMappingFunction : public MHuiMappingFunction |
|
40 { |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Constructor. |
|
45 */ |
|
46 IMPORT_C THuiConstantMappingFunction(TReal32 aValue = 0.0) __SOFTFP; |
|
47 |
|
48 /* implements MHuiMappingFunction */ |
|
49 IMPORT_C TReal32 MapValue(TReal32 aValue, TInt aComponent) const __SOFTFP; |
|
50 |
|
51 |
|
52 public: |
|
53 |
|
54 /* Parameters. */ |
|
55 |
|
56 TReal32 iValue; |
|
57 |
|
58 }; |
|
59 |
|
60 |
|
61 /** |
|
62 * Linear mapping function. |
|
63 * |
|
64 * Does not implement change flags, which means that if iFactor or iOffset |
|
65 * is changed while the mapping function is in use, timed values will |
|
66 * not notify the change. |
|
67 */ |
|
68 class THuiLinearMappingFunction : public MHuiMappingFunction |
|
69 { |
|
70 public: |
|
71 |
|
72 /** |
|
73 * Constructor. |
|
74 */ |
|
75 IMPORT_C THuiLinearMappingFunction(TReal32 aFactor = 1.0, TReal32 aOffset = 0.0) __SOFTFP; |
|
76 |
|
77 /* implements MHuiMappingFunction */ |
|
78 IMPORT_C TReal32 MapValue(TReal32 aValue, TInt aComponent) const __SOFTFP; |
|
79 |
|
80 |
|
81 public: |
|
82 |
|
83 /* Parameters. */ |
|
84 |
|
85 /** Multiply by a factor. */ |
|
86 TReal32 iFactor; |
|
87 |
|
88 /** Apply offset after multiplication. */ |
|
89 TReal32 iOffset; |
|
90 |
|
91 }; |
|
92 |
|
93 |
|
94 /** |
|
95 * Sine mapping function. |
|
96 * |
|
97 * Does not implement change flags, which means that if iFactor or iOffset |
|
98 * is changed while the mapping function is in use, timed values will |
|
99 * not notify the change. |
|
100 */ |
|
101 class THuiSineMappingFunction : public MHuiMappingFunction |
|
102 { |
|
103 public: |
|
104 |
|
105 /** |
|
106 * Constructor. |
|
107 */ |
|
108 IMPORT_C THuiSineMappingFunction(TReal32 aFactor = 1.0, TReal32 aOffset = 0.0) __SOFTFP; |
|
109 |
|
110 /* implements MHuiMappingFunction */ |
|
111 IMPORT_C TReal32 MapValue(TReal32 aValue, TInt aComponent) const __SOFTFP; |
|
112 |
|
113 |
|
114 public: |
|
115 |
|
116 /* Parameters. */ |
|
117 |
|
118 TReal32 iFactor; |
|
119 |
|
120 TReal32 iOffset; |
|
121 |
|
122 }; |
|
123 |
|
124 |
|
125 /** |
|
126 * Cosine mapping function. |
|
127 * |
|
128 * Does not implement change flags, which means that if iFactor or iOffset |
|
129 * is changed while the mapping function is in use, timed values will |
|
130 * not notify the change. |
|
131 */ |
|
132 class THuiCosineMappingFunction : public MHuiMappingFunction |
|
133 { |
|
134 public: |
|
135 |
|
136 /** |
|
137 * Constructor. |
|
138 */ |
|
139 IMPORT_C THuiCosineMappingFunction(TReal32 aFactor = 1.0, TReal32 aOffset = 0.0) __SOFTFP; |
|
140 |
|
141 /* implements MHuiMappingFunction */ |
|
142 IMPORT_C TReal32 MapValue(TReal32 aValue, TInt aComponent) const __SOFTFP; |
|
143 |
|
144 |
|
145 public: |
|
146 |
|
147 /* Parameters. */ |
|
148 |
|
149 TReal32 iFactor; |
|
150 |
|
151 TReal32 iOffset; |
|
152 |
|
153 }; |
|
154 |
|
155 |
|
156 /** |
|
157 * Weighted average function between two other mapping functions. |
|
158 * By default calculates the average of the two functions. |
|
159 */ |
|
160 class THuiAverageMappingFunction : public MHuiMappingFunction |
|
161 { |
|
162 public: |
|
163 |
|
164 /** |
|
165 * Constructor. |
|
166 * |
|
167 * @param aFunc1 Function 1. |
|
168 * @param aFunc2 Function 2. |
|
169 */ |
|
170 IMPORT_C THuiAverageMappingFunction(MHuiMappingFunction* aFunc1 = 0, MHuiMappingFunction* aFunc2 = 0); |
|
171 |
|
172 |
|
173 /* Implements MHuiMappingFunction. */ |
|
174 |
|
175 IMPORT_C TReal32 MapValue(TReal32 aValue, TInt aComponent) const __SOFTFP; |
|
176 |
|
177 IMPORT_C TBool MappingFunctionChanged() const; |
|
178 |
|
179 IMPORT_C void MappingFunctionClearChanged(); |
|
180 |
|
181 |
|
182 public: |
|
183 |
|
184 /* Parameters. */ |
|
185 |
|
186 /** First mapping function to average with. */ |
|
187 MHuiMappingFunction* iFunc1; |
|
188 |
|
189 /** Second mapping function to average with. */ |
|
190 MHuiMappingFunction* iFunc2; |
|
191 |
|
192 /** Defaults to 0.5. Applied to the sum of the functions 1 and 2. */ |
|
193 THuiTimedValue iFactor; |
|
194 |
|
195 /** Weight. 0.0 means function 2 does not contribute to the result, 1.0 |
|
196 means that function 1 does not contribute to the result. The default |
|
197 is 0.5, which means both functions contribute equally. */ |
|
198 THuiTimedValue iWeight; |
|
199 |
|
200 }; |
|
201 |
|
202 |
|
203 #endif |