Skip to content

Commit

Permalink
Add base class for QgsMapLayerElevationProperties
Browse files Browse the repository at this point in the history
Base class for storage of map layer elevation properties.
  • Loading branch information
nyalldawson committed Nov 28, 2020
1 parent 775320e commit 7c964f1
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/core/auto_generated/qgsmaplayer.sip.in
Expand Up @@ -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:
Expand Down
80 changes: 80 additions & 0 deletions 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<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 *
************************************************************************/
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -329,6 +329,7 @@ set(QGIS_CORE_SRCS
qgsmapdecoration.cpp
qgsmaphittest.cpp
qgsmaplayer.cpp
qgsmaplayerelevationproperties.cpp
qgsmaplayerlegend.cpp
qgsmaplayermodel.cpp
qgsmaplayerproxymodel.cpp
Expand Down Expand Up @@ -932,6 +933,7 @@ set(QGIS_CORE_HDRS
qgsmaplayerstore.h
qgsmaplayerstyle.h
qgsmaplayerstylemanager.h
qgsmaplayerelevationproperties.h
qgsmaplayertemporalproperties.h
qgsmaprenderercache.h
qgsmaprenderercustompainterjob.h
Expand Down
8 changes: 8 additions & 0 deletions src/core/qgsmaplayer.h
Expand Up @@ -48,6 +48,7 @@ class QgsMapLayerStyleManager;
class QgsProject;
class QgsStyleEntityVisitorInterface;
class QgsMapLayerTemporalProperties;
class QgsMapLayerElevationProperties;

class QDomDocument;
class QKeyEvent;
Expand Down Expand Up @@ -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:

/**
Expand Down
28 changes: 28 additions & 0 deletions 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;
}
93 changes: 93 additions & 0 deletions 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 <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

0 comments on commit 7c964f1

Please sign in to comment.