2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
23 #include <FBaseSysLog.h>
24 #include <FUiEffects_ParserEffectParser.h>
25 #include "../FUiEffects_EffectErrorMessages.h"
27 #include <FUiEffects_RuntimePointLight.h>
28 #include <FUiEffects_RuntimeSpotLight.h>
29 #include <FUiEffects_RuntimeDirectionalLight.h>
30 #include <FUiEffects_RendererEffectRenderer.h>
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;
37 namespace Tizen { namespace Ui { namespace Effects { namespace _Parser
40 EffectParser* EffectParser::__pInstance = null;
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";
49 FileExists(const char* pPath)
54 file.open(pPath, std::fstream::in);
69 Vec3f EffectParser::StringHexToRgb(const std::string& stringColor)
72 unsigned long int bytes = strtoul(stringColor.c_str(), null, 16);
74 unsigned char nextByte = bytes;
75 rgbColor.z = nextByte / float (UCHAR_MAX);
76 bytes = bytes >> CHAR_BIT;
78 rgbColor.y = nextByte / float (UCHAR_MAX);
79 bytes = bytes >> CHAR_BIT;
81 rgbColor.x = nextByte / float (UCHAR_MAX);
86 EffectParser::SceneData::SceneData()
88 , ambientColor(Vec3f(1.0f, 1.0f, 1.0f))
94 EffectParser::ViewportData::ViewportData()
107 EffectParser::EffectParser(void)
109 , __currentModelFilesDirectoryPath("")
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)
140 __pXmlParser = std::unique_ptr<XmlParser>(new (std::nothrow) XmlParser(this));
142 SysTryReturnVoidResult(NID_UI_EFFECT,
143 __pXmlParser.get() != null,
145 _UiEffectError::OUT_OF_MEMORY
149 EffectParser::~EffectParser(void)
155 EffectParser::ExtractModelFiles(const char* pPath)
159 if (!XmlParser::ExtractFromArchive(pPath, __currentModelFilesDirectoryPath.c_str()))
161 SysLogException(NID_UI_EFFECT, result = false, "Effects. Unzipping of \"%s\" failed!", pPath);
166 std::string sceneFilePath = __currentModelFilesDirectoryPath + __SCENE_FILE_NAME;
167 std::string manifestFilePath = __currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME;
168 std::string scriptFilePath = __currentModelFilesDirectoryPath + __SCRIPT_FILE_NAME;
170 if ( !FileExists(sceneFilePath.c_str()) ||
171 !FileExists(manifestFilePath.c_str()) ||
172 !FileExists(scriptFilePath.c_str()))
174 SysLogException(NID_UI_EFFECT, result = false, "Effects. Effect file is incomplete!", pPath);
182 EffectParser::ParseEffectFile(const char* pEffectFilePath, const char* pModelFilesDirectoryPath)
185 std::string sceneFilePath;
186 std::string manifestFilePath;
188 if (__pInstance == null)
190 __pInstance = new (std::nothrow) EffectParser();
193 SysTryCatchLabel(NID_UI_EFFECT, __pInstance != null, result = false, CATCH1, E_OUT_OF_MEMORY, Tizen::Ui::Effects::_UiEffectError::OUT_OF_MEMORY);
195 SysTryCatchLabel(NID_UI_EFFECT, __pInstance->__pXmlParser != null, result = false, CATCH1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
197 __pInstance->__currentModelFilesDirectoryPath = pModelFilesDirectoryPath;
199 sceneFilePath = __pInstance->__currentModelFilesDirectoryPath + __SCENE_FILE_NAME;
200 manifestFilePath = __pInstance->__currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME;
202 __pInstance->__buildingModelFailed = false;
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);
207 result = __pInstance->__pXmlParser->Parse(manifestFilePath.c_str(), false) && __pInstance->__pXmlParser->Parse(sceneFilePath.c_str(), false);
209 __pInstance->ClearModelFiles(); // should always go before calling _clearBuffers()
210 __pInstance->ClearBuffers(); // not necessary unless XMLParser was sending callbacks by mistake
214 SysLog(NID_UI_EFFECT, "Effects. XML-parsing of the XML-files was successful");
218 SysLog(NID_UI_EFFECT, "Effects. XML-parsing of one of the XML-files failed");
227 __pInstance->ClearModelFiles();
236 EffectParser::ParseEffectFileLoadModel(const char* pEffectFilePath, const char* pModelFilesDirectoryPath,
237 IEffectModelListener* effectsManager, long effectModelID,
238 IEffectModelManager*& pEffectModel, EffectRenderer*& pEffectRenderer, int& modelTimerTimeout)
240 std::unique_ptr<IEffectModelManager> pEffectModelTemp;
241 EffectRendererUniquePtr pRenderer;
242 std::string sceneFilePath;
243 std::string manifestFilePath;
244 result res = E_SUCCESS;
246 if (__pInstance == null)
248 __pInstance = new (std::nothrow) EffectParser();
251 SysTryReturn(NID_UI_EFFECT, __pInstance != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, Tizen::Ui::Effects::_UiEffectError::OUT_OF_MEMORY);
253 SysTryCatchLabel(NID_UI_EFFECT, __pInstance->__pXmlParser != null, , CATCH1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
255 __pInstance->__currentModelFilesDirectoryPath = pModelFilesDirectoryPath;
257 sceneFilePath = __pInstance->__currentModelFilesDirectoryPath + __SCENE_FILE_NAME;
258 manifestFilePath = __pInstance->__currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME;
260 __pInstance->__buildingModelFailed = false;
262 SysTryCatchLabel(NID_UI_EFFECT, __pInstance->ExtractModelFiles(pEffectFilePath), , CATCH2, E_OPERATION_FAILED,
263 Tizen::Ui::Effects::_UiEffectError::EP_EXTRACTING_MODEL_FILES_FAILED);
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;
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()));
306 SysTryCatchLabel(NID_UI_EFFECT, !__pInstance->__buildingModelFailed, , CATCH2, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
308 pEffectModelTemp = std::move(__pInstance->__pCurrentEffectModel);
310 SetLastResult(E_SUCCESS);
312 if(EffectRenderer::CheckOpenGlesInitialized())
314 SysTryCatchLabel(NID_UI_EFFECT, SETJMP == 0, pEffectModelTemp.reset(); pRenderer.reset(); ,
315 CATCH2, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
317 pRenderer = EffectRendererUniquePtr(new (std::nothrow) EffectRenderer());
319 SysTryCatchLabel(NID_UI_EFFECT, pRenderer != null, pEffectModelTemp.reset();,
320 CATCH2, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
322 res = GetLastResult();
324 SysTryCatchLabel(NID_UI_EFFECT, res == E_SUCCESS || res == E_OPERATION_FAILED, pEffectModelTemp.reset(); pRenderer.reset(); ,
325 CATCH2, res, "[%s] Propagating.", GetErrorMessage(res));
327 if (res == E_OPERATION_FAILED)
329 SysLog(NID_UI_EFFECT, "Renderer has invalid context");
330 SetLastResult(E_SUCCESS);
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);
347 pRenderer->Construct(*pEffectModelTemp->GetRenderingData());
349 res = GetLastResult();
350 SysTryCatchLabel(NID_UI_EFFECT, res == E_SUCCESS, pEffectModelTemp.reset(); pRenderer.reset(); ,
351 CATCH2, res, "[%s] Propagating.", GetErrorMessage(res));
355 pEffectRenderer = pRenderer.release();
357 modelTimerTimeout = __pInstance->__currentSceneData.timerTimeout;
359 __pInstance->ClearModelFiles();
360 __pInstance->ClearBuffers();
364 pEffectModel = pEffectModelTemp.release();
366 return GetLastResult();
369 __pInstance->ClearModelFiles();
370 __pInstance->ClearBuffers();
375 return GetLastResult();
379 EffectParser::StartElement(const char* pElementName)
381 if (__buildingModelFailed)
386 std::string elementNameLowerCase(pElementName);
388 XmlElement newElement;
389 newElement.name = elementNameLowerCase;
390 __elementBuffer.push_back(newElement);
392 if (__rightAfterSceneStart)
394 PriorReadSceneData();
395 __rightAfterSceneStart = false;
398 if (__rightAfterModelSurfaceStart)
400 PriorReadModelSurfaceData();
401 __rightAfterModelSurfaceStart = false;
404 if (__rightAfterGraphicalSurfaceStart)
406 PriorReadGraphicalSurfaceData();
407 __rightAfterGraphicalSurfaceStart = false;
410 if (elementNameLowerCase == "Scene")
412 __rightAfterSceneStart = true;
413 __lastSceneXMLElementIndex = (int) __elementBuffer.size() - 1;
418 if (elementNameLowerCase == "Model")
420 __rightAfterModelSurfaceStart = true;
421 __lastModelSurfaceXMLElementIndex = (int) __elementBuffer.size() - 1;
426 if (elementNameLowerCase == "GraphicalSurface")
428 __rightAfterGraphicalSurfaceStart = true;
429 __lastGraphicalSurfaceXMLElementIndex = (int) __elementBuffer.size() - 1;
430 __insideGraphicalSurface = true;
435 if (elementNameLowerCase == "KnotVectorX")
437 __insideVectorX = true;
438 __pCurrentVectorXBuffer = std::unique_ptr<Tizen::Ui::Effects::_Runtime::TypeKnots>(new (std::nothrow) TypeKnots());
440 SysTryCatch(NID_UI_EFFECT, __pCurrentVectorXBuffer != null, , E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
445 if (elementNameLowerCase == "KnotVectorY")
447 __insideVectorY = true;
448 __pCurrentVectorYBuffer = std::unique_ptr<Tizen::Ui::Effects::_Runtime::TypeKnots>(new (std::nothrow) TypeKnots());
450 SysTryCatch(NID_UI_EFFECT, __pCurrentVectorYBuffer != null, , E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY);
455 if (elementNameLowerCase == "ElementsPool")
457 __insideElementsPool = true;
465 __buildingModelFailed = true;
470 EffectParser::EndElement(const char* pElementName)
472 if (__buildingModelFailed)
477 std::string elementName(pElementName);
479 if (__elementBuffer.size() == 0)
481 __buildingModelFailed = true;
483 SysLogException(NID_UI_EFFECT, E_INVALID_STATE, "Effects. [E_INVALID_STATE] Building a model failed: _elementBuffer.size() == 0");
488 int lastElementIndex = (int) __elementBuffer.size() - 1;
490 if (elementName != __elementBuffer[lastElementIndex].name)
492 __buildingModelFailed = true;
494 SysLogException(NID_UI_EFFECT, E_INVALID_ARG, "Effects. [E_INVALID_ARG] Building a model failed: elName != lastElement.name");
499 if (elementName == "ElementsPool")
501 __insideElementsPool = false;
502 __elementBuffer.pop_back();
507 if (__insideElementsPool)
509 __elementBuffer.pop_back();
512 } // _insideElementsPool but not </ElementsPool>
514 if (elementName == "Point")
516 if (__insideGraphicalSurface) // PointSurfaceNURBS
518 CreatePointSurfaceNurbs(__elementBuffer[lastElementIndex]);
520 __elementBuffer.pop_back();
523 } // PointSurfaceNURBS
526 CreatePointSurface(__elementBuffer[lastElementIndex]);
528 __elementBuffer.pop_back();
534 if (elementName == "Spring")
536 CreateSpringSurface(__elementBuffer[lastElementIndex]);
538 __elementBuffer.pop_back();
543 if (elementName == "Rod")
545 CreateRodSurface(__elementBuffer[lastElementIndex]);
547 __elementBuffer.pop_back();
552 if (elementName == "PointLight")
554 CreatePointLight(__elementBuffer[lastElementIndex]);
556 __elementBuffer.pop_back();
561 if (elementName == "SpotLight")
563 CreateSpotLight(__elementBuffer[lastElementIndex]);
565 __elementBuffer.pop_back();
570 if (elementName == "DirectionalLight")
572 CreateDirectionalLight(__elementBuffer[lastElementIndex]);
574 __elementBuffer.pop_back();
577 } // DirectionalLight
579 if (elementName == "ModelsArray")
581 CreateEffectModel(__elementBuffer[lastElementIndex]);
582 __elementBuffer.pop_back();
587 if (elementName == "GraphicalSurface")
589 if (__insideGraphicalSurface)
591 __insideGraphicalSurface = false;
594 CreateGraphicalSurface(__elementBuffer[lastElementIndex]);
596 __elementBuffer.pop_back();
598 __rightAfterGraphicalSurfaceStart = false;
599 __lastGraphicalSurfaceXMLElementIndex = -1;
602 } // GraphicalSurface
604 if (elementName == "KnotVectorX")
608 __insideVectorX = false;
610 __elementBuffer.pop_back();
615 if (elementName == "KnotVectorY")
619 __insideVectorY = false;
621 __elementBuffer.pop_back();
626 if (elementName == "knot")
628 CreateGraphicalSurfaceKnot(__elementBuffer[lastElementIndex]);
629 __elementBuffer.pop_back();
634 if (elementName == "Viewport")
636 ReadViewportData(__elementBuffer[lastElementIndex]);
637 __elementBuffer.pop_back();
642 if (elementName == "GravityForce")
644 CreateGravityForce(__elementBuffer[lastElementIndex]);
645 __elementBuffer.pop_back();
650 if (elementName == "Model")
652 CreateModelSurface(__elementBuffer[lastElementIndex]);
653 __elementBuffer.pop_back();
655 __rightAfterModelSurfaceStart = false;
656 __currentModelSurfaceX = 0;
657 __currentModelSurfaceY = 0;
658 __currentGraphicalSurfaceDimCtrlX = 0;
659 __currentGraphicalSurfaceDimCtrlY = 0;
660 __lastModelSurfaceXMLElementIndex = -1;
665 if (elementName == "Scene")
667 __elementBuffer.pop_back();
669 __rightAfterSceneStart = false;
670 __lastSceneXMLElementIndex = -1;
675 if (elementName == "EffectManifest")
677 ReadManifestData(__elementBuffer[lastElementIndex]);
678 __elementBuffer.pop_back();
684 __elementBuffer.pop_back();
690 EffectParser::Attribute(const char* pAttributeName, const char* pAttributeValue)
692 if (__buildingModelFailed)
697 std::string attributeNameLowerCase(pAttributeName);
699 if (__elementBuffer.size() == 0)
701 __buildingModelFailed = true;
703 SysLogException(NID_UI_EFFECT, E_INVALID_STATE, "Effects. [E_INVALID_STATE] Building a model failed: _elementBuffer.size() == 0 ( %s = %s )",
704 pAttributeName, pAttributeValue);
709 int lastElementIndex = (int) __elementBuffer.size() - 1;
710 __elementBuffer[lastElementIndex].attributes[attributeNameLowerCase] = pAttributeValue;
716 EffectParser::ClearBuffers(void)
718 for (TypePModelSurfaceCollection::iterator it = __modelSurfaceBuffer.begin();
719 it != __modelSurfaceBuffer.end();
722 ModelSurface* pNextModelSurface = *it;
723 if (pNextModelSurface != null)
725 delete pNextModelSurface;
733 for (TypePElementSurfaceCollection::iterator it = __elementSurfaceBuffer.begin();
734 it != __elementSurfaceBuffer.end();
737 ElementSurface* pNextElementSurface = *it;
738 if (pNextElementSurface != null)
740 delete pNextElementSurface;
748 UnitLight::ReleaseObjectsPool();
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;
783 if (__buildingModelFailed)
785 __currentGravityForce = Vec3f(0, 0, 0);
788 __pCurrentVectorXBuffer.reset();
789 __pCurrentVectorYBuffer.reset();
795 EffectParser::ClearModelFiles(void)
797 std::string sceneFilePath = __currentModelFilesDirectoryPath + __SCENE_FILE_NAME;
798 std::string manifestFilePath = __currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME;
799 std::string scriptFilePath = __currentModelFilesDirectoryPath + __SCRIPT_FILE_NAME;
801 remove(sceneFilePath.c_str());
802 remove(manifestFilePath.c_str());
803 remove(scriptFilePath.c_str());
809 EffectParser::FindPointSurfaceById(long pointId) const
811 PointSurface* pResult = null;
813 for (TypePElementSurfaceCollection::const_iterator it = __elementSurfaceBuffer.begin();
814 it != __elementSurfaceBuffer.end();
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))
823 if ((*it)->GetId() == pointId)
825 pResult = dynamic_cast<PointSurface*>((*it));
834 EffectParser::FindPointSurfaceNurbsByIndices(unsigned int row, unsigned int col) const
836 PointSurfaceNurbs* pResult = null;
837 for (TypeNurbsPointIndexDistributor::const_iterator it = __pointSurfaceNurbsIndices.begin();
838 it != __pointSurfaceNurbsIndices.end();
841 if ((it->first.first == row) && (it->first.second == col))
843 pResult = dynamic_cast<PointSurfaceNurbs*>(__elementSurfaceBuffer[it->second]);
852 EffectParser::CreatePointLight(XmlElement& xmlElement)
855 Tizen::Ui::Effects::_Runtime::PointLight* newPointLight = null;
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;
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();
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);
872 // x - coordinate is absolute
873 position.x = (float) strtod(foundAttribute->second.c_str(), null);
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);
879 // y - coordinate is absolute
880 position.y = (float) strtod(foundAttribute->second.c_str(), null);
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 );
886 // z - coordinate is absolute
887 position.z = (float) strtod(foundAttribute->second.c_str(), null);
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);
893 if (foundAttribute->second == std::string("true"))
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);
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);
907 SysTryCatch(NID_UI_EFFECT, intensity >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
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);
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);
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);
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);
931 __unitLightBuffer.push_back(newPointLight);
936 __buildingModelFailed = true;
942 EffectParser::CreateSpotLight(XmlElement& xmlElement)
945 Tizen::Ui::Effects::_Runtime::SpotLight* newSpotLight = null;
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;
956 TypeXmlElementAttributes::iterator foundAttribute;
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();
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);
966 // x - coordinate is absolute
967 position.x = (float) strtod(foundAttribute->second.c_str(), null);
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);
973 // y - coordinate is absolute
974 position.y = (float) strtod(foundAttribute->second.c_str(), null);
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 );
980 // z - coordinate is absolute
981 position.z = (float) strtod(foundAttribute->second.c_str(), null);
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);
987 if (foundAttribute->second == std::string("true"))
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);
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);
1001 SysTryCatch(NID_UI_EFFECT, intensity >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
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);
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);
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);
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);
1025 // x - coordinate is absolute
1026 direction.x = (float) strtod(foundAttribute->second.c_str(), null);
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);
1032 // y - coordinate is absolute
1033 direction.y = (float) strtod(foundAttribute->second.c_str(), null);
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 );
1039 // z - coordinate is absolute
1040 direction.z = (float) strtod(foundAttribute->second.c_str(), null);
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);
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);
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);
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);
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);
1061 __unitLightBuffer.push_back(newSpotLight);
1066 __buildingModelFailed = true;
1072 EffectParser::CreateDirectionalLight(XmlElement& xmlElement)
1075 Tizen::Ui::Effects::_Runtime::DirectionalLight* newDirectionalLight = null;
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;
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();
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);
1092 // x - coordinate is absolute
1093 direction.x = (float) strtod(foundAttribute->second.c_str(), null);
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);
1099 // y - coordinate is absolute
1100 direction.y = (float) strtod(foundAttribute->second.c_str(), null);
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 );
1106 // z - coordinate is absolute
1107 direction.z = (float) strtod(foundAttribute->second.c_str(), null);
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);
1113 if (foundAttribute->second == std::string("true"))
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);
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);
1127 SysTryCatch(NID_UI_EFFECT, intensity >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
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);
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);
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);
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);
1151 __unitLightBuffer.push_back(newDirectionalLight);
1156 __buildingModelFailed = true;
1162 EffectParser::CreatePointSurface(XmlElement& xmlElement)
1165 PointSurface* newPointSurface = null;
1168 Vec3f positionInit(0, 0, 0);
1169 float massInit = 1.0f;
1170 float pointResistance = 0.f;
1172 TypeXmlElementAttributes::iterator foundAttribute;
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);
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);
1183 // x - coordinate is related to the ModelSurface's x-coordinate
1184 positionInit.x = __currentModelSurfaceX + (float) strtod(foundAttribute->second.c_str(), null);
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);
1190 // y - coordinate is related to the ModelSurface's y-coordinate
1191 positionInit.y = __currentModelSurfaceY + (float) strtod(foundAttribute->second.c_str(), null);
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 );
1197 // z - coordinate is absolute
1198 positionInit.z = (float) strtod(foundAttribute->second.c_str(), null);
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);
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);
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);
1214 if (foundAttribute->second == std::string("true"))
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);
1223 SysTryCatch(NID_UI_EFFECT, massInit > 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
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);
1229 __elementSurfaceBuffer.push_back(newPointSurface);
1234 __buildingModelFailed = true;
1240 EffectParser::CreatePointSurfaceNurbs(XmlElement& xmlElement)
1243 PointSurfaceNurbs* newPointSurfaceNurbs = null;
1246 Vec3f positionInit(0, 0, 0);
1247 float massInit = 1.0f;
1248 float weight = 0.0f;
1249 float pointResistance = 2.f;
1251 unsigned int row = 0;
1252 unsigned int col = 0;
1253 TypeXmlElementAttributes::iterator foundAttribute;
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);
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);
1264 // x - coordinate is related to the ModelSurface's x-coordinate
1265 positionInit.x = __currentModelSurfaceX + (float) strtod(foundAttribute->second.c_str(), null);
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 );
1271 // y - coordinate is related to the ModelSurface's y-coordinate
1272 positionInit.y = __currentModelSurfaceY + (float) strtod(foundAttribute->second.c_str(), null);
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);
1278 // z - coordinate is absolute
1279 positionInit.z = (float) strtod(foundAttribute->second.c_str(), null);
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);
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);
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);
1295 if (foundAttribute->second == std::string("true"))
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);
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);
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);
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);
1316 row = (unsigned int) rowValue;
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);
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);
1326 col = (unsigned int) colValue;
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);
1332 SysTryCatchLabel(NID_UI_EFFECT,(col < __currentGraphicalSurfaceDimCtrlX) && (row < __currentGraphicalSurfaceDimCtrlY), result = false, CATCH2,
1333 E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC);
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);
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);
1341 __elementSurfaceBuffer.push_back(newPointSurfaceNurbs);
1343 __pointSurfaceNurbsIndices[std::pair<int, int>(row, col)] = __elementSurfaceBuffer.size() - 1;
1348 __buildingModelFailed = true;
1353 __buildingModelFailed = true;
1358 __buildingModelFailed = true;
1364 EffectParser::CreateSpringSurface(XmlElement& xmlElement)
1367 SpringSurface* newSpringSurface = null;
1370 float stiffness = 0.0f;
1371 PointSurface* pPoint1 = null;
1372 PointSurface* pPoint2 = null;
1373 TypeXmlElementAttributes::iterator foundAttribute;
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);
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 );
1382 long point1ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1383 pPoint1 = FindPointSurfaceById(point1ID);
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);
1389 long point2ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1390 pPoint2 = FindPointSurfaceById(point2ID);
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);
1397 SysTryCatch(NID_UI_EFFECT, stiffness >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1399 // Create a new Spring if all the requests for an attribute succeeded
1400 if ((pPoint1 != null) && (pPoint2 != null) && result)
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);
1405 __elementSurfaceBuffer.push_back(newSpringSurface);
1411 __buildingModelFailed = true;
1413 SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] Building a model failed: error in SpringSurface's attributes");
1419 __buildingModelFailed = true;
1425 EffectParser::CreateRodSurface(XmlElement& xmlElement)
1428 RodSurface* newRodSurface = null;
1431 float stiffness = 0.0f;
1432 PointSurface* pPoint1 = null;
1433 PointSurface* pPoint2 = null;
1434 PointSurface* pPoint3 = null;
1435 TypeXmlElementAttributes::iterator foundAttribute;
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);
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);
1444 long point1ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1445 pPoint1 = FindPointSurfaceById(point1ID);
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);
1451 long point2ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1452 pPoint2 = FindPointSurfaceById(point2ID);
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);
1458 long point3ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1459 pPoint3 = FindPointSurfaceById(point3ID);
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);
1466 SysTryCatch(NID_UI_EFFECT, stiffness >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1468 // Create a new rod if all the requests for an attribute succeeded
1469 if ((pPoint1 != null) && (pPoint2 != null) && (pPoint3 != null) && result)
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);
1474 __elementSurfaceBuffer.push_back(newRodSurface);
1480 __buildingModelFailed = true;
1482 SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] Building a model failed: error in RodSurface's attributes");
1488 __buildingModelFailed = true;
1494 EffectParser::CreateRodSurfaceNurbs(XmlElement& xmlElement)
1497 RodSurfaceNurbs* newRodSurfaceNurbs = null;
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;
1508 foundAttribute = xmlElement.attributes.find("id");
1511 foundAttribute != xmlElement.attributes.end(),
1514 Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND);
1515 id = (long) strtol(foundAttribute->second.c_str(), null, 10);
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);
1520 long point1ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1521 pPoint1 = dynamic_cast<PointSurfaceNurbs*> (FindPointSurfaceById(point1ID));
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);
1527 long point2ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1528 pPoint2 = dynamic_cast<PointSurfaceNurbs*> (FindPointSurfaceById(point2ID));
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);
1534 long point3ID = (long) strtol(foundAttribute->second.c_str(), null, 10);
1535 pPoint3 = dynamic_cast<PointSurfaceNurbs*> (FindPointSurfaceById(point3ID));
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);
1542 SysTryCatch(NID_UI_EFFECT, stiffness >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
1544 if ((pPoint1 != null) && (pPoint2 != null) && (pPoint3 != null))
1546 int tempRow = (int) pPoint2->GetRow() + (int) pPoint2->GetCol() - (int) pPoint1->GetCol();
1547 int tempCol = (int) pPoint2->GetCol() + (int) pPoint1->GetRow() - (int) pPoint2->GetRow();
1549 if (( tempRow < 0 ) ||
1550 ((int) __currentGraphicalSurfaceDimCtrlY - 1 < tempRow) ||
1552 ((int) __currentGraphicalSurfaceDimCtrlX - 1 < tempCol))
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());
1558 normalPointRowIndex = tempRow;
1559 normalPointColIndex = tempCol;
1561 pPoint4 = FindPointSurfaceNurbsByIndices(normalPointRowIndex, normalPointColIndex);
1564 // Create a new rod if all the requests for an attribute succeeded
1565 if ((pPoint1 != null) && (pPoint2 != null) && (pPoint3 != null) && (pPoint4 != null) && result)
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);
1570 __elementSurfaceBuffer.push_back(newRodSurfaceNurbs);
1576 __buildingModelFailed = true;
1578 SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] Building a model failed: _error in RodSurfaceNURBS's attributes");
1584 __buildingModelFailed = true;
1590 EffectParser::CreateGraphicalSurface(XmlElement& xmlElement)
1597 float height = 0.0f;
1598 float transparency = 0.0f;
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;
1607 TypeXmlElementAttributes::iterator foundAttribute;
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);
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);
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);
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);
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);
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);
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);
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);
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);
1643 dimGraphX = (unsigned int) dimGraphXValue;
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 );
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);
1652 dimGraphY = (unsigned int) dimGraphYValue;
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);
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);
1661 dimCtrlX = (unsigned int) dimCtrlXValue;
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);
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);
1670 dimCtrlY = (unsigned int) dimCtrlYValue;
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);
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);
1679 orderX = (unsigned int) orderXValue;
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);
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);
1688 orderY = (unsigned int) orderYValue;
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);
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));
1698 if (__pCurrentGraphicalSurface != null)
1705 __buildingModelFailed = true;
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
1712 __pCurrentVectorXBuffer.reset();
1713 __pCurrentVectorYBuffer.reset();
1719 __buildingModelFailed = true;
1721 __pCurrentVectorXBuffer.reset();
1722 __pCurrentVectorYBuffer.reset();
1728 EffectParser::CreateModelSurface(XmlElement& xmlElement)
1734 float height = 0.0f;
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;
1743 TypeXmlElementAttributes::iterator foundAttribute;
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);
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);
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);
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();
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);
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);
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);
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);
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);
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);
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");
1789 __currentGravityForce = Vec3f(0, 0, 0);
1790 __currentGravityForceValue = 0;
1792 // Now add the ElementSurface objects to a newly created ModelSurface
1794 expectedNurbsPointsCount = __currentGraphicalSurfaceDimCtrlX * __currentGraphicalSurfaceDimCtrlY;
1796 if ((unsigned int) __elementSurfaceBuffer.size() < expectedNurbsPointsCount)
1798 __buildingModelFailed = true;
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");
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)
1809 for (unsigned int colIndex = 0; colIndex < __currentGraphicalSurfaceDimCtrlX; ++colIndex)
1811 TypeNurbsPointIndexDistributor::iterator indexIt;
1813 indexIt = __pointSurfaceNurbsIndices.find(std::pair<int, int>(rowIndex, colIndex));
1814 if (indexIt != __pointSurfaceNurbsIndices.end())
1816 unsigned int pointNurbsIndex = indexIt->second;
1818 if (pointNurbsIndex < expectedNurbsPointsCount)
1820 TypePElementSurfaceCollection::iterator pointNurbsIterator =
1821 beginIt + pointNurbsIndex;
1823 if ((*pointNurbsIterator)->GetType() == ESURFACE_POINT_SURFACE_NURBS)
1825 newModelSurface->AddElementSurface(*pointNurbsIterator);
1829 __buildingModelFailed = true;
1831 SysLogException(NID_UI_EFFECT, E_INVALID_FORMAT,"Effects. [E_INVALID_FORMAT] _elementSurfaceBuffer.begin() + %i is not a PointSurfaceNURBS",
1837 __buildingModelFailed = true;
1839 SysLogException(NID_UI_EFFECT, E_INVALID_FORMAT, "Effects. [E_INVALID_FORMAT] pointNurbsIndex = %i is >= expectedNumberOfNurbsPoints = %i",
1840 pointNurbsIndex, expectedNurbsPointsCount);
1845 __buildingModelFailed = true;
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);
1853 // now add all the Elementsurface objects going after PointSurfaceNURBS objects
1854 if (!__buildingModelFailed)
1856 for (TypePElementSurfaceCollection::iterator it = __elementSurfaceBuffer.begin() + expectedNurbsPointsCount;
1857 it != __elementSurfaceBuffer.end();
1860 newModelSurface->AddElementSurface(*it);
1865 __pointSurfaceNurbsIndices.clear();
1866 __elementSurfaceBuffer.clear();
1868 // set Graphical surface
1869 newModelSurface->AddGraphicalSurface(std::move(__pCurrentGraphicalSurface));
1871 __pCurrentGraphicalSurface = null;
1873 // Add created ModelSurface to the list
1874 __modelSurfaceBuffer.push_back(newModelSurface);
1881 __buildingModelFailed = true;
1883 __pointSurfaceNurbsIndices.clear();
1884 __elementSurfaceBuffer.clear();
1890 EffectParser::CreateEffectModel(XmlElement& xmlElement)
1894 std::string pathToScript = __currentModelFilesDirectoryPath + __SCRIPT_FILE_NAME;
1896 SetLastResult(E_SUCCESS);
1898 __pCurrentEffectModel = std::unique_ptr<_Runtime::EffectModel>(new (std::nothrow) _Runtime::EffectModel(
1899 __currentEffectId, __currentEffectInstanceName, pathToScript.c_str(), __pCurrentEffectManager, __currentModelBehaviourType, __currentEffectDuration));
1901 if (__pCurrentEffectModel != null)
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
1913 if (GetLastResult() != E_SUCCESS)
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()));
1922 if ((__pCurrentEffectModel != null) && (GetLastResult() == E_SUCCESS))
1924 for (TypePModelSurfaceCollection::iterator it = __modelSurfaceBuffer.begin();
1925 it != __modelSurfaceBuffer.end();
1928 __pCurrentEffectModel->AddModelSurface(*it);
1931 __modelSurfaceBuffer.clear();
1933 RenderDataScene* pRenderDataScene = __pCurrentEffectModel->GetRenderingData();
1935 // in case there was no light sources described inthe scene a single directional light should be set
1936 if (__unitLightBuffer.size() == 0)
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);
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);
1948 for (TypePUnitLightCollection::iterator it = __unitLightBuffer.begin();
1949 it != __unitLightBuffer.end();
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);
1957 __unitLightBuffer.clear();
1959 pRenderDataScene->SetLightAmbientColour(__currentSceneData.ambientColor);
1960 pRenderDataScene->SetLightIntensity(__currentSceneData.intensity);
1961 pRenderDataScene->SetLightAttenuation(__currentSceneData.attenuation);
1963 __pCurrentEffectModel->Construct();
1969 __buildingModelFailed = true;
1975 EffectParser::CreateGraphicalSurfaceKnot(XmlElement& xmlElement)
1978 Tizen::Ui::Effects::_Runtime::TypeKnots* pVectorToRefill = null;
1979 unsigned int index = 0;
1981 TypeXmlElementAttributes::iterator foundAttribute;
1983 if (__insideVectorX)
1985 pVectorToRefill = __pCurrentVectorXBuffer.get();
1987 else if (__insideVectorY)
1989 pVectorToRefill = __pCurrentVectorYBuffer.get();
1996 SysTryCatchLabel(NID_UI_EFFECT, pVectorToRefill != null, result = false, CATCH1, E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
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);
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);
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);
2014 __buildingModelFailed = true;
2019 __buildingModelFailed = true;
2024 __buildingModelFailed = true;
2030 EffectParser::CreateGravityForce(XmlElement& xmlElement)
2033 Vec3f gravity = Vec3f(0, 0, 0);
2035 TypeXmlElementAttributes::iterator foundAttribute;
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);
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);
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);
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);
2053 SysTryCatch(NID_UI_EFFECT, value >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2055 __currentGravityForce = gravity;
2056 __currentGravityForceValue = value;
2061 __buildingModelFailed = true;
2067 EffectParser::ReadViewportData(XmlElement& xmlElement)
2070 TypeXmlElementAttributes::iterator foundAttribute;
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);
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);
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);
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);
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);
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);
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);
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);
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"))
2108 __currentViewportData.perspective = true;
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);
2115 SysTryCatch(NID_UI_EFFECT, __currentViewportData.near < __currentViewportData.far, result = false, E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC);
2120 __buildingModelFailed = true;
2126 EffectParser::PriorReadModelSurfaceData(void)
2129 TypeXmlElementAttributes::iterator foundAttribute;
2131 SysTryCatchLabel(NID_UI_EFFECT, __lastModelSurfaceXMLElementIndex != -1, result = false, CATCH1, E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
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);
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);
2146 __buildingModelFailed = true;
2151 __buildingModelFailed = true;
2157 EffectParser::PriorReadGraphicalSurfaceData(void)
2160 TypeXmlElementAttributes::iterator foundAttribute;
2162 SysTryCatchLabel(NID_UI_EFFECT, __lastGraphicalSurfaceXMLElementIndex != -1, result = false, CATCH1,
2163 E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
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);
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);
2178 __buildingModelFailed = true;
2183 __buildingModelFailed = true;
2189 EffectParser::PriorReadSceneData(void)
2192 int timerTimeout = 0;
2193 Vec3f ambientColor = __currentSceneData.ambientColor;
2194 float intensity = __currentSceneData.intensity;
2195 float attenuation = __currentSceneData.attenuation;
2196 TypeXmlElementAttributes::iterator foundAttribute;
2198 SysTryCatch(NID_UI_EFFECT, __lastSceneXMLElementIndex != -1, result = false, E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED);
2200 XmlElement& xmlElement = __elementBuffer[__lastSceneXMLElementIndex];
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;
2208 foundAttribute = xmlElement.attributes.find("ambientColor");
2209 if (foundAttribute != xmlElement.attributes.end())
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);
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);
2225 __currentSceneData.ambientColor = ambientColor;
2227 foundAttribute = xmlElement.attributes.find("intensity");
2228 if (foundAttribute != xmlElement.attributes.end())
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;
2235 foundAttribute = xmlElement.attributes.find("attenuation");
2236 if (foundAttribute != xmlElement.attributes.end())
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;
2246 __buildingModelFailed = true;
2252 EffectParser::ReadManifestData(XmlElement& xmlElement)
2255 TypeXmlElementAttributes::iterator foundAttribute;
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;
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"))
2265 __currentModelBehaviourType = EFFECT_TYPE_INTERACTIVE;
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);
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);
2276 SysTryCatch(NID_UI_EFFECT, __currentEffectDuration >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE);
2281 __buildingModelFailed = true;
2286 } } } } // Tizen::Ui::Effects::_EffectParser