27 , mDisableMinMaxWidgetRefresh( false )
30 connect( mRedMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mRedMinLineEdit_textChanged );
31 connect( mRedMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mRedMaxLineEdit_textChanged );
32 connect( mGreenMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mGreenMinLineEdit_textChanged );
33 connect( mGreenMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mGreenMaxLineEdit_textChanged );
34 connect( mBlueMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mBlueMinLineEdit_textChanged );
35 connect( mBlueMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mBlueMaxLineEdit_textChanged );
49 QHBoxLayout *layout =
new QHBoxLayout();
50 layout->setContentsMargins( 0, 0, 0, 0 );
51 mMinMaxContainerWidget->setLayout( layout );
52 layout->addWidget( mMinMaxWidget );
60 this, &QgsMultiBandColorRendererWidget::onBandChanged );
62 this, &QgsMultiBandColorRendererWidget::onBandChanged );
64 this, &QgsMultiBandColorRendererWidget::onBandChanged );
66 mRedBandComboBox->setShowNotSetOption(
true );
67 mGreenBandComboBox->setShowNotSetOption(
true );
68 mBlueBandComboBox->setShowNotSetOption(
true );
98 const int redBand = mRedBandComboBox->currentBand();
99 const int greenBand = mGreenBandComboBox->currentBand();
100 const int blueBand = mBlueBandComboBox->currentBand();
103 setCustomMinMaxValues( r, provider, redBand, greenBand, blueBand );
121 void QgsMultiBandColorRendererWidget::createValidators()
133 int redBand,
int greenBand,
int blueBand )
135 if ( !r || !provider )
144 bool redMinOk, redMaxOk;
147 if ( redMinOk && redMaxOk && redBand != -1 )
155 bool greenMinOk, greenMaxOk;
158 if ( greenMinOk && greenMaxOk && greenBand != -1 )
161 provider->
dataType( greenBand ) ) );
166 bool blueMinOk, blueMaxOk;
169 if ( blueMinOk && blueMaxOk && blueBand != -1 )
177 if ( redEnhancement )
180 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
182 if ( greenEnhancement )
185 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
187 if ( blueEnhancement )
190 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
197 void QgsMultiBandColorRendererWidget::onBandChanged(
int index )
202 myBands.append( mRedBandComboBox->currentBand() );
203 myBands.append( mGreenBandComboBox->currentBand() );
204 myBands.append( mBlueBandComboBox->currentBand() );
209 void QgsMultiBandColorRendererWidget::mRedMinLineEdit_textChanged(
const QString & )
214 void QgsMultiBandColorRendererWidget::mRedMaxLineEdit_textChanged(
const QString & )
219 void QgsMultiBandColorRendererWidget::mGreenMinLineEdit_textChanged(
const QString & )
224 void QgsMultiBandColorRendererWidget::mGreenMaxLineEdit_textChanged(
const QString & )
229 void QgsMultiBandColorRendererWidget::mBlueMinLineEdit_textChanged(
const QString & )
234 void QgsMultiBandColorRendererWidget::mBlueMaxLineEdit_textChanged(
const QString & )
239 void QgsMultiBandColorRendererWidget::minMaxModified()
241 if ( !mDisableMinMaxWidgetRefresh )
245 mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
255 QgsDebugMsg( QStringLiteral(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg(
min ).arg(
max ) );
257 QLineEdit *myMinLineEdit, *myMaxLineEdit;
259 if ( mRedBandComboBox->currentBand() == bandNo )
261 myMinLineEdit = mRedMinLineEdit;
262 myMaxLineEdit = mRedMaxLineEdit;
264 else if ( mGreenBandComboBox->currentBand() == bandNo )
266 myMinLineEdit = mGreenMinLineEdit;
267 myMaxLineEdit = mGreenMaxLineEdit;
269 else if ( mBlueBandComboBox->currentBand() == bandNo )
271 myMinLineEdit = mBlueMinLineEdit;
272 myMaxLineEdit = mBlueMaxLineEdit;
280 mDisableMinMaxWidgetRefresh =
true;
281 if ( std::isnan(
min ) )
283 myMinLineEdit->clear();
287 myMinLineEdit->setText( QLocale().toString(
min ) );
290 if ( std::isnan(
max ) )
292 myMaxLineEdit->clear();
296 myMaxLineEdit->setText( QLocale().toString(
max ) );
298 mDisableMinMaxWidgetRefresh =
false;
301 void QgsMultiBandColorRendererWidget::setMinMaxValue(
const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit )
303 if ( !minEdit || !maxEdit )
315 minEdit->setText( QLocale().toString( ce->
minimumValue() ) );
316 maxEdit->setText( QLocale().toString( ce->
maximumValue() ) );
320 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
329 mRedBandComboBox->setBand( mbcr->
redBand() );
330 mGreenBandComboBox->setBand( mbcr->
greenBand() );
331 mBlueBandComboBox->setBand( mbcr->
blueBand() );
333 mDisableMinMaxWidgetRefresh =
true;
337 mDisableMinMaxWidgetRefresh =
false;
343 if ( mRedBandComboBox->findText( tr(
"Red" ) ) > -1 && mRedBandComboBox->findText( tr(
"Green" ) ) > -1 &&
344 mRedBandComboBox->findText( tr(
"Blue" ) ) > -1 )
346 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findText( tr(
"Red" ) ) );
347 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findText( tr(
"Green" ) ) );
348 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findText( tr(
"Blue" ) ) );
352 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 1 ? 1 : 0 );
353 mGreenBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 2 ? 2 : 0 );
354 mBlueBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 3 ? 3 : 0 );
364 return mRedMinLineEdit->text();
366 return mGreenMinLineEdit->text();
368 return mBlueMinLineEdit->text();
380 return mRedMaxLineEdit->text();
382 return mGreenMaxLineEdit->text();
384 return mBlueMaxLineEdit->text();
393 mDisableMinMaxWidgetRefresh =
true;
397 mRedMinLineEdit->setText( value );
400 mGreenMinLineEdit->setText( value );
403 mBlueMinLineEdit->setText( value );
408 mDisableMinMaxWidgetRefresh =
false;
413 mDisableMinMaxWidgetRefresh =
true;
417 mRedMaxLineEdit->setText( value );
420 mGreenMaxLineEdit->setText( value );
423 mBlueMaxLineEdit->setText( value );
428 mDisableMinMaxWidgetRefresh =
false;
436 return mRedBandComboBox->currentBand();
438 return mGreenBandComboBox->currentBand();
440 return mBlueBandComboBox->currentBand();
454 mDisableMinMaxWidgetRefresh =
true;
455 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
static_cast<int>(
algorithm ) ) );
456 mDisableMinMaxWidgetRefresh =
false;