19 #include <QMessageBox>
35 , mLastRectangleValid( false )
36 , mBandsChanged( false )
40 connect( mUserDefinedRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mUserDefinedRadioButton_toggled );
41 connect( mMinMaxRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mMinMaxRadioButton_toggled );
42 connect( mStdDevRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mStdDevRadioButton_toggled );
43 connect( mCumulativeCutRadioButton, &QRadioButton::toggled,
this, &QgsRasterMinMaxWidget::mCumulativeCutRadioButton_toggled );
44 connect( mStatisticsExtentCombo,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterMinMaxWidget::mStatisticsExtentCombo_currentIndexChanged );
45 connect( mCumulativeCutLowerDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMinMaxWidget::mCumulativeCutLowerDoubleSpinBox_valueChanged );
46 connect( mCumulativeCutUpperDoubleSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMinMaxWidget::mCumulativeCutUpperDoubleSpinBox_valueChanged );
47 connect( mStdDevSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsRasterMinMaxWidget::mStdDevSpinBox_valueChanged );
48 connect( cboAccuracy,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsRasterMinMaxWidget::cboAccuracy_currentIndexChanged );
66 mBandsChanged = bands != mBands;
72 const int nExtentIdx = mStatisticsExtentCombo->currentIndex();
76 if ( mLayer && mCanvas )
86 mUserDefinedRadioButton->setChecked(
true );
90 void QgsRasterMinMaxWidget::mUserDefinedRadioButton_toggled(
bool toggled )
92 mStatisticsExtentCombo->setEnabled( !toggled );
93 cboAccuracy->setEnabled( !toggled );
102 mUserDefinedRadioButton->setChecked(
true );
106 mMinMaxRadioButton->setChecked(
true );
110 mStdDevRadioButton->setChecked(
true );
114 mCumulativeCutRadioButton->setChecked(
true );
144 if ( mMinMaxRadioButton->isChecked() )
146 else if ( mStdDevRadioButton->isChecked() )
148 else if ( mCumulativeCutRadioButton->isChecked() )
153 switch ( mStatisticsExtentCombo->currentIndex() )
167 if ( cboAccuracy->currentIndex() == 0 )
173 mCumulativeCutLowerDoubleSpinBox->value() / 100.0 );
175 mCumulativeCutUpperDoubleSpinBox->value() / 100.0 );
191 if ( mLastRectangleValid && mLastRectangle == myExtent &&
192 mLastMinMaxOrigin == newMinMaxOrigin &&
195 QgsDebugMsg( QStringLiteral(
"Does not need to redo statistics computations" ) );
199 mLastRectangleValid =
true;
200 mLastRectangle = myExtent;
201 mLastMinMaxOrigin = newMinMaxOrigin;
202 mBandsChanged =
false;
204 const auto constMBands = mBands;
205 for (
int myBand : constMBands )
207 QgsDebugMsg( QStringLiteral(
"myBand = %1" ).arg( myBand ) );
212 double myMin = std::numeric_limits<double>::quiet_NaN();
213 double myMax = std::numeric_limits<double>::quiet_NaN();
215 bool updateMinMax =
false;
216 if ( mCumulativeCutRadioButton->isChecked() )
219 double myLower = mCumulativeCutLowerDoubleSpinBox->value() / 100.0;
220 double myUpper = mCumulativeCutUpperDoubleSpinBox->value() / 100.0;
223 else if ( mMinMaxRadioButton->isChecked() )
231 else if ( mStdDevRadioButton->isChecked() )
235 double myStdDev = mStdDevSpinBox->value();
236 myMin = myRasterBandStats.
mean - ( myStdDev * myRasterBandStats.
stdDev );
237 myMax = myRasterBandStats.
mean + ( myStdDev * myRasterBandStats.
stdDev );
241 emit
load( myBand, myMin, myMax );