(Scene3D) Allow/Block model view's children hit-test events
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / src / model-wrap.cpp
1 /*
2  * Copyright (c) 2022 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 // EXTERNAL INCLUDES
19 #include <dali-scene3d/public-api/controls/model/model.h>
20
21 // INTERNAL INCLUDES
22 #include "common.h"
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_New_SWIG_0(char* csModelPath, char* csResourcePath)
29 {
30   Dali::Scene3D::Model result;
31
32   if(!csModelPath)
33   {
34     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
35     return 0;
36   }
37   std::string modelPath(csModelPath);
38
39   if(!csResourcePath)
40   {
41     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
42     return 0;
43   }
44   std::string resourcePath(csResourcePath);
45
46   {
47     try
48     {
49       result = Dali::Scene3D::Model::New(modelPath, resourcePath);
50     }
51     CALL_CATCH_EXCEPTION(0);
52   }
53
54   return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
55 }
56
57 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Model_SWIG_0()
58 {
59   Dali::Scene3D::Model* result = 0;
60
61   {
62     try
63     {
64       result = (Dali::Scene3D::Model*)new Dali::Scene3D::Model();
65     }
66     CALL_CATCH_EXCEPTION(0);
67   }
68
69   return (void*)result;
70 }
71
72 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Model_SWIG_1(void* csModel)
73 {
74   Dali::Scene3D::Model* model  = (Dali::Scene3D::Model*)csModel;
75   Dali::Scene3D::Model* result = 0;
76
77   if(!model)
78   {
79     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Scene3D::Model const & type is null", 0);
80     return 0;
81   }
82   {
83     try
84     {
85       result = (Dali::Scene3D::Model*)new Dali::Scene3D::Model((Dali::Scene3D::Model const&)*model);
86     }
87     CALL_CATCH_EXCEPTION(0);
88   }
89
90   return (void*)result;
91 }
92
93 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_Model(void* csModel)
94 {
95   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
96   {
97     try
98     {
99       delete model;
100     }
101     CALL_CATCH_EXCEPTION();
102   }
103 }
104
105 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_Assign(void* csDestination, void* csSource)
106 {
107   Dali::Scene3D::Model* destination = (Dali::Scene3D::Model*)csDestination;
108   Dali::Scene3D::Model* source      = (Dali::Scene3D::Model*)csSource;
109   Dali::Scene3D::Model* result      = 0;
110
111   if(!source)
112   {
113     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Scene3D::Model const & type is null", 0);
114     return 0;
115   }
116   {
117     try
118     {
119       result = (Dali::Scene3D::Model*)&(destination)->operator=((Dali::Scene3D::Model const&)*source);
120     }
121     CALL_CATCH_EXCEPTION(0);
122   }
123
124   return (void*)result;
125 }
126
127 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_DownCast(void* csHandle)
128 {
129   Dali::BaseHandle*    handle = (Dali::BaseHandle*)csHandle;
130   Dali::Scene3D::Model result;
131
132   if(!handle)
133   {
134     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
135     return 0;
136   }
137   {
138     try
139     {
140       result = Dali::Scene3D::Model::DownCast(*handle);
141     }
142     CALL_CATCH_EXCEPTION(0);
143   }
144
145   return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
146 }
147
148 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetModelRoot(void* csModel)
149 {
150   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
151   Dali::Actor           result;
152
153   if(!model)
154   {
155     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
156     return 0;
157   }
158   {
159     try
160     {
161       result = model->GetModelRoot();
162     }
163     CALL_CATCH_EXCEPTION(0);
164   }
165
166   return new Dali::Actor((const Dali::Actor&)result);
167 }
168
169 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetChildrenSensitive(void* csModel, bool enable)
170 {
171   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
172
173   if(!model)
174   {
175     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
176     return;
177   }
178   {
179     try
180     {
181       model->SetChildrenSensitive(enable);
182     }
183     CALL_CATCH_EXCEPTION();
184   }
185 }
186
187 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_Model_GetChildrenSensitive(void* csModel)
188 {
189   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
190   bool                  result;
191
192   if(!model)
193   {
194     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
195     return false;
196   }
197   {
198     try
199     {
200       result = model->GetChildrenSensitive();
201     }
202     CALL_CATCH_EXCEPTION(0);
203   }
204   return result;
205 }
206
207 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetImageBasedLightSource(void* csModel, char* csDiffuseUrl, char* csSpecularUrl, float scaleFactor)
208 {
209   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
210
211   if(!model)
212   {
213     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
214     return;
215   }
216   if(!csDiffuseUrl)
217   {
218     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
219     return;
220   }
221   std::string diffuseUrl(csDiffuseUrl);
222   if(!csSpecularUrl)
223   {
224     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
225     return;
226   }
227   std::string specularUrl(csSpecularUrl);
228   {
229     try
230     {
231       model->SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
232     }
233     CALL_CATCH_EXCEPTION();
234   }
235 }
236
237 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetImageBasedLightScaleFactor(void* csModel, float scaleFactor)
238 {
239   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
240
241   if(!model)
242   {
243     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
244     return;
245   }
246   {
247     try
248     {
249       model->SetImageBasedLightScaleFactor(scaleFactor);
250     }
251     CALL_CATCH_EXCEPTION();
252   }
253 }
254
255 SWIGEXPORT float SWIGSTDCALL CSharp_Dali_Model_GetImageBasedLightScaleFactor(void* csModel)
256 {
257   Dali::Scene3D::Model* model       = (Dali::Scene3D::Model*)csModel;
258   float                 scaleFactor = 1.0f;
259
260   if(!model)
261   {
262     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
263     return scaleFactor;
264   }
265   {
266     try
267     {
268       scaleFactor = model->GetImageBasedLightScaleFactor();
269     }
270     CALL_CATCH_EXCEPTION(0.0f);
271   }
272   return scaleFactor;
273 }
274
275 SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Model_GetAnimationCount(void* csModel)
276 {
277   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
278   unsigned int          result;
279
280   if(!model)
281   {
282     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
283     return 0;
284   }
285   {
286     try
287     {
288       result = model->GetAnimationCount();
289     }
290     CALL_CATCH_EXCEPTION(0);
291   }
292
293   return result;
294 }
295
296 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetAnimation_1(void* csModel, unsigned int index)
297 {
298   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
299   Dali::Animation       result;
300
301   if(!model)
302   {
303     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
304     return 0;
305   }
306   {
307     try
308     {
309       result = model->GetAnimation(index);
310     }
311     CALL_CATCH_EXCEPTION(0);
312   }
313
314   return new Dali::Animation((const Dali::Animation&)result);
315 }
316
317 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetAnimation_2(void* csModel, char* csName)
318 {
319   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
320   Dali::Animation       result;
321
322   if(!model)
323   {
324     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
325     return 0;
326   }
327   if(!csName)
328   {
329     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
330     return 0;
331   }
332   std::string name(csName);
333   {
334     try
335     {
336       result = model->GetAnimation(name);
337     }
338     CALL_CATCH_EXCEPTION(0);
339   }
340
341   return new Dali::Animation((const Dali::Animation&)result);
342 }
343
344 #ifdef __cplusplus
345 }
346 #endif