QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
A paint effect which consists of a stack of other chained paint effects. More...
#include <qgseffectstack.h>
Public Member Functions | |
QgsEffectStack () | |
QgsEffectStack (const QgsEffectStack &other) | |
QgsEffectStack (const QgsPaintEffect &effect) | |
Creates a new QgsEffectStack effect from a single initial effect. More... | |
virtual | ~QgsEffectStack () |
void | appendEffect (QgsPaintEffect *effect) |
Appends an effect to the end of the stack. More... | |
bool | changeEffect (const int index, QgsPaintEffect *effect) |
Replaces the effect at a specified position within the stack. More... | |
virtual QgsEffectStack * | clone () const override |
Duplicates an effect by creating a deep copy of the effect. More... | |
int | count () const |
Returns count of effects contained by the stack. More... | |
QgsPaintEffect * | effect (int index) const |
Returns a pointer to the effect at a specified index within the stack. More... | |
QList< QgsPaintEffect *> * | effectList () |
Returns a pointer to the list of effects currently contained by the stack. More... | |
bool | insertEffect (const int index, QgsPaintEffect *effect) |
Inserts an effect at a specified index within the stack. More... | |
QgsEffectStack & | operator= (const QgsEffectStack &rhs) |
virtual QgsStringMap | properties () const override |
Unused for QgsEffectStack, will always return an empty string map. More... | |
virtual bool | readProperties (const QDomElement &element) override |
Restores the effect to the state described by a DOM element. More... | |
virtual void | readProperties (const QgsStringMap &props) override |
Unused for QgsEffectStack, props parameter will be ignored. More... | |
virtual bool | saveProperties (QDomDocument &doc, QDomElement &element) const override |
Saves the current state of the effect to a DOM element. More... | |
QgsPaintEffect * | takeEffect (const int index) |
Removes an effect from the stack and returns a pointer to it. More... | |
virtual QString | type () const override |
Returns the effect type. More... | |
![]() | |
QgsPaintEffect () | |
QgsPaintEffect (const QgsPaintEffect &other) | |
virtual | ~QgsPaintEffect () |
virtual void | begin (QgsRenderContext &context) |
Begins intercepting paint operations to a render context. More... | |
DrawMode | drawMode () const |
Returns the draw mode for the effect. More... | |
bool | enabled () const |
Returns whether the effect is enabled. More... | |
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. More... | |
virtual void | render (QPicture &picture, QgsRenderContext &context) |
Renders a picture using the effect. More... | |
void | setDrawMode (const DrawMode drawMode) |
Sets the draw mode for the effect. More... | |
void | setEnabled (const bool enabled) |
Sets whether the effect is enabled. More... | |
Static Public Member Functions | |
static QgsPaintEffect * | create (const QgsStringMap &map) |
Creates a new QgsEffectStack effect. More... | |
Protected Member Functions | |
virtual void | draw (QgsRenderContext &context) override |
Handles drawing of the effect's result on to the specified render context. More... | |
![]() | |
virtual QRectF | boundingRect (const QRectF &rect, const QgsRenderContext &context) const |
Returns the bounding rect required for drawing the effect. More... | |
void | drawSource (QPainter &painter) |
Draws the source QPicture onto the specified painter. More... | |
void | fixQPictureDpi (QPainter *painter) const |
Applies a workaround to a QPainter to avoid an issue with incorrect scaling when drawing QPictures. More... | |
QPointF | imageOffset (const QgsRenderContext &context) const |
Returns the offset which should be used when drawing the source image on to a destination render context. More... | |
const QPicture * | source () const |
Returns the source QPicture. More... | |
QImage * | sourceAsImage (QgsRenderContext &context) |
Returns the source QPicture rendered to a new QImage. More... | |
Additional Inherited Members | |
![]() | |
enum | DrawMode { Modifier, Render, ModifyAndRender } |
Drawing modes for effects. More... | |
![]() | |
DrawMode | mDrawMode |
bool | mEnabled |
bool | requiresQPainterDpiFix |
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 41 of file qgseffectstack.h.
QgsEffectStack::QgsEffectStack | ( | ) |
Definition at line 22 of file qgseffectstack.cpp.
QgsEffectStack::QgsEffectStack | ( | const QgsEffectStack & | other | ) |
Definition at line 28 of file qgseffectstack.cpp.
|
explicit |
Creates a new QgsEffectStack effect from a single initial effect.
effect | initial effect to add to the stack. The effect will be cloned, so ownership is not transferred to the stack. |
Definition at line 38 of file qgseffectstack.cpp.
|
virtual |
Definition at line 44 of file qgseffectstack.cpp.
void QgsEffectStack::appendEffect | ( | QgsPaintEffect * | effect | ) |
Appends an effect to the end of the stack.
effect | QgsPaintEffect to append. Ownership of the effect will be transferred to the stack object. |
Definition at line 209 of file qgseffectstack.cpp.
bool QgsEffectStack::changeEffect | ( | const int | index, |
QgsPaintEffect * | effect | ||
) |
Replaces the effect at a specified position within the stack.
index | position of effect to replace |
effect | QgsPaintEffect to replace with. Ownership of the effect will be transferred to the stack object. |
Definition at line 225 of file qgseffectstack.cpp.
|
overridevirtual |
Duplicates an effect by creating a deep copy of the effect.
Implements QgsPaintEffect.
Definition at line 141 of file qgseffectstack.cpp.
|
inline |
Returns count of effects contained by the stack.
Definition at line 114 of file qgseffectstack.h.
|
static |
Creates a new QgsEffectStack effect.
This method ignores the map parameter, and always returns an empty effect stack.
map | unused encoded properties string map |
Definition at line 64 of file qgseffectstack.cpp.
|
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.
context | destination render context |
Implements QgsPaintEffect.
Definition at line 71 of file qgseffectstack.cpp.
QgsPaintEffect * QgsEffectStack::effect | ( | int | index | ) | const |
Returns a pointer to the effect at a specified index within the stack.
index | position of effect to return |
Definition at line 250 of file qgseffectstack.cpp.
QList< QgsPaintEffect * > * QgsEffectStack::effectList | ( | ) |
Returns a pointer to the list of effects currently contained by the stack.
Definition at line 245 of file qgseffectstack.cpp.
bool QgsEffectStack::insertEffect | ( | const int | index, |
QgsPaintEffect * | effect | ||
) |
Inserts an effect at a specified index within the stack.
index | position to insert the effect |
effect | QgsPaintEffect to insert. Ownership of the effect will be transferred to the stack object. |
Definition at line 214 of file qgseffectstack.cpp.
QgsEffectStack & QgsEffectStack::operator= | ( | const QgsEffectStack & | rhs | ) |
Definition at line 49 of file qgseffectstack.cpp.
|
overridevirtual |
Unused for QgsEffectStack, will always return an empty string map.
Implements QgsPaintEffect.
Definition at line 192 of file qgseffectstack.cpp.
|
overridevirtual |
Restores the effect to the state described by a DOM element.
element | DOM element describing an effect's state |
Reimplemented from QgsPaintEffect.
Definition at line 169 of file qgseffectstack.cpp.
|
overridevirtual |
Unused for QgsEffectStack, props parameter will be ignored.
Implements QgsPaintEffect.
Definition at line 198 of file qgseffectstack.cpp.
|
overridevirtual |
Saves the current state of the effect to a DOM element.
The default behaviour is to save the properties string map returned by properties.
doc | destination DOM document |
element | destination DOM element |
Reimplemented from QgsPaintEffect.
Definition at line 146 of file qgseffectstack.cpp.
QgsPaintEffect * QgsEffectStack::takeEffect | ( | const int | index | ) |
Removes an effect from the stack and returns a pointer to it.
index | position of effect to take |
Definition at line 237 of file qgseffectstack.cpp.
|
inlineoverridevirtual |
Returns the effect type.
Implements QgsPaintEffect.
Definition at line 65 of file qgseffectstack.h.