QgsDrawSourceEffect class
A paint effect which draws the source picture with minor or no alterations.
Contents
The draw source effect can be used to draw an unaltered copy of the original source picture. Minor changes like lowering the opacity and applying a blend mode are supported, however these changes will force the resultant output to be rasterized. If no alterations are performed then the original picture will be rendered as a vector.
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 QgsDrawSource effect from a properties string map.
Constructors, destructors, conversion operators
- QgsDrawSourceEffect() defaulted
- Constructor for QgsDrawSourceEffect.
Public functions
- auto blendMode() const -> QPainter::CompositionMode
- Returns the blend mode for the effect.
- auto clone() const -> QgsDrawSourceEffect* override
- Duplicates an effect by creating a deep copy of the effect.
- auto opacity() const -> double
- Returns the opacity for the effect.
- auto properties() const -> QgsStringMap override
- Returns the properties describing the paint effect encoded in a string format.
- void readProperties(const QgsStringMap& props) override
- Reads a string map of an effect's properties and restores the effect to the state described by the properties map.
- void setBlendMode(const QPainter::CompositionMode mode)
- Sets the blend mode for the effect.
- void setOpacity(const double opacity)
- Sets the opacity for the effect.
- 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* QgsDrawSourceEffect:: create(const QgsStringMap& map)
Creates a new QgsDrawSource effect from a properties string map.
| Parameters | |
|---|---|
| map | encoded properties string map |
| Returns | new QgsDrawSourceEffect |
QPainter::CompositionMode QgsDrawSourceEffect:: blendMode() const
Returns the blend mode for the effect.
| Returns | blend mode used for drawing the source on to a destination paint device |
|---|
QgsDrawSourceEffect* QgsDrawSourceEffect:: clone() const override
Duplicates an effect by creating a deep copy of the effect.
| Returns | clone of paint effect |
|---|
double QgsDrawSourceEffect:: opacity() const
Returns the opacity for the effect.
| Returns | opacity value between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque |
|---|
QgsStringMap QgsDrawSourceEffect:: properties() const override
Returns the properties describing the paint effect encoded in a string format.
| Returns | string map of properties, in the form property key, value |
|---|
void QgsDrawSourceEffect:: readProperties(const QgsStringMap& props) override
Reads a string map of an effect's properties and restores the effect to the state described by the properties map.
| Parameters | |
|---|---|
| props | effect properties encoded in a string map |
void QgsDrawSourceEffect:: setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
| Parameters | |
|---|---|
| mode | blend mode used for drawing the source on to a destination paint device |
void QgsDrawSourceEffect:: setOpacity(const double opacity)
Sets the opacity for the effect.
| Parameters | |
|---|---|
| opacity | double between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque |
QString QgsDrawSourceEffect:: type() const override
Returns the effect type.
| Returns | unique string representation of the effect type |
|---|
void QgsDrawSourceEffect:: 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.