Skip to content

Commit 6d09a3c

Browse files
author
wonder
committed
Fixed map overview handling
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6971 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 22f5769 commit 6d09a3c

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

python/gui/qgsmapoverviewcanvas.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class QgsMapOverviewCanvas : QWidget
2626

2727
void enableAntiAliasing(bool flag);
2828

29-
void updateFullExtent();
29+
void updateFullExtent(const QgsRect& rect);
3030

3131
public slots:
3232

src/gui/qgsmapcanvas.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,17 @@ void QgsMapCanvas::setLayerSet(QList<QgsMapCanvasLayer>& layers)
263263

264264
if (mMapOverview)
265265
{
266+
mMapOverview->updateFullExtent(fullExtent());
267+
266268
QStringList& layerSetOvOld = mMapOverview->layerSet();
267269
if (layerSetOvOld != layerSetOverview)
268270
{
269271
mMapOverview->setLayerSet(layerSetOverview);
270-
updateOverview();
271272
}
273+
274+
// refresh overview maplayers even if layer set is the same
275+
// because full extent might have changed
276+
updateOverview();
272277
}
273278

274279
if (layerSetChanged)
@@ -404,8 +409,7 @@ void QgsMapCanvas::updateFullExtent()
404409
mMapRender->updateFullExtent();
405410
if (mMapOverview)
406411
{
407-
mMapOverview->updateFullExtent();
408-
mMapOverview->reflectChangedExtent();
412+
mMapOverview->updateFullExtent(fullExtent());
409413
updateOverview();
410414
}
411415
refresh();
@@ -414,6 +418,11 @@ void QgsMapCanvas::updateFullExtent()
414418

415419
void QgsMapCanvas::setExtent(QgsRect const & r)
416420
{
421+
if (r.isEmpty())
422+
{
423+
QgsDebugMsg("Setting empty extent!");
424+
}
425+
417426
QgsRect current = extent();
418427
mMapRender->setExtent(r);
419428
emit extentsChanged();

src/gui/qgsmapoverviewcanvas.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ void QgsMapOverviewCanvas::reflectChangedExtent()
9595
// show only when valid extent is set
9696
if (extent.isEmpty())
9797
{
98-
#ifdef QGISDEBUG
99-
std::cout << "panning: empty extent" << std::endl;
100-
#endif
10198
mPanningWidget->hide();
10299
return;
103100
}
@@ -246,7 +243,6 @@ void QgsMapOverviewCanvas::refresh()
246243
painter.setRenderHint(QPainter::Antialiasing);
247244

248245
// render image
249-
mMapRender->setExtent(mMapCanvas->fullExtent());
250246
mMapRender->render(&painter);
251247

252248
painter.end();
@@ -274,9 +270,10 @@ void QgsMapOverviewCanvas::setLayerSet(const QStringList& layerSet)
274270
mMapRender->setLayerSet(layerSet);
275271
}
276272

277-
void QgsMapOverviewCanvas::updateFullExtent()
273+
void QgsMapOverviewCanvas::updateFullExtent(const QgsRect& rect)
278274
{
279-
mMapRender->updateFullExtent();
275+
mMapRender->setExtent(rect);
276+
reflectChangedExtent();
280277
}
281278

282279
void QgsMapOverviewCanvas::projectionsEnabled(bool flag)

src/gui/qgsmapoverviewcanvas.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
class QgsMapCanvas;
3131
class QgsMapRender;
3232
class QgsPanningWidget; // defined in .cpp
33+
class QgsRect;
3334

3435
class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
3536
{
@@ -56,7 +57,7 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
5657

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

59-
void updateFullExtent();
60+
void updateFullExtent(const QgsRect& rect);
6061

6162
public slots:
6263

0 commit comments

Comments
 (0)