2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using Tizen.NUI.Binding;
23 /// RelativeVector4 is a four-dimensional vector.
24 /// All values (x, y, and z) should be between [0, 1].
26 /// <since_tizen> 3 </since_tizen>
27 [TypeConverter(typeof(RelativeVector4TypeConverter))]
28 public class RelativeVector4 : Disposable
33 /// <since_tizen> 3 </since_tizen>
34 protected bool swigCMemOwn;
36 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
41 /// <since_tizen> 3 </since_tizen>
42 public RelativeVector4() : this(Interop.Vector4.new_Vector4__SWIG_0(), true)
44 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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)
57 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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)
67 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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)
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
80 internal RelativeVector4(RelativeVector4ChangedCallback cb, float x, float y, float z, float w) : this(Interop.Vector4.new_Vector4__SWIG_1(ValueCheck(x), ValueCheck(y), ValueCheck(z), ValueCheck(w)), true)
83 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
85 internal delegate void RelativeVector4ChangedCallback(float x, float y, float z, float w);
86 private RelativeVector4ChangedCallback callback = null;
91 /// <since_tizen> 3 </since_tizen>
96 Interop.Vector4.Vector4_X_set(swigCPtr, ValueCheck(value));
97 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99 callback?.Invoke(X, Y, Z, W);
103 float ret = Interop.Vector4.Vector4_X_get(swigCPtr);
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112 /// <since_tizen> 3 </since_tizen>
117 Interop.Vector4.Vector4_Y_set(swigCPtr, ValueCheck(value));
118 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120 callback?.Invoke(X, Y, Z, W);
124 float ret = Interop.Vector4.Vector4_Y_get(swigCPtr);
125 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133 /// <since_tizen> 3 </since_tizen>
138 Interop.Vector4.Vector4_Z_set(swigCPtr, ValueCheck(value));
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141 callback?.Invoke(X, Y, Z, W);
145 float ret = Interop.Vector4.Vector4_Z_get(swigCPtr);
146 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154 /// <since_tizen> 3 </since_tizen>
159 Interop.Vector4.Vector4_W_set(swigCPtr, ValueCheck(value));
160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 callback?.Invoke(X, Y, Z, W);
166 float ret = Interop.Vector4.Vector4_W_get(swigCPtr);
167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 /// The addition operator.
175 /// <param name="arg1">The vector to add.</param>
176 /// <param name="arg2">The vector to add.</param>
177 /// <returns>The vector containing the result of the addition.</returns>
178 /// <since_tizen> 3 </since_tizen>
179 public static RelativeVector4 operator +(RelativeVector4 arg1, RelativeVector4 arg2)
181 RelativeVector4 result = arg1.Add(arg2);
182 return ValueCheck(result);
186 /// The subtraction operator.
188 /// <param name="arg1">The vector to subtract.</param>
189 /// <param name="arg2">The vector to subtract.</param>
190 /// <returns>The vector containing the result of the subtraction.</returns>
191 /// <since_tizen> 3 </since_tizen>
192 public static RelativeVector4 operator -(RelativeVector4 arg1, RelativeVector4 arg2)
194 RelativeVector4 result = arg1.Subtract(arg2);
195 return ValueCheck(result);
199 /// The multiplication operator.
201 /// <param name="arg1">The vector to multiply.</param>
202 /// <param name="arg2">The vector to multiply.</param>
203 /// <returns>The vector containing the result of the multiplication.</returns>
204 /// <since_tizen> 3 </since_tizen>
205 public static RelativeVector4 operator *(RelativeVector4 arg1, RelativeVector4 arg2)
207 RelativeVector4 result = arg1.Multiply(arg2);
208 return ValueCheck(result);
212 /// The multiplication operator.
214 /// <param name="arg1">The vector to multiply.</param>
215 /// <param name="arg2">The float value to scale the vector.</param>
216 /// <returns>The vector containing the result of the scaling.</returns>
217 /// <since_tizen> 3 </since_tizen>
218 public static RelativeVector4 operator *(RelativeVector4 arg1, float arg2)
220 RelativeVector4 result = arg1.Multiply(arg2);
221 return ValueCheck(result);
225 /// The division operator.
227 /// <param name="arg1">The vector to divide.</param>
228 /// <param name="arg2">The vector to divide.</param>
229 /// <returns>The vector containing the result of the division.</returns>
230 /// <since_tizen> 3 </since_tizen>
231 public static RelativeVector4 operator /(RelativeVector4 arg1, RelativeVector4 arg2)
233 RelativeVector4 result = arg1.Divide(arg2);
234 return ValueCheck(result);
238 /// The division operator.
240 /// <param name="arg1">The vector to divide.</param>
241 /// <param name="arg2">The float value to scale the vector by.</param>
242 /// <returns>The vector containing the result of the scaling.</returns>
243 /// <since_tizen> 3 </since_tizen>
244 public static RelativeVector4 operator /(RelativeVector4 arg1, float arg2)
246 RelativeVector4 result = arg1.Divide(arg2);
247 return ValueCheck(result);
252 /// <since_tizen> 3 </since_tizen>
253 public static implicit operator Vector4(RelativeVector4 relativeVector4)
255 return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
260 /// <since_tizen> 3 </since_tizen>
261 public static implicit operator RelativeVector4(Vector4 vec)
263 return new RelativeVector4(ValueCheck(vec.X), ValueCheck(vec.Y), ValueCheck(vec.Z), ValueCheck(vec.W));
267 /// The const array subscript operator overload. Should be 0, 1 3 or 3.
269 /// <param name="index">The subscript index.</param>
270 /// <returns>The float at the given index.</returns>
271 /// <since_tizen> 3 </since_tizen>
272 public float this[uint index]
276 return ValueOfIndex(index);
281 /// Determines whether the specified object is equal to the current object.
283 /// <param name="obj">The object to compare with the current object.</param>
284 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
285 public override bool Equals(System.Object obj)
287 RelativeVector4 relativeVector4 = obj as RelativeVector4;
289 if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
297 /// Gets the the hash code of this RelativeVector4.
299 /// <returns>The Hash Code.</returns>
300 /// <since_tizen> 6 </since_tizen>
301 public override int GetHashCode()
303 return swigCPtr.Handle.GetHashCode();
307 /// Compares if the rhs is equal to.
309 /// <param name="rhs">The vector to compare.</param>
310 /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
311 /// <since_tizen> 3 </since_tizen>
312 public bool EqualTo(RelativeVector4 rhs)
314 bool ret = Interop.Vector4.Vector4_EqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
320 /// Compares if the rhs is not equal to.
322 /// <param name="rhs">The vector to compare.</param>
323 /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
324 /// <since_tizen> 3 </since_tizen>
325 public bool NotEqualTo(RelativeVector4 rhs)
327 bool ret = Interop.Vector4.Vector4_NotEqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
328 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334 internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
336 RelativeVector4 ret = new RelativeVector4(cPtr, false);
337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 internal static RelativeVector4 ValueCheck(RelativeVector4 relativeVector4)
343 if (relativeVector4.X < 0.0f)
345 relativeVector4.X = 0.0f;
346 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
348 else if (relativeVector4.X > 1.0f)
350 relativeVector4.X = 1.0f;
351 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
353 if (relativeVector4.Y < 0.0f)
355 relativeVector4.Y = 0.0f;
356 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
358 else if (relativeVector4.Y > 1.0f)
360 relativeVector4.Y = 1.0f;
361 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
363 if (relativeVector4.Z < 0.0f)
365 relativeVector4.Z = 0.0f;
366 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
368 else if (relativeVector4.Z > 1.0f)
370 relativeVector4.Z = 1.0f;
371 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
373 if (relativeVector4.W < 0.0f)
375 relativeVector4.W = 0.0f;
376 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
378 else if (relativeVector4.W > 1.0f)
380 relativeVector4.W = 1.0f;
381 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
383 return relativeVector4;
386 internal static float ValueCheck(float value)
391 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
393 else if (value > 1.0f)
396 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
401 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector4 obj)
403 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
406 internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn)
408 swigCMemOwn = cMemoryOwn;
409 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
415 /// <since_tizen> 3 </since_tizen>
416 protected override void Dispose(DisposeTypes type)
423 //Release your own unmanaged resources here.
424 //You should not access any managed member here except static instance.
425 //because the execution order of Finalizes is non-deterministic.
427 if (swigCPtr.Handle != global::System.IntPtr.Zero)
432 Interop.Vector4.delete_Vector4(swigCPtr);
434 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
439 private RelativeVector4 Add(RelativeVector4 rhs)
441 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Add(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
446 private RelativeVector4 Subtract(RelativeVector4 rhs)
448 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Subtract__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453 private RelativeVector4 Multiply(RelativeVector4 rhs)
455 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Multiply__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460 private RelativeVector4 Multiply(float rhs)
462 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 private RelativeVector4 Divide(RelativeVector4 rhs)
469 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Divide__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
474 private RelativeVector4 Divide(float rhs)
476 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
477 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
481 private float ValueOfIndex(uint index)
483 float ret = Interop.Vector4.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
484 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();