Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPaintInformation Class Reference

#include <kis_paint_information.h>

Classes

class  DistanceInformationRegistrar
 
struct  Private
 

Public Member Functions

bool canvasMirroredH () const
 
bool canvasMirroredV () const
 
qreal canvasRotation () const
 
int currentDabSeqNo () const
 Number of dabs painted since the beginning of the stroke.
 
qreal currentTime () const
 Number of ms since the beginning of the stroke.
 
qreal drawingAngle (bool considerLockedAngle=false) const
 
qreal drawingAngleSafe (const KisDistanceInformation &distance) const
 XXX !!! :-| Please add dox!
 
QPointF drawingDirectionVector () const
 
qreal drawingDistance () const
 
qreal drawingSpeed () const
 
bool isHoveringMode () const
 
 KisPaintInformation (const KisPaintInformation &rhs)
 
 KisPaintInformation (const QPointF &pos, qreal pressure, qreal xTilt, qreal yTilt, qreal rotation)
 
 KisPaintInformation (const QPointF &pos, qreal pressure, qreal xTilt, qreal yTilt, qreal rotation, qreal tangentialPressure, qreal perspective, qreal time, qreal speed)
 
 KisPaintInformation (const QPointF &pos=QPointF(), qreal pressure=PRESSURE_DEFAULT)
 
qreal maxPressure () const
 
void mixOtherOnlyPosition (qreal t, const KisPaintInformation &other)
 
void mixOtherWithoutTime (qreal t, const KisPaintInformation &other)
 
void operator= (const KisPaintInformation &rhs)
 
void overrideDrawingAngle (qreal angle)
 XXX !!! :-| Please add dox!
 
template<class PaintOp >
void paintAt (PaintOp &op, KisDistanceInformation *distanceInfo)
 
qreal perspective () const
 reciprocal of distance on the perspective grid
 
KisPerStrokeRandomSourceSP perStrokeRandomSource () const
 
const QPointF & pos () const
 
qreal pressure () const
 The pressure of the value (from 0.0 to 1.0)
 
KisRandomSourceSP randomSource () const
 
DistanceInformationRegistrar registerDistanceInformation (KisDistanceInformation *distance)
 
qreal rotation () const
 rotation as given by the tablet event
 
void setCanvasMirroredH (bool value)
 
void setCanvasMirroredV (bool value)
 
void setCanvasRotation (qreal rotation)
 
void setCurrentTime (qreal time) const
 
void setLevelOfDetail (int levelOfDetail)
 
void setPerStrokeRandomSource (KisPerStrokeRandomSourceSP value)
 
void setPos (const QPointF &p)
 
void setPressure (qreal p)
 Set the pressure.
 
void setRandomSource (KisRandomSourceSP value)
 
void setTiltDirectionOffset (qreal angle)
 
qreal tangentialPressure () const
 tangential pressure (i.e., rate for an airbrush device)
 
qreal tiltDirectionOffset () const
 
qreal totalStrokeLength () const
 The length of the stroke before painting the current dab.
 
void toXML (QDomDocument &, QDomElement &) const
 
qreal xTilt () const
 The tilt of the pen on the horizontal axis (from 0.0 to 1.0)
 
qreal yTilt () const
 The tilt of the pen on the vertical axis (from 0.0 to 1.0)
 
 ~KisPaintInformation ()
 

Static Public Member Functions

static KisPaintInformation createHoveringModeInfo (const QPointF &pos, qreal pressure=PRESSURE_DEFAULT, qreal xTilt=0.0, qreal yTilt=0.0, qreal rotation=0.0, qreal tangentialPressure=0.0, qreal perspective=1.0, qreal speed=0.0, qreal canvasrotation=0.0, bool canvasMirroredH=false, bool canvasMirroredV=false, qreal tiltDirectionOffset=0.0)
 
static KisPaintInformation fromXML (const QDomElement &)
 
static KisPaintInformation mix (const QPointF &p, qreal t, const KisPaintInformation &p1, const KisPaintInformation &p2)
 
static KisPaintInformation mix (qreal t, const KisPaintInformation &pi1, const KisPaintInformation &pi2)
 
static KisPaintInformation mixOnlyPosition (qreal t, const KisPaintInformation &mixedPi, const KisPaintInformation &basePi)
 (1-t) * p1 + t * p2
 
static KisPaintInformation mixWithoutTime (const QPointF &p, qreal t, const KisPaintInformation &p1, const KisPaintInformation &p2)
 
static KisPaintInformation mixWithoutTime (qreal t, const KisPaintInformation &pi1, const KisPaintInformation &pi2)
 
static qreal tiltDirection (const KisPaintInformation &info, bool normalize=true)
 
static qreal tiltElevation (const KisPaintInformation &info, qreal maxTiltX=60.0, qreal maxTiltY=60.0, bool normalize=true)
 

Private Member Functions

void mixOtherImpl (const QPointF &p, qreal t, const KisPaintInformation &other, bool posOnly, bool mixTime)
 

Static Private Member Functions

static KisPaintInformation mixImpl (const QPointF &p, qreal t, const KisPaintInformation &p1, const KisPaintInformation &p2, bool posOnly, bool mixTime)
 

Private Attributes

Private *const d
 

Detailed Description

KisPaintInformation contains information about the input event that causes the brush action to happen to the brush engine's paint methods.

XXX: we directly pass the KoPointerEvent x and y tilt to KisPaintInformation, and their range is -60 to +60!

Parameters
posthe position of the paint event in subpixel accuracy
pressurethe pressure of the stylus
xTiltthe angle between the device (a pen, for example) and the perpendicular in the direction of the x axis. Positive values are towards the bottom of the tablet. The angle is within the range 0 to 1
yTiltthe angle between the device (a pen, for example) and the perpendicular in the direction of the y axis. Positive values are towards the bottom of the tablet. The angle is within the range 0 to .
movementcurrent position minus the last position of the call to paintAt
rotation
tangentialPressure
perspective

Definition at line 50 of file kis_paint_information.h.

Constructor & Destructor Documentation

◆ KisPaintInformation() [1/4]

KisPaintInformation::KisPaintInformation ( const QPointF & pos,
qreal pressure,
qreal xTilt,
qreal yTilt,
qreal rotation,
qreal tangentialPressure,
qreal perspective,
qreal time,
qreal speed )

Create a new KisPaintInformation object.

Definition at line 174 of file kis_paint_information.cc.

182 : d(new Private(pos,
183 pressure,
184 xTilt, yTilt,
185 rotation,
188 time,
189 speed,
190 false))
191{
192}
qreal perspective() const
reciprocal of distance on the perspective grid
const QPointF & pos() const
qreal xTilt() const
The tilt of the pen on the horizontal axis (from 0.0 to 1.0)
qreal tangentialPressure() const
tangential pressure (i.e., rate for an airbrush device)
qreal yTilt() const
The tilt of the pen on the vertical axis (from 0.0 to 1.0)
qreal rotation() const
rotation as given by the tablet event
qreal pressure() const
The pressure of the value (from 0.0 to 1.0)

◆ KisPaintInformation() [2/4]

KisPaintInformation::KisPaintInformation ( const QPointF & pos,
qreal pressure,
qreal xTilt,
qreal yTilt,
qreal rotation )

Definition at line 194 of file kis_paint_information.cc.

199 : d(new Private(pos,
200 pressure,
201 xTilt, yTilt,
202 rotation,
203 0.0,
204 1.0,
205 0.0,
206 0.0,
207 false))
208{
209
210}

◆ KisPaintInformation() [3/4]

KisPaintInformation::KisPaintInformation ( const QPointF & pos = QPointF(),
qreal pressure = PRESSURE_DEFAULT )

Definition at line 212 of file kis_paint_information.cc.

214 : d(new Private(pos,
215 pressure,
216 0.0, 0.0,
217 0.0,
218 0.0,
219 1.0,
220 0.0,
221 0.0,
222 false))
223{
224}

◆ KisPaintInformation() [4/4]

KisPaintInformation::KisPaintInformation ( const KisPaintInformation & rhs)

Definition at line 226 of file kis_paint_information.cc.

227 : d(new Private(*rhs.d))
228{
229}

◆ ~KisPaintInformation()

KisPaintInformation::~KisPaintInformation ( )

Definition at line 236 of file kis_paint_information.cc.

237{
238 delete d;
239}

References d.

Member Function Documentation

◆ canvasMirroredH()

bool KisPaintInformation::canvasMirroredH ( ) const

Whether the canvas is horizontally mirrored for the paint-operation.

Definition at line 285 of file kis_paint_information.cc.

References KisPaintInformation::Private::canvasMirroredH, and d.

◆ canvasMirroredV()

bool KisPaintInformation::canvasMirroredV ( ) const

Whether the canvas is vertically mirrored for the paint-operation.

Definition at line 295 of file kis_paint_information.cc.

References KisPaintInformation::Private::canvasMirroredV, and d.

◆ canvasRotation()

qreal KisPaintInformation::canvasRotation ( ) const

Returns the canvas rotation if that has been given to the kispaintinformation.

Definition at line 275 of file kis_paint_information.cc.

276{
277 return d->canvasRotation;
278}

References KisPaintInformation::Private::canvasRotation, and d.

◆ createHoveringModeInfo()

KisPaintInformation KisPaintInformation::createHoveringModeInfo ( const QPointF & pos,
qreal pressure = PRESSURE_DEFAULT,
qreal xTilt = 0.0,
qreal yTilt = 0.0,
qreal rotation = 0.0,
qreal tangentialPressure = 0.0,
qreal perspective = 1.0,
qreal speed = 0.0,
qreal canvasrotation = 0.0,
bool canvasMirroredH = false,
bool canvasMirroredV = false,
qreal tiltDirectionOffset = 0.0 )
static

Create a fake info object with isHoveringMode() property set to true.

See also
isHoveringMode()

Definition at line 248 of file kis_paint_information.cc.

259{
261 pressure,
262 xTilt, yTilt,
263 rotation,
265 perspective, 0, speed);
266 info.d->isHoveringMode = true;
267 info.d->canvasRotation = canvasrotation;
268 info.d->canvasMirroredH = canvasMirroredH;
269 info.d->canvasMirroredV = canvasMirroredV;
270 info.d->tiltDirectionOffset = tiltDirectionOffset;
271 return info;
272}

References KisPaintInformation::Private::canvasMirroredH, canvasMirroredH(), KisPaintInformation::Private::canvasMirroredV, canvasMirroredV(), KisPaintInformation::Private::canvasRotation, d, KisPaintInformation::Private::isHoveringMode, perspective(), pos(), pressure(), rotation(), tangentialPressure(), KisPaintInformation::Private::tiltDirectionOffset, tiltDirectionOffset(), xTilt(), and yTilt().

◆ currentDabSeqNo()

int KisPaintInformation::currentDabSeqNo ( ) const

Number of dabs painted since the beginning of the stroke.

Definition at line 487 of file kis_paint_information.cc.

488{
489 if (!d->directionHistoryInfo) {
490 warnKrita << "KisPaintInformation::currentDabSeqNo()" << "DirectionHistoryInfo object is not available";
491 return 0;
492 }
493
494 return d->directionHistoryInfo->currentDabSeqNo;
495}
#define warnKrita
Definition kis_debug.h:87
boost::optional< DirectionHistoryInfo > directionHistoryInfo

References d, KisPaintInformation::Private::directionHistoryInfo, and warnKrita.

◆ currentTime()

qreal KisPaintInformation::currentTime ( ) const

Number of ms since the beginning of the stroke.

Definition at line 482 of file kis_paint_information.cc.

483{
484 return d->time;
485}

References d, and KisPaintInformation::Private::time.

◆ drawingAngle()

qreal KisPaintInformation::drawingAngle ( bool considerLockedAngle = false) const

Current brush direction computed from the cursor movement

WARNING: this method is available only inside paintAt() call, that is when the distance information is registered.

Definition at line 402 of file kis_paint_information.cc.

403{
405
406 if (!d->directionHistoryInfo) {
407 warnKrita << "KisPaintInformation::drawingAngleSafe()" << "DirectionHistoryInfo object is not available";
408 return 0.0;
409 }
410
411 if (considerLockedAngle &&
412 d->directionHistoryInfo->lockedDrawingAngle) {
413
414 return *d->directionHistoryInfo->lockedDrawingAngle;
415 }
416
417 // If the start and end positions are the same, we can't compute an angle. In that case, use the
418 // provided default.
420 pos(),
421 d->directionHistoryInfo->lastAngle);
422}
qreal directionBetweenPoints(const QPointF &p1, const QPointF &p2, qreal defaultAngle)
boost::optional< qreal > drawingAngleOverride

References d, KisAlgebra2D::directionBetweenPoints(), KisPaintInformation::Private::directionHistoryInfo, KisPaintInformation::Private::drawingAngleOverride, pos(), and warnKrita.

◆ drawingAngleSafe()

qreal KisPaintInformation::drawingAngleSafe ( const KisDistanceInformation & distance) const

XXX !!! :-| Please add dox!

Definition at line 384 of file kis_paint_information.cc.

385{
387 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(distance.hasLastDabInformation(), 0.0);
389
391 pos(),
392 distance.lastDrawingAngle());
393
394}
qreal distance(const QPointF &p1, const QPointF &p2)
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References d, KisAlgebra2D::directionBetweenPoints(), KisPaintInformation::Private::directionHistoryInfo, distance(), KisPaintInformation::Private::drawingAngleOverride, KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and pos().

◆ drawingDirectionVector()

QPointF KisPaintInformation::drawingDirectionVector ( ) const

Current brush direction vector computed from the cursor movement

WARNING: this method is available only inside paintAt() call, that is when the distance information is registered.

Definition at line 424 of file kis_paint_information.cc.

425{
426 const qreal angle = drawingAngle(false);
427 return QPointF(cos(angle), sin(angle));
428}
qreal drawingAngle(bool considerLockedAngle=false) const

References drawingAngle().

◆ drawingDistance()

qreal KisPaintInformation::drawingDistance ( ) const

Current distance from the previous dab

WARNING: this method is available only inside paintAt() call, that is when the distance information is registered.

Definition at line 430 of file kis_paint_information.cc.

431{
432 if (!d->directionHistoryInfo) {
433 warnKrita << "KisPaintInformation::drawingDistance()" << "DirectionHistoryInfo object is not available";
434 return 1.0;
435 }
436
437 QVector2D diff(pos() - d->directionHistoryInfo->lastPosition);
438 qreal length = diff.length();
439
440 if (d->levelOfDetail) {
442 }
443
444 return length;
445}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
static qreal lodToInvScale(int levelOfDetail)

References d, KisPaintInformation::Private::directionHistoryInfo, length(), KisPaintInformation::Private::levelOfDetail, KisLodTransformBase::lodToInvScale(), pos(), and warnKrita.

◆ drawingSpeed()

qreal KisPaintInformation::drawingSpeed ( ) const

Current brush speed computed from the cursor movement

WARNING: this method is available only inside paintAt() call, that is when the distance information is registered.

Definition at line 457 of file kis_paint_information.cc.

458{
459 return d->speed;
460}

References d, and KisPaintInformation::Private::speed.

◆ fromXML()

KisPaintInformation KisPaintInformation::fromXML ( const QDomElement & e)
static

Definition at line 332 of file kis_paint_information.cc.

333{
334 qreal pointX = qreal(KisDomUtils::toDouble(e.attribute("pointX", "0.0")));
335 qreal pointY = qreal(KisDomUtils::toDouble(e.attribute("pointY", "0.0")));
336 qreal pressure = qreal(KisDomUtils::toDouble(e.attribute("pressure", "0.0")));
337 qreal rotation = qreal(KisDomUtils::toDouble(e.attribute("rotation", "0.0")));
338 qreal tangentialPressure = qreal(KisDomUtils::toDouble(e.attribute("tangentialPressure", "0.0")));
339 qreal perspective = qreal(KisDomUtils::toDouble(e.attribute("perspective", "0.0")));
340 qreal xTilt = qreal(KisDomUtils::toDouble(e.attribute("xTilt", "0.0")));
341 qreal yTilt = qreal(KisDomUtils::toDouble(e.attribute("yTilt", "0.0")));
342 qreal time = KisDomUtils::toDouble(e.attribute("time", "0"));
343 qreal speed = KisDomUtils::toDouble(e.attribute("speed", "0"));
344
345 return KisPaintInformation(QPointF(pointX, pointY), pressure, xTilt, yTilt,
347}
KisPaintInformation(const QPointF &pos, qreal pressure, qreal xTilt, qreal yTilt, qreal rotation, qreal tangentialPressure, qreal perspective, qreal time, qreal speed)
double toDouble(const QString &str, bool *ok=nullptr)

References KisPaintInformation(), perspective(), pressure(), rotation(), tangentialPressure(), KisDomUtils::toDouble(), xTilt(), and yTilt().

◆ isHoveringMode()

bool KisPaintInformation::isHoveringMode ( ) const

The paint information may be generated not only during real stroke when the actual painting is happening, but also when the cursor is hovering the canvas. In this mode some of the sensors work a bit differently. The most outstanding example is Fuzzy sensor, which returns unit value in this mode, otherwise it is too irritating for a user.

This value is true only for paint information objects created with createHoveringModeInfo() constructor.

See also
createHoveringModeInfo()

Definition at line 241 of file kis_paint_information.cc.

References d, and KisPaintInformation::Private::isHoveringMode.

◆ maxPressure()

qreal KisPaintInformation::maxPressure ( ) const

Maximum pressure that has been known during the stroke

WARNING: this method is available only inside paintAt() call, that is when the distance information is registered.

Definition at line 447 of file kis_paint_information.cc.

448{
449 if (!d->directionHistoryInfo) {
450 warnKrita << "KisPaintInformation::maxPressure()" << "DirectionHistoryInfo object is not available";
451 return d->pressure;
452 }
453
454 return qMax(d->directionHistoryInfo->lastMaxPressure, d->pressure);
455}

References d, KisPaintInformation::Private::directionHistoryInfo, KisPaintInformation::Private::pressure, and warnKrita.

◆ mix() [1/2]

KisPaintInformation KisPaintInformation::mix ( const QPointF & p,
qreal t,
const KisPaintInformation & p1,
const KisPaintInformation & p2 )
static

Definition at line 575 of file kis_paint_information.cc.

576{
577 return mixImpl(p, t, pi1, pi2, false, true);
578}
const Params2D p
static KisPaintInformation mixImpl(const QPointF &p, qreal t, const KisPaintInformation &p1, const KisPaintInformation &p2, bool posOnly, bool mixTime)

References mixImpl(), and p.

◆ mix() [2/2]

KisPaintInformation KisPaintInformation::mix ( qreal t,
const KisPaintInformation & pi1,
const KisPaintInformation & pi2 )
static

Definition at line 569 of file kis_paint_information.cc.

570{
571 QPointF pt = (1 - t) * pi1.pos() + t * pi2.pos();
572 return mix(pt, t, pi1, pi2);
573}
static KisPaintInformation mix(const QPointF &p, qreal t, const KisPaintInformation &p1, const KisPaintInformation &p2)

References mix(), and pos().

◆ mixImpl()

KisPaintInformation KisPaintInformation::mixImpl ( const QPointF & p,
qreal t,
const KisPaintInformation & p1,
const KisPaintInformation & p2,
bool posOnly,
bool mixTime )
staticprivate

Definition at line 603 of file kis_paint_information.cc.

604{
605 KisPaintInformation result(pi2);
606 result.mixOtherImpl(p, t, pi1, posOnly, mixTime);
607 return result;
608}

References mixOtherImpl(), and p.

◆ mixOnlyPosition()

KisPaintInformation KisPaintInformation::mixOnlyPosition ( qreal t,
const KisPaintInformation & mixedPi,
const KisPaintInformation & basePi )
static

(1-t) * p1 + t * p2

Definition at line 563 of file kis_paint_information.cc.

564{
565 QPointF pt = (1 - t) * mixedPi.pos() + t * basePi.pos();
566 return mixImpl(pt, t, mixedPi, basePi, true, false);
567}

References mixImpl(), and pos().

◆ mixOtherImpl()

void KisPaintInformation::mixOtherImpl ( const QPointF & p,
qreal t,
const KisPaintInformation & other,
bool posOnly,
bool mixTime )
private

Definition at line 610 of file kis_paint_information.cc.

611{
612 if (posOnly) {
613 this->d->pos = p;
614 this->d->isHoveringMode = false;
615 this->d->levelOfDetail = 0;
616 return;
617 }
618 else {
619 qreal pressure = (1 - t) * other.pressure() + t * this->pressure();
620 qreal xTilt = (1 - t) * other.xTilt() + t * this->xTilt();
621 qreal yTilt = (1 - t) * other.yTilt() + t * this->yTilt();
622
623 qreal rotation = other.rotation();
624
625 if (other.rotation() != this->rotation()) {
626 qreal a1 = kisDegreesToRadians(other.rotation());
627 qreal a2 = kisDegreesToRadians(this->rotation());
628 qreal distance = shortestAngularDistance(a2, a1);
629
631 }
632
633 qreal tangentialPressure = (1 - t) * other.tangentialPressure() + t * this->tangentialPressure();
634 qreal perspective = (1 - t) * other.perspective() + t * this->perspective();
635 qreal time = mixTime ? ((1 - t) * other.currentTime() + t * this->currentTime()) : this->currentTime();
636 qreal speed = (1 - t) * other.drawingSpeed() + t * this->drawingSpeed();
637
638 KIS_ASSERT_RECOVER_NOOP(other.isHoveringMode() == this->isHoveringMode());
639 *(this->d) = Private(p, pressure, xTilt, yTilt, rotation, tangentialPressure, perspective, time, speed, other.isHoveringMode());
640 this->d->canvasRotation = other.d->canvasRotation;
641 this->d->canvasMirroredH = other.d->canvasMirroredH;
642 this->d->canvasMirroredV = other.d->canvasMirroredV;
643 this->d->randomSource = other.d->randomSource;
645 // this->d->isHoveringMode = other.isHoveringMode();
646 this->d->levelOfDetail = other.d->levelOfDetail;
648 }
649}
qreal currentTime() const
Number of ms since the beginning of the stroke.
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97
qreal incrementInDirection(qreal a, qreal inc, qreal direction)
Definition kis_global.h:147
T kisRadiansToDegrees(T radians)
Definition kis_global.h:181
qreal shortestAngularDistance(qreal a, qreal b)
Definition kis_global.h:140
T kisDegreesToRadians(T degrees)
Definition kis_global.h:176
KisPerStrokeRandomSourceSP perStrokeRandomSource

References KisPaintInformation::Private::canvasMirroredH, KisPaintInformation::Private::canvasMirroredV, KisPaintInformation::Private::canvasRotation, currentTime(), d, distance(), drawingSpeed(), incrementInDirection(), KisPaintInformation::Private::isHoveringMode, isHoveringMode(), KIS_ASSERT_RECOVER_NOOP, kisDegreesToRadians(), kisRadiansToDegrees(), KisPaintInformation::Private::levelOfDetail, p, perspective(), KisPaintInformation::Private::perStrokeRandomSource, KisPaintInformation::Private::pos, pressure(), KisPaintInformation::Private::randomSource, rotation(), shortestAngularDistance(), tangentialPressure(), KisPaintInformation::Private::tiltDirectionOffset, xTilt(), and yTilt().

◆ mixOtherOnlyPosition()

void KisPaintInformation::mixOtherOnlyPosition ( qreal t,
const KisPaintInformation & other )

Definition at line 591 of file kis_paint_information.cc.

592{
593 QPointF pt = (1 - t) * other.pos() + t * this->pos();
594 this->mixOtherImpl(pt, t, other, true, false);
595}
void mixOtherImpl(const QPointF &p, qreal t, const KisPaintInformation &other, bool posOnly, bool mixTime)

References mixOtherImpl(), and pos().

◆ mixOtherWithoutTime()

void KisPaintInformation::mixOtherWithoutTime ( qreal t,
const KisPaintInformation & other )

Definition at line 597 of file kis_paint_information.cc.

598{
599 QPointF pt = (1 - t) * other.pos() + t * this->pos();
600 this->mixOtherImpl(pt, t, other, false, false);
601}

References mixOtherImpl(), and pos().

◆ mixWithoutTime() [1/2]

KisPaintInformation KisPaintInformation::mixWithoutTime ( const QPointF & p,
qreal t,
const KisPaintInformation & p1,
const KisPaintInformation & p2 )
static

Definition at line 586 of file kis_paint_information.cc.

587{
588 return mixImpl(p, t, pi1, pi2, false, false);
589}

References mixImpl(), and p.

◆ mixWithoutTime() [2/2]

KisPaintInformation KisPaintInformation::mixWithoutTime ( qreal t,
const KisPaintInformation & pi1,
const KisPaintInformation & pi2 )
static

Definition at line 580 of file kis_paint_information.cc.

581{
582 QPointF pt = (1 - t) * pi1.pos() + t * pi2.pos();
583 return mixWithoutTime(pt, t, pi1, pi2);
584}
static KisPaintInformation mixWithoutTime(const QPointF &p, qreal t, const KisPaintInformation &p1, const KisPaintInformation &p2)

References mixWithoutTime(), and pos().

◆ operator=()

void KisPaintInformation::operator= ( const KisPaintInformation & rhs)

Definition at line 231 of file kis_paint_information.cc.

232{
233 *d = *rhs.d;
234}

References d.

◆ overrideDrawingAngle()

void KisPaintInformation::overrideDrawingAngle ( qreal angle)

XXX !!! :-| Please add dox!

Definition at line 379 of file kis_paint_information.cc.

380{
381 d->drawingAngleOverride = angle;
382}

References d, and KisPaintInformation::Private::drawingAngleOverride.

◆ paintAt()

template<class PaintOp >
void KisPaintInformation::paintAt ( PaintOp & op,
KisDistanceInformation * distanceInfo )
inline

Definition at line 100 of file kis_paint_information.h.

100 {
101 KisSpacingInformation spacingInfo;
102 KisTimingInformation timingInfo;
103 {
104 DistanceInformationRegistrar r = registerDistanceInformation(distanceInfo);
105 spacingInfo = op.paintAt(*this);
106 timingInfo = op.updateTimingImpl(*this);
107
108 // Initiate the process of locking the drawing angle. The locked value will
109 // always be present in the internals, but it will be requested but the users
110 // with a special parameter of drawingAngle() only.
111 if (!this->isHoveringMode()) {
112 distanceInfo->lockCurrentDrawingAngle(*this);
113 }
114 }
115
116 distanceInfo->registerPaintedDab(*this, spacingInfo, timingInfo);
117 }
DistanceInformationRegistrar registerDistanceInformation(KisDistanceInformation *distance)
void lockCurrentDrawingAngle(const KisPaintInformation &info) const
void registerPaintedDab(const KisPaintInformation &info, const KisSpacingInformation &spacing, const KisTimingInformation &timing)

References KisDistanceInformation::lockCurrentDrawingAngle(), and KisDistanceInformation::registerPaintedDab().

◆ perspective()

qreal KisPaintInformation::perspective ( ) const

reciprocal of distance on the perspective grid

Definition at line 477 of file kis_paint_information.cc.

478{
479 return d->perspective;
480}

References d, and KisPaintInformation::Private::perspective.

◆ perStrokeRandomSource()

KisPerStrokeRandomSourceSP KisPaintInformation::perStrokeRandomSource ( ) const

Definition at line 523 of file kis_paint_information.cc.

524{
525 if (!d->perStrokeRandomSource) {
526 qWarning() << "Accessing uninitialized per stroke random source!";
528 }
529
530 return d->perStrokeRandomSource;
531}

References d, and KisPaintInformation::Private::perStrokeRandomSource.

◆ pos()

const QPointF & KisPaintInformation::pos ( ) const

Definition at line 349 of file kis_paint_information.cc.

350{
351 return d->pos;
352}

References d, and KisPaintInformation::Private::pos.

◆ pressure()

qreal KisPaintInformation::pressure ( ) const

The pressure of the value (from 0.0 to 1.0)

Definition at line 359 of file kis_paint_information.cc.

360{
361 return d->pressure;
362}

References d, and KisPaintInformation::Private::pressure.

◆ randomSource()

KisRandomSourceSP KisPaintInformation::randomSource ( ) const

Definition at line 507 of file kis_paint_information.cc.

508{
509 if (!d->randomSource) {
510 qWarning() << "Accessing uninitialized random source!";
511 qDebug().noquote() << kisBacktrace();
513 }
514
515 return d->randomSource;
516}
QString kisBacktrace()
Definition kis_debug.cpp:51

References d, kisBacktrace(), and KisPaintInformation::Private::randomSource.

◆ registerDistanceInformation()

KisPaintInformation::DistanceInformationRegistrar KisPaintInformation::registerDistanceInformation ( KisDistanceInformation * distance)

Causes the specified distance information to be temporarily registered with this KisPaintInformation object, so that the KisPaintInformation can compute certain values that may be needed at painting time, such as the drawing direction. When the returned object is destroyed, the KisDistanceInformation will be unregistered. At most one KisDistanceInformation can be registered with a given KisPaintInformation at a time.

Definition at line 397 of file kis_paint_information.cc.

398{
399 return DistanceInformationRegistrar(this, distance);
400}

References distance().

◆ rotation()

qreal KisPaintInformation::rotation ( ) const

rotation as given by the tablet event

Definition at line 467 of file kis_paint_information.cc.

468{
469 return d->rotation;
470}

References d, and KisPaintInformation::Private::rotation.

◆ setCanvasMirroredH()

void KisPaintInformation::setCanvasMirroredH ( bool value)

Set whether the canvas is horizontally mirrored for the paint-operation.

Definition at line 290 of file kis_paint_information.cc.

291{
293}
float value(const T *src, size_t ch)

References KisPaintInformation::Private::canvasMirroredH, d, and value().

◆ setCanvasMirroredV()

void KisPaintInformation::setCanvasMirroredV ( bool value)

Set whether the canvas is vertically mirrored for the paint-operation.

Definition at line 300 of file kis_paint_information.cc.

301{
303}

References KisPaintInformation::Private::canvasMirroredV, d, and value().

◆ setCanvasRotation()

void KisPaintInformation::setCanvasRotation ( qreal rotation)

Set the canvas rotation.

Definition at line 280 of file kis_paint_information.cc.

281{
283}
std::enable_if< std::is_floating_point< T >::value, T >::type normalizeAngleDegrees(T a)
Definition kis_global.h:132

References KisPaintInformation::Private::canvasRotation, d, normalizeAngleDegrees(), and rotation().

◆ setCurrentTime()

void KisPaintInformation::setCurrentTime ( qreal time) const

Definition at line 462 of file kis_paint_information.cc.

462 {
463
464 d->time = time;
465}

References d, and KisPaintInformation::Private::time.

◆ setLevelOfDetail()

void KisPaintInformation::setLevelOfDetail ( int levelOfDetail)

Definition at line 538 of file kis_paint_information.cc.

539{
540 d->levelOfDetail = levelOfDetail;
541}

References d, and KisPaintInformation::Private::levelOfDetail.

◆ setPerStrokeRandomSource()

void KisPaintInformation::setPerStrokeRandomSource ( KisPerStrokeRandomSourceSP value)

◆ setPos()

void KisPaintInformation::setPos ( const QPointF & p)

Definition at line 354 of file kis_paint_information.cc.

355{
356 d->pos = p;
357}

References d, p, and KisPaintInformation::Private::pos.

◆ setPressure()

void KisPaintInformation::setPressure ( qreal p)

Set the pressure.

Definition at line 364 of file kis_paint_information.cc.

365{
366 d->pressure = p;
367}

References d, p, and KisPaintInformation::Private::pressure.

◆ setRandomSource()

void KisPaintInformation::setRandomSource ( KisRandomSourceSP value)

Definition at line 518 of file kis_paint_information.cc.

519{
521}

References d, KisPaintInformation::Private::randomSource, and value().

◆ setTiltDirectionOffset()

void KisPaintInformation::setTiltDirectionOffset ( qreal angle)

Set the tilt direction offset. Will be clamped to [0, 360) degrees.

Definition at line 310 of file kis_paint_information.cc.

References d, normalizeAngleDegrees(), KisPaintInformation::Private::tiltDirectionOffset, and value().

◆ tangentialPressure()

qreal KisPaintInformation::tangentialPressure ( ) const

tangential pressure (i.e., rate for an airbrush device)

Definition at line 472 of file kis_paint_information.cc.

References d, and KisPaintInformation::Private::tangentialPressure.

◆ tiltDirection()

qreal KisPaintInformation::tiltDirection ( const KisPaintInformation & info,
bool normalize = true )
static

When the stylus is in fully vertical position, stick it to a "neutral position", which is a 3 o'clock tilt of the stylus as defined in the Krita documentation.

The normal 0 deg position as returned from Qt is at 6 o'clock tilt of the stylus

Definition at line 651 of file kis_paint_information.cc.

652{
653 qreal xTilt = info.xTilt();
654 qreal yTilt = info.yTilt();
655
656 // radians -PI, PI
657 qreal tiltDirection = 0.0;
658
669 } else {
671 }
672
673 if (!qFuzzyIsNull(info.d->tiltDirectionOffset)) {
675 // ensure we stay in the -PI, PI range
676 if (tiltDirection < -M_PI) {
677 tiltDirection += 2 * M_PI;
678 } else if (tiltDirection > M_PI) {
679 tiltDirection -= 2 * M_PI;
680 }
681 }
682
683 // if normalize is true map to 0.0..1.0
684 return normalize ? (tiltDirection / (2 * M_PI) + 0.5) : tiltDirection;
685}
static qreal tiltDirection(const KisPaintInformation &info, bool normalize=true)
static bool qFuzzyIsNull(half h)
#define M_PI
Definition kis_global.h:111
Point normalize(const Point &a)
KRITAIMAGE_EXPORT qreal atan2(qreal y, qreal x)
atan2 replacement

References d, kisDegreesToRadians(), M_PI, qFuzzyIsNull(), KisAlgebra2D::signPZ(), tiltDirection(), KisPaintInformation::Private::tiltDirectionOffset, xTilt(), and yTilt().

◆ tiltDirectionOffset()

qreal KisPaintInformation::tiltDirectionOffset ( ) const

Constant offset added to the reported pen tilt direction. [0, 360) degrees.

Definition at line 305 of file kis_paint_information.cc.

306{
307 return d->tiltDirectionOffset;
308}

References d, and KisPaintInformation::Private::tiltDirectionOffset.

◆ tiltElevation()

qreal KisPaintInformation::tiltElevation ( const KisPaintInformation & info,
qreal maxTiltX = 60.0,
qreal maxTiltY = 60.0,
bool normalize = true )
static

Definition at line 687 of file kis_paint_information.cc.

688{
689 qreal xTilt = qBound(qreal(-1.0), info.xTilt() / maxTiltX , qreal(1.0));
690 qreal yTilt = qBound(qreal(-1.0), info.yTilt() / maxTiltY , qreal(1.0));
691
692 qreal e;
693 if (fabs(xTilt) > fabs(yTilt)) {
694 e = sqrt(qreal(1.0) + yTilt * yTilt);
695 } else {
696 e = sqrt(qreal(1.0) + xTilt * xTilt);
697 }
698
699 qreal cosAlpha = sqrt(xTilt * xTilt + yTilt * yTilt) / e;
700 qreal tiltElevation = acos(cosAlpha); // in radians in [0, 0.5 * PI]
701
702 // mapping to 0.0..1.0 if normalize is true
703 return normalize ? (tiltElevation / (M_PI * qreal(0.5))) : tiltElevation;
704}
static qreal tiltElevation(const KisPaintInformation &info, qreal maxTiltX=60.0, qreal maxTiltY=60.0, bool normalize=true)

References M_PI, tiltElevation(), xTilt(), and yTilt().

◆ totalStrokeLength()

qreal KisPaintInformation::totalStrokeLength ( ) const

The length of the stroke before painting the current dab.

Definition at line 497 of file kis_paint_information.cc.

498{
499 if (!d->directionHistoryInfo) {
500 warnKrita << "KisPaintInformation::totalStrokeLength()" << "DirectionHistoryInfo object is not available";
501 return 0;
502 }
503
504 return d->directionHistoryInfo->totalStrokeLength;
505}

References d, KisPaintInformation::Private::directionHistoryInfo, and warnKrita.

◆ toXML()

void KisPaintInformation::toXML ( QDomDocument & ,
QDomElement & e ) const

Definition at line 315 of file kis_paint_information.cc.

316{
317 // hovering mode infos are not supposed to be saved
319
320 e.setAttribute("pointX", QString::number(pos().x(), 'g', 15));
321 e.setAttribute("pointY", QString::number(pos().y(), 'g', 15));
322 e.setAttribute("pressure", QString::number(pressure(), 'g', 15));
323 e.setAttribute("xTilt", QString::number(xTilt(), 'g', 15));
324 e.setAttribute("yTilt", QString::number(yTilt(), 'g', 15));
325 e.setAttribute("rotation", QString::number(rotation(), 'g', 15));
326 e.setAttribute("tangentialPressure", QString::number(tangentialPressure(), 'g', 15));
327 e.setAttribute("perspective", QString::number(perspective(), 'g', 15));
328 e.setAttribute("time", QString::number(d->time, 'g', 15));
329 e.setAttribute("speed", QString::number(d->speed, 'g', 15));
330}

References d, KisPaintInformation::Private::isHoveringMode, KIS_ASSERT_RECOVER_NOOP, perspective(), pos(), pressure(), rotation(), KisPaintInformation::Private::speed, tangentialPressure(), KisPaintInformation::Private::time, xTilt(), and yTilt().

◆ xTilt()

qreal KisPaintInformation::xTilt ( ) const

The tilt of the pen on the horizontal axis (from 0.0 to 1.0)

Definition at line 369 of file kis_paint_information.cc.

370{
371 return d->xTilt;
372}

References d, and KisPaintInformation::Private::xTilt.

◆ yTilt()

qreal KisPaintInformation::yTilt ( ) const

The tilt of the pen on the vertical axis (from 0.0 to 1.0)

Definition at line 374 of file kis_paint_information.cc.

375{
376 return d->yTilt;
377}

References d, and KisPaintInformation::Private::yTilt.

Member Data Documentation

◆ d

Private* const KisPaintInformation::d
private

Definition at line 326 of file kis_paint_information.h.


The documentation for this class was generated from the following files: