Skip to content

Commit

Permalink
save default bands combination and stadard deviation. Also use this v…
Browse files Browse the repository at this point in the history
…alues when loading new raster layer (fix #3519)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15256 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
alexbruy committed Feb 24, 2011
1 parent 63d3f86 commit 68ff7e8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,18 @@ void QgsRasterLayerProperties::sync()
cboxContrastEnhancementAlgorithm->setCurrentIndex( cboxContrastEnhancementAlgorithm->findText( tr( "No Stretch" ) ) );
}

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

// and used band combination
cboRed->setCurrentIndex( cboRed->findText( mRasterLayer->redBandName() ) );
cboGreen->setCurrentIndex( cboGreen->findText( mRasterLayer->greenBandName() ) );
cboBlue->setCurrentIndex( cboBlue->findText( mRasterLayer->blueBandName() ) );

//Display the current default contrast enhancement algorithm
mDefaultContrastEnhancementAlgorithm = myQSettings.value( "/Raster/defaultContrastEnhancementAlgorithm", "NoEnhancement" ).toString();
if ( mDefaultContrastEnhancementAlgorithm == "NoEnhancement" )
{
Expand All @@ -722,6 +728,8 @@ void QgsRasterLayerProperties::sync()
{
labelDefaultContrastEnhancementAlgorithm->setText( tr( "No Stretch" ) );
}
mDefaultStandardDeviation = myQSettings.value("/Raster/defaultStandardDeviation", 1.0).toDouble();
sboxThreeBandStdDev->setValue(mDefaultStandardDeviation);
}

QgsDebugMsg( "populate transparency tab" );
Expand Down Expand Up @@ -2193,6 +2201,7 @@ void QgsRasterLayerProperties::on_rbtnThreeBandMinMax_toggled( bool theState )
void QgsRasterLayerProperties::on_rbtnThreeBandStdDev_toggled( bool theState )
{
sboxThreeBandStdDev->setEnabled( theState );
sboxThreeBandStdDev->setValue( mDefaultStandardDeviation );
}

void QgsRasterLayerProperties::pixelSelected( int x, int y )
Expand Down
12 changes: 12 additions & 0 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5531,6 +5531,12 @@ bool QgsRasterLayer::readFile( QString const &theFilename )
mTransparencyBandName = TRSTRING_NOT_SET;
mGrayBandName = TRSTRING_NOT_SET; //sensible default
mDrawingStyle = MultiBandColor; //sensible default

// read standard deviations
if ( mContrastEnhancementAlgorithm == QgsContrastEnhancement::StretchToMinimumMaximum )
{
setStandardDeviations( myQSettings.value( "/Raster/defaultStandardDeviation", 2 ).toInt() );
}
}
else //GrayOrUndefined
{
Expand All @@ -5540,6 +5546,12 @@ bool QgsRasterLayer::readFile( QString const &theFilename )
mTransparencyBandName = TRSTRING_NOT_SET; //sensible default
mDrawingStyle = SingleBandGray; //sensible default
mGrayBandName = bandName( 1 );

// read standard deviations
if ( mContrastEnhancementAlgorithm == QgsContrastEnhancement::StretchToMinimumMaximum )
{
setStandardDeviations( myQSettings.value( "/Raster/defaultStandardDeviation", 2 ).toInt() );
}
}

//mark the layer as valid
Expand Down

0 comments on commit 68ff7e8

Please sign in to comment.