Skip to content

Commit 41da5c3

Browse files
author
Sandro Santilli
committedJan 4, 2015
Fix handling of rotation in partial-rendering of map (#11909)
1 parent 2418ec7 commit 41da5c3

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed
 

‎src/gui/qgsmapcanvas.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -723,14 +723,7 @@ void QgsMapCanvas::rendererJobFinished()
723723

724724
p.end();
725725

726-
// This is an hack to pass QgsMapCanvasItem::setRect what it
727-
// expects (encoding of position and size of the item)
728-
const QgsMapToPixel& m2p = mSettings.mapToPixel();
729-
QgsPoint topLeft = m2p.toMapPoint( 0, 0 );
730-
double res = m2p.mapUnitsPerPixel();
731-
QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + img.width()*res, topLeft.y() - img.height()*res );
732-
733-
mMap->setContent( img, rect );
726+
mMap->setContent( img, imageRect( img ) );
734727
}
735728

736729
// now we are in a slot called from mJob - do not delete it immediately
@@ -741,9 +734,21 @@ void QgsMapCanvas::rendererJobFinished()
741734
emit mapCanvasRefreshed();
742735
}
743736

737+
QgsRectangle QgsMapCanvas::imageRect( const QImage& img )
738+
{
739+
// This is an hack to pass QgsMapCanvasItem::setRect what it
740+
// expects (encoding of position and size of the item)
741+
const QgsMapToPixel& m2p = mSettings.mapToPixel();
742+
QgsPoint topLeft = m2p.toMapPoint( 0, 0 );
743+
double res = m2p.mapUnitsPerPixel();
744+
QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + img.width()*res, topLeft.y() - img.height()*res );
745+
return rect;
746+
}
747+
744748
void QgsMapCanvas::mapUpdateTimeout()
745749
{
746-
mMap->setContent( mJob->renderedImage(), mJob->mapSettings().visibleExtent() );
750+
const QImage& img = mJob->renderedImage();
751+
mMap->setContent( img, imageRect( img ) );
Code has comments. Press enter to view.
747752
}
748753

749754
void QgsMapCanvas::stopRendering()

‎src/gui/qgsmapcanvas.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
643643

644644
QgsPreviewEffect* mPreviewEffect;
645645

646+
QgsRectangle imageRect( const QImage& img );
647+
646648
}; // class QgsMapCanvas
647649

648650

0 commit comments

Comments
 (0)
Please sign in to comment.