Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] Paint effects for layers and symbol layers
This commit adds a new framework for implementing paint effects, which
modify the results of QPainter operations to apply visual effects
such as drop shadows and blurs.

The initial implementation allows for effects to be applied to entire
layers and individual symbol layers.

Included are a drop shadow, inner shadow, blur, inner glow, outer glow,
colorise and transform effect. A "stack" effect is also implemented
which allows other paint effects to be combined in various ways.

Sponsored by hundreds of generous kickstarter contributors!
  • Loading branch information
nyalldawson committed Mar 28, 2015
1 parent fe2db52 commit 742f323
Show file tree
Hide file tree
Showing 99 changed files with 11,650 additions and 179 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -479,6 +479,7 @@
<file>themes/default/bubble.svg</file>
<file>themes/default/mIconClear.png</file>
<file>flags/zh.png</file>
<file>themes/default/mIconPaintEffects.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
127 changes: 127 additions & 0 deletions images/themes/default/mIconPaintEffects.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions python/CMakeLists.txt
Expand Up @@ -92,6 +92,7 @@ INCLUDE_DIRECTORIES(
../src/gui/attributetable
../src/gui/editorwidgets
../src/gui/editorwidgets/core
../src/gui/effects
../src/gui/layertree

${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h
Expand Down Expand Up @@ -144,6 +145,7 @@ ADD_SIP_PYTHON_MODULE(qgis._core core/core.sip qgis_core)
INCLUDE_DIRECTORIES(
../src/gui
../src/gui/symbology-ng
../src/gui/effects
../src/plugins
${CMAKE_BINARY_DIR}/src/gui
${CMAKE_BINARY_DIR}/src/ui
Expand Down
8 changes: 8 additions & 0 deletions python/core/core.sip
Expand Up @@ -174,6 +174,14 @@
%Include diagram/qgstextdiagram.sip

%Include effects/qgsimageoperation.sip
%Include effects/qgspainteffect.sip
%Include effects/qgseffectstack.sip
%Include effects/qgsblureffect.sip
%Include effects/qgsshadoweffect.sip
%Include effects/qgsgloweffect.sip
%Include effects/qgstransformeffect.sip
%Include effects/qgscoloreffect.sip
%Include effects/qgspainteffectregistry.sip

%Include gps/qgsgpsconnection.sip
%Include gps/qgsgpsconnectionregistry.sip
Expand Down
99 changes: 99 additions & 0 deletions python/core/effects/qgsblureffect.sip
@@ -0,0 +1,99 @@
/** \ingroup core
* \class QgsBlurEffect
* \brief A paint effect which blurs a source picture, using a number of different blur
* methods.
*
* \note Added in version 2.9
*/

class QgsBlurEffect : QgsPaintEffect
{
%TypeHeaderCode
#include <qgsblureffect.h>
%End

public:

/** Available blur methods (algorithms) */
enum BlurMethod
{
StackBlur, /*< stack blur, a fast but low quality blur. Valid blur level values are between 0 - 16.*/
GaussianBlur /*< Gaussian blur, a slower but high quality blur. Blur level values are the distance in pixels for the blur operation. */
};

/** Creates a new QgsBlurEffect effect from a properties string map.
* @param map encoded properties string map
* @returns new QgsBlurEffect
*/
static QgsPaintEffect* create( const QgsStringMap& ) /Factory/;

QgsBlurEffect();
virtual ~QgsBlurEffect();

virtual QString type() const;
virtual QgsStringMap properties() const;
virtual void readProperties( const QgsStringMap& props );
virtual QgsPaintEffect* clone() const /Factory/;

/** Sets blur level (strength)
* @param level blur level. Depending on the current @link blurMethod @endlink, this parameter
* has different effects
* @see blurLevel
* @see blurMethod
*/
void setBlurLevel( const int level );

/** Returns the blur level (strength)
* @returns blur level. Depending on the current @link blurMethod @endlink, this parameter
* has different effects
* @see setBlurLevel
* @see blurMethod
*/
int blurLevel() const;

/** Sets the blur method (algorithm) to use for performing the blur.
* @param method blur method
* @see blurMethod
*/
void setBlurMethod( const BlurMethod method );

/** Returns the blur method (algorithm) used for performing the blur.
* @returns blur method
* @see setBlurMethod
*/
BlurMethod blurMethod() const;

/** Sets the transparency for the effect
* @param transparency double between 0 and 1 inclusive, where 0 is fully opaque
* and 1 is fully transparent
* @see transparency
*/
void setTransparency( const double transparency );

/** Returns the transparency for the effect
* @returns transparency value between 0 and 1 inclusive, where 0 is fully opaque
* and 1 is fully transparent
* @see setTransparency
*/
double transparency() const;

/** Sets the blend mode for the effect
* @param mode blend mode used for drawing the effect on to a destination
* paint device
* @see blendMode
*/
void setBlendMode( const QPainter::CompositionMode mode );

/** Returns the blend mode for the effect
* @returns blend mode used for drawing the effect on to a destination
* paint device
* @see setBlendMode
*/
QPainter::CompositionMode blendMode() const;

protected:

virtual void draw( QgsRenderContext& context );
virtual QRectF boundingRect( const QRectF& rect, const QgsRenderContext& context ) const;

};

0 comments on commit 742f323

Please sign in to comment.