Skip to content
Permalink
Browse files

[layouts] Show more precision in map scale for map item properties

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 0a662576a74a742e1a8936a6f8dcfcc5a33607ae
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/app/layout/qgslayoutmapwidget.cpp
@@ -483,7 +483,7 @@ void QgsLayoutMapWidget::mScaleLineEdit_editingFinished()
return;
}

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

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

//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 ) );
}
else if ( scale >= 10 )
{
mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(), 'f', 3 ) );
}
else if ( scale >= 1 )
{
//don't round scale if it's less than 10, instead use 4 decimal places

0 comments on commit 0a66257

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