21#include <QDomDocument> 
   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  const QDomText limitsText = doc.createTextNode( 
limitsString( mLimits ) );
 
  132  limitsElem.appendChild( limitsText );
 
  133  parentElem.appendChild( limitsElem );
 
  136  QDomElement extentElem = doc.createElement( QStringLiteral( 
"extent" ) );
 
  137  const QDomText extentText = doc.createTextNode( 
extentString( mExtent ) );
 
  138  extentElem.appendChild( extentText );
 
  139  parentElem.appendChild( extentElem );
 
  142  QDomElement statAccuracyElem = doc.createElement( QStringLiteral( 
"statAccuracy" ) );
 
  143  const QDomText statAccuracyText = doc.createTextNode( 
statAccuracyString( mAccuracy ) );
 
  144  statAccuracyElem.appendChild( statAccuracyText );
 
  145  parentElem.appendChild( statAccuracyElem );
 
  148  QDomElement cumulativeCutLowerElem = doc.createElement( QStringLiteral( 
"cumulativeCutLower" ) );
 
  149  const QDomText cumulativeCutLowerText = doc.createTextNode( QString::number( mCumulativeCutLower ) );
 
  150  cumulativeCutLowerElem.appendChild( cumulativeCutLowerText );
 
  151  parentElem.appendChild( cumulativeCutLowerElem );
 
  154  QDomElement cumulativeCutUpperElem = doc.createElement( QStringLiteral( 
"cumulativeCutUpper" ) );
 
  155  const QDomText cumulativeCutUpperText = doc.createTextNode( QString::number( mCumulativeCutUpper ) );
 
  156  cumulativeCutUpperElem.appendChild( cumulativeCutUpperText );
 
  157  parentElem.appendChild( cumulativeCutUpperElem );
 
  160  QDomElement stdDevFactorElem = doc.createElement( QStringLiteral( 
"stdDevFactor" ) );
 
  161  const QDomText stdDevFactorText = doc.createTextNode( QString::number( mStdDevFactor ) );
 
  162  stdDevFactorElem.appendChild( stdDevFactorText );
 
  163  parentElem.appendChild( stdDevFactorElem );
 
 
  168  const QDomElement limitsElem = elem.firstChildElement( QStringLiteral( 
"limits" ) );
 
  169  if ( !limitsElem.isNull() )
 
  174  const QDomElement extentElem = elem.firstChildElement( QStringLiteral( 
"extent" ) );
 
  175  if ( !extentElem.isNull() )
 
  180  const QDomElement statAccuracyElem = elem.firstChildElement( QStringLiteral( 
"statAccuracy" ) );
 
  181  if ( !statAccuracyElem.isNull() )
 
  186  const QDomElement cumulativeCutLowerElem = elem.firstChildElement( QStringLiteral( 
"cumulativeCutLower" ) );
 
  187  if ( !cumulativeCutLowerElem.isNull() )
 
  189    mCumulativeCutLower = cumulativeCutLowerElem.text().toDouble();
 
  192  const QDomElement cumulativeCutUpperElem = elem.firstChildElement( QStringLiteral( 
"cumulativeCutUpper" ) );
 
  193  if ( !cumulativeCutUpperElem.isNull() )
 
  195    mCumulativeCutUpper = cumulativeCutUpperElem.text().toDouble();
 
  198  const QDomElement stdDevFactorElem = elem.firstChildElement( QStringLiteral( 
"stdDevFactor" ) );
 
  199  if ( !stdDevFactorElem.isNull() )
 
  201    mStdDevFactor = stdDevFactorElem.text().toDouble();
 
 
This class describes the origin of min/max values.
static QString limitsString(Limits limits)
Returns a string to serialize Limits.
static QgsRasterMinMaxOrigin::Extent extentFromString(const QString &extent)
Deserialize Extent.
StatAccuracy
This enumerator describes the accuracy used to compute statistics.
@ Estimated
Approximated statistics.
QgsRasterMinMaxOrigin::Limits limits() const
Returns the raster limits.
static constexpr double CUMULATIVE_CUT_UPPER
Default cumulative cut upper limit.
static QgsRasterMinMaxOrigin::StatAccuracy statAccuracyFromString(const QString &accuracy)
Deserialize StatAccuracy.
static QString statAccuracyString(QgsRasterMinMaxOrigin::StatAccuracy accuracy)
Returns a string to serialize StatAccuracy.
Extent
This enumerator describes the extent used to compute min/max values.
@ UpdatedCanvas
Constantly updated extent of the canvas is used to compute statistics.
@ CurrentCanvas
Current extent of the canvas (at the time of computation) is used to compute statistics.
@ WholeRaster
Whole raster is used to compute statistics.
static constexpr double DEFAULT_STDDEV_FACTOR
Default standard deviation factor.
static QString extentString(QgsRasterMinMaxOrigin::Extent extent)
Returns a string to serialize Extent.
bool operator==(const QgsRasterMinMaxOrigin &other) const
Equality operator.
static constexpr double CUMULATIVE_CUT_LOWER
Default cumulative cut lower limit.
QgsRasterMinMaxOrigin()
Default constructor.
void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Serialize object.
void readXml(const QDomElement &elem)
Deserialize object.
Limits
This enumerator describes the limits used to compute min/max values.
@ StdDev
Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ].
@ MinMax
Real min-max values.
@ CumulativeCut
Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ].
static Limits limitsFromString(const QString &limits)
Deserialize 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.