QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgsgloweffect.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgloweffect.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 QGSGLOWEFFECT_H
18#define QGSGLOWEFFECT_H
19
20#include "qgis_core.h"
21#include "qgis.h"
22#include "qgspainteffect.h"
23#include "qgscolorramp.h"
24#include "qgsmapunitscale.h"
25
26#include <QPainter>
27
28
37class CORE_EXPORT QgsGlowEffect : public QgsPaintEffect
38{
39
40 public:
41
44 {
46 ColorRamp
47 };
48
50 QgsGlowEffect( const QgsGlowEffect &other );
51 ~QgsGlowEffect() override;
52
53 QVariantMap properties() const override;
54 void readProperties( const QVariantMap &props ) override;
55
63 void setSpread( const double spread ) { mSpread = spread; }
64
72 double spread() const { return mSpread; }
73
81 void setSpreadUnit( const Qgis::RenderUnit unit ) { mSpreadUnit = unit; }
82
90 Qgis::RenderUnit spreadUnit() const { return mSpreadUnit; }
91
99 void setSpreadMapUnitScale( const QgsMapUnitScale &scale ) { mSpreadMapUnitScale = scale; }
100
108 const QgsMapUnitScale &spreadMapUnitScale() const { return mSpreadMapUnitScale; }
109
118 void setBlurLevel( const double level ) { mBlurLevel = level; }
119
127 double blurLevel() const { return mBlurLevel; }
128
137 void setBlurUnit( const Qgis::RenderUnit unit ) { mBlurUnit = unit; }
138
147 Qgis::RenderUnit blurUnit() const { return mBlurUnit; }
148
157 void setBlurMapUnitScale( const QgsMapUnitScale &scale ) { mBlurMapUnitScale = scale; }
158
167 const QgsMapUnitScale &blurMapUnitScale() const { return mBlurMapUnitScale; }
168
175 void setOpacity( const double opacity ) { mOpacity = opacity; }
176
183 double opacity() const { return mOpacity; }
184
193 void setColor( const QColor &color ) { mColor = color; }
194
203 QColor color() const { return mColor; }
204
212 void setRamp( QgsColorRamp *ramp SIP_TRANSFER );
213
221 QgsColorRamp *ramp() const { return mRamp; }
222
229 void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
230
237 QPainter::CompositionMode blendMode() const { return mBlendMode; }
238
248 void setColorType( GlowColorType colorType ) { mColorType = colorType; }
249
258 GlowColorType colorType() const { return mColorType; }
259
260 QgsGlowEffect &operator=( const QgsGlowEffect &rhs );
261
262 protected:
263
264 QRectF boundingRect( const QRectF &rect, const QgsRenderContext &context ) const override;
265 void draw( QgsRenderContext &context ) override;
266
273 virtual bool shadeExterior() const = 0;
274
275 double mSpread = 2.0;
278 QgsColorRamp *mRamp = nullptr;
279 double mBlurLevel = 2.645;
282 double mOpacity = 0.5;
283 QColor mColor;
284 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
285 GlowColorType mColorType = SingleColor;
286
287};
288
289
297class CORE_EXPORT QgsOuterGlowEffect : public QgsGlowEffect
298{
299
300 public:
301
307 static QgsPaintEffect *create( const QVariantMap &map ) SIP_FACTORY;
308
310
311 QString type() const override { return QStringLiteral( "outerGlow" ); }
312 QgsOuterGlowEffect *clone() const override SIP_FACTORY;
313
314 protected:
315
316 bool shadeExterior() const override { return true; }
317
318};
319
320
328class CORE_EXPORT QgsInnerGlowEffect : public QgsGlowEffect
329{
330
331 public:
332
338 static QgsPaintEffect *create( const QVariantMap &map ) SIP_FACTORY;
339
341
342 QString type() const override { return QStringLiteral( "innerGlow" ); }
343 QgsInnerGlowEffect *clone() const override SIP_FACTORY;
344
345 protected:
346
347 bool shadeExterior() const override { return false; }
348
349};
350
351#endif // QGSGLOWEFFECT_H
352
RenderUnit
Rendering size units.
Definition qgis.h:4847
@ Millimeters
Millimeters.
Abstract base class for color ramps.
Base class for paint effect which draw a glow inside or outside a picture.
void setSpread(const double spread)
Sets the spread distance for drawing the glow effect.
void setColorType(GlowColorType colorType)
Sets the color mode to use for the glow.
void setSpreadMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the spread distance.
Qgis::RenderUnit blurUnit() const
Returns the units used for the glow blur level (radius).
void setOpacity(const double opacity)
Sets the opacity for the effect.
QgsMapUnitScale mBlurMapUnitScale
double spread() const
Returns the spread distance used for drawing the glow effect.
virtual bool shadeExterior() const =0
Specifies whether the glow is drawn outside the picture or within the picture.
const QgsMapUnitScale & spreadMapUnitScale() const
Returns the map unit scale used for the spread distance.
GlowColorType
Color sources for the glow.
@ SingleColor
Use a single color and fade the color to totally transparent.
QPainter::CompositionMode blendMode() const
Returns the blend mode for the effect.
double blurLevel() const
Returns the blur level (radius) for the glow.
double opacity() const
Returns the opacity for the effect.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
QColor color() const
Returns the color for the glow.
const QgsMapUnitScale & blurMapUnitScale() const
Returns the map unit scale used for the glow blur strength (radius).
void setBlurUnit(const Qgis::RenderUnit unit)
Sets the units used for the glow blur level (radius).
void setBlurLevel(const double level)
Sets blur level (radius) for the glow.
QgsColorRamp * ramp() const
Returns the color ramp used for the glow.
Qgis::RenderUnit spreadUnit() const
Returns the units used for the glow spread distance.
QgsMapUnitScale mSpreadMapUnitScale
void setSpreadUnit(const Qgis::RenderUnit unit)
Sets the units used for the glow spread distance.
void setColor(const QColor &color)
Sets the color for the glow.
GlowColorType colorType() const
Returns the color mode used for the glow.
void setBlurMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the glow blur strength (radius).
A paint effect which draws a glow within a picture.
QString type() const override
Returns the effect type.
Struct for storing maximum and minimum scales for measurements in map units.
A paint effect which draws a glow outside of a picture.
QString type() const override
Returns the effect type.
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_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76