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

#include <kis_hatching_paintop.h>

+ Inheritance diagram for KisHatchingPaintOp:

Public Member Functions

 KisHatchingPaintOp (const KisPaintOpSettingsSP settings, KisPainter *painter, KisNodeSP node, KisImageSP image)
 
double spinAngle (double spin)
 
 ~KisHatchingPaintOp () override
 
- Public Member Functions inherited from KisBrushBasedPaintOp
bool canPaint () const override
 Reimplemented, false if brush is 0.
 
bool checkSizeTooSmall (qreal scale)
 
KisSpacingInformation effectiveSpacing (qreal scale) const
 
KisSpacingInformation effectiveSpacing (qreal scale, qreal rotation, const KisAirbrushOptionData *airbrushOption, const KisSpacingOption *spacingOption, const KisPaintInformation &pi) const
 
KisSpacingInformation effectiveSpacing (qreal scale, qreal rotation, const KisPaintInformation &pi) const
 
KisSpacingInformation effectiveSpacing (qreal scale, qreal rotation, const KisSpacingOption &spacingOption, const KisPaintInformation &pi) const
 
 KisBrushBasedPaintOp (const KisPaintOpSettingsSP settings, KisPainter *painter, KisBrushTextureFlags textureFlags=None)
 
 ~KisBrushBasedPaintOp () override
 
- Public Member Functions inherited from KisPaintOp
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
 
- 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 Attributes

KisAngleOption m_angleOption
 
KisCrosshatchingOption m_crosshatchingOption
 
KisPaintDeviceSP m_hatchedDab
 
HatchingBrushm_hatchingBrush
 
KisHatchingOptionsData m_hatchingOptions
 
KisHatchingPreferencesData m_hatchingPreferences
 
KisOpacityOption m_opacityOption
 
KisSeparationOption m_separationOption
 
KisHatchingPaintOpSettingsSP m_settings
 
KisSizeOption m_sizeOption
 
KisThicknessOption m_thicknessOption
 

Additional Inherited Members

- Static Public Member Functions inherited from KisBrushBasedPaintOp
static QList< KoResourceLoadResultprepareEmbeddedResources (const KisPaintOpSettingsSP settings, KisResourcesInterfaceSP resourcesInterface)
 
static QList< KoResourceLoadResultprepareLinkedResources (const KisPaintOpSettingsSP settings, KisResourcesInterfaceSP resourcesInterface)
 
- 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
 
- Protected Attributes inherited from KisBrushBasedPaintOp
KisBrushSP m_brush
 
KisDabCachem_dabCache
 
KisMirrorOption m_mirrorOption
 
KisPrecisionOption m_precisionOption
 

Detailed Description

Definition at line 30 of file kis_hatching_paintop.h.

Constructor & Destructor Documentation

◆ KisHatchingPaintOp()

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

Definition at line 35 of file kis_hatching_paintop.cpp.

36 : KisBrushBasedPaintOp(settings, painter)
37 , m_angleOption(settings.data())
38 , m_crosshatchingOption(settings.data())
39 , m_separationOption(settings.data())
40 , m_thicknessOption(settings.data())
41 , m_opacityOption(settings.data(), node)
42 , m_sizeOption(settings.data())
43{
44 Q_UNUSED(node);
45
46 m_settings = static_cast<KisHatchingPaintOpSettings*>(settings->clone().data());
47 static_cast<const KisHatchingPaintOpSettings*>(settings.data())->initializeTwin(m_settings);
48
50 m_hatchingOptions.read(settings.data());
52
53}
KisBrushBasedPaintOp(const KisPaintOpSettingsSP settings, KisPainter *painter, KisBrushTextureFlags textureFlags=None)
KisThicknessOption m_thicknessOption
HatchingBrush * m_hatchingBrush
KisAngleOption m_angleOption
KisHatchingOptionsData m_hatchingOptions
KisCrosshatchingOption m_crosshatchingOption
KisSeparationOption m_separationOption
KisHatchingPreferencesData m_hatchingPreferences
KisHatchingPaintOpSettingsSP m_settings
KisOpacityOption m_opacityOption
bool read(const KisPropertiesConfiguration *setting)
bool read(const KisPropertiesConfiguration *setting)
KisPainter * painter

References KisSharedPtr< T >::data(), m_hatchingBrush, m_hatchingOptions, m_hatchingPreferences, m_settings, KisHatchingOptionsData::read(), and KisHatchingPreferencesData::read().

◆ ~KisHatchingPaintOp()

KisHatchingPaintOp::~KisHatchingPaintOp ( )
override

Definition at line 55 of file kis_hatching_paintop.cpp.

56{
57 delete m_hatchingBrush;
58}

References m_hatchingBrush.

Member Function Documentation

◆ paintAt()

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

Paint a hatched dab around the mouse cursor according to sensor settings and user preferences.

Implements KisPaintOp.

Definition at line 60 of file kis_hatching_paintop.cpp.

61{
62 //------START SIMPLE ERROR CATCHING-------
63 if (!painter()->device()) return KisSpacingInformation(1.0);
64
65 if (!m_hatchedDab)
67 else
69
70 //Simple convenience renaming, I'm thinking of removing these inherited quirks
71 KisBrushSP brush = m_brush;
72 KisPaintDeviceSP device = painter()->device();
73
74 //Macro to catch errors
75 Q_ASSERT(brush);
76
77 //----------SIMPLE error catching code, maybe it's not even needed------
78 if (!brush) return KisSpacingInformation(1.0);
79 if (!brush->canPaintFor(info)) return KisSpacingInformation(1.0);
80
81 //SENSOR-depending settings
86
87 const qreal additionalScale = KisLodTransform::lodToScale(painter()->device());
88 const double scale = additionalScale * m_sizeOption.apply(info);
89 if ((scale * brush->width()) <= 0.01 || (scale * brush->height()) <= 0.01) return KisSpacingInformation(1.0);
90 KisDabShape shape(scale, 1.0, 0.0);
91
93
94 /*----Fetch the Dab----*/
96 static KoColor color(Qt::black, cs);
97
98 QRect dstRect;
99 KisFixedPaintDeviceSP maskDab =
100 m_dabCache->fetchDab(cs, color, info.pos(),
101 shape,
102 info, 1.0, &dstRect);
103
104 // sanity check
105 KIS_ASSERT_RECOVER_NOOP(dstRect.size() == maskDab->bounds().size());
106
107 /*-----Convenient renaming for the limits of the maskDab, this will be used
108 to hatch a dab of just the right size------*/
109 qint32 x, y, sw, sh;
110 dstRect.getRect(&x, &y, &sw, &sh);
111
112 //------This If_block pre-fills the future m_hatchedDab with a pretty backgroundColor
114 KoColor aersh = painter()->backgroundColor();
115 m_hatchedDab->fill(0, 0, (sw - 1), (sh - 1), aersh.data()); //this plus yellow background = french fry brush
116 }
117
118 /* If block describing how to stack hatching passes to generate
119 crosshatching according to user specifications */
123 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(90), painter()->paintColor(), additionalScale);
124 }
127 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(-45), painter()->paintColor(), additionalScale);
129 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(45), painter()->paintColor(), additionalScale);
130 }
133 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(45), painter()->paintColor(), additionalScale);
135 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(-45), painter()->paintColor(), additionalScale);
136 }
138 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle((m_settings->crosshatchingsensorvalue) * 360), painter()->paintColor(), additionalScale);
139 }
140 } else {
142 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(90), painter()->paintColor(), additionalScale);
143 }
145 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(-45), painter()->paintColor(), additionalScale);
146 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(45), painter()->paintColor(), additionalScale);
147 }
149 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(45), painter()->paintColor(), additionalScale);
150 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(-45), painter()->paintColor(), additionalScale);
151 }
153 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(-10), painter()->paintColor(), additionalScale);
154 }
155 }
156
158 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle((m_settings->anglesensorvalue)*360+m_hatchingOptions.angle), painter()->paintColor(), additionalScale);
159
160 // The base hatch... unless moiré or angle
162 m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, m_hatchingOptions.angle, painter()->paintColor(), additionalScale);
163
164
165 // The most important line, the one that paints to the screen.
166 painter()->bitBltWithFixedSelection(x, y, m_hatchedDab, maskDab, sw, sh);
167 painter()->renderMirrorMaskSafe(QRect(QPoint(x, y), QSize(sw, sh)), m_hatchedDab, 0, 0, maskDab,
169
170 return effectiveSpacing(scale);
171}
void hatch(KisPaintDeviceSP dev, qreal x, qreal y, double width, double height, double givenAngle, const KoColor &color, qreal additionalScale)
KisSpacingInformation effectiveSpacing(qreal scale) const
bool isChecked() const
bool needSeparateOriginal() const
KisFixedPaintDeviceSP fetchDab(const KoColorSpace *cs, KisColorSource *colorSource, const QPointF &cursorPoint, KisDabShape const &, const KisPaintInformation &info, qreal softnessFactor, QRect *dstDabRect, qreal lightnessStrength=1.0)
double spinAngle(double spin)
KisPaintDeviceSP m_hatchedDab
static qreal lodToScale(int levelOfDetail)
void apply(KisPainter *painter, const KisPaintInformation &info) const
virtual void clear()
KisPaintDeviceSP createCompositionSourceDevice() const
void fill(const QRect &rc, const KoColor &color)
const QPointF & pos() const
void renderMirrorMaskSafe(QRect rc, KisFixedPaintDeviceSP dab, bool preserveDab)
KisPaintDeviceSP device
KoColor backgroundColor
void bitBltWithFixedSelection(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, const KisFixedPaintDeviceSP selection, qint32 selX, qint32 selY, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
qreal apply(const KisPaintInformation &info) const
quint8 * data()
Definition KoColor.h:144
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97
CrosshatchingType crosshatchingStyle
KisPaintDeviceSP source() const
static KoColorSpaceRegistry * instance()
const KoColorSpace * alpha8()

References KoColorSpaceRegistry::alpha8(), KisHatchingOptionsData::angle, KisHatchingPaintOpSettings::anglesensorvalue, KisStandardOption< Data >::apply(), KisOpacityOption::apply(), KisPainter::backgroundColor, KisPainter::bitBltWithFixedSelection(), KisFixedPaintDevice::bounds(), KisPaintDevice::clear(), KisPaintDevice::createCompositionSourceDevice(), KisHatchingPaintOpSettings::crosshatchingsensorvalue, KisHatchingOptionsData::crosshatchingStyle, KoColor::data(), KisPainter::device, KisBrushBasedPaintOp::effectiveSpacing(), KisDabCache::fetchDab(), KisPaintDevice::fill(), HatchingBrush::hatch(), KoColorSpaceRegistry::instance(), KisCurveOption::isChecked(), KIS_ASSERT_RECOVER_NOOP, KisLodTransformBase::lodToScale(), m_angleOption, KisBrushBasedPaintOp::m_brush, m_crosshatchingOption, KisBrushBasedPaintOp::m_dabCache, m_hatchedDab, m_hatchingBrush, m_hatchingOptions, m_hatchingPreferences, m_opacityOption, m_separationOption, m_settings, m_sizeOption, m_thicknessOption, MinusThenPlus, MoirePattern, KisDabCache::needSeparateOriginal(), KisPaintOp::painter, Perpendicular, PlusThenMinus, KisPaintInformation::pos(), KisPainter::renderMirrorMaskSafe(), KisHatchingPaintOpSettings::separationsensorvalue, KisPaintOp::source(), spinAngle(), KisHatchingPaintOpSettings::thicknesssensorvalue, and KisHatchingPreferencesData::useOpaqueBackground.

◆ spinAngle()

double KisHatchingPaintOp::spinAngle ( double spin)

Returns a number between -90 and 90, and corresponds to the angle that results from adding angle 'spin' to 'm_hatchingOptions.angle', corrected to coincide with the way the GUI operates.

Definition at line 179 of file kis_hatching_paintop.cpp.

180{
181 double tempangle = m_hatchingOptions.angle + spin;
182 qint8 factor = 1;
183
184 if (tempangle < 0)
185 factor = -1;
186
187 tempangle = fabs(fmod(tempangle, 180));
188
189 if ((tempangle >= 0) && (tempangle <= 90))
190 return factor * tempangle;
191 else if ((tempangle > 90) && (tempangle <= 180))
192 return factor * -(180 - tempangle);
193
194 return 0; // this should never be executed except if NAN
195}

References KisHatchingOptionsData::angle, and m_hatchingOptions.

◆ updateSpacingImpl()

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

Implementation of a spacing update

Implements KisPaintOp.

Definition at line 173 of file kis_hatching_paintop.cpp.

174{
175 const qreal scale = KisLodTransform::lodToScale(painter()->device()) * m_sizeOption.apply(info);
176 return effectiveSpacing(scale);
177}

References KisStandardOption< Data >::apply(), KisBrushBasedPaintOp::effectiveSpacing(), KisLodTransformBase::lodToScale(), m_sizeOption, and KisPaintOp::painter.

Member Data Documentation

◆ m_angleOption

KisAngleOption KisHatchingPaintOp::m_angleOption
private

Curve to control the hatching angle according to user preferences set in the GUI

Definition at line 70 of file kis_hatching_paintop.h.

◆ m_crosshatchingOption

KisCrosshatchingOption KisHatchingPaintOp::m_crosshatchingOption
private

Curve to control the intensity of crosshatching according to user preferences set in the GUI

Definition at line 76 of file kis_hatching_paintop.h.

◆ m_hatchedDab

KisPaintDeviceSP KisHatchingPaintOp::m_hatchedDab
private

PaintDevice that will be filled with a single pass of hatching by HatchingBrush::hatch

Definition at line 64 of file kis_hatching_paintop.h.

◆ m_hatchingBrush

HatchingBrush* KisHatchingPaintOp::m_hatchingBrush
private

Definition at line 58 of file kis_hatching_paintop.h.

◆ m_hatchingOptions

KisHatchingOptionsData KisHatchingPaintOp::m_hatchingOptions
private

Definition at line 56 of file kis_hatching_paintop.h.

◆ m_hatchingPreferences

KisHatchingPreferencesData KisHatchingPaintOp::m_hatchingPreferences
private

Definition at line 57 of file kis_hatching_paintop.h.

◆ m_opacityOption

KisOpacityOption KisHatchingPaintOp::m_opacityOption
private

Curve to control the opacity of the entire dab with device input

Definition at line 94 of file kis_hatching_paintop.h.

◆ m_separationOption

KisSeparationOption KisHatchingPaintOp::m_separationOption
private

Curve to control the dynamics of separation with device input

Definition at line 82 of file kis_hatching_paintop.h.

◆ m_settings

KisHatchingPaintOpSettingsSP KisHatchingPaintOp::m_settings
private

Definition at line 55 of file kis_hatching_paintop.h.

◆ m_sizeOption

KisSizeOption KisHatchingPaintOp::m_sizeOption
private

Curve to control the size of the entire dab with device input

Definition at line 100 of file kis_hatching_paintop.h.

◆ m_thicknessOption

KisThicknessOption KisHatchingPaintOp::m_thicknessOption
private

Curve to control the thickness of the hatching lines with device input

Definition at line 88 of file kis_hatching_paintop.h.


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