2 * Copyright (c) 2017 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.
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 public class RelativeVector4 : global::System.IDisposable
29 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33 /// <since_tizen> 3 </since_tizen>
34 protected bool swigCMemOwn;
36 internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn)
38 swigCMemOwn = cMemoryOwn;
39 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
42 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector4 obj)
44 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
47 //A Flag to check who called Dispose(). (By User or DisposeQueue)
48 private bool isDisposeQueued = false;
50 /// A Flat to check if it is already disposed.
52 /// <since_tizen> 3 </since_tizen>
53 protected bool disposed = false;
58 /// <since_tizen> 3 </since_tizen>
63 isDisposeQueued = true;
64 DisposeQueue.Instance.Add(this);
71 /// <since_tizen> 3 </since_tizen>
74 //Throw excpetion if Dispose() is called in separate thread.
75 if (!Window.IsInstalled())
77 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
82 Dispose(DisposeTypes.Implicit);
86 Dispose(DisposeTypes.Explicit);
87 System.GC.SuppressFinalize(this);
94 /// <since_tizen> 3 </since_tizen>
95 protected virtual void Dispose(DisposeTypes type)
102 if(type == DisposeTypes.Explicit)
105 //Release your own managed resources here.
106 //You should release all of your own disposable objects here.
109 //Release your own unmanaged resources here.
110 //You should not access any managed member here except static instance.
111 //because the execution order of Finalizes is non-deterministic.
113 if (swigCPtr.Handle != global::System.IntPtr.Zero)
118 NDalicPINVOKE.delete_Vector4(swigCPtr);
120 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
127 /// The addition operator.
129 /// <param name="arg1">The vector to add.</param>
130 /// <param name="arg2">The vector to add.</param>
131 /// <returns>The vector containing the result of the addition.</returns>
132 /// <since_tizen> 3 </since_tizen>
133 public static RelativeVector4 operator +(RelativeVector4 arg1, RelativeVector4 arg2)
135 RelativeVector4 result = arg1.Add(arg2);
136 return ValueCheck(result);
140 /// The subtraction operator.
142 /// <param name="arg1">The vector to subtract.</param>
143 /// <param name="arg2">The vector to subtract.</param>
144 /// <returns>The vector containing the result of the subtraction.</returns>
145 /// <since_tizen> 3 </since_tizen>
146 public static RelativeVector4 operator -(RelativeVector4 arg1, RelativeVector4 arg2)
148 RelativeVector4 result = arg1.Subtract(arg2);
149 return ValueCheck(result);
153 /// The multiplication operator.
155 /// <param name="arg1">The vector to multiply.</param>
156 /// <param name="arg2">The vector to multiply.</param>
157 /// <returns>The vector containing the result of the multiplication.</returns>
158 /// <since_tizen> 3 </since_tizen>
159 public static RelativeVector4 operator *(RelativeVector4 arg1, RelativeVector4 arg2)
161 RelativeVector4 result = arg1.Multiply(arg2);
162 return ValueCheck(result);
166 /// The multiplication operator.
168 /// <param name="arg1">The vector to multiply.</param>
169 /// <param name="arg2">The float value to scale the vector.</param>
170 /// <returns>The vector containing the result of the scaling.</returns>
171 /// <since_tizen> 3 </since_tizen>
172 public static RelativeVector4 operator *(RelativeVector4 arg1, float arg2)
174 RelativeVector4 result = arg1.Multiply(arg2);
175 return ValueCheck(result);
179 /// The division operator.
181 /// <param name="arg1">The vector to divide.</param>
182 /// <param name="arg2">The vector to divide.</param>
183 /// <returns>The vector containing the result of the division.</returns>
184 /// <since_tizen> 3 </since_tizen>
185 public static RelativeVector4 operator /(RelativeVector4 arg1, RelativeVector4 arg2)
187 RelativeVector4 result = arg1.Divide(arg2);
188 return ValueCheck(result);
192 /// The division operator.
194 /// <param name="arg1">The vector to divide.</param>
195 /// <param name="arg2">The float value to scale the vector by.</param>
196 /// <returns>The vector containing the result of the scaling.</returns>
197 /// <since_tizen> 3 </since_tizen>
198 public static RelativeVector4 operator /(RelativeVector4 arg1, float arg2)
200 RelativeVector4 result = arg1.Divide(arg2);
201 return ValueCheck(result);
206 /// The const array subscript operator overload. Should be 0, 1 3 or 3.
208 /// <param name="index">The subscript index.</param>
209 /// <returns>The float at the given index.</returns>
210 /// <since_tizen> 3 </since_tizen>
211 public float this[uint index]
215 return ValueOfIndex(index);
221 internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
223 RelativeVector4 ret = new RelativeVector4(cPtr, false);
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 /// <since_tizen> 3 </since_tizen>
233 public RelativeVector4() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241 /// <param name="x">The x component.</param>
242 /// <param name="y">The y component.</param>
243 /// <param name="z">The z component.</param>
244 /// <param name="w">The w component.</param>
245 /// <since_tizen> 3 </since_tizen>
246 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)
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
255 /// <since_tizen> 3 </since_tizen>
256 public RelativeVector4(RelativeVector2 relativeVector2) : this(NDalicPINVOKE.new_Vector4__SWIG_3(RelativeVector2.getCPtr(relativeVector2)), true)
258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264 /// <param name="relativeVector3">The RelativeVector3 to create this vector from.</param>
265 /// <since_tizen> 3 </since_tizen>
266 public RelativeVector4(RelativeVector3 relativeVector3) : this(NDalicPINVOKE.new_Vector4__SWIG_4(RelativeVector3.getCPtr(relativeVector3)), true)
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271 private RelativeVector4 Add(RelativeVector4 rhs)
273 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Add(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
274 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278 private RelativeVector4 Subtract(RelativeVector4 rhs)
280 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
281 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 private RelativeVector4 Multiply(RelativeVector4 rhs)
287 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
288 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292 private RelativeVector4 Multiply(float rhs)
294 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
295 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299 private RelativeVector4 Divide(RelativeVector4 rhs)
301 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
302 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
306 private RelativeVector4 Divide(float rhs)
308 RelativeVector4 ret = new RelativeVector4(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
309 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313 private float ValueOfIndex(uint index)
315 float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
316 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321 /// Compares if the rhs is equal to.
323 /// <param name="rhs">The vector to compare.</param>
324 /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
325 /// <since_tizen> 3 </since_tizen>
326 public bool EqualTo(RelativeVector4 rhs)
328 bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334 /// Compares if the rhs is not equal to.
336 /// <param name="rhs">The vector to compare.</param>
337 /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
338 /// <since_tizen> 3 </since_tizen>
339 public bool NotEqualTo(RelativeVector4 rhs)
341 bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 /// <since_tizen> 3 </since_tizen>
355 NDalicPINVOKE.Vector4_X_set(swigCPtr, ValueCheck(value));
356 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
360 float ret = NDalicPINVOKE.Vector4_X_get(swigCPtr);
361 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
369 /// <since_tizen> 3 </since_tizen>
374 NDalicPINVOKE.Vector4_Y_set(swigCPtr, ValueCheck(value));
375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
379 float ret = NDalicPINVOKE.Vector4_Y_get(swigCPtr);
380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388 /// <since_tizen> 3 </since_tizen>
393 NDalicPINVOKE.Vector4_Z_set(swigCPtr, ValueCheck(value));
394 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
398 float ret = NDalicPINVOKE.Vector4_Z_get(swigCPtr);
399 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
407 /// <since_tizen> 3 </since_tizen>
412 NDalicPINVOKE.Vector4_W_set(swigCPtr, ValueCheck(value));
413 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
417 float ret = NDalicPINVOKE.Vector4_W_get(swigCPtr);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
425 /// <since_tizen> 3 </since_tizen>
426 public static implicit operator Vector4(RelativeVector4 relativeVector4)
428 return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
433 /// <since_tizen> 3 </since_tizen>
434 public static implicit operator RelativeVector4(Vector4 vec)
436 return new RelativeVector4(ValueCheck(vec.X), ValueCheck(vec.Y), ValueCheck(vec.Z), ValueCheck(vec.W));
439 internal static RelativeVector4 ValueCheck(RelativeVector4 relativeVector4)
441 if(relativeVector4.X < 0.0f)
443 relativeVector4.X = 0.0f;
444 NUILog.Error( "The value of Result is invalid! Should be between [0, 1].");
446 else if(relativeVector4.X > 1.0f)
448 relativeVector4.X = 1.0f;
449 NUILog.Error( "The value of Result is invalid! Should be between [0, 1].");
451 if(relativeVector4.Y < 0.0f)
453 relativeVector4.Y = 0.0f;
454 NUILog.Error( "The value of Result is invalid! Should be between [0, 1].");
456 else if(relativeVector4.Y > 1.0f)
458 relativeVector4.Y = 1.0f;
459 NUILog.Error( "The value of Result is invalid! Should be between [0, 1].");
461 if(relativeVector4.Z < 0.0f)
463 relativeVector4.Z = 0.0f;
464 NUILog.Error( "The value of Result is invalid! Should be between [0, 1].");
466 else if(relativeVector4.Z > 1.0f)
468 relativeVector4.Z = 1.0f;
469 NUILog.Error( "The value of Result is invalid! Should be between [0, 1].");
471 if(relativeVector4.W < 0.0f)
473 relativeVector4.W = 0.0f;
474 NUILog.Error( "The value of Result is invalid! Should be between [0, 1].");
476 else if(relativeVector4.W > 1.0f)
478 relativeVector4.W = 1.0f;
479 NUILog.Error( "The value of Result is invalid! Should be between [0, 1].");
481 return relativeVector4;
484 internal static float ValueCheck(float value)
489 NUILog.Error( "The value of Parameters is invalid! Should be between [0, 1].");
491 else if(value > 1.0f)
494 NUILog.Error( "The value of Parameters is invalid! Should be between [0, 1].");