QGIS API Documentation 3.41.0-Master (25ec5511245)
Loading...
Searching...
No Matches
qgsshadoweffect.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsshadoweffect.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 QGSSHADOWEFFECT_H
18#define QGSSHADOWEFFECT_H
19
20#include "qgis_core.h"
21#include "qgspainteffect.h"
22#include "qgis_sip.h"
23#include "qgsmapunitscale.h"
24#include "qgis.h"
25
26#include <QPainter>
27
36{
37
38 public:
39
41
42 QVariantMap properties() const override;
43 void readProperties( const QVariantMap &props ) override;
44
53 void setBlurLevel( const double level ) { mBlurLevel = level; }
54
63 double blurLevel() const { return mBlurLevel; }
64
73 void setBlurUnit( const Qgis::RenderUnit unit ) { mBlurUnit = unit; }
74
83 Qgis::RenderUnit blurUnit() const { return mBlurUnit; }
84
93 void setBlurMapUnitScale( const QgsMapUnitScale &scale ) { mBlurMapUnitScale = scale; }
94
103 const QgsMapUnitScale &blurMapUnitScale() const { return mBlurMapUnitScale; }
104
111 void setOffsetAngle( const int angle ) { mOffsetAngle = angle; }
112
119 int offsetAngle() const { return mOffsetAngle; }
120
128 void setOffsetDistance( const double distance ) { mOffsetDist = distance; }
129
137 double offsetDistance() const { return mOffsetDist; }
138
146 void setOffsetUnit( const Qgis::RenderUnit unit ) { mOffsetUnit = unit; }
147
155 Qgis::RenderUnit offsetUnit() const { return mOffsetUnit; }
156
164 void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
165
173 const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
174
180 void setColor( const QColor &color ) { mColor = color; }
181
187 QColor color() const { return mColor; }
188
195 void setOpacity( const double opacity ) { mOpacity = opacity; }
196
203 double opacity() const { return mOpacity; }
204
211 void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
212
219 QPainter::CompositionMode blendMode() const { return mBlendMode; }
220
221 protected:
222
223 QRectF boundingRect( const QRectF &rect, const QgsRenderContext &context ) const override;
224 void draw( QgsRenderContext &context ) override;
225
232 virtual bool exteriorShadow() const = 0;
233
234 double mBlurLevel = 2.645;
237 int mOffsetAngle = 135;
238 double mOffsetDist = 2.0;
241 double mOpacity = 1.0;
242 QColor mColor;
243 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_Multiply;
244
245};
246
247
255{
256
257 public:
258
264 static QgsPaintEffect *create( const QVariantMap &map ) SIP_FACTORY;
265
267
268 QString type() const override;
269 QgsDropShadowEffect *clone() const override SIP_FACTORY;
270
271 protected:
272
273 bool exteriorShadow() const override;
274
275};
276
285{
286
287 public:
288
294 static QgsPaintEffect *create( const QVariantMap &map ) SIP_FACTORY;
295
297
298 QString type() const override;
299 QgsInnerShadowEffect *clone() const override SIP_FACTORY;
300
301 protected:
302
303 bool exteriorShadow() const override;
304
305};
306
307#endif // QGSSHADOWEFFECT_H
308
RenderUnit
Rendering size units.
Definition qgis.h:4839
@ Millimeters
Millimeters.
A paint effect which draws an offset and optionally blurred drop shadow.
A paint effect which draws an offset and optionally blurred drop shadow within a picture.
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.
virtual QString type() const =0
Returns the effect type.
Contains information about the context of a rendering operation.
Base class for paint effects which offset, blurred shadows.
int offsetAngle() const
Returns the angle used for offsetting the shadow.
void setOffsetAngle(const int angle)
Sets the angle for offsetting the shadow.
void setOpacity(const double opacity)
Sets the opacity for the effect.
void setColor(const QColor &color)
Sets the color for the shadow.
double opacity() const
Returns the opacity for the effect.
Qgis::RenderUnit offsetUnit() const
Returns the units used for the shadow offset distance.
QColor color() const
Returns the color used for the shadow.
virtual bool exteriorShadow() const =0
Specifies whether the shadow is drawn outside the picture or within the picture.
QPainter::CompositionMode blendMode() const
Returns the blend mode for the effect.
Qgis::RenderUnit blurUnit() const
Returns the units used for the shadow blur level (radius).
void setBlurLevel(const double level)
Sets blur level (radius) for the shadow.
void setOffsetUnit(const Qgis::RenderUnit unit)
Sets the units used for the shadow offset distance.
void setOffsetDistance(const double distance)
Sets the distance for offsetting the shadow.
QgsMapUnitScale mOffsetMapUnitScale
double blurLevel() const
Returns the blur level (radius) for the shadow.
void setBlurUnit(const Qgis::RenderUnit unit)
Sets the units used for the shadow blur level (radius).
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale used for the shadow offset distance.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the shadow offset distance.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
double offsetDistance() const
Returns the distance used for offsetting the shadow.
QgsMapUnitScale mBlurMapUnitScale
const QgsMapUnitScale & blurMapUnitScale() const
Returns the map unit scale used for the shadow blur strength (radius).
void setBlurMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the shadow blur strength (radius).
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_NODEFAULTCTORS
Definition qgis_sip.h:101