24 , mMinMaxWidget( nullptr )
42 mMinMaxContainerWidget->setLayout( layout );
44 connect( mMinMaxWidget, SIGNAL( load(
int,
double,
double,
int ) ),
45 this, SLOT(
loadMinMax(
int,
double,
double,
int ) ) );
47 connect( mRedBandComboBox, SIGNAL( currentIndexChanged(
int ) ),
48 this, SLOT( onBandChanged(
int ) ) );
49 connect( mGreenBandComboBox, SIGNAL( currentIndexChanged(
int ) ),
50 this, SLOT( onBandChanged(
int ) ) );
51 connect( mBlueBandComboBox, SIGNAL( currentIndexChanged(
int ) ),
52 this, SLOT( onBandChanged(
int ) ) );
55 mRedBandComboBox->addItem(
tr(
"Not set" ), -1 );
56 mGreenBandComboBox->addItem(
tr(
"Not set" ), -1 );
57 mBlueBandComboBox->addItem(
tr(
"Not set" ), -1 );
60 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"No enhancement" ), 0 );
61 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"Stretch to MinMax" ), 1 );
62 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"Stretch and clip to MinMax" ), 2 );
63 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"Clip to MinMax" ), 3 );
66 for (
int i = 1; i <= nBands; ++i )
69 mRedBandComboBox->addItem( bandName, i );
70 mGreenBandComboBox->addItem( bandName, i );
71 mBlueBandComboBox->addItem( bandName, i );
103 int redBand = mRedBandComboBox->itemData( mRedBandComboBox->currentIndex() ).toInt();
104 int greenBand = mGreenBandComboBox->itemData( mGreenBandComboBox->currentIndex() ).toInt();
105 int blueBand = mBlueBandComboBox->itemData( mBlueBandComboBox->currentIndex() ).toInt();
108 setCustomMinMaxValues( r, provider, redBand, greenBand, blueBand );
118 void QgsMultiBandColorRendererWidget::createValidators()
122 mGreenMinLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
123 mGreenMaxLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
130 int redBand,
int greenBand,
int blueBand )
132 if ( !r || !provider )
137 if ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ==
150 bool redMinOk, redMaxOk;
151 double redMin = mRedMinLineEdit->text().toDouble( &redMinOk );
152 double redMax = mRedMaxLineEdit->text().toDouble( &redMaxOk );
153 if ( redMinOk && redMaxOk && redBand != -1 )
161 bool greenMinOk, greenMaxOk;
162 double greenMin = mGreenMinLineEdit->text().toDouble( &greenMinOk );
163 double greenMax = mGreenMaxLineEdit->text().toDouble( &greenMaxOk );
164 if ( greenMinOk && greenMaxOk && greenBand != -1 )
167 provider->
dataType( greenBand ) ) );
172 bool blueMinOk, blueMaxOk;
173 double blueMin = mBlueMinLineEdit->text().toDouble( &blueMinOk );
174 double blueMax = mBlueMaxLineEdit->text().toDouble( &blueMaxOk );
175 if ( blueMinOk && blueMaxOk && blueBand != -1 )
183 if ( redEnhancement )
186 ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ) );
188 if ( greenEnhancement )
191 ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ) );
193 if ( blueEnhancement )
196 ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ) );
203 void QgsMultiBandColorRendererWidget::onBandChanged(
int index )
208 myBands.
append( mRedBandComboBox->itemData( mRedBandComboBox->currentIndex() ).toInt() );
209 myBands.
append( mGreenBandComboBox->itemData( mGreenBandComboBox->currentIndex() ).toInt() );
210 myBands.
append( mBlueBandComboBox->itemData( mBlueBandComboBox->currentIndex() ).toInt() );
217 Q_UNUSED( theOrigin );
218 QgsDebugMsg(
QString(
"theBandNo = %1 theMin = %2 theMax = %3" ).arg( theBandNo ).arg( theMin ).arg( theMax ) );
220 QLineEdit *myMinLineEdit, *myMaxLineEdit;
222 if ( mRedBandComboBox->itemData( mRedBandComboBox->currentIndex() ).toInt() == theBandNo )
224 myMinLineEdit = mRedMinLineEdit;
225 myMaxLineEdit = mRedMaxLineEdit;
227 else if ( mGreenBandComboBox->itemData( mGreenBandComboBox->currentIndex() ).toInt() == theBandNo )
229 myMinLineEdit = mGreenMinLineEdit;
230 myMaxLineEdit = mGreenMaxLineEdit;
232 else if ( mBlueBandComboBox->itemData( mBlueBandComboBox->currentIndex() ).toInt() == theBandNo )
234 myMinLineEdit = mBlueMinLineEdit;
235 myMaxLineEdit = mBlueMaxLineEdit;
243 if ( qIsNaN( theMin ) )
245 myMinLineEdit->
clear();
252 if ( qIsNaN( theMax ) )
254 myMaxLineEdit->
clear();
264 if ( !minEdit || !maxEdit )
281 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
290 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findData( mbcr->
redBand() ) );
291 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findData( mbcr->
greenBand() ) );
292 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findData( mbcr->
blueBand() ) );
300 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findText(
tr(
"Red" ) ) );
301 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findText(
tr(
"Green" ) ) );
302 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findText(
tr(
"Blue" ) ) );
311 return mRedMinLineEdit->text();
313 return mGreenMinLineEdit->text();
315 return mBlueMinLineEdit->text();
327 return mRedMaxLineEdit->text();
329 return mGreenMaxLineEdit->text();
331 return mBlueMaxLineEdit->text();
343 mRedMinLineEdit->setText( value );
346 mGreenMinLineEdit->setText( value );
349 mBlueMinLineEdit->setText( value );
361 mRedMaxLineEdit->setText( value );
364 mGreenMaxLineEdit->setText( value );
367 mBlueMaxLineEdit->setText( value );
379 return mRedBandComboBox->currentIndex();
381 return mGreenBandComboBox->currentIndex();
383 return mBlueBandComboBox->currentIndex();
virtual int bandCount() const =0
Get number of bands.
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm, bool generateTable=true)
Set the contrast enhancement algorithm.
double maximumValue() const
Return the maximum value for the contrast enhancement range.
A rectangle specified with double values.
void setContentsMargins(int left, int top, int right, int bottom)
const QgsContrastEnhancement * blueContrastEnhancement() const
void setText(const QString &)
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
double minimumValue() const
Return the minimum value for the contrast enhancement range.
QgsRasterRenderer * renderer() const
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
void setGreenContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
QString number(int n, int base)
void append(const T &value)
void setRedContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
void setMinimumValue(double, bool generateTable=true)
Return the minimum value for the contrast enhancement range.
virtual QGis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
const QgsContrastEnhancement * redContrastEnhancement() const
const QgsContrastEnhancement * greenContrastEnhancement() const
DataType
Raster data types.
void setBlueContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
Renderer for multiband images with the color components.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
QgsRasterDataProvider * dataProvider()
Returns the data provider.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Raster renderer pipe that applies colors to a raster.
void setMaximumValue(double, bool generateTable=true)
Set the maximum value for the contrast enhancement range.
Base class for raster data providers.