5f07ac3472c4f1c7e779bf8a881139fd873e5f8c
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / RelativeVector3.cs
1 /*
2  * Copyright (c) 2019 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.Binding;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// RelativeVector3 is a three-dimensional vector.
25     /// All values (x, y, z and w) should be between [0, 1].
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     [Binding.TypeConverter(typeof(RelativeVector3TypeConverter))]
29     public class RelativeVector3 : Disposable
30     {
31
32         /// <summary>
33         /// The constructor.
34         /// </summary>
35         /// <since_tizen> 3 </since_tizen>
36         public RelativeVector3() : this(Interop.Vector3.NewVector3(), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39         }
40
41         /// <summary>
42         /// The constructor.
43         /// </summary>
44         /// <param name="x">The x component.</param>
45         /// <param name="y">The y component.</param>
46         /// <param name="z">The z component.</param>
47         /// <since_tizen> 3 </since_tizen>
48         public RelativeVector3(float x, float y, float z) : this(Interop.Vector3.NewVector3(x, y, z), true)
49         {
50             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51         }
52
53         /// <summary>
54         /// The constructor.
55         /// </summary>
56         /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
57         /// <since_tizen> 3 </since_tizen>
58         public RelativeVector3(RelativeVector2 relativeVector2) : this(Interop.Vector3.NewVector3WithVector2(RelativeVector2.getCPtr(relativeVector2)), true)
59         {
60             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61         }
62
63         /// <summary>
64         /// The constructor.
65         /// </summary>
66         /// <param name="relativeVector4">The RelativeVector4 to create this vector from.</param>
67         /// <since_tizen> 3 </since_tizen>
68         public RelativeVector3(RelativeVector4 relativeVector4) : this(Interop.Vector3.NewVector3WithVector4(RelativeVector4.getCPtr(relativeVector4)), true)
69         {
70             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71         }
72
73         /// <summary>
74         /// The x component.
75         /// </summary>
76         /// <remarks>
77         /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector3(...) constructor.
78         /// </remarks>
79         /// <code>
80         /// // DO NOT use like the followings!
81         /// RelativeVector3 relativeVector3 = new RelativeVector3();
82         /// relativeVector3.X = 0.1f; 
83         /// // Please USE like this
84         /// float x = 0.1f, y = 0.5f, z = 0.9f;
85         /// RelativeVector3 relativeVector3 = new RelativeVector3(x, y, z);
86         /// </code>
87         /// <since_tizen> 3 </since_tizen>
88         public float X
89         {
90             set
91             {
92                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector3(...) constructor");
93
94                 Interop.Vector3.XSet(SwigCPtr, value);
95                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
96             }
97             get
98             {
99                 float ret = Interop.Vector3.XGet(SwigCPtr);
100                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
101                 return ret;
102             }
103         }
104
105         /// <summary>
106         /// The y component.
107         /// </summary>
108         /// <remarks>
109         /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector3(...) constructor.
110         /// </remarks>
111         /// <code>
112         /// // DO NOT use like the followings!
113         /// RelativeVector3 relativeVector3 = new RelativeVector3();
114         /// relativeVector3.Y = 0.5f; 
115         /// // Please USE like this
116         /// float x = 0.1f, y = 0.5f, z = 0.9f;
117         /// RelativeVector3 relativeVector3 = new RelativeVector3(x, y, z);
118         /// </code>
119         /// <since_tizen> 3 </since_tizen>
120         public float Y
121         {
122             set
123             {
124                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector3(...) constructor");
125
126                 Interop.Vector3.YSet(SwigCPtr, value);
127                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128             }
129             get
130             {
131                 float ret = Interop.Vector3.YGet(SwigCPtr);
132                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
133                 return ret;
134             }
135         }
136
137         /// <summary>
138         /// The z component.
139         /// </summary>
140         /// <remarks>
141         /// The setter is deprecated in API8 and will be removed in API10. Please use new RelativeVector3(...) constructor.
142         /// </remarks>
143         /// <code>
144         /// // DO NOT use like the followings!
145         /// RelativeVector3 relativeVector3 = new RelativeVector3();
146         /// relativeVector3.Z = 0.9f; 
147         /// // Please USE like this
148         /// float x = 0.1f, y = 0.5f, z = 0.9f;
149         /// RelativeVector3 relativeVector3 = new RelativeVector3(x, y, z);
150         /// </code>
151         /// <since_tizen> 3 </since_tizen>
152         public float Z
153         {
154             set
155             {
156                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new RelativeVector3(...) constructor");
157
158                 Interop.Vector3.ZSet(SwigCPtr, value);
159                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160             }
161             get
162             {
163                 float ret = Interop.Vector3.ZGet(SwigCPtr);
164                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
165                 return ret;
166             }
167         }
168
169         /// <summary>
170         /// The addition operator.
171         /// </summary>
172         /// <param name="arg1">The vector to add.</param>
173         /// <param name="arg2">Th vector to add.</param>
174         /// <returns>The vector containing the result of the addition.</returns>
175         /// <since_tizen> 3 </since_tizen>
176         public static RelativeVector3 operator +(RelativeVector3 arg1, RelativeVector3 arg2)
177         {
178             RelativeVector3 result = arg1?.Add(arg2);
179             return result;
180         }
181
182         /// <summary>
183         /// The subtraction operator.
184         /// </summary>
185         /// <param name="arg1">The vector to subtract.</param>
186         /// <param name="arg2">The vector to subtract.</param>
187         /// <returns>The vector containing the result of the subtraction.</returns>
188         /// <since_tizen> 3 </since_tizen>
189         public static RelativeVector3 operator -(RelativeVector3 arg1, RelativeVector3 arg2)
190         {
191             RelativeVector3 result = arg1?.Subtract(arg2);
192             return result;
193         }
194
195         /// <summary>
196         /// The multiplication operator.
197         /// </summary>
198         /// <param name="arg1">The vector to multiply.</param>
199         /// <param name="arg2">The vector to multiply.</param>
200         /// <returns>The vector containing the result of the multiplication.</returns>
201         /// <since_tizen> 3 </since_tizen>
202         public static RelativeVector3 operator *(RelativeVector3 arg1, RelativeVector3 arg2)
203         {
204             RelativeVector3 result = arg1?.Multiply(arg2);
205             return result;
206         }
207
208         /// <summary>
209         /// The multiplication operator.
210         /// </summary>
211         /// <param name="arg1">The vector to multiply.</param>
212         /// <param name="arg2">The float value to scale the vector.</param>
213         /// <returns>The vector containing the result of the scaling.</returns>
214         /// <since_tizen> 3 </since_tizen>
215         public static RelativeVector3 operator *(RelativeVector3 arg1, float arg2)
216         {
217             RelativeVector3 result = arg1?.Multiply(arg2);
218             return result;
219         }
220
221         /// <summary>
222         /// The division operator.
223         /// </summary>
224         /// <param name="arg1">The vector to divide.</param>
225         /// <param name="arg2">The vector to divide.</param>
226         /// <returns>The vector containing the result of the division.</returns>
227         /// <since_tizen> 3 </since_tizen>
228         public static RelativeVector3 operator /(RelativeVector3 arg1, RelativeVector3 arg2)
229         {
230             RelativeVector3 result = arg1?.Divide(arg2);
231             return result;
232         }
233
234         /// <summary>
235         /// The division operator.
236         /// </summary>
237         /// <param name="arg1">The vector to divide.</param>
238         /// <param name="arg2">The float value to scale the vector by.</param>
239         /// <returns>The vector containing the result of the scaling.</returns>
240         /// <since_tizen> 3 </since_tizen>
241         public static RelativeVector3 operator /(RelativeVector3 arg1, float arg2)
242         {
243             RelativeVector3 result = arg1?.Divide(arg2);
244             return result;
245         }
246
247         /// <summary>
248         /// </summary>
249         /// <since_tizen> 3 </since_tizen>
250         public static implicit operator Vector3(RelativeVector3 relativeVector3)
251         {
252             return new Vector3(relativeVector3.X, relativeVector3.Y, relativeVector3.Z);
253         }
254
255         /// <summary>
256         /// </summary>
257         /// <since_tizen> 3 </since_tizen>
258         public static implicit operator RelativeVector3(Vector3 vec)
259         {
260             return new RelativeVector3(vec.X, vec.Y, vec.Z);
261         }
262
263         /// <summary>
264         /// The const array subscript operator overload. Should be 0, 1 or 2.
265         /// </summary>
266         /// <param name="index">The subscript index.</param>
267         /// <returns>The float at the given index.</returns>
268         /// <since_tizen> 3 </since_tizen>
269         public float this[uint index]
270         {
271             get
272             {
273                 return ValueOfIndex(index);
274             }
275         }
276
277         /// <summary>
278         /// Determines whether the specified object is equal to the current object.
279         /// </summary>
280         /// <param name="obj">The object to compare with the current object.</param>
281         /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
282         public override bool Equals(System.Object obj)
283         {
284             RelativeVector3 relativeVector3 = obj as RelativeVector3;
285             bool equal = false;
286             if (X == relativeVector3?.X && Y == relativeVector3?.Y && Z == relativeVector3?.Z)
287             {
288                 equal = true;
289             }
290             return equal;
291         }
292
293         /// <summary>
294         /// Gets the the hash code of this RelativeVector3.
295         /// </summary>
296         /// <returns>The Hash Code.</returns>
297         /// <since_tizen> 6 </since_tizen>
298         public override int GetHashCode()
299         {
300             return SwigCPtr.Handle.GetHashCode();
301         }
302
303         /// <summary>
304         /// Compares if the rhs is equal to.
305         /// </summary>
306         /// <param name="rhs">The vector to compare.</param>
307         /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
308         /// <since_tizen> 3 </since_tizen>
309         public bool EqualTo(RelativeVector3 rhs)
310         {
311             bool ret = Interop.Vector3.EqualTo(SwigCPtr, RelativeVector3.getCPtr(rhs));
312             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313             return ret;
314         }
315
316         /// <summary>
317         /// Compares if the rhs is not equal to.
318         /// </summary>
319         /// <param name="rhs">The vector to compare.</param>
320         /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
321         /// <since_tizen> 3 </since_tizen>
322         public bool NotEqualTo(RelativeVector3 rhs)
323         {
324             bool ret = Interop.Vector3.NotEqualTo(SwigCPtr, RelativeVector3.getCPtr(rhs));
325             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326             return ret;
327         }
328
329         /// <summary>
330         /// </summary>
331         internal static RelativeVector3 GetRelativeVector3FromPtr(global::System.IntPtr cPtr)
332         {
333             RelativeVector3 ret = new RelativeVector3(cPtr, false);
334             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335             return ret;
336         }
337
338         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector3 obj)
339         {
340             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
341         }
342
343         internal RelativeVector3(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
344         {
345         }
346
347         /// This will not be public opened.
348         [EditorBrowsable(EditorBrowsableState.Never)]
349         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
350         {
351             Interop.Vector3.DeleteVector3(swigCPtr);
352         }
353
354         private RelativeVector3 Add(RelativeVector3 rhs)
355         {
356             RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Add(SwigCPtr, RelativeVector3.getCPtr(rhs)), true);
357             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358             return ret;
359         }
360
361         private RelativeVector3 Subtract(RelativeVector3 rhs)
362         {
363             RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Subtract(SwigCPtr, RelativeVector3.getCPtr(rhs)), true);
364             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
365             return ret;
366         }
367
368         private RelativeVector3 Multiply(RelativeVector3 rhs)
369         {
370             RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Multiply(SwigCPtr, RelativeVector3.getCPtr(rhs)), true);
371             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
372             return ret;
373         }
374
375         private RelativeVector3 Multiply(float rhs)
376         {
377             RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Multiply(SwigCPtr, rhs), true);
378             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
379             return ret;
380         }
381
382         private RelativeVector3 Divide(RelativeVector3 rhs)
383         {
384             RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Divide(SwigCPtr, RelativeVector3.getCPtr(rhs)), true);
385             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386             return ret;
387         }
388
389         private RelativeVector3 Divide(float rhs)
390         {
391             RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Divide(SwigCPtr, rhs), true);
392             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
393             return ret;
394         }
395
396         private float ValueOfIndex(uint index)
397         {
398             float ret = Interop.Vector3.ValueOfIndex(SwigCPtr, index);
399             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
400             return ret;
401         }
402     }
403
404 }
405
406