X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fbeziercurve%2Fcubicbezierspline.h;h=7cd0275e5bc3905375402f918e9b8cb11f14c463;hb=96d7f5a694d5440a935562a441060a42b447a998;hp=078066e29cc20f8d47ba2eda471ca233d5d907ed;hpb=60d9d6db7d92c37de9e20f10c137552aa0cafbce;p=kdenlive diff --git a/src/beziercurve/cubicbezierspline.h b/src/beziercurve/cubicbezierspline.h index 078066e2..7cd0275e 100644 --- a/src/beziercurve/cubicbezierspline.h +++ b/src/beziercurve/cubicbezierspline.h @@ -19,52 +19,61 @@ #ifndef CUBICBEZIERSPLINE_H #define CUBICBEZIERSPLINE_H +#include "bpoint.h" #include -class BPoint -{ -public: - QPointF h1; // handle 1 - QPointF p; // point - QPointF h2; // handle 2 - - bool operator==(const BPoint &point) const { return point.h1 == h1 && point.p == p && point.h2 == h2; } -}; class CubicBezierSpline : public QObject { Q_OBJECT public: - CubicBezierSpline(QObject* parent = 0); + explicit CubicBezierSpline(QObject* parent = 0); CubicBezierSpline(const CubicBezierSpline &spline, QObject* parent = 0); CubicBezierSpline& operator=(const CubicBezierSpline &spline); + /** @brief Loads the points from the string @param spline. + * + * x, y values have to be separated with a ';' + * handles and points with a '#' + * and the nodes with a '|' + * So that you get: h1x;h1y#px;py#h2x;h2y|h1x;h1y#... */ void fromString(const QString &spline); + /** @brief Returns the points stoed in a string. + * + * x, y values have are separated with a ';' + * handles and points with a '#' + * and the nodes with a '|' + * So that you get: h1x;h1y#px;py#h2x;h2y|h1x;h1y#... */ QString toString() const; - QList points(); - qreal value(qreal x, bool cont = false); + /** @brief Returns a list of the points defining the spline. */ + QList points() const; + /** @brief Sets the point at index @param ix to @param point and returns its index (it might have changed during validation). */ int setPoint(int ix, const BPoint &point); + /** @brief Adds @param point and returns its index. */ int addPoint(const BPoint &point); + /** @brief Removes the point at @param ix. */ void removePoint(int ix); - void setPrecision(int pre); - int getPrecision(); + + /** @brief Returns the point at @param ix. + * @param ix Index of the point + * @param normalisedWidth (default = 1) Will be multiplied will all x values to change the range from 0-1 into another one + * @param normalisedHeight (default = 1) Will be multiplied will all y values to change the range from 0-1 into another one + * @param invertHeight (default = false) true => y = 0 is at the very top + */ + BPoint getPoint(int ix, int normalisedWidth = 1, int normalisedHeight = 1, bool invertHeight = false); + + private: - QPointF point(double t, const QList &points); void validatePoints(); void keepSorted(); - void update(); + int indexOf(const BPoint &p); QList m_points; - QMap m_spline; - QMap ::const_iterator m_i; - bool m_validSpline; - int m_precision; - }; #endif