QGIS API Documentation 3.39.0-Master (3aed037ce22)
Loading...
Searching...
No Matches
qgselevationmap.h
Go to the documentation of this file.
1/***************************************************************************
2 qgselevationmap.h
3 --------------------------------------
4 Date : August 2022
5 Copyright : (C) 2022 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSELEVATIONMAP_H
17#define QGSELEVATIONMAP_H
18
19#include "qgis.h"
20#include "qgis_sip.h"
21
22#include <QImage>
23#include <memory>
24
25class QgsRasterBlock;
26
42class CORE_EXPORT QgsElevationMap
43{
44 public:
45
46 QgsElevationMap() = default;
47
49 explicit QgsElevationMap( const QSize &size, float devicePixelRatio = 1.0 );
50
58 explicit QgsElevationMap( const QImage &image );
59
60 QgsElevationMap( const QgsElevationMap &other );
61
77 void applyEyeDomeLighting( QImage &image, int distance, float strength, float rendererScale ) const;
78
97 void applyHillshading( QImage &image, bool multiDirectional, double altitude, double azimuth, double zFactor, double cellSizeX, double cellSizeY ) const;
98
100 QImage rawElevationImage() const { return mElevationImage; }
101
102#ifndef SIP_RUN
103
108 QRgb *rawElevationImageData() { return reinterpret_cast<QRgb *>( mElevationImage.bits() ); }
109#endif
110
112 QPainter *painter() const;
113
123 void combine( const QgsElevationMap &otherElevationMap, Qgis::ElevationMapCombineMethod method );
124
129 void fillWithRasterBlock( QgsRasterBlock *block, int top, int left, double zScale = 1.0, double offset = 0.0 ) SIP_SKIP;
130
136 bool isValid() const;
137
139 static QRgb encodeElevation( float z );
141 static float decodeElevation( QRgb colorRaw );
142
144 static std::unique_ptr<QgsElevationMap> fromRasterBlock( QgsRasterBlock *block ) SIP_SKIP;
145
147 inline bool isNoData( QRgb colorRaw ) const {return colorRaw == 0;}
148
150 inline float noDataValue() const {return decodeElevation( 0 );}
151
152 QgsElevationMap &operator=( const QgsElevationMap &other );
153
154 private:
155
156 mutable QImage mElevationImage;
157 mutable std::unique_ptr<QPainter> mPainter;
158};
159
160#endif // QGSELEVATIONMAP_H
ElevationMapCombineMethod
Methods used to select the elevation when two elevation maps are combined.
Definition qgis.h:4365
Stores digital elevation model in a raster image which may get updated as a part of map layer renderi...
QgsElevationMap()=default
float noDataValue() const
Returns the no data value for the elevation map.
QImage rawElevationImage() const
Returns raw elevation image with elevations encoded as color values.
QRgb * rawElevationImageData()
Returns pointer to the actual elevation image data.
Raster data container.
#define SIP_SKIP
Definition qgis_sip.h:126