mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
keep extent of overview set to union of extents of layer in overview; dont shrink on resize; fixes #1788
This commit is contained in:
parent
fad5cf3f20
commit
2613cf6ad5
@ -26,7 +26,7 @@ class QgsMapOverviewCanvas : QWidget
|
||||
|
||||
void enableAntiAliasing( bool flag );
|
||||
|
||||
void updateFullExtent( const QgsRectangle& rect );
|
||||
void updateFullExtent();
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -265,45 +265,48 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
|
||||
bool layerSetChanged = layerSetOld != layerSet;
|
||||
|
||||
// update only if needed
|
||||
if ( !layerSetChanged )
|
||||
return;
|
||||
|
||||
QgsDebugMsg( "Layer changed to: " + layerSet.join( ", " ) );
|
||||
|
||||
for ( i = 0; i < layerCount(); i++ )
|
||||
if ( layerSetChanged )
|
||||
{
|
||||
// Add check if vector layer when disconnecting from selectionChanged slot
|
||||
// Ticket #811 - racicot
|
||||
QgsMapLayer *currentLayer = layer( i );
|
||||
disconnect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) );
|
||||
disconnect( currentLayer, SIGNAL( screenUpdateRequested() ), this, SLOT( updateMap() ) );
|
||||
QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer );
|
||||
if ( isVectLyr )
|
||||
{
|
||||
disconnect( currentLayer, SIGNAL( selectionChanged() ), this, SLOT( selectionChangedSlot() ) );
|
||||
}
|
||||
}
|
||||
QgsDebugMsg( "Layers changed to: " + layerSet.join( ", " ) );
|
||||
|
||||
mMapRenderer->setLayerSet( layerSet );
|
||||
|
||||
for ( i = 0; i < layerCount(); i++ )
|
||||
{
|
||||
// Add check if vector layer when connecting to selectionChanged slot
|
||||
// Ticket #811 - racicot
|
||||
QgsMapLayer *currentLayer = layer( i );
|
||||
connect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) );
|
||||
connect( currentLayer, SIGNAL( screenUpdateRequested() ), this, SLOT( updateMap() ) );
|
||||
QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer );
|
||||
if ( isVectLyr )
|
||||
for ( i = 0; i < layerCount(); i++ )
|
||||
{
|
||||
connect( currentLayer, SIGNAL( selectionChanged() ), this, SLOT( selectionChangedSlot() ) );
|
||||
// Add check if vector layer when disconnecting from selectionChanged slot
|
||||
// Ticket #811 - racicot
|
||||
QgsMapLayer *currentLayer = layer( i );
|
||||
disconnect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) );
|
||||
disconnect( currentLayer, SIGNAL( screenUpdateRequested() ), this, SLOT( updateMap() ) );
|
||||
QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer );
|
||||
if ( isVectLyr )
|
||||
{
|
||||
disconnect( currentLayer, SIGNAL( selectionChanged() ), this, SLOT( selectionChangedSlot() ) );
|
||||
}
|
||||
}
|
||||
|
||||
mMapRenderer->setLayerSet( layerSet );
|
||||
|
||||
for ( i = 0; i < layerCount(); i++ )
|
||||
{
|
||||
// Add check if vector layer when connecting to selectionChanged slot
|
||||
// Ticket #811 - racicot
|
||||
QgsMapLayer *currentLayer = layer( i );
|
||||
connect( currentLayer, SIGNAL( repaintRequested() ), this, SLOT( refresh() ) );
|
||||
connect( currentLayer, SIGNAL( screenUpdateRequested() ), this, SLOT( updateMap() ) );
|
||||
QgsVectorLayer *isVectLyr = qobject_cast<QgsVectorLayer *>( currentLayer );
|
||||
if ( isVectLyr )
|
||||
{
|
||||
connect( currentLayer, SIGNAL( selectionChanged() ), this, SLOT( selectionChangedSlot() ) );
|
||||
}
|
||||
}
|
||||
|
||||
QgsDebugMsg( "Layers have changed, refreshing" );
|
||||
emit layersChanged();
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
if ( mMapOverview )
|
||||
{
|
||||
mMapOverview->updateFullExtent( fullExtent() );
|
||||
|
||||
QStringList& layerSetOvOld = mMapOverview->layerSet();
|
||||
if ( layerSetOvOld != layerSetOverview )
|
||||
{
|
||||
@ -314,12 +317,6 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
|
||||
// because full extent might have changed
|
||||
updateOverview();
|
||||
}
|
||||
|
||||
QgsDebugMsg( "Layers have changed, refreshing" );
|
||||
emit layersChanged();
|
||||
|
||||
refresh();
|
||||
|
||||
} // setLayerSet
|
||||
|
||||
void QgsMapCanvas::enableOverviewMode( QgsMapOverviewCanvas* overview )
|
||||
@ -514,11 +511,6 @@ void QgsMapCanvas::updateFullExtent()
|
||||
QgsDebugMsg( "updating full extent" );
|
||||
|
||||
mMapRenderer->updateFullExtent();
|
||||
if ( mMapOverview )
|
||||
{
|
||||
mMapOverview->updateFullExtent( fullExtent() );
|
||||
updateOverview();
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ void QgsMapOverviewCanvas::paintEvent( QPaintEvent* pe )
|
||||
{
|
||||
mPixmap = QPixmap( mNewSize );
|
||||
mMapRenderer->setOutputSize( mNewSize, mPixmap.logicalDpiX() );
|
||||
updateFullExtent();
|
||||
mNewSize = QSize();
|
||||
refresh();
|
||||
}
|
||||
@ -106,10 +107,12 @@ void QgsMapOverviewCanvas::paintEvent( QPaintEvent* pe )
|
||||
|
||||
void QgsMapOverviewCanvas::drawExtentRect()
|
||||
{
|
||||
if ( !mMapCanvas || !mMapRenderer ) return;
|
||||
|
||||
const QgsRectangle& extent = mMapCanvas->extent();
|
||||
|
||||
// show only when valid extent is set
|
||||
if ( extent.isEmpty() )
|
||||
if ( extent.isEmpty() || mMapRenderer->extent().isEmpty() )
|
||||
{
|
||||
mPanningWidget->hide();
|
||||
return;
|
||||
@ -290,11 +293,23 @@ void QgsMapOverviewCanvas::setBackgroundColor( const QColor& color )
|
||||
|
||||
void QgsMapOverviewCanvas::setLayerSet( const QStringList& layerSet )
|
||||
{
|
||||
QgsDebugMsg( "layerSet: " + layerSet.join( ", " ) );
|
||||
if ( !mMapRenderer ) return;
|
||||
mMapRenderer->setLayerSet( layerSet );
|
||||
mMapRenderer->updateFullExtent();
|
||||
updateFullExtent();
|
||||
}
|
||||
|
||||
void QgsMapOverviewCanvas::updateFullExtent( const QgsRectangle& rect )
|
||||
void QgsMapOverviewCanvas::updateFullExtent()
|
||||
{
|
||||
if ( !mMapRenderer ) return;
|
||||
QgsRectangle rect;
|
||||
if ( !mMapRenderer->layerSet().isEmpty() )
|
||||
{
|
||||
rect = mMapRenderer->fullExtent();
|
||||
// expand a bit to keep features on margin
|
||||
rect.scale( 1.1 );
|
||||
}
|
||||
mMapRenderer->setExtent( rect );
|
||||
drawExtentRect();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
|
||||
|
||||
void enableAntiAliasing( bool flag ) { mAntiAliasing = flag; }
|
||||
|
||||
void updateFullExtent( const QgsRectangle& rect );
|
||||
void updateFullExtent();
|
||||
|
||||
public slots:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user