QgsEffectStack class
A paint effect which consists of a stack of other chained paint effects.
Contents
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.
Base classes
- class QgsPaintEffect
- Base class for visual effects which can be applied to QPicture drawings.
Public static functions
- static auto create(const QgsStringMap& map) -> QgsPaintEffect*
- Creates a new QgsEffectStack effect.
Constructors, destructors, conversion operators
- QgsEffectStack() defaulted
- Constructor for empty QgsEffectStack.
- QgsEffectStack(const QgsPaintEffect& effect) explicit
- Creates a new QgsEffectStack effect from a single initial effect.
Public functions
- void appendEffect(QgsPaintEffect* effect)
- Appends an effect to the end of the stack.
- auto changeEffect(int index, QgsPaintEffect* effect) -> bool
- Replaces the effect at a specified position within the stack.
- auto clone() const -> QgsEffectStack* override
- Duplicates an effect by creating a deep copy of the effect.
- auto count() const -> int
- Returns count of effects contained by the stack.
- auto effect(int index) const -> QgsPaintEffect*
- Returns a pointer to the effect at a specified index within the stack.
- auto effectList() -> QList<QgsPaintEffect*>*
- Returns a pointer to the list of effects currently contained by the stack.
- auto insertEffect(int index, QgsPaintEffect* effect) -> bool
- Inserts an effect at a specified index within the stack.
- auto properties() const -> QgsStringMap override
- Unused for QgsEffectStack, will always return an empty string map.
- auto readProperties(const QDomElement& element) -> bool override
- Restores the effect to the state described by a DOM element.
- void readProperties(const QgsStringMap& props) override
- Unused for QgsEffectStack, props parameter will be ignored.
- auto saveProperties(QDomDocument& doc, QDomElement& element) const -> bool override
- Saves the current state of the effect to a DOM element.
- auto takeEffect(int index) -> QgsPaintEffect*
- Removes an effect from the stack and returns a pointer to it.
- auto type() const -> QString override
- Returns the effect type.
Protected functions
- void draw(QgsRenderContext& context) override
- Handles drawing of the effect's result on to the specified render context.
Function documentation
static QgsPaintEffect* QgsEffectStack:: create(const QgsStringMap& map)
Creates a new QgsEffectStack effect.
| Parameters | |
|---|---|
| map | unused encoded properties string map |
| Returns | new QgsEffectStack |
This method ignores the map parameter, and always returns an empty effect stack.
QgsEffectStack:: QgsEffectStack(const QgsPaintEffect& effect) explicit
Creates a new QgsEffectStack effect from a single initial effect.
| Parameters | |
|---|---|
| effect | initial effect to add to the stack. The effect will be cloned, so ownership is not transferred to the stack. |
| Returns | new QgsEffectStack containing initial effect |
void QgsEffectStack:: appendEffect(QgsPaintEffect* effect)
Appends an effect to the end of the stack.
| Parameters | |
|---|---|
| effect | QgsPaintEffect to append. Ownership of the effect will be transferred to the stack object. |
bool QgsEffectStack:: changeEffect(int index,
QgsPaintEffect* effect)
Replaces the effect at a specified position within the stack.
| Parameters | |
|---|---|
| index | position of effect to replace |
| effect | QgsPaintEffect to replace with. Ownership of the effect will be transferred to the stack object. |
QgsEffectStack* QgsEffectStack:: clone() const override
Duplicates an effect by creating a deep copy of the effect.
| Returns | clone of paint effect |
|---|
int QgsEffectStack:: count() const
Returns count of effects contained by the stack.
| Returns | count of effects |
|---|
QgsPaintEffect* QgsEffectStack:: effect(int index) const
Returns a pointer to the effect at a specified index within the stack.
| Parameters | |
|---|---|
| index | position of effect to return |
| Returns | QgsPaintEffect at specified position |
QList<QgsPaintEffect*>* QgsEffectStack:: effectList()
Returns a pointer to the list of effects currently contained by the stack.
| Returns | list of QgsPaintEffects within the stack |
|---|
bool QgsEffectStack:: insertEffect(int index,
QgsPaintEffect* effect)
Inserts an effect at a specified index within the stack.
| Parameters | |
|---|---|
| index | position to insert the effect |
| effect | QgsPaintEffect to insert. Ownership of the effect will be transferred to the stack object. |
bool QgsEffectStack:: readProperties(const QDomElement& element) override
Restores the effect to the state described by a DOM element.
| Parameters | |
|---|---|
| element | DOM element describing an effect's state |
| Returns | true if read was successful |
bool QgsEffectStack:: saveProperties(QDomDocument& doc,
QDomElement& element) const override
Saves the current state of the effect to a DOM element.
| Parameters | |
|---|---|
| doc | destination DOM document |
| element | destination DOM element |
| Returns | true if save was successful |
The default behavior is to save the properties string map returned by properties().
QgsPaintEffect* QgsEffectStack:: takeEffect(int index)
Removes an effect from the stack and returns a pointer to it.
| Parameters | |
|---|---|
| index | position of effect to take |
QString QgsEffectStack:: type() const override
Returns the effect type.
| Returns | unique string representation of the effect type |
|---|
void QgsEffectStack:: draw(QgsRenderContext& context) override protected
Handles drawing of the effect's result on to the specified render context.
| Parameters | |
|---|---|
| context | destination 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.