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 <BPoint> points();
- qreal value(qreal x, bool cont = false);
+ /** @brief Returns a list of the points defining the spline. */
+ QList <BPoint> 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<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