24 , mMinMaxWidget( NULL )
39 layout()->addWidget( mMinMaxWidget );
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()
102 mRedMinLineEdit->setValidator(
new QDoubleValidator( mRedMinLineEdit ) );
103 mRedMaxLineEdit->setValidator(
new QDoubleValidator( mRedMinLineEdit ) );
104 mGreenMinLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
105 mGreenMaxLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
106 mBlueMinLineEdit->setValidator(
new QDoubleValidator( mBlueMinLineEdit ) );
107 mBlueMaxLineEdit->setValidator(
new QDoubleValidator( mBlueMinLineEdit ) );
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();
230 myMinLineEdit->setText( QString::number( theMin ) );
233 if ( qIsNaN( theMax ) )
235 myMaxLineEdit->clear();
239 myMaxLineEdit->setText( QString::number( theMax ) );
243 void QgsMultiBandColorRendererWidget::setMinMaxValue(
const QgsContrastEnhancement* ce, QLineEdit* minEdit, QLineEdit* maxEdit )
245 if ( !minEdit || !maxEdit )
257 minEdit->setText( QString::number( ce->
minimumValue() ) );
258 maxEdit->setText( QString::number( ce->
maximumValue() ) );
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();