Fix canvas zorder syncing problems between overview and mapcanvas.

git-svn-id: http://svn.osgeo.org/qgis/trunk@1559 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2004-06-11 17:09:46 +00:00
parent b52c7eed86
commit d0dc16e8c5
2 changed files with 48 additions and 2 deletions

View File

@ -62,7 +62,7 @@
#include <iostream>
#include <iomanip>
#include <memory>
#include <vector>
#ifndef GDAL_PRIV_H_INCLUDED
@ -294,6 +294,7 @@ QgisApp::QgisApp(QWidget * parent, const char *name, WFlags fl):QgisAppBase(pare
connect(mMapLegend, SIGNAL(rightButtonPressed(QListViewItem *, const QPoint &, int)),
this, SLOT(rightClickLegendMenu(QListViewItem *, const QPoint &, int)));
connect(mMapLegend, SIGNAL(zOrderChanged(QgsLegend *)), mMapCanvas, SLOT(setZOrderFromLegend(QgsLegend *)));
connect(mMapLegend, SIGNAL(zOrderChanged(QgsLegend *)), this, SLOT(setOverviewZOrder(QgsLegend *)));
connect(mMapLegend, SIGNAL(currentChanged(QListViewItem *)), this, SLOT(currentLayerChanged(QListViewItem *)));
// add the whats this toolbar button
@ -3087,3 +3088,47 @@ void QgisApp::setLayerOverviewStatus(QString theLayerId, bool theVisibilityFlag)
std::cout << " Removed layer " << theLayerId << " from overview map" << std::endl;
}
}
void QgisApp::setOverviewZOrder(QgsLegend * lv)
{
#ifdef QGISDEBUG
std::cout << " Resetting z-order of overview map" << std::endl;
#endif
//we must clear the overview canvas first to ensure layers are added again
//in the correect order!
mOverviewCanvas->clear();
mOverviewCanvas->freeze(false);
QListViewItemIterator it(lv);
std::vector<QString> myOverviewLayerVector;
/** Move to the end of the list first, making sure all layers are removed as we go */
while (it.current())
{
QgsLegendItem *li = (QgsLegendItem *) it.current();
QgsMapLayer *lyr = li->layer();
QString myLayerId = lyr->getLayerID();
mOverviewCanvas->remove(myLayerId);
#ifdef QGISDEBUG
std::cout << " Removed layer " << myLayerId << " from overview map" << std::endl;
#endif
myOverviewLayerVector.push_back(myLayerId);
++it;
}
std::vector<QString>::reverse_iterator myIterator=myOverviewLayerVector.rbegin();
while (myIterator != myOverviewLayerVector.rend())
{
QgsMapLayer *lyr = mMapLayerRegistry->mapLayer(*myIterator);
if (lyr->showInOverviewStatus())
{
mOverviewCanvas->addLayer(lyr);
#ifdef QGISDEBUG
std::cout << " Added layer " << *myIterator << " to overview map" << std::endl;
#endif
}
myIterator++;
}
mOverviewCanvas->render();
mOverviewCanvas->zoomFullExtent();
mOverviewCanvas->refresh();
}

View File

@ -148,7 +148,6 @@ private:
bool isValidVectorFileName (QString theFileNameQString);
/** Overloaded version of the above function provided for convenience that takes a qstring pointer */
bool isValidVectorFileName (QString * theFileNameQString);
#ifdef HAVE_POSTGRESQL
//! Add a databaselayer to the map
void addDatabaseLayer();
@ -265,6 +264,8 @@ private slots:
//! Set project properties, including map untis
void projectProperties();
/* void urlData(); */
/** Used to (re)set the zordering of the overview map*/
void setOverviewZOrder(QgsLegend * );
public slots:
void showProgress(int theProgress, int theTotalSteps);
void showExtents(QgsRect theExtents);