[QGIS Commit] r8139 - trunk/qgis/src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Feb 11 19:49:18 EST 2008


Author: timlinux
Date: 2008-02-11 19:49:17 -0500 (Mon, 11 Feb 2008)
New Revision: 8139

Modified:
   trunk/qgis/src/gui/qgsquickprint.cpp
Log:
Restore map canvas to exactly same size and dpi after printing


Modified: trunk/qgis/src/gui/qgsquickprint.cpp
===================================================================
--- trunk/qgis/src/gui/qgsquickprint.cpp	2008-02-11 18:22:40 UTC (rev 8138)
+++ trunk/qgis/src/gui/qgsquickprint.cpp	2008-02-12 00:49:17 UTC (rev 8139)
@@ -337,17 +337,19 @@
   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 @@
      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)



More information about the QGIS-commit mailing list