21 #include <QDomDocument> 22 #include <QDomElement> 25 : mCumulativeCutLower( CUMULATIVE_CUT_LOWER )
26 , mCumulativeCutUpper( CUMULATIVE_CUT_UPPER )
27 , mStdDevFactor( DEFAULT_STDDEV_FACTOR )
37 return mLimits == other.mLimits &&
38 mExtent == other.mExtent &&
39 mAccuracy == other.mAccuracy &&
40 std::fabs( mCumulativeCutLower - other.mCumulativeCutLower ) < 1e-5 &&
41 std::fabs( mCumulativeCutUpper - other.mCumulativeCutUpper ) < 1e-5 &&
42 std::fabs( mStdDevFactor - other.mStdDevFactor ) < 1e-5;
50 return QStringLiteral(
"MinMax" );
52 return QStringLiteral(
"StdDev" );
54 return QStringLiteral(
"CumulativeCut" );
58 return QStringLiteral(
"None" );
63 if ( limits == QLatin1String(
"MinMax" ) )
67 else if ( limits == QLatin1String(
"StdDev" ) )
71 else if ( limits == QLatin1String(
"CumulativeCut" ) )
80 switch ( minMaxExtent )
83 return QStringLiteral(
"WholeRaster" );
85 return QStringLiteral(
"CurrentCanvas" );
87 return QStringLiteral(
"UpdatedCanvas" );
89 return QStringLiteral(
"WholeRaster" );
94 if ( extent == QLatin1String(
"WholeRaster" ) )
98 else if ( extent == QLatin1String(
"CurrentCanvas" ) )
102 else if ( extent == QLatin1String(
"UpdatedCanvas" ) )
114 if ( accuracy ==
Exact )
115 return QStringLiteral(
"Exact" );
116 return QStringLiteral(
"Estimated" );
121 if ( accuracy == QLatin1String(
"Exact" ) )
129 QDomElement limitsElem = doc.createElement( QStringLiteral(
"limits" ) );
130 QDomText limitsText = doc.createTextNode(
limitsString( mLimits ) );
131 limitsElem.appendChild( limitsText );
132 parentElem.appendChild( limitsElem );
135 QDomElement extentElem = doc.createElement( QStringLiteral(
"extent" ) );
136 QDomText extentText = doc.createTextNode(
extentString( mExtent ) );
137 extentElem.appendChild( extentText );
138 parentElem.appendChild( extentElem );
141 QDomElement statAccuracyElem = doc.createElement( QStringLiteral(
"statAccuracy" ) );
143 statAccuracyElem.appendChild( statAccuracyText );
144 parentElem.appendChild( statAccuracyElem );
147 QDomElement cumulativeCutLowerElem = doc.createElement( QStringLiteral(
"cumulativeCutLower" ) );
148 QDomText cumulativeCutLowerText = doc.createTextNode( QString::number( mCumulativeCutLower ) );
149 cumulativeCutLowerElem.appendChild( cumulativeCutLowerText );
150 parentElem.appendChild( cumulativeCutLowerElem );
153 QDomElement cumulativeCutUpperElem = doc.createElement( QStringLiteral(
"cumulativeCutUpper" ) );
154 QDomText cumulativeCutUpperText = doc.createTextNode( QString::number( mCumulativeCutUpper ) );
155 cumulativeCutUpperElem.appendChild( cumulativeCutUpperText );
156 parentElem.appendChild( cumulativeCutUpperElem );
159 QDomElement stdDevFactorElem = doc.createElement( QStringLiteral(
"stdDevFactor" ) );
160 QDomText stdDevFactorText = doc.createTextNode( QString::number( mStdDevFactor ) );
161 stdDevFactorElem.appendChild( stdDevFactorText );
162 parentElem.appendChild( stdDevFactorElem );
167 QDomElement limitsElem = elem.firstChildElement( QStringLiteral(
"limits" ) );
168 if ( !limitsElem.isNull() )
173 QDomElement extentElem = elem.firstChildElement( QStringLiteral(
"extent" ) );
174 if ( !extentElem.isNull() )
179 QDomElement statAccuracyElem = elem.firstChildElement( QStringLiteral(
"statAccuracy" ) );
180 if ( !statAccuracyElem.isNull() )
185 QDomElement cumulativeCutLowerElem = elem.firstChildElement( QStringLiteral(
"cumulativeCutLower" ) );
186 if ( !cumulativeCutLowerElem.isNull() )
188 mCumulativeCutLower = cumulativeCutLowerElem.text().toDouble();
191 QDomElement cumulativeCutUpperElem = elem.firstChildElement( QStringLiteral(
"cumulativeCutUpper" ) );
192 if ( !cumulativeCutUpperElem.isNull() )
194 mCumulativeCutUpper = cumulativeCutUpperElem.text().toDouble();
197 QDomElement stdDevFactorElem = elem.firstChildElement( QStringLiteral(
"stdDevFactor" ) );
198 if ( !stdDevFactorElem.isNull() )
200 mStdDevFactor = stdDevFactorElem.text().toDouble();
This class is a composition of two QSettings instances:
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.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
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.
QgsRasterMinMaxOrigin::Extent extent() const
Returns the raster extent.
bool operator==(const QgsRasterMinMaxOrigin &other) const
Equality operator.
QgsRasterMinMaxOrigin::Limits limits() const
Returns the raster limits.
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.