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 );
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() ) ) );
135 mCumulativeCutLowerDoubleSpinBox->setValue( 100.0 *
minMaxOrigin.cumulativeCutLower() );
136 mCumulativeCutUpperDoubleSpinBox->setValue( 100.0 *
minMaxOrigin.cumulativeCutUpper() );
137 mStdDevSpinBox->setValue(
minMaxOrigin.stdDevFactor() );
139 cboAccuracy->setCurrentIndex( cboAccuracy->findData( QVariant::fromValue(
minMaxOrigin.statAccuracy() ) ) );
172 if ( !mLayer->dataProvider() )
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 ) )
193 if ( myBand < 1 || myBand > mLayer->dataProvider()->bandCount() )
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;
206 mLayer->dataProvider()->cumulativeCut( myBand, myLower, myUpper, myMin, myMax, myExtent, mySampleSize );
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 );