24 , mMinMaxWidget( NULL )
40 connect( mMinMaxWidget, SIGNAL( load(
int,
double,
double,
int ) ),
41 this, SLOT(
loadMinMax(
int,
double,
double,
int ) ) );
43 connect( mRedBandComboBox, SIGNAL( currentIndexChanged(
int ) ),
44 this, SLOT( onBandChanged(
int ) ) );
45 connect( mGreenBandComboBox, SIGNAL( currentIndexChanged(
int ) ),
46 this, SLOT( onBandChanged(
int ) ) );
47 connect( mBlueBandComboBox, SIGNAL( currentIndexChanged(
int ) ),
48 this, SLOT( onBandChanged(
int ) ) );
51 mRedBandComboBox->addItem(
tr(
"Not set" ), -1 );
52 mGreenBandComboBox->addItem(
tr(
"Not set" ), -1 );
53 mBlueBandComboBox->addItem(
tr(
"Not set" ), -1 );
56 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"No enhancement" ), 0 );
57 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"Stretch to MinMax" ), 1 );
58 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"Stretch and clip to MinMax" ), 2 );
59 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"Clip to MinMax" ), 3 );
62 for (
int i = 1; i <= nBands; ++i )
65 mRedBandComboBox->addItem( bandName, i );
66 mGreenBandComboBox->addItem( bandName, i );
67 mBlueBandComboBox->addItem( bandName, i );
91 int redBand = mRedBandComboBox->itemData( mRedBandComboBox->currentIndex() ).toInt();
92 int greenBand = mGreenBandComboBox->itemData( mGreenBandComboBox->currentIndex() ).toInt();
93 int blueBand = mBlueBandComboBox->itemData( mBlueBandComboBox->currentIndex() ).toInt();
96 setCustomMinMaxValues( r, provider, redBand, greenBand, blueBand );
100 void QgsMultiBandColorRendererWidget::createValidators()
104 mGreenMinLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
105 mGreenMaxLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
112 int redBand,
int greenBand,
int blueBand )
114 if ( !r || !provider )
119 if ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ==
132 bool redMinOk, redMaxOk;
133 double redMin = mRedMinLineEdit->text().toDouble( &redMinOk );
134 double redMax = mRedMaxLineEdit->text().toDouble( &redMaxOk );
135 if ( redMinOk && redMaxOk && redBand != -1 )
143 bool greenMinOk, greenMaxOk;
144 double greenMin = mGreenMinLineEdit->text().toDouble( &greenMinOk );
145 double greenMax = mGreenMaxLineEdit->text().toDouble( &greenMaxOk );
146 if ( greenMinOk && greenMaxOk && greenBand != -1 )
149 provider->
dataType( greenBand ) ) );
154 bool blueMinOk, blueMaxOk;
155 double blueMin = mBlueMinLineEdit->text().toDouble( &blueMinOk );
156 double blueMax = mBlueMaxLineEdit->text().toDouble( &blueMaxOk );
157 if ( blueMinOk && blueMaxOk && blueBand != -1 )
165 if ( redEnhancement )
168 ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ) );
170 if ( greenEnhancement )
173 ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ) );
175 if ( blueEnhancement )
178 ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ) );
185 void QgsMultiBandColorRendererWidget::onBandChanged(
int index )
190 myBands.
append( mRedBandComboBox->itemData( mRedBandComboBox->currentIndex() ).toInt() );
191 myBands.
append( mGreenBandComboBox->itemData( mGreenBandComboBox->currentIndex() ).toInt() );
192 myBands.
append( mBlueBandComboBox->itemData( mBlueBandComboBox->currentIndex() ).toInt() );
198 Q_UNUSED( theOrigin );
199 QgsDebugMsg(
QString(
"theBandNo = %1 theMin = %2 theMax = %3" ).arg( theBandNo ).arg( theMin ).arg( theMax ) );
201 QLineEdit *myMinLineEdit, *myMaxLineEdit;
203 if ( mRedBandComboBox->itemData( mRedBandComboBox->currentIndex() ).toInt() == theBandNo )
205 myMinLineEdit = mRedMinLineEdit;
206 myMaxLineEdit = mRedMaxLineEdit;
208 else if ( mGreenBandComboBox->itemData( mGreenBandComboBox->currentIndex() ).toInt() == theBandNo )
210 myMinLineEdit = mGreenMinLineEdit;
211 myMaxLineEdit = mGreenMaxLineEdit;
213 else if ( mBlueBandComboBox->itemData( mBlueBandComboBox->currentIndex() ).toInt() == theBandNo )
215 myMinLineEdit = mBlueMinLineEdit;
216 myMaxLineEdit = mBlueMaxLineEdit;
224 if ( qIsNaN( theMin ) )
226 myMinLineEdit->
clear();
233 if ( qIsNaN( theMax ) )
235 myMaxLineEdit->
clear();
245 if ( !minEdit || !maxEdit )
262 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
271 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findData( mbcr->
redBand() ) );
272 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findData( mbcr->
greenBand() ) );
273 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findData( mbcr->
blueBand() ) );
281 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findText(
tr(
"Red" ) ) );
282 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findText(
tr(
"Green" ) ) );
283 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findText(
tr(
"Blue" ) ) );
292 return mRedMinLineEdit->text();
295 return mGreenMinLineEdit->text();
298 return mBlueMinLineEdit->text();
311 return mRedMaxLineEdit->text();
314 return mGreenMaxLineEdit->text();
317 return mBlueMaxLineEdit->text();
330 mRedMinLineEdit->setText( value );
333 mGreenMinLineEdit->setText( value );
336 mBlueMinLineEdit->setText( value );
348 mRedMaxLineEdit->setText( value );
351 mGreenMaxLineEdit->setText( value );
354 mBlueMaxLineEdit->setText( value );
366 return mRedBandComboBox->currentIndex();
369 return mGreenBandComboBox->currentIndex();
372 return mBlueBandComboBox->currentIndex();
virtual int bandCount() const =0
Get number of bands.
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm, bool generateTable=true)
Set the contrast enhancement algorithm.
A rectangle specified with double values.
const QgsContrastEnhancement * greenContrastEnhancement() const
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
void setText(const QString &)
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
const QgsContrastEnhancement * redContrastEnhancement() const
QString tr(const char *sourceText, const char *disambiguation, int n)
void setGreenContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
QString number(int n, int base)
void append(const T &value)
void setRedContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
QgsRasterRenderer * renderer() const
void setMinimumValue(double, bool generateTable=true)
Return the minimum value for the contrast enhancement range.
double minimumValue() const
Return the minimum value for the contrast enhancement range.
DataType
Raster data types.
const QgsContrastEnhancement * blueContrastEnhancement() const
virtual QGis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
double maximumValue() const
Return 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...
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.