Skip to content
Browse files

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: c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Apr 15, 2006
1 parent 298f9ab commit 57179069301f4454b05b3a904f35c2fe25b28555
Showing with 20 additions and 1 deletion.
  1. +12 −0 src/gui/qgsmapcanvas.cpp
  2. +5 −1 src/gui/qgsmaprender.cpp
  3. +3 −0 src/gui/qgsmaprender.h
@@ -457,6 +457,18 @@ void QgsMapCanvas::mapUnitsChanged()
// We assume that if the map units have changed, the changed value
// will be accessible from QgsProject.
// Since the map units have changed, force a recalculation of the scale.
// And then force a redraw of the scale number in the status bar
// 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.

void QgsMapCanvas::zoomToSelected()
@@ -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()

// update the scale
mScale = mScaleCalculator->calculate(mExtent, myWidth);

QgsLogger::debug("Scale (assuming meters as map units) = 1", mScale, 1, __FILE__, __FUNCTION__, __LINE__);
@@ -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);

0 comments on commit 5717906

Please sign in to comment.
You can’t perform that action at this time.