Release 4.0.0-preview1-00301
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Path.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 using System;
19
20 namespace Tizen.NUI
21 {
22
23     /// <summary>
24     /// A 3D parametric curve.<br />
25     /// Paths can be used to animate the position and orientation of actors.<br />
26     /// </summary>
27     public class Path : BaseHandle
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30
31         internal Path(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Path_SWIGUpcast(cPtr), cMemoryOwn)
32         {
33             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34         }
35
36         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Path obj)
37         {
38             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39         }
40
41         /// <summary>
42         /// Dispose
43         /// </summary>
44         /// <param name="type">The dispoase type</param>
45         /// <since_tizen> 3 </since_tizen>
46         protected override void Dispose(DisposeTypes type)
47         {
48             if(disposed)
49             {
50                 return;
51             }
52
53             if(type == DisposeTypes.Explicit)
54             {
55                 //Called by User
56                 //Release your own managed resources here.
57                 //You should release all of your own disposable objects here.
58             }
59
60             //Release your own unmanaged resources here.
61             //You should not access any managed member here except static instance.
62             //because the execution order of Finalizes is non-deterministic.
63
64             if (swigCPtr.Handle != global::System.IntPtr.Zero)
65             {
66                 if (swigCMemOwn)
67                 {
68                     swigCMemOwn = false;
69                     NDalicPINVOKE.delete_Path(swigCPtr);
70                 }
71                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
72             }
73
74             base.Dispose(type);
75         }
76
77
78         internal class Property
79         {
80             internal static readonly int POINTS = NDalicPINVOKE.Path_Property_POINTS_get();
81             internal static readonly int CONTROL_POINTS = NDalicPINVOKE.Path_Property_CONTROL_POINTS_get();
82         }
83
84         /// <summary>
85         /// Creates an initialized path handle.
86         /// </summary>
87         /// <since_tizen> 3 </since_tizen>
88         public Path() : this(NDalicPINVOKE.Path_New(), true)
89         {
90             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
91
92         }
93
94         /// <summary>
95         /// Please do not use! this will be deprecated
96         /// </summary>
97         /// <since_tizen> 3 </since_tizen>
98         [Obsolete("Please do not use! this will be deprecated")]
99         public static Path DownCast(BaseHandle handle)
100         {
101             Path ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as Path;
102             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
103             return ret;
104         }
105
106         /// <summary>
107         /// Adds an interpolation point.
108         /// </summary>
109         /// <param name="point">The new interpolation point to be added.</param>
110         /// <since_tizen> 3 </since_tizen>
111         public void AddPoint(Position point)
112         {
113             NDalicPINVOKE.Path_AddPoint(swigCPtr, Position.getCPtr(point));
114             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115         }
116
117         /// <summary>
118         /// Adds a control point.
119         /// </summary>
120         /// <param name="point">The new control point to be added.</param>
121         /// <since_tizen> 3 </since_tizen>
122         public void AddControlPoint(Vector3 point)
123         {
124             NDalicPINVOKE.Path_AddControlPoint(swigCPtr, Vector3.getCPtr(point));
125             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126         }
127
128         /// <summary>
129         /// Automatic generation of control points. Generated control points which result in a smooth join between the splines of each segment.<br />
130         /// The generating algorithm is as follows:<br />
131         /// For a given knot point K[N], find the vector that bisects K[N-1],[N] and [N],[N+1].<br />
132         /// Calculate the tangent vector by taking the normal of this bisector.<br />
133         /// The in control point is the length of the preceding segment back along this bisector multiplied by the curvature.<br />
134         /// The out control point is the length of the succeeding segment forward along this bisector multiplied by the curvature.<br />
135         /// </summary>
136         /// <param name="curvature">The curvature of the spline. 0 gives straight lines between the knots, negative values means the spline contains loops, positive values up to 0.5 result in a smooth curve, positive values between 0.5 and 1 result in looped curves where the loops are not distinct (i.e., the curve appears to be non-continuous), positive values higher than 1 result in looped curves.</param>
137         /// <since_tizen> 3 </since_tizen>
138         public void GenerateControlPoints(float curvature)
139         {
140             NDalicPINVOKE.Path_GenerateControlPoints(swigCPtr, curvature);
141             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142         }
143
144         /// <summary>
145         /// Sample path at a given progress. Calculates the position and tangent at that point of the curve.
146         /// </summary>
147         /// <param name="progress">A floating point value between 0.0 and 1.0.</param>
148         /// <param name="position">The interpolated position at that progress.</param>
149         /// <param name="tangent">The interpolated tangent at that progress.</param>
150         /// <since_tizen> 3 </since_tizen>
151         public void Sample(float progress, Vector3 position, Vector3 tangent)
152         {
153             NDalicPINVOKE.Path_Sample(swigCPtr, progress, Vector3.getCPtr(position), Vector3.getCPtr(tangent));
154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155         }
156
157         /// <summary>
158         /// An accessor for the interpolation points.
159         /// </summary>
160         /// <param name="index">The index of the interpolation point.</param>
161         /// <since_tizen> 3 </since_tizen>
162         public Vector3 GetPoint(uint index)
163         {
164             Vector3 ret = new Vector3(NDalicPINVOKE.Path_GetPoint(swigCPtr, index), false);
165             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166             return ret;
167         }
168
169         /// <summary>
170         /// An accessor for the control points.
171         /// </summary>
172         /// <param name="index">The index of the control point.</param>
173         /// <since_tizen> 3 </since_tizen>
174         public Vector3 GetControlPoint(uint index)
175         {
176             Vector3 ret = new Vector3(NDalicPINVOKE.Path_GetControlPoint(swigCPtr, index), false);
177             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178             return ret;
179         }
180
181         /// <summary>
182         /// Gets the number of interpolation points in the path.
183         /// </summary>
184         /// <returns>The number of interpolation points in the path.</returns>
185         /// <since_tizen> 3 </since_tizen>
186         public uint GetPointCount()
187         {
188             uint ret = NDalicPINVOKE.Path_GetPointCount(swigCPtr);
189             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190             return ret;
191         }
192
193         /// <summary>
194         /// Enumeration for the Points.
195         /// </summary>
196         /// <since_tizen> 3 </since_tizen>
197         public PropertyArray Points
198         {
199             get
200             {
201                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
202                 Tizen.NUI.Object.GetProperty(swigCPtr, Path.Property.POINTS).Get(temp);
203                 return temp;
204             }
205             set
206             {
207                 Tizen.NUI.Object.SetProperty(swigCPtr, Path.Property.POINTS, new Tizen.NUI.PropertyValue(value));
208             }
209         }
210
211         /// <summary>
212         /// Enumeration for the ControlPoints.
213         /// </summary>
214         /// <since_tizen> 3 </since_tizen>
215         public PropertyArray ControlPoints
216         {
217             get
218             {
219                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
220                 Tizen.NUI.Object.GetProperty(swigCPtr, Path.Property.CONTROL_POINTS).Get(temp);
221                 return temp;
222             }
223             set
224             {
225                 Tizen.NUI.Object.SetProperty(swigCPtr, Path.Property.CONTROL_POINTS, new Tizen.NUI.PropertyValue(value));
226             }
227         }
228
229     }
230
231 }