Skip to content
Permalink
Browse files

Restore map canvas to exactly same size and dpi after printing

git-svn-id: http://svn.osgeo.org/qgis/trunk@8139 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Feb 12, 2008
1 parent 28a7a07 commit 3bae90d1683fda12441a9b2f1dc71c221c140ffe
Showing with 12 additions and 6 deletions.
  1. +12 −6 src/gui/qgsquickprint.cpp
@@ -337,17 +337,19 @@ void QgsQuickPrint::printMap()
myMapPixmap.fill ( mMapBackgroundColour );
QPainter myMapPainter;
myMapPainter.begin( &myMapPixmap );
//
// Remember the size and dpi of the maprender
// so we can restore it properly
//
int myOriginalDpi = mpMapRender->outputDpi();
QSize myOriginalSize = mpMapRender->outputSize();
// Now resize for print
mpMapRender->setOutputSize(
QSize ( myMapDimensionX, myMapDimensionY ), myPrinter.resolution() );
scalePointSymbols(mySymbolScalingAmount, ScaleUp);
scaleTextLabels(mySymbolScalingAmount, ScaleUp);
mpMapRender->render( &myMapPainter );
//maprender has no accessor for output size so
//we couldnt store the size before starting the print render
//so that it can be restored properly so what follows here is a
//best guess approach
mpMapRender->setOutputSize(
QSize ( mpMapRender->width(), mpMapRender->height() ), myScreenResolutionDpi );

myMapPainter.end();
//draw the map pixmap onto our pdf print device
myOriginX = myPrinter.pageRect().left() + myHorizontalSpacing;
@@ -672,6 +674,10 @@ void QgsQuickPrint::printMap()
mProgressDialog.setWindowModality ( Qt::WindowModal );
mProgressDialog.setAutoClose ( true );
*/
//
// Restore the map render to its former glory
//
mpMapRender->setOutputSize( myOriginalSize, myOriginalDpi);
}

void QgsQuickPrint::scaleTextLabels( int theScaleFactor, SymbolScalingType theDirection)

0 comments on commit 3bae90d

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