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

#include <kis_roundmarkerop.h>

+ Inheritance diagram for KisRoundMarkerOp:

Public Member Functions

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

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

Private Attributes

bool m_firstRun
 
QPointF m_lastPaintPos
 
qreal m_lastRadius
 
KisRoundMarkerOpOptionData m_markerOption
 
KisSizeOption m_sizeOption
 
KisSpacingOption m_spacingOption
 
KisPaintDeviceSP m_tempDev
 

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 kis_roundmarkerop.h.

Constructor & Destructor Documentation

◆ KisRoundMarkerOp()

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

Definition at line 34 of file kis_roundmarkerop.cpp.

36 , m_sizeOption(settings.data())
37 , m_spacingOption(settings.data())
38{
39 Q_UNUSED(node);
40
41 Q_ASSERT(settings);
42 Q_ASSERT(painter);
43
44 m_firstRun = true;
45 m_lastRadius = 1.0;
46
47 m_markerOption.read(settings.data());
48}
KisSizeOption m_sizeOption
KisRoundMarkerOpOptionData m_markerOption
KisSpacingOption m_spacingOption
KisPainter * painter
KisPaintOp(KisPainter *painter)
bool read(const KisPropertiesConfiguration *setting)

References KisSharedPtr< T >::data(), m_firstRun, m_lastRadius, m_markerOption, KisPaintOp::painter, and KisRoundMarkerOpOptionData::read().

◆ ~KisRoundMarkerOp()

KisRoundMarkerOp::~KisRoundMarkerOp ( )
override

Definition at line 50 of file kis_roundmarkerop.cpp.

51{
52}

Member Function Documentation

◆ computeSpacing()

KisSpacingInformation KisRoundMarkerOp::computeSpacing ( const KisPaintInformation & info,
qreal diameter ) const
private

Definition at line 154 of file kis_roundmarkerop.cpp.

156{
157 const qreal rotation = 0; // TODO
158 const bool axesFlipped = false; // TODO
159
160 qreal extraSpacingScale = 1.0;
162 extraSpacingScale = m_spacingOption.apply(info);
163 }
164
165 return KisPaintOpUtils::effectiveSpacing(diameter, diameter,
166 extraSpacingScale, true, true, rotation, axesFlipped,
171}
bool isChecked() const
static qreal lodToScale(int levelOfDetail)
qreal apply(const KisPaintInformation &info) const
KisSpacingInformation effectiveSpacing(qreal dabWidth, qreal dabHeight, qreal extraScale, bool distanceSpacingEnabled, bool isotropicSpacing, qreal rotation, bool axesFlipped, qreal spacingVal, bool autoSpacingActive, qreal autoSpacingCoeff, qreal lodScale)

References KisSpacingOption::apply(), KisRoundMarkerOpOptionData::autoSpacingCoeff, KisPaintOpUtils::effectiveSpacing(), KisCurveOption::isChecked(), KisLodTransformBase::lodToScale(), m_markerOption, m_spacingOption, KisPaintOp::painter, KisRoundMarkerOpOptionData::spacing, and KisRoundMarkerOpOptionData::useAutoSpacing.

◆ paintAt()

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

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

Save the center of the current dab to know where to read the data during the next pass. We do not save scatteredPos here, because it may differ slightly from the real center of the brush (due to rounding effects), which will result in a really weird quality.

Implements KisPaintOp.

Definition at line 54 of file kis_roundmarkerop.cpp.

55{
56 // Simple error catching
57 if (!painter()->device()) {
58 return KisSpacingInformation(1.0);
59 }
60
61 // get the scaling factor calculated by the size option
62 const qreal lodScale = KisLodTransform::lodToScale(painter()->device());
63 const qreal scale = m_sizeOption.apply(info) * lodScale;
64 const qreal rotation = 0; // TODO
65
66 const qreal diameter = m_markerOption.diameter * scale;
67 qreal radius = 0.5 * diameter;
68
69 if (KisPaintOpUtils::checkSizeTooSmall(scale, diameter, diameter)) return KisSpacingInformation();
70 KisDabShape shape(scale, 1.0, rotation);
71
72 // The position will need subtracting 0.5, but you cannot do this here
73 // because then the mirroring tools get wrong position to mirror
74 // and the mirroring doesn't work well.
75 // Subtracting must happen just before the painting.
76 QPointF pos = info.pos();
77
78 KisMarkerPainter gc(painter()->device(), painter()->paintColor());
79
80 if (m_firstRun) {
81 const QVector<QPointF> points =
83
84 Q_FOREACH(const QPointF &pt, points) {
85 // Subtracting .5 from both dimensions, because the final dab tends to exaggerate towards the lower right.
86 // This aligns it with the brush cursor.
87 gc.fillFullCircle(pt - QPointF(0.5, 0.5), radius);
88 }
89 } else {
92
93 Q_FOREACH(const auto &pair, pairs) {
94 // Subtracting .5 from both dimensions, because the final dab tends to exaggerate towards the lower right.
95 // This aligns it with the brush cursor.
96 gc.fillCirclesDiff(pair.first - QPointF(0.5, 0.5), m_lastRadius,
97 pair.second - QPointF(0.5, 0.5), radius);
98 }
99 }
100
101 m_firstRun = false;
102 m_lastPaintPos = pos;
103 m_lastRadius = radius;
104
105 QRectF dirtyRect(pos.x() - radius, pos.y() - radius,
106 2 * radius, 2 * radius);
107 dirtyRect = kisGrowRect(dirtyRect, 1);
108
109 const QVector<QRect> allDirtyRects =
110 painter()->calculateAllMirroredRects(dirtyRect.toAlignedRect());
111
112 painter()->addDirtyRects(allDirtyRects);
113
114 // QPointF scatteredPos =
115 // m_scatterOption.apply(info,
116 // brush->maskWidth(shape, 0, 0, info),
117 // brush->maskHeight(shape, 0, 0, info));
118
119
120
121 //updateMask(info, scale, rotation, scatteredPos);
122
123 //QPointF newCenterPos = QRectF(m_dstDabRect).center();
131 //QRect srcDabRect = m_dstDabRect.translated((m_lastPaintPos - newCenterPos).toPoint());
132
133 //m_lastPaintPos = newCenterPos;
134
135 KisSpacingInformation spacingInfo = computeSpacing(info, diameter);
136
137 if (m_firstRun) {
138 m_firstRun = false;
139 return spacingInfo;
140 }
141
142
143 return spacingInfo;
144}
const QPointF & pos() const
const QVector< QRect > calculateAllMirroredRects(const QRect &rc)
void addDirtyRects(const QVector< QRect > &rects)
const QVector< QPointF > calculateAllMirroredPoints(const QPointF &pos)
KisSpacingInformation computeSpacing(const KisPaintInformation &info, qreal diameter) const
qreal apply(const KisPaintInformation &info) const
T kisGrowRect(const T &rect, U offset)
Definition kis_global.h:186
bool checkSizeTooSmall(qreal scale, qreal width, qreal height)

References KisPainter::addDirtyRects(), KisStandardOption< Data >::apply(), KisPainter::calculateAllMirroredPoints(), KisPainter::calculateAllMirroredRects(), KisPaintOpUtils::checkSizeTooSmall(), computeSpacing(), KisRoundMarkerOpOptionData::diameter, KisMarkerPainter::fillCirclesDiff(), KisMarkerPainter::fillFullCircle(), kisGrowRect(), KisLodTransformBase::lodToScale(), m_firstRun, m_lastPaintPos, m_lastRadius, m_markerOption, m_sizeOption, KisPaintOp::painter, and KisPaintInformation::pos().

◆ updateSpacingImpl()

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

Implementation of a spacing update

Implements KisPaintOp.

Definition at line 146 of file kis_roundmarkerop.cpp.

147{
148 const qreal lodScale = KisLodTransform::lodToScale(painter()->device());
149 const qreal diameter = m_markerOption.diameter * m_sizeOption.apply(info) * lodScale;
150
151 return computeSpacing(info, diameter);
152}

References KisStandardOption< Data >::apply(), computeSpacing(), KisRoundMarkerOpOptionData::diameter, KisLodTransformBase::lodToScale(), m_markerOption, m_sizeOption, and KisPaintOp::painter.

Member Data Documentation

◆ m_firstRun

bool KisRoundMarkerOp::m_firstRun
private

Definition at line 38 of file kis_roundmarkerop.h.

◆ m_lastPaintPos

QPointF KisRoundMarkerOp::m_lastPaintPos
private

Definition at line 42 of file kis_roundmarkerop.h.

◆ m_lastRadius

qreal KisRoundMarkerOp::m_lastRadius
private

Definition at line 43 of file kis_roundmarkerop.h.

◆ m_markerOption

KisRoundMarkerOpOptionData KisRoundMarkerOp::m_markerOption
private

Definition at line 44 of file kis_roundmarkerop.h.

◆ m_sizeOption

KisSizeOption KisRoundMarkerOp::m_sizeOption
private

Definition at line 40 of file kis_roundmarkerop.h.

◆ m_spacingOption

KisSpacingOption KisRoundMarkerOp::m_spacingOption
private

Definition at line 41 of file kis_roundmarkerop.h.

◆ m_tempDev

KisPaintDeviceSP KisRoundMarkerOp::m_tempDev
private

Definition at line 39 of file kis_roundmarkerop.h.


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