From 76ada2e1ef863db5e85bb303b798b0275c3aa43f Mon Sep 17 00:00:00 2001 From: timlinux Date: Mon, 11 Feb 2008 10:39:40 +0000 Subject: [PATCH] Make maprender able to tell us the map size and dpi (there were previously no accessors for this) git-svn-id: http://svn.osgeo.org/qgis/trunk@8135 c8812cc2-4d05-0410-92ff-de0c093fc19c --- python/core/qgsmaprender.sip | 5 +++++ python/core/qgsscalecalculator.sip | 6 ++++++ src/core/qgsmaprender.cpp | 8 ++++++++ src/core/qgsmaprender.h | 5 +++++ src/core/qgsscalecalculator.cpp | 4 ++++ src/core/qgsscalecalculator.h | 7 ++++++- 6 files changed, 34 insertions(+), 1 deletion(-) diff --git a/python/core/qgsmaprender.sip b/python/core/qgsmaprender.sip index 74539abc1e6..2fde002bcb0 100644 --- a/python/core/qgsmaprender.sip +++ b/python/core/qgsmaprender.sip @@ -48,6 +48,11 @@ class QgsMapRender : QObject void setOutputSize(QSize size, int dpi); + //!accessor for output dpi + int outputDpi(); + //!accessor for output size + QSize outputSize(); + //! transform extent in layer's SRS to extent in output SRS QgsRect layerExtentToOutputExtent(QgsMapLayer* theLayer, QgsRect extent); diff --git a/python/core/qgsscalecalculator.sip b/python/core/qgsscalecalculator.sip index 417364ee241..1ad62890635 100644 --- a/python/core/qgsscalecalculator.sip +++ b/python/core/qgsscalecalculator.sip @@ -30,6 +30,12 @@ class QgsScaleCalculator */ void setDpi(int dpi); + /** + * Accessor for dpi used in scale calculations + * @return int the dpi used for scale calculations. + */ + int dpi(); + /** * Set the map units * @param mapUnits Units of the data on the map. Must match a value from the diff --git a/src/core/qgsmaprender.cpp b/src/core/qgsmaprender.cpp index 2c11c873240..465a4e14935 100644 --- a/src/core/qgsmaprender.cpp +++ b/src/core/qgsmaprender.cpp @@ -118,6 +118,14 @@ void QgsMapRender::setOutputSize(QSize size, int dpi) mScaleCalculator->setDpi(dpi); adjustExtentToSize(); } +int QgsMapRender::outputDpi() +{ + return mScaleCalculator->dpi(); +} +QSize QgsMapRender::outputSize() +{ + return mSize; +} void QgsMapRender::adjustExtentToSize() { diff --git a/src/core/qgsmaprender.h b/src/core/qgsmaprender.h index 531958306bf..ce0f63e9b2f 100644 --- a/src/core/qgsmaprender.h +++ b/src/core/qgsmaprender.h @@ -79,6 +79,11 @@ class CORE_EXPORT QgsMapRender : public QObject void setOverview(bool isOverview = true) { mOverview = isOverview; } void setOutputSize(QSize size, int dpi); + + //!accessor for output dpi + int outputDpi(); + //!accessor for output size + QSize outputSize(); //! transform extent in layer's SRS to extent in output SRS QgsRect layerExtentToOutputExtent(QgsMapLayer* theLayer, QgsRect extent); diff --git a/src/core/qgsscalecalculator.cpp b/src/core/qgsscalecalculator.cpp index dac6b6ef750..14c3a4f6cf3 100644 --- a/src/core/qgsscalecalculator.cpp +++ b/src/core/qgsscalecalculator.cpp @@ -35,6 +35,10 @@ void QgsScaleCalculator::setDpi(int dpi) { mDpi = dpi; } +int QgsScaleCalculator::dpi() +{ + return mDpi; +} void QgsScaleCalculator::setMapUnits(QGis::units mapUnits) { diff --git a/src/core/qgsscalecalculator.h b/src/core/qgsscalecalculator.h index a8e3c15ea12..3217bffa54e 100644 --- a/src/core/qgsscalecalculator.h +++ b/src/core/qgsscalecalculator.h @@ -51,6 +51,11 @@ class CORE_EXPORT QgsScaleCalculator * @param dpi Dots per inch of monitor resolution */ void setDpi(int dpi); + /** + * Accessor for dpi used in scale calculations + * @return int the dpi used for scale calculations. + */ + int dpi(); /** * Set the map units @@ -70,7 +75,7 @@ class CORE_EXPORT QgsScaleCalculator double calculate(QgsRect &mapExtent, int canvasWidth); /** - * Calculate the distance between to points in geographic coordinates. + * Calculate the distance between two points in geographic coordinates. * Used to calculate scale for map views with geographic (decimal degree) * data. * @param mapExtent QgsRect containing the current map extent