From e5e4a81083277c87185675c83b18a4965cb0e112 Mon Sep 17 00:00:00 2001 From: marco Date: Mon, 8 Aug 2011 08:24:49 +0200 Subject: [PATCH] Center small marker symbols in composer legend --- src/core/composer/qgscomposerlegend.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/composer/qgscomposerlegend.cpp b/src/core/composer/qgscomposerlegend.cpp index 5a50f7e5d815..2690ba199224 100644 --- a/src/core/composer/qgscomposerlegend.cpp +++ b/src/core/composer/qgscomposerlegend.cpp @@ -404,6 +404,9 @@ void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double curren double height = mSymbolHeight; double width = mSymbolWidth; double size = 0; + //Center small marker symbols + double widthOffset = 0; + double heightOffset = 0; if ( markerSymbol ) { @@ -416,10 +419,18 @@ void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double curren width *= mmPerMapUnit; markerSymbol->setSize( width ); } + if ( width < mSymbolWidth ) + { + widthOffset = ( mSymbolWidth - width ) / 2.0; + } + if ( height < mSymbolHeight ) + { + heightOffset = ( mSymbolHeight - height ) / 2.0; + } } p->save(); - p->translate( currentXPosition, currentYCoord ); + p->translate( currentXPosition + widthOffset, currentYCoord + heightOffset ); p->scale( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor ); if ( markerSymbol && sizeInMapUnits ) @@ -436,7 +447,8 @@ void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double curren p->restore(); currentXPosition += width; - symbolHeight = height; + currentXPosition += 2 * widthOffset; + symbolHeight = height + 2 * heightOffset; } void QgsComposerLegend::drawPointSymbol( QPainter* p, QgsSymbol* s, double currentYCoord, double& currentXPosition, double& symbolHeight, int opacity ) const