QGIS API Documentation 3.39.0-Master (3aed037ce22)
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
39
45 {
46
55 TransparentThreeValuePixel( double red = 0, double green = 0, double blue = 0, double opacity = 0 )
56 : red( red )
57 , green( green )
58 , blue( blue )
59 , opacity( opacity )
60 {}
61
65 double red;
66
70 double green;
71
75 double blue;
76
82 double opacity = 0;
83
85 {
86 return qgsDoubleNear( red, other.red )
87 && qgsDoubleNear( green, other.green )
88 && qgsDoubleNear( blue, other.blue )
89 && qgsDoubleNear( opacity, other.opacity );
90 }
92 {
93 return !( *this == other );
94 }
95
96#ifdef SIP_RUN
97 SIP_PYOBJECT __repr__();
98 % MethodCode
99 const QString str = QStringLiteral( "<QgsRasterTransparency.TransparentThreeValuePixel: %1, %2, %3, %4>" ).arg( sipCpp->red ).arg( sipCpp->green ).arg( sipCpp->blue ).arg( sipCpp->opacity );
100 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
101 % End
102#endif
103 };
104
110 {
111
122 TransparentSingleValuePixel( double minimum = 0, double maximum = 0, double opacity = 0, bool includeMinimum = true, bool includeMaximum = true )
123 : min( minimum )
124 , max( maximum )
125 , opacity( opacity )
126 , includeMinimum( includeMinimum )
127 , includeMaximum( includeMaximum )
128 {}
129
133 double min;
134
138 double max;
139
145 double opacity = 0;
146
153 bool includeMinimum = true;
154
161 bool includeMaximum = true;
162
164 {
165 return qgsDoubleNear( min, other.min )
166 && qgsDoubleNear( max, other.max )
167 && qgsDoubleNear( opacity, other.opacity )
168 && includeMinimum == other.includeMinimum && includeMaximum == other.includeMaximum;
169 }
171 {
172 return !( *this == other );
173 }
174
175#ifdef SIP_RUN
176 SIP_PYOBJECT __repr__();
177 % MethodCode
178 const QString str = QStringLiteral( "<QgsRasterTransparency.TransparentSingleValuePixel: %1, %2, %3>" ).arg( sipCpp->min ).arg( sipCpp->max ).arg( sipCpp->opacity );
179 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
180 % End
181#endif
182 };
183
188 QVector<QgsRasterTransparency::TransparentSingleValuePixel> transparentSingleValuePixelList() const;
189
194 QVector<QgsRasterTransparency::TransparentThreeValuePixel> transparentThreeValuePixelList() const;
195
199 void initializeTransparentPixelList( double value );
200
204 void initializeTransparentPixelList( double redValue, double greenValue, double blueValue );
205
210 void setTransparentSingleValuePixelList( const QVector<QgsRasterTransparency::TransparentSingleValuePixel> &newList );
211
216 void setTransparentThreeValuePixelList( const QVector<QgsRasterTransparency::TransparentThreeValuePixel> &newList );
217
229 Q_DECL_DEPRECATED int alphaValue( double value, int globalTransparency = 255 ) const SIP_DEPRECATED;
230
239 double opacityForValue( double value ) const;
240
253 Q_DECL_DEPRECATED int alphaValue( double redValue, double greenValue, double blueValue, int globalTransparency = 255 ) const SIP_DEPRECATED;
254
265 double opacityForRgbValues( double redValue, double greenValue, double blueValue ) const;
266
268 bool isEmpty() const;
269
273 void writeXml( QDomDocument &doc, QDomElement &parentElem ) const;
274
278 void readXml( const QDomElement &elem );
279
280 private:
282 QVector<QgsRasterTransparency::TransparentThreeValuePixel> mTransparentThreeValuePixelList;
283
285 QVector<QgsRasterTransparency::TransparentSingleValuePixel> mTransparentSingleValuePixelList;
286
287};
288#endif
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
QgsRasterTransparency()=default
#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:5652
#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