Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / parser / FUiEffects_ParserEffectParser.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #include <algorithm>
19 #include <string.h>
20 #include <fstream>
21 #include <cctype>
22
23 #include <FBaseSysLog.h>
24 #include <FUiEffects_ParserEffectParser.h>
25 #include "../FUiEffects_EffectErrorMessages.h"
26
27 #include <FUiEffects_RuntimePointLight.h>
28 #include <FUiEffects_RuntimeSpotLight.h>
29 #include <FUiEffects_RuntimeDirectionalLight.h>
30 #include <FUiEffects_RendererEffectRenderer.h>
31
32 using namespace Tizen::Ui::Effects::_Runtime;
33 using namespace Tizen::Ui::Effects::_PhysicsEngine;
34 using namespace Tizen::Ui::Effects::_Renderer;
35 using namespace Tizen::Ui::Effects::_Utils;
36
37 namespace Tizen { namespace Ui { namespace Effects { namespace _Parser
38 {
39
40 EffectParser* EffectParser::__pInstance = null;
41
42 const std::string EffectParser::__MANIFEST_FILE_NAME = "manifest.xml";
43 const std::string EffectParser::__SCENE_FILE_NAME = "scene.xml";
44 const std::string EffectParser::__SCRIPT_FILE_NAME = "script.lua";
45
46 namespace
47 {
48 bool
49 FileExists(const char* pPath)
50 {
51         bool result = true;
52         std::fstream file;
53
54         file.open(pPath, std::fstream::in);
55
56         if (file.is_open())
57         {
58                 file.close();
59         }
60         else
61         {
62                 result = false;
63         }
64
65         return result;
66 }
67 } // namespace
68
69 Vec3f EffectParser::StringHexToRgb(const std::string& stringColor)
70 {
71         Vec3f rgbColor;
72         unsigned long int bytes = strtoul(stringColor.c_str(), null, 16);
73
74         unsigned char nextByte = bytes;
75         rgbColor.z = nextByte / float (UCHAR_MAX);
76         bytes = bytes >> CHAR_BIT;
77         nextByte = bytes;
78         rgbColor.y = nextByte / float (UCHAR_MAX);
79         bytes = bytes >> CHAR_BIT;
80         nextByte = bytes;
81         rgbColor.x = nextByte / float (UCHAR_MAX);
82
83         return rgbColor;
84 }
85
86 EffectParser::SceneData::SceneData()
87         : timerTimeout(0u)
88         , ambientColor(Vec3f(1.0f, 1.0f, 1.0f))
89         , intensity(1.0f)
90         , attenuation(0.f)
91 {
92 }
93
94 EffectParser::ViewportData::ViewportData()
95         : x(0.f)
96         , y(0.f)
97         , z(0.f)
98         , width(0.f)
99         , height(0.f)
100         , near(0.f)
101         , far(0.f)
102         , angle(0.f)
103         , perspective(false)
104 {
105 }
106
107 EffectParser::EffectParser(void)
108         : __pXmlParser(null)
109         , __currentModelFilesDirectoryPath("")
110         , __elementBuffer(0)
111         , __pointSurfaceNurbsIndices()
112         , __elementSurfaceBuffer(0)
113         , __unitLightBuffer(0)
114         , __pCurrentGraphicalSurface(null)
115         , __currentGravityForce(0, 0, 0)
116         , __currentGravityForceValue(0.f)
117         , __modelSurfaceBuffer(0)
118         , __lastSceneXMLElementIndex(0)
119         , __lastModelSurfaceXMLElementIndex(0)
120         , __lastGraphicalSurfaceXMLElementIndex(0)
121         , __pCurrentEffectModel(null)
122         , __pCurrentEffectManager(null)
123         , __currentEffectId(0l)
124         , __currentModelBehaviourType(EFFECT_TYPE_TIME_BASED)
125         , __currentEffectDuration(0.f)
126         , __currentEffectInstanceName("")
127         , __currentModelSurfaceX(0.f)
128         , __currentModelSurfaceY(0.f)
129         , __currentGraphicalSurfaceDimCtrlX(0u)
130         , __currentGraphicalSurfaceDimCtrlY(0u)
131         , __insideGraphicalSurface(false)
132         , __rightAfterSceneStart(false)
133         , __rightAfterModelSurfaceStart(false)
134         , __rightAfterGraphicalSurfaceStart(false)
135         , __insideVectorX(false)
136         , __insideVectorY(false)
137         , __buildingModelFailed(false)
138         , __insideElementsPool(false)
139 {
140         __pXmlParser = std::unique_ptr<XmlParser>(new (std::nothrow) XmlParser(this));
141
142         SysTryReturnVoidResult(NID_UI_EFFECT,
143                         __pXmlParser.get() != null,
144                         E_OUT_OF_MEMORY,
145                         _UiEffectError::OUT_OF_MEMORY
146                         );
147 }
148
149 EffectParser::~EffectParser(void)
150 {
151         __pInstance = null;
152 }
153
154 bool
155 EffectParser::ExtractModelFiles(const char* pPath)
156 {
157         bool result = true;
158
159         if (!XmlParser::ExtractFromArchive(pPath, __currentModelFilesDirectoryPath.c_str()))
160         {
161                 SysLogException(NID_UI_EFFECT, result = false, "Effects. Unzipping of \"%s\" failed!", pPath);
162         }
163
164         if (result)
165         {
166                 std::string sceneFilePath = __currentModelFilesDirectoryPath + __SCENE_FILE_NAME;
167                 std::string manifestFilePath = __currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME;
168                 std::string scriptFilePath = __currentModelFilesDirectoryPath + __SCRIPT_FILE_NAME;
169
170                 if ( !FileExists(sceneFilePath.c_str()) ||
171                          !FileExists(manifestFilePath.c_str()) ||
172                          !FileExists(scriptFilePath.c_str()))
173                 {
174                         SysLogException(NID_UI_EFFECT, result = false, "Effects. Effect file is incomplete!", pPath);
175                 }
176         }
177
178         return result;
179 }
180
181 bool
182 EffectParser::ParseEffectFile(const char* pEffectFilePath, const char* pModelFilesDirectoryPath)
183 {
184         bool result = true;
185         std::string sceneFilePath;
186         std::string manifestFilePath;
187
188         if (__pInstance == null)
189         {
190                 __pInstance = new (std::nothrow) EffectParser();
191         }
192
193         SysTryCatchLabel(NID_UI_EFFECT, __pInstance != null, result = false, CATCH1, E_OUT_OF_MEMORY, Tizen::Ui::Effects::_UiEffectError::OUT_OF_MEMORY);
194
195         SysTryCatchLabel(NID_UI_EFFECT, __pInstance->__pXmlParser != null, result = false, CATCH1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
196
197         __pInstance->__currentModelFilesDirectoryPath = pModelFilesDirectoryPath;
198
199         sceneFilePath = __pInstance->__currentModelFilesDirectoryPath + __SCENE_FILE_NAME;
200         manifestFilePath = __pInstance->__currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME;
201
202         __pInstance->__buildingModelFailed = false;
203
204         SysTryCatchLabel(NID_UI_EFFECT, __pInstance->ExtractModelFiles(pEffectFilePath), result = false;
205                                         __pInstance->ClearModelFiles(); , CATCH2, E_OPERATION_FAILED, Tizen::Ui::Effects::_UiEffectError::EP_EXTRACTING_MODEL_FILES_FAILED);
206
207         result = __pInstance->__pXmlParser->Parse(manifestFilePath.c_str(), false) && __pInstance->__pXmlParser->Parse(sceneFilePath.c_str(), false);
208
209         __pInstance->ClearModelFiles(); // should always go before calling _clearBuffers()
210         __pInstance->ClearBuffers();    // not necessary unless XMLParser was sending callbacks by mistake
211
212         if (result)
213         {
214                 SysLog(NID_UI_EFFECT, "Effects. XML-parsing of the XML-files was successful");
215         }
216         else
217         {
218                 SysLog(NID_UI_EFFECT, "Effects. XML-parsing of one of the XML-files failed");
219         }
220
221         delete __pInstance;
222         __pInstance = null;
223
224         return result;
225
226 CATCH2:
227         __pInstance->ClearModelFiles();
228 CATCH1:
229         delete __pInstance;
230         __pInstance = null;
231
232         return result;
233 }
234
235 result
236 EffectParser::ParseEffectFileLoadModel(const char* pEffectFilePath, const char* pModelFilesDirectoryPath,
237                                                                                 IEffectModelListener* effectsManager, long effectModelID,
238                                                                                 IEffectModelManager*& pEffectModel, EffectRenderer*& pEffectRenderer, int& modelTimerTimeout)
239 {
240         std::unique_ptr<IEffectModelManager> pEffectModelTemp;
241         EffectRendererUniquePtr pRenderer;
242         std::string sceneFilePath;
243         std::string manifestFilePath;
244         result res = E_SUCCESS;
245
246         if (__pInstance == null)
247         {
248                 __pInstance = new (std::nothrow) EffectParser();
249         }
250
251         SysTryReturn(NID_UI_EFFECT, __pInstance != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, Tizen::Ui::Effects::_UiEffectError::OUT_OF_MEMORY);
252
253         SysTryCatchLabel(NID_UI_EFFECT, __pInstance->__pXmlParser != null, , CATCH1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
254
255         __pInstance->__currentModelFilesDirectoryPath = pModelFilesDirectoryPath;
256
257         sceneFilePath = __pInstance->__currentModelFilesDirectoryPath + __SCENE_FILE_NAME;
258         manifestFilePath = __pInstance->__currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME;
259
260         __pInstance->__buildingModelFailed = false;
261
262         SysTryCatchLabel(NID_UI_EFFECT, __pInstance->ExtractModelFiles(pEffectFilePath), , CATCH2, E_OPERATION_FAILED,
263                                                 Tizen::Ui::Effects::_UiEffectError::EP_EXTRACTING_MODEL_FILES_FAILED);
264
265         __pInstance->__lastSceneXMLElementIndex = -1;
266         __pInstance->__lastModelSurfaceXMLElementIndex = -1;
267         __pInstance->__lastGraphicalSurfaceXMLElementIndex = -1;
268         __pInstance->__pCurrentEffectModel = null;
269         __pInstance->__pCurrentGraphicalSurface = null;
270         __pInstance->__pCurrentVectorXBuffer.reset();
271         __pInstance->__pCurrentVectorYBuffer.reset();
272         __pInstance->__insideGraphicalSurface = false;
273         __pInstance->__rightAfterSceneStart = false;
274         __pInstance->__rightAfterModelSurfaceStart = false;
275         __pInstance->__rightAfterGraphicalSurfaceStart = false;
276         __pInstance->__insideVectorX = false;
277         __pInstance->__insideVectorY = false;
278         __pInstance->__insideElementsPool = false;
279         __pInstance->__pCurrentEffectManager = effectsManager;
280         __pInstance->__currentEffectId = effectModelID;
281         __pInstance->__currentModelBehaviourType = EFFECT_TYPE_TIME_BASED;
282         __pInstance->__currentEffectDuration = 0.0f;
283         __pInstance->__currentEffectInstanceName = "";
284         __pInstance->__currentSceneData.timerTimeout = 30;
285         __pInstance->__currentSceneData.ambientColor = Vec3f(0.0f, 0.0f, 0.0f);
286         __pInstance->__currentSceneData.intensity = 1.0f;
287         __pInstance->__currentSceneData.attenuation = 0.0f;
288         __pInstance->__currentViewportData.x = 0.0f;
289         __pInstance->__currentViewportData.y = 0.0f;
290         __pInstance->__currentViewportData.z = 0.0f;
291         __pInstance->__currentViewportData.width = 0.0f;
292         __pInstance->__currentViewportData.height = 0.0f;
293         __pInstance->__currentViewportData.near = 0.0f;
294         __pInstance->__currentViewportData.far = 0.0f;
295         __pInstance->__currentViewportData.angle = 0.0f;
296         __pInstance->__currentViewportData.perspective = false;
297         __pInstance->__currentModelSurfaceX = 0.0f;
298         __pInstance->__currentModelSurfaceY = 0.0f;
299         __pInstance->__currentGraphicalSurfaceDimCtrlX = 0;
300         __pInstance->__currentGraphicalSurfaceDimCtrlY = 0;
301         __pInstance->__currentGravityForceValue = 0.0f;
302
303         SysTryCatchLabel(NID_UI_EFFECT, __pInstance->__pXmlParser->Parse(manifestFilePath.c_str(), true) && __pInstance->__pXmlParser->Parse(sceneFilePath.c_str(), true),
304                                 __pInstance->__buildingModelFailed = true, CATCH2, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
305
306         SysTryCatchLabel(NID_UI_EFFECT, !__pInstance->__buildingModelFailed, , CATCH2, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
307
308         pEffectModelTemp = std::move(__pInstance->__pCurrentEffectModel);
309
310         SetLastResult(E_SUCCESS);
311
312         if(EffectRenderer::CheckOpenGlesInitialized())
313         {
314                 SysTryCatchLabel(NID_UI_EFFECT, SETJMP == 0, pEffectModelTemp.reset(); pRenderer.reset(); ,
315                                                 CATCH2, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
316
317                 pRenderer = EffectRendererUniquePtr(new (std::nothrow) EffectRenderer());
318
319                 SysTryCatchLabel(NID_UI_EFFECT, pRenderer != null, pEffectModelTemp.reset();,
320                                                 CATCH2, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
321
322                 res = GetLastResult();
323
324                 SysTryCatchLabel(NID_UI_EFFECT, res == E_SUCCESS || res == E_OPERATION_FAILED, pEffectModelTemp.reset(); pRenderer.reset(); ,
325                                                 CATCH2, res, "[%s] Propagating.", GetErrorMessage(res));
326
327                 if (res == E_OPERATION_FAILED)
328                 {
329                         SysLog(NID_UI_EFFECT, "Renderer has invalid context");
330                         SetLastResult(E_SUCCESS);
331
332                         pRenderer.reset();
333                 }
334                 else
335                 {
336                         pRenderer->SetWorld(
337                                         __pInstance->__currentViewportData.x,
338                                         __pInstance->__currentViewportData.x + __pInstance->__currentViewportData.width,
339                                         __pInstance->__currentViewportData.y,
340                                         __pInstance->__currentViewportData.y + __pInstance->__currentViewportData.height,
341                                         __pInstance->__currentViewportData.z,
342                                         __pInstance->__currentViewportData.near,
343                                         __pInstance->__currentViewportData.far,
344                                         __pInstance->__currentViewportData.angle,
345                                         __pInstance->__currentViewportData.perspective);
346
347                         pRenderer->Construct(*pEffectModelTemp->GetRenderingData());
348
349                         res = GetLastResult();
350                         SysTryCatchLabel(NID_UI_EFFECT, res == E_SUCCESS, pEffectModelTemp.reset(); pRenderer.reset(); ,
351                                                         CATCH2, res, "[%s] Propagating.", GetErrorMessage(res));
352                 }
353         }
354
355         pEffectRenderer = pRenderer.release();
356
357         modelTimerTimeout = __pInstance->__currentSceneData.timerTimeout;
358
359         __pInstance->ClearModelFiles();
360         __pInstance->ClearBuffers();
361         delete __pInstance;
362         __pInstance = null;
363
364         pEffectModel = pEffectModelTemp.release();
365
366         return GetLastResult();
367
368 CATCH2:
369         __pInstance->ClearModelFiles();
370         __pInstance->ClearBuffers();
371 CATCH1:
372         delete __pInstance;
373         __pInstance = null;
374
375         return GetLastResult();
376 }
377
378 void
379 EffectParser::StartElement(const char* pElementName)
380 {
381         if (__buildingModelFailed)
382         {
383                 return;
384         }
385
386         std::string elementNameLowerCase(pElementName);
387
388         XmlElement newElement;
389         newElement.name = elementNameLowerCase;
390         __elementBuffer.push_back(newElement);
391
392         if (__rightAfterSceneStart)
393         {
394                 PriorReadSceneData();
395                 __rightAfterSceneStart = false;
396         }
397
398         if (__rightAfterModelSurfaceStart)
399         {
400                 PriorReadModelSurfaceData();
401                 __rightAfterModelSurfaceStart = false;
402         }
403
404         if (__rightAfterGraphicalSurfaceStart)
405         {
406                 PriorReadGraphicalSurfaceData();
407                 __rightAfterGraphicalSurfaceStart = false;
408         }
409
410         if (elementNameLowerCase == "Scene")
411         {
412                 __rightAfterSceneStart = true;
413                 __lastSceneXMLElementIndex = (int) __elementBuffer.size() - 1;
414
415                 return;
416         }
417
418         if (elementNameLowerCase == "Model")
419         {
420                 __rightAfterModelSurfaceStart = true;
421                 __lastModelSurfaceXMLElementIndex = (int) __elementBuffer.size() - 1;
422
423                 return;
424         }
425
426         if (elementNameLowerCase == "GraphicalSurface")
427         {
428                 __rightAfterGraphicalSurfaceStart = true;
429                 __lastGraphicalSurfaceXMLElementIndex = (int) __elementBuffer.size() - 1;
430                 __insideGraphicalSurface = true;
431
432                 return;
433         }
434
435         if (elementNameLowerCase == "KnotVectorX")
436         {
437                 __insideVectorX = true;
438                 __pCurrentVectorXBuffer = std::unique_ptr<Tizen::Ui::Effects::_Runtime::TypeKnots>(new (std::nothrow) TypeKnots());
439
440                 SysTryCatch(NID_UI_EFFECT, __pCurrentVectorXBuffer != null, , E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
441
442                 return;
443         }
444
445         if (elementNameLowerCase == "KnotVectorY")
446         {
447                 __insideVectorY = true;
448                 __pCurrentVectorYBuffer = std::unique_ptr<Tizen::Ui::Effects::_Runtime::TypeKnots>(new (std::nothrow) TypeKnots());
449
450                 SysTryCatch(NID_UI_EFFECT, __pCurrentVectorYBuffer != null, , E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
451
452                 return;
453         }
454
455         if (elementNameLowerCase == "ElementsPool")
456         {
457                 __insideElementsPool = true;
458
459                 return;
460         }
461
462         return;
463
464 CATCH:
465         __buildingModelFailed = true;
466         return;
467 }
468
469 void
470 EffectParser::EndElement(const char* pElementName)
471 {
472         if (__buildingModelFailed)
473         {
474                 return;
475         }
476
477         std::string elementName(pElementName);
478
479         if (__elementBuffer.size() == 0)
480         {
481                 __buildingModelFailed = true;
482
483                 SysLogException(NID_UI_EFFECT, E_INVALID_STATE, "Effects. [E_INVALID_STATE] Building a model failed: _elementBuffer.size() == 0");
484
485                 return;
486         }
487
488         int lastElementIndex = (int) __elementBuffer.size() - 1;
489
490         if (elementName != __elementBuffer[lastElementIndex].name)
491         {
492                 __buildingModelFailed = true;
493
494                 SysLogException(NID_UI_EFFECT, E_INVALID_ARG, "Effects. [E_INVALID_ARG] Building a model failed: elName != lastElement.name");
495
496                 return;
497         }
498
499         if (elementName == "ElementsPool")
500         {
501                 __insideElementsPool = false;
502                 __elementBuffer.pop_back();
503
504                 return;
505         } // ElementsPool
506
507         if (__insideElementsPool)
508         {
509                 __elementBuffer.pop_back();
510
511                 return;
512         } // _insideElementsPool but not </ElementsPool>
513
514         if (elementName == "Point")
515         {
516                 if (__insideGraphicalSurface) // PointSurfaceNURBS
517                 {
518                         CreatePointSurfaceNurbs(__elementBuffer[lastElementIndex]);
519
520                         __elementBuffer.pop_back();
521
522                         return;
523                 } // PointSurfaceNURBS
524                 else // PointSurface
525                 {
526                         CreatePointSurface(__elementBuffer[lastElementIndex]);
527
528                         __elementBuffer.pop_back();
529
530                         return;
531                 } // PointSurface
532         }
533
534         if (elementName == "Spring")
535         {
536                 CreateSpringSurface(__elementBuffer[lastElementIndex]);
537
538                 __elementBuffer.pop_back();
539
540                 return;
541         } // SpringSurface
542
543         if (elementName == "Rod")
544         {
545                 CreateRodSurface(__elementBuffer[lastElementIndex]);
546
547                 __elementBuffer.pop_back();
548
549                 return;
550         } // RodSurface
551
552         if (elementName == "PointLight")
553         {
554                 CreatePointLight(__elementBuffer[lastElementIndex]);
555
556                 __elementBuffer.pop_back();
557
558                 return;
559         } // PointLight
560
561         if (elementName == "SpotLight")
562         {
563                 CreateSpotLight(__elementBuffer[lastElementIndex]);
564
565                 __elementBuffer.pop_back();
566
567                 return;
568         } // SpotLight
569
570         if (elementName == "DirectionalLight")
571         {
572                 CreateDirectionalLight(__elementBuffer[lastElementIndex]);
573
574                 __elementBuffer.pop_back();
575
576                 return;
577         } // DirectionalLight
578
579         if (elementName == "ModelsArray")
580         {
581                 CreateEffectModel(__elementBuffer[lastElementIndex]);
582                 __elementBuffer.pop_back();
583
584                 return;
585         } // EffectModel
586
587         if (elementName == "GraphicalSurface")
588         {
589                 if (__insideGraphicalSurface)
590                 {
591                         __insideGraphicalSurface = false;
592                 }
593
594                 CreateGraphicalSurface(__elementBuffer[lastElementIndex]);
595
596                 __elementBuffer.pop_back();
597
598                 __rightAfterGraphicalSurfaceStart = false;
599                 __lastGraphicalSurfaceXMLElementIndex = -1;
600
601                 return;
602         } // GraphicalSurface
603
604         if (elementName == "KnotVectorX")
605         {
606                 if (__insideVectorX)
607                 {
608                         __insideVectorX = false;
609                 }
610                 __elementBuffer.pop_back();
611
612                 return;
613         } // VectorX
614
615         if (elementName == "KnotVectorY")
616         {
617                 if (__insideVectorY)
618                 {
619                         __insideVectorY = false;
620                 }
621                 __elementBuffer.pop_back();
622
623                 return;
624         } // VectorY
625
626         if (elementName == "knot")
627         {
628                 CreateGraphicalSurfaceKnot(__elementBuffer[lastElementIndex]);
629                 __elementBuffer.pop_back();
630
631                 return;
632         } // knot
633
634         if (elementName == "Viewport")
635         {
636                 ReadViewportData(__elementBuffer[lastElementIndex]);
637                 __elementBuffer.pop_back();
638
639                 return;
640         } // Viewport
641
642         if (elementName == "GravityForce")
643         {
644                 CreateGravityForce(__elementBuffer[lastElementIndex]);
645                 __elementBuffer.pop_back();
646
647                 return;
648         } // GravityForce
649
650         if (elementName == "Model")
651         {
652                 CreateModelSurface(__elementBuffer[lastElementIndex]);
653                 __elementBuffer.pop_back();
654
655                 __rightAfterModelSurfaceStart = false;
656                 __currentModelSurfaceX = 0;
657                 __currentModelSurfaceY = 0;
658                 __currentGraphicalSurfaceDimCtrlX = 0;
659                 __currentGraphicalSurfaceDimCtrlY = 0;
660                 __lastModelSurfaceXMLElementIndex = -1;
661
662                 return;
663         } // ModelSurface
664
665         if (elementName == "Scene")
666         {
667                 __elementBuffer.pop_back();
668
669                 __rightAfterSceneStart = false;
670                 __lastSceneXMLElementIndex = -1;
671
672                 return;
673         } // Scene
674
675         if (elementName == "EffectManifest")
676         {
677                 ReadManifestData(__elementBuffer[lastElementIndex]);
678                 __elementBuffer.pop_back();
679
680                 return;
681         } // EffectManifest
682
683         // otherwise
684         __elementBuffer.pop_back();
685
686         return;
687 }
688
689 void
690 EffectParser::Attribute(const char* pAttributeName, const char* pAttributeValue)
691 {
692         if (__buildingModelFailed)
693         {
694                 return;
695         }
696
697         std::string attributeNameLowerCase(pAttributeName);
698
699         if (__elementBuffer.size() == 0)
700         {
701                 __buildingModelFailed = true;
702
703                 SysLogException(NID_UI_EFFECT, E_INVALID_STATE, "Effects. [E_INVALID_STATE] Building a model failed: _elementBuffer.size() == 0 ( %s = %s )",
704                                 pAttributeName, pAttributeValue);
705
706                 return;
707         }
708
709         int lastElementIndex = (int) __elementBuffer.size() - 1;
710         __elementBuffer[lastElementIndex].attributes[attributeNameLowerCase] = pAttributeValue;
711
712         return;
713 }
714
715 void
716 EffectParser::ClearBuffers(void)
717 {
718         for (TypePModelSurfaceCollection::iterator it = __modelSurfaceBuffer.begin();
719                         it != __modelSurfaceBuffer.end();
720                         ++it)
721         {
722                 ModelSurface* pNextModelSurface = *it;
723                 if (pNextModelSurface != null)
724                 {
725                         delete pNextModelSurface;
726                 }
727                 else
728                 {
729                         ;
730                 }
731         }
732
733         for (TypePElementSurfaceCollection::iterator it = __elementSurfaceBuffer.begin();
734                         it != __elementSurfaceBuffer.end();
735                         ++it)
736         {
737                 ElementSurface* pNextElementSurface = *it;
738                 if (pNextElementSurface != null)
739                 {
740                         delete pNextElementSurface;
741                 }
742                 else
743                 {
744                         ;
745                 }
746         }
747
748         UnitLight::ReleaseObjectsPool();
749
750         __lastSceneXMLElementIndex = -1;
751         __lastModelSurfaceXMLElementIndex = -1;
752         __lastGraphicalSurfaceXMLElementIndex = -1;
753         __currentModelFilesDirectoryPath = "";
754         __modelSurfaceBuffer.clear();
755         __elementSurfaceBuffer.clear();
756         __unitLightBuffer.clear();
757         __elementBuffer.clear();
758         __pointSurfaceNurbsIndices.clear();
759         __pCurrentEffectManager = null;
760         __currentEffectId = 0;
761         __currentModelBehaviourType = EFFECT_TYPE_TIME_BASED;
762         __currentEffectDuration = 0.0f;
763         __currentEffectInstanceName = "";
764         __currentSceneData.timerTimeout = 0;
765         __pInstance->__currentSceneData.ambientColor = Vec3f(1.0f, 1.0f, 1.0f);
766         __pInstance->__currentSceneData.intensity = 1.0f;
767         __pInstance->__currentSceneData.attenuation = 0.0f;
768         __currentViewportData.x = 0.0f;
769         __currentViewportData.y = 0.0f;
770         __currentViewportData.z = 0.0f;
771         __currentViewportData.width = 0.0f;
772         __currentViewportData.height = 0.0f;
773         __currentViewportData.near = 0.0f;
774         __currentViewportData.far = 0.0f;
775         __currentViewportData.angle = 0.0f;
776         __currentViewportData.perspective = false;
777         __currentModelSurfaceX = 0.0f;
778         __currentModelSurfaceY = 0.0f;
779         __currentGraphicalSurfaceDimCtrlX = 0;
780         __currentGraphicalSurfaceDimCtrlY = 0;
781         __currentGravityForceValue = 0.0f;
782
783         if (__buildingModelFailed)
784         {
785                 __currentGravityForce = Vec3f(0, 0, 0);
786         }
787
788         __pCurrentVectorXBuffer.reset();
789         __pCurrentVectorYBuffer.reset();
790
791         return;
792 }
793
794 void
795 EffectParser::ClearModelFiles(void)
796 {
797         std::string sceneFilePath = __currentModelFilesDirectoryPath + __SCENE_FILE_NAME;
798         std::string manifestFilePath = __currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME;
799         std::string scriptFilePath = __currentModelFilesDirectoryPath + __SCRIPT_FILE_NAME;
800
801         remove(sceneFilePath.c_str());
802         remove(manifestFilePath.c_str());
803         remove(scriptFilePath.c_str());
804
805         return;
806 }
807
808 PointSurface*
809 EffectParser::FindPointSurfaceById(long pointId) const
810 {
811         PointSurface* pResult = null;
812
813         for (TypePElementSurfaceCollection::const_iterator it = __elementSurfaceBuffer.begin();
814                         it != __elementSurfaceBuffer.end();
815                         ++it)
816         {
817                 // It is assumed that all the points are going before any Spring or a rod
818                 if (((*it)->GetType() != ESURFACE_POINT_SURFACE)
819                                 && ((*it)->GetType() != ESURFACE_POINT_SURFACE_NURBS))
820                 {
821                         break;
822                 }
823                 if ((*it)->GetId() == pointId)
824                 {
825                         pResult = dynamic_cast<PointSurface*>((*it));
826                         break;
827                 }
828         }
829
830         return pResult;
831 }
832
833 PointSurfaceNurbs*
834 EffectParser::FindPointSurfaceNurbsByIndices(unsigned int row, unsigned int col) const
835 {
836         PointSurfaceNurbs* pResult = null;
837         for (TypeNurbsPointIndexDistributor::const_iterator it = __pointSurfaceNurbsIndices.begin();
838                         it != __pointSurfaceNurbsIndices.end();
839                         ++it)
840         {
841                 if ((it->first.first == row) && (it->first.second == col))
842                 {
843                         pResult = dynamic_cast<PointSurfaceNurbs*>(__elementSurfaceBuffer[it->second]);
844                         break;
845                 }
846         }
847
848         return pResult;
849 }
850
851 bool
852 EffectParser::CreatePointLight(XmlElement& xmlElement)
853 {
854         bool result = true;
855         Tizen::Ui::Effects::_Runtime::PointLight* newPointLight = null;
856
857         std::string name;
858         bool isEnabled = false;
859         float intensity = 0.0f;
860         Vec3f color(0, 0, 0);
861         Vec3f position(0, 0, 0);
862         TypeXmlElementAttributes::iterator foundAttribute;
863
864         foundAttribute = xmlElement.attributes.find("name");
865         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
866         name = foundAttribute->second.c_str();
867
868         foundAttribute = xmlElement.attributes.find("x");
869         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
870                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
871
872         // x - coordinate is absolute
873         position.x = (float) strtod(foundAttribute->second.c_str(), null);
874
875         foundAttribute = xmlElement.attributes.find("y");
876         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
877                         E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
878
879         // y - coordinate is absolute
880         position.y = (float) strtod(foundAttribute->second.c_str(), null);
881
882         foundAttribute = xmlElement.attributes.find("z");
883         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
884                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
885
886         // z - coordinate is absolute
887         position.z = (float) strtod(foundAttribute->second.c_str(), null);
888
889         foundAttribute = xmlElement.attributes.find("enable");
890         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
891                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
892
893         if (foundAttribute->second == std::string("true"))
894         {
895                 isEnabled = true;
896         }
897         else
898         {
899                 SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
900         }
901
902         foundAttribute = xmlElement.attributes.find("intensity");
903         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
904                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
905         intensity = (float) strtod(foundAttribute->second.c_str(), null);
906
907         SysTryCatch(NID_UI_EFFECT, intensity >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
908
909         foundAttribute = xmlElement.attributes.find("color");
910         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
911                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
912         {
913                 std::string stringColor = foundAttribute->second;
914                 SysTryCatchLabel(NID_UI_EFFECT, *(stringColor.begin()) == '#', result = false, CATCH,
915                                 E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
916                 SysTryCatchLabel(NID_UI_EFFECT, stringColor.size() == 7, result = false, CATCH,
917                                 E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
918                 stringColor.erase(stringColor.begin());
919                 stringColor = "0x" + stringColor;
920                 color = StringHexToRgb(stringColor);
921         }
922
923         SysTryCatch(NID_UI_EFFECT, (0.0f <= color.x) && (color.x <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
924         SysTryCatch(NID_UI_EFFECT, (0.0f <= color.y) && (color.y <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
925         SysTryCatch(NID_UI_EFFECT, (0.0f <= color.z) && (color.z <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
926
927         // Create a new point light if all the requests for an attribute succeeded
928         newPointLight = Tizen::Ui::Effects::_Runtime::PointLight::CreatePointLight(isEnabled, name, color, intensity, position);
929         SysTryReturn(NID_UI_EFFECT,  newPointLight != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
930
931         __unitLightBuffer.push_back(newPointLight);
932
933         return result;
934
935 CATCH:
936         __buildingModelFailed = true;
937
938         return result;
939 }
940
941 bool
942 EffectParser::CreateSpotLight(XmlElement& xmlElement)
943 {
944         bool result = true;
945         Tizen::Ui::Effects::_Runtime::SpotLight* newSpotLight = null;
946
947         std::string name;
948         bool isEnabled = false;
949         float intensity = 0.0f;
950         Vec3f color(0, 0, 0);
951         Vec3f position(0, 0, 0);
952         Vec3f direction(0, 0, 0);
953         float angleOpening = 0.0f;
954         float angleFadeOut = 0.0f;
955
956         TypeXmlElementAttributes::iterator foundAttribute;
957
958         foundAttribute = xmlElement.attributes.find("name");
959         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
960         name = foundAttribute->second.c_str();
961
962         foundAttribute = xmlElement.attributes.find("x");
963         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
964                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
965
966         // x - coordinate is absolute
967         position.x = (float) strtod(foundAttribute->second.c_str(), null);
968
969         foundAttribute = xmlElement.attributes.find("y");
970         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
971                         E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
972
973         // y - coordinate is absolute
974         position.y = (float) strtod(foundAttribute->second.c_str(), null);
975
976         foundAttribute = xmlElement.attributes.find("z");
977         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
978                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
979
980         // z - coordinate is absolute
981         position.z = (float) strtod(foundAttribute->second.c_str(), null);
982
983         foundAttribute = xmlElement.attributes.find("enable");
984         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
985                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
986
987         if (foundAttribute->second == std::string("true"))
988         {
989                 isEnabled = true;
990         }
991         else
992         {
993                 SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
994         }
995
996         foundAttribute = xmlElement.attributes.find("intensity");
997         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
998                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
999         intensity = (float) strtod(foundAttribute->second.c_str(), null);
1000
1001         SysTryCatch(NID_UI_EFFECT, intensity >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1002
1003         foundAttribute = xmlElement.attributes.find("color");
1004         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1005                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1006         {
1007                 std::string stringColor = foundAttribute->second;
1008                 SysTryCatchLabel(NID_UI_EFFECT, *(stringColor.begin()) == '#', result = false, CATCH,
1009                                 E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1010                 SysTryCatchLabel(NID_UI_EFFECT, stringColor.size() == 7, result = false, CATCH,
1011                                 E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1012                 stringColor.erase(stringColor.begin());
1013                 stringColor = "0x" + stringColor;
1014                 color = StringHexToRgb(stringColor);
1015         }
1016
1017         SysTryCatch(NID_UI_EFFECT, (0.0f <= color.x) && (color.x <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1018         SysTryCatch(NID_UI_EFFECT, (0.0f <= color.y) && (color.y <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1019         SysTryCatch(NID_UI_EFFECT, (0.0f <= color.z) && (color.z <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1020
1021         foundAttribute = xmlElement.attributes.find("targetX");
1022         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1023                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1024
1025         // x - coordinate is absolute
1026         direction.x = (float) strtod(foundAttribute->second.c_str(), null);
1027
1028         foundAttribute = xmlElement.attributes.find("targetY");
1029         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1030                         E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1031
1032         // y - coordinate is absolute
1033         direction.y = (float) strtod(foundAttribute->second.c_str(), null);
1034
1035         foundAttribute = xmlElement.attributes.find("targetZ");
1036         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1037                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
1038
1039         // z - coordinate is absolute
1040         direction.z = (float) strtod(foundAttribute->second.c_str(), null);
1041
1042         foundAttribute = xmlElement.attributes.find("angleOpening");
1043         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1044                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1045         angleOpening = (float) strtod(foundAttribute->second.c_str(), null);
1046
1047         SysTryCatch(NID_UI_EFFECT, (0.0f <= angleOpening) && (angleOpening <= 360.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1048
1049         foundAttribute = xmlElement.attributes.find("angleFadeOut");
1050         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1051                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1052         angleFadeOut = (float) strtod(foundAttribute->second.c_str(), null);
1053
1054         SysTryCatch(NID_UI_EFFECT, (0.0f <= angleFadeOut) && (angleFadeOut <= 360.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1055
1056         // Create a new spot light if all the requests for an attribute succeeded
1057         newSpotLight = Tizen::Ui::Effects::_Runtime::SpotLight::
1058                         CreateSpotLight(isEnabled, name, color, intensity, position, direction, angleOpening, angleFadeOut);
1059         SysTryReturn(NID_UI_EFFECT,  newSpotLight != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
1060
1061         __unitLightBuffer.push_back(newSpotLight);
1062
1063         return result;
1064
1065 CATCH:
1066         __buildingModelFailed = true;
1067
1068         return result;
1069 }
1070
1071 bool
1072 EffectParser::CreateDirectionalLight(XmlElement& xmlElement)
1073 {
1074         bool result = true;
1075         Tizen::Ui::Effects::_Runtime::DirectionalLight* newDirectionalLight = null;
1076
1077         std::string name;
1078         bool isEnabled = false;
1079         float intensity = 0.0f;
1080         Vec3f color(0, 0, 0);
1081         Vec3f direction(0, 0, 0);
1082         TypeXmlElementAttributes::iterator foundAttribute;
1083
1084         foundAttribute = xmlElement.attributes.find("name");
1085         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1086         name = foundAttribute->second.c_str();
1087
1088         foundAttribute = xmlElement.attributes.find("directionX");
1089         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1090                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1091
1092         // x - coordinate is absolute
1093         direction.x = (float) strtod(foundAttribute->second.c_str(), null);
1094
1095         foundAttribute = xmlElement.attributes.find("directionY");
1096         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1097                         E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1098
1099         // y - coordinate is absolute
1100         direction.y = (float) strtod(foundAttribute->second.c_str(), null);
1101
1102         foundAttribute = xmlElement.attributes.find("directionZ");
1103         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1104                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
1105
1106         // z - coordinate is absolute
1107         direction.z = (float) strtod(foundAttribute->second.c_str(), null);
1108
1109         foundAttribute = xmlElement.attributes.find("enable");
1110         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1111                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1112
1113         if (foundAttribute->second == std::string("true"))
1114         {
1115                 isEnabled = true;
1116         }
1117         else
1118         {
1119                 SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1120         }
1121
1122         foundAttribute = xmlElement.attributes.find("intensity");
1123         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1124                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1125         intensity = (float) strtod(foundAttribute->second.c_str(), null);
1126
1127         SysTryCatch(NID_UI_EFFECT, intensity >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1128
1129         foundAttribute = xmlElement.attributes.find("color");
1130         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1131                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1132         {
1133                 std::string stringColor = foundAttribute->second;
1134                 SysTryCatchLabel(NID_UI_EFFECT, *(stringColor.begin()) == '#', result = false, CATCH,
1135                                 E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1136                 SysTryCatchLabel(NID_UI_EFFECT, stringColor.size() == 7, result = false, CATCH,
1137                                 E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1138                 stringColor.erase(stringColor.begin());
1139                 stringColor = "0x" + stringColor;
1140                 color = StringHexToRgb(stringColor);
1141         }
1142
1143         SysTryCatch(NID_UI_EFFECT, (0.0f <= color.x) && (color.x <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1144         SysTryCatch(NID_UI_EFFECT, (0.0f <= color.y) && (color.y <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1145         SysTryCatch(NID_UI_EFFECT, (0.0f <= color.z) && (color.z <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1146
1147         // Create a new directional light if all the requests for an attribute succeeded
1148         newDirectionalLight = Tizen::Ui::Effects::_Runtime::DirectionalLight::CreateDirectionalLight(isEnabled, name, color, intensity, direction);
1149         SysTryReturn(NID_UI_EFFECT,  newDirectionalLight != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
1150
1151         __unitLightBuffer.push_back(newDirectionalLight);
1152
1153         return result;
1154
1155 CATCH:
1156         __buildingModelFailed = true;
1157
1158         return result;
1159 }
1160
1161 bool
1162 EffectParser::CreatePointSurface(XmlElement& xmlElement)
1163 {
1164         bool result = true;
1165         PointSurface* newPointSurface = null;
1166
1167         long id = 0;
1168         Vec3f positionInit(0, 0, 0);
1169         float massInit = 1.0f;
1170         float pointResistance = 0.f;
1171         bool fixed = false;
1172         TypeXmlElementAttributes::iterator foundAttribute;
1173
1174         foundAttribute = xmlElement.attributes.find("id");
1175         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1176                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1177         id = (long) strtol(foundAttribute->second.c_str(), null, 10);
1178
1179         foundAttribute = xmlElement.attributes.find("x");
1180         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1181                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1182
1183         // x - coordinate is related to the ModelSurface's x-coordinate
1184         positionInit.x = __currentModelSurfaceX + (float) strtod(foundAttribute->second.c_str(), null);
1185
1186         foundAttribute = xmlElement.attributes.find("y");
1187         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1188                         E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1189
1190         // y - coordinate is related to the ModelSurface's y-coordinate
1191         positionInit.y = __currentModelSurfaceY + (float) strtod(foundAttribute->second.c_str(), null);
1192
1193         foundAttribute = xmlElement.attributes.find("z");
1194         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1195                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
1196
1197         // z - coordinate is absolute
1198         positionInit.z = (float) strtod(foundAttribute->second.c_str(), null);
1199
1200         foundAttribute = xmlElement.attributes.find("mass");
1201         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1202                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1203         massInit = (float) strtod(foundAttribute->second.c_str(), null);
1204
1205         foundAttribute = xmlElement.attributes.find("pointResistance");
1206         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1207                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1208         pointResistance = (float) strtod(foundAttribute->second.c_str(), null);
1209
1210         foundAttribute = xmlElement.attributes.find("fixed");
1211         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH,
1212                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1213
1214         if (foundAttribute->second == std::string("true"))
1215         {
1216                 fixed = true;
1217         }
1218         else
1219         {
1220                 SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1221         }
1222
1223         SysTryCatch(NID_UI_EFFECT, massInit > 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1224
1225         // Create a new point if all the requests for an attribute succeeded
1226         newPointSurface = new (std::nothrow) PointSurface(id, positionInit, massInit, pointResistance, fixed);
1227         SysTryReturn(NID_UI_EFFECT,  newPointSurface != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
1228
1229         __elementSurfaceBuffer.push_back(newPointSurface);
1230
1231         return result;
1232
1233 CATCH:
1234         __buildingModelFailed = true;
1235
1236         return result;
1237 }
1238
1239 bool
1240 EffectParser::CreatePointSurfaceNurbs(XmlElement& xmlElement)
1241 {
1242         bool result = true;
1243         PointSurfaceNurbs* newPointSurfaceNurbs = null;
1244
1245         long id = 0;
1246         Vec3f positionInit(0, 0, 0);
1247         float massInit = 1.0f;
1248         float weight = 0.0f;
1249         float pointResistance = 2.f;
1250         bool fixed = false;
1251         unsigned int row = 0;
1252         unsigned int col = 0;
1253         TypeXmlElementAttributes::iterator foundAttribute;
1254
1255         foundAttribute = xmlElement.attributes.find("id");
1256         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1257                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1258         id = (long) strtol(foundAttribute->second.c_str(), null, 10);
1259
1260         foundAttribute = xmlElement.attributes.find("x");
1261         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1262                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1263
1264         // x - coordinate is related to the ModelSurface's x-coordinate
1265         positionInit.x = __currentModelSurfaceX + (float) strtod(foundAttribute->second.c_str(), null);
1266
1267         foundAttribute = xmlElement.attributes.find("y");
1268         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1269                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
1270
1271         // y - coordinate is related to the ModelSurface's y-coordinate
1272         positionInit.y = __currentModelSurfaceY + (float) strtod(foundAttribute->second.c_str(), null);
1273
1274         foundAttribute = xmlElement.attributes.find("z");
1275         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1276                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1277
1278         // z - coordinate is absolute
1279         positionInit.z = (float) strtod(foundAttribute->second.c_str(), null);
1280
1281         foundAttribute = xmlElement.attributes.find("mass");
1282         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1283                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
1284         massInit = (float) strtod(foundAttribute->second.c_str(), null);
1285
1286         foundAttribute = xmlElement.attributes.find("gWeight");
1287         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1288                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1289         weight = (float) strtod(foundAttribute->second.c_str(), null);
1290
1291         foundAttribute = xmlElement.attributes.find("fixed");
1292         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1293                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1294
1295         if (foundAttribute->second == std::string("true"))
1296         {
1297                 fixed = true;
1298         }
1299         else
1300         {
1301                 SysTryCatchLabel(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1302         }
1303
1304         foundAttribute = xmlElement.attributes.find("pointResistance");
1305         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1306                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1307         pointResistance = (float) strtod(foundAttribute->second.c_str(), null);
1308
1309         foundAttribute = xmlElement.attributes.find("row");
1310         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1311                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1312         {
1313                 int rowValue = (int) strtol(foundAttribute->second.c_str(), null, 10);
1314                 SysTryCatchLabel(NID_UI_EFFECT, rowValue >= 0, result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1315
1316                 row = (unsigned int) rowValue;
1317         }
1318
1319         foundAttribute = xmlElement.attributes.find("col");
1320         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1,
1321                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1322         {
1323                 int colValue = (int) strtol(foundAttribute->second.c_str(), null, 10);
1324                 SysTryCatchLabel(NID_UI_EFFECT, colValue >= 0, result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1325
1326                 col = (unsigned int) colValue;
1327         }
1328
1329         SysTryCatchLabel(NID_UI_EFFECT, massInit > 0.0f, result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1330         SysTryCatchLabel(NID_UI_EFFECT, weight >= 0.0f, result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1331
1332         SysTryCatchLabel(NID_UI_EFFECT,(col < __currentGraphicalSurfaceDimCtrlX) && (row < __currentGraphicalSurfaceDimCtrlY), result = false, CATCH2,
1333                         E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC);
1334
1335         SysTryCatchLabel(NID_UI_EFFECT, __pointSurfaceNurbsIndices.find(std::pair<int, int>(row, col)) == __pointSurfaceNurbsIndices.end(), result = false, CATCH3,
1336                         E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC);
1337
1338         newPointSurfaceNurbs = new (std::nothrow) PointSurfaceNurbs(id, positionInit, massInit, pointResistance, weight, fixed, row, col);
1339         SysTryReturn(NID_UI_EFFECT,  newPointSurfaceNurbs != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
1340
1341         __elementSurfaceBuffer.push_back(newPointSurfaceNurbs);
1342
1343         __pointSurfaceNurbsIndices[std::pair<int, int>(row, col)] = __elementSurfaceBuffer.size() - 1;
1344
1345         return true;
1346
1347 CATCH1:
1348         __buildingModelFailed = true;
1349
1350         return result;
1351
1352 CATCH2:
1353         __buildingModelFailed = true;
1354
1355         return result;
1356
1357 CATCH3:
1358         __buildingModelFailed = true;
1359
1360         return result;
1361 }
1362
1363 bool
1364 EffectParser::CreateSpringSurface(XmlElement& xmlElement)
1365 {
1366         bool result = true;
1367         SpringSurface* newSpringSurface = null;
1368
1369         long id = 0;
1370         float stiffness = 0.0f;
1371         PointSurface* pPoint1 = null;
1372         PointSurface* pPoint2 = null;
1373         TypeXmlElementAttributes::iterator foundAttribute;
1374
1375         foundAttribute = xmlElement.attributes.find("id");
1376         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1377         id = (long) strtol(foundAttribute->second.c_str(), null, 10);
1378
1379         foundAttribute = xmlElement.attributes.find("pointId1");
1380         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
1381         {
1382                 long point1ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1383                 pPoint1 = FindPointSurfaceById(point1ID);
1384         }
1385
1386         foundAttribute = xmlElement.attributes.find("pointId2");
1387         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1388         {
1389                 long point2ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1390                 pPoint2 = FindPointSurfaceById(point2ID);
1391         }
1392
1393         foundAttribute = xmlElement.attributes.find("stiffness");
1394         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1395         stiffness = (float) strtod(foundAttribute->second.c_str(), null);
1396
1397         SysTryCatch(NID_UI_EFFECT, stiffness >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1398
1399         // Create a new Spring if all the requests for an attribute succeeded
1400         if ((pPoint1 != null) && (pPoint2 != null) && result)
1401         {
1402                 newSpringSurface = new (std::nothrow) SpringSurface(id, stiffness, pPoint1, pPoint2);
1403                 SysTryReturn(NID_UI_EFFECT,  newSpringSurface != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
1404
1405                 __elementSurfaceBuffer.push_back(newSpringSurface);
1406         }
1407         else
1408         {
1409                 result = false;
1410
1411                 __buildingModelFailed = true;
1412
1413                 SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] Building a model failed: error in SpringSurface's attributes");
1414         }
1415
1416         return result;
1417
1418 CATCH:
1419         __buildingModelFailed = true;
1420
1421         return result;
1422 }
1423
1424 bool
1425 EffectParser::CreateRodSurface(XmlElement& xmlElement)
1426 {
1427         bool result = true;
1428         RodSurface* newRodSurface = null;
1429
1430         long id = 0;
1431         float stiffness = 0.0f;
1432         PointSurface* pPoint1 = null;
1433         PointSurface* pPoint2 = null;
1434         PointSurface* pPoint3 = null;
1435         TypeXmlElementAttributes::iterator foundAttribute;
1436
1437         foundAttribute = xmlElement.attributes.find("id");
1438         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1439         id = (long) strtol(foundAttribute->second.c_str(), null, 10);
1440
1441         foundAttribute = xmlElement.attributes.find("pointId1");
1442         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1443         {
1444                 long point1ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1445                 pPoint1 = FindPointSurfaceById(point1ID);
1446         }
1447
1448         foundAttribute = xmlElement.attributes.find("pointId2");
1449         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1450         {
1451                 long point2ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1452                 pPoint2 = FindPointSurfaceById(point2ID);
1453         }
1454
1455         foundAttribute = xmlElement.attributes.find("pointId3");
1456         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1457         {
1458                 long point3ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1459                 pPoint3 = FindPointSurfaceById(point3ID);
1460         }
1461
1462         foundAttribute = xmlElement.attributes.find("stiffness");
1463         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1464         stiffness = (float) strtod(foundAttribute->second.c_str(), null);
1465
1466         SysTryCatch(NID_UI_EFFECT, stiffness >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1467
1468         // Create a new rod if all the requests for an attribute succeeded
1469         if ((pPoint1 != null) && (pPoint2 != null) && (pPoint3 != null) && result)
1470         {
1471                 newRodSurface = new (std::nothrow) RodSurface(id, stiffness, pPoint1, pPoint2, pPoint3);
1472                 SysTryReturn(NID_UI_EFFECT,  newRodSurface != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
1473
1474                 __elementSurfaceBuffer.push_back(newRodSurface);
1475         }
1476         else
1477         {
1478                 result = false;
1479
1480                 __buildingModelFailed = true;
1481
1482                 SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] Building a model failed: error in RodSurface's attributes");
1483         }
1484
1485         return result;
1486
1487 CATCH:
1488         __buildingModelFailed = true;
1489
1490         return result;
1491 }
1492
1493 bool
1494 EffectParser::CreateRodSurfaceNurbs(XmlElement& xmlElement)
1495 {
1496         bool result = true;
1497         RodSurfaceNurbs* newRodSurfaceNurbs = null;
1498         long id = 0;
1499         float stiffness = 0.0f;
1500         PointSurfaceNurbs* pPoint1 = null;
1501         PointSurfaceNurbs* pPoint2 = null;
1502         PointSurfaceNurbs* pPoint3 = null;
1503         PointSurfaceNurbs* pPoint4 = null;
1504         unsigned int normalPointRowIndex = 0;
1505         unsigned int normalPointColIndex = 0;
1506         TypeXmlElementAttributes::iterator foundAttribute;
1507
1508         foundAttribute = xmlElement.attributes.find("id");
1509         SysTryCatch(
1510                                 NID_UI_EFFECT,
1511                                 foundAttribute != xmlElement.attributes.end(),
1512                                 result = false,
1513                                 E_KEY_NOT_FOUND,
1514                                 Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1515         id = (long) strtol(foundAttribute->second.c_str(), null, 10);
1516
1517         foundAttribute = xmlElement.attributes.find("pointId1");
1518         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1519         {
1520                  long point1ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1521                  pPoint1 = dynamic_cast<PointSurfaceNurbs*> (FindPointSurfaceById(point1ID));
1522         }
1523
1524         foundAttribute = xmlElement.attributes.find("pointId2");
1525         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1526         {
1527                 long point2ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1528                 pPoint2 = dynamic_cast<PointSurfaceNurbs*> (FindPointSurfaceById(point2ID));
1529         }
1530
1531         foundAttribute = xmlElement.attributes.find("pointId3");
1532         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1533         {
1534                 long point3ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1535                 pPoint3 = dynamic_cast<PointSurfaceNurbs*> (FindPointSurfaceById(point3ID));
1536         }
1537
1538         foundAttribute = xmlElement.attributes.find("stiffness");
1539         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1540         stiffness = (float) strtod(foundAttribute->second.c_str(), null);
1541
1542         SysTryCatch(NID_UI_EFFECT, stiffness >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1543
1544         if ((pPoint1 != null) && (pPoint2 != null) && (pPoint3 != null))
1545         {
1546                 int tempRow = (int) pPoint2->GetRow() + (int) pPoint2->GetCol() - (int) pPoint1->GetCol();
1547                 int tempCol = (int) pPoint2->GetCol() + (int) pPoint1->GetRow() - (int) pPoint2->GetRow();
1548
1549                 if (( tempRow < 0 ) ||
1550                         ((int) __currentGraphicalSurfaceDimCtrlY - 1 < tempRow) ||
1551                         (tempCol < 0 ) ||
1552                         ((int) __currentGraphicalSurfaceDimCtrlX - 1 < tempCol))
1553                 {
1554                         tempRow = static_cast<int>(pPoint2->GetRow()) + static_cast<int>(pPoint1->GetCol()) - static_cast<int>(pPoint2->GetCol());
1555                         tempCol = static_cast<int>(pPoint2->GetCol()) + static_cast<int>(pPoint2->GetRow()) - static_cast<int>(pPoint1->GetRow());
1556                 }
1557
1558                 normalPointRowIndex = tempRow;
1559                 normalPointColIndex = tempCol;
1560
1561                 pPoint4 = FindPointSurfaceNurbsByIndices(normalPointRowIndex, normalPointColIndex);
1562         }
1563
1564         // Create a new rod if all the requests for an attribute succeeded
1565         if ((pPoint1 != null) && (pPoint2 != null) && (pPoint3 != null) && (pPoint4 != null) && result)
1566         {
1567                 newRodSurfaceNurbs = new (std::nothrow) RodSurfaceNurbs(id, stiffness, pPoint1, pPoint2, pPoint3, pPoint4);
1568                 SysTryReturn(NID_UI_EFFECT,  newRodSurfaceNurbs != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
1569
1570                 __elementSurfaceBuffer.push_back(newRodSurfaceNurbs);
1571         }
1572         else
1573         {
1574                 result = false;
1575
1576                 __buildingModelFailed = true;
1577
1578                 SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] Building a model failed: _error in RodSurfaceNURBS's attributes");
1579         }
1580
1581         return result;
1582
1583 CATCH:
1584         __buildingModelFailed = true;
1585
1586         return result;
1587 }
1588
1589 bool
1590 EffectParser::CreateGraphicalSurface(XmlElement& xmlElement)
1591 {
1592         bool result = true;
1593         long id = 0;
1594         float x = 0.0f;
1595         float y = 0.0f;
1596         float width = 0.0f;
1597         float height = 0.0f;
1598         float transparency = 0.0f;
1599         long bitmapId = 0;
1600         unsigned int dimGraphX = 0;
1601         unsigned int dimGraphY = 0;
1602         unsigned int dimCtrlX = 0;
1603         unsigned int dimCtrlY = 0;
1604         unsigned int orderX = 0;
1605         unsigned int orderY = 0;
1606
1607         TypeXmlElementAttributes::iterator foundAttribute;
1608
1609         foundAttribute = xmlElement.attributes.find("id");
1610         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1611         id = (long) strtol(foundAttribute->second.c_str(), null, 10);
1612
1613         foundAttribute = xmlElement.attributes.find("x");
1614         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1615         x = (float) strtod(foundAttribute->second.c_str(), null);
1616
1617         foundAttribute = xmlElement.attributes.find("y");
1618         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1619         y = (float) strtod(foundAttribute->second.c_str(), null);
1620
1621         foundAttribute = xmlElement.attributes.find("width");
1622         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1623         width = (float) strtod(foundAttribute->second.c_str(), null);
1624
1625         foundAttribute = xmlElement.attributes.find("height");
1626         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1627         height = (float) strtod(foundAttribute->second.c_str(), null);
1628
1629         foundAttribute = xmlElement.attributes.find("transparency");
1630         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1631         transparency = (float) strtod(foundAttribute->second.c_str(), null);
1632
1633         foundAttribute = xmlElement.attributes.find("bitmapID");
1634         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1635         bitmapId = (long) strtol(foundAttribute->second.c_str(), null, 10);
1636
1637         foundAttribute = xmlElement.attributes.find("dimGraphX");
1638         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1639         {
1640                 int dimGraphXValue = (int) strtol(foundAttribute->second.c_str(), null, 10);
1641                 SysTryCatch(NID_UI_EFFECT, dimGraphXValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1642
1643                 dimGraphX = (unsigned int) dimGraphXValue;
1644         }
1645
1646         foundAttribute = xmlElement.attributes.find("dimGraphY");
1647         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
1648         {
1649                 int dimGraphYValue = (int) strtol(foundAttribute->second.c_str(), null, 10);
1650                 SysTryCatch(NID_UI_EFFECT, dimGraphYValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1651
1652                 dimGraphY = (unsigned int) dimGraphYValue;
1653         }
1654
1655         foundAttribute = xmlElement.attributes.find("dimCtrlX");
1656         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1657         {
1658                 int dimCtrlXValue = (int) strtol(foundAttribute->second.c_str(), null, 10);
1659                 SysTryCatch(NID_UI_EFFECT, dimCtrlXValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1660
1661                 dimCtrlX = (unsigned int) dimCtrlXValue;
1662         }
1663
1664         foundAttribute = xmlElement.attributes.find("dimCtrlY");
1665         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1666         {
1667                 int dimCtrlYValue = (int) strtol(foundAttribute->second.c_str(), null, 10);
1668                 SysTryCatch(NID_UI_EFFECT, dimCtrlYValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1669
1670                 dimCtrlY = (unsigned int) dimCtrlYValue;
1671         }
1672
1673         foundAttribute = xmlElement.attributes.find("orderX");
1674         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1675         {
1676                 int orderXValue = (int) strtol(foundAttribute->second.c_str(), null, 10);
1677                 SysTryCatch(NID_UI_EFFECT, orderXValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1678
1679                 orderX = (unsigned int) orderXValue;
1680         }
1681
1682         foundAttribute = xmlElement.attributes.find("orderY");
1683         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1684         {
1685                 int orderYValue = (int) strtol(foundAttribute->second.c_str(), null, 10);
1686                 SysTryCatch(NID_UI_EFFECT, orderYValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1687
1688                 orderY = (unsigned int) orderYValue;
1689         }
1690
1691         SysTryCatch(NID_UI_EFFECT, width >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1692         SysTryCatch(NID_UI_EFFECT, height >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1693         SysTryCatch(NID_UI_EFFECT, (0.0f <= transparency) && (transparency <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1694
1695         __pCurrentGraphicalSurface = std::unique_ptr<GraphicalSurface>(new (std::nothrow) GraphicalSurfaceNurbs(id, bitmapId, dimCtrlX, dimCtrlY, orderX, orderY, dimGraphX, dimGraphY,
1696                 std::move(__pCurrentVectorXBuffer), std::move(__pCurrentVectorYBuffer), transparency));
1697
1698         if (__pCurrentGraphicalSurface != null)
1699         {
1700                 ;
1701         }
1702         else
1703         {
1704                 result = false;
1705                 __buildingModelFailed = true;
1706
1707                 SysLogException(NID_UI_EFFECT, E_OUT_OF_MEMORY, "Effects. Effect was not created! Exception E_OUT_OF_MEMORY was appeared while creating of GraphicalSurfaceNurbs instance"); //E_OUT_OF_MEMORY
1708         }
1709
1710         if (result)
1711         {
1712                 __pCurrentVectorXBuffer.reset();
1713                 __pCurrentVectorYBuffer.reset();
1714         }
1715
1716         return result;
1717
1718 CATCH:
1719         __buildingModelFailed = true;
1720
1721         __pCurrentVectorXBuffer.reset();
1722         __pCurrentVectorYBuffer.reset();
1723
1724         return result;
1725 }
1726
1727 bool
1728 EffectParser::CreateModelSurface(XmlElement& xmlElement)
1729 {
1730         bool result = true;
1731
1732         long id = 0;
1733         float width = 0.0f;
1734         float height = 0.0f;
1735         std::string name;
1736         unsigned short iterationCount = 1;
1737         unsigned short modelSpeed = 1;
1738         float environmentResistance = 0.0f;
1739         float groundLevel = 0.0f;
1740         unsigned int expectedNurbsPointsCount = 0;
1741         ModelSurface* newModelSurface = null;
1742
1743         TypeXmlElementAttributes::iterator foundAttribute;
1744
1745         foundAttribute = xmlElement.attributes.find("id");
1746         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1747         id = (long) strtol(foundAttribute->second.c_str(), null, 10);
1748
1749         foundAttribute = xmlElement.attributes.find("width");
1750         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
1751         width = (float) strtod(foundAttribute->second.c_str(), null);
1752
1753         foundAttribute = xmlElement.attributes.find("height");
1754         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1755         height = (float) strtod(foundAttribute->second.c_str(), null);
1756
1757         foundAttribute = xmlElement.attributes.find("name");
1758         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1759         name = foundAttribute->second.c_str();
1760
1761         foundAttribute = xmlElement.attributes.find("timeoutDivisor");
1762         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1763         iterationCount = (unsigned short) strtod(foundAttribute->second.c_str(), null);
1764
1765         foundAttribute = xmlElement.attributes.find("speedFactor");
1766         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1767         modelSpeed = (unsigned short) strtod(foundAttribute->second.c_str(), null);
1768
1769         foundAttribute = xmlElement.attributes.find("environmentResistance");
1770         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1771         environmentResistance = (float) strtod(foundAttribute->second.c_str(), null);
1772
1773         foundAttribute = xmlElement.attributes.find("groundLevel");
1774         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND );
1775         groundLevel = (float) strtod(foundAttribute->second.c_str(), null);
1776
1777         SysTryCatch(NID_UI_EFFECT, width >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1778         SysTryCatch(NID_UI_EFFECT, height >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1779         SysTryCatch(NID_UI_EFFECT, environmentResistance >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1780
1781         // Create a new ModelSurface object if all the requests for an attribute succeded
1782         newModelSurface = new (std::nothrow) ModelSurface(
1783                         id, iterationCount, modelSpeed, environmentResistance, __currentGravityForce, __currentGravityForceValue, groundLevel);
1784
1785         SysTryCatchLabel(NID_UI_EFFECT, newModelSurface != null, result = false, CATCH1, E_OUT_OF_MEMORY,
1786                         "Effects. [E_OUT_OF_MEMORY] NOT CREATED: ModelSurface\n"
1787                         "Effects. Building a model failed: an object of ModelSurface hasn't been created");
1788
1789         __currentGravityForce = Vec3f(0, 0, 0);
1790         __currentGravityForceValue = 0;
1791
1792         // Now add the ElementSurface objects to a newly created ModelSurface
1793
1794         expectedNurbsPointsCount = __currentGraphicalSurfaceDimCtrlX * __currentGraphicalSurfaceDimCtrlY;
1795
1796         if ((unsigned int) __elementSurfaceBuffer.size() < expectedNurbsPointsCount)
1797         {
1798                 __buildingModelFailed = true;
1799
1800                 SysLogException(NID_UI_EFFECT, E_INVALID_FORMAT, "Effects. [E_INVALID_FORMAT] Building a model failed : "
1801                                 "not enough ElementSurface objects in _elementSurfaceBuffer - less then the predefined number of PoiinSurfaceNURBS objects");
1802         }
1803         else
1804         {
1805                 // first add all the PointSurfaceNURBS objects in the right order
1806                 TypePElementSurfaceCollection::iterator beginIt = __elementSurfaceBuffer.begin();
1807                 for (unsigned int rowIndex = 0; rowIndex < __currentGraphicalSurfaceDimCtrlY; ++rowIndex)
1808                 {
1809                         for (unsigned int colIndex = 0; colIndex < __currentGraphicalSurfaceDimCtrlX; ++colIndex)
1810                         {
1811                                 TypeNurbsPointIndexDistributor::iterator indexIt;
1812
1813                                 indexIt = __pointSurfaceNurbsIndices.find(std::pair<int, int>(rowIndex, colIndex));
1814                                 if (indexIt     != __pointSurfaceNurbsIndices.end())
1815                                 {
1816                                         unsigned int pointNurbsIndex = indexIt->second;
1817
1818                                         if (pointNurbsIndex < expectedNurbsPointsCount)
1819                                         {
1820                                                 TypePElementSurfaceCollection::iterator pointNurbsIterator =
1821                                                                 beginIt + pointNurbsIndex;
1822
1823                                                 if ((*pointNurbsIterator)->GetType() == ESURFACE_POINT_SURFACE_NURBS)
1824                                                 {
1825                                                         newModelSurface->AddElementSurface(*pointNurbsIterator);
1826                                                 }
1827                                                 else
1828                                                 {
1829                                                         __buildingModelFailed = true;
1830
1831                                                         SysLogException(NID_UI_EFFECT, E_INVALID_FORMAT,"Effects. [E_INVALID_FORMAT] _elementSurfaceBuffer.begin() + %i is not a PointSurfaceNURBS",
1832                                                                         pointNurbsIndex);
1833                                                 }
1834                                         }
1835                                         else
1836                                         {
1837                                                 __buildingModelFailed = true;
1838
1839                                                 SysLogException(NID_UI_EFFECT, E_INVALID_FORMAT, "Effects. [E_INVALID_FORMAT] pointNurbsIndex = %i is >= expectedNumberOfNurbsPoints = %i",
1840                                                                 pointNurbsIndex, expectedNurbsPointsCount);
1841                                         }
1842                                 }
1843                                 else
1844                                 {
1845                                         __buildingModelFailed = true;
1846
1847                                         SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] A pair <%i, %i> not present in _pointSurfaceNurbsIndices",
1848                                                         rowIndex, colIndex);
1849                                 }
1850                         }
1851                 }
1852
1853                 // now add all the Elementsurface objects going after PointSurfaceNURBS objects
1854                 if (!__buildingModelFailed)
1855                 {
1856                         for (TypePElementSurfaceCollection::iterator it = __elementSurfaceBuffer.begin() + expectedNurbsPointsCount;
1857                                         it != __elementSurfaceBuffer.end();
1858                                         ++it)
1859                         {
1860                                 newModelSurface->AddElementSurface(*it);
1861                         }
1862                 }
1863         }
1864
1865         __pointSurfaceNurbsIndices.clear();
1866         __elementSurfaceBuffer.clear();
1867
1868         // set Graphical surface
1869         newModelSurface->AddGraphicalSurface(std::move(__pCurrentGraphicalSurface));
1870
1871         __pCurrentGraphicalSurface = null;
1872
1873          // Add created ModelSurface to the list
1874         __modelSurfaceBuffer.push_back(newModelSurface);
1875
1876         return result;
1877
1878 CATCH:
1879         ;
1880 CATCH1:
1881         __buildingModelFailed = true;
1882
1883         __pointSurfaceNurbsIndices.clear();
1884         __elementSurfaceBuffer.clear();
1885
1886         return result;
1887 }
1888
1889 bool
1890 EffectParser::CreateEffectModel(XmlElement& xmlElement)
1891 {
1892         bool result = true;
1893
1894         std::string pathToScript = __currentModelFilesDirectoryPath + __SCRIPT_FILE_NAME;
1895
1896         SetLastResult(E_SUCCESS);
1897
1898         __pCurrentEffectModel = std::unique_ptr<_Runtime::EffectModel>(new (std::nothrow) _Runtime::EffectModel(
1899                         __currentEffectId, __currentEffectInstanceName, pathToScript.c_str(), __pCurrentEffectManager, __currentModelBehaviourType, __currentEffectDuration));
1900
1901         if (__pCurrentEffectModel != null)
1902         {
1903                 ;
1904         }
1905         else
1906         {
1907                 result = false;
1908
1909                 __buildingModelFailed = true;
1910                 SysLogException(NID_UI_EFFECT, E_OUT_OF_MEMORY, "Effects. Effect was not created! Exception E_OUT_OF_MEMORY was appeared while creating of EffectModel instance"); //E_OUT_OF_MEMORY
1911         }
1912
1913         if (GetLastResult() != E_SUCCESS)
1914         {
1915                 result = false;
1916
1917                 __buildingModelFailed = true;
1918                 SysLogException(NID_UI_EFFECT, GetLastResult(),
1919                                 "Effects. Building a model failed: error generated by the constructor of EffectModel: %s", GetErrorMessage(GetLastResult()));
1920         }
1921
1922         if ((__pCurrentEffectModel != null) && (GetLastResult() == E_SUCCESS))
1923         {
1924                 for (TypePModelSurfaceCollection::iterator it = __modelSurfaceBuffer.begin();
1925                                 it != __modelSurfaceBuffer.end();
1926                                 ++it)
1927                 {
1928                         __pCurrentEffectModel->AddModelSurface(*it);
1929                 }
1930
1931                 __modelSurfaceBuffer.clear();
1932
1933                 RenderDataScene* pRenderDataScene = __pCurrentEffectModel->GetRenderingData();
1934
1935                 // in case there was no light sources described inthe scene a single directional light should be set
1936                 if (__unitLightBuffer.size() == 0)
1937                 {
1938                         Tizen::Ui::Effects::_Runtime::DirectionalLight* newDirectionalLight =
1939                                         Tizen::Ui::Effects::_Runtime::DirectionalLight::CreateDirectionalLight(
1940                                                         true, std::string("DirectionalLight_0"), Vec3f(1.0f, 1.0f, 1.0f), 1.0f, Vec3f(0.0f, 0.0f, -1.0f));
1941                         SysTryReturn(NID_UI_EFFECT,  newDirectionalLight != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
1942
1943                         bool addUnitLightResult = pRenderDataScene->AddUnitLight(*newDirectionalLight);
1944                         SysTryCatch(NID_UI_EFFECT, addUnitLightResult, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
1945                 }
1946                 else
1947                 {
1948                         for (TypePUnitLightCollection::iterator it = __unitLightBuffer.begin();
1949                                         it != __unitLightBuffer.end();
1950                                         ++it)
1951                         {
1952                                 bool addUnitLightResult = pRenderDataScene->AddUnitLight(*(*it));
1953                                 SysTryCatch(NID_UI_EFFECT, addUnitLightResult, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
1954                         }
1955                 }
1956
1957                 __unitLightBuffer.clear();
1958
1959                 pRenderDataScene->SetLightAmbientColour(__currentSceneData.ambientColor);
1960                 pRenderDataScene->SetLightIntensity(__currentSceneData.intensity);
1961                 pRenderDataScene->SetLightAttenuation(__currentSceneData.attenuation);
1962
1963                 __pCurrentEffectModel->Construct();
1964         }
1965
1966         return result;
1967
1968 CATCH:
1969         __buildingModelFailed = true;
1970
1971         return result;
1972 }
1973
1974 bool
1975 EffectParser::CreateGraphicalSurfaceKnot(XmlElement& xmlElement)
1976 {
1977         bool result = true;
1978         Tizen::Ui::Effects::_Runtime::TypeKnots* pVectorToRefill = null;
1979         unsigned int index = 0;
1980         float value = 0.0f;
1981         TypeXmlElementAttributes::iterator foundAttribute;
1982
1983         if (__insideVectorX)
1984         {
1985                 pVectorToRefill = __pCurrentVectorXBuffer.get();
1986         }
1987         else if (__insideVectorY)
1988         {
1989                 pVectorToRefill = __pCurrentVectorYBuffer.get();
1990         }
1991         else
1992         {
1993                 ;
1994         }
1995
1996         SysTryCatchLabel(NID_UI_EFFECT, pVectorToRefill != null, result = false, CATCH1, E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
1997
1998         foundAttribute = xmlElement.attributes.find("index");
1999         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH2,
2000                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2001         index = (unsigned int) strtol(foundAttribute->second.c_str(), null, 10);
2002
2003         foundAttribute = xmlElement.attributes.find("value");
2004         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH2,
2005                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2006         value = (float) strtod(foundAttribute->second.c_str(), null);
2007
2008         SysTryCatchLabel(NID_UI_EFFECT, index == pVectorToRefill->size(), result = false, CATCH3, E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC);
2009         pVectorToRefill->push_back(value);
2010
2011         return true;
2012
2013 CATCH1:
2014         __buildingModelFailed = true;
2015
2016         return result;
2017
2018 CATCH2:
2019         __buildingModelFailed = true;
2020
2021         return result;
2022
2023 CATCH3:
2024         __buildingModelFailed = true;
2025
2026         return result;
2027 }
2028
2029 bool
2030 EffectParser::CreateGravityForce(XmlElement& xmlElement)
2031 {
2032         bool result = true;
2033         Vec3f gravity = Vec3f(0, 0, 0);
2034         float value = 0.0f;
2035         TypeXmlElementAttributes::iterator foundAttribute;
2036
2037         foundAttribute = xmlElement.attributes.find("x");
2038         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2039         gravity.x = (float) strtod(foundAttribute->second.c_str(), null);
2040
2041         foundAttribute = xmlElement.attributes.find("y");
2042         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2043         gravity.y = (float) strtod(foundAttribute->second.c_str(), null);
2044
2045         foundAttribute = xmlElement.attributes.find("z");
2046         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2047         gravity.z = (float) strtod(foundAttribute->second.c_str(), null);
2048
2049         foundAttribute = xmlElement.attributes.find("abs");
2050         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2051         value = (float) strtod(foundAttribute->second.c_str(), null);
2052
2053         SysTryCatch(NID_UI_EFFECT, value >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2054
2055         __currentGravityForce = gravity;
2056         __currentGravityForceValue = value;
2057
2058         return true;
2059
2060 CATCH:
2061         __buildingModelFailed = true;
2062
2063         return result;
2064 }
2065
2066 bool
2067 EffectParser::ReadViewportData(XmlElement& xmlElement)
2068 {
2069         bool result = true;
2070         TypeXmlElementAttributes::iterator foundAttribute;
2071
2072         foundAttribute = xmlElement.attributes.find("x");
2073         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2074         __currentViewportData.x = (float) strtod(foundAttribute->second.c_str(), null);
2075
2076         foundAttribute = xmlElement.attributes.find("y");
2077         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2078         __currentViewportData.y = (float) strtod(foundAttribute->second.c_str(), null);
2079
2080         foundAttribute = xmlElement.attributes.find("z");
2081         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2082         __currentViewportData.z = (float) strtod(foundAttribute->second.c_str(), null);
2083
2084         foundAttribute = xmlElement.attributes.find("width");
2085         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2086         __currentViewportData.width = (float) strtod(foundAttribute->second.c_str(), null);
2087
2088         foundAttribute = xmlElement.attributes.find("height");
2089         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2090         __currentViewportData.height = (float) strtod(foundAttribute->second.c_str(), null);
2091
2092         foundAttribute = xmlElement.attributes.find("near");
2093         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2094         __currentViewportData.near = (float) strtod(foundAttribute->second.c_str(), null);
2095
2096         foundAttribute = xmlElement.attributes.find("far");
2097         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2098         __currentViewportData.far = (float) strtod(foundAttribute->second.c_str(), null);
2099
2100         foundAttribute = xmlElement.attributes.find("angle");
2101         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2102         __currentViewportData.angle = (float) strtod(foundAttribute->second.c_str(), null);
2103
2104         foundAttribute = xmlElement.attributes.find("perspective");
2105         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2106         if (foundAttribute->second == std::string("true"))
2107         {
2108                 __currentViewportData.perspective = true;
2109         }
2110         else
2111         {
2112                 SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2113         }
2114
2115         SysTryCatch(NID_UI_EFFECT, __currentViewportData.near < __currentViewportData.far, result = false, E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC);
2116
2117         return true;
2118
2119 CATCH:
2120         __buildingModelFailed = true;
2121
2122         return result;
2123 }
2124
2125 bool
2126 EffectParser::PriorReadModelSurfaceData(void)
2127 {
2128         bool result = true;
2129         TypeXmlElementAttributes::iterator foundAttribute;
2130
2131         SysTryCatchLabel(NID_UI_EFFECT, __lastModelSurfaceXMLElementIndex != -1, result = false, CATCH1, E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
2132
2133         foundAttribute = __elementBuffer[__lastModelSurfaceXMLElementIndex].attributes.find("x");
2134         SysTryCatchLabel(NID_UI_EFFECT, (foundAttribute != __elementBuffer[__lastModelSurfaceXMLElementIndex].attributes.end()), result = false, CATCH2,
2135                         E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2136         __currentModelSurfaceX = (float) strtod(foundAttribute->second.c_str(), null);
2137
2138         foundAttribute = __elementBuffer[__lastModelSurfaceXMLElementIndex].attributes.find("y");
2139         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != __elementBuffer[__lastModelSurfaceXMLElementIndex].attributes.end(), result = false, CATCH2,
2140                                 E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2141         __currentModelSurfaceY = (float) strtod(foundAttribute->second.c_str(), null);
2142
2143         return true;
2144
2145 CATCH1:
2146         __buildingModelFailed = true;
2147
2148         return result;
2149
2150 CATCH2:
2151         __buildingModelFailed = true;
2152
2153         return result;
2154 }
2155
2156 bool
2157 EffectParser::PriorReadGraphicalSurfaceData(void)
2158 {
2159         bool result = true;
2160         TypeXmlElementAttributes::iterator foundAttribute;
2161
2162         SysTryCatchLabel(NID_UI_EFFECT, __lastGraphicalSurfaceXMLElementIndex != -1, result = false, CATCH1,
2163                         E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
2164
2165         foundAttribute = __elementBuffer[__lastGraphicalSurfaceXMLElementIndex].attributes.find("dimCtrlX");
2166         SysTryCatchLabel(NID_UI_EFFECT, (foundAttribute != __elementBuffer[__lastGraphicalSurfaceXMLElementIndex].attributes.end()), result = false, CATCH2,
2167                                 E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2168         __currentGraphicalSurfaceDimCtrlX = (unsigned int) strtol(foundAttribute->second.c_str(), null, 10);
2169
2170         foundAttribute = __elementBuffer[__lastGraphicalSurfaceXMLElementIndex].attributes.find("dimCtrlY");
2171         SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != __elementBuffer[__lastGraphicalSurfaceXMLElementIndex].attributes.end(), result = false, CATCH2,
2172                                 E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2173         __currentGraphicalSurfaceDimCtrlY = (unsigned int) strtol(foundAttribute->second.c_str(), null, 10);
2174
2175         return true;
2176
2177 CATCH1:
2178         __buildingModelFailed = true;
2179
2180         return result;
2181
2182 CATCH2:
2183         __buildingModelFailed = true;
2184
2185         return result;
2186 }
2187
2188 bool
2189 EffectParser::PriorReadSceneData(void)
2190 {
2191         bool result = true;
2192         int timerTimeout = 0;
2193         Vec3f ambientColor = __currentSceneData.ambientColor;
2194         float intensity = __currentSceneData.intensity;
2195         float attenuation = __currentSceneData.attenuation;
2196         TypeXmlElementAttributes::iterator foundAttribute;
2197
2198         SysTryCatch(NID_UI_EFFECT, __lastSceneXMLElementIndex != -1, result = false, E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
2199         {
2200                 XmlElement& xmlElement = __elementBuffer[__lastSceneXMLElementIndex];
2201
2202                 foundAttribute = xmlElement.attributes.find("timerTimeout");
2203                 SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2204                 timerTimeout = (int) strtol(foundAttribute->second.c_str(), null, 10);
2205                 SysTryCatch(NID_UI_EFFECT, timerTimeout > 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2206                 __currentSceneData.timerTimeout = (unsigned int) timerTimeout;
2207
2208                 foundAttribute = xmlElement.attributes.find("ambientColor");
2209                 if (foundAttribute != xmlElement.attributes.end())
2210                 {
2211                         std::string stringColor = foundAttribute->second;
2212                         SysTryCatchLabel(NID_UI_EFFECT, *(stringColor.begin()) == '#', result = false, CATCH,
2213                                         E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2214                         SysTryCatchLabel(NID_UI_EFFECT, stringColor.size() == 7, result = false, CATCH,
2215                                         E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2216                         stringColor.erase(stringColor.begin());
2217                         stringColor = "0x" + stringColor;
2218                         ambientColor = StringHexToRgb(stringColor);
2219                 }
2220
2221                 SysTryCatch(NID_UI_EFFECT, (0.0f <= ambientColor.x) && (ambientColor.x <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2222                 SysTryCatch(NID_UI_EFFECT, (0.0f <= ambientColor.y) && (ambientColor.y <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2223                 SysTryCatch(NID_UI_EFFECT, (0.0f <= ambientColor.z) && (ambientColor.z <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2224
2225                 __currentSceneData.ambientColor = ambientColor;
2226
2227                 foundAttribute = xmlElement.attributes.find("intensity");
2228                 if (foundAttribute != xmlElement.attributes.end())
2229                 {
2230                         intensity = (float) strtod(foundAttribute->second.c_str(), null);
2231                         SysTryCatch(NID_UI_EFFECT, (0.0f <= intensity) && (intensity <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2232                         __currentSceneData.intensity = intensity;
2233                 }
2234
2235                 foundAttribute = xmlElement.attributes.find("attenuation");
2236                 if (foundAttribute != xmlElement.attributes.end())
2237                 {
2238                         attenuation = (float) strtod(foundAttribute->second.c_str(), null);
2239                         SysTryCatch(NID_UI_EFFECT, 0.0f <= attenuation, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2240                         __currentSceneData.attenuation = attenuation;
2241                 }
2242         }
2243         return true;
2244
2245 CATCH:
2246         __buildingModelFailed = true;
2247
2248         return result;
2249 }
2250
2251 bool
2252 EffectParser::ReadManifestData(XmlElement& xmlElement)
2253 {
2254         bool result = true;
2255         TypeXmlElementAttributes::iterator foundAttribute;
2256
2257         foundAttribute = xmlElement.attributes.find("name");
2258         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2259         __currentEffectInstanceName = foundAttribute->second;
2260
2261         foundAttribute = xmlElement.attributes.find("behaviorType");
2262         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2263         if (foundAttribute->second == std::string("User controlled"))
2264         {
2265                 __currentModelBehaviourType = EFFECT_TYPE_INTERACTIVE;
2266         }
2267         else
2268         {
2269                 SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("Time based"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2270         }
2271
2272         foundAttribute = xmlElement.attributes.find("timeDuration");
2273         SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
2274         __currentEffectDuration = (TypeTimeEffect) ((float) strtod(foundAttribute->second.c_str(), null)  / 1000.0f);
2275
2276         SysTryCatch(NID_UI_EFFECT, __currentEffectDuration >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2277
2278         return true;
2279
2280 CATCH:
2281         __buildingModelFailed = true;
2282
2283         return result;
2284 }
2285
2286 } } } } // Tizen::Ui::Effects::_EffectParser