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@9283 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2008-09-08 10:12:27 +00:00
parent 17d69a13df
commit 5638905dc0
2 changed files with 22 additions and 1 deletions

View File

@ -50,6 +50,8 @@ QgsMapRenderer::QgsMapRenderer()
mProjectionsEnabled = FALSE; mProjectionsEnabled = FALSE;
mDestCRS = new QgsCoordinateReferenceSystem( GEOEPSG_ID, QgsCoordinateReferenceSystem::EPSG ); //WGS 84 mDestCRS = new QgsCoordinateReferenceSystem( GEOEPSG_ID, QgsCoordinateReferenceSystem::EPSG ); //WGS 84
mOutputUnits = QgsMapRenderer::MM;
} }
QgsMapRenderer::~QgsMapRenderer() QgsMapRenderer::~QgsMapRenderer()
@ -238,7 +240,11 @@ void QgsMapRenderer::render( QPainter* painter )
//use the specified dpi and not those from the paint device //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) //because sometimes QPainter units are in a local coord sys (e.g. in case of QGraphicsScene)
double sceneDpi = mScaleCalculator->dpi(); 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; double rasterScaleFactor = ( thePaintDevice->logicalDpiX() + thePaintDevice->logicalDpiY() ) / 2.0 / sceneDpi;
mRenderContext.setScaleFactor( scaleFactor ); mRenderContext.setScaleFactor( scaleFactor );
mRenderContext.setRasterScaleFactor( rasterScaleFactor ); mRenderContext.setRasterScaleFactor( rasterScaleFactor );

View File

@ -44,6 +44,14 @@ class CORE_EXPORT QgsMapRenderer : public QObject
public: public:
/**Output units for pen width and point marker width/height*/
enum OUTPUT_UNITS
{
MM,
PIXEL
//MAP_UNITS probably supported in future versions
};
//! constructor //! constructor
QgsMapRenderer(); QgsMapRenderer();
@ -112,6 +120,10 @@ class CORE_EXPORT QgsMapRenderer : public QObject
//! returns CRS ID of destination spatial reference system //! returns CRS ID of destination spatial reference system
const QgsCoordinateReferenceSystem& destinationSrs(); const QgsCoordinateReferenceSystem& destinationSrs();
void setOutputUnits(OUTPUT_UNITS u){mOutputUnits = u;}
OUTPUT_UNITS outputUnits() const {return mOutputUnits;}
//! returns current extent of layer set //! returns current extent of layer set
QgsRect fullExtent(); QgsRect fullExtent();
@ -205,6 +217,9 @@ class CORE_EXPORT QgsMapRenderer : public QObject
//!Encapsulates context of rendering //!Encapsulates context of rendering
QgsRenderContext mRenderContext; QgsRenderContext mRenderContext;
//!Output units
OUTPUT_UNITS mOutputUnits;
}; };
#endif #endif