Skip to content
Permalink
Browse files

[raster] when loading min/max, activate contrast enhancement if set t…

…o none
  • Loading branch information
nirvn committed Dec 6, 2016
1 parent 0a2e104 commit 5db654be6e802d66522a84f6e133ff906e6c5323
@@ -59,10 +59,10 @@ QgsMultiBandColorRendererWidget::QgsMultiBandColorRendererWidget( QgsRasterLayer
mBlueBandComboBox->addItem( tr( "Not set" ), -1 );

//contrast enhancement algorithms
mContrastEnhancementAlgorithmComboBox->addItem( tr( "No enhancement" ), 0 );
mContrastEnhancementAlgorithmComboBox->addItem( tr( "Stretch to MinMax" ), 1 );
mContrastEnhancementAlgorithmComboBox->addItem( tr( "Stretch and clip to MinMax" ), 2 );
mContrastEnhancementAlgorithmComboBox->addItem( tr( "Clip to MinMax" ), 3 );
mContrastEnhancementAlgorithmComboBox->addItem( tr( "No enhancement" ), QgsContrastEnhancement::NoEnhancement );
mContrastEnhancementAlgorithmComboBox->addItem( tr( "Stretch to MinMax" ), QgsContrastEnhancement::StretchToMinimumMaximum );
mContrastEnhancementAlgorithmComboBox->addItem( tr( "Stretch and clip to MinMax" ), QgsContrastEnhancement::StretchAndClipToMinimumMaximum );
mContrastEnhancementAlgorithmComboBox->addItem( tr( "Clip to MinMax" ), QgsContrastEnhancement::ClipToMinimumMaximum );

int nBands = provider->bandCount();
for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1
@@ -259,6 +259,13 @@ void QgsMultiBandColorRendererWidget::loadMinMax( int theBandNo, double theMin,
{
myMaxLineEdit->setText( QString::number( theMax ) );
}

//automaticlly activate contrast enhancement algorithm if set to none
if ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() == QgsContrastEnhancement::NoEnhancement )
{
mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
mContrastEnhancementAlgorithmComboBox->findData( QgsContrastEnhancement::StretchToMinimumMaximum ) );
}
}

void QgsMultiBandColorRendererWidget::setMinMaxValue( const QgsContrastEnhancement* ce, QLineEdit* minEdit, QLineEdit* maxEdit )
@@ -61,10 +61,10 @@ QgsSingleBandGrayRendererWidget::QgsSingleBandGrayRendererWidget( QgsRasterLayer
}

//contrast enhancement algorithms
mContrastEnhancementComboBox->addItem( tr( "No enhancement" ), 0 );
mContrastEnhancementComboBox->addItem( tr( "Stretch to MinMax" ), 1 );
mContrastEnhancementComboBox->addItem( tr( "Stretch and clip to MinMax" ), 2 );
mContrastEnhancementComboBox->addItem( tr( "Clip to MinMax" ), 3 );
mContrastEnhancementComboBox->addItem( tr( "No enhancement" ), QgsContrastEnhancement::NoEnhancement );
mContrastEnhancementComboBox->addItem( tr( "Stretch to MinMax" ), QgsContrastEnhancement::StretchToMinimumMaximum );
mContrastEnhancementComboBox->addItem( tr( "Stretch and clip to MinMax" ), QgsContrastEnhancement::StretchAndClipToMinimumMaximum );
mContrastEnhancementComboBox->addItem( tr( "Clip to MinMax" ), QgsContrastEnhancement::ClipToMinimumMaximum );

setFromRenderer( layer->renderer() );

@@ -96,8 +96,7 @@ QgsRasterRenderer* QgsSingleBandGrayRendererWidget::renderer()
provider->dataType( band ) ) );
e->setMinimumValue( mMinLineEdit->text().toDouble() );
e->setMaximumValue( mMaxLineEdit->text().toDouble() );
e->setContrastEnhancementAlgorithm(( QgsContrastEnhancement::ContrastEnhancementAlgorithm )( mContrastEnhancementComboBox->itemData(
mContrastEnhancementComboBox->currentIndex() ).toInt() ) );
e->setContrastEnhancementAlgorithm(( QgsContrastEnhancement::ContrastEnhancementAlgorithm )( mContrastEnhancementComboBox->currentData().toInt() ) );


QgsSingleBandGrayRenderer* renderer = new QgsSingleBandGrayRenderer( provider, band );
@@ -137,6 +136,12 @@ void QgsSingleBandGrayRendererWidget::loadMinMax( int theBandNo, double theMin,
{
mMaxLineEdit->setText( QString::number( theMax ) );
}

//automaticlly activate contrast enhancement algorithm if set to none
if ( mContrastEnhancementComboBox->currentData().toInt() == QgsContrastEnhancement::NoEnhancement )
{
mContrastEnhancementComboBox->setCurrentIndex( mContrastEnhancementComboBox->findData( QgsContrastEnhancement::StretchToMinimumMaximum ) );
}
}

void QgsSingleBandGrayRendererWidget::on_mGrayBandComboBox_currentIndexChanged( int index )

0 comments on commit 5db654b

Please sign in to comment.
You can’t perform that action at this time.