Krita Source Code Documentation
Loading...
Searching...
No Matches
KisBrushesPipe< BrushType > Class Template Referenceabstract

#include <kis_brushes_pipe.h>

Public Member Functions

QVector< QSharedPointer< BrushType > > brushes ()
 
virtual void clear ()
 
QSharedPointer< BrushType > currentBrush (const KisPaintInformation &info)
 
QSharedPointer< BrushType > firstBrush () const
 
void generateMaskAndApplyMaskOrCreateDab (KisFixedPaintDeviceSP dst, KisBrush::ColoringInformation *coloringInformation, KisDabShape const &shape, const KisPaintInformation &info, double subPixelX, double subPixelY, qreal softnessFactor, qreal lightnessStrength=DEFAULT_LIGHTNESS_STRENGTH)
 
bool hasColorAndTransparency () const
 
bool isImageType () const
 
 KisBrushesPipe ()
 
 KisBrushesPipe (const KisBrushesPipe &rhs)
 
QSharedPointer< BrushType > lastBrush () const
 
qint32 maskHeight (KisDabShape const &shape, double subPixelX, double subPixelY, const KisPaintInformation &info)
 
qint32 maskWidth (KisDabShape const &shape, double subPixelX, double subPixelY, const KisPaintInformation &info)
 
void notifyBrushIsGoingToBeClonedForStroke ()
 
virtual void notifyStrokeStarted ()=0
 
KisFixedPaintDeviceSP paintDevice (const KoColorSpace *colorSpace, KisDabShape const &shape, const KisPaintInformation &info, double subPixelX, double subPixelY)
 
void prepareForSeqNo (const KisPaintInformation &info, int seqNo)
 
void setAngle (qreal angle)
 
void setBrushApplication (enumBrushApplication brushApplication) const
 
void setGradient (KoAbstractGradientSP gradient) const
 
void setScale (qreal scale)
 
void setSpacing (double spacing)
 
void testingSelectNextBrush (const KisPaintInformation &info)
 
virtual ~KisBrushesPipe ()
 

Protected Member Functions

void addBrush (QSharedPointer< BrushType > brush)
 
virtual int chooseNextBrush (const KisPaintInformation &info)=0
 
virtual int currentBrushIndex ()=0
 
int sizeBrush ()
 
virtual void updateBrushIndexes (KisRandomSourceSP randomSource, int seqNo)=0
 

Protected Attributes

QVector< QSharedPointer< BrushType > > m_brushes
 

Detailed Description

template<class BrushType>
class KisBrushesPipe< BrushType >

Definition at line 19 of file kis_brushes_pipe.h.

Constructor & Destructor Documentation

◆ KisBrushesPipe() [1/2]

template<class BrushType >
KisBrushesPipe< BrushType >::KisBrushesPipe ( )
inline

Definition at line 22 of file kis_brushes_pipe.h.

22 {
23 }

◆ KisBrushesPipe() [2/2]

template<class BrushType >
KisBrushesPipe< BrushType >::KisBrushesPipe ( const KisBrushesPipe< BrushType > & rhs)
inline

Definition at line 25 of file kis_brushes_pipe.h.

25 {
26 m_brushes.clear();
27 Q_FOREACH (QSharedPointer<BrushType> brush, rhs.m_brushes) {
28 KoResourceSP clonedBrush = brush->clone();
29 QSharedPointer<BrushType> actualClonedBrush = clonedBrush.dynamicCast<BrushType>();
30 m_brushes.append(actualClonedBrush );
31 KIS_ASSERT_RECOVER(clonedBrush) {continue;}
32 }
33 }
QVector< QSharedPointer< BrushType > > m_brushes
#define KIS_ASSERT_RECOVER(cond)
Definition kis_assert.h:55

References KIS_ASSERT_RECOVER, and KisBrushesPipe< BrushType >::m_brushes.

◆ ~KisBrushesPipe()

template<class BrushType >
virtual KisBrushesPipe< BrushType >::~KisBrushesPipe ( )
inlinevirtual

Definition at line 35 of file kis_brushes_pipe.h.

35 {
36 }

Member Function Documentation

◆ addBrush()

template<class BrushType >
void KisBrushesPipe< BrushType >::addBrush ( QSharedPointer< BrushType > brush)
inlineprotected

Definition at line 168 of file kis_brushes_pipe.h.

168 {
169 m_brushes.append(brush);
170 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ brushes()

template<class BrushType >
QVector< QSharedPointer< BrushType > > KisBrushesPipe< BrushType >::brushes ( )
inline

Definition at line 151 of file kis_brushes_pipe.h.

151 {
152 return m_brushes;
153 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ chooseNextBrush()

template<class BrushType >
virtual int KisBrushesPipe< BrushType >::chooseNextBrush ( const KisPaintInformation & info)
protectedpure virtual

Returns the index of the next brush that corresponds to the current values of info. This method is called before the dab is actually painted.

Implemented in KisImageBrushesPipe, and KisTextBrushesPipe.

◆ clear()

template<class BrushType >
virtual void KisBrushesPipe< BrushType >::clear ( )
inlinevirtual

Reimplemented in KisTextBrushesPipe.

Definition at line 38 of file kis_brushes_pipe.h.

38 {
39 m_brushes.clear();
40 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ currentBrush()

template<class BrushType >
QSharedPointer< BrushType > KisBrushesPipe< BrushType >::currentBrush ( const KisPaintInformation & info)
inline

Definition at line 51 of file kis_brushes_pipe.h.

51 {
52 Q_UNUSED(info);
53 return !m_brushes.isEmpty() ? m_brushes.at(currentBrushIndex()) : 0;
54 }
virtual int currentBrushIndex()=0

References KisBrushesPipe< BrushType >::currentBrushIndex(), and KisBrushesPipe< BrushType >::m_brushes.

◆ currentBrushIndex()

template<class BrushType >
virtual int KisBrushesPipe< BrushType >::currentBrushIndex ( )
protectedpure virtual

Returns the current index of the brush This method is called before the dab is actually painted.

The method is const, so no internal counters of the brush should change during its execution

Implemented in KisImageBrushesPipe, and KisTextBrushesPipe.

◆ firstBrush()

template<class BrushType >
QSharedPointer< BrushType > KisBrushesPipe< BrushType >::firstBrush ( ) const
inline

Definition at line 42 of file kis_brushes_pipe.h.

42 {
43 return m_brushes.first();
44 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ generateMaskAndApplyMaskOrCreateDab()

template<class BrushType >
void KisBrushesPipe< BrushType >::generateMaskAndApplyMaskOrCreateDab ( KisFixedPaintDeviceSP dst,
KisBrush::ColoringInformation * coloringInformation,
KisDabShape const & shape,
const KisPaintInformation & info,
double subPixelX,
double subPixelY,
qreal softnessFactor,
qreal lightnessStrength = DEFAULT_LIGHTNESS_STRENGTH )
inline

Definition at line 120 of file kis_brushes_pipe.h.

124 {
125
127 if (!brush) return;
128
129
130 brush->generateMaskAndApplyMaskOrCreateDab(dst, coloringInformation, shape, info, subPixelX, subPixelY, softnessFactor, lightnessStrength);
131 }
QSharedPointer< BrushType > currentBrush(const KisPaintInformation &info)

References KisBrushesPipe< BrushType >::currentBrush().

◆ hasColorAndTransparency()

template<class BrushType >
bool KisBrushesPipe< BrushType >::hasColorAndTransparency ( ) const
inline

Definition at line 91 of file kis_brushes_pipe.h.

91 {
92 Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
93 if (brush->hasColorAndTransparency()) return true;
94 }
95 return false;
96 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ isImageType()

template<class BrushType >
bool KisBrushesPipe< BrushType >::isImageType ( ) const
inline

Definition at line 84 of file kis_brushes_pipe.h.

84 {
85 Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
86 if (brush->isImageType()) return true;
87 }
88 return false;
89 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ lastBrush()

template<class BrushType >
QSharedPointer< BrushType > KisBrushesPipe< BrushType >::lastBrush ( ) const
inline

Definition at line 46 of file kis_brushes_pipe.h.

46 {
47 return m_brushes.last();
48 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ maskHeight()

template<class BrushType >
qint32 KisBrushesPipe< BrushType >::maskHeight ( KisDabShape const & shape,
double subPixelX,
double subPixelY,
const KisPaintInformation & info )
inline

Definition at line 61 of file kis_brushes_pipe.h.

61 {
63 return brush ? brush->maskHeight(shape, subPixelX, subPixelY, info) : 0;
64 }

References KisBrushesPipe< BrushType >::currentBrush().

◆ maskWidth()

template<class BrushType >
qint32 KisBrushesPipe< BrushType >::maskWidth ( KisDabShape const & shape,
double subPixelX,
double subPixelY,
const KisPaintInformation & info )
inline

Definition at line 56 of file kis_brushes_pipe.h.

56 {
58 return brush ? brush->maskWidth(shape, subPixelX, subPixelY, info) : 0;
59 }

References KisBrushesPipe< BrushType >::currentBrush().

◆ notifyBrushIsGoingToBeClonedForStroke()

template<class BrushType >
void KisBrushesPipe< BrushType >::notifyBrushIsGoingToBeClonedForStroke ( )
inline

Definition at line 145 of file kis_brushes_pipe.h.

145 {
146 Q_FOREACH(QSharedPointer<BrushType> brush, m_brushes) {
147 brush->notifyBrushIsGoingToBeClonedForStroke();
148 }
149 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ notifyStrokeStarted()

template<class BrushType >
virtual void KisBrushesPipe< BrushType >::notifyStrokeStarted ( )
pure virtual

Is called by the paint op when a paintop starts a stroke. The brushes are shared among different strokes, so sometimes the brush should be reset.

Implemented in KisImageBrushesPipe, and KisTextBrushesPipe.

◆ paintDevice()

template<class BrushType >
KisFixedPaintDeviceSP KisBrushesPipe< BrushType >::paintDevice ( const KoColorSpace * colorSpace,
KisDabShape const & shape,
const KisPaintInformation & info,
double subPixelX,
double subPixelY )
inline

Definition at line 133 of file kis_brushes_pipe.h.

136 {
137
139 if (!brush) return 0;
140
141 KisFixedPaintDeviceSP device = brush->paintDevice(colorSpace, shape, info, subPixelX, subPixelY);
142 return device;
143 }

References KisBrushesPipe< BrushType >::currentBrush().

◆ prepareForSeqNo()

template<class BrushType >
void KisBrushesPipe< BrushType >::prepareForSeqNo ( const KisPaintInformation & info,
int seqNo )
inline

We first need to initialize the brush index to satisfy the current sequence number, and only after that choose the brush

Definition at line 110 of file kis_brushes_pipe.h.

110 {
116 updateBrushIndexes(info.randomSource(), seqNo);
117 chooseNextBrush(info);
118 }
virtual void updateBrushIndexes(KisRandomSourceSP randomSource, int seqNo)=0
virtual int chooseNextBrush(const KisPaintInformation &info)=0
KisRandomSourceSP randomSource() const

References KisBrushesPipe< BrushType >::chooseNextBrush(), KisPaintInformation::randomSource(), and KisBrushesPipe< BrushType >::updateBrushIndexes().

◆ setAngle()

template<class BrushType >
void KisBrushesPipe< BrushType >::setAngle ( qreal angle)
inline

Definition at line 66 of file kis_brushes_pipe.h.

66 {
67 Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
68 brush->setAngle(angle);
69 }
70 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ setBrushApplication()

template<class BrushType >
void KisBrushesPipe< BrushType >::setBrushApplication ( enumBrushApplication brushApplication) const
inline

Definition at line 98 of file kis_brushes_pipe.h.

98 {
99 Q_FOREACH(QSharedPointer<BrushType> brush, m_brushes) {
100 brush->setBrushApplication(brushApplication);
101 }
102 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ setGradient()

template<class BrushType >
void KisBrushesPipe< BrushType >::setGradient ( KoAbstractGradientSP gradient) const
inline

Definition at line 104 of file kis_brushes_pipe.h.

104 {
105 Q_FOREACH(QSharedPointer<BrushType> brush, m_brushes) {
106 brush->setGradient(gradient);
107 }
108 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ setScale()

template<class BrushType >
void KisBrushesPipe< BrushType >::setScale ( qreal scale)
inline

Definition at line 72 of file kis_brushes_pipe.h.

72 {
73 Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
74 brush->setScale(scale);
75 }
76 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ setSpacing()

template<class BrushType >
void KisBrushesPipe< BrushType >::setSpacing ( double spacing)
inline

Definition at line 78 of file kis_brushes_pipe.h.

78 {
79 Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
80 brush->setSpacing(spacing);
81 }
82 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ sizeBrush()

template<class BrushType >
int KisBrushesPipe< BrushType >::sizeBrush ( )
inlineprotected

Definition at line 172 of file kis_brushes_pipe.h.

172 {
173 return m_brushes.size();
174 }

References KisBrushesPipe< BrushType >::m_brushes.

◆ testingSelectNextBrush()

template<class BrushType >
void KisBrushesPipe< BrushType >::testingSelectNextBrush ( const KisPaintInformation & info)
inline

Definition at line 155 of file kis_brushes_pipe.h.

155 {
157 (void) chooseNextBrush(info);
158 }
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)

References KisBrushesPipe< BrushType >::chooseNextBrush(), KisPaintInformation::randomSource(), KisBrushesPipe< BrushType >::updateBrushIndexes(), and void().

◆ updateBrushIndexes()

template<class BrushType >
virtual void KisBrushesPipe< BrushType >::updateBrushIndexes ( KisRandomSourceSP randomSource,
int seqNo )
protectedpure virtual

Updates internal counters of the brush after a dab has been painted on the canvas. Some incremental switching of the brushes may me implemented in this method.

If seqNo is equal or greater than zero, then incremental iteration is overridden by this seqNo value

Implemented in KisImageBrushesPipe, and KisTextBrushesPipe.

Member Data Documentation

◆ m_brushes

template<class BrushType >
QVector<QSharedPointer<BrushType> > KisBrushesPipe< BrushType >::m_brushes
protected

Definition at line 205 of file kis_brushes_pipe.h.


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