[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / model-motion / motion-index / motion-transform-index-impl.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-scene3d/internal/model-motion/motion-index/motion-transform-index-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/type-registry-helper.h>
24 #include <dali/public-api/object/type-registry.h>
25
26 // INTERNAL INCLUDES
27
28 namespace Dali
29 {
30 namespace Scene3D
31 {
32 namespace Internal
33 {
34 namespace
35 {
36 /**
37  * Creates control through type registry
38  */
39 BaseHandle Create()
40 {
41   return Scene3D::MotionTransformIndex::New();
42 }
43
44 // Setup properties, signals and actions using the type-registry.
45 DALI_TYPE_REGISTRATION_BEGIN(Scene3D::MotionTransformIndex, Dali::BaseHandle, Create);
46 DALI_TYPE_REGISTRATION_END()
47 } // namespace
48
49 MotionTransformIndexPtr MotionTransformIndex::New()
50 {
51   MotionTransformIndexPtr motionTransformIndex = new MotionTransformIndex();
52
53   motionTransformIndex->Initialize();
54
55   return motionTransformIndex;
56 }
57
58 MotionTransformIndex::MotionTransformIndex()
59 {
60 }
61
62 MotionTransformIndex::~MotionTransformIndex()
63 {
64 }
65
66 void MotionTransformIndex::Initialize()
67 {
68 }
69
70 void MotionTransformIndex::SetTransformType(Scene3D::MotionTransformIndex::TransformType type)
71 {
72   mTransformType = type;
73 }
74
75 Scene3D::MotionTransformIndex::TransformType MotionTransformIndex::GetTransformType() const
76 {
77   return mTransformType;
78 }
79
80 std::string MotionTransformIndex::GetPropertyName(Scene3D::ModelNode node)
81 {
82   using TransformType = Scene3D::MotionTransformIndex::TransformType;
83
84   switch(mTransformType)
85   {
86     case TransformType::POSITION:
87     {
88       return "position";
89     }
90     case TransformType::POSITION_X:
91     {
92       return "positionX";
93     }
94     case TransformType::POSITION_Y:
95     {
96       return "positionY";
97     }
98     case TransformType::POSITION_Z:
99     {
100       return "positionZ";
101     }
102     case TransformType::ORIENTATION:
103     {
104       return "orientation";
105     }
106     case TransformType::SCALE:
107     {
108       return "scale";
109     }
110     case TransformType::SCALE_X:
111     {
112       return "scaleX";
113     }
114     case TransformType::SCALE_Y:
115     {
116       return "scaleY";
117     }
118     case TransformType::SCALE_Z:
119     {
120       return "scaleZ";
121     }
122     default:
123     {
124       DALI_LOG_ERROR("Invalid transform type used\n");
125       return "";
126     }
127   }
128 }
129
130 Property::Index MotionTransformIndex::GetPropertyIndex(Scene3D::ModelNode node)
131 {
132   using TransformType = Scene3D::MotionTransformIndex::TransformType;
133
134   switch(mTransformType)
135   {
136     case TransformType::POSITION:
137     {
138       return Dali::Actor::Property::POSITION;
139     }
140     case TransformType::POSITION_X:
141     {
142       return Dali::Actor::Property::POSITION_X;
143     }
144     case TransformType::POSITION_Y:
145     {
146       return Dali::Actor::Property::POSITION_Y;
147     }
148     case TransformType::POSITION_Z:
149     {
150       return Dali::Actor::Property::POSITION_Z;
151     }
152     case TransformType::ORIENTATION:
153     {
154       return Dali::Actor::Property::ORIENTATION;
155     }
156     case TransformType::SCALE:
157     {
158       return Dali::Actor::Property::SCALE;
159     }
160     case TransformType::SCALE_X:
161     {
162       return Dali::Actor::Property::SCALE_X;
163     }
164     case TransformType::SCALE_Y:
165     {
166       return Dali::Actor::Property::SCALE_Y;
167     }
168     case TransformType::SCALE_Z:
169     {
170       return Dali::Actor::Property::SCALE_Z;
171     }
172     default:
173     {
174       DALI_LOG_ERROR("Invalid transform type used\n");
175       return Property::INVALID_INDEX;
176     }
177   }
178 }
179
180 } // namespace Internal
181
182 } // namespace Scene3D
183
184 } // namespace Dali