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::IsSceneObjectRemovable()
78 virtual bool IsSceneObjectRemovable() const{ return false;}
81 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
83 virtual unsigned int GetDefaultPropertyCount() const;
86 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
88 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
91 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
93 virtual const char* GetDefaultPropertyName(Property::Index index) const;
96 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
98 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
101 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
103 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
106 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
108 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
111 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
113 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
116 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
118 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
121 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
123 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
126 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
128 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
131 * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
133 virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ){}
136 * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
138 virtual const SceneGraph::PropertyOwner* GetSceneObject() const{ return NULL; }
141 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
143 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const{ return NULL; }
146 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
148 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const{ return NULL; }
153 * Returns a clone to the given path
155 static Path* Clone(const Path& path);
158 * @copydoc Dali::Path::AddPoint
160 void AddPoint(const Vector3& point );
163 * @copydoc Dali::Path::AddControlPoint
165 void AddControlPoint(const Vector3& point );
168 * @copydoc Dali::Path::GenerateControlPoints
170 void GenerateControlPoints( float curvature );
173 * @copydoc Dali::Path::Sample
175 void Sample( float t, Vector3& position, Vector3& tangent ) const;
178 * Sample position at point t.
180 * @param[in] progress A floating point value between 0.0 and 1.0.
181 * @param[out] position The interpolated position at that progress.
183 Vector3 SamplePosition( float t ) const;
186 * @brief Sample tangent at point t.
188 * @param[in] progress A floating point value between 0.0 and 1.0.
189 * @param[out] tangent The interpolated tangent at that progress.
191 Vector3 SampleTangent( float t ) const;
194 * @copydoc Dali::Path::GetPoint
196 Vector3& GetPoint( size_t index );
199 * @copydoc Dali::Path::GetControlPoint
201 Vector3& GetControlPoint( size_t index );
204 * @copydoc Dali::Path::GetPointCount
206 size_t GetPointCount() const;
209 * @brief Get mPoint property
211 * @return A const reference to mPoint vector
213 const Dali::Vector<Vector3>& GetPoints() const{ return mPoint; }
218 * @param[in] p New value for mPoint property
220 void SetPoints( const Dali::Vector<Vector3>& p ){ mPoint = p; }
223 * @brief Get mCotrolPoint property
225 * @return A const reference to mControlPoint vector
227 const Dali::Vector<Vector3>& GetControlPoints() const{ return mControlPoint; }
230 * @brief Set mControlPoint property
232 * @param[in] p New value for mControlPoint property
234 void SetControlPoints( const Dali::Vector<Vector3>& p ){ mControlPoint = p; }
246 Path& operator=(const Path& rhs);
249 * Helper function to calculate the segment and local progress in that segment
252 * @param[in] t Progress
253 * @param[out] segment Segment for t
254 * @param[out] tLocal Local progress in the segment
257 void FindSegmentAndProgress( float t, unsigned int& segment, float& tLocal ) const;
260 * Helper function to calculate to number of segments in the path
262 unsigned int GetNumberOfSegments() const;
264 Dali::Vector<Vector3> mPoint; ///< Interpolation points
265 Dali::Vector<Vector3> mControlPoint; ///< Control points
270 // Get impl of handle
271 inline Internal::Path& GetImplementation(Dali::Path& path)
273 DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
274 Dali::RefObject& object = path.GetBaseObject();
275 return static_cast<Internal::Path&>(object);
278 inline const Internal::Path& GetImplementation(const Dali::Path& path)
280 DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
281 const Dali::RefObject& object = path.GetBaseObject();
282 return static_cast<const Internal::Path&>(object);
288 #endif //__DALI_INTERNAL_KEY_FRAMES_H__