QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsblureffect.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsblureffect.h
3 ---------------
4 begin : December 2014
5 copyright : (C) 2014 Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSBLUREFFECT_H
18#define QGSBLUREFFECT_H
19
20#include "qgis_core.h"
21#include "qgspainteffect.h"
22#include "qgis_sip.h"
23#include "qgis.h"
24#include "qgsmapunitscale.h"
25
26#include <QPainter>
27
37{
38
39 public:
40
43 {
45 GaussianBlur
46 };
47
53 static QgsPaintEffect *create( const QVariantMap &map ) SIP_FACTORY;
54
55 QgsBlurEffect() = default;
56
57 QString type() const override { return QStringLiteral( "blur" ); }
58 QVariantMap properties() const override;
59 void readProperties( const QVariantMap &props ) override;
60 QgsBlurEffect *clone() const override SIP_FACTORY;
61
71 void setBlurLevel( const double level ) { mBlurLevel = level; }
72
82 double blurLevel() const { return mBlurLevel; }
83
92 void setBlurUnit( const Qgis::RenderUnit unit ) { mBlurUnit = unit; }
93
102 Qgis::RenderUnit blurUnit() const { return mBlurUnit; }
103
112 void setBlurMapUnitScale( const QgsMapUnitScale &scale ) { mBlurMapUnitScale = scale; }
113
122 const QgsMapUnitScale &blurMapUnitScale() const { return mBlurMapUnitScale; }
123
129 void setBlurMethod( const BlurMethod method ) { mBlurMethod = method; }
130
136 BlurMethod blurMethod() const { return mBlurMethod; }
137
144 void setOpacity( const double opacity ) { mOpacity = opacity; }
145
152 double opacity() const { return mOpacity; }
153
160 void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
161
168 QPainter::CompositionMode blendMode() const { return mBlendMode; }
169
170 protected:
171
172 void draw( QgsRenderContext &context ) override;
173 QRectF boundingRect( const QRectF &rect, const QgsRenderContext &context ) const override;
174
175 private:
176
177 double mBlurLevel = 2.645;
179 QgsMapUnitScale mBlurMapUnitScale;
180 BlurMethod mBlurMethod = StackBlur;
181 double mOpacity = 1.0;
182 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
183
184 void drawStackBlur( QgsRenderContext &context );
185 void drawGaussianBlur( QgsRenderContext &context );
186 void drawBlurredImage( QgsRenderContext &context, QImage &image );
187};
188
189#endif // QGSBLUREFFECT_H
190
RenderUnit
Rendering size units.
Definition qgis.h:4839
@ Millimeters
Millimeters.
A paint effect which blurs a source picture, using a number of different blur methods.
const QgsMapUnitScale & blurMapUnitScale() const
Returns the map unit scale used for the blur strength (radius).
void setBlurUnit(const Qgis::RenderUnit unit)
Sets the units used for the blur level (radius).
void setBlurMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the blur strength (radius).
QPainter::CompositionMode blendMode() const
Returns the blend mode for the effect.
Qgis::RenderUnit blurUnit() const
Returns the units used for the blur level (radius).
QgsBlurEffect()=default
BlurMethod
Available blur methods (algorithms)
@ StackBlur
Stack blur, a fast but low quality blur. Valid blur level values are between 0 - 16.
double opacity() const
Returns the opacity for the effect.
QString type() const override
Returns the effect type.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
BlurMethod blurMethod() const
Returns the blur method (algorithm) used for performing the blur.
double blurLevel() const
Returns the blur level (radius)
void setBlurMethod(const BlurMethod method)
Sets the blur method (algorithm) to use for performing the blur.
void setOpacity(const double opacity)
Sets the opacity for the effect.
Struct for storing maximum and minimum scales for measurements in map units.
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...
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
virtual QRectF boundingRect(const QRectF &rect, const QgsRenderContext &context) const
Returns the bounding rect required for drawing the effect.
virtual QVariantMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect's result on to the specified render context.
Contains information about the context of a rendering operation.
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_NODEFAULTCTORS
Definition qgis_sip.h:101