Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[effect] fix issue with svg marker and antialiasing (fixes #14960)
Credit for original patch to @nirvn
  • Loading branch information
nyalldawson committed Jun 7, 2016
1 parent a625eeb commit 179a92c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions python/core/qgsmapsettings.sip
Expand Up @@ -105,10 +105,10 @@ class QgsMapSettings
//! Get color that is used for drawing of selected vector features
QColor selectionColor() const;

//! Enumeration of flags that adjust the way how map is rendered
//! Enumeration of flags that adjust the way the map is rendered
enum Flag
{
Antialiasing, //!< Enable anti-aliasin for map rendering
Antialiasing, //!< Enable anti-aliasing for map rendering
DrawEditingInfo, //!< Enable drawing of vertex markers for layers in editing mode
ForceVectorOutput, //!< Vector graphics should not be cached and drawn as raster images
UseAdvancedEffects, //!< Enable layer transparency and blending effects
Expand Down
3 changes: 2 additions & 1 deletion python/core/qgsrendercontext.sip
Expand Up @@ -21,7 +21,8 @@ class QgsRenderContext
UseRenderingOptimization, //!< Enable vector simplification and other rendering optimizations
DrawSelection, //!< Whether vector selections should be shown in the rendered map
DrawSymbolBounds, //!< Draw bounds of symbols (for debugging/testing)
RenderMapTile
RenderMapTile, //!< Draw map such that there are no problems between adjacent tiles
Antialiasing, //!< Use antialiasing while drawing
};
typedef QFlags<QgsRenderContext::Flag> Flags;

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsmapsettings.h
Expand Up @@ -153,10 +153,10 @@ class CORE_EXPORT QgsMapSettings
//! Get color that is used for drawing of selected vector features
QColor selectionColor() const { return mSelectionColor; }

//! Enumeration of flags that adjust the way how map is rendered
//! Enumeration of flags that adjust the way the map is rendered
enum Flag
{
Antialiasing = 0x01, //!< Enable anti-aliasin for map rendering
Antialiasing = 0x01, //!< Enable anti-aliasing for map rendering
DrawEditingInfo = 0x02, //!< Enable drawing of vertex markers for layers in editing mode
ForceVectorOutput = 0x04, //!< Vector graphics should not be cached and drawn as raster images
UseAdvancedEffects = 0x08, //!< Enable layer transparency and blending effects
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsrendercontext.cpp
Expand Up @@ -129,6 +129,7 @@ QgsRenderContext QgsRenderContext::fromMapSettings( const QgsMapSettings& mapSet
ctx.setFlag( DrawSelection, mapSettings.testFlag( QgsMapSettings::DrawSelection ) );
ctx.setFlag( DrawSymbolBounds, mapSettings.testFlag( QgsMapSettings::DrawSymbolBounds ) );
ctx.setFlag( RenderMapTile, mapSettings.testFlag( QgsMapSettings::RenderMapTile ) );
ctx.setFlag( Antialiasing, mapSettings.testFlag( QgsMapSettings::Antialiasing ) );
ctx.setRasterScaleFactor( 1.0 );
ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
ctx.setRendererScale( mapSettings.scale() );
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsrendercontext.h
Expand Up @@ -64,6 +64,7 @@ class CORE_EXPORT QgsRenderContext
DrawSelection = 0x10, //!< Whether vector selections should be shown in the rendered map
DrawSymbolBounds = 0x20, //!< Draw bounds of symbols (for debugging/testing)
RenderMapTile = 0x40, //!< Draw map such that there are no problems between adjacent tiles
Antialiasing = 0x80, //!< Use antialiasing while drawing
};
Q_DECLARE_FLAGS( Flags, Flag )

Expand Down
7 changes: 7 additions & 0 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Expand Up @@ -2042,6 +2042,13 @@ void QgsSvgMarkerSymbolLayerV2::renderPoint( QPointF point, QgsSymbolV2RenderCon
}

p->restore();

if ( context.renderContext().flags() & QgsRenderContext::Antialiasing )
{
// workaround issue with nested QPictures forgetting antialiasing flag - see http://hub.qgis.org/issues/14960
p->setRenderHint( QPainter::Antialiasing );
}

}

double QgsSvgMarkerSymbolLayerV2::calculateSize( QgsSymbolV2RenderContext& context, bool& hasDataDefinedSize ) const
Expand Down

1 comment on commit 179a92c

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 179a92c Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nyalldawson .

Please sign in to comment.