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 );
    99   switch ( minMaxOrigin.
limits() )
   103       mUserDefinedRadioButton->setChecked( 
true );
   107       mMinMaxRadioButton->setChecked( 
true );
   111       mStdDevRadioButton->setChecked( 
true );
   115       mCumulativeCutRadioButton->setChecked( 
true );
   119   switch ( minMaxOrigin.
extent() )
   135   mCumulativeCutLowerDoubleSpinBox->setValue( 100.0 * minMaxOrigin.
cumulativeCutLower() );
   136   mCumulativeCutUpperDoubleSpinBox->setValue( 100.0 * minMaxOrigin.
cumulativeCutUpper() );
   137   mStdDevSpinBox->setValue( minMaxOrigin.
stdDevFactor() );
   146   if ( mMinMaxRadioButton->isChecked() )
   148   else if ( mStdDevRadioButton->isChecked() )
   150   else if ( mCumulativeCutRadioButton->isChecked() )
   155   switch ( mStatisticsExtentCombo->currentIndex() )
   169   if ( cboAccuracy->currentIndex() == 0 )
   175     mCumulativeCutLowerDoubleSpinBox->value() / 100.0 );
   177     mCumulativeCutUpperDoubleSpinBox->value() / 100.0 );
   191   if ( mLastRectangleValid && mLastRectangle == myExtent &&
   192        mLastMinMaxOrigin == newMinMaxOrigin &&
   195     QgsDebugMsg( 
"Does not need to redo statistics computations" );
   199   mLastRectangleValid = 
true;
   200   mLastRectangle = myExtent;
   201   mLastMinMaxOrigin = newMinMaxOrigin;
   202   mBandsChanged = 
false;
   204   Q_FOREACH ( 
int myBand, mBands )
   206     QgsDebugMsg( QString( 
"myBand = %1" ).arg( myBand ) );
   211     double myMin = std::numeric_limits<double>::quiet_NaN();
   212     double myMax = std::numeric_limits<double>::quiet_NaN();
   214     bool updateMinMax = 
false;
   215     if ( mCumulativeCutRadioButton->isChecked() )
   218       double myLower = mCumulativeCutLowerDoubleSpinBox->value() / 100.0;
   219       double myUpper = mCumulativeCutUpperDoubleSpinBox->value() / 100.0;
   222     else if ( mMinMaxRadioButton->isChecked() )
   230     else if ( mStdDevRadioButton->isChecked() )
   234       double myStdDev = mStdDevSpinBox->value();
   235       myMin = myRasterBandStats.
mean - ( myStdDev * myRasterBandStats.
stdDev );
   236       myMax = myRasterBandStats.
mean + ( myStdDev * myRasterBandStats.
stdDev );
   240       emit 
load( myBand, myMin, myMax );
 QgsRasterMinMaxOrigin::Limits limits() const
Returns the raster limits. 
 
virtual int bandCount() const =0
Gets number of bands. 
 
QgsRasterMinMaxOrigin::Extent extent() const
Returns the raster extent. 
 
A rectangle specified with double values. 
 
This class provides qgis with the ability to render raster datasets onto the mapcanvas. 
 
QgsRectangle outputExtentToLayerExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from output CRS to layer's CRS 
 
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. 
 
Map canvas is a class for displaying all GIS data types on a canvas. 
 
Current extent of the canvas (at the time of computation) is used to compute statistics. 
 
void setExtent(QgsRasterMinMaxOrigin::Extent extent)
Sets the extent. 
 
double cumulativeCutLower() const
Returns the lower bound of cumulative cut method (between 0 and 1). 
 
double stdDev
The standard deviation of the cell values. 
 
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider. 
 
This class describes the origin of min/max values. 
 
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 cumulativeCutUpper() const
Returns the upper bound of cumulative cut method (between 0 and 1). 
 
QgsRectangle extent() const
Returns the current zoom extent of the map canvas. 
 
Constantly updated extent of the canvas is used to compute statistics. 
 
Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ]. 
 
void setStdDevFactor(double val)
Sets the factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ]...
 
Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ]...
 
void setCumulativeCutLower(double val)
Sets the lower bound of cumulative cut method (between 0 and 1). 
 
void setLimits(QgsRasterMinMaxOrigin::Limits limits)
Sets the limits. 
 
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering. 
 
virtual QgsRasterBandStats bandStatistics(int bandNo, int stats=QgsRasterBandStats::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics. 
 
void setStatAccuracy(QgsRasterMinMaxOrigin::StatAccuracy accuracy)
Sets the statistics accuracy. 
 
Whole raster is used to compute statistics. 
 
double minimumValue
The minimum cell value in the raster band. 
 
QgsRasterMinMaxOrigin::StatAccuracy statAccuracy() const
Returns the raster statistic accuracy. 
 
void setCumulativeCutUpper(double val)
Sets the upper bound of cumulative cut method (between 0 and 1). 
 
double stdDevFactor() const
Returns the factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ]...