@@ -61,10 +61,10 @@ QgsSingleBandGrayRendererWidget::QgsSingleBandGrayRendererWidget( QgsRasterLayer
61
61
}
62
62
63
63
// contrast enhancement algorithms
64
- mContrastEnhancementComboBox ->addItem ( tr ( " No enhancement" ), 0 );
65
- mContrastEnhancementComboBox ->addItem ( tr ( " Stretch to MinMax" ), 1 );
66
- mContrastEnhancementComboBox ->addItem ( tr ( " Stretch and clip to MinMax" ), 2 );
67
- mContrastEnhancementComboBox ->addItem ( tr ( " Clip to MinMax" ), 3 );
64
+ mContrastEnhancementComboBox ->addItem ( tr ( " No enhancement" ), QgsContrastEnhancement::NoEnhancement );
65
+ mContrastEnhancementComboBox ->addItem ( tr ( " Stretch to MinMax" ), QgsContrastEnhancement::StretchToMinimumMaximum );
66
+ mContrastEnhancementComboBox ->addItem ( tr ( " Stretch and clip to MinMax" ), QgsContrastEnhancement::StretchAndClipToMinimumMaximum );
67
+ mContrastEnhancementComboBox ->addItem ( tr ( " Clip to MinMax" ), QgsContrastEnhancement::ClipToMinimumMaximum );
68
68
69
69
setFromRenderer ( layer->renderer () );
70
70
@@ -96,8 +96,7 @@ QgsRasterRenderer* QgsSingleBandGrayRendererWidget::renderer()
96
96
provider->dataType ( band ) ) );
97
97
e->setMinimumValue ( mMinLineEdit ->text ().toDouble () );
98
98
e->setMaximumValue ( mMaxLineEdit ->text ().toDouble () );
99
- e->setContrastEnhancementAlgorithm (( QgsContrastEnhancement::ContrastEnhancementAlgorithm )( mContrastEnhancementComboBox ->itemData (
100
- mContrastEnhancementComboBox ->currentIndex () ).toInt () ) );
99
+ e->setContrastEnhancementAlgorithm (( QgsContrastEnhancement::ContrastEnhancementAlgorithm )( mContrastEnhancementComboBox ->currentData ().toInt () ) );
101
100
102
101
103
102
QgsSingleBandGrayRenderer* renderer = new QgsSingleBandGrayRenderer ( provider, band );
@@ -137,6 +136,12 @@ void QgsSingleBandGrayRendererWidget::loadMinMax( int theBandNo, double theMin,
137
136
{
138
137
mMaxLineEdit ->setText ( QString::number ( theMax ) );
139
138
}
139
+
140
+ // automaticlly activate contrast enhancement algorithm if set to none
141
+ if ( mContrastEnhancementComboBox ->currentData ().toInt () == QgsContrastEnhancement::NoEnhancement )
142
+ {
143
+ mContrastEnhancementComboBox ->setCurrentIndex ( mContrastEnhancementComboBox ->findData ( QgsContrastEnhancement::StretchToMinimumMaximum ) );
144
+ }
140
145
}
141
146
142
147
void QgsSingleBandGrayRendererWidget::on_mGrayBandComboBox_currentIndexChanged ( int index )
0 commit comments