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
This commit is contained in:
timlinux 2008-02-11 10:39:40 +00:00
parent 01f79abe26
commit 76ada2e1ef
6 changed files with 34 additions and 1 deletions

View File

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

View File

@ -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

View File

@ -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()
{

View File

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

View File

@ -35,6 +35,10 @@ void QgsScaleCalculator::setDpi(int dpi)
{
mDpi = dpi;
}
int QgsScaleCalculator::dpi()
{
return mDpi;
}
void QgsScaleCalculator::setMapUnits(QGis::units mapUnits)
{

View File

@ -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