Skip to content

Commit 79c5b35

Browse files
committedNov 6, 2018
create a core interface for QgsMapCanvas
1 parent 5ae2bae commit 79c5b35

File tree

6 files changed

+75
-4
lines changed

6 files changed

+75
-4
lines changed
 
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsmapcanvasinterface.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
class QgsMapCanvasInterface
12+
{
13+
%Docstring
14+
The QgsMapCanvasInterface class provides a simple interface to access
15+
core components of a map canvas.
16+
17+
.. versionadded:: 3.6
18+
%End
19+
20+
%TypeHeaderCode
21+
#include "qgsmapcanvasinterface.h"
22+
%End
23+
public:
24+
explicit QgsMapCanvasInterface();
25+
%Docstring
26+
Constructor of QgsMapCanvasInterface
27+
%End
28+
virtual ~QgsMapCanvasInterface();
29+
30+
virtual const QgsMapSettings &mapSettings() const = 0 /KeepReference/;
31+
%Docstring
32+
Returns the map settings
33+
%End
34+
};
35+
36+
/************************************************************************
37+
* This file has been generated automatically from *
38+
* *
39+
* src/core/qgsmapcanvasinterface.h *
40+
* *
41+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
42+
************************************************************************/

‎python/core/core_auto.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
%Include auto_generated/qgslegendsettings.sip
6868
%Include auto_generated/qgslegendstyle.sip
6969
%Include auto_generated/qgslogger.sip
70+
%Include auto_generated/qgsmapcanvasinterface.sip
7071
%Include auto_generated/qgsmapdecoration.sip
7172
%Include auto_generated/qgsmaphittest.sip
7273
%Include auto_generated/qgsmaplayerdependency.sip

‎python/gui/auto_generated/qgsmapcanvas.sip.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020

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

6666
void setCurrentLayer( QgsMapLayer *layer );
6767

68-
const QgsMapSettings &mapSettings() const /KeepReference/;
68+
virtual const QgsMapSettings &mapSettings() const ${SIP_FINAL} /KeepReference/;
69+
6970
%Docstring
7071
Gets access to properties used for map rendering
7172

‎src/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ SET(QGIS_CORE_HDRS
888888
qgslegendsettings.h
889889
qgslegendstyle.h
890890
qgslogger.h
891+
qgsmapcanvasinterface.h
891892
qgsmapdecoration.h
892893
qgsmaplayerref.h
893894
qgsmaphittest.h

‎src/core/qgsmapcanvasinterface.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef QGSMAPCANVASINTERFACE_H
2+
#define QGSMAPCANVASINTERFACE_H
3+
4+
#include "qgis_core.h"
5+
#include "qgis_sip.h"
6+
7+
class QgsMapSettings;
8+
9+
/**
10+
* The QgsMapCanvasInterface class provides a simple interface to access
11+
* core components of a map canvas.
12+
* \since QGIS 3.6
13+
*/
14+
class CORE_EXPORT QgsMapCanvasInterface
15+
{
16+
public:
17+
//! Constructor of QgsMapCanvasInterface
18+
explicit QgsMapCanvasInterface() = default;
19+
virtual ~QgsMapCanvasInterface() = default;
20+
21+
//! Returns the map settings
22+
virtual const QgsMapSettings &mapSettings() const = 0 SIP_KEEPREFERENCE;
23+
};
24+
25+
#endif // QGSMAPCANVASINTERFACE_H

‎src/gui/qgsmapcanvas.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "qgsfeatureid.h"
2727
#include "qgsgeometry.h"
2828
#include "qgis.h"
29+
#include "qgsmapcanvasinterface.h"
2930

3031
#include <QDomDocument>
3132
#include <QGraphicsView>
@@ -71,7 +72,7 @@ class QgsMapCanvasAnnotationItem;
7172
* Map canvas is a class for displaying all GIS data types on a canvas.
7273
*/
7374

74-
class GUI_EXPORT QgsMapCanvas : public QGraphicsView
75+
class GUI_EXPORT QgsMapCanvas : public QGraphicsView, public QgsMapCanvasInterface
7576
{
7677

7778
#ifdef SIP_RUN
@@ -119,7 +120,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
119120
* Gets access to properties used for map rendering
120121
* \since QGIS 2.4
121122
*/
122-
const QgsMapSettings &mapSettings() const SIP_KEEPREFERENCE;
123+
const QgsMapSettings &mapSettings() const FINAL SIP_KEEPREFERENCE;
123124

124125
/**
125126
* sets destination coordinate reference system

0 commit comments

Comments
 (0)
Please sign in to comment.