Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix scaling of rotated svg markers if printing a QGIS server WMS with…
… QGIS desktop
  • Loading branch information
mhugent committed Jul 18, 2013
1 parent 7a73307 commit 1e29b76
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Expand Up @@ -956,7 +956,7 @@ void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Re
{
p->setOpacity( context.alpha() );
const QPicture& pct = QgsSvgCache::instance()->svgAsPicture( path, size, fillColor, outlineColor, outlineWidth,
context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor() );
context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor(), context.renderContext().forceVectorOutput() );

if ( pct.width() > 1 )
{
Expand Down
10 changes: 5 additions & 5 deletions src/core/symbology-ng/qgssvgcache.cpp
Expand Up @@ -138,7 +138,7 @@ const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const Q
// instead cache picture
if ( !currentEntry->picture )
{
cachePicture( currentEntry );
cachePicture( currentEntry, false );
}
}
else
Expand All @@ -152,15 +152,15 @@ const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const Q
}

const QPicture& QgsSvgCache::svgAsPicture( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor )
double widthScaleFactor, double rasterScaleFactor, bool forceVectorOutput )
{
QgsSvgCacheEntry* currentEntry = cacheEntry( file, size, fill, outline, outlineWidth, widthScaleFactor, rasterScaleFactor );

//if current entry picture is 0: cache picture for entry
//update stats for memory usage
if ( !currentEntry->picture )
{
cachePicture( currentEntry );
cachePicture( currentEntry, forceVectorOutput );
trimToMaximumSize();
}

Expand Down Expand Up @@ -398,7 +398,7 @@ void QgsSvgCache::cacheImage( QgsSvgCacheEntry* entry )
mTotalSize += ( image->width() * image->height() * 32 );
}

void QgsSvgCache::cachePicture( QgsSvgCacheEntry *entry )
void QgsSvgCache::cachePicture( QgsSvgCacheEntry *entry, bool forceVectorOutput )
{
if ( !entry )
{
Expand All @@ -418,7 +418,7 @@ void QgsSvgCache::cachePicture( QgsSvgCacheEntry *entry )
hwRatio = r.viewBoxF().height() / r.viewBoxF().width();
}
bool drawOnScreen = qgsDoubleNear( entry->rasterScaleFactor, 1.0, 0.1 );
if ( drawOnScreen )
if ( drawOnScreen && forceVectorOutput ) //forceVectorOutput always true in case of composer draw / composer preview
{
// fix to ensure rotated symbols scale with composer page (i.e. not map item) zoom
double wSize = entry->size;
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology-ng/qgssvgcache.h
Expand Up @@ -72,7 +72,7 @@ class CORE_EXPORT QgsSvgCache : public QObject
const QImage& svgAsImage( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor, bool& fitsInCache );
const QPicture& svgAsPicture( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor );
double widthScaleFactor, double rasterScaleFactor, bool forceVectorOutput = false );

/**Tests if an svg file contains parameters for fill, outline color, outline width. If yes, possible default values are returned. If there are several
default values in the svg file, only the first one is considered*/
Expand All @@ -96,7 +96,7 @@ class CORE_EXPORT QgsSvgCache : public QObject

void replaceParamsAndCacheSvg( QgsSvgCacheEntry* entry );
void cacheImage( QgsSvgCacheEntry* entry );
void cachePicture( QgsSvgCacheEntry* entry );
void cachePicture( QgsSvgCacheEntry* entry, bool forceVectorOutput = false );
/**Returns entry from cache or creates a new entry if it does not exist already*/
QgsSvgCacheEntry* cacheEntry( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor );
Expand Down

0 comments on commit 1e29b76

Please sign in to comment.