Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
create a core interface for QgsMapCanvas
  • Loading branch information
3nids committed Nov 6, 2018
1 parent 5ae2bae commit 79c5b35
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 4 deletions.
42 changes: 42 additions & 0 deletions python/core/auto_generated/qgsmapcanvasinterface.sip.in
@@ -0,0 +1,42 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsmapcanvasinterface.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsMapCanvasInterface
{
%Docstring
The QgsMapCanvasInterface class provides a simple interface to access
core components of a map canvas.

.. versionadded:: 3.6
%End

%TypeHeaderCode
#include "qgsmapcanvasinterface.h"
%End
public:
explicit QgsMapCanvasInterface();
%Docstring
Constructor of QgsMapCanvasInterface
%End
virtual ~QgsMapCanvasInterface();

virtual const QgsMapSettings &mapSettings() const = 0 /KeepReference/;
%Docstring
Returns the map settings
%End
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsmapcanvasinterface.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -67,6 +67,7 @@
%Include auto_generated/qgslegendsettings.sip
%Include auto_generated/qgslegendstyle.sip
%Include auto_generated/qgslogger.sip
%Include auto_generated/qgsmapcanvasinterface.sip
%Include auto_generated/qgsmapdecoration.sip
%Include auto_generated/qgsmaphittest.sip
%Include auto_generated/qgsmaplayerdependency.sip
Expand Down
5 changes: 3 additions & 2 deletions python/gui/auto_generated/qgsmapcanvas.sip.in
Expand Up @@ -18,7 +18,7 @@



class QgsMapCanvas : QGraphicsView
class QgsMapCanvas : QGraphicsView, QgsMapCanvasInterface
{
%Docstring
Map canvas is a class for displaying all GIS data types on a canvas.
Expand Down Expand Up @@ -65,7 +65,8 @@ empty string before setLayers() calls can be made.

void setCurrentLayer( QgsMapLayer *layer );

const QgsMapSettings &mapSettings() const /KeepReference/;
virtual const QgsMapSettings &mapSettings() const ${SIP_FINAL} /KeepReference/;

%Docstring
Gets access to properties used for map rendering

Expand Down
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -888,6 +888,7 @@ SET(QGIS_CORE_HDRS
qgslegendsettings.h
qgslegendstyle.h
qgslogger.h
qgsmapcanvasinterface.h
qgsmapdecoration.h
qgsmaplayerref.h
qgsmaphittest.h
Expand Down
25 changes: 25 additions & 0 deletions src/core/qgsmapcanvasinterface.h
@@ -0,0 +1,25 @@
#ifndef QGSMAPCANVASINTERFACE_H
#define QGSMAPCANVASINTERFACE_H

#include "qgis_core.h"
#include "qgis_sip.h"

class QgsMapSettings;

/**
* The QgsMapCanvasInterface class provides a simple interface to access
* core components of a map canvas.
* \since QGIS 3.6
*/
class CORE_EXPORT QgsMapCanvasInterface
{
public:
//! Constructor of QgsMapCanvasInterface
explicit QgsMapCanvasInterface() = default;
virtual ~QgsMapCanvasInterface() = default;

//! Returns the map settings
virtual const QgsMapSettings &mapSettings() const = 0 SIP_KEEPREFERENCE;
};

#endif // QGSMAPCANVASINTERFACE_H
5 changes: 3 additions & 2 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -26,6 +26,7 @@
#include "qgsfeatureid.h"
#include "qgsgeometry.h"
#include "qgis.h"
#include "qgsmapcanvasinterface.h"

#include <QDomDocument>
#include <QGraphicsView>
Expand Down Expand Up @@ -71,7 +72,7 @@ class QgsMapCanvasAnnotationItem;
* Map canvas is a class for displaying all GIS data types on a canvas.
*/

class GUI_EXPORT QgsMapCanvas : public QGraphicsView
class GUI_EXPORT QgsMapCanvas : public QGraphicsView, public QgsMapCanvasInterface
{

#ifdef SIP_RUN
Expand Down Expand Up @@ -119,7 +120,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
* Gets access to properties used for map rendering
* \since QGIS 2.4
*/
const QgsMapSettings &mapSettings() const SIP_KEEPREFERENCE;
const QgsMapSettings &mapSettings() const FINAL SIP_KEEPREFERENCE;

/**
* sets destination coordinate reference system
Expand Down

0 comments on commit 79c5b35

Please sign in to comment.