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 )
140 if ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ==
153 bool redMinOk, redMaxOk;
156 if ( redMinOk && redMaxOk && redBand != -1 )
164 bool greenMinOk, greenMaxOk;
167 if ( greenMinOk && greenMaxOk && greenBand != -1 )
170 provider->
dataType( greenBand ) ) );
175 bool blueMinOk, blueMaxOk;
178 if ( blueMinOk && blueMaxOk && blueBand != -1 )
186 if ( redEnhancement )
189 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
191 if ( greenEnhancement )
194 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
196 if ( blueEnhancement )
199 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
206 void QgsMultiBandColorRendererWidget::onBandChanged(
int index )
211 myBands.append( mRedBandComboBox->currentBand() );
212 myBands.append( mGreenBandComboBox->currentBand() );
213 myBands.append( mBlueBandComboBox->currentBand() );
218 void QgsMultiBandColorRendererWidget::mRedMinLineEdit_textChanged(
const QString & )
223 void QgsMultiBandColorRendererWidget::mRedMaxLineEdit_textChanged(
const QString & )
228 void QgsMultiBandColorRendererWidget::mGreenMinLineEdit_textChanged(
const QString & )
233 void QgsMultiBandColorRendererWidget::mGreenMaxLineEdit_textChanged(
const QString & )
238 void QgsMultiBandColorRendererWidget::mBlueMinLineEdit_textChanged(
const QString & )
243 void QgsMultiBandColorRendererWidget::mBlueMaxLineEdit_textChanged(
const QString & )
248 void QgsMultiBandColorRendererWidget::minMaxModified()
250 if ( !mDisableMinMaxWidgetRefresh )
254 mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
264 QgsDebugMsg( QStringLiteral(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg(
min ).arg(
max ) );
266 QLineEdit *myMinLineEdit, *myMaxLineEdit;
268 if ( mRedBandComboBox->currentBand() == bandNo )
270 myMinLineEdit = mRedMinLineEdit;
271 myMaxLineEdit = mRedMaxLineEdit;
273 else if ( mGreenBandComboBox->currentBand() == bandNo )
275 myMinLineEdit = mGreenMinLineEdit;
276 myMaxLineEdit = mGreenMaxLineEdit;
278 else if ( mBlueBandComboBox->currentBand() == bandNo )
280 myMinLineEdit = mBlueMinLineEdit;
281 myMaxLineEdit = mBlueMaxLineEdit;
289 mDisableMinMaxWidgetRefresh =
true;
290 if ( std::isnan(
min ) )
292 myMinLineEdit->clear();
296 myMinLineEdit->setText( QLocale().toString(
min ) );
299 if ( std::isnan(
max ) )
301 myMaxLineEdit->clear();
305 myMaxLineEdit->setText( QLocale().toString(
max ) );
307 mDisableMinMaxWidgetRefresh =
false;
310 void QgsMultiBandColorRendererWidget::setMinMaxValue(
const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit )
312 if ( !minEdit || !maxEdit )
324 minEdit->setText( QLocale().toString( ce->
minimumValue() ) );
325 maxEdit->setText( QLocale().toString( ce->
maximumValue() ) );
329 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
338 mRedBandComboBox->setBand( mbcr->
redBand() );
339 mGreenBandComboBox->setBand( mbcr->
greenBand() );
340 mBlueBandComboBox->setBand( mbcr->
blueBand() );
342 mDisableMinMaxWidgetRefresh =
true;
346 mDisableMinMaxWidgetRefresh =
false;
352 if ( mRedBandComboBox->findText( tr(
"Red" ) ) > -1 && mRedBandComboBox->findText( tr(
"Green" ) ) > -1 &&
353 mRedBandComboBox->findText( tr(
"Blue" ) ) > -1 )
355 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findText( tr(
"Red" ) ) );
356 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findText( tr(
"Green" ) ) );
357 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findText( tr(
"Blue" ) ) );
361 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 1 ? 1 : 0 );
362 mGreenBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 2 ? 2 : 0 );
363 mBlueBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 3 ? 3 : 0 );
373 return mRedMinLineEdit->text();
375 return mGreenMinLineEdit->text();
377 return mBlueMinLineEdit->text();
389 return mRedMaxLineEdit->text();
391 return mGreenMaxLineEdit->text();
393 return mBlueMaxLineEdit->text();
402 mDisableMinMaxWidgetRefresh =
true;
406 mRedMinLineEdit->setText( value );
409 mGreenMinLineEdit->setText( value );
412 mBlueMinLineEdit->setText( value );
417 mDisableMinMaxWidgetRefresh =
false;
422 mDisableMinMaxWidgetRefresh =
true;
426 mRedMaxLineEdit->setText( value );
429 mGreenMaxLineEdit->setText( value );
432 mBlueMaxLineEdit->setText( value );
437 mDisableMinMaxWidgetRefresh =
false;
445 return mRedBandComboBox->currentBand();
447 return mGreenBandComboBox->currentBand();
449 return mBlueBandComboBox->currentBand();
DataType
Raster data types.
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used.
@ StretchToMinimumMaximum
Linear histogram.
@ StretchAndClipToMinimumMaximum
@ NoEnhancement
Default color scaling algorithm, no scaling is applied.
void setMinimumValue(double value, bool generateTable=true)
Sets the minimum value for the contrast enhancement range.
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm algorithm, bool generateTable=true)
Sets the contrast enhancement algorithm.
double minimumValue() const
Returns the minimum value for the contrast enhancement range.
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
void setMaximumValue(double value, bool generateTable=true)
Sets the maximum value for the contrast enhancement range.
double maximumValue() const
Returns the maximum value for the contrast enhancement range.
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
Map canvas is a class for displaying all GIS data types on a canvas.
Renderer for multiband images with the color components.
const QgsContrastEnhancement * redContrastEnhancement() const
Returns the contrast enhancement to use for the red channel.
const QgsContrastEnhancement * blueContrastEnhancement() const
Returns the contrast enhancement to use for the blue channel.
void setGreenContrastEnhancement(QgsContrastEnhancement *ce)
Sets the contrast enhancement to use for the green channel.
void setBlueContrastEnhancement(QgsContrastEnhancement *ce)
Sets the contrast enhancement to use for the blue channel.
void setRedContrastEnhancement(QgsContrastEnhancement *ce)
Sets the contrast enhancement to use for the red channel.
const QgsContrastEnhancement * greenContrastEnhancement() const
Returns the contrast enhancement to use for the green channel.
void bandChanged(int band)
Emitted when the currently selected band changes.
Base class for raster data providers.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
Represents a raster layer.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
Raster renderer pipe that applies colors to a raster.
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
A rectangle specified with double values.