26 , mDisableMinMaxWidgetRefresh( false )
29 connect( mRedMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mRedMinLineEdit_textChanged );
30 connect( mRedMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mRedMaxLineEdit_textChanged );
31 connect( mGreenMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mGreenMinLineEdit_textChanged );
32 connect( mGreenMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mGreenMaxLineEdit_textChanged );
33 connect( mBlueMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mBlueMinLineEdit_textChanged );
34 connect( mBlueMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mBlueMaxLineEdit_textChanged );
48 QHBoxLayout *layout =
new QHBoxLayout();
49 layout->setContentsMargins( 0, 0, 0, 0 );
50 mMinMaxContainerWidget->setLayout( layout );
51 layout->addWidget( mMinMaxWidget );
59 this, &QgsMultiBandColorRendererWidget::onBandChanged );
61 this, &QgsMultiBandColorRendererWidget::onBandChanged );
63 this, &QgsMultiBandColorRendererWidget::onBandChanged );
65 mRedBandComboBox->setShowNotSetOption(
true );
66 mGreenBandComboBox->setShowNotSetOption(
true );
67 mBlueBandComboBox->setShowNotSetOption(
true );
97 int redBand = mRedBandComboBox->currentBand();
98 int greenBand = mGreenBandComboBox->currentBand();
99 int blueBand = mBlueBandComboBox->currentBand();
102 setCustomMinMaxValues( r, provider, redBand, greenBand, blueBand );
120 void QgsMultiBandColorRendererWidget::createValidators()
122 mRedMinLineEdit->setValidator(
new QDoubleValidator( mRedMinLineEdit ) );
123 mRedMaxLineEdit->setValidator(
new QDoubleValidator( mRedMinLineEdit ) );
124 mGreenMinLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
125 mGreenMaxLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
126 mBlueMinLineEdit->setValidator(
new QDoubleValidator( mBlueMinLineEdit ) );
127 mBlueMaxLineEdit->setValidator(
new QDoubleValidator( mBlueMinLineEdit ) );
132 int redBand,
int greenBand,
int blueBand )
134 if ( !r || !provider )
139 if ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ==
152 bool redMinOk, redMaxOk;
153 double redMin = mRedMinLineEdit->text().toDouble( &redMinOk );
154 double redMax = mRedMaxLineEdit->text().toDouble( &redMaxOk );
155 if ( redMinOk && redMaxOk && redBand != -1 )
163 bool greenMinOk, greenMaxOk;
164 double greenMin = mGreenMinLineEdit->text().toDouble( &greenMinOk );
165 double greenMax = mGreenMaxLineEdit->text().toDouble( &greenMaxOk );
166 if ( greenMinOk && greenMaxOk && greenBand != -1 )
169 provider->
dataType( greenBand ) ) );
174 bool blueMinOk, blueMaxOk;
175 double blueMin = mBlueMinLineEdit->text().toDouble( &blueMinOk );
176 double blueMax = mBlueMaxLineEdit->text().toDouble( &blueMaxOk );
177 if ( blueMinOk && blueMaxOk && blueBand != -1 )
185 if ( redEnhancement )
188 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
190 if ( greenEnhancement )
193 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
195 if ( blueEnhancement )
198 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
205 void QgsMultiBandColorRendererWidget::onBandChanged(
int index )
210 myBands.append( mRedBandComboBox->currentBand() );
211 myBands.append( mGreenBandComboBox->currentBand() );
212 myBands.append( mBlueBandComboBox->currentBand() );
217 void QgsMultiBandColorRendererWidget::mRedMinLineEdit_textChanged(
const QString & )
222 void QgsMultiBandColorRendererWidget::mRedMaxLineEdit_textChanged(
const QString & )
227 void QgsMultiBandColorRendererWidget::mGreenMinLineEdit_textChanged(
const QString & )
232 void QgsMultiBandColorRendererWidget::mGreenMaxLineEdit_textChanged(
const QString & )
237 void QgsMultiBandColorRendererWidget::mBlueMinLineEdit_textChanged(
const QString & )
242 void QgsMultiBandColorRendererWidget::mBlueMaxLineEdit_textChanged(
const QString & )
247 void QgsMultiBandColorRendererWidget::minMaxModified()
249 if ( !mDisableMinMaxWidgetRefresh )
253 mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
263 QgsDebugMsg( QStringLiteral(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg( min ).arg( max ) );
265 QLineEdit *myMinLineEdit, *myMaxLineEdit;
267 if ( mRedBandComboBox->currentBand() == bandNo )
269 myMinLineEdit = mRedMinLineEdit;
270 myMaxLineEdit = mRedMaxLineEdit;
272 else if ( mGreenBandComboBox->currentBand() == bandNo )
274 myMinLineEdit = mGreenMinLineEdit;
275 myMaxLineEdit = mGreenMaxLineEdit;
277 else if ( mBlueBandComboBox->currentBand() == bandNo )
279 myMinLineEdit = mBlueMinLineEdit;
280 myMaxLineEdit = mBlueMaxLineEdit;
288 mDisableMinMaxWidgetRefresh =
true;
289 if ( std::isnan( min ) )
291 myMinLineEdit->clear();
295 myMinLineEdit->setText( QString::number( min ) );
298 if ( std::isnan( max ) )
300 myMaxLineEdit->clear();
304 myMaxLineEdit->setText( QString::number( max ) );
306 mDisableMinMaxWidgetRefresh =
false;
309 void QgsMultiBandColorRendererWidget::setMinMaxValue(
const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit )
311 if ( !minEdit || !maxEdit )
323 minEdit->setText( QString::number( ce->
minimumValue() ) );
324 maxEdit->setText( QString::number( ce->
maximumValue() ) );
328 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
337 mRedBandComboBox->setBand( mbcr->
redBand() );
338 mGreenBandComboBox->setBand( mbcr->
greenBand() );
339 mBlueBandComboBox->setBand( mbcr->
blueBand() );
341 mDisableMinMaxWidgetRefresh =
true;
345 mDisableMinMaxWidgetRefresh =
false;
351 if ( mRedBandComboBox->findText( tr(
"Red" ) ) > -1 && mRedBandComboBox->findText( tr(
"Green" ) ) > -1 &&
352 mRedBandComboBox->findText( tr(
"Blue" ) ) > -1 )
354 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findText( tr(
"Red" ) ) );
355 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findText( tr(
"Green" ) ) );
356 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findText( tr(
"Blue" ) ) );
360 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 1 ? 1 : 0 );
361 mGreenBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 2 ? 2 : 0 );
362 mBlueBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 3 ? 3 : 0 );
372 return mRedMinLineEdit->text();
374 return mGreenMinLineEdit->text();
376 return mBlueMinLineEdit->text();
388 return mRedMaxLineEdit->text();
390 return mGreenMaxLineEdit->text();
392 return mBlueMaxLineEdit->text();
401 mDisableMinMaxWidgetRefresh =
true;
405 mRedMinLineEdit->setText( value );
408 mGreenMinLineEdit->setText( value );
411 mBlueMinLineEdit->setText( value );
416 mDisableMinMaxWidgetRefresh =
false;
421 mDisableMinMaxWidgetRefresh =
true;
425 mRedMaxLineEdit->setText( value );
428 mGreenMaxLineEdit->setText( value );
431 mBlueMaxLineEdit->setText( value );
436 mDisableMinMaxWidgetRefresh =
false;
444 return mRedBandComboBox->currentBand();
446 return mGreenBandComboBox->currentBand();
448 return mBlueBandComboBox->currentBand();
A rectangle specified with double values.
const QgsContrastEnhancement * greenContrastEnhancement() const
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
void setMinimumValue(double value, bool generateTable=true)
Sets the minimum value for the contrast enhancement range.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
DataType
Raster data types.
const QgsRasterMinMaxOrigin & minMaxOrigin() const
Returns const reference to origin of min/max values.
const QgsContrastEnhancement * redContrastEnhancement() const
Map canvas is a class for displaying all GIS data types on a canvas.
void setGreenContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider.
void setRedContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
QgsRasterRenderer * renderer() const
void setMaximumValue(double value, bool generateTable=true)
Sets the maximum value for the contrast enhancement range.
void bandChanged(int band)
This signal is emitted when the currently selected band changes.
double minimumValue() const
Returns the minimum value for the contrast enhancement range.
const QgsContrastEnhancement * blueContrastEnhancement() const
void setMinMaxOrigin(const QgsRasterMinMaxOrigin &origin)
Sets origin of min/max values.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
double maximumValue() const
Returns the maximum value for the contrast enhancement range.
void setBlueContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
Renderer for multiband images with the color components.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
Raster renderer pipe that applies colors to a raster.
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm algorithm, bool generateTable=true)
Sets the contrast enhancement algorithm.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
Base class for raster data providers.