abbdc4e942e22197c12d686b601b7ab366e741c9
[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     [global::System.Obsolete("Do not use this. Use Tizen.NUI.Scene3D.Camera instead.")]
24     [EditorBrowsable(EditorBrowsableState.Never)]
25     public partial 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("This has been deprecated in API9 and will be removed in API11. 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("This has been deprecated in API9 and will be removed in API11. 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("This has been deprecated in API9 and will be removed in API11. 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("This has been deprecated in API9 and will be removed in API11. 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("This has been deprecated in API9 and will be removed in API11. 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("This has been deprecated in API9 and will be removed in API11. 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("This has been deprecated in API9 and will be removed in API11. 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("This has been deprecated in API9 and will be removed in API11. 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                 return GetValue(TypeProperty) as string;
225             }
226             set
227             {
228                 SetValue(TypeProperty, value);
229                 NotifyPropertyChanged();
230             }
231         }
232
233         private string InternalType
234         {
235             get
236             {
237                 string returnValue = "";
238                 PropertyValue type = GetProperty(Camera.Property.TYPE);
239                 type?.Get(out returnValue);
240                 type?.Dispose();
241                 return returnValue;
242             }
243             set
244             {
245                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
246                 SetProperty(Camera.Property.TYPE, setValue);
247                 setValue.Dispose();
248             }
249         }
250
251         // The type of GetProjectionMode() and SetProjectionMode() is different from Projection Property.
252         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
253         public string ProjectionMode
254         {
255             get
256             {
257                 return GetValue(ProjectionModeProperty) as string;
258             }
259             set
260             {
261                 SetValue(ProjectionModeProperty, value);
262                 NotifyPropertyChanged();
263             }
264         }
265
266         private string InternalProjectionMode
267         {
268             get
269             {
270                 string returnValue = "";
271                 PropertyValue projectionMode = GetProperty(Camera.Property.ProjectionMode);
272                 projectionMode?.Get(out returnValue);
273                 projectionMode?.Dispose();
274                 return returnValue;
275             }
276             set
277             {
278                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
279                 SetProperty(Camera.Property.ProjectionMode, setValue);
280                 setValue.Dispose();
281             }
282         }
283
284         public float FieldOfView
285         {
286             get
287             {
288                 return (float)GetValue(FieldOfViewProperty);
289             }
290             set
291             {
292                 SetValue(FieldOfViewProperty, value);
293                 NotifyPropertyChanged();
294             }
295         }
296
297         private float InternalFieldOfView
298         {
299             get
300             {
301                 float returnValue = 0.0f;
302                 PropertyValue fieldView = GetProperty(Camera.Property.FieldOfView);
303                 fieldView?.Get(out returnValue);
304                 fieldView?.Dispose();
305                 return returnValue;
306             }
307             set
308             {
309                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
310                 SetProperty(Camera.Property.FieldOfView, setValue);
311                 setValue.Dispose();
312             }
313         }
314
315         public float AspectRatio
316         {
317             get
318             {
319                 return (float)GetValue(AspectRatioProperty);
320             }
321             set
322             {
323                 SetValue(AspectRatioProperty, value);
324                 NotifyPropertyChanged();
325             }
326         }
327
328         private float InternalAspectRatio
329         {
330             get
331             {
332                 float returnValue = 0.0f;
333                 PropertyValue aspectRatio = GetProperty(Camera.Property.AspectRatio);
334                 aspectRatio?.Get(out returnValue);
335                 aspectRatio?.Dispose();
336                 return returnValue;
337             }
338             set
339             {
340                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
341                 SetProperty(Camera.Property.AspectRatio, setValue);
342                 setValue.Dispose();
343             }
344         }
345
346         public float NearPlaneDistance
347         {
348             get
349             {
350                 return (float)GetValue(NearPlaneDistanceProperty);
351             }
352             set
353             {
354                 SetValue(NearPlaneDistanceProperty, value);
355                 NotifyPropertyChanged();
356             }
357         }
358         
359         private float InternalNearPlaneDistance
360         {
361             get
362             {
363                 float returnValue = 0.0f;
364                 PropertyValue nearPlaneDistance = GetProperty(Camera.Property.NearPlaneDistance);
365                 nearPlaneDistance?.Get(out returnValue);
366                 nearPlaneDistance?.Dispose();
367                 return returnValue;
368             }
369             set
370             {
371                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
372                 SetProperty(Camera.Property.NearPlaneDistance, setValue);
373                 setValue.Dispose();
374             }
375         }
376
377         public float FarPlaneDistance
378         {
379             get
380             {
381                 return (float)GetValue(FarPlaneDistanceProperty);
382             }
383             set
384             {
385                 SetValue(FarPlaneDistanceProperty, value);
386                 NotifyPropertyChanged();
387             }
388         }
389         
390         private float InternalFarPlaneDistance
391         {
392             get
393             {
394                 float returnValue = 0.0f;
395                 PropertyValue farPlaneDistance = GetProperty(Camera.Property.FarPlaneDistance);
396                 farPlaneDistance?.Get(out returnValue);
397                 farPlaneDistance?.Dispose();
398                 return returnValue;
399             }
400             set
401             {
402                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
403                 SetProperty(Camera.Property.FarPlaneDistance, setValue);
404                 setValue.Dispose();
405             }
406         }
407
408         public float LeftPlaneDistance
409         {
410             get
411             {
412                 return (float)GetValue(LeftPlaneDistanceProperty);
413             }
414             set
415             {
416                 SetValue(LeftPlaneDistanceProperty, value);
417                 NotifyPropertyChanged();
418             }
419         }
420         
421         private float InternalLeftPlaneDistance
422         {
423             get
424             {
425                 float returnValue = 0.0f;
426                 PropertyValue leftPlaneDistance = GetProperty(Camera.Property.LeftPlaneDistance);
427                 leftPlaneDistance?.Get(out returnValue);
428                 leftPlaneDistance?.Dispose();
429                 return returnValue;
430             }
431             set
432             {
433                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
434                 SetProperty(Camera.Property.LeftPlaneDistance, setValue);
435                 setValue.Dispose();
436             }
437         }
438
439         public float RightPlaneDistance
440         {
441             get
442             {
443                 return (float)GetValue(RightPlaneDistanceProperty);
444             }
445             set
446             {
447                 SetValue(RightPlaneDistanceProperty, value);
448                 NotifyPropertyChanged();
449             }
450         }
451         
452         private float InternalRightPlaneDistance
453         {
454             get
455             {
456                 float returnValue = 0.0f;
457                 PropertyValue rightPlaneDistance = GetProperty(Camera.Property.RightPlaneDistance);
458                 rightPlaneDistance?.Get(out returnValue);
459                 rightPlaneDistance?.Dispose();
460                 return returnValue;
461             }
462             set
463             {
464                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
465                 SetProperty(Camera.Property.RightPlaneDistance, setValue);
466                 setValue.Dispose();
467             }
468         }
469
470         public float TopPlaneDistance
471         {
472             get
473             {
474                 return (float)GetValue(TopPlaneDistanceProperty);
475             }
476             set
477             {
478                 SetValue(TopPlaneDistanceProperty, value);
479                 NotifyPropertyChanged();
480             }
481         }
482         
483         private float InternalTopPlaneDistance
484         {
485             get
486             {
487                 float returnValue = 0.0f;
488                 PropertyValue topPlaneDistance = GetProperty(Camera.Property.TopPlaneDistance);
489                 topPlaneDistance?.Get(out returnValue);
490                 topPlaneDistance?.Dispose();
491                 return returnValue;
492             }
493             set
494             {
495                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
496                 SetProperty(Camera.Property.TopPlaneDistance, setValue);
497                 setValue.Dispose();
498             }
499         }
500
501         public float BottomPlaneDistance
502         {
503             get
504             {
505                 return (float)GetValue(BottomPlaneDistanceProperty);
506             }
507             set
508             {
509                 SetValue(BottomPlaneDistanceProperty, value);
510                 NotifyPropertyChanged();
511             }
512         }
513         
514         private float InternalBottomPlaneDistance
515         {
516             get
517             {
518                 float returnValue = 0.0f;
519                 PropertyValue bottomPlaneDistance = GetProperty(Camera.Property.BottomPlaneDistance);
520                 bottomPlaneDistance?.Get(out returnValue);
521                 bottomPlaneDistance?.Dispose();
522                 return returnValue;
523             }
524             set
525             {
526                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
527                 SetProperty(Camera.Property.BottomPlaneDistance, setValue);
528                 setValue.Dispose();
529             }
530         }
531
532         public Vector3 TargetPosition
533         {
534             get
535             {
536                 return GetValue(TargetPositionProperty) as Vector3;
537             }
538             set
539             {
540                 SetValue(TargetPositionProperty, value);
541                 NotifyPropertyChanged();
542             }
543         }
544         
545         private Vector3 InternalTargetPosition
546         {
547             get
548             {
549                 Vector3 returnValue = new Vector3(0.0f, 0.0f, 0.0f);
550                 PropertyValue targetPosition = GetProperty(Camera.Property.TargetPosition);
551                 targetPosition?.Get(returnValue);
552                 targetPosition?.Dispose();
553                 return returnValue;
554             }
555             set
556             {
557                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
558                 SetProperty(Camera.Property.TargetPosition, setValue);
559                 setValue.Dispose();
560             }
561         }
562         internal Matrix ProjectionMatrix
563         {
564             get
565             {
566                 Matrix returnValue = new Matrix();
567                 PropertyValue projectionMatrix = GetProperty(Camera.Property.ProjectionMatrix);
568                 projectionMatrix?.Get(returnValue);
569                 projectionMatrix?.Dispose();
570                 return returnValue;
571             }
572         }
573         internal Matrix ViewMatrix
574         {
575             get
576             {
577                 Matrix returnValue = new Matrix();
578                 PropertyValue viewMatrix = GetProperty(Camera.Property.ViewMatrix);
579                 viewMatrix.Get(returnValue);
580                 viewMatrix.Dispose();
581                 return returnValue;
582             }
583         }
584
585         public bool InvertYAxis
586         {
587             get
588             {
589                 return (bool)GetValue(InvertYAxisProperty);
590             }
591             set
592             {
593                 SetValue(InvertYAxisProperty, value);
594                 NotifyPropertyChanged();
595             }
596         }
597         
598         private bool InternalInvertYAxis
599         {
600             get
601             {
602                 bool returnValue = false;
603                 PropertyValue invertYAxis = GetProperty(Camera.Property.InvertYAxis);
604                 invertYAxis?.Get(out returnValue);
605                 invertYAxis?.Dispose();
606                 return returnValue;
607             }
608             set
609             {
610                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
611                 SetProperty(Camera.Property.InvertYAxis, setValue);
612                 setValue.Dispose();
613             }
614         }
615     }
616 }