Skip to content

Commit

Permalink
[layouts] Show more precision in map scale for map item properties
Browse files Browse the repository at this point in the history
Previously we would often round the scale displayed to the nearest
integer. Now ensure that the map scale widget shows more decimals
to allow verification that the actual map scale exactly matches
the desired scale.

Fixes #20133
  • Loading branch information
nyalldawson committed Oct 19, 2018
1 parent fb2883c commit 0a66257
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/layout/qgslayoutmapwidget.cpp
Expand Up @@ -483,7 +483,7 @@ void QgsLayoutMapWidget::mScaleLineEdit_editingFinished()
return; return;
} }


if ( std::round( scaleDenominator ) == std::round( mMapItem->scale() ) ) if ( qgsDoubleNear( scaleDenominator, mMapItem->scale() ) )
return; return;


mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( "Change Map Scale" ) ); mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( "Change Map Scale" ) );
Expand Down Expand Up @@ -604,11 +604,15 @@ void QgsLayoutMapWidget::updateGuiElements()
double scale = mMapItem->scale(); double scale = mMapItem->scale();


//round scale to an appropriate number of decimal places //round scale to an appropriate number of decimal places
if ( scale >= 10 ) if ( scale >= 10000 )
{ {
//round scale to integer if it's greater than 10 //round scale to integer if it's greater than 10000
mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 'f', 0 ) ); mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 'f', 0 ) );
} }
else if ( scale >= 10 )
{
mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 'f', 3 ) );
}
else if ( scale >= 1 ) else if ( scale >= 1 )
{ {
//don't round scale if it's less than 10, instead use 4 decimal places //don't round scale if it's less than 10, instead use 4 decimal places
Expand Down

0 comments on commit 0a66257

Please sign in to comment.