17#ifndef QGSPAINTEFFECT_H
18#define QGSPAINTEFFECT_H
24#include <QDomDocument>
59 if ( sipCpp->type() ==
"drawSource" &&
dynamic_cast<QgsDrawSourceEffect *
>( sipCpp ) != NULL )
61 sipType = sipType_QgsDrawSourceEffect;
63 else if ( sipCpp->type() ==
"effectStack" &&
dynamic_cast<QgsEffectStack *
>( sipCpp ) != NULL )
65 sipType = sipType_QgsEffectStack;
67 else if ( sipCpp->type() ==
"blur" &&
dynamic_cast<QgsBlurEffect *
>( sipCpp ) != NULL )
69 sipType = sipType_QgsBlurEffect;
71 else if ( sipCpp->type() ==
"dropShadow" &&
dynamic_cast<QgsDropShadowEffect *
>( sipCpp ) != NULL )
73 sipType = sipType_QgsDropShadowEffect;
75 else if ( sipCpp->type() ==
"outerGlow" &&
dynamic_cast<QgsOuterGlowEffect *
>( sipCpp ) != NULL )
77 sipType = sipType_QgsOuterGlowEffect;
79 else if ( sipCpp->type() ==
"innerGlow" &&
dynamic_cast<QgsInnerGlowEffect *
>( sipCpp ) != NULL )
81 sipType = sipType_QgsInnerGlowEffect;
83 else if ( sipCpp->type() ==
"transform" &&
dynamic_cast<QgsTransformEffect *
>( sipCpp ) != NULL )
85 sipType = sipType_QgsTransformEffect;
87 else if ( sipCpp->type() ==
"color" &&
dynamic_cast<QgsColorEffect *
>( sipCpp ) != NULL )
89 sipType = sipType_QgsColorEffect;
121 virtual QString
type()
const = 0;
162 virtual bool saveProperties( QDomDocument &doc, QDomElement &element )
const;
210 void setEnabled(
bool enabled );
226 void setDrawMode( DrawMode drawMode );
259 const QPicture &
source()
const {
return mPicture; }
292 virtual QRectF boundingRect(
const QRectF &rect,
const QgsRenderContext &context )
const;
302 Q_DECL_DEPRECATED
void fixQPictureDpi( QPainter *painter )
const SIP_DEPRECATED;
309 QPainter *mPrevPainter =
nullptr;
310 std::unique_ptr< QPainter > mEffectPainter;
311 std::unique_ptr< QPicture > mTempPicture;
347 QString
type()
const override {
return QStringLiteral(
"drawSource" ); }
349 QVariantMap properties() const override;
350 void readProperties( const QVariantMap &props ) override;
374 void setBlendMode(
const QPainter::CompositionMode mode ) { mBlendMode = mode; }
382 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
390 double mOpacity = 1.0;
391 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
433 QPainter *operator->() {
return mPainter; }
442 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