mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
[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
This commit is contained in:
parent
fb2883c79c
commit
0a662576a7
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user