Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_cubic_curve.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2010 Cyrille Berger <cberger@cberger.net>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef _KIS_CUBIC_CURVE_H_
8#define _KIS_CUBIC_CURVE_H_
9
10#include <boost/operators.hpp>
11
12#include<QList>
13#include<QVector>
14#include<QPointF>
15#include<QVariant>
16
18
19#include <kritaimage_export.h>
20
21const QString DEFAULT_CURVE_STRING = "0,0;1,1;";
22
23class KRITAIMAGE_EXPORT KisCubicCurvePoint
24{
25public:
26 KisCubicCurvePoint() = default;
28 KisCubicCurvePoint(const QPointF &position, bool setAsCorner = false);
29 KisCubicCurvePoint(qreal x, qreal y, bool setAsCorner = false);
31
32 bool operator==(const KisCubicCurvePoint &other) const;
33
34 qreal x() const;
35 qreal y() const;
36 const QPointF& position() const;
37 bool isSetAsCorner() const;
38
39 void setX(qreal newX);
40 void setY(qreal newY);
41 void setPosition(const QPointF &newPosition);
42 void setAsCorner(bool newIsSetAsCorner);
43
44private:
45 QPointF m_position;
46 bool m_isCorner { false };
47};
48
50
51
54class KRITAIMAGE_EXPORT KisCubicCurve : public boost::equality_comparable<KisCubicCurve>
55{
56public:
58
59 KisCubicCurve(const QList<QPointF>& points);
60 KisCubicCurve(const QList<QPointF>& points, bool setAsCorner);
62
63 KisCubicCurve(const QString &curveString);
64 KisCubicCurve(const KisCubicCurve& curve);
66 KisCubicCurve& operator=(const KisCubicCurve& curve);
67 bool operator==(const KisCubicCurve& curve) const;
68public:
69 qreal value(qreal x) const;
73 Q_DECL_DEPRECATED QList<QPointF> points() const;
74 const QList<KisCubicCurvePoint>& curvePoints() const;
75 void setPoints(const QList<QPointF>& points);
76 void setPoints(const QList<KisCubicCurvePoint>& points);
77 void setPoint(int idx, const KisCubicCurvePoint& point);
78 void setPoint(int idx, const QPointF& position, bool setAsCorner);
79 void setPoint(int idx, const QPointF& position);
80 void setPointPosition(int idx, const QPointF& position);
81 void setPointAsCorner(int idx, bool setAsCorner);
86 int addPoint(const KisCubicCurvePoint& point);
87 int addPoint(const QPointF& position, bool setAsCorner);
88 int addPoint(const QPointF& position);
89 void removePoint(int idx);
90
91 /*
92 * Check whether the curve maps all values to themselves.
93 */
94 bool isIdentity() const;
95
96 /*
97 * Check whether the curve maps all values to given constant.
98 */
99 bool isConstant(qreal c) const;
100
106 void setName(const QString& name);
107 const QString& name() const;
108
109 static qreal interpolateLinear(qreal normalizedValue, const QVector<qreal> &transfer);
110
111public:
112 const QVector<quint16> uint16Transfer(int size = 256) const;
113 const QVector<qreal> floatTransfer(int size = 256) const;
114public:
115 QString toString() const;
116 Q_DECL_DEPRECATED void fromString(const QString&);
117private:
118 struct Data;
119 struct Private;
120 Private* const d {nullptr};
121};
122
124
125#endif
float value(const T *src, size_t ch)
bool operator==(const KisRegion &lhs, const KisRegion &rhs)
KisCubicCurvePoint & operator=(const KisCubicCurvePoint &)=default
KisCubicCurvePoint(const KisCubicCurvePoint &)=default
KisCubicCurvePoint()=default
const QString DEFAULT_CURVE_STRING
Q_DECLARE_METATYPE(KisPaintopLodLimitations)
const QString & name() const
Q_DECL_DEPRECATED QList< QPointF > points() const