Skip to content

Commit

Permalink
Restore map canvas to exactly same size and dpi after printing
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@8139 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Feb 12, 2008
1 parent 28a7a07 commit 3bae90d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/gui/qgsquickprint.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3bae90d

Please sign in to comment.