Skip to content
Permalink
Browse files

lazily determine full canvas extent

  • Loading branch information
jef-n committed Mar 3, 2016
1 parent f722bb2 commit c87529e3934791c8d64ab442ab10c71b0a5e782f
Showing with 22 additions and 10 deletions.
  1. +10 −10 src/core/qgsmaprenderer.cpp
  2. +9 −0 src/gui/qgsmapoverviewcanvas.cpp
  3. +3 −0 src/gui/qgsmapoverviewcanvas.h
@@ -58,6 +58,7 @@ QgsMapRenderer::QgsMapRenderer()
mDestCRS = new QgsCoordinateReferenceSystem( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId ); //WGS 84

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

mLabelingEngine = nullptr;
}
@@ -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
@@ -993,11 +998,7 @@ void QgsMapRenderer::updateFullExtent()
}

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

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

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


bool QgsMapRenderer::readXML( QDomNode & theNode )
{
QgsMapSettings tmpSettings;
@@ -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() )
@@ -155,6 +161,9 @@ void QgsMapOverviewCanvas::updatePanningWidget( QPoint pos )

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

updateFullExtent();

if ( !mSettings.hasValidSettings() )
@@ -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;

0 comments on commit c87529e

Please sign in to comment.
You can’t perform that action at this time.