Skip to content

Commit

Permalink
Center small marker symbols in composer legend
Browse files Browse the repository at this point in the history
  • Loading branch information
marco committed Aug 8, 2011
1 parent cb529d0 commit e5e4a81
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/composer/qgscomposerlegend.cpp
Expand Up @@ -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 )
{
Expand All @@ -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 )
Expand All @@ -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
Expand Down

0 comments on commit e5e4a81

Please sign in to comment.