X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbeziercurve%2Fcubicbezierspline.h;h=ee21c987f5f7b9e58d116e03f8dfae433f05b210;hb=6898a01de5854d00ebb724b4b77e3d59c0d2d9be;hp=4ddd0ce807869001d5d386504e57a4e9bc72b2ea;hpb=8f59e06aedf509255edb93295514c40eab2adf18;p=kdenlive diff --git a/src/beziercurve/cubicbezierspline.h b/src/beziercurve/cubicbezierspline.h index 4ddd0ce8..ee21c987 100644 --- a/src/beziercurve/cubicbezierspline.h +++ b/src/beziercurve/cubicbezierspline.h @@ -19,19 +19,10 @@ #ifndef CUBICBEZIERSPLINE_H #define CUBICBEZIERSPLINE_H +#include "bpoint.h" #include -class BPoint -{ -public: - QPointF h1; // handle 1 - QPointF p; // point - QPointF h2; // handle 2 - - BPoint() { p = QPointF(-1,-1); } // makes it illegal -> cannot be equal any point - bool operator==(const BPoint &point) const { return point.h1 == h1 && point.p == p && point.h2 == h2; } -}; class CubicBezierSpline : public QObject { @@ -42,30 +33,47 @@ public: 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; + /** @brief Returns a list of the points defining the spline. */ QList points(); - qreal value(qreal x, bool cont = false); + /** @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