2 * Copyright (c) 2018 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 : global::System.IDisposable
33 /// <since_tizen> 3 </since_tizen>
34 protected bool swigCMemOwn;
37 /// A Flat to check if it is already disposed.
39 /// <since_tizen> 3 </since_tizen>
40 protected bool disposed = false;
42 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
44 //A Flag to check who called Dispose(). (By User or DisposeQueue)
45 private bool isDisposeQueued = false;
50 /// <since_tizen> 3 </since_tizen>
51 public RelativeVector4() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
53 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
59 /// <param name="x">The x component.</param>
60 /// <param name="y">The y component.</param>
61 /// <param name="z">The z component.</param>
62 /// <param name="w">The w component.</param>
63 /// <since_tizen> 3 </since_tizen>
64 public RelativeVector4(float x, float y, float z, float w) : this(NDalicPINVOKE.new_Vector4__SWIG_1(ValueCheck(x), ValueCheck(y), ValueCheck(z), ValueCheck(w)), true)
66 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72 /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
73 /// <since_tizen> 3 </since_tizen>
74 public RelativeVector4(RelativeVector2 relativeVector2) : this(NDalicPINVOKE.new_Vector4__SWIG_3(RelativeVector2.getCPtr(relativeVector2)), true)
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
82 /// <param name="relativeVector3">The RelativeVector3 to create this vector from.</param>
83 /// <since_tizen> 3 </since_tizen>
84 public RelativeVector4(RelativeVector3 relativeVector3) : this(NDalicPINVOKE.new_Vector4__SWIG_4(RelativeVector3.getCPtr(relativeVector3)), true)
86 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92 /// <since_tizen> 3 </since_tizen>
97 isDisposeQueued = true;
98 DisposeQueue.Instance.Add(this);
105 /// <since_tizen> 3 </since_tizen>
110 NDalicPINVOKE.Vector4_X_set(swigCPtr, ValueCheck(value));
111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115 float ret = NDalicPINVOKE.Vector4_X_get(swigCPtr);
116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124 /// <since_tizen> 3 </since_tizen>
129 NDalicPINVOKE.Vector4_Y_set(swigCPtr, ValueCheck(value));
130 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134 float ret = NDalicPINVOKE.Vector4_Y_get(swigCPtr);
135 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143 /// <since_tizen> 3 </since_tizen>
148 NDalicPINVOKE.Vector4_Z_set(swigCPtr, ValueCheck(value));
149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153 float ret = NDalicPINVOKE.Vector4_Z_get(swigCPtr);
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 /// <since_tizen> 3 </since_tizen>
167 NDalicPINVOKE.Vector4_W_set(swigCPtr, ValueCheck(value));
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172 float ret = NDalicPINVOKE.Vector4_W_get(swigCPtr);
173 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 /// The addition operator.
181 /// <param name="arg1">The vector to add.</param>
182 /// <param name="arg2">The vector to add.</param>
183 /// <returns>The vector containing the result of the addition.</returns>
184 /// <since_tizen> 3 </since_tizen>
185 public static RelativeVector4 operator +(RelativeVector4 arg1, RelativeVector4 arg2)
187 RelativeVector4 result = arg1.Add(arg2);
188 return ValueCheck(result);
192 /// The subtraction operator.
194 /// <param name="arg1">The vector to subtract.</param>
195 /// <param name="arg2">The vector to subtract.</param>
196 /// <returns>The vector containing the result of the subtraction.</returns>
197 /// <since_tizen> 3 </since_tizen>
198 public static RelativeVector4 operator -(RelativeVector4 arg1, RelativeVector4 arg2)
200 RelativeVector4 result = arg1.Subtract(arg2);
201 return ValueCheck(result);
205 /// The multiplication operator.
207 /// <param name="arg1">The vector to multiply.</param>
208 /// <param name="arg2">The vector to multiply.</param>
209 /// <returns>The vector containing the result of the multiplication.</returns>
210 /// <since_tizen> 3 </since_tizen>
211 public static RelativeVector4 operator *(RelativeVector4 arg1, RelativeVector4 arg2)
213 RelativeVector4 result = arg1.Multiply(arg2);
214 return ValueCheck(result);
218 /// The multiplication operator.
220 /// <param name="arg1">The vector to multiply.</param>
221 /// <param name="arg2">The float value to scale the vector.</param>
222 /// <returns>The vector containing the result of the scaling.</returns>
223 /// <since_tizen> 3 </since_tizen>
224 public static RelativeVector4 operator *(RelativeVector4 arg1, float arg2)
226 RelativeVector4 result = arg1.Multiply(arg2);
227 return ValueCheck(result);
231 /// The division operator.
233 /// <param name="arg1">The vector to divide.</param>
234 /// <param name="arg2">The vector to divide.</param>
235 /// <returns>The vector containing the result of the division.</returns>
236 /// <since_tizen> 3 </since_tizen>
237 public static RelativeVector4 operator /(RelativeVector4 arg1, RelativeVector4 arg2)
239 RelativeVector4 result = arg1.Divide(arg2);
240 return ValueCheck(result);
244 /// The division operator.
246 /// <param name="arg1">The vector to divide.</param>
247 /// <param name="arg2">The float value to scale the vector by.</param>
248 /// <returns>The vector containing the result of the scaling.</returns>
249 /// <since_tizen> 3 </since_tizen>
250 public static RelativeVector4 operator /(RelativeVector4 arg1, float arg2)
252 RelativeVector4 result = arg1.Divide(arg2);
253 return ValueCheck(result);
258 /// <since_tizen> 3 </since_tizen>
259 public static implicit operator Vector4(RelativeVector4 relativeVector4)
261 return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
266 /// <since_tizen> 3 </since_tizen>
267 public static implicit operator RelativeVector4(Vector4 vec)
269 return new RelativeVector4(ValueCheck(vec.X), ValueCheck(vec.Y), ValueCheck(vec.Z), ValueCheck(vec.W));
275 /// <since_tizen> 3 </since_tizen>
276 public void Dispose()
278 //Throw excpetion if Dispose() is called in separate thread.
279 if (!Window.IsInstalled())
281 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
286 Dispose(DisposeTypes.Implicit);
290 Dispose(DisposeTypes.Explicit);
291 System.GC.SuppressFinalize(this);
296 /// The const array subscript operator overload. Should be 0, 1 3 or 3.
298 /// <param name="index">The subscript index.</param>
299 /// <returns>The float at the given index.</returns>
300 /// <since_tizen> 3 </since_tizen>
301 public float this[uint index]
305 return ValueOfIndex(index);
310 /// Determines whether the specified object is equal to the current object.
312 /// <param name="obj">The object to compare with the current object.</param>
313 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
314 public override bool Equals(System.Object obj)
316 RelativeVector4 relativeVector4 = obj as RelativeVector4;
318 if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
326 /// Gets the the hash code of this RelativeVector4.
328 /// <returns>The Hash Code.</returns>
329 /// <since_tizen> 6 </since_tizen>
330 public override int GetHashCode()
332 return swigCPtr.Handle.GetHashCode();
336 /// Compares if the rhs is equal to.
338 /// <param name="rhs">The vector to compare.</param>
339 /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
340 /// <since_tizen> 3 </since_tizen>
341 public bool EqualTo(RelativeVector4 rhs)
343 bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
344 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
349 /// Compares if the rhs is not equal to.
351 /// <param name="rhs">The vector to compare.</param>
352 /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
353 /// <since_tizen> 3 </since_tizen>
354 public bool NotEqualTo(RelativeVector4 rhs)
356 bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
363 internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
365 RelativeVector4 ret = new RelativeVector4(cPtr, false);
366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
370 internal static RelativeVector4 ValueCheck(RelativeVector4 relativeVector4)
372 if (relativeVector4.X < 0.0f)
374 relativeVector4.X = 0.0f;
375 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
377 else if (relativeVector4.X > 1.0f)
379 relativeVector4.X = 1.0f;
380 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
382 if (relativeVector4.Y < 0.0f)
384 relativeVector4.Y = 0.0f;
385 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
387 else if (relativeVector4.Y > 1.0f)
389 relativeVector4.Y = 1.0f;
390 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
392 if (relativeVector4.Z < 0.0f)
394 relativeVector4.Z = 0.0f;
395 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
397 else if (relativeVector4.Z > 1.0f)
399 relativeVector4.Z = 1.0f;
400 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
402 if (relativeVector4.W < 0.0f)
404 relativeVector4.W = 0.0f;
405 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
407 else if (relativeVector4.W > 1.0f)
409 relativeVector4.W = 1.0f;
410 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
412 return relativeVector4;
415 internal static float ValueCheck(float value)
420 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
422 else if (value > 1.0f)
425 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
430 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector4 obj)
432 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
435 internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn)
437 swigCMemOwn = cMemoryOwn;
438 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
444 /// <since_tizen> 3 </since_tizen>
445 protected virtual void Dispose(DisposeTypes type)
452 if(type == DisposeTypes.Explicit)
455 //Release your own managed resources here.
456 //You should release all of your own disposable objects here.
459 //Release your own unmanaged resources here.
460 //You should not access any managed member here except static instance.
461 //because the execution order of Finalizes is non-deterministic.
463 if (swigCPtr.Handle != global::System.IntPtr.Zero)
468 NDalicPINVOKE.delete_Vector4(swigCPtr);
470 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
475 private RelativeVector4 Add(RelativeVector4 rhs)
477 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Add(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
478 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
482 private RelativeVector4 Subtract(RelativeVector4 rhs)
484 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
485 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
489 private RelativeVector4 Multiply(RelativeVector4 rhs)
491 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
496 private RelativeVector4 Multiply(float rhs)
498 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
499 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
503 private RelativeVector4 Divide(RelativeVector4 rhs)
505 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
506 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
510 private RelativeVector4 Divide(float rhs)
512 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
513 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
517 private float ValueOfIndex(uint index)
519 float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
520 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();