QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsEffectStack Class Reference

A paint effect which consists of a stack of other chained paint effects. More...

#include <qgseffectstack.h>

Inheritance diagram for QgsEffectStack:
Inheritance graph
[legend]

Public Member Functions

 QgsEffectStack ()=default
 
 QgsEffectStack (const QgsEffectStack &other)
 
 QgsEffectStack (const QgsPaintEffect &effect)
 Creates a new QgsEffectStack effect from a single initial effect.
 
 QgsEffectStack (QgsEffectStack &&other)
 Move constructor.
 
 ~QgsEffectStack () override
 
void appendEffect (QgsPaintEffect *effect)
 Appends an effect to the end of the stack.
 
bool changeEffect (int index, QgsPaintEffect *effect)
 Replaces the effect at a specified position within the stack.
 
QgsEffectStackclone () const override
 Duplicates an effect by creating a deep copy of the effect.
 
int count () const
 Returns count of effects contained by the stack.
 
QgsPaintEffecteffect (int index) const
 Returns a pointer to the effect at a specified index within the stack.
 
QList< QgsPaintEffect * > * effectList ()
 Returns a pointer to the list of effects currently contained by the stack.
 
bool insertEffect (int index, QgsPaintEffect *effect)
 Inserts an effect at a specified index within the stack.
 
QgsEffectStackoperator= (const QgsEffectStack &rhs)
 
QgsEffectStackoperator= (QgsEffectStack &&other)
 
QVariantMap properties () const override
 Unused for QgsEffectStack, will always return an empty string map.
 
bool readProperties (const QDomElement &element) override
 Restores the effect to the state described by a DOM element.
 
void readProperties (const QVariantMap &props) override
 Unused for QgsEffectStack, props parameter will be ignored.
 
bool saveProperties (QDomDocument &doc, QDomElement &element) const override
 Saves the current state of the effect to a DOM element.
 
QgsPaintEffecttakeEffect (int index)
 Removes an effect from the stack and returns a pointer to it.
 
QString type () const override
 Returns the effect type.
 
- Public Member Functions inherited from QgsPaintEffect
 QgsPaintEffect ()=default
 
 QgsPaintEffect (const QgsPaintEffect &other)
 
virtual ~QgsPaintEffect ()
 
virtual void begin (QgsRenderContext &context)
 Begins intercepting paint operations to a render context.
 
DrawMode drawMode () const
 Returns the draw mode for the effect.
 
bool enabled () const
 Returns whether the effect is enabled.
 
virtual void end (QgsRenderContext &context)
 Ends interception of paint operations to a render context, and draws the result to the render context after being modified by the effect.
 
virtual void render (QPicture &picture, QgsRenderContext &context)
 Renders a picture using the effect.
 
void setDrawMode (DrawMode drawMode)
 Sets the draw mode for the effect.
 
void setEnabled (bool enabled)
 Sets whether the effect is enabled.
 

Static Public Member Functions

static QgsPaintEffectcreate (const QVariantMap &map)
 Creates a new QgsEffectStack effect.
 

Protected Member Functions

void draw (QgsRenderContext &context) override
 Handles drawing of the effect's result on to the specified render context.
 
- Protected Member Functions inherited from QgsPaintEffect
virtual QRectF boundingRect (const QRectF &rect, const QgsRenderContext &context) const
 Returns the bounding rect required for drawing the effect.
 
void drawSource (QPainter &painter)
 Draws the source QPicture onto the specified painter.
 
Q_DECL_DEPRECATED void fixQPictureDpi (QPainter *painter) const
 Applies a workaround to a QPainter to avoid an issue with incorrect scaling when drawing QPictures.
 
QPointF imageOffset (const QgsRenderContext &context) const
 Returns the offset which should be used when drawing the source image on to a destination render context.
 
const QPicture * source () const
 Returns the source QPicture.
 
QImage * sourceAsImage (QgsRenderContext &context)
 Returns the source QPicture rendered to a new QImage.
 

Additional Inherited Members

- Public Types inherited from QgsPaintEffect
enum  DrawMode { Modifier , Render , ModifyAndRender }
 Drawing modes for effects. More...
 
- Protected Attributes inherited from QgsPaintEffect
DrawMode mDrawMode = ModifyAndRender
 
bool mEnabled = true
 
bool requiresQPainterDpiFix = true
 

Detailed Description

A paint effect which consists of a stack of other chained paint effects.

Effect stacks can be used to apply multiple paint effects to a QPicture. For instance, an effect stack may blur then apply a drop shadow.

The way in which effects apply to a stack is controlled by the effect's drawMode. Effects can either render their results onto the destination paint device, or just modify the source picture which is drawn by subsequent effects in the stack. For instance, a blur effect with a Modifier drawMode will blur the source picture for the following drop shadow effect without actually drawing the blurred picture to the paint device. If the blur effect had a Render drawMode then the blurred picture will be drawn on the paint device, but the following drop shadow effect will be drawn using the original picture, not the blurred version.

Definition at line 43 of file qgseffectstack.h.

Constructor & Destructor Documentation

◆ QgsEffectStack() [1/4]

QgsEffectStack::QgsEffectStack ( )
default

◆ QgsEffectStack() [2/4]

QgsEffectStack::QgsEffectStack ( const QgsEffectStack other)

Definition at line 25 of file qgseffectstack.cpp.

◆ QgsEffectStack() [3/4]

QgsEffectStack::QgsEffectStack ( QgsEffectStack &&  other)

Move constructor.

Definition at line 35 of file qgseffectstack.cpp.

◆ QgsEffectStack() [4/4]

QgsEffectStack::QgsEffectStack ( const QgsPaintEffect effect)
explicit

Creates a new QgsEffectStack effect from a single initial effect.

Parameters
effectinitial effect to add to the stack. The effect will be cloned, so ownership is not transferred to the stack.

Definition at line 41 of file qgseffectstack.cpp.

◆ ~QgsEffectStack()

QgsEffectStack::~QgsEffectStack ( )
override

Definition at line 46 of file qgseffectstack.cpp.

Member Function Documentation

◆ appendEffect()

void QgsEffectStack::appendEffect ( QgsPaintEffect effect)

Appends an effect to the end of the stack.

Parameters
effectQgsPaintEffect to append. Ownership of the effect will be transferred to the stack object.
See also
insertEffect

Definition at line 214 of file qgseffectstack.cpp.

◆ changeEffect()

bool QgsEffectStack::changeEffect ( int  index,
QgsPaintEffect effect 
)

Replaces the effect at a specified position within the stack.

Parameters
indexposition of effect to replace
effectQgsPaintEffect to replace with. Ownership of the effect will be transferred to the stack object.

Definition at line 230 of file qgseffectstack.cpp.

◆ clone()

QgsEffectStack * QgsEffectStack::clone ( ) const
overridevirtual

Duplicates an effect by creating a deep copy of the effect.

Returns
clone of paint effect

Implements QgsPaintEffect.

Definition at line 146 of file qgseffectstack.cpp.

◆ count()

int QgsEffectStack::count ( ) const
inline

Returns count of effects contained by the stack.

Returns
count of effects

Definition at line 131 of file qgseffectstack.h.

◆ create()

QgsPaintEffect * QgsEffectStack::create ( const QVariantMap &  map)
static

Creates a new QgsEffectStack effect.

This method ignores the map parameter, and always returns an empty effect stack.

Parameters
mapunused encoded properties string map
Returns
new QgsEffectStack

Definition at line 73 of file qgseffectstack.cpp.

◆ draw()

void QgsEffectStack::draw ( QgsRenderContext context)
overrideprotectedvirtual

Handles drawing of the effect's result on to the specified render context.

Derived classes must reimplement this method to apply any transformations to the source QPicture and draw the result using the context's painter.

Parameters
contextdestination render context
See also
drawSource

Implements QgsPaintEffect.

Definition at line 80 of file qgseffectstack.cpp.

◆ effect()

QgsPaintEffect * QgsEffectStack::effect ( int  index) const

Returns a pointer to the effect at a specified index within the stack.

Parameters
indexposition of effect to return
Returns
QgsPaintEffect at specified position

Definition at line 255 of file qgseffectstack.cpp.

◆ effectList()

QList< QgsPaintEffect * > * QgsEffectStack::effectList ( )

Returns a pointer to the list of effects currently contained by the stack.

Returns
list of QgsPaintEffects within the stack

Definition at line 250 of file qgseffectstack.cpp.

◆ insertEffect()

bool QgsEffectStack::insertEffect ( int  index,
QgsPaintEffect effect 
)

Inserts an effect at a specified index within the stack.

Parameters
indexposition to insert the effect
effectQgsPaintEffect to insert. Ownership of the effect will be transferred to the stack object.
See also
appendEffect

Definition at line 219 of file qgseffectstack.cpp.

◆ operator=() [1/2]

QgsEffectStack & QgsEffectStack::operator= ( const QgsEffectStack rhs)

Definition at line 51 of file qgseffectstack.cpp.

◆ operator=() [2/2]

QgsEffectStack & QgsEffectStack::operator= ( QgsEffectStack &&  other)

Definition at line 66 of file qgseffectstack.cpp.

◆ properties()

QVariantMap QgsEffectStack::properties ( ) const
overridevirtual

Unused for QgsEffectStack, will always return an empty string map.

Implements QgsPaintEffect.

Definition at line 197 of file qgseffectstack.cpp.

◆ readProperties() [1/2]

bool QgsEffectStack::readProperties ( const QDomElement &  element)
overridevirtual

Restores the effect to the state described by a DOM element.

Parameters
elementDOM element describing an effect's state
Returns
true if read was successful
See also
saveProperties

Reimplemented from QgsPaintEffect.

Definition at line 174 of file qgseffectstack.cpp.

◆ readProperties() [2/2]

void QgsEffectStack::readProperties ( const QVariantMap &  props)
overridevirtual

Unused for QgsEffectStack, props parameter will be ignored.

Implements QgsPaintEffect.

Definition at line 203 of file qgseffectstack.cpp.

◆ saveProperties()

bool QgsEffectStack::saveProperties ( QDomDocument &  doc,
QDomElement &  element 
) const
overridevirtual

Saves the current state of the effect to a DOM element.

The default behavior is to save the properties string map returned by properties().

Parameters
docdestination DOM document
elementdestination DOM element
Returns
true if save was successful
See also
readProperties

Reimplemented from QgsPaintEffect.

Definition at line 151 of file qgseffectstack.cpp.

◆ takeEffect()

QgsPaintEffect * QgsEffectStack::takeEffect ( int  index)

Removes an effect from the stack and returns a pointer to it.

Parameters
indexposition of effect to take

Definition at line 242 of file qgseffectstack.cpp.

◆ type()

QString QgsEffectStack::type ( ) const
inlineoverridevirtual

Returns the effect type.

Returns
unique string representation of the effect type

Implements QgsPaintEffect.

Definition at line 74 of file qgseffectstack.h.


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