From a71e95abcbbb7ce1ec01cc1e3e83e9d371239a6a Mon Sep 17 00:00:00 2001 From: g_j_m Date: Mon, 24 Oct 2005 00:29:36 +0000 Subject: [PATCH] Fix a bug where the scale bar units weren't being correctly updated after a change in map units caused by turning on on-the-fly-reprojection. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4127 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/qgisapp.cpp | 10 ++-------- src/qgsmapcanvas.cpp | 7 +++++++ src/qgsmapcanvas.h | 3 +++ src/qgsprojectproperties.cpp | 1 + src/qgsprojectproperties.h | 3 +++ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/qgisapp.cpp b/src/qgisapp.cpp index ae81fa394ca..10230b3f403 100644 --- a/src/qgisapp.cpp +++ b/src/qgisapp.cpp @@ -4698,6 +4698,7 @@ void QgisApp::projectProperties() QApplication::restoreOverrideCursor(); //pass any refresg signals off to canvases connect (pp,SIGNAL(refresh()), mMapCanvas, SLOT(refresh())); + connect (pp,SIGNAL(mapUnitsChanged()), mMapCanvas, SLOT(mapUnitsChanged())); connect (pp,SIGNAL(refresh()), mOverviewCanvas, SLOT(refresh())); bool wasProjected = pp->isProjected(); @@ -4705,20 +4706,13 @@ void QgisApp::projectProperties() // Display the modal dialog box. pp->exec(); - // set the map units for the project if they have changed - if (mMapCanvas->mapUnits() != pp->mapUnits()) - { - mMapCanvas->setMapUnits(pp->mapUnits()); - } - // If the canvas projection settings changed, we need to recalculate the extents in the // new coordinate system if(pp->isProjected() != wasProjected) { mMapCanvas->recalculateExtents(); } - // Set the window title. No way to do a comparison like for the map - // units above, so redo it everytime. + // Set the window title. setTitleBarText_( *this ); // delete the property sheet object delete pp; diff --git a/src/qgsmapcanvas.cpp b/src/qgsmapcanvas.cpp index 5d9dcc26656..abf39a951e7 100644 --- a/src/qgsmapcanvas.cpp +++ b/src/qgsmapcanvas.cpp @@ -955,6 +955,13 @@ bool QgsMapCanvas::projectionsEnabled() } } +void QgsMapCanvas::mapUnitsChanged() +{ + // We assume that if the map units have changed, the changed value + // will be accessible from QgsProject. + setMapUnits(QgsProject::instance()->mapUnits()); +} + void QgsMapCanvas::zoomToSelected() { QgsVectorLayer *lyr = diff --git a/src/qgsmapcanvas.h b/src/qgsmapcanvas.h index 60e34aed8d3..e2fb98650b6 100644 --- a/src/qgsmapcanvas.h +++ b/src/qgsmapcanvas.h @@ -259,6 +259,9 @@ public slots: /** A simple helper method to find out if on the fly projections are enabled or not */ bool projectionsEnabled(); + + /** The map units may have changed, so cope with that */ + void mapUnitsChanged(); signals: /** Let the owner know how far we are with render operations */ diff --git a/src/qgsprojectproperties.cpp b/src/qgsprojectproperties.cpp index f630a23736d..47909f6128c 100644 --- a/src/qgsprojectproperties.cpp +++ b/src/qgsprojectproperties.cpp @@ -228,6 +228,7 @@ void QgsProjectProperties::apply() QgsProject::instance()->mapUnits(srs.mapUnits()); } } + emit mapUnitsChanged(); // set the mouse display precision method and the // number of decimal places for the manual option diff --git a/src/qgsprojectproperties.h b/src/qgsprojectproperties.h index 12aafa64950..f5f5c090257 100644 --- a/src/qgsprojectproperties.h +++ b/src/qgsprojectproperties.h @@ -89,6 +89,9 @@ signals: void setDestSRSID(long theSRSID); //! Signal used to inform listeners that the mouse display precision may have changed void displayPrecisionChanged(); + //! Signal used to inform listeners that the map units may of + //changed (and that the new value can be found in QgsProject. + void mapUnitsChanged(); //! let listening canvases know to refresh void refresh(); //! notification of when on the fly projections are enabled / disabled