Logo Search packages:      
Sourcecode: qgis version File versions

void QgisApp::setOverviewZOrder ( QgsLegend lv  )  [private, slot]

Used to (re)set the zordering of the overview map

Move to the end of the list first, making sure all layers are removed as we go

Definition at line 3709 of file qgisapp.cpp.

References QgsMapCanvas::addLayer(), QgsMapCanvas::clear(), QgsProject::dirty(), QgsMapCanvas::freeze(), QgsMapCanvas::fullExtent(), QgsMapLayer::getLayerID(), QgsProject::instance(), QgsMapLayerRegistry::instance(), QgsLegendItem::layer(), QgsMapLayerRegistry::mapLayer(), mMapCanvas, mOverviewCanvas, QgsMapCanvas::remove(), QgsMapCanvas::setExtent(), QgsMapLayer::showInOverviewStatus(), and QgsMapCanvas::zoomFullExtent().

Referenced by QgisApp().

{
#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 = QgsMapLayerRegistry::instance()->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();
    // set the extents of the overview to match the mapcanvas
    mOverviewCanvas->setExtent(mMapCanvas->fullExtent());
    //mOverviewCanvas->refresh();

    // notify the project we've made a change
    QgsProject::instance()->dirty(true);
}


Generated by  Doxygen 1.6.0   Back to index