[NUI] Remove duplicate getCPtr from Disposable/View subclasses (#3544)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Common / Matrix.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
18 namespace Tizen.NUI
19 {
20     internal class Matrix : Disposable
21     {
22         internal Matrix(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
23         {
24         }
25
26         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
27         {
28             Interop.Matrix.DeleteMatrix(swigCPtr);
29         }
30
31
32         public static Vector4 operator *(Matrix arg1, Vector4 arg2)
33         {
34             return arg1.Multiply(arg2);
35         }
36
37         public Matrix() : this(Interop.Matrix.NewMatrix(), true)
38         {
39             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
40         }
41
42         public Matrix(bool initialize) : this(Interop.Matrix.NewMatrix(initialize), true)
43         {
44             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
45         }
46
47         public Matrix(float[] array) : this(Interop.Matrix.NewMatrix(array), true)
48         {
49             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50         }
51
52         public Matrix(Rotation rotation) : this(Interop.Matrix.NewMatrixQuaternion(Rotation.getCPtr(rotation)), true)
53         {
54             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55         }
56
57         public Matrix(Matrix matrix) : this(Interop.Matrix.NewMatrix(Matrix.getCPtr(matrix)), true)
58         {
59             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
60         }
61
62         public Matrix Assign(Matrix matrix)
63         {
64             Matrix ret = new Matrix(Interop.Matrix.Assign(SwigCPtr, Matrix.getCPtr(matrix)), false);
65             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
66             return ret;
67         }
68
69         public static Matrix IDENTITY
70         {
71             get
72             {
73                 global::System.IntPtr cPtr = Interop.Matrix.IdentityGet();
74                 Matrix ret = (cPtr == global::System.IntPtr.Zero) ? null : new Matrix(cPtr, false);
75                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
76                 return ret;
77             }
78         }
79
80         public void SetIdentity()
81         {
82             Interop.Matrix.SetIdentity(SwigCPtr);
83             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84         }
85
86         public void SetIdentityAndScale(Vector3 scale)
87         {
88             Interop.Matrix.SetIdentityAndScale(SwigCPtr, Vector3.getCPtr(scale));
89             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90         }
91
92         public void InvertTransform(Matrix result)
93         {
94             Interop.Matrix.InvertTransform(SwigCPtr, Matrix.getCPtr(result));
95             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
96         }
97
98         public bool Invert()
99         {
100             bool ret = Interop.Matrix.Invert(SwigCPtr);
101             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102             return ret;
103         }
104
105         public void Transpose()
106         {
107             Interop.Matrix.Transpose(SwigCPtr);
108             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109         }
110
111         public Vector3 GetXAxis()
112         {
113             Vector3 ret = new Vector3(Interop.Matrix.GetXAxis(SwigCPtr), true);
114             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115             return ret;
116         }
117
118         public Vector3 GetYAxis()
119         {
120             Vector3 ret = new Vector3(Interop.Matrix.GetYAxis(SwigCPtr), true);
121             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122             return ret;
123         }
124
125         public Vector3 GetZAxis()
126         {
127             Vector3 ret = new Vector3(Interop.Matrix.GetZAxis(SwigCPtr), true);
128             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129             return ret;
130         }
131
132         public void SetXAxis(Vector3 axis)
133         {
134             Interop.Matrix.SetXAxis(SwigCPtr, Vector3.getCPtr(axis));
135             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136         }
137
138         public void SetYAxis(Vector3 axis)
139         {
140             Interop.Matrix.SetYAxis(SwigCPtr, Vector3.getCPtr(axis));
141             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142         }
143
144         public void SetZAxis(Vector3 axis)
145         {
146             Interop.Matrix.SetZAxis(SwigCPtr, Vector3.getCPtr(axis));
147             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148         }
149
150         public Vector4 GetTranslation()
151         {
152             Vector4 ret = new Vector4(Interop.Matrix.GetTranslation(SwigCPtr), false);
153             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154             return ret;
155         }
156
157         public Vector3 GetTranslation3()
158         {
159             Vector3 ret = new Vector3(Interop.Matrix.GetTranslation3(SwigCPtr), false);
160             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161             return ret;
162         }
163
164         public void SetTranslation(Vector4 translation)
165         {
166             Interop.Matrix.SetTranslationVector4(SwigCPtr, Vector4.getCPtr(translation));
167             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168         }
169
170         public void SetTranslation(Vector3 translation)
171         {
172             Interop.Matrix.SetTranslationVector3(SwigCPtr, Vector3.getCPtr(translation));
173             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174         }
175
176         public void OrthoNormalize()
177         {
178             Interop.Matrix.OrthoNormalize(SwigCPtr);
179             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180         }
181
182         public SWIGTYPE_p_float AsFloat()
183         {
184             global::System.IntPtr cPtr = Interop.Matrix.AsFloat(SwigCPtr);
185             SWIGTYPE_p_float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_float(cPtr);
186             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187             return ret;
188         }
189
190         public static void Multiply(Matrix result, Matrix lhs, Matrix rhs)
191         {
192             Interop.Matrix.Multiply(Matrix.getCPtr(result), Matrix.getCPtr(lhs), Matrix.getCPtr(rhs));
193             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194         }
195
196         public static void Multiply(Matrix result, Matrix lhs, Rotation rhs)
197         {
198             Interop.Matrix.MultiplyQuaternion(Matrix.getCPtr(result), Matrix.getCPtr(lhs), Rotation.getCPtr(rhs));
199             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200         }
201
202         public Vector4 Multiply(Vector4 rhs)
203         {
204             Vector4 ret = new Vector4(Interop.Matrix.Multiply(SwigCPtr, Vector4.getCPtr(rhs)), true);
205             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206             return ret;
207         }
208
209         public bool EqualTo(Matrix rhs)
210         {
211             bool ret = Interop.Matrix.EqualTo(SwigCPtr, Matrix.getCPtr(rhs));
212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213             return ret;
214         }
215
216         public bool NotEqualTo(Matrix rhs)
217         {
218             bool ret = Interop.Matrix.NotEqualTo(SwigCPtr, Matrix.getCPtr(rhs));
219             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220             return ret;
221         }
222
223         public void SetTransformComponents(Vector3 scale, Rotation rotation, Vector3 translation)
224         {
225             Interop.Matrix.SetTransformComponents(SwigCPtr, Vector3.getCPtr(scale), Rotation.getCPtr(rotation), Vector3.getCPtr(translation));
226             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227         }
228
229         public void SetInverseTransformComponents(Vector3 scale, Rotation rotation, Vector3 translation)
230         {
231             Interop.Matrix.SetInverseTransformComponents(SwigCPtr, Vector3.getCPtr(scale), Rotation.getCPtr(rotation), Vector3.getCPtr(translation));
232             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233         }
234
235         public void SetInverseTransformComponents(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis, Vector3 translation)
236         {
237             Interop.Matrix.SetInverseTransformComponents(SwigCPtr, Vector3.getCPtr(xAxis), Vector3.getCPtr(yAxis), Vector3.getCPtr(zAxis), Vector3.getCPtr(translation));
238             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239         }
240
241         public void GetTransformComponents(Vector3 position, Rotation rotation, Vector3 scale)
242         {
243             Interop.Matrix.GetTransformComponents(SwigCPtr, Vector3.getCPtr(position), Rotation.getCPtr(rotation), Vector3.getCPtr(scale));
244             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245         }
246     }
247 }