[NUI] Fix Svace issue (#949)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Camera.cs
1 /*
2  * Copyright(c) 2017 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 namespace Tizen.NUI
19 {
20
21     internal class Camera : Animatable
22     {
23         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
24
25         internal Camera(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.CameraActor.CameraActor_SWIGUpcast(cPtr), cMemoryOwn)
26         {
27             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
28         }
29
30         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Camera obj)
31         {
32             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
33         }
34
35         protected override void Dispose(DisposeTypes type)
36         {
37             if (disposed)
38             {
39                 return;
40             }
41
42             if (type == DisposeTypes.Explicit)
43             {
44                 //Called by User
45                 //Release your own managed resources here.
46                 //You should release all of your own disposable objects here.
47
48             }
49
50             //Release your own unmanaged resources here.
51             //You should not access any managed member here except static instance.
52             //because the execution order of Finalizes is non-deterministic.
53
54             if (swigCPtr.Handle != global::System.IntPtr.Zero)
55             {
56                 if (swigCMemOwn)
57                 {
58                     swigCMemOwn = false;
59                     Interop.CameraActor.delete_CameraActor(swigCPtr);
60                 }
61                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
62             }
63
64             base.Dispose(type);
65         }
66
67
68
69         /// <since_tizen> 3 </since_tizen>
70         public class Property : global::System.IDisposable
71         {
72             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
73             /// <since_tizen> 3 </since_tizen>
74             protected bool swigCMemOwn;
75
76             internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
77             {
78                 swigCMemOwn = cMemoryOwn;
79                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
80             }
81
82             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
83             {
84                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
85             }
86
87             //A Flag to check who called Dispose(). (By User or DisposeQueue)
88             private bool isDisposeQueued = false;
89             //A Flat to check if it is already disposed.
90             /// <since_tizen> 3 </since_tizen>
91             protected bool disposed = false;
92
93             ~Property()
94             {
95                 if (!isDisposeQueued)
96                 {
97                     isDisposeQueued = true;
98                     DisposeQueue.Instance.Add(this);
99                 }
100             }
101
102             /// <since_tizen> 3 </since_tizen>
103             public void Dispose()
104             {
105                 //Throw excpetion if Dispose() is called in separate thread.
106                 if (!Window.IsInstalled())
107                 {
108                     throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
109                 }
110
111                 if (isDisposeQueued)
112                 {
113                     Dispose(DisposeTypes.Implicit);
114                 }
115                 else
116                 {
117                     Dispose(DisposeTypes.Explicit);
118                     System.GC.SuppressFinalize(this);
119                 }
120             }
121
122             /// <since_tizen> 3 </since_tizen>
123             protected virtual void Dispose(DisposeTypes type)
124             {
125                 if (disposed)
126                 {
127                     return;
128                 }
129
130                 if (type == DisposeTypes.Explicit)
131                 {
132                     //Called by User
133                     //Release your own managed resources here.
134                     //You should release all of your own disposable objects here.
135
136                 }
137
138                 //Release your own unmanaged resources here.
139                 //You should not access any managed member here except static instance.
140                 //because the execution order of Finalizes is non-deterministic.
141
142                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
143                 {
144                     if (swigCMemOwn)
145                     {
146                         swigCMemOwn = false;
147                         Interop.CameraActor.delete_CameraActor_Property(swigCPtr);
148                     }
149                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
150                 }
151
152                 disposed = true;
153             }
154
155
156             /// <since_tizen> 3 </since_tizen>
157             public Property() : this(Interop.CameraActor.new_CameraActor_Property(), true)
158             {
159                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160             }
161
162             /// <since_tizen> 3 </since_tizen>
163             public static readonly int TYPE = Interop.CameraActor.CameraActor_Property_TYPE_get();
164             /// <since_tizen> 3 </since_tizen>
165             public static readonly int PROJECTION_MODE = Interop.CameraActor.CameraActor_Property_PROJECTION_MODE_get();
166             /// <since_tizen> 3 </since_tizen>
167             public static readonly int FIELD_OF_VIEW = Interop.CameraActor.CameraActor_Property_FIELD_OF_VIEW_get();
168             /// <since_tizen> 3 </since_tizen>
169             public static readonly int ASPECT_RATIO = Interop.CameraActor.CameraActor_Property_ASPECT_RATIO_get();
170             /// <since_tizen> 3 </since_tizen>
171             public static readonly int NEAR_PLANE_DISTANCE = Interop.CameraActor.CameraActor_Property_NEAR_PLANE_DISTANCE_get();
172             /// <since_tizen> 3 </since_tizen>
173             public static readonly int FAR_PLANE_DISTANCE = Interop.CameraActor.CameraActor_Property_FAR_PLANE_DISTANCE_get();
174             /// <since_tizen> 3 </since_tizen>
175             public static readonly int LEFT_PLANE_DISTANCE = Interop.CameraActor.CameraActor_Property_LEFT_PLANE_DISTANCE_get();
176             /// <since_tizen> 3 </since_tizen>
177             public static readonly int RIGHT_PLANE_DISTANCE = Interop.CameraActor.CameraActor_Property_RIGHT_PLANE_DISTANCE_get();
178             /// <since_tizen> 3 </since_tizen>
179             public static readonly int TOP_PLANE_DISTANCE = Interop.CameraActor.CameraActor_Property_TOP_PLANE_DISTANCE_get();
180             /// <since_tizen> 3 </since_tizen>
181             public static readonly int BOTTOM_PLANE_DISTANCE = Interop.CameraActor.CameraActor_Property_BOTTOM_PLANE_DISTANCE_get();
182             /// <since_tizen> 3 </since_tizen>
183             public static readonly int TARGET_POSITION = Interop.CameraActor.CameraActor_Property_TARGET_POSITION_get();
184             /// <since_tizen> 3 </since_tizen>
185             public static readonly int PROJECTION_MATRIX = Interop.CameraActor.CameraActor_Property_PROJECTION_MATRIX_get();
186             /// <since_tizen> 3 </since_tizen>
187             public static readonly int VIEW_MATRIX = Interop.CameraActor.CameraActor_Property_VIEW_MATRIX_get();
188             /// <since_tizen> 3 </since_tizen>
189             public static readonly int INVERT_Y_AXIS = Interop.CameraActor.CameraActor_Property_INVERT_Y_AXIS_get();
190
191         }
192
193         public Camera() : this(Interop.CameraActor.CameraActor_New__SWIG_0(), true)
194         {
195             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196
197         }
198         public Camera(Vector2 size) : this(Interop.CameraActor.CameraActor_New__SWIG_1(Vector2.getCPtr(size)), true)
199         {
200             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201
202         }
203         public static Camera DownCast(BaseHandle handle)
204         {
205             Camera ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Camera;
206             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207             return ret;
208         }
209
210         public Camera(Camera copy) : this(Interop.CameraActor.new_CameraActor__SWIG_1(Camera.getCPtr(copy)), true)
211         {
212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213         }
214
215         public Camera Assign(Camera rhs)
216         {
217             Camera ret = new Camera(Interop.CameraActor.CameraActor_Assign(swigCPtr, Camera.getCPtr(rhs)), false);
218             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219             return ret;
220         }
221
222         public void SetType(CameraType type)
223         {
224             Interop.CameraActor.CameraActor_SetType(swigCPtr, (int)type);
225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226         }
227
228         public new CameraType GetType()
229         {
230             CameraType ret = (CameraType)Interop.CameraActor.CameraActor_GetType(swigCPtr);
231             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232             return ret;
233         }
234
235         public void SetProjectionMode(ProjectionMode mode)
236         {
237             Interop.CameraActor.CameraActor_SetProjectionMode(swigCPtr, (int)mode);
238             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239         }
240
241         public ProjectionMode GetProjectionMode()
242         {
243             ProjectionMode ret = (ProjectionMode)Interop.CameraActor.CameraActor_GetProjectionMode(swigCPtr);
244             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245             return ret;
246         }
247
248         public void SetFieldOfView(float fieldOfView)
249         {
250             Interop.CameraActor.CameraActor_SetFieldOfView(swigCPtr, fieldOfView);
251             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252         }
253
254         public float GetFieldOfView()
255         {
256             float ret = Interop.CameraActor.CameraActor_GetFieldOfView(swigCPtr);
257             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258             return ret;
259         }
260
261         public void SetAspectRatio(float aspectRatio)
262         {
263             Interop.CameraActor.CameraActor_SetAspectRatio(swigCPtr, aspectRatio);
264             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265         }
266
267         public float GetAspectRatio()
268         {
269             float ret = Interop.CameraActor.CameraActor_GetAspectRatio(swigCPtr);
270             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271             return ret;
272         }
273
274         public void SetNearClippingPlane(float nearClippingPlane)
275         {
276             Interop.CameraActor.CameraActor_SetNearClippingPlane(swigCPtr, nearClippingPlane);
277             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278         }
279
280         public float GetNearClippingPlane()
281         {
282             float ret = Interop.CameraActor.CameraActor_GetNearClippingPlane(swigCPtr);
283             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284             return ret;
285         }
286
287         public void SetFarClippingPlane(float farClippingPlane)
288         {
289             Interop.CameraActor.CameraActor_SetFarClippingPlane(swigCPtr, farClippingPlane);
290             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
291         }
292
293         public float GetFarClippingPlane()
294         {
295             float ret = Interop.CameraActor.CameraActor_GetFarClippingPlane(swigCPtr);
296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297             return ret;
298         }
299
300         public void SetTargetPosition(Vector3 targetPosition)
301         {
302             Interop.CameraActor.CameraActor_SetTargetPosition(swigCPtr, Vector3.getCPtr(targetPosition));
303             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304         }
305
306         public Vector3 GetTargetPosition()
307         {
308             Vector3 ret = new Vector3(Interop.CameraActor.CameraActor_GetTargetPosition(swigCPtr), true);
309             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310             return ret;
311         }
312
313         public void SetInvertYAxis(bool invertYAxis)
314         {
315             Interop.CameraActor.CameraActor_SetInvertYAxis(swigCPtr, invertYAxis);
316             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317         }
318
319         public bool GetInvertYAxis()
320         {
321             bool ret = Interop.CameraActor.CameraActor_GetInvertYAxis(swigCPtr);
322             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323             return ret;
324         }
325
326         public void SetPerspectiveProjection(Vector2 size)
327         {
328             Interop.CameraActor.CameraActor_SetPerspectiveProjection(swigCPtr, Vector2.getCPtr(size));
329             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330         }
331
332         public void SetOrthographicProjection(Vector2 size)
333         {
334             Interop.CameraActor.CameraActor_SetOrthographicProjection__SWIG_0(swigCPtr, Vector2.getCPtr(size));
335             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336         }
337
338         public void SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far)
339         {
340             Interop.CameraActor.CameraActor_SetOrthographicProjection__SWIG_1(swigCPtr, left, right, top, bottom, near, far);
341             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
342         }
343
344         public string Type
345         {
346             get
347             {
348                 string temp;
349                 GetProperty(Camera.Property.TYPE).Get(out temp);
350                 return temp;
351             }
352             set
353             {
354                 SetProperty(Camera.Property.TYPE, new Tizen.NUI.PropertyValue(value));
355             }
356         }
357         public string ProjectionMode
358         {
359             get
360             {
361                 string temp;
362                 GetProperty(Camera.Property.PROJECTION_MODE).Get(out temp);
363                 return temp;
364             }
365             set
366             {
367                 SetProperty(Camera.Property.PROJECTION_MODE, new Tizen.NUI.PropertyValue(value));
368             }
369         }
370         public float FieldOfView
371         {
372             get
373             {
374                 float temp = 0.0f;
375                 GetProperty(Camera.Property.FIELD_OF_VIEW).Get(out temp);
376                 return temp;
377             }
378             set
379             {
380                 SetProperty(Camera.Property.FIELD_OF_VIEW, new Tizen.NUI.PropertyValue(value));
381             }
382         }
383         public float AspectRatio
384         {
385             get
386             {
387                 float temp = 0.0f;
388                 GetProperty(Camera.Property.ASPECT_RATIO).Get(out temp);
389                 return temp;
390             }
391             set
392             {
393                 SetProperty(Camera.Property.ASPECT_RATIO, new Tizen.NUI.PropertyValue(value));
394             }
395         }
396         public float NearPlaneDistance
397         {
398             get
399             {
400                 float temp = 0.0f;
401                 GetProperty(Camera.Property.NEAR_PLANE_DISTANCE).Get(out temp);
402                 return temp;
403             }
404             set
405             {
406                 SetProperty(Camera.Property.NEAR_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
407             }
408         }
409         public float FarPlaneDistance
410         {
411             get
412             {
413                 float temp = 0.0f;
414                 GetProperty(Camera.Property.FAR_PLANE_DISTANCE).Get(out temp);
415                 return temp;
416             }
417             set
418             {
419                 SetProperty(Camera.Property.FAR_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
420             }
421         }
422         public float LeftPlaneDistance
423         {
424             get
425             {
426                 float temp = 0.0f;
427                 GetProperty(Camera.Property.LEFT_PLANE_DISTANCE).Get(out temp);
428                 return temp;
429             }
430             set
431             {
432                 SetProperty(Camera.Property.LEFT_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
433             }
434         }
435         public float RightPlaneDistance
436         {
437             get
438             {
439                 float temp = 0.0f;
440                 GetProperty(Camera.Property.RIGHT_PLANE_DISTANCE).Get(out temp);
441                 return temp;
442             }
443             set
444             {
445                 SetProperty(Camera.Property.RIGHT_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
446             }
447         }
448         public float TopPlaneDistance
449         {
450             get
451             {
452                 float temp = 0.0f;
453                 GetProperty(Camera.Property.TOP_PLANE_DISTANCE).Get(out temp);
454                 return temp;
455             }
456             set
457             {
458                 SetProperty(Camera.Property.TOP_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
459             }
460         }
461         public float BottomPlaneDistance
462         {
463             get
464             {
465                 float temp = 0.0f;
466                 GetProperty(Camera.Property.BOTTOM_PLANE_DISTANCE).Get(out temp);
467                 return temp;
468             }
469             set
470             {
471                 SetProperty(Camera.Property.BOTTOM_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
472             }
473         }
474         public Vector3 TargetPosition
475         {
476             get
477             {
478                 Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
479                 GetProperty(Camera.Property.TARGET_POSITION).Get(temp);
480                 return temp;
481             }
482             set
483             {
484                 SetProperty(Camera.Property.TARGET_POSITION, new Tizen.NUI.PropertyValue(value));
485             }
486         }
487         internal Matrix ProjectionMatrix
488         {
489             get
490             {
491                 Matrix temp = new Matrix();
492                 GetProperty(Camera.Property.PROJECTION_MATRIX).Get(temp);
493                 return temp;
494             }
495         }
496         internal Matrix ViewMatrix
497         {
498             get
499             {
500                 Matrix temp = new Matrix();
501                 GetProperty(Camera.Property.VIEW_MATRIX).Get(temp);
502                 return temp;
503             }
504         }
505         public bool InvertYAxis
506         {
507             get
508             {
509                 bool temp = false;
510                 GetProperty(Camera.Property.INVERT_Y_AXIS).Get(out temp);
511                 return temp;
512             }
513             set
514             {
515                 SetProperty(Camera.Property.INVERT_Y_AXIS, new Tizen.NUI.PropertyValue(value));
516             }
517         }
518
519     }
520
521 }