QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsrasterlayerelevationproperties.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrasterlayerelevationproperties.h
3 ---------------
4 begin : February 2022
5 copyright : (C) 2022 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 QGSRASTERLAYERELEVATIONPROPERTIES_H
20#define QGSRASTERLAYERELEVATIONPROPERTIES_H
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
25#include "qgslinesymbol.h"
26
27class QgsRasterLayer;
28
37{
38
39 Q_OBJECT
40
41 public:
42
48
49 bool hasElevation() const override;
50 QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) override;
51 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
53 QString htmlSummary() const override;
54 bool isVisibleInZRange( const QgsDoubleRange &range, QgsMapLayer *layer = nullptr ) const override;
55 QgsDoubleRange calculateZRange( QgsMapLayer *layer ) const override;
56 bool showByDefaultInElevationProfilePlots() const override;
57 QgsMapLayerElevationProperties::Flags flags() const override;
58
64 bool isEnabled() const { return mEnabled; }
65
71 void setEnabled( bool enabled );
72
79 Qgis::RasterElevationMode mode() const;
80
87 void setMode( Qgis::RasterElevationMode mode );
88
96 int bandNumber() const { return mBandNumber; }
97
105 void setBandNumber( int band );
106
117 QgsDoubleRange fixedRange() const;
118
129 void setFixedRange( const QgsDoubleRange &range );
130
141 QMap<int, QgsDoubleRange> fixedRangePerBand() const;
142
153 void setFixedRangePerBand( const QMap<int, QgsDoubleRange> &ranges );
154
162 QgsDoubleRange elevationRangeForPixelValue( QgsRasterLayer *layer, int band, double pixelValue ) const;
163
172 int bandForElevationRange( QgsRasterLayer *layer, const QgsDoubleRange &range ) const;
173
179 QgsLineSymbol *profileLineSymbol() const;
180
188 void setProfileLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
189
195 QgsFillSymbol *profileFillSymbol() const;
196
204 void setProfileFillSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
205
211 Qgis::ProfileSurfaceSymbology profileSymbology() const { return mSymbology; }
212
218 void setProfileSymbology( Qgis::ProfileSurfaceSymbology symbology );
219
230 double elevationLimit() const;
231
242 void setElevationLimit( double limit );
243
259 static bool layerLooksLikeDem( QgsRasterLayer *layer );
260
261 private:
262
263 void setDefaultProfileLineSymbol( const QColor &color );
264 void setDefaultProfileFillSymbol( const QColor &color );
265
266 bool mEnabled = false;
267
269
270 std::unique_ptr< QgsLineSymbol > mProfileLineSymbol;
271 std::unique_ptr< QgsFillSymbol > mProfileFillSymbol;
273 double mElevationLimit = std::numeric_limits< double >::quiet_NaN();
274 int mBandNumber = 1;
275
276 QgsDoubleRange mFixedRange;
277 QMap< int, QgsDoubleRange > mRangePerBand;
278};
279
280#endif // QGSRASTERLAYERELEVATIONPROPERTIES_H
RasterElevationMode
Raster layer elevation modes.
Definition: qgis.h:3277
@ RepresentsElevationSurface
Pixel values represent an elevation surface.
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
Definition: qgis.h:3435
@ Line
The elevation surface will be rendered using a line symbol.
QgsRange which stores a range of double values.
Definition: qgsrange.h:231
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
Base class for storage of map layer elevation properties.
virtual QgsMapLayerElevationProperties * clone() const =0
Creates a clone of the properties.
virtual QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context)=0
Writes the properties to a DOM element, to be used later with readXml().
virtual bool readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads the elevation properties from a DOM element previously written by writeXml().
virtual bool hasElevation() const
Returns true if the layer has an elevation or z component.
Base class for all map layer types.
Definition: qgsmaplayer.h:75
Raster layer specific subclass of QgsMapLayerElevationProperties.
Qgis::ProfileSurfaceSymbology profileSymbology() const
Returns the symbology option used to render the raster profile in elevation profile plots.
int bandNumber() const
Returns the band number from which the elevation should be taken.
Represents a raster layer.
The class is used as a container of context for various read/write operations on other objects.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76