1 #ifndef DALI_INTERNAL_PATH_H
2 #define DALI_INTERNAL_PATH_H
5 * Copyright (c) 2019 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/object-impl.h>
33 typedef IntrusivePtr<Path> PathPtr;
38 class Path : public Object
43 * Construct a new path
62 * @copydoc Dali::Internal::Object::SetDefaultProperty()
64 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
67 * @copydoc Dali::Internal::Object::GetDefaultProperty()
69 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
74 * Returns a clone to the given path
76 static Path* Clone(const Path& path);
79 * @copydoc Dali::Path::AddPoint
81 void AddPoint(const Vector3& point );
84 * @copydoc Dali::Path::AddControlPoint
86 void AddControlPoint(const Vector3& point );
89 * @copydoc Dali::Path::GenerateControlPoints
91 void GenerateControlPoints( float curvature );
94 * @copydoc Dali::Path::Sample
96 void Sample( float t, Vector3& position, Vector3& tangent ) const;
99 * @brief Sample path at a given progress. Calculates position and tangent at that point of the curve
101 * @param[in] progress A floating point value between 0.0 and 1.0.
102 * @param[out] position The interpolated position at that progress.
103 * @param[out] tangent The interpolated tangent at that progress.
104 * @return true if Sample could be calculated
106 bool SampleAt( float t, Vector3& position, Vector3& tangent ) const;
109 * Sample position at point t.
111 * @param[in] progress A floating point value between 0.0 and 1.0.
112 * @param[out] position The interpolated position at that progress.
113 * @return true if sample could be calculated
115 bool SamplePosition( float t, Vector3& position ) const;
118 * @brief Sample tangent at point t.
120 * @param[in] progress A floating point value between 0.0 and 1.0.
121 * @param[out] tangent The interpolated tangent at that progress.
122 * @return true if sample could be calculated
124 bool SampleTangent( float t, Vector3& tangent ) const;
127 * @copydoc Dali::Path::GetPoint
129 Vector3& GetPoint( uint32_t index );
132 * @copydoc Dali::Path::GetControlPoint
134 Vector3& GetControlPoint( uint32_t index );
137 * @copydoc Dali::Path::GetPointCount
139 uint32_t GetPointCount() const;
142 * Clears the points of the path
147 * Clears the control points of the path
149 void ClearControlPoints();
152 * @brief Get mPoint property
154 * @return A const reference to mPoint vector
156 const Dali::Vector<Vector3>& GetPoints() const{ return mPoint; }
161 * @param[in] p New value for mPoint property
163 void SetPoints( const Dali::Vector<Vector3>& p ){ mPoint = p; }
166 * @brief Get mCotrolPoint property
168 * @return A const reference to mControlPoint vector
170 const Dali::Vector<Vector3>& GetControlPoints() const{ return mControlPoint; }
173 * @brief Set mControlPoint property
175 * @param[in] p New value for mControlPoint property
177 void SetControlPoints( const Dali::Vector<Vector3>& p ){ mControlPoint = p; }
189 Path& operator=(const Path& rhs);
192 * Helper function to calculate the segment and local progress in that segment
195 * @param[in] t Progress
196 * @param[out] segment Segment for t
197 * @param[out] tLocal Local progress in the segment
200 void FindSegmentAndProgress( float t, uint32_t& segment, float& tLocal ) const;
203 * Helper function to calculate to number of segments in the path
205 uint32_t GetNumberOfSegments() const;
207 Dali::Vector<Vector3> mPoint; ///< Interpolation points
208 Dali::Vector<Vector3> mControlPoint; ///< Control points
213 // Get impl of handle
214 inline Internal::Path& GetImplementation(Dali::Path& path)
216 DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
217 Dali::RefObject& object = path.GetBaseObject();
218 return static_cast<Internal::Path&>(object);
221 inline const Internal::Path& GetImplementation(const Dali::Path& path)
223 DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
224 const Dali::RefObject& object = path.GetBaseObject();
225 return static_cast<const Internal::Path&>(object);
231 #endif // DALI_INTERNAL_PATH_H