Skip to content
Permalink
Browse files

[raster] re-compute min/max when band(s) changed (#3923)

  • Loading branch information
nirvn committed Dec 30, 2016
1 parent 882878b commit 46a69dfc6a7b7d78295d1c7302e02430634e0cf2
Showing with 13 additions and 2 deletions.
  1. +10 −1 src/gui/raster/qgsrasterminmaxwidget.cpp
  2. +3 −1 src/gui/raster/qgsrasterminmaxwidget.h
@@ -34,6 +34,7 @@ QgsRasterMinMaxWidget::QgsRasterMinMaxWidget( QgsRasterLayer* theLayer, QWidget
, mLayer( theLayer )
, mCanvas( nullptr )
, mLastRectangleValid( false )
, mBandsChanged( false )
{
QgsDebugMsg( "Entered." );
setupUi( this );
@@ -56,6 +57,12 @@ QgsMapCanvas* QgsRasterMinMaxWidget::mapCanvas()
return mCanvas;
}

void QgsRasterMinMaxWidget::setBands( const QList<int> & theBands )
{
mBandsChanged = theBands != mBands;
mBands = theBands;
}

QgsRectangle QgsRasterMinMaxWidget::extent()
{
const int nExtentIdx = mStatisticsExtentCombo->currentIndex();
@@ -178,7 +185,8 @@ void QgsRasterMinMaxWidget::doComputations()

QgsRasterMinMaxOrigin newMinMaxOrigin = minMaxOrigin();
if ( mLastRectangleValid && mLastRectangle == myExtent &&
mLastMinMaxOrigin == newMinMaxOrigin )
mLastMinMaxOrigin == newMinMaxOrigin &&
!mBandsChanged )
{
QgsDebugMsg( "Does not need to redo statistics computations" );
return;
@@ -187,6 +195,7 @@ void QgsRasterMinMaxWidget::doComputations()
mLastRectangleValid = true;
mLastRectangle = myExtent;
mLastMinMaxOrigin = newMinMaxOrigin;
mBandsChanged = false;

Q_FOREACH ( int myBand, mBands )
{
@@ -61,7 +61,7 @@ class GUI_EXPORT QgsRasterMinMaxWidget: public QWidget, private Ui::QgsRasterMin
*/
QgsMapCanvas* mapCanvas();

void setBands( const QList<int> & theBands ) { mBands = theBands; }
void setBands( const QList<int> & theBands );

/** Return the extent selected by the user.
* Either an empty extent for 'full' or the current visible extent.
@@ -125,6 +125,8 @@ class GUI_EXPORT QgsRasterMinMaxWidget: public QWidget, private Ui::QgsRasterMin
bool mLastRectangleValid;
QgsRectangle mLastRectangle;
QgsRasterMinMaxOrigin mLastMinMaxOrigin;

bool mBandsChanged;
};

#endif // QGSRASTERMINMAXWIDGET_H

0 comments on commit 46a69df

Please sign in to comment.
You can’t perform that action at this time.