[NUI] Sync with dalihub & API5 branch (#631)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Geometry.cs
1 /*
2  * Copyright(c) 2017 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
21     /// <summary>
22     /// Geometry is handle to an object that can be used to define a geometric elements.
23     /// </summary>
24     /// <since_tizen> 3 </since_tizen>
25     public class Geometry : BaseHandle
26     {
27         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28
29         /// <summary>
30         /// Create an instance of Geometry.
31         /// </summary>
32         /// <since_tizen> 3 </since_tizen>
33         public Geometry() : this(NDalicPINVOKE.Geometry_New(), true)
34         {
35             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
36
37         }
38
39         internal Geometry(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Geometry_SWIGUpcast(cPtr), cMemoryOwn)
40         {
41             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
42         }
43
44         /// <summary>
45         /// Enumeration for the description of the type of geometry,
46         /// used to determine how the coordinates will be used.
47         /// </summary>
48         /// <returns>Type of primitives this geometry contains.</returns>
49         /// <since_tizen> 3 </since_tizen>
50         public enum Type
51         {
52             /// <summary>
53             /// Individual points.
54             /// </summary>
55             POINTS,
56
57             /// <summary>
58             /// Individual lines (made of 2 points each).
59             /// </summary>
60             LINES,
61
62             /// <summary>
63             /// A strip of lines (made of 1 point each) which also joins the first and last point.
64             /// </summary>
65             LINE_LOOP,
66
67             /// <summary>
68             /// A strip of lines (made of 1 point each).
69             /// </summary>
70             LINE_STRIP,
71
72             /// <summary>
73             /// Individual triangles (made of 3 points each).
74             /// </summary>
75             TRIANGLES,
76
77             /// <summary>
78             /// A fan of triangles around a centre point (after the first triangle, following triangles need only 1 point).
79             /// </summary>
80             TRIANGLE_FAN,
81
82             /// <summary>
83             /// A strip of triangles (after the first triangle, following triangles need only 1 point).
84             /// </summary>
85             TRIANGLE_STRIP
86         }
87
88         /// <summary>
89         /// Adds a PropertyBuffer to be used as source of geometry vertices.
90         /// </summary>
91         /// <param name="vertexBuffer">PropertyBuffer to be used as source of geometry vertices.</param>
92         /// <returns>Index of the newly added buffer.</returns>
93         /// <since_tizen> 3 </since_tizen>
94         public uint AddVertexBuffer(PropertyBuffer vertexBuffer)
95         {
96             uint ret = NDalicPINVOKE.Geometry_AddVertexBuffer(swigCPtr, PropertyBuffer.getCPtr(vertexBuffer));
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98             return ret;
99         }
100
101         /// <summary>
102         /// Retrieves the number of vertex buffers that have been added to this geometry.
103         /// </summary>
104         /// <returns>Number of vertex buffers that have been added to this geometry.</returns>
105         /// <since_tizen> 3 </since_tizen>
106         public uint GetNumberOfVertexBuffers()
107         {
108             uint ret = NDalicPINVOKE.Geometry_GetNumberOfVertexBuffers(swigCPtr);
109             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110             return ret;
111         }
112
113         /// <summary>
114         /// Removes a vertex buffer.
115         /// </summary>
116         /// <param name="index">Index to the vertex buffer to remove.</param>
117         /// <since_tizen> 3 </since_tizen>
118         public void RemoveVertexBuffer(uint index)
119         {
120             NDalicPINVOKE.Geometry_RemoveVertexBuffer(swigCPtr, index);
121             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122         }
123
124         /// <summary>
125         /// Sets a the index data to be used as a source of indices for the geometry
126         /// Setting this buffer will cause the geometry to be rendered using indices.
127         /// </summary>
128         /// <param name="indices">Array of indices.</param>
129         /// <param name="count">Number of indices in the array.</param>
130         /// <since_tizen> 3 </since_tizen>
131         public void SetIndexBuffer(ushort[] indices, uint count)
132         {
133             NDalicPINVOKE.Geometry_SetIndexBuffer(swigCPtr, indices, count);
134             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135         }
136
137         /// <summary>
138         /// Sets the type of primitives this geometry contains.
139         /// </summary>
140         /// <param name="geometryType">Array of indices.</param>
141         /// <since_tizen> 3 </since_tizen>
142         public void SetType(Geometry.Type geometryType)
143         {
144             NDalicPINVOKE.Geometry_SetType(swigCPtr, (int)geometryType);
145             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146         }
147
148         /// <summary>
149         /// Gets the type of primitives this geometry contains.
150         /// </summary>
151         /// <returns>Type of primitives this geometry contains.</returns>
152         /// <since_tizen> 3 </since_tizen>
153         public new Geometry.Type GetType()
154         {
155             Geometry.Type ret = (Geometry.Type)NDalicPINVOKE.Geometry_GetType(swigCPtr);
156             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157             return ret;
158         }
159
160         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Geometry obj)
161         {
162             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
163         }
164
165         /// <summary>
166         /// Dispose.
167         /// </summary>
168         /// <since_tizen> 3 </since_tizen>
169         protected override void Dispose(DisposeTypes type)
170         {
171             if (disposed)
172             {
173                 return;
174             }
175
176             if (type == DisposeTypes.Explicit)
177             {
178                 //Called by User
179                 //Release your own managed resources here.
180                 //You should release all of your own disposable objects here.
181
182             }
183
184             //Release your own unmanaged resources here.
185             //You should not access any managed member here except static instance.
186             //because the execution order of Finalizes is non-deterministic.
187
188             if (swigCPtr.Handle != global::System.IntPtr.Zero)
189             {
190                 if (swigCMemOwn)
191                 {
192                     swigCMemOwn = false;
193                     NDalicPINVOKE.delete_Geometry(swigCPtr);
194                 }
195                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
196             }
197
198             base.Dispose(type);
199         }
200
201     }
202 }