24 #include <QDomDocument> 25 #include <QDomElement> 37 return mTransparentSingleValuePixelList;
45 return mTransparentThreeValuePixelList;
54 mTransparentSingleValuePixelList.
clear();
58 myTransparentSingleValuePixel.
min = theValue;
59 myTransparentSingleValuePixel.
max = theValue;
61 mTransparentSingleValuePixelList.
append( myTransparentSingleValuePixel );
70 mTransparentThreeValuePixelList.
clear();
74 myTransparentThreeValuePixel.
red = theRedValue;
75 myTransparentThreeValuePixel.
green = theGreenValue;
76 myTransparentThreeValuePixel.
blue = theBlueValue;
78 mTransparentThreeValuePixelList.
append( myTransparentThreeValuePixel );
87 mTransparentSingleValuePixelList = theNewList;
95 mTransparentThreeValuePixelList = theNewList;
107 if ( qIsNaN( theValue ) )
113 bool myTransparentPixelFound =
false;
115 for (
int myListRunner = 0; myListRunner < mTransparentSingleValuePixelList.
count(); myListRunner++ )
117 myTransparentPixel = mTransparentSingleValuePixelList[myListRunner];
118 if (( theValue >= myTransparentPixel.
min && theValue <= myTransparentPixel.
max ) ||
122 myTransparentPixelFound =
true;
128 if ( myTransparentPixelFound )
130 return static_cast< int >(
static_cast< float >( theGlobalTransparency ) *( 1.0 - ( myTransparentPixel.
percentTransparent / 100.0 ) ) );
133 return theGlobalTransparency;
147 if ( qIsNaN( theRedValue ) || qIsNaN( theGreenValue ) || qIsNaN( theBlueValue ) )
153 bool myTransparentPixelFound =
false;
155 for (
int myListRunner = 0; myListRunner < mTransparentThreeValuePixelList.
count(); myListRunner++ )
157 myTransparentPixel = mTransparentThreeValuePixelList[myListRunner];
164 myTransparentPixelFound =
true;
172 if ( myTransparentPixelFound )
174 return static_cast< int >(
static_cast< float >( theGlobalTransparency ) *( 1.0 - ( myTransparentPixel.
percentTransparent / 100.0 ) ) );
177 return theGlobalTransparency;
182 return mTransparentSingleValuePixelList.
isEmpty() && mTransparentThreeValuePixelList.
isEmpty();
188 if ( !mTransparentSingleValuePixelList.
isEmpty() )
192 for ( ; it != mTransparentSingleValuePixelList.
constEnd(); ++it )
198 singleValuePixelListElement.
appendChild( pixelListElement );
200 rasterTransparencyElem.
appendChild( singleValuePixelListElement );
203 if ( !mTransparentThreeValuePixelList.
isEmpty() )
207 for ( ; it != mTransparentThreeValuePixelList.
constEnd(); ++it )
214 threeValuePixelListElement.
appendChild( pixelListElement );
216 rasterTransparencyElem.
appendChild( threeValuePixelListElement );
228 mTransparentSingleValuePixelList.
clear();
229 mTransparentThreeValuePixelList.
clear();
233 if ( !singlePixelListElem.
isNull() )
237 for (
int i = 0; i < entryList.
size(); ++i )
251 mTransparentSingleValuePixelList.
append( sp );
255 if ( !threeValuePixelListElem.
isNull() )
259 for (
int i = 0; i < entryList.
size(); ++i )
266 mTransparentThreeValuePixelList.
append( tp );
QDomNodeList elementsByTagName(const QString &tagname) const
bool isEmpty() const
True if there are no entries in the pixel lists except the nodata value.
static QString printValue(double value)
Print double value with all necessary significant digits.
QDomNode appendChild(const QDomNode &newChild)
QString attribute(const QString &name, const QString &defValue) const
int alphaValue(double, int theGlobalTransparency=255) const
Returns the transparency value for a single value Pixel.
void setTransparentThreeValuePixelList(const QList< TransparentThreeValuePixel > &theNewList)
Mutator for transparentThreeValuePixelList.
double toDouble(bool *ok) const
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
QDomElement toElement() const
QString number(int n, int base)
int count(const T &value) const
void append(const T &value)
bool hasAttribute(const QString &name) const
double percentTransparent
void setAttribute(const QString &name, const QString &value)
QList< QgsRasterTransparency::TransparentSingleValuePixel > transparentSingleValuePixelList() const
Accessor for transparentSingleValuePixelList.
void setTransparentSingleValuePixelList(const QList< TransparentSingleValuePixel > &theNewList)
Mutator for transparentSingleValuePixelList.
QDomElement firstChildElement(const QString &tagName) const
void readXML(const QDomElement &elem)
void writeXML(QDomDocument &doc, QDomElement &parentElem) const
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
const_iterator constBegin() const
QList< QgsRasterTransparency::TransparentThreeValuePixel > transparentThreeValuePixelList() const
Accessor for transparentThreeValuePixelList.
double percentTransparent
void initializeTransparentPixelList(double)
Reset to the transparency list to a single value.
QDomNode at(int index) const