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

#include <MyPaintPaintOp.h>

+ Inheritance diagram for KisMyPaintPaintOp:

Public Member Functions

 KisMyPaintPaintOp (const KisPaintOpSettingsSP settings, KisPainter *painter, KisNodeSP node, KisImageSP image)
 
 ~KisMyPaintPaintOp () 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)
 
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 ()
 

Protected Member Functions

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

Private Member Functions

KisSpacingInformation computeSpacing (const KisPaintInformation &info, qreal lodScale) const
 

Private Attributes

KisAirbrushOptionData m_airBrushData
 
QScopedPointer< KisMyPaintPaintOpPresetm_brush
 
double m_dtime
 
KisImageWSP m_image
 
bool m_isStrokeStarted
 
double m_previousTime = 0
 
double m_radius
 
KisPaintOpSettingsSP m_settings
 
QScopedPointer< KisMyPaintSurfacem_surface
 

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 22 of file MyPaintPaintOp.h.

Constructor & Destructor Documentation

◆ KisMyPaintPaintOp()

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

Definition at line 25 of file MyPaintPaintOp.cpp.

27
28 m_image = image;
29
31 m_surface.reset(new KisMyPaintSurface(this->painter(), nullptr, m_image));
32
33 m_brush->apply(settings);
34
35 if (settings->getBool("EraserMode")) {
36
38 mypaint_brush_set_base_value(m_brush->brush(), MYPAINT_BRUSH_SETTING_ERASER, false);
39 }
40
41 m_brush->setColor(this->painter()->paintColor(), painter->device()->colorSpace());
42
43 if (KoToolManager::instance()->activeToolId() != "KritaShape/KisToolBrush") {
44 mypaint_brush_set_base_value(m_brush->brush(), MYPAINT_BRUSH_SETTING_SLOW_TRACKING, 0.0);
45 }
46
47 m_settings = settings;
49
50 m_dtime = -1;
51 m_isStrokeStarted = false;
52 m_radius = exp(mypaint_brush_get_base_value(m_brush->brush(), MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC));
53}
const QString COMPOSITE_ERASE
QScopedPointer< KisMyPaintSurface > m_surface
KisPaintOpSettingsSP m_settings
QScopedPointer< KisMyPaintPaintOpPreset > m_brush
KisImageWSP m_image
KisAirbrushOptionData m_airBrushData
const KoColorSpace * colorSpace() const
KisPaintDeviceSP device
void setCompositeOpId(const KoCompositeOp *op)
static KoToolManager * instance()
Return the toolmanager singleton.
bool read(const KisPropertiesConfiguration *setting)
KisPainter * painter
KisPaintOp(KisPainter *painter)

References KisPaintDevice::colorSpace(), COMPOSITE_ERASE, KisSharedPtr< T >::data(), KisPainter::device, KoToolManager::instance(), m_airBrushData, m_brush, m_dtime, m_image, m_isStrokeStarted, m_radius, m_settings, m_surface, KisPaintOp::painter, KisAirbrushOptionData::read(), and KisPainter::setCompositeOpId().

◆ ~KisMyPaintPaintOp()

KisMyPaintPaintOp::~KisMyPaintPaintOp ( )
override

Definition at line 55 of file MyPaintPaintOp.cpp.

55 {
56}

Member Function Documentation

◆ computeSpacing()

KisSpacingInformation KisMyPaintPaintOp::computeSpacing ( const KisPaintInformation & info,
qreal lodScale ) const
private

Definition at line 101 of file MyPaintPaintOp.cpp.

101 {
102
104 false, 0.0, false, m_radius*2,
105 true, 1, lodScale, &m_airBrushData, nullptr, info);
106}
KisSpacingInformation effectiveSpacing(qreal dabWidth, qreal dabHeight, bool isotropicSpacing, qreal rotation, bool axesFlipped, qreal spacingVal, bool autoSpacingActive, qreal autoSpacingCoeff, qreal lodScale, const KisAirbrushOptionData *airbrushOption, const KisSpacingOption *spacingOption, const KisPaintInformation &pi)

References KisPaintOpPluginUtils::effectiveSpacing(), m_airBrushData, and m_radius.

◆ paintAt()

KisSpacingInformation KisMyPaintPaintOp::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 58 of file MyPaintPaintOp.cpp.

58 {
59
60 if (!painter()) {
61 return KisSpacingInformation(1.0);
62 }
63
64 const qreal lodScale = KisLodTransform::lodToScale(painter()->device());
65
66 qreal radius = m_radius;
67 radius *= lodScale;
68 mypaint_brush_set_base_value(m_brush->brush(), MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC, log(radius));
69
70 m_isStrokeStarted = mypaint_brush_get_state(m_brush->brush(), MYPAINT_BRUSH_STATE_STROKE_STARTED);
71 if (!m_isStrokeStarted) {
72
73 mypaint_brush_stroke_to(m_brush->brush(), m_surface->surface(), info.pos().x(), info.pos().y(), info.pressure(),
74 info.xTilt(), info.yTilt(), 1.0f);
75
76 m_dtime = 0.015;
77 }
78 else {
79 m_dtime = abs(info.currentTime() - m_previousTime)*0.001;
80 }
81
82 mypaint_brush_stroke_to(m_brush->brush(), m_surface->surface(), info.pos().x(), info.pos().y(), info.pressure(),
83 info.xTilt(), info.yTilt(), m_dtime);
84
86
87 return computeSpacing(info, lodScale);
88}
static qreal lodToScale(int levelOfDetail)
KisSpacingInformation computeSpacing(const KisPaintInformation &info, qreal lodScale) const
const QPointF & pos() const
qreal xTilt() const
The tilt of the pen on the horizontal axis (from 0.0 to 1.0)
qreal currentTime() const
Number of ms since the beginning of the stroke.
qreal yTilt() const
The tilt of the pen on the vertical axis (from 0.0 to 1.0)
qreal pressure() const
The pressure of the value (from 0.0 to 1.0)
Point abs(const Point &pt)

References computeSpacing(), KisPaintInformation::currentTime(), KisLodTransformBase::lodToScale(), m_brush, m_dtime, m_isStrokeStarted, m_previousTime, m_radius, m_surface, KisPaintOp::painter, KisPaintInformation::pos(), KisPaintInformation::pressure(), KisPaintInformation::xTilt(), and KisPaintInformation::yTilt().

◆ updateSpacingImpl()

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

Implementation of a spacing update

Implements KisPaintOp.

Definition at line 90 of file MyPaintPaintOp.cpp.

91{
93 return spacingInfo;
94}

References computeSpacing(), KisLodTransformBase::lodToScale(), and KisPaintOp::painter.

◆ updateTimingImpl()

KisTimingInformation KisMyPaintPaintOp::updateTimingImpl ( const KisPaintInformation & info) const
overrideprotectedvirtual

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

Reimplemented from KisPaintOp.

Definition at line 96 of file MyPaintPaintOp.cpp.

96 {
97
99}
KisTimingInformation effectiveTiming(const KisAirbrushOptionData *airbrushOption, const KisRateOption *rateOption, const KisPaintInformation &pi)

References KisPaintOpPluginUtils::effectiveTiming(), and m_airBrushData.

Member Data Documentation

◆ m_airBrushData

KisAirbrushOptionData KisMyPaintPaintOp::m_airBrushData
private

Definition at line 45 of file MyPaintPaintOp.h.

◆ m_brush

QScopedPointer<KisMyPaintPaintOpPreset> KisMyPaintPaintOp::m_brush
private

Definition at line 42 of file MyPaintPaintOp.h.

◆ m_dtime

double KisMyPaintPaintOp::m_dtime
private

Definition at line 47 of file MyPaintPaintOp.h.

◆ m_image

KisImageWSP KisMyPaintPaintOp::m_image
private

Definition at line 46 of file MyPaintPaintOp.h.

◆ m_isStrokeStarted

bool KisMyPaintPaintOp::m_isStrokeStarted
private

Definition at line 48 of file MyPaintPaintOp.h.

◆ m_previousTime

double KisMyPaintPaintOp::m_previousTime = 0
private

Definition at line 47 of file MyPaintPaintOp.h.

◆ m_radius

double KisMyPaintPaintOp::m_radius
private

Definition at line 47 of file MyPaintPaintOp.h.

◆ m_settings

KisPaintOpSettingsSP KisMyPaintPaintOp::m_settings
private

Definition at line 44 of file MyPaintPaintOp.h.

◆ m_surface

QScopedPointer<KisMyPaintSurface> KisMyPaintPaintOp::m_surface
private

Definition at line 43 of file MyPaintPaintOp.h.


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