Skip to content

Commit c17ccca

Browse files
author
mhugent
committed
Added option to disable mm units in maprenderer (e.g. for third party apps). Not yet exposed to GUI because of feature freeze
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9283 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 46c840f commit c17ccca

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/core/qgsmaprenderer.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ QgsMapRenderer::QgsMapRenderer()
5050

5151
mProjectionsEnabled = FALSE;
5252
mDestCRS = new QgsCoordinateReferenceSystem( GEOEPSG_ID, QgsCoordinateReferenceSystem::EPSG ); //WGS 84
53+
54+
mOutputUnits = QgsMapRenderer::MM;
5355
}
5456

5557
QgsMapRenderer::~QgsMapRenderer()
@@ -238,7 +240,11 @@ void QgsMapRenderer::render( QPainter* painter )
238240
//use the specified dpi and not those from the paint device
239241
//because sometimes QPainter units are in a local coord sys (e.g. in case of QGraphicsScene)
240242
double sceneDpi = mScaleCalculator->dpi();
241-
double scaleFactor = sceneDpi / 25.4; //units should always be mm
243+
double scaleFactor = 1.0;
244+
if(mOutputUnits == QgsMapRenderer::MM)
245+
{
246+
scaleFactor = sceneDpi / 25.4;
247+
}
242248
double rasterScaleFactor = ( thePaintDevice->logicalDpiX() + thePaintDevice->logicalDpiY() ) / 2.0 / sceneDpi;
243249
mRenderContext.setScaleFactor( scaleFactor );
244250
mRenderContext.setRasterScaleFactor( rasterScaleFactor );

src/core/qgsmaprenderer.h

+15
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ class CORE_EXPORT QgsMapRenderer : public QObject
4444

4545
public:
4646

47+
/**Output units for pen width and point marker width/height*/
48+
enum OUTPUT_UNITS
49+
{
50+
MM,
51+
PIXEL
52+
//MAP_UNITS probably supported in future versions
53+
};
54+
4755
//! constructor
4856
QgsMapRenderer();
4957

@@ -112,6 +120,10 @@ class CORE_EXPORT QgsMapRenderer : public QObject
112120
//! returns CRS ID of destination spatial reference system
113121
const QgsCoordinateReferenceSystem& destinationSrs();
114122

123+
void setOutputUnits(OUTPUT_UNITS u){mOutputUnits = u;}
124+
125+
OUTPUT_UNITS outputUnits() const {return mOutputUnits;}
126+
115127
//! returns current extent of layer set
116128
QgsRect fullExtent();
117129

@@ -205,6 +217,9 @@ class CORE_EXPORT QgsMapRenderer : public QObject
205217

206218
//!Encapsulates context of rendering
207219
QgsRenderContext mRenderContext;
220+
221+
//!Output units
222+
OUTPUT_UNITS mOutputUnits;
208223
};
209224

210225
#endif

0 commit comments

Comments
 (0)