Add base class for QgsMapLayerElevationProperties

Base class for storage of map layer elevation properties.
This commit is contained in:
Nyall Dawson 2020-11-24 13:26:37 +10:00
parent 775320e095
commit 7c964f1d41
7 changed files with 219 additions and 0 deletions

View File

@ -1360,6 +1360,13 @@ should be canceled.
Returns the layer's temporal properties. This may be ``None``, depending on the layer type.
.. versionadded:: 3.14
%End
virtual QgsMapLayerElevationProperties *elevationProperties();
%Docstring
Returns the layer's elevation properties. This may be ``None``, depending on the layer type.
.. versionadded:: 3.18
%End
public slots:

View File

@ -0,0 +1,80 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsmaplayerelevationproperties.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsMapLayerElevationProperties : QObject
{
%Docstring
Base class for storage of map layer elevation properties.
QgsMapLayerElevationProperties exposes user-configurable settings for controlling
how an individual QgsMapLayer behaves with relation to z values or elevations.
.. versionadded:: 3.18
%End
%TypeHeaderCode
#include "qgsmaplayerelevationproperties.h"
%End
public:
enum Flag
{
FlagDontInvalidateCachedRendersWhenRangeChanges
};
typedef QFlags<QgsMapLayerElevationProperties::Flag> Flags;
QgsMapLayerElevationProperties( QObject *parent /TransferThis/ );
%Docstring
Constructor for QgsMapLayerElevationProperties, with the specified ``parent`` object.
%End
virtual QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) = 0;
%Docstring
Writes the properties to a DOM ``element``, to be used later with :py:func:`~QgsMapLayerElevationProperties.readXml`.
.. seealso:: :py:func:`readXml`
%End
virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
%Docstring
Reads the elevation properties from a DOM ``element`` previously written by :py:func:`~QgsMapLayerElevationProperties.writeXml`.
.. seealso:: :py:func:`writeXml`
%End
virtual bool isVisibleInZRange( const QgsDoubleRange &range ) const;
%Docstring
Returns ``True`` if the layer should be visible and rendered for the specified z ``range``.
%End
virtual QgsMapLayerElevationProperties::Flags flags() const;
%Docstring
Returns flags associated to the elevation properties.
%End
signals:
void changed();
%Docstring
Emitted when the elevation properties have changed.
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsmaplayerelevationproperties.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -115,6 +115,7 @@
%Include auto_generated/qgsmaplayerstore.sip
%Include auto_generated/qgsmaplayerstyle.sip
%Include auto_generated/qgsmaplayerstylemanager.sip
%Include auto_generated/qgsmaplayerelevationproperties.sip
%Include auto_generated/qgsmaplayertemporalproperties.sip
%Include auto_generated/qgsmaprenderercache.sip
%Include auto_generated/qgsmaprenderercustompainterjob.sip

View File

@ -329,6 +329,7 @@ set(QGIS_CORE_SRCS
qgsmapdecoration.cpp
qgsmaphittest.cpp
qgsmaplayer.cpp
qgsmaplayerelevationproperties.cpp
qgsmaplayerlegend.cpp
qgsmaplayermodel.cpp
qgsmaplayerproxymodel.cpp
@ -932,6 +933,7 @@ set(QGIS_CORE_HDRS
qgsmaplayerstore.h
qgsmaplayerstyle.h
qgsmaplayerstylemanager.h
qgsmaplayerelevationproperties.h
qgsmaplayertemporalproperties.h
qgsmaprenderercache.h
qgsmaprenderercustompainterjob.h

View File

@ -48,6 +48,7 @@ class QgsMapLayerStyleManager;
class QgsProject;
class QgsStyleEntityVisitorInterface;
class QgsMapLayerTemporalProperties;
class QgsMapLayerElevationProperties;
class QDomDocument;
class QKeyEvent;
@ -1228,6 +1229,13 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
virtual QgsMapLayerTemporalProperties *temporalProperties() { return nullptr; }
/**
* Returns the layer's elevation properties. This may be NULLPTR, depending on the layer type.
*
* \since QGIS 3.18
*/
virtual QgsMapLayerElevationProperties *elevationProperties() { return nullptr; }
public slots:
/**

View File

@ -0,0 +1,28 @@
/***************************************************************************
qgsmaplayerelevationproperties.cpp
---------------
begin : November 2020
copyright : (C) 2020 by Nyall Dawson
email : nyall dot dawson dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsmaplayerelevationproperties.h"
QgsMapLayerElevationProperties::QgsMapLayerElevationProperties( QObject *parent )
: QObject( parent )
{
}
bool QgsMapLayerElevationProperties::isVisibleInZRange( const QgsDoubleRange & ) const
{
return true;
}

View File

@ -0,0 +1,93 @@
/***************************************************************************
qgsmaplayerelevationproperties.h
---------------
begin : November 2020
copyright : (C) 2020 by Nyall Dawson
email : nyall dot dawson dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMAPLAYERELEVATIONPROPERTIES_H
#define QGSMAPLAYERELEVATIONPROPERTIES_H
#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsreadwritecontext.h"
#include "qgsrange.h"
#include <QObject>
#include <QDomElement>
/**
* \class QgsMapLayerElevationProperties
* \ingroup core
* Base class for storage of map layer elevation properties.
*
* QgsMapLayerElevationProperties exposes user-configurable settings for controlling
* how an individual QgsMapLayer behaves with relation to z values or elevations.
*
* \since QGIS 3.18
*/
class CORE_EXPORT QgsMapLayerElevationProperties : public QObject
{
Q_OBJECT
public:
/**
* Flags attached to the elevation property.
*/
enum Flag
{
FlagDontInvalidateCachedRendersWhenRangeChanges = 1 //!< Any cached rendering will not be invalidated when z range context is modified.
};
Q_DECLARE_FLAGS( Flags, Flag )
/**
* Constructor for QgsMapLayerElevationProperties, with the specified \a parent object.
*/
QgsMapLayerElevationProperties( QObject *parent SIP_TRANSFERTHIS );
/**
* Writes the properties to a DOM \a element, to be used later with readXml().
*
* \see readXml()
*/
virtual QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) = 0;
/**
* Reads the elevation properties from a DOM \a element previously written by writeXml().
*
* \see writeXml()
*/
virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
/**
* Returns TRUE if the layer should be visible and rendered for the specified z \a range.
*/
virtual bool isVisibleInZRange( const QgsDoubleRange &range ) const;
/**
* Returns flags associated to the elevation properties.
*/
virtual QgsMapLayerElevationProperties::Flags flags() const { return QgsMapLayerElevationProperties::Flags(); }
signals:
/**
* Emitted when the elevation properties have changed.
*/
void changed();
};
#endif // QGSMAPLAYERELEVATIONPROPERTIES_H