21 #include <QDomDocument> 22 #include <QDomElement> 26 : mCumulativeCutLower( CUMULATIVE_CUT_LOWER )
27 , mCumulativeCutUpper( CUMULATIVE_CUT_UPPER )
28 , mStdDevFactor( DEFAULT_STDDEV_FACTOR )
38 return mLimits == other.mLimits &&
39 mExtent == other.mExtent &&
40 mAccuracy == other.mAccuracy &&
41 std::fabs( mCumulativeCutLower - other.mCumulativeCutLower ) < 1e-5 &&
42 std::fabs( mCumulativeCutUpper - other.mCumulativeCutUpper ) < 1e-5 &&
43 std::fabs( mStdDevFactor - other.mStdDevFactor ) < 1e-5;
51 return QStringLiteral(
"MinMax" );
53 return QStringLiteral(
"StdDev" );
55 return QStringLiteral(
"CumulativeCut" );
59 return QStringLiteral(
"None" );
64 if ( limits == QLatin1String(
"MinMax" ) )
68 else if ( limits == QLatin1String(
"StdDev" ) )
72 else if ( limits == QLatin1String(
"CumulativeCut" ) )
81 switch ( minMaxExtent )
84 return QStringLiteral(
"WholeRaster" );
86 return QStringLiteral(
"CurrentCanvas" );
88 return QStringLiteral(
"UpdatedCanvas" );
90 return QStringLiteral(
"WholeRaster" );
95 if ( extent == QLatin1String(
"WholeRaster" ) )
99 else if ( extent == QLatin1String(
"CurrentCanvas" ) )
103 else if ( extent == QLatin1String(
"UpdatedCanvas" ) )
115 if ( accuracy ==
Exact )
116 return QStringLiteral(
"Exact" );
117 return QStringLiteral(
"Estimated" );
122 if ( accuracy == QLatin1String(
"Exact" ) )
130 QDomElement limitsElem = doc.createElement( QStringLiteral(
"limits" ) );
131 QDomText limitsText = doc.createTextNode(
limitsString( mLimits ) );
132 limitsElem.appendChild( limitsText );
133 parentElem.appendChild( limitsElem );
136 QDomElement extentElem = doc.createElement( QStringLiteral(
"extent" ) );
137 QDomText extentText = doc.createTextNode(
extentString( mExtent ) );
138 extentElem.appendChild( extentText );
139 parentElem.appendChild( extentElem );
142 QDomElement statAccuracyElem = doc.createElement( QStringLiteral(
"statAccuracy" ) );
144 statAccuracyElem.appendChild( statAccuracyText );
145 parentElem.appendChild( statAccuracyElem );
148 QDomElement cumulativeCutLowerElem = doc.createElement( QStringLiteral(
"cumulativeCutLower" ) );
149 QDomText cumulativeCutLowerText = doc.createTextNode( QString::number( mCumulativeCutLower ) );
150 cumulativeCutLowerElem.appendChild( cumulativeCutLowerText );
151 parentElem.appendChild( cumulativeCutLowerElem );
154 QDomElement cumulativeCutUpperElem = doc.createElement( QStringLiteral(
"cumulativeCutUpper" ) );
155 QDomText cumulativeCutUpperText = doc.createTextNode( QString::number( mCumulativeCutUpper ) );
156 cumulativeCutUpperElem.appendChild( cumulativeCutUpperText );
157 parentElem.appendChild( cumulativeCutUpperElem );
160 QDomElement stdDevFactorElem = doc.createElement( QStringLiteral(
"stdDevFactor" ) );
161 QDomText stdDevFactorText = doc.createTextNode( QString::number( mStdDevFactor ) );
162 stdDevFactorElem.appendChild( stdDevFactorText );
163 parentElem.appendChild( stdDevFactorElem );
168 QDomElement limitsElem = elem.firstChildElement( QStringLiteral(
"limits" ) );
169 if ( !limitsElem.isNull() )
174 QDomElement extentElem = elem.firstChildElement( QStringLiteral(
"extent" ) );
175 if ( !extentElem.isNull() )
180 QDomElement statAccuracyElem = elem.firstChildElement( QStringLiteral(
"statAccuracy" ) );
181 if ( !statAccuracyElem.isNull() )
186 QDomElement cumulativeCutLowerElem = elem.firstChildElement( QStringLiteral(
"cumulativeCutLower" ) );
187 if ( !cumulativeCutLowerElem.isNull() )
189 mCumulativeCutLower = cumulativeCutLowerElem.text().toDouble();
192 QDomElement cumulativeCutUpperElem = elem.firstChildElement( QStringLiteral(
"cumulativeCutUpper" ) );
193 if ( !cumulativeCutUpperElem.isNull() )
195 mCumulativeCutUpper = cumulativeCutUpperElem.text().toDouble();
198 QDomElement stdDevFactorElem = elem.firstChildElement( QStringLiteral(
"stdDevFactor" ) );
199 if ( !stdDevFactorElem.isNull() )
201 mStdDevFactor = stdDevFactorElem.text().toDouble();
QgsRasterMinMaxOrigin::Limits limits() const
Returns the raster limits.
QgsRasterMinMaxOrigin::Extent extent() const
Returns the raster extent.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
QgsRasterMinMaxOrigin()
Default constructor.
Extent
This enumerator describes the extent used to compute min/max values.
static Limits limitsFromString(const QString &limits)
Deserialize Limits.
StatAccuracy
This enumerator describes the accuracy used to compute statistics.
static QgsRasterMinMaxOrigin::Extent extentFromString(const QString &extent)
Deserialize Extent.
Current extent of the canvas (at the time of computation) is used to compute statistics.
This class describes the origin of min/max values.
bool operator==(const QgsRasterMinMaxOrigin &other) const
Equality operator.
void readXml(const QDomElement &elem)
Deserialize object.
Constantly updated extent of the canvas is used to compute statistics.
static constexpr double DEFAULT_STDDEV_FACTOR
Default standard deviation factor.
Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ].
static constexpr double CUMULATIVE_CUT_UPPER
Default cumulative cut upper limit.
static constexpr double CUMULATIVE_CUT_LOWER
Default cumulative cut lower limit.
Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ]...
static QString limitsString(Limits limits)
Returns a string to serialize Limits.
static QString extentString(QgsRasterMinMaxOrigin::Extent extent)
Returns a string to serialize Extent.
Limits
This enumerator describes the limits used to compute min/max values.
Whole raster is used to compute statistics.
static QString statAccuracyString(QgsRasterMinMaxOrigin::StatAccuracy accuracy)
Returns a string to serialize StatAccuracy.
static QgsRasterMinMaxOrigin::StatAccuracy statAccuracyFromString(const QString &accuracy)
Deserialize StatAccuracy.
void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Serialize object.