QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsmaplayerelevationproperties.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaplayerelevationproperties.h
3 ---------------
4 begin : November 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18
19#ifndef QGSMAPLAYERELEVATIONPROPERTIES_H
20#define QGSMAPLAYERELEVATIONPROPERTIES_H
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
24#include "qgsreadwritecontext.h"
25#include "qgsrange.h"
27
28#include <QObject>
29#include <QDomElement>
30
31class QgsMapLayer;
32
33
44class CORE_EXPORT QgsMapLayerElevationProperties : public QObject
45{
46#ifdef SIP_RUN
51#endif
52
53 Q_OBJECT
54
55#ifdef SIP_RUN
57 if ( qobject_cast<QgsPointCloudLayerElevationProperties *>( sipCpp ) )
58 {
59 sipType = sipType_QgsPointCloudLayerElevationProperties;
60 }
61 else if ( qobject_cast<QgsVectorLayerElevationProperties *>( sipCpp ) )
62 {
63 sipType = sipType_QgsVectorLayerElevationProperties;
64 }
65 else if ( qobject_cast<QgsRasterLayerElevationProperties *>( sipCpp ) )
66 {
67 sipType = sipType_QgsRasterLayerElevationProperties;
68 }
69 else if ( qobject_cast<QgsMeshLayerElevationProperties *>( sipCpp ) )
70 {
71 sipType = sipType_QgsMeshLayerElevationProperties;
72 }
73 else
74 {
75 sipType = 0;
76 }
78#endif
79
80 public:
81
87 {
90 };
91
95 enum Flag
96 {
97 FlagDontInvalidateCachedRendersWhenRangeChanges = 1
98 };
99 Q_DECLARE_FLAGS( Flags, Flag )
100
101
105
109 virtual bool hasElevation() const;
110
116 virtual QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) = 0;
117
123 virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
124
130 virtual void setDefaultsFromLayer( QgsMapLayer *layer );
131
137 virtual QString htmlSummary() const;
138
145
149 virtual bool isVisibleInZRange( const QgsDoubleRange &range ) const;
150
154 virtual QgsMapLayerElevationProperties::Flags flags() const { return QgsMapLayerElevationProperties::Flags(); }
155
162 virtual QgsDoubleRange calculateZRange( QgsMapLayer *layer ) const;
163
173 virtual bool showByDefaultInElevationProfilePlots() const;
174
183 double zOffset() const { return mZOffset; }
184
193 void setZOffset( double offset );
194
206 double zScale() const { return mZScale; }
207
219 void setZScale( double scale );
220
226 QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
227
235 const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
236
246 void setDataDefinedProperties( const QgsPropertyCollection &collection );
247
253 static QgsPropertiesDefinition propertyDefinitions();
254
255 signals:
256
262 void changed();
263
270
277
287
297
298 protected:
300 double mZScale = 1.0;
302 double mZOffset = 0.0;
303
306
309
316 void writeCommonProperties( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context );
317
324 void readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
325
331 void copyCommonProperties( const QgsMapLayerElevationProperties *other );
332
333 private:
334
338 static void initPropertyDefinitions();
339
340};
341
342#endif // QGSMAPLAYERELEVATIONPROPERTIES_H
QgsRange which stores a range of double values.
Definition: qgsrange.h:203
Base class for storage of map layer elevation properties.
void zScaleChanged()
Emitted when the z scale changes.
QgsPropertyCollection mDataDefinedProperties
Property collection for data defined elevation settings.
void profileGenerationPropertyChanged()
Emitted when any of the elevation properties which relate solely to generation of elevation profiles ...
virtual QgsMapLayerElevationProperties::Flags flags() const
Returns flags associated to the elevation properties.
virtual QgsMapLayerElevationProperties * clone() const =0
Creates a clone of the properties.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the object's property collection, used for data defined overrides.
void changed()
Emitted when any of the elevation properties have changed.
void profileRenderingPropertyChanged()
Emitted when any of the elevation properties which relate solely to presentation of elevation results...
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the object's property collection, used for data defined overrides.
void zOffsetChanged()
Emitted when the z offset changes.
double zScale() const
Returns the z scale, which is a scaling factor which should be applied to z values from the layer.
virtual QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context)=0
Writes the properties to a DOM element, to be used later with readXml().
static QgsPropertiesDefinition sPropertyDefinitions
Property definitions.
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads the elevation properties from a DOM element previously written by writeXml().
Flag
Flags attached to the elevation property.
double zOffset() const
Returns the z offset, which is a fixed offset amount which should be added to z values from the layer...
Base class for all map layer types.
Definition: qgsmaplayer.h:73
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
The class is used as a container of context for various read/write operations on other objects.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:203
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.