Skip to content

Commit

Permalink
[map canvas] Fix scale change when resizing in locked scale mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jun 24, 2019
1 parent 468281b commit 17802c1
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1540,19 +1540,28 @@ void QgsMapCanvas::mouseReleaseEvent( QMouseEvent *e )
void QgsMapCanvas::resizeEvent( QResizeEvent *e )
{
QGraphicsView::resizeEvent( e );
mResizeTimer->start( 500 );
mResizeTimer->start( 500 ); // in charge of refreshing canvas

double oldScale = mSettings.scale();
QSize lastSize = viewport()->size();

mSettings.setOutputSize( lastSize );

mScene->setSceneRect( QRectF( 0, 0, lastSize.width(), lastSize.height() ) );

moveCanvasContents( true );

updateScale();

//refresh();
if ( mScaleLocked )
{
double scaleFactor = oldScale / mSettings.scale();
QgsRectangle r = mSettings.extent();
QgsPointXY center = r.center();
r.scale( scaleFactor, &center );
mSettings.setExtent( r );
}
else
{
updateScale();
}

emit extentsChanged();
}
Expand Down

0 comments on commit 17802c1

Please sign in to comment.