Skip to content
Permalink
Browse files
Center small marker symbols in composer legend
  • Loading branch information
marco committed Aug 8, 2011
1 parent cb529d0 commit e5e4a81083277c87185675c83b18a4965cb0e112
Showing with 14 additions and 2 deletions.
  1. +14 −2 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

0 comments on commit e5e4a81

Please sign in to comment.