mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04: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 enableAntiAliasing( bool flag );
|
||||||
|
|
||||||
void updateFullExtent( const QgsRectangle& rect );
|
void updateFullExtent();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@ -265,45 +265,48 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
|
|||||||
bool layerSetChanged = layerSetOld != layerSet;
|
bool layerSetChanged = layerSetOld != layerSet;
|
||||||
|
|
||||||
// update only if needed
|
// update only if needed
|
||||||
if ( !layerSetChanged )
|
if ( layerSetChanged )
|
||||||
return;
|
|
||||||
|
|
||||||
QgsDebugMsg( "Layer changed to: " + layerSet.join( ", " ) );
|
|
||||||
|
|
||||||
for ( i = 0; i < layerCount(); i++ )
|
|
||||||
{
|
{
|
||||||
// Add check if vector layer when disconnecting from selectionChanged slot
|
QgsDebugMsg( "Layers changed to: " + layerSet.join( ", " ) );
|
||||||
// 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++ )
|
||||||
|
|
||||||
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() ) );
|
// 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 )
|
if ( mMapOverview )
|
||||||
{
|
{
|
||||||
mMapOverview->updateFullExtent( fullExtent() );
|
|
||||||
|
|
||||||
QStringList& layerSetOvOld = mMapOverview->layerSet();
|
QStringList& layerSetOvOld = mMapOverview->layerSet();
|
||||||
if ( layerSetOvOld != layerSetOverview )
|
if ( layerSetOvOld != layerSetOverview )
|
||||||
{
|
{
|
||||||
@ -314,12 +317,6 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
|
|||||||
// because full extent might have changed
|
// because full extent might have changed
|
||||||
updateOverview();
|
updateOverview();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsDebugMsg( "Layers have changed, refreshing" );
|
|
||||||
emit layersChanged();
|
|
||||||
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
} // setLayerSet
|
} // setLayerSet
|
||||||
|
|
||||||
void QgsMapCanvas::enableOverviewMode( QgsMapOverviewCanvas* overview )
|
void QgsMapCanvas::enableOverviewMode( QgsMapOverviewCanvas* overview )
|
||||||
@ -514,11 +511,6 @@ void QgsMapCanvas::updateFullExtent()
|
|||||||
QgsDebugMsg( "updating full extent" );
|
QgsDebugMsg( "updating full extent" );
|
||||||
|
|
||||||
mMapRenderer->updateFullExtent();
|
mMapRenderer->updateFullExtent();
|
||||||
if ( mMapOverview )
|
|
||||||
{
|
|
||||||
mMapOverview->updateFullExtent( fullExtent() );
|
|
||||||
updateOverview();
|
|
||||||
}
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ void QgsMapOverviewCanvas::paintEvent( QPaintEvent* pe )
|
|||||||
{
|
{
|
||||||
mPixmap = QPixmap( mNewSize );
|
mPixmap = QPixmap( mNewSize );
|
||||||
mMapRenderer->setOutputSize( mNewSize, mPixmap.logicalDpiX() );
|
mMapRenderer->setOutputSize( mNewSize, mPixmap.logicalDpiX() );
|
||||||
|
updateFullExtent();
|
||||||
mNewSize = QSize();
|
mNewSize = QSize();
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
@ -106,10 +107,12 @@ void QgsMapOverviewCanvas::paintEvent( QPaintEvent* pe )
|
|||||||
|
|
||||||
void QgsMapOverviewCanvas::drawExtentRect()
|
void QgsMapOverviewCanvas::drawExtentRect()
|
||||||
{
|
{
|
||||||
|
if ( !mMapCanvas || !mMapRenderer ) return;
|
||||||
|
|
||||||
const QgsRectangle& extent = mMapCanvas->extent();
|
const QgsRectangle& extent = mMapCanvas->extent();
|
||||||
|
|
||||||
// show only when valid extent is set
|
// show only when valid extent is set
|
||||||
if ( extent.isEmpty() )
|
if ( extent.isEmpty() || mMapRenderer->extent().isEmpty() )
|
||||||
{
|
{
|
||||||
mPanningWidget->hide();
|
mPanningWidget->hide();
|
||||||
return;
|
return;
|
||||||
@ -290,11 +293,23 @@ void QgsMapOverviewCanvas::setBackgroundColor( const QColor& color )
|
|||||||
|
|
||||||
void QgsMapOverviewCanvas::setLayerSet( const QStringList& layerSet )
|
void QgsMapOverviewCanvas::setLayerSet( const QStringList& layerSet )
|
||||||
{
|
{
|
||||||
|
QgsDebugMsg( "layerSet: " + layerSet.join( ", " ) );
|
||||||
|
if ( !mMapRenderer ) return;
|
||||||
mMapRenderer->setLayerSet( layerSet );
|
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 );
|
mMapRenderer->setExtent( rect );
|
||||||
drawExtentRect();
|
drawExtentRect();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget
|
|||||||
|
|
||||||
void enableAntiAliasing( bool flag ) { mAntiAliasing = flag; }
|
void enableAntiAliasing( bool flag ) { mAntiAliasing = flag; }
|
||||||
|
|
||||||
void updateFullExtent( const QgsRectangle& rect );
|
void updateFullExtent();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user