create a core interface for QgsMapCanvas

This commit is contained in:
Denis Rouzaud 2018-11-02 11:28:06 -04:00
parent 5ae2bae909
commit 79c5b35a39
6 changed files with 75 additions and 4 deletions

View File

@ -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 *
************************************************************************/

View File

@ -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

View File

@ -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.
@ -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

View File

@ -888,6 +888,7 @@ SET(QGIS_CORE_HDRS
qgslegendsettings.h
qgslegendstyle.h
qgslogger.h
qgsmapcanvasinterface.h
qgsmapdecoration.h
qgsmaplayerref.h
qgsmaphittest.h

View File

@ -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

View File

@ -26,6 +26,7 @@
#include "qgsfeatureid.h"
#include "qgsgeometry.h"
#include "qgis.h"
#include "qgsmapcanvasinterface.h"
#include <QDomDocument>
#include <QGraphicsView>
@ -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
@ -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