Skip to content

Commit

Permalink
lazily determine full canvas extent
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Mar 3, 2016
1 parent f722bb2 commit c87529e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/core/qgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ QgsMapRenderer::QgsMapRenderer()
mDestCRS = new QgsCoordinateReferenceSystem( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId ); //WGS 84

mOutputUnits = QgsMapRenderer::Millimeters;
mFullExtent.setMinimal();

mLabelingEngine = nullptr;
}
Expand Down Expand Up @@ -928,15 +929,19 @@ QgsRectangle QgsMapRenderer::mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRe
return rect;
}


void QgsMapRenderer::updateFullExtent()
{
mFullExtent.setMinimal();
}

QgsRectangle QgsMapRenderer::fullExtent()
{
QgsDebugMsg( "called." );
QgsMapLayerRegistry* registry = QgsMapLayerRegistry::instance();

// reset the map canvas extent since the extent may now be smaller
// We can't use a constructor since QgsRectangle normalizes the rectangle upon construction
mFullExtent.setMinimal();
if ( !mFullExtent.isNull() )
return mFullExtent;

QgsMapLayerRegistry* registry = QgsMapLayerRegistry::instance();

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

QgsDebugMsg( "Full extent: " + mFullExtent.toString() );
}

QgsRectangle QgsMapRenderer::fullExtent()
{
updateFullExtent();
return mFullExtent;
}

Expand All @@ -1013,7 +1014,6 @@ QStringList& QgsMapRenderer::layerSet()
return mLayerSet;
}


bool QgsMapRenderer::readXML( QDomNode & theNode )
{
QgsMapSettings tmpSettings;
Expand Down
9 changes: 9 additions & 0 deletions src/gui/qgsmapoverviewcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ void QgsMapOverviewCanvas::resizeEvent( QResizeEvent* e )
QWidget::resizeEvent( e );
}

void QgsMapOverviewCanvas::showEvent( QShowEvent* e )
{
refresh();
QWidget::showEvent( e );
}

void QgsMapOverviewCanvas::paintEvent( QPaintEvent* pe )
{
if ( !mPixmap.isNull() )
Expand Down Expand Up @@ -155,6 +161,9 @@ void QgsMapOverviewCanvas::updatePanningWidget( QPoint pos )

void QgsMapOverviewCanvas::refresh()
{
if ( !isVisible() )
return;

updateFullExtent();

if ( !mSettings.hasValidSettings() )
Expand Down
3 changes: 3 additions & 0 deletions src/gui/qgsmapoverviewcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
//! Overridden paint event
void paintEvent( QPaintEvent * pe ) override;

//! Overridden show event
void showEvent( QShowEvent * e ) override;

//! Overridden resize event
void resizeEvent( QResizeEvent * e ) override;

Expand Down

0 comments on commit c87529e

Please sign in to comment.