Skip to content
Permalink
Browse files

Fix relationship between scale<->extent in the save [canvas] as image…

…/pdf dialog
  • Loading branch information
nirvn committed Feb 5, 2019
1 parent 34de184 commit d5be8559612205b4dbaa4092b9efc37514fec415
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/app/qgsmapsavedialog.cpp
@@ -81,9 +81,9 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co
}
mDrawDecorations->setText( tr( "Draw active decorations: %1" ).arg( !activeDecorations.isEmpty() ? activeDecorations : tr( "none" ) ) );

connect( mResolutionSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsMapSaveDialog::updateDpi );
connect( mOutputWidthSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsMapSaveDialog::updateOutputWidth );
connect( mOutputHeightSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsMapSaveDialog::updateOutputHeight );
connect( mResolutionSpinBox, &QSpinBox::editingFinished, this, [ = ] { updateDpi( mResolutionSpinBox->value() ); } );
connect( mOutputWidthSpinBox, &QSpinBox::editingFinished, this, [ = ] { updateOutputWidth( mOutputWidthSpinBox->value() );} );
connect( mOutputHeightSpinBox, &QSpinBox::editingFinished, this, [ = ] { updateOutputWidth( mOutputHeightSpinBox->value() );} );
connect( mExtentGroupBox, &QgsExtentGroupBox::extentChanged, this, &QgsMapSaveDialog::updateExtent );
connect( mScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsMapSaveDialog::updateScale );
connect( mLockAspectRatio, &QgsRatioLockButton::lockChanged, this, &QgsMapSaveDialog::lockChanged );
@@ -229,7 +229,7 @@ void QgsMapSaveDialog::updateScale( double scale )
calculator.setMapUnits( mExtentGroupBox->currentCrs().mapUnits() );
calculator.setDpi( mDpi );

double oldScale = 1 / ( calculator.calculate( mExtent, mSize.width() ) );
double oldScale = calculator.calculate( mExtent, mSize.width() );
double scaleRatio = scale / oldScale;
mExtent.scale( scaleRatio );
mExtentGroupBox->setOutputExtentFromUser( mExtent, mExtentGroupBox->currentCrs() );
@@ -298,6 +298,7 @@ void QgsMapSaveDialog::applyMapSettings( QgsMapSettings &mapSettings )
mapSettings.setOutputDpi( dpi() );
mapSettings.setBackgroundColor( mMapCanvas->canvasColor() );
mapSettings.setRotation( mMapCanvas->rotation() );
mapSettings.setEllipsoid( QgsProject::instance()->ellipsoid() );
mapSettings.setLayers( mMapCanvas->layers() );
mapSettings.setLabelingEngineSettings( mMapCanvas->mapSettings().labelingEngineSettings() );
mapSettings.setTransformContext( QgsProject::instance()->transformContext() );

0 comments on commit d5be855

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