26#include "moc_qgsmultibandcolorrendererwidget.cpp"
32 connect( mRedMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mRedMinLineEdit_textChanged );
33 connect( mRedMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mRedMaxLineEdit_textChanged );
34 connect( mGreenMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mGreenMinLineEdit_textChanged );
35 connect( mGreenMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mGreenMaxLineEdit_textChanged );
36 connect( mBlueMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mBlueMinLineEdit_textChanged );
37 connect( mBlueMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mBlueMaxLineEdit_textChanged );
49 mMinMaxWidget->setExtent( extent );
50 mMinMaxWidget->setMapCanvas(
mCanvas );
51 QHBoxLayout *layout =
new QHBoxLayout();
52 layout->setContentsMargins( 0, 0, 0, 0 );
53 mMinMaxContainerWidget->setLayout( layout );
54 layout->addWidget( mMinMaxWidget );
63 mRedBandComboBox->setShowNotSetOption(
true );
64 mGreenBandComboBox->setShowNotSetOption(
true );
65 mBlueBandComboBox->setShowNotSetOption(
true );
95 const int redBand = mRedBandComboBox->currentBand();
96 const int greenBand = mGreenBandComboBox->currentBand();
97 const int blueBand = mBlueBandComboBox->currentBand();
100 setCustomMinMaxValues( r, provider, redBand, greenBand, blueBand );
109 mMinMaxWidget->doComputations();
115 mMinMaxWidget->setMapCanvas( canvas );
118void QgsMultiBandColorRendererWidget::createValidators()
130 if ( !r || !provider )
135 QgsContrastEnhancement *redEnhancement =
nullptr;
136 QgsContrastEnhancement *greenEnhancement =
nullptr;
137 QgsContrastEnhancement *blueEnhancement =
nullptr;
139 bool redMinOk, redMaxOk;
142 if ( redMinOk && redMaxOk && redBand != -1 )
151 bool greenMinOk, greenMaxOk;
154 if ( greenMinOk && greenMaxOk && greenBand != -1 )
156 greenEnhancement =
new QgsContrastEnhancement( (
Qgis::DataType )(
163 bool blueMinOk, blueMaxOk;
166 if ( blueMinOk && blueMaxOk && blueBand != -1 )
175 if ( redEnhancement )
179 if ( greenEnhancement )
183 if ( blueEnhancement )
192void QgsMultiBandColorRendererWidget::onBandChanged(
int index )
197 myBands.append( mRedBandComboBox->currentBand() );
198 myBands.append( mGreenBandComboBox->currentBand() );
199 myBands.append( mBlueBandComboBox->currentBand() );
200 mMinMaxWidget->setBands( myBands );
204void QgsMultiBandColorRendererWidget::mRedMinLineEdit_textChanged(
const QString & )
209void QgsMultiBandColorRendererWidget::mRedMaxLineEdit_textChanged(
const QString & )
214void QgsMultiBandColorRendererWidget::mGreenMinLineEdit_textChanged(
const QString & )
219void QgsMultiBandColorRendererWidget::mGreenMaxLineEdit_textChanged(
const QString & )
224void QgsMultiBandColorRendererWidget::mBlueMinLineEdit_textChanged(
const QString & )
229void QgsMultiBandColorRendererWidget::mBlueMaxLineEdit_textChanged(
const QString & )
234void QgsMultiBandColorRendererWidget::minMaxModified()
236 if ( !mDisableMinMaxWidgetRefresh )
240 mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
244 mMinMaxWidget->userHasSetManualMinMaxValues();
251 QgsDebugMsgLevel( QStringLiteral(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg(
min ).arg(
max ), 2 );
253 QLineEdit *myMinLineEdit, *myMaxLineEdit;
255 if ( mRedBandComboBox->currentBand() == bandNo )
257 myMinLineEdit = mRedMinLineEdit;
258 myMaxLineEdit = mRedMaxLineEdit;
260 else if ( mGreenBandComboBox->currentBand() == bandNo )
262 myMinLineEdit = mGreenMinLineEdit;
263 myMaxLineEdit = mGreenMaxLineEdit;
265 else if ( mBlueBandComboBox->currentBand() == bandNo )
267 myMinLineEdit = mBlueMinLineEdit;
268 myMaxLineEdit = mBlueMaxLineEdit;
276 mDisableMinMaxWidgetRefresh =
true;
277 if ( std::isnan(
min ) )
279 myMinLineEdit->clear();
283 myMinLineEdit->setText( QLocale().toString(
min ) );
286 if ( std::isnan(
max ) )
288 myMaxLineEdit->clear();
292 myMaxLineEdit->setText( QLocale().toString(
max ) );
294 mDisableMinMaxWidgetRefresh =
false;
297void QgsMultiBandColorRendererWidget::setMinMaxValue(
const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit )
299 if ( !minEdit || !maxEdit )
311 minEdit->setText( QLocale().toString( ce->
minimumValue() ) );
312 maxEdit->setText( QLocale().toString( ce->
maximumValue() ) );
316 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
326 mRedBandComboBox->setBand( mbcr->
redBand() );
327 mGreenBandComboBox->setBand( mbcr->
greenBand() );
328 mBlueBandComboBox->setBand( mbcr->
blueBand() );
330 mDisableMinMaxWidgetRefresh =
true;
334 mDisableMinMaxWidgetRefresh =
false;
336 mMinMaxWidget->setFromMinMaxOrigin( mbcr->
minMaxOrigin() );
340 if ( mRedBandComboBox->findText( tr(
"Red" ) ) > -1 && mRedBandComboBox->findText( tr(
"Green" ) ) > -1 && mRedBandComboBox->findText( tr(
"Blue" ) ) > -1 )
342 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findText( tr(
"Red" ) ) );
343 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findText( tr(
"Green" ) ) );
344 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findText( tr(
"Blue" ) ) );
348 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 1 ? 1 : 0 );
349 mGreenBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 2 ? 2 : 0 );
350 mBlueBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 3 ? 3 : 0 );
360 return mRedMinLineEdit->text();
362 return mGreenMinLineEdit->text();
364 return mBlueMinLineEdit->text();
376 return mRedMaxLineEdit->text();
378 return mGreenMaxLineEdit->text();
380 return mBlueMaxLineEdit->text();
389 mDisableMinMaxWidgetRefresh =
true;
393 mRedMinLineEdit->setText( value );
396 mGreenMinLineEdit->setText( value );
399 mBlueMinLineEdit->setText( value );
404 mDisableMinMaxWidgetRefresh =
false;
409 mDisableMinMaxWidgetRefresh =
true;
413 mRedMaxLineEdit->setText( value );
416 mGreenMaxLineEdit->setText( value );
419 mBlueMaxLineEdit->setText( value );
424 mDisableMinMaxWidgetRefresh =
false;
432 return mRedBandComboBox->currentBand();
434 return mGreenBandComboBox->currentBand();
436 return mBlueBandComboBox->currentBand();
450 mDisableMinMaxWidgetRefresh =
true;
451 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
static_cast<int>(
algorithm ) ) );
452 mDisableMinMaxWidgetRefresh =
false;
DataType
Raster data types.
Handles contrast enhancement and clipping.
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.
A custom validator which allows entry of doubles in a locale-tolerant way.
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 * greenContrastEnhancement() const
Returns the contrast enhancement to use for the green channel.
int blueBand() const
Returns the band number for the blue 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 * redContrastEnhancement() const
Returns the contrast enhancement to use for the red channel.
int redBand() const
Returns the band number for the red channel.
int greenBand() const
Returns the band number 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.
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.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)