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

#include <kis_tangent_normal_paintop.h>

+ Inheritance diagram for KisTangentNormalPaintOp:

Public Member Functions

 KisTangentNormalPaintOp (const KisPaintOpSettingsSP settings, KisPainter *painter, KisNodeSP node, KisImageSP image)
 
void paintLine (const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance) override
 
 ~KisTangentNormalPaintOp () 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)
 
 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 scale, qreal rotation) const
 

Private Attributes

KisAirbrushOptionData m_airbrushData
 
QRect m_dstDabRect
 
KisFlowOption m_flowOption
 
KisPaintDeviceSP m_lineCacheDevice
 
KisFixedPaintDeviceSP m_maskDab
 
KisFlowOpacityOption2 m_opacityOption
 
KisRateOption m_rateOption
 
KisRotationOption m_rotationOption
 
KisScatterOption m_scatterOption
 
KisSharpnessOption m_sharpnessOption
 
KisSizeOption m_sizeOption
 
KisSoftnessOption m_softnessOption
 
KisSpacingOption m_spacingOption
 
KisTangentTiltOption m_tangentTiltOption
 
KisPaintDeviceSP m_tempDev
 

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 29 of file kis_tangent_normal_paintop.h.

Constructor & Destructor Documentation

◆ KisTangentNormalPaintOp()

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

Definition at line 25 of file kis_tangent_normal_paintop.cpp.

26 : KisBrushBasedPaintOp(settings, painter)
27 , m_tangentTiltOption(settings.data())
28 , m_opacityOption(settings.data(), node)
29 , m_flowOption(settings.data())
30 , m_sizeOption(settings.data())
31 , m_spacingOption(settings.data())
32 , m_softnessOption(settings.data())
33 , m_sharpnessOption(settings.data())
34 , m_scatterOption(settings.data())
35 , m_rotationOption(settings.data())
36 , m_rateOption(settings.data())
38
39{
40 Q_UNUSED(image);
41 //Init, read settings, etc//
42 m_airbrushData.read(settings.data());
43
46}
KisBrushBasedPaintOp(const KisPaintOpSettingsSP settings, KisPainter *painter, KisBrushTextureFlags textureFlags=None)
void setSharpnessPostprocessing(KisSharpnessOption *option)
KisPaintDeviceSP createCompositionSourceDevice() const
KisPaintDeviceSP device
void applyFanCornersInfo(KisPaintOp *op)
KisAirbrushOptionData m_airbrushData
KisTangentTiltOption m_tangentTiltOption
KisFlowOpacityOption2 m_opacityOption
bool read(const KisPropertiesConfiguration *setting)
KisPainter * painter

References KisRotationOption::applyFanCornersInfo(), KisSharedPtr< T >::data(), m_airbrushData, KisBrushBasedPaintOp::m_dabCache, m_rotationOption, m_sharpnessOption, KisAirbrushOptionData::read(), and KisDabCache::setSharpnessPostprocessing().

◆ ~KisTangentNormalPaintOp()

KisTangentNormalPaintOp::~KisTangentNormalPaintOp ( )
override

Definition at line 48 of file kis_tangent_normal_paintop.cpp.

49{
50 //destroy things here//
51}

Member Function Documentation

◆ computeSpacing()

KisSpacingInformation KisTangentNormalPaintOp::computeSpacing ( const KisPaintInformation & info,
qreal scale,
qreal rotation ) const
private

Definition at line 162 of file kis_tangent_normal_paintop.cpp.

164{
165 return effectiveSpacing(scale, rotation, &m_airbrushData, &m_spacingOption, info);
166}
KisSpacingInformation effectiveSpacing(qreal scale) const

References KisBrushBasedPaintOp::effectiveSpacing(), m_airbrushData, and m_spacingOption.

◆ paintAt()

KisSpacingInformation KisTangentNormalPaintOp::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 53 of file kis_tangent_normal_paintop.cpp.

54{
55 /*
56 * For the color, the precision of tilt is only 60x60, and the precision of direction and rotation are 360 and 360*90.
57 * You can't get more precise than 8bit. Therefore, we will check if the current space is RGB,
58 * if so we request a profile with that space and 8bit bit depth, if not, just sRGB
59 */
61 QString currentSpace = currentColor.colorSpace()->colorModelId().id();
62 const KoColorSpace* rgbColorSpace = KoColorSpaceRegistry::instance()->rgb8();
63 if (currentSpace != "RGBA") {
64 rgbColorSpace = KoColorSpaceRegistry::instance()->rgb8();
65 } else {
66 rgbColorSpace = currentColor.colorSpace();
67 }
68 QVector <float> channelValues(4);
69 qreal r, g, b;
70
71 if (currentColor.colorSpace()->colorDepthId().id()=="F16" || currentColor.colorSpace()->colorDepthId().id()=="F32"){
72 channelValues[0] = 0.5;//red
73 channelValues[1] = 0.5;//green
74 channelValues[2] = 1.0;//blue
75 channelValues[3] = 1.0;//alpha, leave alone.
76
77
78 m_tangentTiltOption.apply(info, &r, &g, &b);
79
80 channelValues[0] = r;//red
81 channelValues[1] = g;//green
82 channelValues[2] = b;//blue
83 } else {
84 channelValues[0] = 1.0;//blue
85 channelValues[1] = 0.5;//green
86 channelValues[2] = 0.5;//red
87 channelValues[3] = 1.0;//alpha, leave alone.
88
89 m_tangentTiltOption.apply(info, &r, &g, &b);
90
91 channelValues[0] = b;//blue
92 channelValues[1] = g;//green
93 channelValues[2] = r;//red
94 }
95
96 quint8 data[MAX_PIXEL_SIZE];
97 rgbColorSpace->fromNormalisedChannelsValue(data, channelValues);
98 KoColor color(data, rgbColorSpace);//Should be default RGB(0.5,0.5,1.0)
99 //draw stuff here, return kisspacinginformation.
100 KisBrushSP brush = m_brush;
101
102 if (!painter()->device() || !brush || !brush->canPaintFor(info)) {
103 return KisSpacingInformation(1.0);
104 }
105
106 qreal scale = m_sizeOption.apply(info);
108 qreal rotation = m_rotationOption.apply(info);
109 if (checkSizeTooSmall(scale)) return KisSpacingInformation();
110 KisDabShape shape(scale, 1.0, rotation);
111
112
113 QPointF cursorPos =
115 brush->maskWidth(shape, 0, 0, info),
116 brush->maskHeight(shape, 0, 0, info));
117
118 m_maskDab =
119 m_dabCache->fetchDab(rgbColorSpace, color, cursorPos,
120 shape,
121 info, m_softnessOption.apply(info),
122 &m_dstDabRect);
123
124 if (m_dstDabRect.isEmpty()) return KisSpacingInformation(1.0);
125
126 QRect dabRect = m_maskDab->bounds();
127
128 // sanity check
129 Q_ASSERT(m_dstDabRect.size() == dabRect.size());
130 Q_UNUSED(dabRect);
131
132 qreal oldOpacityF = painter()->opacityF();
133 QString oldCompositeOpId = painter()->compositeOpId();
134
135
137 //paint with the default color? Copied this from color smudge.//
138 //painter()->setCompositeOp(COMPOSITE_COPY);
139 //painter()->fill(0, 0, m_dstDabRect.width(), m_dstDabRect.height(), color);
142
143 // restore original opacity and composite mode values
144 painter()->setOpacityF(oldOpacityF);
145 painter()->setCompositeOpId(oldCompositeOpId);
146
147 return computeSpacing(info, scale, rotation);
148}
const int MAX_PIXEL_SIZE
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)
void apply(KisPainter *painter, const KisPaintInformation &info)
static qreal lodToScale(int levelOfDetail)
QString compositeOpId
qreal opacityF() const
Returns the opacity that is used in painting.
KoColor paintColor
void setOpacityF(qreal opacity)
void renderMirrorMaskSafe(QRect rc, KisFixedPaintDeviceSP dab, bool preserveDab)
void bltFixed(qint32 dstX, qint32 dstY, const KisFixedPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
void setCompositeOpId(const KoCompositeOp *op)
qreal apply(const KisPaintInformation &info) const
QPointF apply(const KisPaintInformation &info, qreal width, qreal height) const
qreal apply(const KisPaintInformation &info) const
KisSpacingInformation computeSpacing(const KisPaintInformation &info, qreal scale, qreal rotation) const
void apply(const KisPaintInformation &info, qreal *r, qreal *g, qreal *b)
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
virtual void fromNormalisedChannelsValue(quint8 *pixel, const QVector< float > &values) const =0
const KoColorSpace * colorSpace() const
return the current colorSpace
Definition KoColor.h:82
QString id() const
Definition KoID.cpp:63
KoColor currentColor(ResourceProvider *provider, ColorRole role)
static KoColorSpaceRegistry * instance()
const KoColorSpace * rgb8(const QString &profileName=QString())

References KisRotationOption::apply(), KisStandardOption< Data >::apply(), KisTangentTiltOption::apply(), KisScatterOption::apply(), KisFlowOpacityOption2::apply(), KisPainter::bltFixed(), KisFixedPaintDevice::bounds(), KisBrushBasedPaintOp::checkSizeTooSmall(), KoColorSpace::colorDepthId(), KoColorSpace::colorModelId(), KoColor::colorSpace(), KisPainter::compositeOpId, computeSpacing(), KisDabCache::fetchDab(), KoColorSpace::fromNormalisedChannelsValue(), KoID::id(), KoColorSpaceRegistry::instance(), KisLodTransformBase::lodToScale(), KisBrushBasedPaintOp::m_brush, KisBrushBasedPaintOp::m_dabCache, m_dstDabRect, m_maskDab, m_opacityOption, m_rotationOption, m_scatterOption, m_sizeOption, m_softnessOption, m_tangentTiltOption, MAX_PIXEL_SIZE, KisDabCache::needSeparateOriginal(), KisPainter::opacityF(), KisPainter::paintColor, KisPaintOp::painter, KisPainter::renderMirrorMaskSafe(), KoColorSpaceRegistry::rgb8(), KisPainter::setCompositeOpId(), and KisPainter::setOpacityF().

◆ paintLine()

void KisTangentNormalPaintOp::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 168 of file kis_tangent_normal_paintop.cpp.

169{
170 if (m_sharpnessOption.isChecked() && m_brush && (m_brush->width() == 1) && (m_brush->height() == 1)) {
171
172 if (!m_lineCacheDevice) {
174 }
175 else {
177 }
178
181 QString currentSpace = currentColor.colorSpace()->colorModelId().id();
182 const KoColorSpace* rgbColorSpace = KoColorSpaceRegistry::instance()->rgb8();
183 if (currentSpace != "RGBA") {
184 rgbColorSpace = KoColorSpaceRegistry::instance()->rgb8();
185 } else {
186 rgbColorSpace = currentColor.colorSpace();
187 }
188 QVector <float> channelValues(4);
189 qreal r, g, b;
190
191 if (currentColor.colorSpace()->colorDepthId().id()=="F16" || currentColor.colorSpace()->colorDepthId().id()=="F32"){
192 channelValues[0] = 0.5;//red
193 channelValues[1] = 0.5;//green
194 channelValues[2] = 1.0;//blue
195 channelValues[3] = 1.0;//alpha, leave alone.
196
197
198 m_tangentTiltOption.apply(pi2, &r, &g, &b);
199
200 channelValues[0] = r;//red
201 channelValues[1] = g;//green
202 channelValues[2] = b;//blue
203 } else {
204 channelValues[0] = 1.0;//blue
205 channelValues[1] = 0.5;//green
206 channelValues[2] = 0.5;//red
207 channelValues[3] = 1.0;//alpha, leave alone.
208
209 m_tangentTiltOption.apply(pi2, &r, &g, &b);
210
211 channelValues[0] = b;//blue
212 channelValues[1] = g;//green
213 channelValues[2] = r;//red
214 }
215
216 quint8 data[4];
217 rgbColorSpace->fromNormalisedChannelsValue(data, channelValues);
218 KoColor color(data, rgbColorSpace);
219 p.setPaintColor(color);
220 p.drawDDALine(pi1.pos(), pi2.pos());
221
222 QRect rc = m_lineCacheDevice->extent();
223 painter()->bitBlt(rc.x(), rc.y(), m_lineCacheDevice, rc.x(), rc.y(), rc.width(), rc.height());
225 }
226 else {
227 KisPaintOp::paintLine(pi1, pi2, currentDistance);
228 }
229}
const Params2D p
bool isChecked() const
virtual void clear()
QRect extent() const
const QPointF & pos() const
void renderMirrorMask(QRect rc, KisFixedPaintDeviceSP dab)
void bitBlt(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
virtual void paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance)

References KisTangentTiltOption::apply(), KisPainter::bitBlt(), KisPaintDevice::clear(), KoColorSpace::colorDepthId(), KoColorSpace::colorModelId(), KoColor::colorSpace(), KisPaintDevice::extent(), KoColorSpace::fromNormalisedChannelsValue(), KoID::id(), KoColorSpaceRegistry::instance(), KisCurveOption::isChecked(), KisBrushBasedPaintOp::m_brush, m_lineCacheDevice, m_sharpnessOption, m_tangentTiltOption, m_tempDev, p, KisPainter::paintColor, KisPaintOp::painter, KisPaintOp::paintLine(), KisPaintInformation::pos(), KisPainter::renderMirrorMask(), and KoColorSpaceRegistry::rgb8().

◆ updateSpacingImpl()

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

Implementation of a spacing update

Implements KisPaintOp.

Definition at line 150 of file kis_tangent_normal_paintop.cpp.

151{
152 qreal scale = m_sizeOption.apply(info) * KisLodTransform::lodToScale(painter()->device());
153 qreal rotation = m_rotationOption.apply(info);
154 return computeSpacing(info, scale, rotation);
155}

References KisRotationOption::apply(), KisStandardOption< Data >::apply(), computeSpacing(), KisLodTransformBase::lodToScale(), m_rotationOption, m_sizeOption, and KisPaintOp::painter.

◆ updateTimingImpl()

KisTimingInformation KisTangentNormalPaintOp::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 157 of file kis_tangent_normal_paintop.cpp.

158{
160}
KisTimingInformation effectiveTiming(const KisAirbrushOptionData *airbrushOption, const KisRateOption *rateOption, const KisPaintInformation &pi)

References KisPaintOpPluginUtils::effectiveTiming(), m_airbrushData, and m_rateOption.

Member Data Documentation

◆ m_airbrushData

KisAirbrushOptionData KisTangentNormalPaintOp::m_airbrushData
private

Definition at line 64 of file kis_tangent_normal_paintop.h.

◆ m_dstDabRect

QRect KisTangentNormalPaintOp::m_dstDabRect
private

Definition at line 69 of file kis_tangent_normal_paintop.h.

◆ m_flowOption

KisFlowOption KisTangentNormalPaintOp::m_flowOption
private

Definition at line 57 of file kis_tangent_normal_paintop.h.

◆ m_lineCacheDevice

KisPaintDeviceSP KisTangentNormalPaintOp::m_lineCacheDevice
private

Definition at line 71 of file kis_tangent_normal_paintop.h.

◆ m_maskDab

KisFixedPaintDeviceSP KisTangentNormalPaintOp::m_maskDab
private

Definition at line 67 of file kis_tangent_normal_paintop.h.

◆ m_opacityOption

KisFlowOpacityOption2 KisTangentNormalPaintOp::m_opacityOption
private

Definition at line 56 of file kis_tangent_normal_paintop.h.

◆ m_rateOption

KisRateOption KisTangentNormalPaintOp::m_rateOption
private

Definition at line 65 of file kis_tangent_normal_paintop.h.

◆ m_rotationOption

KisRotationOption KisTangentNormalPaintOp::m_rotationOption
private

Definition at line 63 of file kis_tangent_normal_paintop.h.

◆ m_scatterOption

KisScatterOption KisTangentNormalPaintOp::m_scatterOption
private

Definition at line 62 of file kis_tangent_normal_paintop.h.

◆ m_sharpnessOption

KisSharpnessOption KisTangentNormalPaintOp::m_sharpnessOption
private

Definition at line 61 of file kis_tangent_normal_paintop.h.

◆ m_sizeOption

KisSizeOption KisTangentNormalPaintOp::m_sizeOption
private

Definition at line 58 of file kis_tangent_normal_paintop.h.

◆ m_softnessOption

KisSoftnessOption KisTangentNormalPaintOp::m_softnessOption
private

Definition at line 60 of file kis_tangent_normal_paintop.h.

◆ m_spacingOption

KisSpacingOption KisTangentNormalPaintOp::m_spacingOption
private

Definition at line 59 of file kis_tangent_normal_paintop.h.

◆ m_tangentTiltOption

KisTangentTiltOption KisTangentNormalPaintOp::m_tangentTiltOption
private

Definition at line 54 of file kis_tangent_normal_paintop.h.

◆ m_tempDev

KisPaintDeviceSP KisTangentNormalPaintOp::m_tempDev
private

Definition at line 68 of file kis_tangent_normal_paintop.h.


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