28 , mDrawMode( ModifyAndRender )
29 , requiresQPainterDpiFix( true )
31 , mSourceImage( nullptr )
33 , mPrevPainter( nullptr )
34 , mEffectPainter( nullptr )
35 , mTempPicture( nullptr )
45 , mSourceImage( nullptr )
47 , mPrevPainter( nullptr )
48 , mEffectPainter( nullptr )
49 , mTempPicture( nullptr )
60 delete mEffectPainter;
118 props[propKey] = propValue;
132 mSourceImage =
nullptr;
140 mPrevPainter = context.
painter();
145 delete mEffectPainter;
147 mEffectPainter->
begin( mTempPicture );
154 if ( !mEffectPainter )
157 mEffectPainter->
end();
158 delete mEffectPainter;
159 mEffectPainter =
nullptr;
163 mPrevPainter =
nullptr;
171 render( *mTempPicture, context );
175 mTempPicture =
nullptr;
206 QRectF bounds = imageBoundingRect( context );
207 mSourceImage =
new QImage( bounds.
width(), bounds.
height(), QImage::Format_ARGB32 );
208 mSourceImage->
fill( Qt::transparent );
209 QPainter imagePainter( mSourceImage );
220 return imageBoundingRect( context ).
topLeft();
251 , mTransparency( 0.0 )
252 , mBlendMode(
QPainter::CompositionMode_SourceOver )
276 if ( mBlendMode == QPainter::CompositionMode_SourceOver &&
qgsDoubleNear( mTransparency, 0.0 ) )
311 QPainter::CompositionMode mode =
static_cast< QPainter::CompositionMode
>( props.
value(
"blend_mode" ).toInt( &ok ) );
void setEnabled(const bool enabled)
Sets whether the effect is enabled.
virtual QgsStringMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
QRect boundingRect() const
void setCompositionMode(CompositionMode mode)
static void multiplyOpacity(QImage &image, const double factor)
Multiplies opacity of image pixel values by a factor.
void setRenderHint(RenderHint hint, bool on)
QDomNode appendChild(const QDomNode &newChild)
QString attribute(const QString &name, const QString &defValue) const
void fixQPictureDpi(QPainter *painter) const
Applies a workaround to a QPainter to avoid an issue with incorrect scaling when drawing QPictures...
void scale(qreal sx, qreal sy)
Base class for visual effects which can be applied to QPicture drawings.
void setDrawMode(const DrawMode drawMode)
Sets the draw mode for the effect.
QDomElement nextSiblingElement(const QString &tagName) const
Q_GUI_EXPORT int qt_defaultDpiX()
DrawMode drawMode() const
Returns the draw mode for the effect.
virtual ~QgsDrawSourceEffect()
QImage copy(const QRect &rectangle) const
double transparency() const
Returns the transparency for the effect.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
QImage * sourceAsImage(QgsRenderContext &context)
Returns the source QPicture rendered to a new QImage.
QPointF imageOffset(const QgsRenderContext &context) const
Returns the offset which should be used when drawing the source image on to a destination render cont...
static QgsPaintEffect * create(const QgsStringMap &map)
Creates a new QgsDrawSource effect from a properties string map.
QString number(int n, int base)
virtual QgsDrawSourceEffect * clone() const override
Duplicates an effect by creating a deep copy of the effect.
void fill(uint pixelValue)
virtual QString type() const =0
Returns the effect type.
virtual QgsStringMap properties() const override
Returns the properties describing the paint effect encoded in a string format.
void setPen(const QColor &color)
void setAttribute(const QString &name, const QString &value)
virtual ~QgsPaintEffect()
QPaintDevice * device() const
void setBrush(const QBrush &brush)
void setPainter(QPainter *p)
Q_GUI_EXPORT int qt_defaultDpiY()
bool enabled() const
Returns whether the effect is enabled.
virtual 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 pr...
bool requiresQPainterDpiFix
DrawMode
Drawing modes for effects.
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.
virtual QRectF boundingRect(const QRectF &rect, const QgsRenderContext &context) const
Returns the bounding rect required for drawing the effect.
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
void drawSource(QPainter &painter)
Draws the source QPicture onto the specified painter.
QDomElement firstChildElement(const QString &tagName) const
void translate(const QPointF &offset)
iterator insert(const Key &key, const T &value)
virtual void render(QPicture &picture, QgsRenderContext &context)
Renders a picture using the effect.
void drawPicture(const QPointF &point, const QPicture &picture)
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect's result on to the specified render context.
QDomElement createElement(const QString &tagName)
virtual void draw(QgsRenderContext &context) override
Handles drawing of the effect's result on to the specified render context.
A paint effect which draws the source picture with minor or no alterations.
bool begin(QPaintDevice *device)
virtual void end(QgsRenderContext &context)
Ends interception of paint operations to a render context, and draws the result to the render context...
virtual void begin(QgsRenderContext &context)
Begins intercepting paint operations to a render context.
const T value(const Key &key) const
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.