mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Fix data defined size legend
This commit is contained in:
parent
31981123d4
commit
29fe35265c
@ -148,8 +148,8 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
|
||||
// optionally scale size values if transformer is defined
|
||||
if ( mSizeScaleTransformer )
|
||||
{
|
||||
for ( auto it = classes.begin(); it != classes.end(); ++it )
|
||||
it->size = mSizeScaleTransformer->size( it->size );
|
||||
for ( SizeClass &cls : classes )
|
||||
cls.size = mSizeScaleTransformer->size( cls.size );
|
||||
}
|
||||
|
||||
// make sure we draw bigger symbols first
|
||||
@ -174,7 +174,7 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
|
||||
|
||||
// find out how wide the text will be
|
||||
int maxTextWidth = 0;
|
||||
for ( const SizeClass &c : qgis::as_const( mSizeClasses ) )
|
||||
for ( const SizeClass &c : qgis::as_const( classes ) )
|
||||
{
|
||||
int w = fm.width( c.label );
|
||||
if ( w > maxTextWidth )
|
||||
@ -189,7 +189,7 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
|
||||
|
||||
// find out top Y coordinate for individual symbol sizes
|
||||
QList<int> symbolTopY;
|
||||
for ( const SizeClass &c : qgis::as_const( mSizeClasses ) )
|
||||
for ( const SizeClass &c : qgis::as_const( classes ) )
|
||||
{
|
||||
int outputSymbolSize = std::round( context.convertToPainterUnits( c.size, s->sizeUnit(), s->sizeMapUnitScale() ) );
|
||||
switch ( mVAlign )
|
||||
@ -243,7 +243,7 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
|
||||
p->translate( 0, -textTopY );
|
||||
|
||||
// draw symbols first so that they do not cover
|
||||
for ( const SizeClass &c : qgis::as_const( mSizeClasses ) )
|
||||
for ( const SizeClass &c : qgis::as_const( classes ) )
|
||||
{
|
||||
s->setSize( c.size );
|
||||
|
||||
@ -268,7 +268,7 @@ void QgsDataDefinedSizeLegend::drawCollapsedLegend( QgsRenderContext &context, Q
|
||||
p->setFont( mFont );
|
||||
|
||||
int i = 0;
|
||||
for ( const SizeClass &c : qgis::as_const( mSizeClasses ) )
|
||||
for ( const SizeClass &c : qgis::as_const( classes ) )
|
||||
{
|
||||
// line from symbol to the text
|
||||
p->drawLine( outputLargestSize / 2, symbolTopY[i], outputLargestSize + hLengthLine, textCenterY[i] );
|
||||
@ -405,8 +405,7 @@ void QgsDataDefinedSizeLegend::writeXml( QDomElement &elem, const QgsReadWriteCo
|
||||
if ( !mSizeClasses.isEmpty() )
|
||||
{
|
||||
QDomElement elemClasses = doc.createElement( QStringLiteral( "classes" ) );
|
||||
const auto constMSizeClasses = mSizeClasses;
|
||||
for ( const SizeClass &sc : constMSizeClasses )
|
||||
for ( const SizeClass &sc : qgis::as_const( mSizeClasses ) )
|
||||
{
|
||||
QDomElement elemClass = doc.createElement( QStringLiteral( "class" ) );
|
||||
elemClass.setAttribute( QStringLiteral( "size" ), sc.size );
|
||||
|
Loading…
x
Reference in New Issue
Block a user