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

#include <kis_curve_paintop.h>

+ Inheritance diagram for KisCurvePaintOp:

Public Member Functions

 KisCurvePaintOp (const KisPaintOpSettingsSP settings, KisPainter *painter, KisNodeSP node, KisImageSP image)
 
void paintLine (const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance) override
 
 ~KisCurvePaintOp () override
 
- Public Member Functions inherited from KisPaintOp
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)
 
 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 ()
 

Protected Member Functions

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

Private Member Functions

void paintLine (KisPaintDeviceSP dab, const KisPaintInformation &pi1, const KisPaintInformation &pi2)
 

Private Attributes

KisCurveOpOptionData m_curveOpOption
 
KisCurvesOpacityOption m_curvesOpacityOption
 
KisPaintDeviceSP m_dab
 
KisPaintDeviceSP m_dev
 
KisLineWidthOption m_lineWidthOption
 
KisOpacityOption m_opacityOption
 
KisPainterm_painter
 
QList< QPointF > m_points
 

Additional Inherited Members

- Static Public Member Functions inherited from KisPaintOp
static void splitCoordinate (qreal coordinate, qint32 *whole, qreal *fraction)
 
- Public Attributes inherited from KisPaintOp
KisFixedPaintDeviceSP dab
 
bool fanCornersEnabled {false}
 
qreal fanCornersStep {1.0}
 
KisPainterpainter {nullptr}
 
KisPaintOpq {nullptr}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Detailed Description

Definition at line 18 of file kis_curve_paintop.h.

Constructor & Destructor Documentation

◆ KisCurvePaintOp()

KisCurvePaintOp::KisCurvePaintOp ( const KisPaintOpSettingsSP settings,
KisPainter * painter,
KisNodeSP node,
KisImageSP image )

Definition at line 25 of file kis_curve_paintop.cpp.

27 , m_opacityOption(settings.data(), node)
28 , m_lineWidthOption(settings.data())
29 , m_curvesOpacityOption(settings.data())
30 , m_painter(0)
31{
32 Q_ASSERT(settings);
33 Q_UNUSED(image);
34 Q_UNUSED(node);
35
36 m_curveOpOption.read(settings.data());
37}
KisPainter * m_painter
KisOpacityOption m_opacityOption
KisCurveOpOptionData m_curveOpOption
KisCurvesOpacityOption m_curvesOpacityOption
KisLineWidthOption m_lineWidthOption
bool read(const KisPropertiesConfiguration *setting)
KisPainter * painter
KisPaintOp(KisPainter *painter)

References KisSharedPtr< T >::data(), m_curveOpOption, and KisCurveOpOptionData::read().

◆ ~KisCurvePaintOp()

KisCurvePaintOp::~KisCurvePaintOp ( )
override

Definition at line 39 of file kis_curve_paintop.cpp.

40{
41 delete m_painter;
42}

References m_painter.

Member Function Documentation

◆ paintAt()

KisSpacingInformation KisCurvePaintOp::paintAt ( const KisPaintInformation & info)
overrideprotectedvirtual

The implementation of painting of a dab and updating spacing. This does NOT need to update the timing information.

Implements KisPaintOp.

Definition at line 44 of file kis_curve_paintop.cpp.

45{
46 return updateSpacingImpl(info);
47}
KisSpacingInformation updateSpacingImpl(const KisPaintInformation &info) const override

References updateSpacingImpl().

◆ paintLine() [1/2]

void KisCurvePaintOp::paintLine ( const KisPaintInformation & pi1,
const KisPaintInformation & pi2,
KisDistanceInformation * currentDistance )
overridevirtual

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 from KisPaintOp.

Definition at line 55 of file kis_curve_paintop.cpp.

56{
57 Q_UNUSED(currentDistance);
58 if (!painter()) return;
59
60 if (!m_dab) {
62 }
63 else {
64 m_dab->clear();
65 }
66
67 paintLine(m_dab, pi1, pi2);
68
69 QRect rc = m_dab->extent();
70
72 painter()->bitBlt(rc.topLeft(), m_dab, rc);
74}
KisPaintDeviceSP m_dab
void paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance) override
void apply(KisPainter *painter, const KisPaintInformation &info) const
virtual void clear()
KisPaintDeviceSP createCompositionSourceDevice() const
QRect extent() const
void renderMirrorMask(QRect rc, KisFixedPaintDeviceSP dab)
void bitBlt(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
KisPaintDeviceSP source() const

References KisOpacityOption::apply(), KisPainter::bitBlt(), KisPaintDevice::clear(), KisPaintDevice::createCompositionSourceDevice(), KisPaintDevice::extent(), m_dab, m_opacityOption, KisPaintOp::painter, paintLine(), KisPainter::renderMirrorMask(), and KisPaintOp::source().

◆ paintLine() [2/2]

void KisCurvePaintOp::paintLine ( KisPaintDeviceSP dab,
const KisPaintInformation & pi1,
const KisPaintInformation & pi2 )
private

Definition at line 76 of file kis_curve_paintop.cpp.

77{
78 if (!m_painter) {
80 m_painter->setPaintColor(painter()->paintColor());
81 }
82
84
85 m_points.append(pi2.pos());
86
87 while (m_points.length() > maxPoints) {
88 m_points.removeFirst();
89 }
90
91 const qreal additionalScale = KisLodTransform::lodToScale(painter()->device());
92 const qreal lineWidth = additionalScale * m_lineWidthOption.apply(pi2) * m_curveOpOption.curve_line_width;
93
94 QPen pen(QBrush(Qt::white), lineWidth);
95 QPainterPath path;
96
98 path.moveTo(pi1.pos());
99 path.lineTo(pi2.pos());
100 m_painter->drawPainterPath(path, pen);
101 path = QPainterPath();
102 }
103
104 if (m_points.length() >= maxPoints) {
105 // alpha * 0.2;
106 path.moveTo(m_points.first());
107
109 path.quadTo(m_points.at(maxPoints / 2), m_points.last());
110 }
111 else {
112 // control point is at 1/3 of the history, 2/3 of the history and endpoint at 3/3
113 int step = maxPoints / 3;
114 path.cubicTo(m_points.at(step), m_points.at(step + step), m_points.last());
115 }
116
118 m_painter->setOpacityF(curveOpacity);
119 m_painter->drawPainterPath(path, pen);
121 }
122}
QList< QPointF > m_points
static qreal lodToScale(int levelOfDetail)
const QPointF & pos() const
void drawPainterPath(const QPainterPath &path, const QPen &pen, const QRect &requestedRect)
void setOpacityF(qreal opacity)
void setOpacityToUnit()
void setPaintColor(const KoColor &color)
qreal apply(const KisPaintInformation &info) const
KisFixedPaintDeviceSP dab

References KisStandardOption< Data >::apply(), KisCurveOpOptionData::curve_curves_opacity, KisCurveOpOptionData::curve_line_width, KisCurveOpOptionData::curve_paint_connection_line, KisCurveOpOptionData::curve_smoothing, KisCurveOpOptionData::curve_stroke_history_size, KisPaintOp::dab, KisPainter::drawPainterPath(), KisLodTransformBase::lodToScale(), m_curveOpOption, m_curvesOpacityOption, m_lineWidthOption, m_painter, m_points, KisPaintOp::painter, KisPaintInformation::pos(), KisPainter::setOpacityF(), KisPainter::setOpacityToUnit(), and KisPainter::setPaintColor().

◆ updateSpacingImpl()

KisSpacingInformation KisCurvePaintOp::updateSpacingImpl ( const KisPaintInformation & info) const
overrideprotectedvirtual

Implementation of a spacing update

Implements KisPaintOp.

Definition at line 49 of file kis_curve_paintop.cpp.

50{
51 Q_UNUSED(info);
52 return KisSpacingInformation(1.0);
53}

Member Data Documentation

◆ m_curveOpOption

KisCurveOpOptionData KisCurvePaintOp::m_curveOpOption
private

Definition at line 39 of file kis_curve_paintop.h.

◆ m_curvesOpacityOption

KisCurvesOpacityOption KisCurvePaintOp::m_curvesOpacityOption
private

Definition at line 42 of file kis_curve_paintop.h.

◆ m_dab

KisPaintDeviceSP KisCurvePaintOp::m_dab
private

Definition at line 36 of file kis_curve_paintop.h.

◆ m_dev

KisPaintDeviceSP KisCurvePaintOp::m_dev
private

Definition at line 37 of file kis_curve_paintop.h.

◆ m_lineWidthOption

KisLineWidthOption KisCurvePaintOp::m_lineWidthOption
private

Definition at line 41 of file kis_curve_paintop.h.

◆ m_opacityOption

KisOpacityOption KisCurvePaintOp::m_opacityOption
private

Definition at line 40 of file kis_curve_paintop.h.

◆ m_painter

KisPainter* KisCurvePaintOp::m_painter
private

Definition at line 45 of file kis_curve_paintop.h.

◆ m_points

QList<QPointF> KisCurvePaintOp::m_points
private

Definition at line 44 of file kis_curve_paintop.h.


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