19#include "moc_qgsmultibandcolorrendererwidget.cpp"
28 , mDisableMinMaxWidgetRefresh( false )
31 connect( mRedMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mRedMinLineEdit_textChanged );
32 connect( mRedMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mRedMaxLineEdit_textChanged );
33 connect( mGreenMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mGreenMinLineEdit_textChanged );
34 connect( mGreenMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mGreenMaxLineEdit_textChanged );
35 connect( mBlueMinLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mBlueMinLineEdit_textChanged );
36 connect( mBlueMaxLineEdit, &QLineEdit::textChanged,
this, &QgsMultiBandColorRendererWidget::mBlueMaxLineEdit_textChanged );
50 QHBoxLayout *layout =
new QHBoxLayout();
51 layout->setContentsMargins( 0, 0, 0, 0 );
52 mMinMaxContainerWidget->setLayout( layout );
53 layout->addWidget( mMinMaxWidget );
61 this, &QgsMultiBandColorRendererWidget::onBandChanged );
63 this, &QgsMultiBandColorRendererWidget::onBandChanged );
65 this, &QgsMultiBandColorRendererWidget::onBandChanged );
67 mRedBandComboBox->setShowNotSetOption(
true );
68 mGreenBandComboBox->setShowNotSetOption(
true );
69 mBlueBandComboBox->setShowNotSetOption(
true );
99 const int redBand = mRedBandComboBox->currentBand();
100 const int greenBand = mGreenBandComboBox->currentBand();
101 const int blueBand = mBlueBandComboBox->currentBand();
104 setCustomMinMaxValues( r, provider, redBand, greenBand, blueBand );
122void QgsMultiBandColorRendererWidget::createValidators()
134 int redBand,
int greenBand,
int blueBand )
136 if ( !r || !provider )
145 bool redMinOk, redMaxOk;
148 if ( redMinOk && redMaxOk && redBand != -1 )
156 bool greenMinOk, greenMaxOk;
159 if ( greenMinOk && greenMaxOk && greenBand != -1 )
162 provider->
dataType( greenBand ) ) );
167 bool blueMinOk, blueMaxOk;
170 if ( blueMinOk && blueMaxOk && blueBand != -1 )
178 if ( redEnhancement )
181 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
183 if ( greenEnhancement )
186 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
188 if ( blueEnhancement )
191 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) );
198void QgsMultiBandColorRendererWidget::onBandChanged(
int index )
203 myBands.append( mRedBandComboBox->currentBand() );
204 myBands.append( mGreenBandComboBox->currentBand() );
205 myBands.append( mBlueBandComboBox->currentBand() );
210void QgsMultiBandColorRendererWidget::mRedMinLineEdit_textChanged(
const QString & )
215void QgsMultiBandColorRendererWidget::mRedMaxLineEdit_textChanged(
const QString & )
220void QgsMultiBandColorRendererWidget::mGreenMinLineEdit_textChanged(
const QString & )
225void QgsMultiBandColorRendererWidget::mGreenMaxLineEdit_textChanged(
const QString & )
230void QgsMultiBandColorRendererWidget::mBlueMinLineEdit_textChanged(
const QString & )
235void QgsMultiBandColorRendererWidget::mBlueMaxLineEdit_textChanged(
const QString & )
240void QgsMultiBandColorRendererWidget::minMaxModified()
242 if ( !mDisableMinMaxWidgetRefresh )
246 mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
256 QgsDebugMsgLevel( QStringLiteral(
"theBandNo = %1 min = %2 max = %3" ).arg( bandNo ).arg(
min ).arg(
max ), 2 );
258 QLineEdit *myMinLineEdit, *myMaxLineEdit;
260 if ( mRedBandComboBox->currentBand() == bandNo )
262 myMinLineEdit = mRedMinLineEdit;
263 myMaxLineEdit = mRedMaxLineEdit;
265 else if ( mGreenBandComboBox->currentBand() == bandNo )
267 myMinLineEdit = mGreenMinLineEdit;
268 myMaxLineEdit = mGreenMaxLineEdit;
270 else if ( mBlueBandComboBox->currentBand() == bandNo )
272 myMinLineEdit = mBlueMinLineEdit;
273 myMaxLineEdit = mBlueMaxLineEdit;
281 mDisableMinMaxWidgetRefresh =
true;
282 if ( std::isnan(
min ) )
284 myMinLineEdit->clear();
288 myMinLineEdit->setText( QLocale().toString(
min ) );
291 if ( std::isnan(
max ) )
293 myMaxLineEdit->clear();
297 myMaxLineEdit->setText( QLocale().toString(
max ) );
299 mDisableMinMaxWidgetRefresh =
false;
302void QgsMultiBandColorRendererWidget::setMinMaxValue(
const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit )
304 if ( !minEdit || !maxEdit )
316 minEdit->setText( QLocale().toString( ce->
minimumValue() ) );
317 maxEdit->setText( QLocale().toString( ce->
maximumValue() ) );
321 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
330 mRedBandComboBox->setBand( mbcr->
redBand() );
331 mGreenBandComboBox->setBand( mbcr->
greenBand() );
332 mBlueBandComboBox->setBand( mbcr->
blueBand() );
334 mDisableMinMaxWidgetRefresh =
true;
338 mDisableMinMaxWidgetRefresh =
false;
344 if ( mRedBandComboBox->findText( tr(
"Red" ) ) > -1 && mRedBandComboBox->findText( tr(
"Green" ) ) > -1 &&
345 mRedBandComboBox->findText( tr(
"Blue" ) ) > -1 )
347 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findText( tr(
"Red" ) ) );
348 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findText( tr(
"Green" ) ) );
349 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findText( tr(
"Blue" ) ) );
353 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 1 ? 1 : 0 );
354 mGreenBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 2 ? 2 : 0 );
355 mBlueBandComboBox->setCurrentIndex( mRedBandComboBox->count() > 3 ? 3 : 0 );
365 return mRedMinLineEdit->text();
367 return mGreenMinLineEdit->text();
369 return mBlueMinLineEdit->text();
381 return mRedMaxLineEdit->text();
383 return mGreenMaxLineEdit->text();
385 return mBlueMaxLineEdit->text();
394 mDisableMinMaxWidgetRefresh =
true;
398 mRedMinLineEdit->setText( value );
401 mGreenMinLineEdit->setText( value );
404 mBlueMinLineEdit->setText( value );
409 mDisableMinMaxWidgetRefresh =
false;
414 mDisableMinMaxWidgetRefresh =
true;
418 mRedMaxLineEdit->setText( value );
421 mGreenMaxLineEdit->setText( value );
424 mBlueMaxLineEdit->setText( value );
429 mDisableMinMaxWidgetRefresh =
false;
437 return mRedBandComboBox->currentBand();
439 return mGreenBandComboBox->currentBand();
441 return mBlueBandComboBox->currentBand();
455 mDisableMinMaxWidgetRefresh =
true;
456 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
static_cast<int>(
algorithm ) ) );
457 mDisableMinMaxWidgetRefresh =
false;
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 * greenContrastEnhancement() const
Returns the contrast enhancement to use for the green 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.
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.
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)