From 179a92cd65a70a411c8085875ab3e20bf5fa5d46 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 7 Jun 2016 10:07:23 +1000 Subject: [PATCH] [effect] fix issue with svg marker and antialiasing (fixes #14960) Credit for original patch to @nirvn --- python/core/qgsmapsettings.sip | 4 ++-- python/core/qgsrendercontext.sip | 3 ++- src/core/qgsmapsettings.h | 4 ++-- src/core/qgsrendercontext.cpp | 1 + src/core/qgsrendercontext.h | 1 + src/core/symbology-ng/qgsmarkersymbollayerv2.cpp | 7 +++++++ 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/python/core/qgsmapsettings.sip b/python/core/qgsmapsettings.sip index d8070482e9e..6d0d213c05e 100644 --- a/python/core/qgsmapsettings.sip +++ b/python/core/qgsmapsettings.sip @@ -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 diff --git a/python/core/qgsrendercontext.sip b/python/core/qgsrendercontext.sip index ef5324d9a16..3c5818bfd59 100644 --- a/python/core/qgsrendercontext.sip +++ b/python/core/qgsrendercontext.sip @@ -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 Flags; diff --git a/src/core/qgsmapsettings.h b/src/core/qgsmapsettings.h index 880537af4f4..11973a2a95e 100644 --- a/src/core/qgsmapsettings.h +++ b/src/core/qgsmapsettings.h @@ -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 diff --git a/src/core/qgsrendercontext.cpp b/src/core/qgsrendercontext.cpp index 28204c6d127..7e212ce7b14 100644 --- a/src/core/qgsrendercontext.cpp +++ b/src/core/qgsrendercontext.cpp @@ -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() ); diff --git a/src/core/qgsrendercontext.h b/src/core/qgsrendercontext.h index b87524a9d3e..413d0394831 100644 --- a/src/core/qgsrendercontext.h +++ b/src/core/qgsrendercontext.h @@ -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 ) diff --git a/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp b/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp index 58262020f7a..91dac84515b 100644 --- a/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp +++ b/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp @@ -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