[Tizen] Ensuring that Registry.Unregister is called from the most derived class befor...
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Path.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 using System;
18
19 namespace Tizen.NUI
20 {
21
22     /// <summary>
23     /// A 3D parametric curve.<br>
24     /// Paths can be used to animate position and orientation of actors.<br>
25     /// </summary>
26     public class Path : BaseHandle
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29
30         internal Path(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Path_SWIGUpcast(cPtr), cMemoryOwn)
31         {
32             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33         }
34
35         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Path obj)
36         {
37             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38         }
39
40         protected override void Dispose(DisposeTypes type)
41         {
42             if(disposed)
43             {
44                 return;
45             }
46
47             if(type == DisposeTypes.Explicit)
48             {
49                 //Called by User
50                 //Release your own managed resources here.
51                 //You should release all of your own disposable objects here.
52             }
53
54             //Release your own unmanaged resources here.
55             //You should not access any managed member here except static instance.
56             //because the execution order of Finalizes is non-deterministic.
57
58             if (swigCPtr.Handle != global::System.IntPtr.Zero)
59             {
60                 if (swigCMemOwn)
61                 {
62                     swigCMemOwn = false;
63
64                     //Unreference this instance from Registry.
65                     Registry.Unregister(this);
66
67                     NDalicPINVOKE.delete_Path(swigCPtr);
68                 }
69                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
70             }
71
72             base.Dispose(type);
73         }
74
75
76         internal class Property
77         {
78             internal static readonly int POINTS = NDalicPINVOKE.Path_Property_POINTS_get();
79             internal static readonly int CONTROL_POINTS = NDalicPINVOKE.Path_Property_CONTROL_POINTS_get();
80         }
81
82         /// <summary>
83         /// Creates an initialized Path handle.
84         /// </summary>
85         public Path() : this(NDalicPINVOKE.Path_New(), true)
86         {
87             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88
89         }
90
91
92         [Obsolete("Please do not use! this will be deprecated")]
93         public new static Path DownCast(BaseHandle handle)
94         {
95             Path ret = new Path(NDalicPINVOKE.Path_DownCast(BaseHandle.getCPtr(handle)), true);
96             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97             return ret;
98         }
99
100         /// <summary>
101         /// Adds an interpolation point.
102         /// </summary>
103         /// <param name="point">The new interpolation point to be added</param>
104         public void AddPoint(Position point)
105         {
106             NDalicPINVOKE.Path_AddPoint(swigCPtr, Position.getCPtr(point));
107             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108         }
109
110         /// <summary>
111         /// Adds a control point.
112         /// </summary>
113         /// <param name="point">The new control point to be added</param>
114         public void AddControlPoint(Vector3 point)
115         {
116             NDalicPINVOKE.Path_AddControlPoint(swigCPtr, Vector3.getCPtr(point));
117             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118         }
119
120         /// <summary>
121         /// Automatic generation of control points. Generated control points which result in a smooth join between the splines of each segment.<br>
122         /// The generating algorithm is as follows:<br>
123         /// For a given knot point K[N], find the vector that bisects K[N-1],[N] and [N],[N+1].<br>
124         /// Calculate the tangent vector by taking the normal of this bisector.<br>
125         /// The in control point is the length of the preceding segment back along this bisector multiplied by the curvature.<br>
126         /// The out control point is the length of the succeeding segment forward along this bisector multiplied by the curvature.<br>
127         /// </summary>
128         /// <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>
129         public void GenerateControlPoints(float curvature)
130         {
131             NDalicPINVOKE.Path_GenerateControlPoints(swigCPtr, curvature);
132             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133         }
134
135         /// <summary>
136         /// Sample path at a given progress. Calculates position and tangent at that point of the curve.
137         /// </summary>
138         /// <param name="progress">A floating point value between 0.0 and 1.0</param>
139         /// <param name="position">The interpolated position at that progress</param>
140         /// <param name="tangent">The interpolated tangent at that progress</param>
141         public void Sample(float progress, Vector3 position, Vector3 tangent)
142         {
143             NDalicPINVOKE.Path_Sample(swigCPtr, progress, Vector3.getCPtr(position), Vector3.getCPtr(tangent));
144             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145         }
146
147         /// <summary>
148         /// Accessor for the interpolation points.
149         /// </summary>
150         /// <param name="index">The index of the interpolation point</param>
151         public Vector3 GetPoint(uint index)
152         {
153             Vector3 ret = new Vector3(NDalicPINVOKE.Path_GetPoint(swigCPtr, index), false);
154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155             return ret;
156         }
157
158         /// <summary>
159         /// Accessor for the control points.
160         /// </summary>
161         /// <param name="index">The index of the control point</param>
162         public Vector3 GetControlPoint(uint index)
163         {
164             Vector3 ret = new Vector3(NDalicPINVOKE.Path_GetControlPoint(swigCPtr, index), false);
165             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166             return ret;
167         }
168
169         /// <summary>
170         /// Gets the number of interpolation points in the path.
171         /// </summary>
172         /// <returns>The number of interpolation points in the path</returns>
173         public uint GetPointCount()
174         {
175             uint ret = NDalicPINVOKE.Path_GetPointCount(swigCPtr);
176             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177             return ret;
178         }
179
180         /// <summary>
181         /// Enumeration for Points
182         /// </summary>
183         public PropertyArray Points
184         {
185             get
186             {
187                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
188                 Tizen.NUI.Object.GetProperty(swigCPtr, Path.Property.POINTS).Get(temp);
189                 return temp;
190             }
191             set
192             {
193                 Tizen.NUI.Object.SetProperty(swigCPtr, Path.Property.POINTS, new Tizen.NUI.PropertyValue(value));
194             }
195         }
196
197         /// <summary>
198         /// Enumeration for ControlPoints
199         /// </summary>
200         public PropertyArray ControlPoints
201         {
202             get
203             {
204                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
205                 Tizen.NUI.Object.GetProperty(swigCPtr, Path.Property.CONTROL_POINTS).Get(temp);
206                 return temp;
207             }
208             set
209             {
210                 Tizen.NUI.Object.SetProperty(swigCPtr, Path.Property.CONTROL_POINTS, new Tizen.NUI.PropertyValue(value));
211             }
212         }
213
214     }
215
216 }