[QGIS Commit] r9283 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Sep 8 06:12:27 EDT 2008


Author: mhugent
Date: 2008-09-08 06:12:27 -0400 (Mon, 08 Sep 2008)
New Revision: 9283

Modified:
   trunk/qgis/src/core/qgsmaprenderer.cpp
   trunk/qgis/src/core/qgsmaprenderer.h
Log:
Added option to disable mm units in maprenderer (e.g. for third party apps). Not yet exposed to GUI because of feature freeze

Modified: trunk/qgis/src/core/qgsmaprenderer.cpp
===================================================================
--- trunk/qgis/src/core/qgsmaprenderer.cpp	2008-09-08 08:18:14 UTC (rev 9282)
+++ trunk/qgis/src/core/qgsmaprenderer.cpp	2008-09-08 10:12:27 UTC (rev 9283)
@@ -50,6 +50,8 @@
 
   mProjectionsEnabled = FALSE;
   mDestCRS = new QgsCoordinateReferenceSystem( GEOEPSG_ID, QgsCoordinateReferenceSystem::EPSG ); //WGS 84
+
+  mOutputUnits = QgsMapRenderer::MM;
 }
 
 QgsMapRenderer::~QgsMapRenderer()
@@ -238,7 +240,11 @@
   //use the specified dpi and not those from the paint device
   //because sometimes QPainter units are in a local coord sys (e.g. in case of QGraphicsScene)
   double sceneDpi = mScaleCalculator->dpi();
-  double scaleFactor = sceneDpi / 25.4; //units should always be mm
+  double scaleFactor = 1.0;
+  if(mOutputUnits == QgsMapRenderer::MM)
+    {
+      scaleFactor = sceneDpi / 25.4;
+    }
   double rasterScaleFactor = ( thePaintDevice->logicalDpiX() + thePaintDevice->logicalDpiY() ) / 2.0 / sceneDpi;
   mRenderContext.setScaleFactor( scaleFactor );
   mRenderContext.setRasterScaleFactor( rasterScaleFactor );

Modified: trunk/qgis/src/core/qgsmaprenderer.h
===================================================================
--- trunk/qgis/src/core/qgsmaprenderer.h	2008-09-08 08:18:14 UTC (rev 9282)
+++ trunk/qgis/src/core/qgsmaprenderer.h	2008-09-08 10:12:27 UTC (rev 9283)
@@ -44,6 +44,14 @@
 
   public:
 
+  /**Output units for pen width and point marker width/height*/
+  enum OUTPUT_UNITS
+    {
+      MM,
+      PIXEL
+      //MAP_UNITS probably supported in future versions
+    };
+
     //! constructor
     QgsMapRenderer();
 
@@ -112,6 +120,10 @@
     //! returns CRS ID of destination spatial reference system
     const QgsCoordinateReferenceSystem& destinationSrs();
 
+    void setOutputUnits(OUTPUT_UNITS u){mOutputUnits = u;}
+
+    OUTPUT_UNITS outputUnits() const {return mOutputUnits;}
+
     //! returns current extent of layer set
     QgsRect fullExtent();
 
@@ -205,6 +217,9 @@
 
     //!Encapsulates context of rendering
     QgsRenderContext mRenderContext;
+
+    //!Output units
+    OUTPUT_UNITS mOutputUnits;
 };
 
 #endif



More information about the QGIS-commit mailing list