Skip to content

Commit

Permalink
[composer] Don't round down scale for maps if < 1 (fix #9366)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 11, 2014
1 parent f46053d commit 3224608
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/app/composer/qgscomposermapwidget.cpp
Expand Up @@ -420,8 +420,24 @@ void QgsComposerMapWidget::updateGuiElements()
blockAllSignals( true );

//width, height, scale
// QRectF composerMapRect = mComposerMap->rect();
mScaleLineEdit->setText( QString::number( mComposerMap->scale(), 'f', 0 ) );
double scale = mComposerMap->scale();

//round scale to an appropriate number of decimal places
if ( scale >= 10 )
{
//round scale to integer if it's greater than 10
mScaleLineEdit->setText( QString::number( mComposerMap->scale(), 'f', 0 ) );
}
else if ( scale >= 1 )
{
//don't round scale if it's less than 10, instead use 4 decimal places
mScaleLineEdit->setText( QString::number( mComposerMap->scale(), 'f', 4 ) );
}
else
{
//if scale < 1 then use 10 decimal places
mScaleLineEdit->setText( QString::number( mComposerMap->scale(), 'f', 10 ) );
}

//preview mode
QgsComposerMap::PreviewMode previewMode = mComposerMap->previewMode();
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposermap.cpp
Expand Up @@ -781,7 +781,7 @@ void QgsComposerMap::setNewScale( double scaleDenominator )
{
double currentScaleDenominator = scale();

if ( scaleDenominator == currentScaleDenominator )
if ( scaleDenominator == currentScaleDenominator || scaleDenominator == 0 )
{
return;
}
Expand Down

0 comments on commit 3224608

Please sign in to comment.