File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ QgsMapRenderer::QgsMapRenderer()
50
50
51
51
mProjectionsEnabled = FALSE ;
52
52
mDestCRS = new QgsCoordinateReferenceSystem ( GEOEPSG_ID, QgsCoordinateReferenceSystem::EPSG ); // WGS 84
53
+
54
+ mOutputUnits = QgsMapRenderer::MM;
53
55
}
54
56
55
57
QgsMapRenderer::~QgsMapRenderer ()
@@ -238,7 +240,11 @@ void QgsMapRenderer::render( QPainter* painter )
238
240
// use the specified dpi and not those from the paint device
239
241
// because sometimes QPainter units are in a local coord sys (e.g. in case of QGraphicsScene)
240
242
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
+ }
242
248
double rasterScaleFactor = ( thePaintDevice->logicalDpiX () + thePaintDevice->logicalDpiY () ) / 2.0 / sceneDpi;
243
249
mRenderContext .setScaleFactor ( scaleFactor );
244
250
mRenderContext .setRasterScaleFactor ( rasterScaleFactor );
Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ class CORE_EXPORT QgsMapRenderer : public QObject
44
44
45
45
public:
46
46
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
+
47
55
// ! constructor
48
56
QgsMapRenderer ();
49
57
@@ -112,6 +120,10 @@ class CORE_EXPORT QgsMapRenderer : public QObject
112
120
// ! returns CRS ID of destination spatial reference system
113
121
const QgsCoordinateReferenceSystem& destinationSrs ();
114
122
123
+ void setOutputUnits (OUTPUT_UNITS u){mOutputUnits = u;}
124
+
125
+ OUTPUT_UNITS outputUnits () const {return mOutputUnits ;}
126
+
115
127
// ! returns current extent of layer set
116
128
QgsRect fullExtent ();
117
129
@@ -205,6 +217,9 @@ class CORE_EXPORT QgsMapRenderer : public QObject
205
217
206
218
// !Encapsulates context of rendering
207
219
QgsRenderContext mRenderContext ;
220
+
221
+ // !Output units
222
+ OUTPUT_UNITS mOutputUnits ;
208
223
};
209
224
210
225
#endif
You can’t perform that action at this time.
0 commit comments