@@ -404,6 +404,9 @@ void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double curren
404
404
double height = mSymbolHeight ;
405
405
double width = mSymbolWidth ;
406
406
double size = 0 ;
407
+ // Center small marker symbols
408
+ double widthOffset = 0 ;
409
+ double heightOffset = 0 ;
407
410
408
411
if ( markerSymbol )
409
412
{
@@ -416,10 +419,18 @@ void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double curren
416
419
width *= mmPerMapUnit;
417
420
markerSymbol->setSize ( width );
418
421
}
422
+ if ( width < mSymbolWidth )
423
+ {
424
+ widthOffset = ( mSymbolWidth - width ) / 2.0 ;
425
+ }
426
+ if ( height < mSymbolHeight )
427
+ {
428
+ heightOffset = ( mSymbolHeight - height ) / 2.0 ;
429
+ }
419
430
}
420
431
421
432
p->save ();
422
- p->translate ( currentXPosition, currentYCoord );
433
+ p->translate ( currentXPosition + widthOffset , currentYCoord + heightOffset );
423
434
p->scale ( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor );
424
435
425
436
if ( markerSymbol && sizeInMapUnits )
@@ -436,7 +447,8 @@ void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double curren
436
447
437
448
p->restore ();
438
449
currentXPosition += width;
439
- symbolHeight = height;
450
+ currentXPosition += 2 * widthOffset;
451
+ symbolHeight = height + 2 * heightOffset;
440
452
}
441
453
442
454
void QgsComposerLegend::drawPointSymbol ( QPainter* p, QgsSymbol* s, double currentYCoord, double & currentXPosition, double & symbolHeight, int opacity ) const
0 commit comments