|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <ecam.h> |
|
19 #include <ecamadvsettings.h> |
|
20 #include <ecamimageprocessing.h> |
|
21 #include <ecam/ecamconstants.h> |
|
22 |
|
23 #include <QString> |
|
24 #include <QVariant> |
|
25 |
|
26 #include "cxutils.h" |
|
27 #include "cxenamespace.h" |
|
28 #include "cxecameradevice.h" |
|
29 #include "cxesettings.h" |
|
30 #include "cxesettingsmappersymbian.h" |
|
31 #include "cxesettingscontrolsymbian.h" |
|
32 |
|
33 /*! |
|
34 * Constructor |
|
35 */ |
|
36 CxeSettingsControlSymbian::CxeSettingsControlSymbian(CxeCameraDevice &cameraDevice, CxeSettings &settings) |
|
37 : mCameraDevice(cameraDevice), |
|
38 mSettings(settings) |
|
39 { |
|
40 // connect scene / setting change callbacks to settings control |
|
41 connect(&mSettings, |
|
42 SIGNAL(settingValueChanged(const QString&,QVariant)), |
|
43 this, |
|
44 SLOT(handleSettingValueChanged(const QString&,QVariant))); |
|
45 |
|
46 connect(&mSettings, |
|
47 SIGNAL(sceneChanged(CxeScene&)), |
|
48 this, |
|
49 SLOT(handleSceneChanged(CxeScene&))); |
|
50 } |
|
51 |
|
52 /*! |
|
53 * Destructor |
|
54 */ |
|
55 CxeSettingsControlSymbian::~CxeSettingsControlSymbian() |
|
56 { |
|
57 } |
|
58 |
|
59 /*! |
|
60 * Handle new setting value. |
|
61 * New value is set to camera. |
|
62 */ |
|
63 void CxeSettingsControlSymbian::handleSettingValueChanged(const QString& settingId, QVariant newValue) |
|
64 { |
|
65 CX_DEBUG_ENTER_FUNCTION(); |
|
66 if (settingId == CxeSettingIds::COLOR_TONE) { |
|
67 updateColorToneSetting(newValue); |
|
68 } else if (settingId == CxeSettingIds::WHITE_BALANCE) { |
|
69 updateWhiteBalanceSetting(newValue); |
|
70 } else if (settingId == CxeSettingIds::LIGHT_SENSITIVITY) { |
|
71 updateLightSensitivitySetting(newValue); |
|
72 } else if (settingId == CxeSettingIds::SHARPNESS) { |
|
73 updateSharpnessSetting(newValue); |
|
74 } else if (settingId == CxeSettingIds::CONTRAST) { |
|
75 updateContrastSetting(newValue); |
|
76 } else if (settingId == CxeSettingIds::EXPOSURE_MODE) { |
|
77 updateExposureModeSetting(newValue); |
|
78 } else if (settingId == CxeSettingIds::EV_COMPENSATION_VALUE) { |
|
79 updateExposureCompensationSetting(newValue); |
|
80 } else { |
|
81 // do nothing |
|
82 } |
|
83 |
|
84 // Image mode specific |
|
85 if (settingId == CxeSettingIds::FLASH_MODE) { |
|
86 updateFlashSetting(newValue); |
|
87 } |
|
88 CX_DEBUG_EXIT_FUNCTION(); |
|
89 } |
|
90 |
|
91 /*! |
|
92 * Handle new scene being set. |
|
93 * Scene settings are checked and new values are set to camera. |
|
94 * @param scene New scene containing scene specific settings. |
|
95 */ |
|
96 void CxeSettingsControlSymbian::handleSceneChanged(CxeScene& scene) |
|
97 { |
|
98 CX_DEBUG_ENTER_FUNCTION(); |
|
99 CX_DEBUG(("CxeSettingsControlSymbian <> new scene [%s]", |
|
100 scene[CxeSettingIds::SCENE_ID].value<QString>().toAscii().constData())); |
|
101 |
|
102 foreach (const QString& settingId, scene.keys()) { |
|
103 handleSettingValueChanged(settingId, scene[settingId]); |
|
104 } |
|
105 CX_DEBUG_EXIT_FUNCTION(); |
|
106 } |
|
107 |
|
108 |
|
109 /*! |
|
110 * |
|
111 */ |
|
112 void CxeSettingsControlSymbian::updateColorToneSetting(QVariant newValue) |
|
113 { |
|
114 CX_DEBUG_ENTER_FUNCTION(); |
|
115 |
|
116 //! @todo: Should be fixed in Dummy engine |
|
117 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
|
118 |
|
119 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
|
120 |
|
121 CCamera::CCameraImageProcessing::TEffect effect = |
|
122 CxeSettingsMapperSymbian::Map2CameraEffect(newValue.toInt()); |
|
123 |
|
124 if (effect != mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingEffect)) { |
|
125 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingEffect, effect); |
|
126 } else { |
|
127 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
128 } |
|
129 #else |
|
130 Q_UNUSED(newValue) |
|
131 #endif |
|
132 |
|
133 CX_DEBUG_EXIT_FUNCTION(); |
|
134 } |
|
135 |
|
136 /*! |
|
137 * |
|
138 */ |
|
139 void CxeSettingsControlSymbian::updateWhiteBalanceSetting(QVariant newValue) |
|
140 { |
|
141 CX_DEBUG_ENTER_FUNCTION(); |
|
142 CX_DEBUG_ASSERT(mCameraDevice.camera()); |
|
143 |
|
144 CCamera::TWhiteBalance wb = CxeSettingsMapperSymbian::Map2CameraWb(newValue.toInt()); |
|
145 |
|
146 if (wb != mCameraDevice.camera()->WhiteBalance()) { |
|
147 TRAP_IGNORE( mCameraDevice.camera()->SetWhiteBalanceL(wb) ); |
|
148 } else { |
|
149 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
150 } |
|
151 |
|
152 CX_DEBUG_EXIT_FUNCTION(); |
|
153 } |
|
154 |
|
155 /*! |
|
156 * |
|
157 */ |
|
158 void CxeSettingsControlSymbian::updateLightSensitivitySetting(QVariant newValue) |
|
159 { |
|
160 CX_DEBUG_ENTER_FUNCTION(); |
|
161 CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings()); |
|
162 |
|
163 int iso = newValue.toInt(); |
|
164 |
|
165 if (iso != mCameraDevice.advancedSettings()->IsoRate()) { |
|
166 CCamera::CCameraAdvancedSettings::TISORateType type; |
|
167 if(iso == 0) { |
|
168 // Automatic ISO rate |
|
169 type = CCamera::CCameraAdvancedSettings::EISOAutoUnPrioritised; |
|
170 } else { |
|
171 // Manual ISO rate |
|
172 type = CCamera::CCameraAdvancedSettings::EISOManual; |
|
173 } |
|
174 TRAP_IGNORE(mCameraDevice.advancedSettings()->SetISORateL(type, iso)); |
|
175 } |
|
176 |
|
177 CX_DEBUG_EXIT_FUNCTION(); |
|
178 } |
|
179 |
|
180 /*! |
|
181 * |
|
182 */ |
|
183 void CxeSettingsControlSymbian::updateSharpnessSetting(QVariant newValue) |
|
184 { |
|
185 CX_DEBUG_ENTER_FUNCTION(); |
|
186 |
|
187 //! @todo: Should be fixed in Dummy engine |
|
188 #if !defined(__WINSCW__) && !defined(CXE_USE_DUMMY_CAMERA) |
|
189 |
|
190 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
|
191 |
|
192 // Scale UI values of -10..10 to ECAM range -100..100. |
|
193 int currentSharpness = mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingAdjustSharpness); |
|
194 int newSharpness = newValue.toInt()*10; |
|
195 |
|
196 CX_DEBUG(("Current sharpness [uid:0x%08x] value is [%d]", KUidECamEventImageProcessingAdjustSharpness, currentSharpness)); |
|
197 CX_DEBUG(("Setting sharpness [uid:0x%08x] to value [%d]", KUidECamEventImageProcessingAdjustSharpness, newSharpness)); |
|
198 if (newSharpness != currentSharpness) { |
|
199 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingAdjustSharpness, newSharpness); |
|
200 } else { |
|
201 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
202 } |
|
203 #else |
|
204 Q_UNUSED(newValue) |
|
205 #endif |
|
206 |
|
207 CX_DEBUG_EXIT_FUNCTION(); |
|
208 } |
|
209 |
|
210 /*! |
|
211 * |
|
212 */ |
|
213 void CxeSettingsControlSymbian::updateContrastSetting(QVariant newValue) |
|
214 { |
|
215 CX_DEBUG_ENTER_FUNCTION(); |
|
216 CX_ASSERT_ALWAYS(mCameraDevice.imageProcessor()); |
|
217 |
|
218 // Scale UI values of -10..10 to ECAM range -100..100. |
|
219 int currentContrast = mCameraDevice.imageProcessor()->TransformationValue(KUidECamEventImageProcessingAdjustContrast); |
|
220 int newContrast = newValue.toInt()*10; |
|
221 |
|
222 CX_DEBUG(("Current contrast [uid:0x%08x] value is [%d]", KUidECamEventImageProcessingAdjustContrast, currentContrast)); |
|
223 CX_DEBUG(("Setting contrast [uid:0x%08x] to value [%d]", KUidECamEventImageProcessingAdjustContrast, newContrast)); |
|
224 if (newContrast != currentContrast) { |
|
225 mCameraDevice.imageProcessor()->SetTransformationValue(KUidECamEventImageProcessingAdjustContrast, newContrast); |
|
226 } else { |
|
227 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
228 } |
|
229 |
|
230 CX_DEBUG_EXIT_FUNCTION(); |
|
231 } |
|
232 |
|
233 /*! |
|
234 * |
|
235 */ |
|
236 void CxeSettingsControlSymbian::updateExposureModeSetting(QVariant newValue) |
|
237 { |
|
238 CX_DEBUG_ENTER_FUNCTION(); |
|
239 CX_DEBUG_ASSERT(mCameraDevice.advancedSettings()); |
|
240 |
|
241 CCamera::TExposure exposure = CxeSettingsMapperSymbian::Map2CameraExposureMode(newValue.toInt()); |
|
242 |
|
243 if(exposure != mCameraDevice.advancedSettings()->ExposureMode()) { |
|
244 mCameraDevice.advancedSettings()->SetExposureMode(exposure); |
|
245 } else { |
|
246 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
247 } |
|
248 |
|
249 CX_DEBUG_EXIT_FUNCTION(); |
|
250 } |
|
251 |
|
252 /*! |
|
253 * |
|
254 */ |
|
255 void CxeSettingsControlSymbian::updateExposureCompensationSetting(QVariant newValue) |
|
256 { |
|
257 CX_DEBUG_ENTER_FUNCTION(); |
|
258 CX_ASSERT_ALWAYS(mCameraDevice.advancedSettings()); |
|
259 |
|
260 // Exposure compensation is a float value, e.g. "-1.5". |
|
261 // ECAM interface takes integer values, so KECamFineResolutionFactor from |
|
262 // ecamconstants.h needs to be used as scaler. |
|
263 int ev = newValue.toReal()*KECamFineResolutionFactor; |
|
264 |
|
265 if (ev != mCameraDevice.advancedSettings()->ExposureCompensationStep()) { |
|
266 mCameraDevice.advancedSettings()->SetExposureCompensationStep(ev); |
|
267 } else { |
|
268 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
269 } |
|
270 |
|
271 CX_DEBUG_EXIT_FUNCTION(); |
|
272 } |
|
273 |
|
274 /*! |
|
275 * |
|
276 */ |
|
277 void CxeSettingsControlSymbian::updateFlashSetting(QVariant newValue) |
|
278 { |
|
279 CX_DEBUG_ENTER_FUNCTION(); |
|
280 CX_ASSERT_ALWAYS(mCameraDevice.camera()); |
|
281 |
|
282 CCamera::TFlash flash = CxeSettingsMapperSymbian::Map2CameraFlash(newValue.toInt()); |
|
283 |
|
284 if (flash != mCameraDevice.camera()->Flash()) { |
|
285 TRAP_IGNORE(mCameraDevice.camera()->SetFlashL(flash)); |
|
286 } else { |
|
287 CX_DEBUG(("CxeSettingsControlSymbian: value up-to-date")); |
|
288 } |
|
289 |
|
290 CX_DEBUG_EXIT_FUNCTION(); |
|
291 } |
|
292 |
|
293 // end of file |