19 #include <QMessageBox>
36 , mLastRectangleValid( false )
37 , mBandsChanged( false )
45 connect( mUserDefinedRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mUserDefinedRadioButton_toggled );
46 connect( mMinMaxRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mMinMaxRadioButton_toggled );
47 connect( mStdDevRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mStdDevRadioButton_toggled );
48 connect( mCumulativeCutRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mCumulativeCutRadioButton_toggled );
49 connect( mStatisticsExtentCombo,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterMinMaxWidget::mStatisticsExtentCombo_currentIndexChanged );
50 connect( mCumulativeCutLowerDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMinMaxWidget::mCumulativeCutLowerDoubleSpinBox_valueChanged );
51 connect( mCumulativeCutUpperDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMinMaxWidget::mCumulativeCutUpperDoubleSpinBox_valueChanged );
52 connect( mStdDevSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMinMaxWidget::mStdDevSpinBox_valueChanged );
53 connect( cboAccuracy,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterMinMaxWidget::cboAccuracy_currentIndexChanged );
71 mBandsChanged = bands != mBands;
77 const int nExtentIdx = mStatisticsExtentCombo->currentIndex();
81 if ( mLayer && mCanvas )
91 mUserDefinedRadioButton->setChecked(
true );
95 void QgsRasterMinMaxWidget::mUserDefinedRadioButton_toggled(
bool toggled )
97 mStatisticsExtentCombo->setEnabled( !toggled );
98 cboAccuracy->setEnabled( !toggled );
107 mUserDefinedRadioButton->setChecked(
true );
111 mMinMaxRadioButton->setChecked(
true );
115 mStdDevRadioButton->setChecked(
true );
119 mCumulativeCutRadioButton->setChecked(
true );
149 if ( mMinMaxRadioButton->isChecked() )
151 else if ( mStdDevRadioButton->isChecked() )
153 else if ( mCumulativeCutRadioButton->isChecked() )
158 switch ( mStatisticsExtentCombo->currentIndex() )
172 if ( cboAccuracy->currentIndex() == 0 )
178 mCumulativeCutLowerDoubleSpinBox->value() / 100.0 );
180 mCumulativeCutUpperDoubleSpinBox->value() / 100.0 );
196 if ( mLastRectangleValid && mLastRectangle == myExtent &&
197 mLastMinMaxOrigin == newMinMaxOrigin &&
200 QgsDebugMsgLevel( QStringLiteral(
"Does not need to redo statistics computations" ), 2 );
204 mLastRectangleValid =
true;
205 mLastRectangle = myExtent;
206 mLastMinMaxOrigin = newMinMaxOrigin;
207 mBandsChanged =
false;
209 for (
const int myBand : std::as_const( mBands ) )
216 double myMin = std::numeric_limits<double>::quiet_NaN();
217 double myMax = std::numeric_limits<double>::quiet_NaN();
219 bool updateMinMax =
false;
220 if ( mCumulativeCutRadioButton->isChecked() )
223 const double myLower = mCumulativeCutLowerDoubleSpinBox->value() / 100.0;
224 const double myUpper = mCumulativeCutUpperDoubleSpinBox->value() / 100.0;
227 else if ( mMinMaxRadioButton->isChecked() )
235 else if ( mStdDevRadioButton->isChecked() )
239 const double myStdDev = mStdDevSpinBox->value();
240 myMin = myRasterBandStats.
mean - ( myStdDev * myRasterBandStats.
stdDev );
241 myMax = myRasterBandStats.
mean + ( myStdDev * myRasterBandStats.
stdDev );
245 emit
load( myBand, myMin, myMax );