QGIS API Documentation  2.14.0-Essen
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 "qgspainteffect.h"
21 #include "qgssymbolv2.h"
22 #include <QPainter>
23 
25 
34 class CORE_EXPORT QgsGlowEffect : public QgsPaintEffect
35 {
36 
37  public:
38 
41  {
43  ColorRamp
44  };
45 
46  QgsGlowEffect();
47  QgsGlowEffect( const QgsGlowEffect& other );
48  virtual ~QgsGlowEffect();
49 
50  virtual QgsStringMap properties() const override;
51  virtual void readProperties( const QgsStringMap& props ) override;
52 
59  void setSpread( const double spread ) { mSpread = spread; }
60 
67  double spread() const { return mSpread; }
68 
75  void setSpreadUnit( const QgsSymbolV2::OutputUnit unit ) { mSpreadUnit = unit; }
76 
83  QgsSymbolV2::OutputUnit spreadUnit() const { return mSpreadUnit; }
84 
91  void setSpreadMapUnitScale( const QgsMapUnitScale& scale ) { mSpreadMapUnitScale = scale; }
92 
99  const QgsMapUnitScale& spreadMapUnitScale() const { return mSpreadMapUnitScale; }
100 
107  void setBlurLevel( const int level ) { mBlurLevel = level; }
108 
114  int blurLevel() const { return mBlurLevel; }
115 
121  void setTransparency( const double transparency ) { mTransparency = transparency; }
122 
128  double transparency() const { return mTransparency; }
129 
137  void setColor( const QColor& color ) { mColor = color; }
138 
146  QColor color() const { return mColor; }
147 
154  void setRamp( QgsVectorColorRampV2* ramp );
155 
162  QgsVectorColorRampV2* ramp() const { return mRamp; }
163 
169  void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
170 
176  QPainter::CompositionMode blendMode() const { return mBlendMode; }
177 
186  void setColorType( GlowColorType colorType ) { mColorType = colorType; }
187 
195  GlowColorType colorType() const { return mColorType; }
196 
197  QgsGlowEffect& operator=( const QgsGlowEffect& rhs );
198 
199  protected:
200 
201  virtual QRectF boundingRect( const QRectF& rect, const QgsRenderContext& context ) const override;
202  virtual void draw( QgsRenderContext& context ) override;
203 
209  virtual bool shadeExterior() const = 0;
210 
211  double mSpread;
218  QPainter::CompositionMode mBlendMode;
220 
221 };
222 
223 
231 class CORE_EXPORT QgsOuterGlowEffect : public QgsGlowEffect
232 {
233 
234  public:
235 
240  static QgsPaintEffect* create( const QgsStringMap& map );
241 
243  virtual ~QgsOuterGlowEffect();
244 
245  virtual QString type() const override { return QString( "outerGlow" ); }
246  virtual QgsOuterGlowEffect* clone() const override;
247 
248  protected:
249 
250  virtual bool shadeExterior() const override { return true; }
251 
252 };
253 
254 
262 class CORE_EXPORT QgsInnerGlowEffect : public QgsGlowEffect
263 {
264 
265  public:
266 
271  static QgsPaintEffect* create( const QgsStringMap& map );
272 
274  virtual ~QgsInnerGlowEffect();
275 
276  virtual QString type() const override { return QString( "innerGlow" ); }
277  virtual QgsInnerGlowEffect* clone() const override;
278 
279  protected:
280 
281  virtual bool shadeExterior() const override { return false; }
282 
283 };
284 
285 #endif // QGSGLOWEFFECT_H
286 
QgsVectorColorRampV2 * ramp() const
Returns the color ramp used for the glow.
QgsSymbolV2::OutputUnit mSpreadUnit
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:62
virtual QgsStringMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
virtual QRectF boundingRect(const QRectF &rect, const QgsRenderContext &context) const
Returns the bounding rect required for drawing the effect.
void setSpreadUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units used for the glow spread distance.
Definition: qgsgloweffect.h:75
double transparency() const
Returns the transparency for the effect.
QPainter::CompositionMode mBlendMode
Base class for visual effects which can be applied to QPicture drawings.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
Base class for paint effect which draw a glow inside or outside a picture.
Definition: qgsgloweffect.h:34
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
void setTransparency(const double transparency)
Sets the transparency for the effect.
double mTransparency
void setSpreadMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the spread distance.
Definition: qgsgloweffect.h:91
void setBlurLevel(const int level)
Sets blur level (strength) for the glow.
double spread() const
Returns the spread distance used for drawing the glow effect.
Definition: qgsgloweffect.h:67
GlowColorType mColorType
void setColorType(GlowColorType colorType)
Sets the color mode to use for the glow.
QgsVectorColorRampV2 * mRamp
GlowColorType
Color sources for the glow.
Definition: qgsgloweffect.h:40
virtual bool shadeExterior() const override
Specifies whether the glow is drawn outside the picture or within the picture.
void setSpread(const double spread)
Sets the spread distance for drawing the glow effect.
Definition: qgsgloweffect.h:59
const QgsMapUnitScale & spreadMapUnitScale() const
Returns the map unit scale used for the spread distance.
Definition: qgsgloweffect.h:99
A paint effect which draws a glow outside of a picture.
virtual void readProperties(const QgsStringMap &props)=0
Reads a string map of an effect&#39;s properties and restores the effect to the state described by the pr...
Contains information about the context of a rendering operation.
Struct for storing maximum and minimum scales for measurements in map units.
int blurLevel() const
Returns the blur level (strength) for the glow.
virtual QString type() const override
Returns the effect type.
virtual QString type() const override
Returns the effect type.
QgsMapUnitScale mSpreadMapUnitScale
QColor color() const
Returns the color for the glow.
GlowColorType colorType() const
Returns the color mode used for the glow.
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect&#39;s result on to the specified render context.
virtual bool shadeExterior() const override
Specifies whether the glow is drawn outside the picture or within the picture.
A paint effect which draws a glow within a picture.
QgsSymbolV2::OutputUnit spreadUnit() const
Returns the units used for the glow spread distance.
Definition: qgsgloweffect.h:83
void setColor(const QColor &color)
Sets the color for the glow.
QPainter::CompositionMode blendMode() const
Returns the blend mode for the effect.