Skip to content
Permalink
Browse files
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 1e29b76a83c5c1a657cac2a4db5e21d57ffe5217
@@ -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 )
{
@@ -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
@@ -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();
}

@@ -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 )
{
@@ -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;
@@ -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*/
@@ -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 );

0 comments on commit 1e29b76

Please sign in to comment.