#include <kis_cubic_curve.h>
|
| int | addPoint (const KisCubicCurvePoint &point) |
| |
| int | addPoint (const QPointF &position) |
| |
| int | addPoint (const QPointF &position, bool setAsCorner) |
| |
| const QList< KisCubicCurvePoint > & | curvePoints () const |
| |
| | Data () |
| |
| | Data (const Data &data) |
| |
| const QVector< qreal > | floatTransfer (int size=256) const |
| |
| Q_DECL_DEPRECATED void | fromString (const QString &) |
| |
| void | invalidate () |
| |
| bool | isConstant (qreal c) const |
| |
| bool | isIdentity () const |
| |
| void | keepSorted () |
| |
| | KisCubicCurve () |
| |
| | KisCubicCurve (const KisCubicCurve &curve) |
| |
| | KisCubicCurve (const QList< KisCubicCurvePoint > &points) |
| |
| | KisCubicCurve (const QList< QPointF > &points) |
| |
| | KisCubicCurve (const QString &curveString) |
| |
| const QString & | name () const |
| |
| KisCubicCurve & | operator= (const KisCubicCurve &curve) |
| |
| bool | operator== (const KisCubicCurve &curve) const |
| |
| Q_DECL_DEPRECATED QList< QPointF > | points () const |
| |
| void | removePoint (int idx) |
| |
| void | setName (const QString &name) |
| |
| void | setPoint (int idx, const KisCubicCurvePoint &point) |
| |
| void | setPoint (int idx, const QPointF &position) |
| |
| void | setPoint (int idx, const QPointF &position, bool setAsCorner) |
| |
| void | setPointAsCorner (int idx, bool setAsCorner) |
| |
| void | setPointPosition (int idx, const QPointF &position) |
| |
| void | setPoints (const QList< KisCubicCurvePoint > &points) |
| |
| void | setPoints (const QList< QPointF > &points) |
| |
| QString | toString () const |
| |
| const QVector< quint16 > | uint16Transfer (int size=256) const |
| |
| void | updateSpline () |
| |
| template<typename _T_ , typename _T2_ > |
| void | updateTransfer (QVector< _T_ > *transfer, bool &valid, _T2_ min, _T2_ max, int size) |
| |
| qreal | value (qreal x) |
| |
| qreal | value (qreal x) const |
| |
| | ~Data () |
| |
| | ~KisCubicCurve () |
| |
| | Private (KisCanvas2 *c) |
| |
Hold the data for a cubic curve.
Definition at line 76 of file kis_cubic_curve.cpp.
◆ ~Data()
◆ KisCubicCurve() [1/5]
| KisCubicCurve::KisCubicCurve |
( |
| ) |
|
Definition at line 158 of file kis_cubic_curve.cpp.
160{
162 d->data->points.append({ 0.0, 0.0,
false });
163 d->data->points.append({ 1.0, 1.0,
false });
164}
References d, and Data().
◆ KisCubicCurve() [2/5]
| KisCubicCurve::KisCubicCurve |
( |
const QList< QPointF > & | points | ) |
|
Definition at line 166 of file kis_cubic_curve.cpp.
168{
170 d->data->points.reserve(
points.size());
171 Q_FOREACH(
const QPointF
p,
points) {
172 d->data->points.append({
p,
false });
173 }
174 d->data->keepSorted();
175}
QList< KisCubicCurvePoint > points
References d, Data(), p, and points.
◆ KisCubicCurve() [3/5]
◆ KisCubicCurve() [4/5]
| KisCubicCurve::KisCubicCurve |
( |
const QString & | curveString | ) |
|
Definition at line 190 of file kis_cubic_curve.cpp.
192{
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
210
213 return;
214 }
215
217
219 Q_FOREACH (
const QString &entry,
data) {
220 const QStringList entryData = entry.split(
',', Qt::SkipEmptyParts);
223 return;
224 }
225 bool ok;
229 return;
230 }
234 return;
235 }
236 bool isCorner = false;
237 for (int i = 2; i < entryData.size(); ++i) {
238 if (entryData[i] == "is_corner") {
239 isCorner = true;
240 }
241 }
243 }
244
246}
#define KIS_SAFE_ASSERT_RECOVER(cond)
double toDouble(const QString &str, bool *ok=nullptr)
void setPoints(const QList< QPointF > &points)
QSharedDataPointer< Data > data
References d, Data(), data, KIS_SAFE_ASSERT_RECOVER, KisCubicCurve(), points, setPoints(), and KisDomUtils::toDouble().
◆ KisCubicCurve() [5/5]
◆ ~KisCubicCurve()
| KisCubicCurve::~KisCubicCurve |
( |
| ) |
|
◆ addPoint() [1/3]
Add a point to the curve, the list of point is always sorted.
- Returns
- the index of the inserted point
Definition at line 337 of file kis_cubic_curve.cpp.
338{
340 d->data->points.append(point);
341 d->data->keepSorted();
342 d->data->invalidate();
343
344 return d->data->points.indexOf(point);
345}
References d.
◆ addPoint() [2/3]
| int KisCubicCurve::addPoint |
( |
const QPointF & | position | ) |
|
◆ addPoint() [3/3]
| int KisCubicCurve::addPoint |
( |
const QPointF & | position, |
|
|
bool | setAsCorner ) |
◆ curvePoints()
◆ Data() [1/2]
◆ Data() [2/2]
| KisCubicCurve::Data |
( |
const Data & | data | ) |
|
|
inline |
◆ floatTransfer()
| const QVector< qreal > KisCubicCurve::floatTransfer |
( |
int | size = 256 | ) |
const |
Definition at line 468 of file kis_cubic_curve.cpp.
469{
470 d->data->updateTransfer<qreal, qreal>(&
d->data->fTransfer,
d->data->validFTransfer, 0.0, 1.0,
size);
471 return d->data->fTransfer;
472}
int size(const Forest< T > &forest)
References d.
◆ fromString()
| void KisCubicCurve::fromString |
( |
const QString & | string | ) |
|
◆ interpolateLinear()
| qreal KisCubicCurve::interpolateLinear |
( |
qreal | normalizedValue, |
|
|
const QVector< qreal > & | transfer ) |
|
static |
Definition at line 400 of file kis_cubic_curve.cpp.
401{
402 const qreal maxValue = transfer.size() - 1;
403
404 const qreal bilinearX = qBound(0.0, maxValue * normalizedValue, maxValue);
405 const qreal xFloored = std::floor(bilinearX);
406 const qreal xCeiled = std::ceil(bilinearX);
407
408 const qreal t = bilinearX - xFloored;
409
410 constexpr qreal
eps = 1e-6;
411
412 qreal newValue = normalizedValue;
413
415 newValue = transfer[int(xFloored)];
416 }
else if (t > (1.0 -
eps)) {
417 newValue = transfer[int(xCeiled)];
418 } else {
419 qreal a = transfer[int(xFloored)];
420 qreal
b = transfer[int(xCeiled)];
421
422 newValue = a + t * (
b - a);
423 }
424
426}
References KisAlgebra2D::copysign(), and eps.
◆ invalidate()
| void KisCubicCurve::invalidate |
( |
| ) |
|
◆ isConstant()
| bool KisCubicCurve::isConstant |
( |
qreal | c | ) |
const |
◆ isIdentity()
| bool KisCubicCurve::isIdentity |
( |
| ) |
const |
◆ keepSorted()
| void KisCubicCurve::keepSorted |
( |
| ) |
|
◆ name()
| const QString & KisCubicCurve::name |
( |
| ) |
const |
◆ operator=()
Definition at line 253 of file kis_cubic_curve.cpp.
254{
255 if (&curve != this) {
257 }
258 return *this;
259}
References d.
◆ operator==()
| bool KisCubicCurve::operator== |
( |
const KisCubicCurve & | curve | ) |
const |
Definition at line 261 of file kis_cubic_curve.cpp.
262{
263 if (
d->data == curve.
d->data)
return true;
264 return d->data->points == curve.
d->data->points;
265}
References d.
◆ points()
| Q_DECL_DEPRECATED QList< QPointF > KisCubicCurve::points |
( |
| ) |
const |
Deprecated. Use curvePoints instead
◆ removePoint()
| void KisCubicCurve::removePoint |
( |
int | idx | ) |
|
Definition at line 357 of file kis_cubic_curve.cpp.
358{
360 d->data->points.removeAt(idx);
361 d->data->invalidate();
362}
References d.
◆ setName()
| void KisCubicCurve::setName |
( |
const QString & | name | ) |
|
This allows us to carry around a display name for the curve internally. It is used currently in Sketch for perchannel, but would potentially be useful anywhere curves are used in the UI
Definition at line 428 of file kis_cubic_curve.cpp.
429{
430 d->data->name =
name;
431}
References d, and name.
◆ setPoint() [1/3]
Definition at line 304 of file kis_cubic_curve.cpp.
305{
307 d->data->points[idx] = point;
308 d->data->keepSorted();
309 d->data->invalidate();
310}
References d.
◆ setPoint() [2/3]
| void KisCubicCurve::setPoint |
( |
int | idx, |
|
|
const QPointF & | position ) |
◆ setPoint() [3/3]
| void KisCubicCurve::setPoint |
( |
int | idx, |
|
|
const QPointF & | position, |
|
|
bool | setAsCorner ) |
◆ setPointAsCorner()
| void KisCubicCurve::setPointAsCorner |
( |
int | idx, |
|
|
bool | setAsCorner ) |
Definition at line 330 of file kis_cubic_curve.cpp.
331{
333 d->data->points[idx].setAsCorner(setAsCorner);
334 d->data->invalidate();
335}
References d.
◆ setPointPosition()
| void KisCubicCurve::setPointPosition |
( |
int | idx, |
|
|
const QPointF & | position ) |
Definition at line 322 of file kis_cubic_curve.cpp.
323{
325 d->data->points[idx].setPosition(position);
326 d->data->keepSorted();
327 d->data->invalidate();
328}
References d.
◆ setPoints() [1/2]
◆ setPoints() [2/2]
| void KisCubicCurve::setPoints |
( |
const QList< QPointF > & | points | ) |
|
Definition at line 287 of file kis_cubic_curve.cpp.
288{
290 d->data->points.clear();
291 Q_FOREACH(
const QPointF &
p,
points) {
292 d->data->points.append({
p,
false });
293 }
294 d->data->invalidate();
295}
References d, p, and points.
◆ toString()
| QString KisCubicCurve::toString |
( |
| ) |
const |
◆ uint16Transfer()
| const QVector< quint16 > KisCubicCurve::uint16Transfer |
( |
int | size = 256 | ) |
const |
Definition at line 462 of file kis_cubic_curve.cpp.
463{
464 d->data->updateTransfer<quint16,
int>(&
d->data->u16Transfer,
d->data->validU16Transfer, 0x0, 0xFFFF,
size);
465 return d->data->u16Transfer;
466}
References d.
◆ updateSpline()
| void KisCubicCurve::updateSpline |
( |
| ) |
|
◆ updateTransfer()
template<typename _T_ , typename _T2_ >
| void KisCubicCurve::updateTransfer |
( |
QVector< _T_ > * | transfer, |
|
|
bool & | valid, |
|
|
_T2_ | min, |
|
|
_T2_ | max, |
|
|
int | size ) |
◆ value() [1/2]
| qreal KisCubicCurve::value |
( |
qreal | x | ) |
|
◆ value() [2/2]
| qreal KisCubicCurve::value |
( |
qreal | x | ) |
const |
| Private* const KisCubicCurve::d {nullptr} |
|
private |
◆ data
| QSharedDataPointer<Data> KisCubicCurve::data |
◆ fTransfer
| QVector<qreal> KisCubicCurve::fTransfer |
|
mutable |
◆ name
| const QString & KisCubicCurve::name |
|
mutable |
◆ points
| QList< QPointF > KisCubicCurve::points |
◆ spline
◆ u16Transfer
| QVector<quint16> KisCubicCurve::u16Transfer |
|
mutable |
◆ u8Transfer
| QVector<quint8> KisCubicCurve::u8Transfer |
|
mutable |
◆ validFTransfer
| bool KisCubicCurve::validFTransfer {false} |
|
mutable |
◆ validSpline
| bool KisCubicCurve::validSpline {false} |
|
mutable |
◆ validU16Transfer
| bool KisCubicCurve::validU16Transfer {false} |
|
mutable |
◆ validU8Transfer
| bool KisCubicCurve::validU8Transfer {false} |
|
mutable |
The documentation for this class was generated from the following files: