QGIS API Documentation 3.39.0-Master (67e056379ed)
Loading...
Searching...
No Matches
qgsrastertransparency.h
Go to the documentation of this file.
1/* **************************************************************************
2 qgsrastertransparency.h - description
3 -------------------
4begin : Mon Nov 30 2007
5copyright : (C) 2007 by Peter J. Ersts
7
8****************************************************************************/
9
10/* **************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18#ifndef QGSRASTERTRANSPARENCY_H
19#define QGSRASTERTRANSPARENCY_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgis.h"
24#include <QList>
25class QDomDocument;
26class QDomElement;
27
33class CORE_EXPORT QgsRasterTransparency
34{
35
36 public:
37
42
48 {
49
58 TransparentThreeValuePixel( double red = 0, double green = 0, double blue = 0, double opacity = 0 )
59 : red( red )
60 , green( green )
61 , blue( blue )
62 , opacity( opacity )
63 {}
64
68 double red;
69
73 double green;
74
78 double blue;
79
85 double opacity = 0;
86
88 {
89 return qgsDoubleNear( red, other.red )
90 && qgsDoubleNear( green, other.green )
91 && qgsDoubleNear( blue, other.blue )
92 && qgsDoubleNear( opacity, other.opacity );
93 }
95 {
96 return !( *this == other );
97 }
98
99#ifdef SIP_RUN
100 SIP_PYOBJECT __repr__();
101 % MethodCode
102 const QString str = QStringLiteral( "<QgsRasterTransparency.TransparentThreeValuePixel: %1, %2, %3, %4>" ).arg( sipCpp->red ).arg( sipCpp->green ).arg( sipCpp->blue ).arg( sipCpp->opacity );
103 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
104 % End
105#endif
106 };
107
113 {
114
125 TransparentSingleValuePixel( double minimum = 0, double maximum = 0, double opacity = 0, bool includeMinimum = true, bool includeMaximum = true )
126 : min( minimum )
127 , max( maximum )
128 , opacity( opacity )
129 , includeMinimum( includeMinimum )
130 , includeMaximum( includeMaximum )
131 {}
132
136 double min;
137
141 double max;
142
148 double opacity = 0;
149
156 bool includeMinimum = true;
157
164 bool includeMaximum = true;
165
167 {
168 return qgsDoubleNear( min, other.min )
169 && qgsDoubleNear( max, other.max )
170 && qgsDoubleNear( opacity, other.opacity )
171 && includeMinimum == other.includeMinimum && includeMaximum == other.includeMaximum;
172 }
174 {
175 return !( *this == other );
176 }
177
178#ifdef SIP_RUN
179 SIP_PYOBJECT __repr__();
180 % MethodCode
181 const QString str = QStringLiteral( "<QgsRasterTransparency.TransparentSingleValuePixel: %1, %2, %3>" ).arg( sipCpp->min ).arg( sipCpp->max ).arg( sipCpp->opacity );
182 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
183 % End
184#endif
185 };
186
191 QVector<QgsRasterTransparency::TransparentSingleValuePixel> transparentSingleValuePixelList() const;
192
197 QVector<QgsRasterTransparency::TransparentThreeValuePixel> transparentThreeValuePixelList() const;
198
202 void initializeTransparentPixelList( double value );
203
207 void initializeTransparentPixelList( double redValue, double greenValue, double blueValue );
208
213 void setTransparentSingleValuePixelList( const QVector<QgsRasterTransparency::TransparentSingleValuePixel> &newList );
214
219 void setTransparentThreeValuePixelList( const QVector<QgsRasterTransparency::TransparentThreeValuePixel> &newList );
220
232 Q_DECL_DEPRECATED int alphaValue( double value, int globalTransparency = 255 ) const SIP_DEPRECATED;
233
242 double opacityForValue( double value ) const;
243
256 Q_DECL_DEPRECATED int alphaValue( double redValue, double greenValue, double blueValue, int globalTransparency = 255 ) const SIP_DEPRECATED;
257
268 double opacityForRgbValues( double redValue, double greenValue, double blueValue ) const;
269
271 bool isEmpty() const;
272
276 void writeXml( QDomDocument &doc, QDomElement &parentElem ) const;
277
281 void readXml( const QDomElement &elem );
282
283 private:
285 QVector<QgsRasterTransparency::TransparentThreeValuePixel> mTransparentThreeValuePixelList;
286
288 QVector<QgsRasterTransparency::TransparentSingleValuePixel> mTransparentSingleValuePixelList;
289
290};
291#endif
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
QgsRasterTransparency()=default
Constructor for QgsRasterTransparency.
#define str(x)
Definition qgis.cpp:38
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition qgis.h:5465
#define SIP_DEPRECATED
Definition qgis_sip.h:106
Defines the transparency for a range of single-band pixel values.
bool operator==(const QgsRasterTransparency::TransparentSingleValuePixel &other) const
TransparentSingleValuePixel(double minimum=0, double maximum=0, double opacity=0, bool includeMinimum=true, bool includeMaximum=true)
Constructor for TransparentSingleValuePixel.
double opacity
Opacity for pixel, between 0 and 1.0.
double min
Minimum pixel value to include in range.
double max
Maximum pixel value to include in range.
bool includeMaximum
true if pixels matching the max value should be considered transparent, or false if only pixels less ...
bool operator!=(const QgsRasterTransparency::TransparentSingleValuePixel &other) const
bool includeMinimum
true if pixels matching the min value should be considered transparent, or false if only pixels great...
Defines the transparency for a RGB pixel value.
bool operator!=(const QgsRasterTransparency::TransparentThreeValuePixel &other) const
double opacity
Opacity for pixel, between 0 and 1.0.
TransparentThreeValuePixel(double red=0, double green=0, double blue=0, double opacity=0)
Constructor for TransparentThreeValuePixel.
bool operator==(const QgsRasterTransparency::TransparentThreeValuePixel &other) const