Cleaning up the property framework; removal of duplicate methods and incorrect assers
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / path-impl.h
1 #ifndef __DALI_INTERNAL_PATH_H__
2 #define __DALI_INTERNAL_PATH_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/animation/path.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/math/matrix.h>
25 #include <dali/public-api/common/dali-vector.h>
26 #include <dali/internal/event/common/proxy-object.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33 typedef IntrusivePtr<Path> PathPtr;
34
35 /**
36  * A 3D path
37  */
38 class Path : public ProxyObject
39 {
40 public:
41
42   /**
43    * Construct a new path
44    */
45   static Path* New();
46
47   /**
48    * Constructor
49    */
50   Path();
51
52
53 protected:
54   /**
55    * virtual destructor
56    */
57   virtual ~Path();
58
59 private:
60   /**
61    * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded()
62    */
63   virtual void SceneObjectAdded(ProxyObject& proxy){}
64
65   /**
66    * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded()
67    */
68   virtual void SceneObjectRemoved(ProxyObject& proxy){}
69
70   /**
71    * @copydoc Dali::Internal::ProxyObject::Observer::ProxyDestroyed()
72    */
73   virtual void ProxyDestroyed(ProxyObject& proxy){}
74
75   /**
76    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
77    */
78   virtual unsigned int GetDefaultPropertyCount() const;
79
80   /**
81    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
82    */
83   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
84
85   /**
86    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
87    */
88   virtual const char* GetDefaultPropertyName(Property::Index index) const;
89
90   /**
91    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
92    */
93   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
94
95   /**
96    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
97    */
98   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
99
100   /**
101    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
102    */
103   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
104
105   /**
106    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
107    */
108   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
109
110   /**
111    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
112    */
113   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
114
115   /**
116    * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
117    */
118   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
119
120    /**
121    * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
122    */
123   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
124
125   /**
126    * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
127    */
128   virtual const SceneGraph::PropertyOwner* GetSceneObject() const{ return NULL; }
129
130   /**
131    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
132    */
133   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const{ return NULL; }
134
135   /**
136    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
137    */
138   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const{ return NULL; }
139
140 public:
141
142   /**
143    * Returns a clone to the given path
144    */
145   static Path* Clone(const Path& path);
146
147   /**
148    * @copydoc Dali::Path::AddPoint
149    */
150   void AddPoint(const Vector3& point );
151
152   /**
153    * @copydoc Dali::Path::AddControlPoint
154    */
155   void AddControlPoint(const Vector3& point );
156
157   /**
158    * @copydoc Dali::Path::GenerateControlPoints
159    */
160   void GenerateControlPoints( float curvature );
161
162   /**
163    * @copydoc Dali::Path::Sample
164    */
165   void Sample( float t, Vector3& position, Vector3& tangent ) const;
166
167   /**
168    * Sample position at point t.
169    *
170    * @param[in] progress  A floating point value between 0.0 and 1.0.
171    * @param[out] position The interpolated position at that progress.
172    */
173   Vector3 SamplePosition( float t ) const;
174
175   /**
176    * @brief Sample tangent at point t.
177    *
178    * @param[in] progress  A floating point value between 0.0 and 1.0.
179    * @param[out] tangent The interpolated tangent at that progress.
180    */
181   Vector3 SampleTangent( float t ) const;
182
183   /**
184    * @copydoc Dali::Path::GetPoint
185    */
186   Vector3& GetPoint( size_t index );
187
188   /**
189    * @copydoc Dali::Path::GetControlPoint
190    */
191   Vector3& GetControlPoint( size_t index );
192
193   /**
194    * @copydoc Dali::Path::GetPointCount
195    */
196   size_t GetPointCount() const;
197
198   /**
199    * @brief Get mPoint property
200    *
201    * @return A const reference to mPoint vector
202    */
203   const Dali::Vector<Vector3>& GetPoints() const{ return mPoint; }
204
205   /*
206    * @brief Set mPoint
207    *
208    * @param[in] p New value for mPoint property
209    */
210   void SetPoints( const Dali::Vector<Vector3>& p ){ mPoint = p; }
211
212   /**
213    * @brief Get mCotrolPoint property
214    *
215    * @return A const reference to mControlPoint vector
216    */
217   const Dali::Vector<Vector3>& GetControlPoints() const{ return mControlPoint; }
218
219   /*
220    * @brief Set mControlPoint property
221    *
222    * @param[in] p New value for mControlPoint property
223    */
224   void SetControlPoints( const Dali::Vector<Vector3>& p ){ mControlPoint = p; }
225
226 private:
227
228   /**
229    * Undefined
230    */
231   Path(const Path& p);
232
233   /**
234    * Undefined
235    */
236   Path& operator=(const Path& rhs);
237
238   /**
239    * Helper function to calculate the segment and local progress in that segment
240    * given a progress
241    *
242    * @param[in] t Progress
243    * @param[out] segment Segment for t
244    * @param[out] tLocal Local progress in the segment
245    *
246    */
247   void FindSegmentAndProgress( float t, unsigned int& segment, float& tLocal ) const;
248
249   /**
250    * Helper function to calculate to number of segments in the path
251    */
252   unsigned int GetNumberOfSegments() const;
253
254   Dali::Vector<Vector3> mPoint;            ///< Interpolation points
255   Dali::Vector<Vector3> mControlPoint;     ///< Control points
256 };
257
258 } // Internal
259
260 // Get impl of handle
261 inline Internal::Path& GetImplementation(Dali::Path& path)
262 {
263   DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
264   Dali::RefObject& object = path.GetBaseObject();
265   return static_cast<Internal::Path&>(object);
266 }
267
268 inline const Internal::Path& GetImplementation(const Dali::Path& path)
269 {
270   DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
271   const Dali::RefObject& object = path.GetBaseObject();
272   return static_cast<const Internal::Path&>(object);
273 }
274
275
276 } // Dali
277
278 #endif //__DALI_INTERNAL_KEY_FRAMES_H__