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