Skip to content

Commit 46a69df

Browse files
authored
[raster] re-compute min/max when band(s) changed (#3923)
1 parent 882878b commit 46a69df

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/gui/raster/qgsrasterminmaxwidget.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ QgsRasterMinMaxWidget::QgsRasterMinMaxWidget( QgsRasterLayer* theLayer, QWidget
3434
, mLayer( theLayer )
3535
, mCanvas( nullptr )
3636
, mLastRectangleValid( false )
37+
, mBandsChanged( false )
3738
{
3839
QgsDebugMsg( "Entered." );
3940
setupUi( this );
@@ -56,6 +57,12 @@ QgsMapCanvas* QgsRasterMinMaxWidget::mapCanvas()
5657
return mCanvas;
5758
}
5859

60+
void QgsRasterMinMaxWidget::setBands( const QList<int> & theBands )
61+
{
62+
mBandsChanged = theBands != mBands;
63+
mBands = theBands;
64+
}
65+
5966
QgsRectangle QgsRasterMinMaxWidget::extent()
6067
{
6168
const int nExtentIdx = mStatisticsExtentCombo->currentIndex();
@@ -178,7 +185,8 @@ void QgsRasterMinMaxWidget::doComputations()
178185

179186
QgsRasterMinMaxOrigin newMinMaxOrigin = minMaxOrigin();
180187
if ( mLastRectangleValid && mLastRectangle == myExtent &&
181-
mLastMinMaxOrigin == newMinMaxOrigin )
188+
mLastMinMaxOrigin == newMinMaxOrigin &&
189+
!mBandsChanged )
182190
{
183191
QgsDebugMsg( "Does not need to redo statistics computations" );
184192
return;
@@ -187,6 +195,7 @@ void QgsRasterMinMaxWidget::doComputations()
187195
mLastRectangleValid = true;
188196
mLastRectangle = myExtent;
189197
mLastMinMaxOrigin = newMinMaxOrigin;
198+
mBandsChanged = false;
190199

191200
Q_FOREACH ( int myBand, mBands )
192201
{

src/gui/raster/qgsrasterminmaxwidget.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class GUI_EXPORT QgsRasterMinMaxWidget: public QWidget, private Ui::QgsRasterMin
6161
*/
6262
QgsMapCanvas* mapCanvas();
6363

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

6666
/** Return the extent selected by the user.
6767
* Either an empty extent for 'full' or the current visible extent.
@@ -125,6 +125,8 @@ class GUI_EXPORT QgsRasterMinMaxWidget: public QWidget, private Ui::QgsRasterMin
125125
bool mLastRectangleValid;
126126
QgsRectangle mLastRectangle;
127127
QgsRasterMinMaxOrigin mLastMinMaxOrigin;
128+
129+
bool mBandsChanged;
128130
};
129131

130132
#endif // QGSRASTERMINMAXWIDGET_H

0 commit comments

Comments
 (0)