Skip to content
Permalink
Browse files

[legend] Fix alignment and chopped off text of collapsed data-defined…

… size legend symbol (#9228)
  • Loading branch information
nirvn committed Feb 22, 2019
1 parent 006ddf5 commit 17d077118b311f2bc717efdc49ea2b4d4427cce3
@@ -178,16 +178,18 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
if ( w > maxTextWidth )
maxTextWidth = w;
}
// add extra width needed to handle varying rendering of font weight
maxTextWidth += 1;

// find out size of the largest symbol
double largestSize = classes.at( 0 ).size;
double outputLargestSize = context.convertToPainterUnits( largestSize, s->sizeUnit(), s->sizeMapUnitScale() );
int outputLargestSize = std::round( context.convertToPainterUnits( largestSize, s->sizeUnit(), s->sizeMapUnitScale() ) );

// find out top Y coordinate for individual symbol sizes
QList<int> symbolTopY;
Q_FOREACH ( const SizeClass &c, classes )
{
double outputSymbolSize = context.convertToPainterUnits( c.size, s->sizeUnit(), s->sizeMapUnitScale() );
int outputSymbolSize = std::round( context.convertToPainterUnits( c.size, s->sizeUnit(), s->sizeMapUnitScale() ) );
switch ( mVAlign )
{
case AlignCenter:
@@ -243,7 +245,7 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
{
s->setSize( c.size );

double outputSymbolSize = context.convertToPainterUnits( c.size, s->sizeUnit(), s->sizeMapUnitScale() );
int outputSymbolSize = std::round( context.convertToPainterUnits( c.size, s->sizeUnit(), s->sizeMapUnitScale() ) );
double tx = ( outputLargestSize - outputSymbolSize ) / 2;

p->save();
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 17d0771

Please sign in to comment.
You can’t perform that action at this time.