Skip to content

Commit 0065f6c

Browse files
author
alexbruy
committed
save default bands combination and stadard deviation. Also use this values when loading new raster layer (fix #3519)
git-svn-id: http://svn.osgeo.org/qgis/trunk@15256 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2a53db2 commit 0065f6c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/app/qgsrasterlayerproperties.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -695,12 +695,18 @@ void QgsRasterLayerProperties::sync()
695695
cboxContrastEnhancementAlgorithm->setCurrentIndex( cboxContrastEnhancementAlgorithm->findText( tr( "No Stretch" ) ) );
696696
}
697697

698-
//Display the current default contrast enhancement algorithm
698+
// Display the current default band combination
699699
mDefaultRedBand = myQSettings.value( "/Raster/defaultRedBand", 1 ).toInt();
700700
mDefaultGreenBand = myQSettings.value( "/Raster/defaultGreenBand", 2 ).toInt();
701701
mDefaultBlueBand = myQSettings.value( "/Raster/defaultBlueBand", 3 ).toInt();
702702
labelDefaultBandCombination->setText( tr( "Default R:%1 G:%2 B:%3" ).arg( mDefaultRedBand ) .arg( mDefaultGreenBand ) .arg( mDefaultBlueBand ) );
703703

704+
// and used band combination
705+
cboRed->setCurrentIndex( cboRed->findText( mRasterLayer->redBandName() ) );
706+
cboGreen->setCurrentIndex( cboGreen->findText( mRasterLayer->greenBandName() ) );
707+
cboBlue->setCurrentIndex( cboBlue->findText( mRasterLayer->blueBandName() ) );
708+
709+
//Display the current default contrast enhancement algorithm
704710
mDefaultContrastEnhancementAlgorithm = myQSettings.value( "/Raster/defaultContrastEnhancementAlgorithm", "NoEnhancement" ).toString();
705711
if ( mDefaultContrastEnhancementAlgorithm == "NoEnhancement" )
706712
{
@@ -722,6 +728,8 @@ void QgsRasterLayerProperties::sync()
722728
{
723729
labelDefaultContrastEnhancementAlgorithm->setText( tr( "No Stretch" ) );
724730
}
731+
mDefaultStandardDeviation = myQSettings.value("/Raster/defaultStandardDeviation", 1.0).toDouble();
732+
sboxThreeBandStdDev->setValue(mDefaultStandardDeviation);
725733
}
726734

727735
QgsDebugMsg( "populate transparency tab" );
@@ -2193,6 +2201,7 @@ void QgsRasterLayerProperties::on_rbtnThreeBandMinMax_toggled( bool theState )
21932201
void QgsRasterLayerProperties::on_rbtnThreeBandStdDev_toggled( bool theState )
21942202
{
21952203
sboxThreeBandStdDev->setEnabled( theState );
2204+
sboxThreeBandStdDev->setValue( mDefaultStandardDeviation );
21962205
}
21972206

21982207
void QgsRasterLayerProperties::pixelSelected( int x, int y )

src/core/raster/qgsrasterlayer.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -5531,6 +5531,12 @@ bool QgsRasterLayer::readFile( QString const &theFilename )
55315531
mTransparencyBandName = TRSTRING_NOT_SET;
55325532
mGrayBandName = TRSTRING_NOT_SET; //sensible default
55335533
mDrawingStyle = MultiBandColor; //sensible default
5534+
5535+
// read standard deviations
5536+
if ( mContrastEnhancementAlgorithm == QgsContrastEnhancement::StretchToMinimumMaximum )
5537+
{
5538+
setStandardDeviations( myQSettings.value( "/Raster/defaultStandardDeviation", 2 ).toInt() );
5539+
}
55345540
}
55355541
else //GrayOrUndefined
55365542
{
@@ -5540,6 +5546,12 @@ bool QgsRasterLayer::readFile( QString const &theFilename )
55405546
mTransparencyBandName = TRSTRING_NOT_SET; //sensible default
55415547
mDrawingStyle = SingleBandGray; //sensible default
55425548
mGrayBandName = bandName( 1 );
5549+
5550+
// read standard deviations
5551+
if ( mContrastEnhancementAlgorithm == QgsContrastEnhancement::StretchToMinimumMaximum )
5552+
{
5553+
setStandardDeviations( myQSettings.value( "/Raster/defaultStandardDeviation", 2 ).toInt() );
5554+
}
55435555
}
55445556

55455557
//mark the layer as valid

0 commit comments

Comments
 (0)