Skip to content

Commit

Permalink
[effect] fix issue with svg marker and antialiasing (fixes #14960)
Browse files Browse the repository at this point in the history
Credit for original patch to @nirvn

(cherry-picked from 179a92c)
  • Loading branch information
nyalldawson committed Jun 30, 2016
1 parent 5aa69ce commit 0a93bdd
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 @@ -78,10 +78,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 @@ -125,10 +125,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 @@ -123,6 +123,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 @@ -63,6 +63,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 @@ -1437,6 +1437,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

0 comments on commit 0a93bdd

Please sign in to comment.