23#include "moc_qgsrasterminmaxwidget.cpp"
32 , mLastRectangleValid( false )
33 , mBandsChanged( false )
48 connect( mUserDefinedRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mUserDefinedRadioButton_toggled );
49 connect( mMinMaxRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mMinMaxRadioButton_toggled );
50 connect( mStdDevRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mStdDevRadioButton_toggled );
51 connect( mCumulativeCutRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mCumulativeCutRadioButton_toggled );
52 connect( mStatisticsExtentCombo,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterMinMaxWidget::mStatisticsExtentCombo_currentIndexChanged );
53 connect( mCumulativeCutLowerDoubleSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMinMaxWidget::mCumulativeCutLowerDoubleSpinBox_valueChanged );
54 connect( mCumulativeCutUpperDoubleSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMinMaxWidget::mCumulativeCutUpperDoubleSpinBox_valueChanged );
55 connect( mStdDevSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMinMaxWidget::mStdDevSpinBox_valueChanged );
56 connect( cboAccuracy,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterMinMaxWidget::cboAccuracy_currentIndexChanged );
74 mBandsChanged = bands != mBands;
91 if ( mLayer && mCanvas )
101 mUserDefinedRadioButton->setChecked(
true );
105void QgsRasterMinMaxWidget::mUserDefinedRadioButton_toggled(
bool toggled )
107 mStatisticsExtentCombo->setEnabled( !toggled );
108 cboAccuracy->setEnabled( !toggled );
117 mUserDefinedRadioButton->setChecked(
true );
121 mMinMaxRadioButton->setChecked(
true );
125 mStdDevRadioButton->setChecked(
true );
129 mCumulativeCutRadioButton->setChecked(
true );
133 mStatisticsExtentCombo->setCurrentIndex( mStatisticsExtentCombo->findData( QVariant::fromValue(
minMaxOrigin.
extent() ) ) );
146 if ( mMinMaxRadioButton->isChecked() )
148 else if ( mStdDevRadioButton->isChecked() )
150 else if ( mCumulativeCutRadioButton->isChecked() )
159 mCumulativeCutLowerDoubleSpinBox->value() / 100.0
162 mCumulativeCutUpperDoubleSpinBox->value() / 100.0
179 if ( mLastRectangleValid && mLastRectangle == myExtent && mLastMinMaxOrigin == newMinMaxOrigin && !mBandsChanged )
181 QgsDebugMsgLevel( QStringLiteral(
"Does not need to redo statistics computations" ), 2 );
185 mLastRectangleValid =
true;
186 mLastRectangle = myExtent;
187 mLastMinMaxOrigin = newMinMaxOrigin;
188 mBandsChanged =
false;
190 for (
const int myBand : std::as_const( mBands ) )
197 double myMin = std::numeric_limits<double>::quiet_NaN();
198 double myMax = std::numeric_limits<double>::quiet_NaN();
200 bool updateMinMax =
false;
201 if ( mCumulativeCutRadioButton->isChecked() )
204 const double myLower = mCumulativeCutLowerDoubleSpinBox->value() / 100.0;
205 const double myUpper = mCumulativeCutUpperDoubleSpinBox->value() / 100.0;
208 else if ( mMinMaxRadioButton->isChecked() )
216 else if ( mStdDevRadioButton->isChecked() )
220 const double myStdDev = mStdDevSpinBox->value();
221 myMin = myRasterBandStats.
mean - ( myStdDev * myRasterBandStats.
stdDev );
222 myMax = myRasterBandStats.
mean + ( myStdDev * myRasterBandStats.
stdDev );
226 emit
load( myBand, myMin, myMax );
@ CumulativeCut
Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ].
@ StdDev
Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ].
@ MinimumMaximum
Real min-max values.
RasterRangeAccuracy
Describes the accuracy used to compute raster ranges (min/max values).
@ Estimated
Approximated statistics.
@ StdDev
Standard deviation.
RasterRangeExtent
Describes the extent used to compute raster ranges (min/max values).
@ UpdatedCanvas
Constantly updated extent of the canvas is used to compute statistics.
@ WholeRaster
Whole raster is used to compute statistics.
@ FixedCanvas
Current extent of the canvas (at the time of computation) is used to compute statistics.
@ MaximumValue
Reset value to maximum()
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
QgsRectangle outputExtentToLayerExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from output CRS to layer's CRS
The RasterBandStats struct is a container for statistics about a single raster band.
double mean
The mean cell value for the band. NO_DATA values are excluded.
double stdDev
The standard deviation of the cell values.
double minimumValue
The minimum cell value in the raster band.
double maximumValue
The maximum cell value in the raster band.
virtual void cumulativeCut(int bandNo, double lowerCount, double upperCount, double &lowerValue, double &upperValue, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0)
Find values for cumulative pixel count cut.
Q_DECL_DEPRECATED QgsRasterBandStats bandStatistics(int bandNo, int stats, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
virtual int bandCount() const =0
Gets number of bands.
Represents a raster layer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
This class describes the origin of min/max values.
void setLimits(Qgis::RasterRangeLimit limits)
Sets the limits.
void setExtent(Qgis::RasterRangeExtent extent)
Sets the extent.
double cumulativeCutLower() const
Returns the lower bound of cumulative cut method (between 0 and 1).
Qgis::RasterRangeExtent extent() const
Returns the raster extent.
double stdDevFactor() const
Returns the factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ].
void setCumulativeCutUpper(double val)
Sets the upper bound of cumulative cut method (between 0 and 1).
void setStdDevFactor(double val)
Sets the factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ].
double cumulativeCutUpper() const
Returns the upper bound of cumulative cut method (between 0 and 1).
void setCumulativeCutLower(double val)
Sets the lower bound of cumulative cut method (between 0 and 1).
Qgis::RasterRangeAccuracy statAccuracy() const
Returns the raster statistic accuracy.
Qgis::RasterRangeLimit limits() const
Returns the raster limits.
void setStatAccuracy(Qgis::RasterRangeAccuracy accuracy)
Sets the statistics accuracy.
A rectangle specified with double values.
#define QgsDebugMsgLevel(str, level)