1 #ifndef __DALI_INTERNAL_PATH_H__
2 #define __DALI_INTERNAL_PATH_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
33 typedef IntrusivePtr<Path> PathPtr;
38 class Path : public ProxyObject
43 * Construct a new path
61 * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded()
63 virtual void SceneObjectAdded(ProxyObject& proxy){}
66 * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded()
68 virtual void SceneObjectRemoved(ProxyObject& proxy){}
71 * @copydoc Dali::Internal::ProxyObject::Observer::ProxyDestroyed()
73 virtual void ProxyDestroyed(ProxyObject& proxy){}
76 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
78 virtual unsigned int GetDefaultPropertyCount() const;
81 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
83 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
86 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
88 virtual const char* GetDefaultPropertyName(Property::Index index) const;
91 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
93 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
96 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
98 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
101 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
103 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
106 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
108 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
111 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
113 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
116 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
118 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
121 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
123 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
126 * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
128 virtual const SceneGraph::PropertyOwner* GetSceneObject() const{ return NULL; }
131 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
133 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const{ return NULL; }
136 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
138 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const{ return NULL; }
143 * Returns a clone to the given path
145 static Path* Clone(const Path& path);
148 * @copydoc Dali::Path::AddPoint
150 void AddPoint(const Vector3& point );
153 * @copydoc Dali::Path::AddControlPoint
155 void AddControlPoint(const Vector3& point );
158 * @copydoc Dali::Path::GenerateControlPoints
160 void GenerateControlPoints( float curvature );
163 * @copydoc Dali::Path::Sample
165 void Sample( float t, Vector3& position, Vector3& tangent ) const;
168 * Sample position at point t.
170 * @param[in] progress A floating point value between 0.0 and 1.0.
171 * @param[out] position The interpolated position at that progress.
173 Vector3 SamplePosition( float t ) const;
176 * @brief Sample tangent at point t.
178 * @param[in] progress A floating point value between 0.0 and 1.0.
179 * @param[out] tangent The interpolated tangent at that progress.
181 Vector3 SampleTangent( float t ) const;
184 * @copydoc Dali::Path::GetPoint
186 Vector3& GetPoint( size_t index );
189 * @copydoc Dali::Path::GetControlPoint
191 Vector3& GetControlPoint( size_t index );
194 * @copydoc Dali::Path::GetPointCount
196 size_t GetPointCount() const;
199 * @brief Get mPoint property
201 * @return A const reference to mPoint vector
203 const Dali::Vector<Vector3>& GetPoints() const{ return mPoint; }
208 * @param[in] p New value for mPoint property
210 void SetPoints( const Dali::Vector<Vector3>& p ){ mPoint = p; }
213 * @brief Get mCotrolPoint property
215 * @return A const reference to mControlPoint vector
217 const Dali::Vector<Vector3>& GetControlPoints() const{ return mControlPoint; }
220 * @brief Set mControlPoint property
222 * @param[in] p New value for mControlPoint property
224 void SetControlPoints( const Dali::Vector<Vector3>& p ){ mControlPoint = p; }
236 Path& operator=(const Path& rhs);
239 * Helper function to calculate the segment and local progress in that segment
242 * @param[in] t Progress
243 * @param[out] segment Segment for t
244 * @param[out] tLocal Local progress in the segment
247 void FindSegmentAndProgress( float t, unsigned int& segment, float& tLocal ) const;
250 * Helper function to calculate to number of segments in the path
252 unsigned int GetNumberOfSegments() const;
254 Dali::Vector<Vector3> mPoint; ///< Interpolation points
255 Dali::Vector<Vector3> mControlPoint; ///< Control points
260 // Get impl of handle
261 inline Internal::Path& GetImplementation(Dali::Path& path)
263 DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
264 Dali::RefObject& object = path.GetBaseObject();
265 return static_cast<Internal::Path&>(object);
268 inline const Internal::Path& GetImplementation(const Dali::Path& path)
270 DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
271 const Dali::RefObject& object = path.GetBaseObject();
272 return static_cast<const Internal::Path&>(object);
278 #endif //__DALI_INTERNAL_KEY_FRAMES_H__