Skip to content

Commit

Permalink
Make maprender able to tell us the map size and dpi (there were previ…
Browse files Browse the repository at this point in the history
…ously no accessors for this)

git-svn-id: http://svn.osgeo.org/qgis/trunk@8135 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Feb 11, 2008
1 parent 01f79ab commit 76ada2e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions python/core/qgsmaprender.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions python/core/qgsscalecalculator.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/core/qgsmaprender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsmaprender.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsscalecalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ void QgsScaleCalculator::setDpi(int dpi)
{
mDpi = dpi;
}
int QgsScaleCalculator::dpi()
{
return mDpi;
}

void QgsScaleCalculator::setMapUnits(QGis::units mapUnits)
{
Expand Down
7 changes: 6 additions & 1 deletion src/core/qgsscalecalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 76ada2e

Please sign in to comment.