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