Skip to content

Commit 76ada2e

Browse files
author
timlinux
committedFeb 11, 2008
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
1 parent 01f79ab commit 76ada2e

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed
 

‎python/core/qgsmaprender.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class QgsMapRender : QObject
4848

4949
void setOutputSize(QSize size, int dpi);
5050

51+
//!accessor for output dpi
52+
int outputDpi();
53+
//!accessor for output size
54+
QSize outputSize();
55+
5156
//! transform extent in layer's SRS to extent in output SRS
5257
QgsRect layerExtentToOutputExtent(QgsMapLayer* theLayer, QgsRect extent);
5358

‎python/core/qgsscalecalculator.sip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class QgsScaleCalculator
3030
*/
3131
void setDpi(int dpi);
3232

33+
/**
34+
* Accessor for dpi used in scale calculations
35+
* @return int the dpi used for scale calculations.
36+
*/
37+
int dpi();
38+
3339
/**
3440
* Set the map units
3541
* @param mapUnits Units of the data on the map. Must match a value from the

‎src/core/qgsmaprender.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ void QgsMapRender::setOutputSize(QSize size, int dpi)
118118
mScaleCalculator->setDpi(dpi);
119119
adjustExtentToSize();
120120
}
121+
int QgsMapRender::outputDpi()
122+
{
123+
return mScaleCalculator->dpi();
124+
}
125+
QSize QgsMapRender::outputSize()
126+
{
127+
return mSize;
128+
}
121129

122130
void QgsMapRender::adjustExtentToSize()
123131
{

‎src/core/qgsmaprender.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ class CORE_EXPORT QgsMapRender : public QObject
7979
void setOverview(bool isOverview = true) { mOverview = isOverview; }
8080

8181
void setOutputSize(QSize size, int dpi);
82+
83+
//!accessor for output dpi
84+
int outputDpi();
85+
//!accessor for output size
86+
QSize outputSize();
8287

8388
//! transform extent in layer's SRS to extent in output SRS
8489
QgsRect layerExtentToOutputExtent(QgsMapLayer* theLayer, QgsRect extent);

‎src/core/qgsscalecalculator.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ void QgsScaleCalculator::setDpi(int dpi)
3535
{
3636
mDpi = dpi;
3737
}
38+
int QgsScaleCalculator::dpi()
39+
{
40+
return mDpi;
41+
}
3842

3943
void QgsScaleCalculator::setMapUnits(QGis::units mapUnits)
4044
{

‎src/core/qgsscalecalculator.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class CORE_EXPORT QgsScaleCalculator
5151
* @param dpi Dots per inch of monitor resolution
5252
*/
5353
void setDpi(int dpi);
54+
/**
55+
* Accessor for dpi used in scale calculations
56+
* @return int the dpi used for scale calculations.
57+
*/
58+
int dpi();
5459

5560
/**
5661
* Set the map units
@@ -70,7 +75,7 @@ class CORE_EXPORT QgsScaleCalculator
7075
double calculate(QgsRect &mapExtent, int canvasWidth);
7176

7277
/**
73-
* Calculate the distance between to points in geographic coordinates.
78+
* Calculate the distance between two points in geographic coordinates.
7479
* Used to calculate scale for map views with geographic (decimal degree)
7580
* data.
7681
* @param mapExtent QgsRect containing the current map extent

0 commit comments

Comments
 (0)
Please sign in to comment.