]> git.sesse.net Git - kdenlive/blobdiff - src/beziercurve/cubicbezierspline.h
Merge branch 'buildsystem'
[kdenlive] / src / beziercurve / cubicbezierspline.h
index 078066e29cc20f8d47ba2eda471ca233d5d907ed..ee21c987f5f7b9e58d116e03f8dfae433f05b210 100644 (file)
 #ifndef CUBICBEZIERSPLINE_H
 #define CUBICBEZIERSPLINE_H
 
+#include "bpoint.h"
 
 #include <QtCore>
 
-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
 {
@@ -41,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 <BPoint> 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<QPointF> &points);
     void validatePoints();
     void keepSorted();
-    void update();
+    int indexOf(const BPoint &p);
 
     QList <BPoint> m_points;
-    QMap <double, double> m_spline;
-    QMap <double, double>::const_iterator m_i;
-    bool m_validSpline;
-    int m_precision;
-    
 };
 
 #endif