Skip to content

Commit

Permalink
Added option to disable mm units in maprenderer (e.g. for third party…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
mhugent committed Sep 8, 2008
1 parent 46c840f commit c17ccca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/qgsmaprenderer.cpp
Expand Up @@ -50,6 +50,8 @@ QgsMapRenderer::QgsMapRenderer()

mProjectionsEnabled = FALSE;
mDestCRS = new QgsCoordinateReferenceSystem( GEOEPSG_ID, QgsCoordinateReferenceSystem::EPSG ); //WGS 84

mOutputUnits = QgsMapRenderer::MM;
}

QgsMapRenderer::~QgsMapRenderer()
Expand Down Expand Up @@ -238,7 +240,11 @@ void QgsMapRenderer::render( QPainter* painter )
//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 );
Expand Down
15 changes: 15 additions & 0 deletions src/core/qgsmaprenderer.h
Expand Up @@ -44,6 +44,14 @@ class CORE_EXPORT QgsMapRenderer : public QObject

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();

Expand Down Expand Up @@ -112,6 +120,10 @@ class CORE_EXPORT QgsMapRenderer : public QObject
//! 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();

Expand Down Expand Up @@ -205,6 +217,9 @@ class CORE_EXPORT QgsMapRenderer : public QObject

//!Encapsulates context of rendering
QgsRenderContext mRenderContext;

//!Output units
OUTPUT_UNITS mOutputUnits;
};

#endif
Expand Down

0 comments on commit c17ccca

Please sign in to comment.