Skip to content

Commit

Permalink
Changed deque<QString> to QStringList in QgsMapRender, updated canvas…
Browse files Browse the repository at this point in the history
… and bindings appropriately.

git-svn-id: http://svn.osgeo.org/qgis/trunk@6749 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Mar 3, 2007
1 parent 82eb679 commit 9533cb2
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 50 deletions.
9 changes: 2 additions & 7 deletions python/core/qgsmaprender.sip
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,10 @@ class QgsMapRender : QObject
QgsRect fullExtent();

//! returns current layer set
// TODO: wrap
//std::deque<QString>& layerSet();
QStringList& layerSet();

//! change current layer set
// TODO: wrap
//void setLayerSet(const std::deque<QString>& layers);

//!Overloaded version of above menthod to change current layer set
void setLayerSet(const QStringList layers);
void setLayerSet(const QStringList& layers);

//! updates extent of the layer set
void updateFullExtent();
Expand Down
4 changes: 2 additions & 2 deletions python/gui/qgsmapoverviewcanvas.sip
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class QgsMapOverviewCanvas : QWidget
void setbgColor(const QColor& color);

//! updates layer set for overview
// TODO void setLayerSet(std::deque<QString>& layerSet);
void setLayerSet(const QStringList& layerSet);

// TODO std::deque<QString>& layerSet();
QStringList& layerSet();

void enableAntiAliasing(bool flag);

Expand Down
41 changes: 17 additions & 24 deletions src/core/qgsmaprender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,14 @@ void QgsMapRender::render(QPainter* painter)
#endif

// render all layers in the stack, starting at the base
std::deque<QString>::reverse_iterator li = mLayerSet.rbegin();
QListIterator<QString> li(mLayerSet);
li.toBack();

while (li != mLayerSet.rend())
while (li.hasPrevious())
{
QgsDebugMsg("Rendering at layer item " + (*li));
QString layerId = li.previous();

QgsDebugMsg("Rendering at layer item " + layerId);

// This call is supposed to cause the progress bar to
// advance. However, it seems that updating the progress bar is
Expand All @@ -228,12 +231,11 @@ void QgsMapRender::render(QPainter* painter)
QgsDebugMsg("If there is a QPaintEngine error here, it is caused by an emit call");

//emit drawingProgress(myRenderCounter++, mLayerSet.size());
QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer(*li);
QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer(layerId);

if (!ml)
{
QgsLogger::warning("Layer not found in registry!");
li++;
continue;
}

Expand Down Expand Up @@ -283,20 +285,20 @@ void QgsMapRender::render(QPainter* painter)
"visibility scale range");
}

li++;

} // while (li != end)
} // while (li.hasPrevious())

QgsDebugMsg("Done rendering map layers");

if (!mOverview)
{
// render all labels for vector layers in the stack, starting at the base
li = mLayerSet.rbegin();
while (li != mLayerSet.rend())
li.toBack();
while (li.hasPrevious())
{
QString layerId = li.previous();

// TODO: emit drawingProgress((myRenderCounter++),zOrder.size());
QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer(*li);
QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer(layerId);

if (ml && (ml->type() != QgsMapLayer::RASTER))
{
Expand Down Expand Up @@ -324,7 +326,6 @@ void QgsMapRender::render(QPainter* painter)
delete ct;
}
}
li++;
}
} // if (!mOverview)

Expand Down Expand Up @@ -555,7 +556,7 @@ void QgsMapRender::updateFullExtent()

// iterate through the map layers and test each layers extent
// against the current min and max values
std::deque<QString>::iterator it = mLayerSet.begin();
QStringList::iterator it = mLayerSet.begin();
while(it != mLayerSet.end())
{
QgsMapLayer * lyr = registry->mapLayer(*it);
Expand Down Expand Up @@ -587,25 +588,17 @@ QgsRect QgsMapRender::fullExtent()
return mFullExtent;
}

void QgsMapRender::setLayerSet(const std::deque<QString>& layers)
void QgsMapRender::setLayerSet(const QStringList& layers)
{
mLayerSet = layers;
updateFullExtent();
}

void QgsMapRender::setLayerSet(const QStringList layers)
QStringList& QgsMapRender::layerSet()
{
//convert the stringlist to a deque
QListIterator<QString> i(layers);
mLayerSet.clear();
while (i.hasNext())
{
mLayerSet.push_back(i.next());
}
updateFullExtent();
return mLayerSet;
}


bool QgsMapRender::readXML(QDomNode & theNode)
{
QDomNode myNode = theNode.namedItem("units");
Expand Down
11 changes: 3 additions & 8 deletions src/core/qgsmaprender.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#ifndef QGSMAPRENDER_H
#define QGSMAPRENDER_H

#include <deque>
#include <QString>
#include <QStringList>

#include "qgis.h"
Expand Down Expand Up @@ -107,13 +105,10 @@ class CORE_EXPORT QgsMapRender : public QObject
QgsRect fullExtent();

//! returns current layer set
std::deque<QString>& layerSet() { return mLayerSet; }
QStringList& layerSet();

//! change current layer set
void setLayerSet(const std::deque<QString>& layers);

//!Overloaded version of above menthod to change current layer set
void setLayerSet(const QStringList layers);
void setLayerSet(const QStringList& layers);

//! updates extent of the layer set
void updateFullExtent();
Expand Down Expand Up @@ -189,7 +184,7 @@ class CORE_EXPORT QgsMapRender : public QObject
QgsSpatialRefSys* mDestSRS;

//! stores array of layers to be rendered (identified by string)
std::deque<QString> mLayerSet;
QStringList mLayerSet;

//! full extent of the layer set
QgsRect mFullExtent;
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ QgsMapRender* QgsMapCanvas::mapRender()

QgsMapLayer* QgsMapCanvas::getZpos(int index)
{
std::deque<QString>& layers = mMapRender->layerSet();
QStringList& layers = mMapRender->layerSet();
if (index >= 0 && index < (int) layers.size())
return QgsMapLayerRegistry::instance()->mapLayer(layers[index]);
else
Expand Down Expand Up @@ -223,7 +223,7 @@ void QgsMapCanvas::setLayerSet(QList<QgsMapCanvasLayer>& layers)
int i;

// create layer set
std::deque<QString> layerSet, layerSetOverview;
QStringList layerSet, layerSetOverview;

for (i = 0; i < layers.size(); i++)
{
Expand All @@ -238,7 +238,7 @@ void QgsMapCanvas::setLayerSet(QList<QgsMapCanvasLayer>& layers)
}
}

std::deque<QString>& layerSetOld = mMapRender->layerSet();
QStringList& layerSetOld = mMapRender->layerSet();

bool layerSetChanged = (layerSetOld != layerSet);

Expand All @@ -263,7 +263,7 @@ void QgsMapCanvas::setLayerSet(QList<QgsMapCanvasLayer>& layers)

if (mMapOverview)
{
std::deque<QString>& layerSetOvOld = mMapOverview->layerSet();
QStringList& layerSetOvOld = mMapOverview->layerSet();
if (layerSetOvOld != layerSetOverview)
{
mMapOverview->setLayerSet(layerSetOverview);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmapoverviewcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void QgsMapOverviewCanvas::setbgColor(const QColor& color)
setPalette(palette);
}

void QgsMapOverviewCanvas::setLayerSet(std::deque<QString>& layerSet)
void QgsMapOverviewCanvas::setLayerSet(const QStringList& layerSet)
{
mMapRender->setLayerSet(layerSet);
}
Expand All @@ -290,7 +290,7 @@ void QgsMapOverviewCanvas::destinationSrsChanged()
mMapRender->setDestinationSrs(srs);
}

std::deque<QString>& QgsMapOverviewCanvas::layerSet()
QStringList& QgsMapOverviewCanvas::layerSet()
{
return mMapRender->layerSet();
}
6 changes: 3 additions & 3 deletions src/gui/qgsmapoverviewcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <QMouseEvent>
#include <QWheelEvent>
#include <QWidget>
#include <deque>
#include <QStringList>
#include <QPixmap>

class QgsMapCanvas;
Expand All @@ -50,9 +50,9 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
void setbgColor(const QColor& color);

//! updates layer set for overview
void setLayerSet(std::deque<QString>& layerSet);
void setLayerSet(const QStringList& layerSet);

std::deque<QString>& layerSet();
QStringList& layerSet();

void enableAntiAliasing(bool flag) { mAntiAliasing = flag; }

Expand Down

0 comments on commit 9533cb2

Please sign in to comment.