17#ifndef QGSPAINTEFFECT_H
18#define QGSPAINTEFFECT_H
23#include <QDomDocument>
56 if ( sipCpp->type() ==
"drawSource" &&
dynamic_cast<QgsDrawSourceEffect *
>( sipCpp ) != NULL )
58 sipType = sipType_QgsDrawSourceEffect;
60 else if ( sipCpp->type() ==
"effectStack" &&
dynamic_cast<QgsEffectStack *
>( sipCpp ) != NULL )
62 sipType = sipType_QgsEffectStack;
64 else if ( sipCpp->type() ==
"blur" &&
dynamic_cast<QgsBlurEffect *
>( sipCpp ) != NULL )
66 sipType = sipType_QgsBlurEffect;
68 else if ( sipCpp->type() ==
"dropShadow" &&
dynamic_cast<QgsDropShadowEffect *
>( sipCpp ) != NULL )
70 sipType = sipType_QgsDropShadowEffect;
72 else if ( sipCpp->type() ==
"outerGlow" &&
dynamic_cast<QgsOuterGlowEffect *
>( sipCpp ) != NULL )
74 sipType = sipType_QgsOuterGlowEffect;
76 else if ( sipCpp->type() ==
"innerGlow" &&
dynamic_cast<QgsInnerGlowEffect *
>( sipCpp ) != NULL )
78 sipType = sipType_QgsInnerGlowEffect;
80 else if ( sipCpp->type() ==
"transform" &&
dynamic_cast<QgsTransformEffect *
>( sipCpp ) != NULL )
82 sipType = sipType_QgsTransformEffect;
84 else if ( sipCpp->type() ==
"color" &&
dynamic_cast<QgsColorEffect *
>( sipCpp ) != NULL )
86 sipType = sipType_QgsColorEffect;
118 virtual QString
type()
const = 0;
152 virtual bool saveProperties( QDomDocument &doc, QDomElement &element )
const;
160 virtual bool readProperties(
const QDomElement &element );
200 void setEnabled(
bool enabled );
216 void setDrawMode( DrawMode drawMode );
220 bool mEnabled =
true;
222 bool requiresQPainterDpiFix =
true;
240 void drawSource( QPainter &painter );
249 const QPicture *
source()
const {
return mPicture; }
282 virtual QRectF boundingRect(
const QRectF &rect,
const QgsRenderContext &context )
const;
292 Q_DECL_DEPRECATED
void fixQPictureDpi( QPainter *painter )
const SIP_DEPRECATED;
296 const QPicture *mPicture =
nullptr;
297 QImage *mSourceImage =
nullptr;
298 bool mOwnsImage =
false;
300 QPainter *mPrevPainter =
nullptr;
301 QPainter *mEffectPainter =
nullptr;
302 QPicture *mTempPicture =
nullptr;
337 QString
type()
const override {
return QStringLiteral(
"drawSource" ); }
339 QVariantMap properties() const override;
340 void readProperties( const QVariantMap &props ) override;
348 void setOpacity( const
double opacity ) { mOpacity = opacity; }
364 void setBlendMode(
const QPainter::CompositionMode mode ) { mBlendMode = mode; }
372 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
380 double mOpacity = 1.0;
381 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
423 QPainter *operator->() {
return mPainter; }
432 QPainter *mPainter =
nullptr;
A paint effect which blurs a source picture, using a number of different blur methods.
A paint effect which alters the colors (e.g., brightness, contrast) in a source picture.
A paint effect which draws the source picture with minor or no alterations.
QPainter::CompositionMode blendMode() const
Returns the blend mode for the effect.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
QgsDrawSourceEffect()=default
double opacity() const
Returns the opacity for the effect.
QString type() const override
Returns the effect type.
A paint effect which draws an offset and optionally blurred drop shadow.
A class to manager painter saving and restoring required for effect drawing.
A paint effect which consists of a stack of other chained paint effects.
A paint effect which draws a glow within a picture.
A paint effect which draws a glow outside of a picture.
Base class for visual effects which can be applied to QPicture drawings.
virtual void readProperties(const QVariantMap &props)=0
Reads a string map of an effect's properties and restores the effect to the state described by the pr...
DrawMode drawMode() const
Returns the draw mode for the effect.
const QPicture * source() const
Returns the source QPicture.
bool enabled() const
Returns whether the effect is enabled.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
virtual QVariantMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
DrawMode
Drawing modes for effects.
@ Render
The result of the effect is rendered on the destination, but does not affect subsequent effects in th...
@ Modifier
The result of the effect is not rendered, but is passed on to following effects in the stack.
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect's result on to the specified render context.
virtual QString type() const =0
Returns the effect type.
Contains information about the context of a rendering operation.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_NODEFAULTCTORS