diff --git a/python/core/auto_generated/qgsmaplayer.sip.in b/python/core/auto_generated/qgsmaplayer.sip.in index ad93fcca9e7..f723dc0c4da 100644 --- a/python/core/auto_generated/qgsmaplayer.sip.in +++ b/python/core/auto_generated/qgsmaplayer.sip.in @@ -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: diff --git a/python/core/auto_generated/qgsmaplayerelevationproperties.sip.in b/python/core/auto_generated/qgsmaplayerelevationproperties.sip.in new file mode 100644 index 00000000000..f16ef20704c --- /dev/null +++ b/python/core/auto_generated/qgsmaplayerelevationproperties.sip.in @@ -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 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 * + ************************************************************************/ diff --git a/python/core/core_auto.sip b/python/core/core_auto.sip index 38bff8acdab..7af9045867a 100644 --- a/python/core/core_auto.sip +++ b/python/core/core_auto.sip @@ -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 diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f2a35195e87..a8f24835f0e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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 diff --git a/src/core/qgsmaplayer.h b/src/core/qgsmaplayer.h index 23bf489e2d0..b1bec9f58b6 100644 --- a/src/core/qgsmaplayer.h +++ b/src/core/qgsmaplayer.h @@ -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: /** diff --git a/src/core/qgsmaplayerelevationproperties.cpp b/src/core/qgsmaplayerelevationproperties.cpp new file mode 100644 index 00000000000..3b720bea9d8 --- /dev/null +++ b/src/core/qgsmaplayerelevationproperties.cpp @@ -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; +} diff --git a/src/core/qgsmaplayerelevationproperties.h b/src/core/qgsmaplayerelevationproperties.h new file mode 100644 index 00000000000..be718289010 --- /dev/null +++ b/src/core/qgsmaplayerelevationproperties.h @@ -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 +#include + +/** + * \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