Skip to content

Commit

Permalink
add transform context to the map overview
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Feb 1, 2018
1 parent 247ea02 commit 1ac6792
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
19 changes: 11 additions & 8 deletions python/gui/qgsmapoverviewcanvas.sip.in
Expand Up @@ -48,7 +48,15 @@ Returns list of layers visible in the overview

void updateFullExtent();

public slots:
protected slots:
void mapRenderingFinished();

void layerRepaintRequested( bool deferred = false );
%Docstring
Triggered when a layer in the overview requests a repaint.
%End

protected:

void drawExtentRect();
%Docstring
Expand All @@ -60,16 +68,11 @@ used for overview canvas to reflect changed extent in main map canvas
Should be called when the canvas destination CRS is changed
%End

protected slots:
void mapRenderingFinished();

void layerRepaintRequested( bool deferred = false );
void transformContextChanged();
%Docstring
Triggered when a layer in the overview requests a repaint.
Called when the canvas transform context is changed
%End

protected:

virtual void paintEvent( QPaintEvent *pe );

%Docstring
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsmapoverviewcanvas.cpp
Expand Up @@ -40,10 +40,12 @@ QgsMapOverviewCanvas::QgsMapOverviewCanvas( QWidget *parent, QgsMapCanvas *mapCa
setObjectName( QStringLiteral( "theOverviewCanvas" ) );
mPanningWidget = new QgsPanningWidget( this );

mSettings.setTransformContext( mMapCanvas->mapSettings().transformContext() );
mSettings.setFlag( QgsMapSettings::DrawLabeling, false );

connect( mMapCanvas, &QgsMapCanvas::extentsChanged, this, &QgsMapOverviewCanvas::drawExtentRect );
connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsMapOverviewCanvas::destinationCrsChanged );
connect( mMapCanvas, &QgsMapCanvas::transformContextChanged, this, &QgsMapOverviewCanvas::transformContextChanged );
}

void QgsMapOverviewCanvas::resizeEvent( QResizeEvent *e )
Expand Down Expand Up @@ -262,6 +264,11 @@ void QgsMapOverviewCanvas::destinationCrsChanged()
mSettings.setDestinationCrs( mMapCanvas->mapSettings().destinationCrs() );
}

void QgsMapOverviewCanvas::transformContextChanged()
{
mSettings.setTransformContext( mMapCanvas->mapSettings().transformContext() );
}

QList<QgsMapLayer *> QgsMapOverviewCanvas::layers() const
{
return mSettings.layers();
Expand Down
19 changes: 9 additions & 10 deletions src/gui/qgsmapoverviewcanvas.h
Expand Up @@ -61,16 +61,6 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget

void updateFullExtent();

public slots:

// ### QGIS 3: make protected
//! used for overview canvas to reflect changed extent in main map canvas
void drawExtentRect();

// ### QGIS 3: make protected
//! Should be called when the canvas destination CRS is changed
void destinationCrsChanged();

protected slots:
void mapRenderingFinished();

Expand All @@ -81,6 +71,15 @@ class GUI_EXPORT QgsMapOverviewCanvas : public QWidget

protected:

//! used for overview canvas to reflect changed extent in main map canvas
void drawExtentRect();

//! Should be called when the canvas destination CRS is changed
void destinationCrsChanged();

//! Called when the canvas transform context is changed
void transformContextChanged();

//! Overridden paint event
void paintEvent( QPaintEvent *pe ) override;

Expand Down

0 comments on commit 1ac6792

Please sign in to comment.