QGIS API Documentation 3.99.0-Master (21b3aa880ba)
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 <memory>
20
21#include "qgis.h"
22#include "qgis_sip.h"
23
24#include <QImage>
25
26class QgsRasterBlock;
27
45class CORE_EXPORT QgsElevationMap
46{
47 public:
48
49 QgsElevationMap() = default;
50
52 explicit QgsElevationMap( const QSize &size, float devicePixelRatio = 1.0 );
53
61 explicit QgsElevationMap( const QImage &image );
62
63 QgsElevationMap( const QgsElevationMap &other );
64
80 void applyEyeDomeLighting( QImage &image, int distance, float strength, float rendererScale ) const;
81
100 void applyHillshading( QImage &image, bool multiDirectional, double altitude, double azimuth, double zFactor, double cellSizeX, double cellSizeY ) const;
101
103 QImage rawElevationImage() const { return mElevationImage; }
104
105#ifndef SIP_RUN
106
111 QRgb *rawElevationImageData() { return reinterpret_cast<QRgb *>( mElevationImage.bits() ); }
112#endif
113
115 QPainter *painter() const;
116
126 void combine( const QgsElevationMap &otherElevationMap, Qgis::ElevationMapCombineMethod method );
127
132 void fillWithRasterBlock( QgsRasterBlock *block, int top, int left, double zScale = 1.0, double offset = 0.0 ) SIP_SKIP;
133
139 bool isValid() const;
140
142 static QRgb encodeElevation( float z );
144 static float decodeElevation( QRgb colorRaw );
145
147 static std::unique_ptr<QgsElevationMap> fromRasterBlock( QgsRasterBlock *block ) SIP_SKIP;
148
150 inline bool isNoData( QRgb colorRaw ) const {return colorRaw == 0;}
151
153 inline float noDataValue() const {return decodeElevation( 0 );}
154
155 QgsElevationMap &operator=( const QgsElevationMap &other );
156
157 private:
158
159 mutable QImage mElevationImage;
160 mutable std::unique_ptr<QPainter> mPainter;
161};
162
163#endif // QGSELEVATIONMAP_H
ElevationMapCombineMethod
Methods used to select the elevation when two elevation maps are combined.
Definition qgis.h:4915
Stores a digital elevation model in a raster image which may get updated as a part of the map layer r...
QgsElevationMap()=default
void applyEyeDomeLighting(QImage &image, int distance, float strength, float rendererScale) const
Applies eye dome lighting effect to the given image.
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.
bool isNoData(QRgb colorRaw) const
Returns whether the encoded value is a no data value.
QRgb * rawElevationImageData()
Returns pointer to the actual elevation image data.
static float decodeElevation(QRgb colorRaw)
Converts a color back to elevation value.
void applyHillshading(QImage &image, bool multiDirectional, double altitude, double azimuth, double zFactor, double cellSizeX, double cellSizeY) const
Applies hill shading effect to the given image.
Raster data container.
#define SIP_SKIP
Definition qgis_sip.h:134