17#ifndef QGSPAINTEFFECT_H
18#define QGSPAINTEFFECT_H
24#include <QDomDocument>
30using namespace Qt::StringLiterals;
62 if ( sipCpp->type() ==
"drawSource" &&
dynamic_cast<QgsDrawSourceEffect *
>( sipCpp ) != NULL )
64 sipType = sipType_QgsDrawSourceEffect;
66 else if ( sipCpp->type() ==
"effectStack" &&
dynamic_cast<QgsEffectStack *
>( sipCpp ) != NULL )
68 sipType = sipType_QgsEffectStack;
70 else if ( sipCpp->type() ==
"blur" &&
dynamic_cast<QgsBlurEffect *
>( sipCpp ) != NULL )
72 sipType = sipType_QgsBlurEffect;
74 else if ( sipCpp->type() ==
"dropShadow" &&
dynamic_cast<QgsDropShadowEffect *
>( sipCpp ) != NULL )
76 sipType = sipType_QgsDropShadowEffect;
78 else if ( sipCpp->type() ==
"outerGlow" &&
dynamic_cast<QgsOuterGlowEffect *
>( sipCpp ) != NULL )
80 sipType = sipType_QgsOuterGlowEffect;
82 else if ( sipCpp->type() ==
"innerGlow" &&
dynamic_cast<QgsInnerGlowEffect *
>( sipCpp ) != NULL )
84 sipType = sipType_QgsInnerGlowEffect;
86 else if ( sipCpp->type() ==
"transform" &&
dynamic_cast<QgsTransformEffect *
>( sipCpp ) != NULL )
88 sipType = sipType_QgsTransformEffect;
90 else if ( sipCpp->type() ==
"color" &&
dynamic_cast<QgsColorEffect *
>( sipCpp ) != NULL )
92 sipType = sipType_QgsColorEffect;
124 virtual QString
type()
const = 0;
165 virtual bool saveProperties( QDomDocument &doc, QDomElement &element )
const;
213 void setEnabled(
bool enabled );
229 void setDrawMode( DrawMode drawMode );
262 const QPicture &
source()
const {
return mPicture; }
295 virtual QRectF boundingRect(
const QRectF &rect,
const QgsRenderContext &context )
const;
305 Q_DECL_DEPRECATED
void fixQPictureDpi( QPainter *painter )
const SIP_DEPRECATED;
312 QPainter *mPrevPainter =
nullptr;
313 std::unique_ptr< QPainter > mEffectPainter;
314 std::unique_ptr< QPicture > mTempPicture;
350 QString
type()
const override {
return u
"drawSource"_s; }
352 QVariantMap properties() const override;
355 void readProperties( const QVariantMap &props ) override;
379 void setBlendMode(
const QPainter::CompositionMode mode ) { mBlendMode = mode; }
387 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
395 double mOpacity = 1.0;
396 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
438 QPainter *operator->() {
return mPainter; }
447 QPainter *mPainter =
nullptr;
QFlags< PaintEffectFlag > PaintEffectFlags
Flags which control how paint effects behave.
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.
void setOpacity(const double opacity)
Sets the opacity for the effect.
QString type() const override
Returns the effect type.
static QgsPaintEffect * create(const QVariantMap &map)
Creates a new QgsDrawSource effect from a properties string map.
Qgis::PaintEffectFlags flags() const override
Returns flags which specify how the paint effect behaves.
A paint effect which draws an offset and optionally blurred drop shadow.
QgsEffectPainter(QgsRenderContext &renderContext)
QgsEffectPainter constructor.
void setEffect(QgsPaintEffect *effect)
Sets the effect to be painted.
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.
bool requiresQPainterDpiFix
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
void drawSource(QPainter &painter)
Draws the source QPicture onto the specified painter.
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...
virtual void begin(QgsRenderContext &context)
Begins intercepting paint operations to a render context.
const QPicture & source() const
Returns the source QPicture.
friend class QgsEffectStack
DrawMode drawMode() const
Returns the draw mode for the effect.
virtual void end(QgsRenderContext &context)
Ends interception of paint operations to a render context, and draws the result to the render context...
bool enabled() const
Returns whether the effect is enabled.
virtual Qgis::PaintEffectFlags flags() const
Returns flags which specify how the paint effect behaves.
virtual void render(const QPicture &picture, QgsRenderContext &context)
Renders a picture using the effect.
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.
@ ModifyAndRender
The result of the effect is both rendered and passed on to subsequent 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