Skip to content

Commit c87529e

Browse files
committedMar 3, 2016
lazily determine full canvas extent
1 parent f722bb2 commit c87529e

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed
 

‎src/core/qgsmaprenderer.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ QgsMapRenderer::QgsMapRenderer()
5858
mDestCRS = new QgsCoordinateReferenceSystem( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId ); //WGS 84
5959

6060
mOutputUnits = QgsMapRenderer::Millimeters;
61+
mFullExtent.setMinimal();
6162

6263
mLabelingEngine = nullptr;
6364
}
@@ -928,15 +929,19 @@ QgsRectangle QgsMapRenderer::mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRe
928929
return rect;
929930
}
930931

931-
932932
void QgsMapRenderer::updateFullExtent()
933+
{
934+
mFullExtent.setMinimal();
935+
}
936+
937+
QgsRectangle QgsMapRenderer::fullExtent()
933938
{
934939
QgsDebugMsg( "called." );
935-
QgsMapLayerRegistry* registry = QgsMapLayerRegistry::instance();
936940

937-
// reset the map canvas extent since the extent may now be smaller
938-
// We can't use a constructor since QgsRectangle normalizes the rectangle upon construction
939-
mFullExtent.setMinimal();
941+
if ( !mFullExtent.isNull() )
942+
return mFullExtent;
943+
944+
QgsMapLayerRegistry* registry = QgsMapLayerRegistry::instance();
940945

941946
// iterate through the map layers and test each layers extent
942947
// against the current min and max values
@@ -993,11 +998,7 @@ void QgsMapRenderer::updateFullExtent()
993998
}
994999

9951000
QgsDebugMsg( "Full extent: " + mFullExtent.toString() );
996-
}
9971001

998-
QgsRectangle QgsMapRenderer::fullExtent()
999-
{
1000-
updateFullExtent();
10011002
return mFullExtent;
10021003
}
10031004

@@ -1013,7 +1014,6 @@ QStringList& QgsMapRenderer::layerSet()
10131014
return mLayerSet;
10141015
}
10151016

1016-
10171017
bool QgsMapRenderer::readXML( QDomNode & theNode )
10181018
{
10191019
QgsMapSettings tmpSettings;

‎src/gui/qgsmapoverviewcanvas.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ void QgsMapOverviewCanvas::resizeEvent( QResizeEvent* e )
6262
QWidget::resizeEvent( e );
6363
}
6464

65+
void QgsMapOverviewCanvas::showEvent( QShowEvent* e )
66+
{
67+
refresh();
68+
QWidget::showEvent( e );
69+
}
70+
6571
void QgsMapOverviewCanvas::paintEvent( QPaintEvent* pe )
6672
{
6773
if ( !mPixmap.isNull() )
@@ -155,6 +161,9 @@ void QgsMapOverviewCanvas::updatePanningWidget( QPoint pos )
155161

156162
void QgsMapOverviewCanvas::refresh()
157163
{
164+
if ( !isVisible() )
165+
return;
166+
158167
updateFullExtent();
159168

160169
if ( !mSettings.hasValidSettings() )

‎src/gui/qgsmapoverviewcanvas.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
8181
//! Overridden paint event
8282
void paintEvent( QPaintEvent * pe ) override;
8383

84+
//! Overridden show event
85+
void showEvent( QShowEvent * e ) override;
86+
8487
//! Overridden resize event
8588
void resizeEvent( QResizeEvent * e ) override;
8689

0 commit comments

Comments
 (0)
Please sign in to comment.