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