Skip to content

Commit 1e29b76

Browse files
committedJul 18, 2013
Fix scaling of rotated svg markers if printing a QGIS server WMS with QGIS desktop
1 parent 7a73307 commit 1e29b76

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed
 

‎src/core/symbology-ng/qgsmarkersymbollayerv2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Re
956956
{
957957
p->setOpacity( context.alpha() );
958958
const QPicture& pct = QgsSvgCache::instance()->svgAsPicture( path, size, fillColor, outlineColor, outlineWidth,
959-
context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor() );
959+
context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor(), context.renderContext().forceVectorOutput() );
960960

961961
if ( pct.width() > 1 )
962962
{

‎src/core/symbology-ng/qgssvgcache.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const Q
138138
// instead cache picture
139139
if ( !currentEntry->picture )
140140
{
141-
cachePicture( currentEntry );
141+
cachePicture( currentEntry, false );
142142
}
143143
}
144144
else
@@ -152,15 +152,15 @@ const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const Q
152152
}
153153

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

159159
//if current entry picture is 0: cache picture for entry
160160
//update stats for memory usage
161161
if ( !currentEntry->picture )
162162
{
163-
cachePicture( currentEntry );
163+
cachePicture( currentEntry, forceVectorOutput );
164164
trimToMaximumSize();
165165
}
166166

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

401-
void QgsSvgCache::cachePicture( QgsSvgCacheEntry *entry )
401+
void QgsSvgCache::cachePicture( QgsSvgCacheEntry *entry, bool forceVectorOutput )
402402
{
403403
if ( !entry )
404404
{
@@ -418,7 +418,7 @@ void QgsSvgCache::cachePicture( QgsSvgCacheEntry *entry )
418418
hwRatio = r.viewBoxF().height() / r.viewBoxF().width();
419419
}
420420
bool drawOnScreen = qgsDoubleNear( entry->rasterScaleFactor, 1.0, 0.1 );
421-
if ( drawOnScreen )
421+
if ( drawOnScreen && forceVectorOutput ) //forceVectorOutput always true in case of composer draw / composer preview
422422
{
423423
// fix to ensure rotated symbols scale with composer page (i.e. not map item) zoom
424424
double wSize = entry->size;

‎src/core/symbology-ng/qgssvgcache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CORE_EXPORT QgsSvgCache : public QObject
7272
const QImage& svgAsImage( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
7373
double widthScaleFactor, double rasterScaleFactor, bool& fitsInCache );
7474
const QPicture& svgAsPicture( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
75-
double widthScaleFactor, double rasterScaleFactor );
75+
double widthScaleFactor, double rasterScaleFactor, bool forceVectorOutput = false );
7676

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.