[QGIS Commit] r15256 - in trunk/qgis/src: app core/raster

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Feb 24 09:12:38 EST 2011


Author: alexbruy
Date: 2011-02-24 06:12:38 -0800 (Thu, 24 Feb 2011)
New Revision: 15256

Modified:
   trunk/qgis/src/app/qgsrasterlayerproperties.cpp
   trunk/qgis/src/core/raster/qgsrasterlayer.cpp
Log:
save default bands combination and stadard deviation. Also use this values when loading new raster layer (fix #3519)


Modified: trunk/qgis/src/app/qgsrasterlayerproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsrasterlayerproperties.cpp	2011-02-24 07:42:47 UTC (rev 15255)
+++ trunk/qgis/src/app/qgsrasterlayerproperties.cpp	2011-02-24 14:12:38 UTC (rev 15256)
@@ -695,12 +695,18 @@
       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" )
     {
@@ -722,6 +728,8 @@
     {
       labelDefaultContrastEnhancementAlgorithm->setText( tr( "No Stretch" ) );
     }
+    mDefaultStandardDeviation = myQSettings.value("/Raster/defaultStandardDeviation", 1.0).toDouble();
+    sboxThreeBandStdDev->setValue(mDefaultStandardDeviation);
   }
 
   QgsDebugMsg( "populate transparency tab" );
@@ -2193,6 +2201,7 @@
 void QgsRasterLayerProperties::on_rbtnThreeBandStdDev_toggled( bool theState )
 {
   sboxThreeBandStdDev->setEnabled( theState );
+  sboxThreeBandStdDev->setValue( mDefaultStandardDeviation );
 }
 
 void QgsRasterLayerProperties::pixelSelected( int x, int y )

Modified: trunk/qgis/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.cpp	2011-02-24 07:42:47 UTC (rev 15255)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.cpp	2011-02-24 14:12:38 UTC (rev 15256)
@@ -5531,6 +5531,12 @@
     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
   {
@@ -5540,6 +5546,12 @@
     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



More information about the QGIS-commit mailing list