File indexing completed on 2024-06-16 04:35:04
0001 /* 0002 SPDX-FileCopyrightText: 2010 Cyrille Berger <cberger@cberger.net> 0003 0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QList> 0010 #include <QVector> 0011 0012 class QPointF; 0013 0014 /** @class KisCubicCurve 0015 @brief Hold the data for a cubic curve. 0016 */ 0017 class KisCubicCurve 0018 { 0019 public: 0020 using Point_t = QPointF; 0021 KisCubicCurve(); 0022 explicit KisCubicCurve(const QList<QPointF> &points); 0023 KisCubicCurve(const KisCubicCurve &curve); 0024 ~KisCubicCurve(); 0025 KisCubicCurve &operator=(const KisCubicCurve &curve); 0026 bool operator==(const KisCubicCurve &curve) const; 0027 0028 public: 0029 qreal value(qreal x) const; 0030 QList<QPointF> points() const; 0031 void setPoints(const QList<QPointF> &points); 0032 int setPoint(int idx, const QPointF &point); 0033 /** 0034 * Add a point to the curve, the list of point is always sorted. 0035 * @return the index of the inserted point 0036 */ 0037 int addPoint(const QPointF &point); 0038 void removePoint(int idx); 0039 /** @brief Returns the number of points on the curve 0040 */ 0041 int count() const; 0042 /** @brief Returns the point at @param ix. 0043 * @param ix Index of the point 0044 * @param normalisedWidth (default = 1) Will be multiplied will all x values to change the range from 0-1 into another one 0045 * @param normalisedHeight (default = 1) Will be multiplied will all y values to change the range from 0-1 into another one 0046 * @param invertHeight (default = false) true => y = 0 is at the very top 0047 */ 0048 QPointF getPoint(int ix, int normalisedWidth = 1, int normalisedHeight = 1, bool invertHeight = false); 0049 0050 public: 0051 QVector<quint16> uint16Transfer(int size = 256) const; 0052 QVector<qreal> floatTransfer(int size = 256) const; 0053 0054 public: 0055 const QString toString() const; 0056 void fromString(const QString &); 0057 0058 private: 0059 struct Data; 0060 struct Private; 0061 Private *const d; // NOLINT 0062 };