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 a97ce69 commit 4f77477227ac77fb48a54fa72a4c1214073570b1
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/app/qgsmapsavedialog.cpp
@@ -82,9 +82,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() );} );

This comment has been minimized.

Copy link
@nirvn

nirvn Feb 5, 2019

Author Contributor

Arg, I'll push a follow up commit to fix this hasty copy/paste mistake here. Apologies for the noise.

connect( mExtentGroupBox, &QgsExtentGroupBox::extentChanged, this, &QgsMapSaveDialog::updateExtent );
connect( mScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsMapSaveDialog::updateScale );
connect( mLockAspectRatio, &QgsRatioLockButton::lockChanged, this, &QgsMapSaveDialog::lockChanged );
@@ -230,7 +230,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() );
@@ -299,6 +299,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 4f77477

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