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(); 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(); void drawExtentRect();
%Docstring %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 Should be called when the canvas destination CRS is changed
%End %End


protected slots: void transformContextChanged();
void mapRenderingFinished();

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


protected:

virtual void paintEvent( QPaintEvent *pe ); virtual void paintEvent( QPaintEvent *pe );


%Docstring %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" ) ); setObjectName( QStringLiteral( "theOverviewCanvas" ) );
mPanningWidget = new QgsPanningWidget( this ); mPanningWidget = new QgsPanningWidget( this );


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


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


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


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

QList<QgsMapLayer *> QgsMapOverviewCanvas::layers() const QList<QgsMapLayer *> QgsMapOverviewCanvas::layers() const
{ {
return mSettings.layers(); 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(); 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: protected slots:
void mapRenderingFinished(); void mapRenderingFinished();


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


protected: 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 //! Overridden paint event
void paintEvent( QPaintEvent *pe ) override; void paintEvent( QPaintEvent *pe ) override;


Expand Down

0 comments on commit 1ac6792

Please sign in to comment.