Navigation Menu

Skip to content

Commit

Permalink
[legend] Fix alignment and chopped off text of collapsed data-defined…
Browse files Browse the repository at this point in the history
… size legend symbol (#9228)
  • Loading branch information
nirvn committed Feb 22, 2019
1 parent 006ddf5 commit 17d0771
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/qgsdatadefinedsizelegend.cpp
Expand Up @@ -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:
Expand Down Expand Up @@ -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();
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 17d0771

Please sign in to comment.