17 #ifndef QGSPAINTEFFECT_H 18 #define QGSPAINTEFFECT_H 20 #include "qgis_core.h" 23 #include <QDomDocument> 24 #include <QDomElement> 57 if ( sipCpp->type() ==
"drawSource" &&
dynamic_cast<QgsDrawSourceEffect *
>( sipCpp ) != NULL )
59 sipType = sipType_QgsDrawSourceEffect;
61 else if ( sipCpp->type() ==
"effectStack" &&
dynamic_cast<QgsEffectStack *
>( sipCpp ) != NULL )
63 sipType = sipType_QgsEffectStack;
65 else if ( sipCpp->type() ==
"blur" &&
dynamic_cast<QgsBlurEffect *
>( sipCpp ) != NULL )
67 sipType = sipType_QgsBlurEffect;
69 else if ( sipCpp->type() ==
"dropShadow" &&
dynamic_cast<QgsDropShadowEffect *
>( sipCpp ) != NULL )
71 sipType = sipType_QgsDropShadowEffect;
73 else if ( sipCpp->type() ==
"outerGlow" &&
dynamic_cast<QgsOuterGlowEffect *
>( sipCpp ) != NULL )
75 sipType = sipType_QgsOuterGlowEffect;
77 else if ( sipCpp->type() ==
"innerGlow" &&
dynamic_cast<QgsInnerGlowEffect *
>( sipCpp ) != NULL )
79 sipType = sipType_QgsInnerGlowEffect;
81 else if ( sipCpp->type() ==
"transform" &&
dynamic_cast<QgsTransformEffect *
>( sipCpp ) != NULL )
83 sipType = sipType_QgsTransformEffect;
85 else if ( sipCpp->type() ==
"color" &&
dynamic_cast<QgsColorEffect *
>( sipCpp ) != NULL )
87 sipType = sipType_QgsColorEffect;
122 virtual QString type()
const = 0;
145 virtual void readProperties(
const QgsStringMap &props ) = 0;
156 virtual bool saveProperties( QDomDocument &doc, QDomElement &element )
const;
164 virtual bool readProperties(
const QDomElement &element );
204 void setEnabled(
bool enabled );
220 void setDrawMode(
DrawMode drawMode );
224 bool mEnabled =
true;
226 bool requiresQPainterDpiFix =
true;
244 void drawSource( QPainter &painter );
253 const QPicture *
source()
const {
return mPicture; }
286 virtual QRectF boundingRect(
const QRectF &rect,
const QgsRenderContext &context )
const;
294 void fixQPictureDpi( QPainter *painter )
const;
298 const QPicture *mPicture =
nullptr;
299 QImage *mSourceImage =
nullptr;
300 bool mOwnsImage =
false;
302 QPainter *mPrevPainter =
nullptr;
303 QPainter *mEffectPainter =
nullptr;
304 QPicture *mTempPicture =
nullptr;
339 QString
type()
const override {
return QStringLiteral(
"drawSource" ); }
350 void setOpacity(
const double opacity ) { mOpacity = opacity; }
366 void setBlendMode(
const QPainter::CompositionMode mode ) { mBlendMode = mode; }
374 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
382 double mOpacity = 1.0;
383 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
429 QPainter *operator->() {
return mPainter; }
434 QPainter *mPainter =
nullptr;
438 #endif // QGSPAINTEFFECT_H void setOpacity(const double opacity)
Sets the opacity for the effect.
virtual QgsStringMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
The result of the effect is rendered on the destination, but does not affect subsequent effects in th...
DrawMode drawMode() const
Returns the draw mode for the effect.
bool enabled() const
Returns whether the effect is enabled.
Base class for visual effects which can be applied to QPicture drawings.
QMap< QString, QString > QgsStringMap
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
A paint effect which consists of a stack of other chained paint effects.
The result of the effect is not rendered, but is passed on to following effects in the stack...
A paint effect which draws an offset and optionally blurred drop shadow.
A paint effect which blurs a source picture, using a number of different blur methods.
A paint effect which draws a glow outside of a picture.
DrawMode
Drawing modes for effects.
double opacity() const
Returns the opacity for the effect.
virtual void readProperties(const QgsStringMap &props)=0
Reads a string map of an effect's properties and restores the effect to the state described by the pr...
Contains information about the context of a rendering operation.
QString type() const override
Returns the effect type.
A paint effect which alters the colors (e.g., brightness, contrast) in a source picture.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
const QPicture * source() const
Returns the source QPicture.
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect's result on to the specified render context.
A paint effect which draws a glow within a 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.
A class to manager painter saving and restoring required for effect drawing.