#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 QList< QPointF > &points, bool setAsCorner) |
| |
| | 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/6]
| 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/6]
| KisCubicCurve::KisCubicCurve |
( |
const QList< QPointF > & | points | ) |
|
◆ KisCubicCurve() [3/6]
| KisCubicCurve::KisCubicCurve |
( |
const QList< QPointF > & | points, |
|
|
bool | setAsCorner ) |
◆ KisCubicCurve() [4/6]
◆ KisCubicCurve() [5/6]
| KisCubicCurve::KisCubicCurve |
( |
const QString & | curveString | ) |
|
Definition at line 195 of file kis_cubic_curve.cpp.
197{
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
215
218 return;
219 }
220
222
224 Q_FOREACH (
const QString &entry,
data) {
225 const QStringList entryData = entry.split(
',', Qt::SkipEmptyParts);
228 return;
229 }
230 bool ok;
234 return;
235 }
239 return;
240 }
241 bool isCorner = false;
242 for (int i = 2; i < entryData.size(); ++i) {
243 if (entryData[i] == "is_corner") {
244 isCorner = true;
245 }
246 }
248 }
249
251}
#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() [6/6]
◆ ~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 342 of file kis_cubic_curve.cpp.
343{
345 d->data->points.append(point);
346 d->data->keepSorted();
347 d->data->invalidate();
348
349 return d->data->points.indexOf(point);
350}
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 473 of file kis_cubic_curve.cpp.
474{
475 d->data->updateTransfer<qreal, qreal>(&
d->data->fTransfer,
d->data->validFTransfer, 0.0, 1.0,
size);
476 return d->data->fTransfer;
477}
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 405 of file kis_cubic_curve.cpp.
406{
407 const qreal maxValue = transfer.size() - 1;
408
409 const qreal bilinearX = qBound(0.0, maxValue * normalizedValue, maxValue);
410 const qreal xFloored = std::floor(bilinearX);
411 const qreal xCeiled = std::ceil(bilinearX);
412
413 const qreal t = bilinearX - xFloored;
414
415 constexpr qreal
eps = 1e-6;
416
417 qreal newValue = normalizedValue;
418
420 newValue = transfer[int(xFloored)];
421 }
else if (t > (1.0 -
eps)) {
422 newValue = transfer[int(xCeiled)];
423 } else {
424 qreal a = transfer[int(xFloored)];
425 qreal
b = transfer[int(xCeiled)];
426
427 newValue = a + t * (
b - a);
428 }
429
431}
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 258 of file kis_cubic_curve.cpp.
259{
260 if (&curve != this) {
262 }
263 return *this;
264}
References d.
◆ operator==()
| bool KisCubicCurve::operator== |
( |
const KisCubicCurve & | curve | ) |
const |
Definition at line 266 of file kis_cubic_curve.cpp.
267{
268 if (
d->data == curve.
d->data)
return true;
269 return d->data->points == curve.
d->data->points;
270}
References d.
◆ points()
| Q_DECL_DEPRECATED QList< QPointF > KisCubicCurve::points |
( |
| ) |
const |
Deprecated. Use curvePoints instead
◆ removePoint()
| void KisCubicCurve::removePoint |
( |
int | idx | ) |
|
Definition at line 362 of file kis_cubic_curve.cpp.
363{
365 d->data->points.removeAt(idx);
366 d->data->invalidate();
367}
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 433 of file kis_cubic_curve.cpp.
434{
435 d->data->name =
name;
436}
References d, and name.
◆ setPoint() [1/3]
Definition at line 309 of file kis_cubic_curve.cpp.
310{
312 d->data->points[idx] = point;
313 d->data->keepSorted();
314 d->data->invalidate();
315}
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 335 of file kis_cubic_curve.cpp.
336{
338 d->data->points[idx].setAsCorner(setAsCorner);
339 d->data->invalidate();
340}
References d.
◆ setPointPosition()
| void KisCubicCurve::setPointPosition |
( |
int | idx, |
|
|
const QPointF & | position ) |
Definition at line 327 of file kis_cubic_curve.cpp.
328{
330 d->data->points[idx].setPosition(position);
331 d->data->keepSorted();
332 d->data->invalidate();
333}
References d.
◆ setPoints() [1/2]
◆ setPoints() [2/2]
| void KisCubicCurve::setPoints |
( |
const QList< QPointF > & | points | ) |
|
Definition at line 292 of file kis_cubic_curve.cpp.
293{
295 d->data->points.clear();
296 Q_FOREACH(
const QPointF &
p,
points) {
297 d->data->points.append({
p,
false });
298 }
299 d->data->invalidate();
300}
References d, p, and points.
◆ toString()
| QString KisCubicCurve::toString |
( |
| ) |
const |
◆ uint16Transfer()
| const QVector< quint16 > KisCubicCurve::uint16Transfer |
( |
int | size = 256 | ) |
const |
Definition at line 467 of file kis_cubic_curve.cpp.
468{
469 d->data->updateTransfer<quint16,
int>(&
d->data->u16Transfer,
d->data->validU16Transfer, 0x0, 0xFFFF,
size);
470 return d->data->u16Transfer;
471}
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: