Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPaintOp Class Referenceabstract

#include <kis_paintop.h>

+ Inheritance diagram for KisPaintOp:

Public Member Functions

virtual bool canPaint () const
 
virtual std::pair< int, bool > doAsynchronousUpdate (QVector< KisRunnableStrokeJobData * > &jobs)
 
 KisPaintOp (KisPainter *painter)
 
void paintAt (const KisPaintInformation &info, KisDistanceInformation *currentDistance)
 
virtual void paintBezierCurve (const KisPaintInformation &pi1, const QPointF &control1, const QPointF &control2, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance)
 
virtual void paintLine (const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance)
 
 Private (KisPaintOp *_q)
 
void updateSpacing (const KisPaintInformation &info, KisDistanceInformation &currentDistance) const
 
void updateTiming (const KisPaintInformation &info, KisDistanceInformation &currentDistance) const
 
virtual ~KisPaintOp ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Static Public Member Functions

static void splitCoordinate (qreal coordinate, qint32 *whole, qreal *fraction)
 

Public Attributes

KisFixedPaintDeviceSP dab
 
bool fanCornersEnabled {false}
 
qreal fanCornersStep {1.0}
 
KisPainterpainter {nullptr}
 
KisPaintOpq {nullptr}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Protected Member Functions

KisFixedPaintDeviceSP cachedDab ()
 
KisFixedPaintDeviceSP cachedDab (const KoColorSpace *cs)
 
virtual KisSpacingInformation paintAt (const KisPaintInformation &info)=0
 
KisPainterpainter () const
 
KisPaintDeviceSP source () const
 
virtual KisSpacingInformation updateSpacingImpl (const KisPaintInformation &info) const =0
 
virtual KisTimingInformation updateTimingImpl (const KisPaintInformation &info) const
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Private Member Functions

void setFanCornersInfo (bool fanCornersEnabled, qreal fanCornersStep)
 

Private Attributes

Private *const d {nullptr}
 

Friends

class KisPaintInformation
 
class KisRotationOption
 

Detailed Description

KisPaintOp are use by tools to draw on a paint device. A paintop takes settings and input information, like pressure, tilt or motion and uses that to draw pixels

Definition at line 39 of file kis_paintop.cc.

Constructor & Destructor Documentation

◆ KisPaintOp()

KisPaintOp::KisPaintOp ( KisPainter * painter)

Definition at line 53 of file kis_paintop.cc.

53 : d(new Private(this))
54{
55 d->painter = painter;
56}
KisPainter * painter
Private *const d

References d, and painter.

◆ ~KisPaintOp()

KisPaintOp::~KisPaintOp ( )
virtual

Definition at line 58 of file kis_paintop.cc.

59{
60 d->dab.clear();
61 delete d;
62}

References d.

Member Function Documentation

◆ cachedDab() [1/2]

KisFixedPaintDeviceSP KisPaintOp::cachedDab ( )
protected

Definition at line 64 of file kis_paintop.cc.

65{
66 return cachedDab(d->painter->device()->colorSpace());
67}
KisFixedPaintDeviceSP cachedDab()

References cachedDab(), and d.

◆ cachedDab() [2/2]

KisFixedPaintDeviceSP KisPaintOp::cachedDab ( const KoColorSpace * cs)
protected

Definition at line 69 of file kis_paintop.cc.

70{
71 if (!d->dab || *d->dab->colorSpace() != *cs) {
72 d->dab = new KisFixedPaintDevice(cs);
73 }
74 return d->dab;
75}

References d.

◆ canPaint()

virtual bool KisPaintOp::canPaint ( ) const
inlinevirtual

Whether this paintop can paint. Can be false in case that some setting isn't read correctly.

Returns
if paintop is ready for painting, default is true

Reimplemented in KisBrushBasedPaintOp.

Definition at line 94 of file kis_paintop.h.

94 {
95 return true;
96 }

◆ doAsynchronousUpdate()

std::pair< int, bool > KisPaintOp::doAsynchronousUpdate ( QVector< KisRunnableStrokeJobData * > & jobs)
virtual

If the preset supports asynchronous updates, then the stroke execution core will call this method with a desired frame rate. The jobs that should be run to prepare the update are returned via jobs

Returns
a pair of <the desired FPS rate (period of updates); are there any unprocessed update jobs left?>

Reimplemented in KisBrushOp.

Definition at line 92 of file kis_paintop.cc.

93{
94 Q_UNUSED(jobs);
95 return std::make_pair(40, false);
96}

◆ paintAt() [1/2]

virtual KisSpacingInformation KisPaintOp::paintAt ( const KisPaintInformation & info)
protectedpure virtual

◆ paintAt() [2/2]

void KisPaintOp::paintAt ( const KisPaintInformation & info,
KisDistanceInformation * currentDistance )

Paint at the subpixel point pos using the specified paint information..

The distance/time between two calls of the paintAt is always specified by spacing and timing, which are automatically saved into the current distance information object.

Definition at line 148 of file kis_paintop.cc.

149{
150 Q_ASSERT(currentDistance);
151 KisPaintInformation pi(info);
152 pi.paintAt(*this, currentDistance);
153}

References KisPaintInformation::paintAt().

◆ paintBezierCurve()

void KisPaintOp::paintBezierCurve ( const KisPaintInformation & pi1,
const QPointF & control1,
const QPointF & control2,
const KisPaintInformation & pi2,
KisDistanceInformation * currentDistance )
virtual

Draw a Bezier curve between pos1 and pos2 using control points 1 and 2. If savedDist is less than zero, the brush is painted at pos1 before being painted along the curve using the spacing setting.

Returns
the drag distance, that is the remains of the distance between p1 and p2 not covered because the currently set brush has a spacing greater than that distance.

Definition at line 129 of file kis_paintop.cc.

134{
135 return ::paintBezierCurve(this, pi1, toKisVector2D(control1), toKisVector2D(control2), pi2, currentDistance);
136}
KisVector2D toKisVector2D(const QPointF &p)
Definition kis_vec.h:19

References toKisVector2D().

◆ painter()

KisPainter * KisPaintOp::painter ( ) const
protected

Return the painter this paintop is owned by

◆ paintLine()

void KisPaintOp::paintLine ( const KisPaintInformation & pi1,
const KisPaintInformation & pi2,
KisDistanceInformation * currentDistance )
virtual

Draw a line between pos1 and pos2 using the currently set brush and color. If savedDist is less than zero, the brush is painted at pos1 before being painted along the line using the spacing setting.

Returns
the drag distance, that is the remains of the distance between p1 and p2 not covered because the currently set brush has a spacing greater than that distance.

Reimplemented in KisCurvePaintOp, KisBrushOp, KisExperimentPaintOp, KisHairyPaintOp, KisParticlePaintOp, KisSketchPaintOp, and KisTangentNormalPaintOp.

Definition at line 139 of file kis_paintop.cc.

142{
143 KisPaintOpUtils::paintLine(*this, pi1, pi2, currentDistance,
144 d->fanCornersEnabled,
145 d->fanCornersStep);
146}
void paintLine(PaintOp &op, const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance, bool fanCornersEnabled, qreal fanCornersStep)

References d, and KisPaintOpUtils::paintLine().

◆ Private()

KisPaintOp::Private ( KisPaintOp * _q)
inline

Definition at line 40 of file kis_paintop.cc.

41 : q(_q) {}
KisPaintOp * q

◆ setFanCornersInfo()

void KisPaintOp::setFanCornersInfo ( bool fanCornersEnabled,
qreal fanCornersStep )
private

Definition at line 77 of file kis_paintop.cc.

78{
79 d->fanCornersEnabled = fanCornersEnabled;
80 d->fanCornersStep = fanCornersStep;
81}
qreal fanCornersStep
bool fanCornersEnabled

References d, fanCornersEnabled, and fanCornersStep.

◆ source()

KisPaintDeviceSP KisPaintOp::source ( ) const
protected

Return the paintdevice the painter this paintop is owned by

Definition at line 194 of file kis_paintop.cc.

195{
196 return d->painter->device();
197}

References d.

◆ splitCoordinate()

void KisPaintOp::splitCoordinate ( qreal coordinate,
qint32 * whole,
qreal * fraction )
static

Split the coordinate into whole + fraction, where fraction is always >= 0.

Definition at line 83 of file kis_paintop.cc.

84{
85 const qint32 i = qFloor(coordinate);
86 const qreal f = coordinate - i;
87
88 *whole = i;
89 *fraction = f;
90}

◆ updateSpacing()

void KisPaintOp::updateSpacing ( const KisPaintInformation & info,
KisDistanceInformation & currentDistance ) const

Updates the spacing settings in currentDistance based on the provided information. Note that the spacing is updated automatically in the paintAt method, so there is no need to call this method if paintAt has just been called.

Definition at line 155 of file kis_paintop.cc.

157{
158 KisPaintInformation pi(info);
159 KisSpacingInformation spacingInfo;
160 {
162 = pi.registerDistanceInformation(&currentDistance);
163 spacingInfo = updateSpacingImpl(pi);
164 }
165
166 currentDistance.updateSpacing(spacingInfo);
167}
void updateSpacing(const KisSpacingInformation &spacing)
virtual KisSpacingInformation updateSpacingImpl(const KisPaintInformation &info) const =0

References KisPaintInformation::registerDistanceInformation(), KisDistanceInformation::updateSpacing(), and updateSpacingImpl().

◆ updateSpacingImpl()

◆ updateTiming()

void KisPaintOp::updateTiming ( const KisPaintInformation & info,
KisDistanceInformation & currentDistance ) const

Updates the timing settings in currentDistance based on the provided information. Note that the timing is updated automatically in the paintAt method, so there is no need to call this method if paintAt has just been called.

Definition at line 169 of file kis_paintop.cc.

171{
172 KisPaintInformation pi(info);
173 KisTimingInformation timingInfo;
174 {
176 = pi.registerDistanceInformation(&currentDistance);
177 timingInfo = updateTimingImpl(pi);
178 }
179
180 currentDistance.updateTiming(timingInfo);
181}
void updateTiming(const KisTimingInformation &timing)
virtual KisTimingInformation updateTimingImpl(const KisPaintInformation &info) const

References KisPaintInformation::registerDistanceInformation(), KisDistanceInformation::updateTiming(), and updateTimingImpl().

◆ updateTimingImpl()

KisTimingInformation KisPaintOp::updateTimingImpl ( const KisPaintInformation & info) const
protectedvirtual

Implementation of a timing update. The default implementation always disables timing. This is suitable for paintops that do not support airbrushing.

Reimplemented in KisColorSmudgeOp, KisBrushOp, KisDeformPaintOp, KisMyPaintPaintOp, KisParticlePaintOp, KisSketchPaintOp, KisSprayPaintOp, and KisTangentNormalPaintOp.

Definition at line 183 of file kis_paintop.cc.

184{
185 Q_UNUSED(info);
186 return KisTimingInformation();
187}

Friends And Related Symbol Documentation

◆ KisPaintInformation

friend class KisPaintInformation
friend

Definition at line 113 of file kis_paintop.h.

◆ KisRotationOption

friend class KisRotationOption
friend

Definition at line 145 of file kis_paintop.h.

Member Data Documentation

◆ d

Private* const KisPaintOp::d {nullptr}
private

Definition at line 149 of file kis_paintop.h.

149{nullptr};

◆ dab

KisFixedPaintDeviceSP KisPaintOp::dab

Definition at line 45 of file kis_paintop.cc.

◆ fanCornersEnabled

bool KisPaintOp::fanCornersEnabled {false}

Definition at line 48 of file kis_paintop.cc.

48{false};

◆ fanCornersStep

qreal KisPaintOp::fanCornersStep {1.0}

Definition at line 49 of file kis_paintop.cc.

49{1.0};

◆ painter

KisPainter * KisPaintOp::painter {nullptr}

Definition at line 46 of file kis_paintop.cc.

46{nullptr};

◆ q

KisPaintOp* KisPaintOp::q {nullptr}

Definition at line 43 of file kis_paintop.cc.

43{nullptr};

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