be29df8fda8d46193276fd68b1535a72a60c34a6
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Utility / 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 using System;
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20
21 namespace Tizen.NUI
22 {
23     /// This will be released at Tizen.NET API Level 6, so currently this would be used as inhouse API.
24     [EditorBrowsable(EditorBrowsableState.Never)]
25     public class Camera : View
26     {
27
28         internal Camera(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
29         {
30         }
31
32         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
33         {
34             Interop.CameraActor.DeleteCameraActor(swigCPtr);
35         }
36
37         new internal class Property
38         {
39             internal static readonly int TYPE = Interop.CameraActor.TypeGet();
40             internal static readonly int ProjectionMode = Interop.CameraActor.ProjectionModeGet();
41             internal static readonly int FieldOfView = Interop.CameraActor.FieldOfViewGet();
42             internal static readonly int AspectRatio = Interop.CameraActor.AspectRatioGet();
43             internal static readonly int NearPlaneDistance = Interop.CameraActor.NearPlaneDistanceGet();
44             internal static readonly int FarPlaneDistance = Interop.CameraActor.FarPlaneDistanceGet();
45             internal static readonly int LeftPlaneDistance = Interop.CameraActor.LeftPlaneDistanceGet();
46             internal static readonly int RightPlaneDistance = Interop.CameraActor.RightPlaneDistanceGet();
47             internal static readonly int TopPlaneDistance = Interop.CameraActor.TopPlaneDistanceGet();
48             internal static readonly int BottomPlaneDistance = Interop.CameraActor.BottomPlaneDistanceGet();
49             internal static readonly int TargetPosition = Interop.CameraActor.TargetPositionGet();
50             internal static readonly int ProjectionMatrix = Interop.CameraActor.ProjectionMatrixGet();
51             internal static readonly int ViewMatrix = Interop.CameraActor.ViewMatrixGet();
52             internal static readonly int InvertYAxis = Interop.CameraActor.InvertYAxisGet();
53         }
54
55         public Camera() : this(Interop.CameraActor.New(), true)
56         {
57             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
58         }
59
60         public Camera(Vector2 size) : this(Interop.CameraActor.New(Vector2.getCPtr(size)), true)
61         {
62             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
63         }
64
65         public static Camera DownCast(BaseHandle handle)
66         {
67             if (handle == null)
68             {
69                 throw new global::System.ArgumentNullException(nameof(handle));
70             }
71             Camera ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Camera;
72             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
73             return ret;
74         }
75
76         public Camera(Camera copy) : this(Interop.CameraActor.NewCameraActor(Camera.getCPtr(copy)), true)
77         {
78             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
79         }
80
81         public Camera Assign(Camera rhs)
82         {
83             Camera ret = new Camera(Interop.CameraActor.Assign(SwigCPtr, Camera.getCPtr(rhs)), false);
84             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
85             return ret;
86         }
87
88         public void SetType(CameraType type)
89         {
90             Interop.CameraActor.SetType(SwigCPtr, (int)type);
91             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92         }
93
94         public new CameraType GetType()
95         {
96             CameraType ret = (CameraType)Interop.CameraActor.GetType(SwigCPtr);
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98             return ret;
99         }
100
101         public void SetProjectionMode(ProjectionMode mode)
102         {
103             Interop.CameraActor.SetProjectionMode(SwigCPtr, (int)mode);
104             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105         }
106
107         public ProjectionMode GetProjectionMode()
108         {
109             ProjectionMode ret = (ProjectionMode)Interop.CameraActor.GetProjectionMode(SwigCPtr);
110             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111             return ret;
112         }
113
114         [Obsolete("Deprecated in API9, will be removed in API11. Please use FieldOfView property instead!")]
115         public void SetFieldOfView(float fieldOfView)
116         {
117             Interop.CameraActor.SetFieldOfView(SwigCPtr, fieldOfView);
118             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119         }
120
121         [Obsolete("Deprecated in API9, will be removed in API11. Please use FieldOfView property instead!")]
122         public float GetFieldOfView()
123         {
124             float ret = Interop.CameraActor.GetFieldOfView(SwigCPtr);
125             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126             return ret;
127         }
128
129         [Obsolete("Deprecated in API9, will be removed in API11. Please use AspectRatio property instead!")]
130         public void SetAspectRatio(float aspectRatio)
131         {
132             Interop.CameraActor.SetAspectRatio(SwigCPtr, aspectRatio);
133             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134         }
135
136         [Obsolete("Deprecated in API9, will be removed in API11. Please use AspectRatio property instead!")]
137         public float GetAspectRatio()
138         {
139             float ret = Interop.CameraActor.GetAspectRatio(SwigCPtr);
140             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141             return ret;
142         }
143
144         public void SetNearClippingPlane(float nearClippingPlane)
145         {
146             Interop.CameraActor.SetNearClippingPlane(SwigCPtr, nearClippingPlane);
147             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148         }
149
150         public float GetNearClippingPlane()
151         {
152             float ret = Interop.CameraActor.GetNearClippingPlane(SwigCPtr);
153             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154             return ret;
155         }
156
157         public void SetFarClippingPlane(float farClippingPlane)
158         {
159             Interop.CameraActor.SetFarClippingPlane(SwigCPtr, farClippingPlane);
160             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161         }
162
163         public float GetFarClippingPlane()
164         {
165             float ret = Interop.CameraActor.GetFarClippingPlane(SwigCPtr);
166             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167             return ret;
168         }
169
170         [Obsolete("Deprecated in API9, will be removed in API11. Please use TargetPosition property instead!")]
171         public void SetTargetPosition(Vector3 targetPosition)
172         {
173             Interop.CameraActor.SetTargetPosition(SwigCPtr, Vector3.getCPtr(targetPosition));
174             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175         }
176
177         [Obsolete("Deprecated in API9, will be removed in API11. Please use TargetPosition property instead!")]
178         public Vector3 GetTargetPosition()
179         {
180             Vector3 ret = new Vector3(Interop.CameraActor.GetTargetPosition(SwigCPtr), true);
181             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182             return ret;
183         }
184
185         [Obsolete("Deprecated in API9, will be removed in API11. Please use InvertYAxis property instead!")]
186         public void SetInvertYAxis(bool invertYAxis)
187         {
188             Interop.CameraActor.SetInvertYAxis(SwigCPtr, invertYAxis);
189             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190         }
191
192         [Obsolete("Deprecated in API9, will be removed in API11. Please use InvertYAxis property instead!")]
193         public bool GetInvertYAxis()
194         {
195             bool ret = Interop.CameraActor.GetInvertYAxis(SwigCPtr);
196             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197             return ret;
198         }
199
200         public void SetPerspectiveProjection(Vector2 size)
201         {
202             Interop.CameraActor.SetPerspectiveProjection(SwigCPtr, Vector2.getCPtr(size));
203             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204         }
205
206         public void SetOrthographicProjection(Vector2 size)
207         {
208             Interop.CameraActor.SetOrthographicProjection(SwigCPtr, Vector2.getCPtr(size));
209             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210         }
211
212         public void SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far)
213         {
214             Interop.CameraActor.SetOrthographicProjection(SwigCPtr, left, right, top, bottom, near, far);
215             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216         }
217
218         // The type of GetType() and SetType() is different from Type property.
219         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
220         public string Type
221         {
222             get
223             {
224                 string returnValue = "";
225                 PropertyValue type = GetProperty(Camera.Property.TYPE);
226                 type?.Get(out returnValue);
227                 type?.Dispose();
228                 return returnValue;
229             }
230             set
231             {
232                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
233                 SetProperty(Camera.Property.TYPE, setValue);
234                 setValue.Dispose();
235             }
236         }
237
238         // The type of GetProjectionMode() and SetProjectionMode() is different from Projection Property.
239         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
240         public string ProjectionMode
241         {
242             get
243             {
244                 string returnValue = "";
245                 PropertyValue projectionMode = GetProperty(Camera.Property.ProjectionMode);
246                 projectionMode?.Get(out returnValue);
247                 projectionMode?.Dispose();
248                 return returnValue;
249             }
250             set
251             {
252                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
253                 SetProperty(Camera.Property.ProjectionMode, setValue);
254                 setValue.Dispose();
255             }
256         }
257         public float FieldOfView
258         {
259             get
260             {
261                 float returnValue = 0.0f;
262                 PropertyValue fieldView = GetProperty(Camera.Property.FieldOfView);
263                 fieldView?.Get(out returnValue);
264                 fieldView?.Dispose();
265                 return returnValue;
266             }
267             set
268             {
269                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
270                 SetProperty(Camera.Property.FieldOfView, setValue);
271                 setValue.Dispose();
272             }
273         }
274         public float AspectRatio
275         {
276             get
277             {
278                 float returnValue = 0.0f;
279                 PropertyValue aspectRatio = GetProperty(Camera.Property.AspectRatio);
280                 aspectRatio?.Get(out returnValue);
281                 aspectRatio?.Dispose();
282                 return returnValue;
283             }
284             set
285             {
286                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
287                 SetProperty(Camera.Property.AspectRatio, setValue);
288                 setValue.Dispose();
289             }
290         }
291         public float NearPlaneDistance
292         {
293             get
294             {
295                 float returnValue = 0.0f;
296                 PropertyValue nearPlaneDistance = GetProperty(Camera.Property.NearPlaneDistance);
297                 nearPlaneDistance?.Get(out returnValue);
298                 nearPlaneDistance?.Dispose();
299                 return returnValue;
300             }
301             set
302             {
303                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
304                 SetProperty(Camera.Property.NearPlaneDistance, setValue);
305                 setValue.Dispose();
306             }
307         }
308         public float FarPlaneDistance
309         {
310             get
311             {
312                 float returnValue = 0.0f;
313                 PropertyValue farPlaneDistance = GetProperty(Camera.Property.FarPlaneDistance);
314                 farPlaneDistance?.Get(out returnValue);
315                 farPlaneDistance?.Dispose();
316                 return returnValue;
317             }
318             set
319             {
320                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
321                 SetProperty(Camera.Property.FarPlaneDistance, setValue);
322                 setValue.Dispose();
323             }
324         }
325         public float LeftPlaneDistance
326         {
327             get
328             {
329                 float returnValue = 0.0f;
330                 PropertyValue leftPlaneDistance = GetProperty(Camera.Property.LeftPlaneDistance);
331                 leftPlaneDistance?.Get(out returnValue);
332                 leftPlaneDistance?.Dispose();
333                 return returnValue;
334             }
335             set
336             {
337                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
338                 SetProperty(Camera.Property.LeftPlaneDistance, setValue);
339                 setValue.Dispose();
340             }
341         }
342         public float RightPlaneDistance
343         {
344             get
345             {
346                 float returnValue = 0.0f;
347                 PropertyValue rightPlaneDistance = GetProperty(Camera.Property.RightPlaneDistance);
348                 rightPlaneDistance?.Get(out returnValue);
349                 rightPlaneDistance?.Dispose();
350                 return returnValue;
351             }
352             set
353             {
354                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
355                 SetProperty(Camera.Property.RightPlaneDistance, setValue);
356                 setValue.Dispose();
357             }
358         }
359         public float TopPlaneDistance
360         {
361             get
362             {
363                 float returnValue = 0.0f;
364                 PropertyValue topPlaneDistance = GetProperty(Camera.Property.TopPlaneDistance);
365                 topPlaneDistance?.Get(out returnValue);
366                 topPlaneDistance?.Dispose();
367                 return returnValue;
368             }
369             set
370             {
371                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
372                 SetProperty(Camera.Property.TopPlaneDistance, setValue);
373                 setValue.Dispose();
374             }
375         }
376         public float BottomPlaneDistance
377         {
378             get
379             {
380                 float returnValue = 0.0f;
381                 PropertyValue bottomPlaneDistance = GetProperty(Camera.Property.BottomPlaneDistance);
382                 bottomPlaneDistance?.Get(out returnValue);
383                 bottomPlaneDistance?.Dispose();
384                 return returnValue;
385             }
386             set
387             {
388                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
389                 SetProperty(Camera.Property.BottomPlaneDistance, setValue);
390                 setValue.Dispose();
391             }
392         }
393         public Vector3 TargetPosition
394         {
395             get
396             {
397                 Vector3 returnValue = new Vector3(0.0f, 0.0f, 0.0f);
398                 PropertyValue targetPosition = GetProperty(Camera.Property.TargetPosition);
399                 targetPosition?.Get(returnValue);
400                 targetPosition?.Dispose();
401                 return returnValue;
402             }
403             set
404             {
405                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
406                 SetProperty(Camera.Property.TargetPosition, setValue);
407                 setValue.Dispose();
408             }
409         }
410         internal Matrix ProjectionMatrix
411         {
412             get
413             {
414                 Matrix returnValue = new Matrix();
415                 PropertyValue projectionMatrix = GetProperty(Camera.Property.ProjectionMatrix);
416                 projectionMatrix?.Get(returnValue);
417                 projectionMatrix?.Dispose();
418                 return returnValue;
419             }
420         }
421         internal Matrix ViewMatrix
422         {
423             get
424             {
425                 Matrix returnValue = new Matrix();
426                 PropertyValue viewMatrix = GetProperty(Camera.Property.ViewMatrix);
427                 viewMatrix.Get(returnValue);
428                 viewMatrix.Dispose();
429                 return returnValue;
430             }
431         }
432         public bool InvertYAxis
433         {
434             get
435             {
436                 bool returnValue = false;
437                 PropertyValue invertYAxis = GetProperty(Camera.Property.InvertYAxis);
438                 invertYAxis?.Get(out returnValue);
439                 invertYAxis?.Dispose();
440                 return returnValue;
441             }
442             set
443             {
444                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
445                 SetProperty(Camera.Property.InvertYAxis, setValue);
446                 setValue.Dispose();
447             }
448         }
449     }
450 }