[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / RelativeVector4.cs
1 /*
2  * Copyright (c) 2018 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 Tizen.NUI.Binding;
19
20 namespace Tizen.NUI
21 {
22     /// <summary>
23     /// RelativeVector4 is a four-dimensional vector.
24     /// All values (x, y, and z) should be between [0, 1].
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     [TypeConverter(typeof(RelativeVector4TypeConverter))]
28     public class RelativeVector4 : Disposable
29     {
30         /// <summary>
31         /// swigCMemOwn
32         /// </summary>
33         /// <since_tizen> 3 </since_tizen>
34         protected bool swigCMemOwn;
35
36         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
37
38         /// <summary>
39         /// The constructor.
40         /// </summary>
41         /// <since_tizen> 3 </since_tizen>
42         public RelativeVector4() : this(Interop.Vector4.new_Vector4__SWIG_0(), true)
43         {
44             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
45         }
46
47         /// <summary>
48         /// The constructor.
49         /// </summary>
50         /// <param name="x">The x component.</param>
51         /// <param name="y">The y component.</param>
52         /// <param name="z">The z component.</param>
53         /// <param name="w">The w component.</param>
54         /// <since_tizen> 3 </since_tizen>
55         public RelativeVector4(float x, float y, float z, float w) : this(Interop.Vector4.new_Vector4__SWIG_1(ValueCheck(x), ValueCheck(y), ValueCheck(z), ValueCheck(w)), true)
56         {
57             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
58         }
59
60         /// <summary>
61         /// The constructor.
62         /// </summary>
63         /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
64         /// <since_tizen> 3 </since_tizen>
65         public RelativeVector4(RelativeVector2 relativeVector2) : this(Interop.Vector4.new_Vector4__SWIG_3(RelativeVector2.getCPtr(relativeVector2)), true)
66         {
67             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68         }
69
70         /// <summary>
71         /// The constructor.
72         /// </summary>
73         /// <param name="relativeVector3">The RelativeVector3 to create this vector from.</param>
74         /// <since_tizen> 3 </since_tizen>
75         public RelativeVector4(RelativeVector3 relativeVector3) : this(Interop.Vector4.new_Vector4__SWIG_4(RelativeVector3.getCPtr(relativeVector3)), true)
76         {
77             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
78         }
79
80         /// <summary>
81         /// The x component.
82         /// </summary>
83         /// <since_tizen> 3 </since_tizen>
84         public float X
85         {
86             set
87             {
88                 Interop.Vector4.Vector4_X_set(swigCPtr, ValueCheck(value));
89                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90             }
91             get
92             {
93                 float ret = Interop.Vector4.Vector4_X_get(swigCPtr);
94                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95                 return ret;
96             }
97         }
98
99         /// <summary>
100         /// The y component.
101         /// </summary>
102         /// <since_tizen> 3 </since_tizen>
103         public float Y
104         {
105             set
106             {
107                 Interop.Vector4.Vector4_Y_set(swigCPtr, ValueCheck(value));
108                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109             }
110             get
111             {
112                 float ret = Interop.Vector4.Vector4_Y_get(swigCPtr);
113                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114                 return ret;
115             }
116         }
117
118         /// <summary>
119         /// The z component.
120         /// </summary>
121         /// <since_tizen> 3 </since_tizen>
122         public float Z
123         {
124             set
125             {
126                 Interop.Vector4.Vector4_Z_set(swigCPtr, ValueCheck(value));
127                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128             }
129             get
130             {
131                 float ret = Interop.Vector4.Vector4_Z_get(swigCPtr);
132                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133                 return ret;
134             }
135         }
136
137         /// <summary>
138         /// The w component.
139         /// </summary>
140         /// <since_tizen> 3 </since_tizen>
141         public float W
142         {
143             set
144             {
145                 Interop.Vector4.Vector4_W_set(swigCPtr, ValueCheck(value));
146                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147             }
148             get
149             {
150                 float ret = Interop.Vector4.Vector4_W_get(swigCPtr);
151                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152                 return ret;
153             }
154         }
155
156         /// <summary>
157         /// The addition operator.
158         /// </summary>
159         /// <param name="arg1">The vector to add.</param>
160         /// <param name="arg2">The vector to add.</param>
161         /// <returns>The vector containing the result of the addition.</returns>
162         /// <since_tizen> 3 </since_tizen>
163         public static RelativeVector4 operator +(RelativeVector4 arg1, RelativeVector4 arg2)
164         {
165             RelativeVector4 result = arg1.Add(arg2);
166             return ValueCheck(result);
167         }
168
169         /// <summary>
170         /// The subtraction operator.
171         /// </summary>
172         /// <param name="arg1">The vector to subtract.</param>
173         /// <param name="arg2">The vector to subtract.</param>
174         /// <returns>The vector containing the result of the subtraction.</returns>
175         /// <since_tizen> 3 </since_tizen>
176         public static RelativeVector4 operator -(RelativeVector4 arg1, RelativeVector4 arg2)
177         {
178             RelativeVector4 result = arg1.Subtract(arg2);
179             return ValueCheck(result);
180         }
181
182         /// <summary>
183         /// The multiplication operator.
184         /// </summary>
185         /// <param name="arg1">The vector to multiply.</param>
186         /// <param name="arg2">The vector to multiply.</param>
187         /// <returns>The vector containing the result of the multiplication.</returns>
188         /// <since_tizen> 3 </since_tizen>
189         public static RelativeVector4 operator *(RelativeVector4 arg1, RelativeVector4 arg2)
190         {
191             RelativeVector4 result = arg1.Multiply(arg2);
192             return ValueCheck(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 float value to scale the vector.</param>
200         /// <returns>The vector containing the result of the scaling.</returns>
201         /// <since_tizen> 3 </since_tizen>
202         public static RelativeVector4 operator *(RelativeVector4 arg1, float arg2)
203         {
204             RelativeVector4 result = arg1.Multiply(arg2);
205             return ValueCheck(result);
206         }
207
208         /// <summary>
209         /// The division operator.
210         /// </summary>
211         /// <param name="arg1">The vector to divide.</param>
212         /// <param name="arg2">The vector to divide.</param>
213         /// <returns>The vector containing the result of the division.</returns>
214         /// <since_tizen> 3 </since_tizen>
215         public static RelativeVector4 operator /(RelativeVector4 arg1, RelativeVector4 arg2)
216         {
217             RelativeVector4 result = arg1.Divide(arg2);
218             return ValueCheck(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 float value to scale the vector by.</param>
226         /// <returns>The vector containing the result of the scaling.</returns>
227         /// <since_tizen> 3 </since_tizen>
228         public static RelativeVector4 operator /(RelativeVector4 arg1, float arg2)
229         {
230             RelativeVector4 result = arg1.Divide(arg2);
231             return ValueCheck(result);
232         }
233
234         /// <summary>
235         /// </summary>
236         /// <since_tizen> 3 </since_tizen>
237         public static implicit operator Vector4(RelativeVector4 relativeVector4)
238         {
239             return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
240         }
241
242         /// <summary>
243         /// </summary>
244         /// <since_tizen> 3 </since_tizen>
245         public static implicit operator RelativeVector4(Vector4 vec)
246         {
247             return new RelativeVector4(ValueCheck(vec.X), ValueCheck(vec.Y), ValueCheck(vec.Z), ValueCheck(vec.W));
248         }
249
250         /// <summary>
251         /// The const array subscript operator overload. Should be 0, 1 3 or 3.
252         /// </summary>
253         /// <param name="index">The subscript index.</param>
254         /// <returns>The float at the given index.</returns>
255         /// <since_tizen> 3 </since_tizen>
256         public float this[uint index]
257         {
258             get
259             {
260                 return ValueOfIndex(index);
261             }
262         }
263
264         /// <summary>
265         /// Determines whether the specified object is equal to the current object.
266         /// </summary>
267         /// <param name="obj">The object to compare with the current object.</param>
268         /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
269         public override bool Equals(System.Object obj)
270         {
271             RelativeVector4 relativeVector4 = obj as RelativeVector4;
272             bool equal = false;
273             if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
274             {
275                 equal = true;
276             }
277             return equal;
278         }
279
280         /// <summary>
281         /// Gets the the hash code of this RelativeVector4.
282         /// </summary>
283         /// <returns>The Hash Code.</returns>
284         /// <since_tizen> 6 </since_tizen>
285         public override int GetHashCode()
286         {
287             return swigCPtr.Handle.GetHashCode();
288         }
289
290         /// <summary>
291         /// Compares if the rhs is equal to.
292         /// </summary>
293         /// <param name="rhs">The vector to compare.</param>
294         /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
295         /// <since_tizen> 3 </since_tizen>
296         public bool EqualTo(RelativeVector4 rhs)
297         {
298             bool ret = Interop.Vector4.Vector4_EqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
299             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300             return ret;
301         }
302
303         /// <summary>
304         /// Compares if the rhs is not equal to.
305         /// </summary>
306         /// <param name="rhs">The vector to compare.</param>
307         /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
308         /// <since_tizen> 3 </since_tizen>
309         public bool NotEqualTo(RelativeVector4 rhs)
310         {
311             bool ret = Interop.Vector4.Vector4_NotEqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
312             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313             return ret;
314         }
315
316         /// <summary>
317         /// </summary>
318         internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
319         {
320             RelativeVector4 ret = new RelativeVector4(cPtr, false);
321             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322             return ret;
323         }
324
325         internal static RelativeVector4 ValueCheck(RelativeVector4 relativeVector4)
326         {
327             if (relativeVector4.X < 0.0f)
328             {
329                 relativeVector4.X = 0.0f;
330                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
331             }
332             else if (relativeVector4.X > 1.0f)
333             {
334                 relativeVector4.X = 1.0f;
335                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
336             }
337             if (relativeVector4.Y < 0.0f)
338             {
339                 relativeVector4.Y = 0.0f;
340                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
341             }
342             else if (relativeVector4.Y > 1.0f)
343             {
344                 relativeVector4.Y = 1.0f;
345                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
346             }
347             if (relativeVector4.Z < 0.0f)
348             {
349                 relativeVector4.Z = 0.0f;
350                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
351             }
352             else if (relativeVector4.Z > 1.0f)
353             {
354                 relativeVector4.Z = 1.0f;
355                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
356             }
357             if (relativeVector4.W < 0.0f)
358             {
359                 relativeVector4.W = 0.0f;
360                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
361             }
362             else if (relativeVector4.W > 1.0f)
363             {
364                 relativeVector4.W = 1.0f;
365                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
366             }
367             return relativeVector4;
368         }
369
370         internal static float ValueCheck(float value)
371         {
372             if (value < 0.0f)
373             {
374                 value = 0.0f;
375                 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
376             }
377             else if (value > 1.0f)
378             {
379                 value = 1.0f;
380                 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
381             }
382             return value;
383         }
384
385         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector4 obj)
386         {
387             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
388         }
389
390         internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn)
391         {
392             swigCMemOwn = cMemoryOwn;
393             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
394         }
395
396         /// <summary>
397         /// Dispose.
398         /// </summary>
399         /// <since_tizen> 3 </since_tizen>
400         protected override void Dispose(DisposeTypes type)
401         {
402             if (disposed)
403             {
404                 return;
405             }
406
407             //Release your own unmanaged resources here.
408             //You should not access any managed member here except static instance.
409             //because the execution order of Finalizes is non-deterministic.
410
411             if (swigCPtr.Handle != global::System.IntPtr.Zero)
412             {
413                 if (swigCMemOwn)
414                 {
415                     swigCMemOwn = false;
416                     Interop.Vector4.delete_Vector4(swigCPtr);
417                 }
418                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
419             }
420             base.Dispose(type);
421         }
422
423         private RelativeVector4 Add(RelativeVector4 rhs)
424         {
425             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Add(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
426             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427             return ret;
428         }
429
430         private RelativeVector4 Subtract(RelativeVector4 rhs)
431         {
432             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Subtract__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
433             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434             return ret;
435         }
436
437         private RelativeVector4 Multiply(RelativeVector4 rhs)
438         {
439             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Multiply__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
440             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
441             return ret;
442         }
443
444         private RelativeVector4 Multiply(float rhs)
445         {
446             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
447             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448             return ret;
449         }
450
451         private RelativeVector4 Divide(RelativeVector4 rhs)
452         {
453             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Divide__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
454             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
455             return ret;
456         }
457
458         private RelativeVector4 Divide(float rhs)
459         {
460             RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
461             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
462             return ret;
463         }
464
465         private float ValueOfIndex(uint index)
466         {
467             float ret = Interop.Vector4.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
468             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
469             return ret;
470         }
471     }
472 }
473
474