Fix for ticket #71 (I hope)

Also resolves a long standing issue with the scale units not updating
after being changed until the next map redraw (but the fix involves a
map redraw).


git-svn-id: http://svn.osgeo.org/qgis/trunk@5280 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
g_j_m 2006-04-15 10:27:10 +00:00
parent f8228bc965
commit 69e2ffb9c7
3 changed files with 20 additions and 1 deletions

View File

@ -457,6 +457,18 @@ void QgsMapCanvas::mapUnitsChanged()
// We assume that if the map units have changed, the changed value
// will be accessible from QgsProject.
setMapUnits(QgsProject::instance()->mapUnits());
// Since the map units have changed, force a recalculation of the scale.
mMapRender->updateScale();
// And then force a redraw of the scale number in the status bar
updateScale();
// And then redraw the map to force the scale bar to update
// itself. This is less than ideal as the entire map gets redrawn
// just to get the scale bar to redraw itself. If we ask the scale
// bar to redraw itself without redrawing the map, the existing
// scale bar is not removed, and we end up with two scale bars in
// the same location. This can perhaps be fixed when/if the scale
// bar is done as a transparent layer on top of the map canvas.
render();
}
void QgsMapCanvas::zoomToSelected()

View File

@ -57,6 +57,10 @@ QgsRect QgsMapRender::extent()
return mExtent;
}
void QgsMapRender::updateScale()
{
mScale = mScaleCalculator->calculate(mExtent, mSize.width());
}
bool QgsMapRender::setExtent(const QgsRect& extent)
{
@ -163,7 +167,7 @@ void QgsMapRender::adjustExtentToSize()
mExtent.setYmax(dymax);
// update the scale
mScale = mScaleCalculator->calculate(mExtent, myWidth);
updateScale();
#ifdef QGISDEBUG
QgsLogger::debug("Scale (assuming meters as map units) = 1", mScale, 1, __FILE__, __FUNCTION__, __LINE__);

View File

@ -62,6 +62,9 @@ class QgsMapRender : public QObject
double scale() const { return mScale; }
double mupp() const { return mMupp; }
//! Recalculate the map scale
void updateScale();
QGis::units mapUnits() const { return mMapUnits; }
void setMapUnits(QGis::units u);