[QGIS Commit] r14814 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Nov 30 17:19:16 EST 2010


Author: jef
Date: 2010-11-30 14:19:16 -0800 (Tue, 30 Nov 2010)
New Revision: 14814

Modified:
   trunk/qgis/src/app/qgsrasterlayerproperties.cpp
Log:
fix #3274

Modified: trunk/qgis/src/app/qgsrasterlayerproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsrasterlayerproperties.cpp	2010-11-30 21:15:41 UTC (rev 14813)
+++ trunk/qgis/src/app/qgsrasterlayerproperties.cpp	2010-11-30 22:19:16 UTC (rev 14814)
@@ -290,8 +290,8 @@
   {
     refreshHistogram();
   }
-  tableTransparency->horizontalHeader()->setResizeMode(0,QHeaderView::Stretch);
-  tableTransparency->horizontalHeader()->setResizeMode(1,QHeaderView::Stretch);
+  tableTransparency->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch );
+  tableTransparency->horizontalHeader()->setResizeMode( 1, QHeaderView::Stretch );
 } // QgsRasterLayerProperties ctor
 
 
@@ -945,476 +945,478 @@
  */
 void QgsRasterLayerProperties::apply()
 {
-  QgsDebugMsg( "apply processing symbology tab" );
-  /*
-   * Symbology Tab
-   */
-  //set the appropriate render style
-  if ( rbtnSingleBand->isChecked() )
+  if ( mRasterLayerIsGdal )
   {
-    //
-    // Grayscale
-    //
-    if ( mRasterLayer->rasterType() == QgsRasterLayer::GrayOrUndefined )
+    QgsDebugMsg( "apply processing symbology tab" );
+    /*
+     * Symbology Tab
+     */
+    //set the appropriate render style
+    if ( rbtnSingleBand->isChecked() )
     {
-
-      if ( cboxColorMap->currentText() != tr( "Grayscale" ) )
+      //
+      // Grayscale
+      //
+      if ( mRasterLayer->rasterType() == QgsRasterLayer::GrayOrUndefined )
       {
-        QgsDebugMsg( "Raster Drawing Style to :: SingleBandPseudoColor" );
 
-        mRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
-      }
-      else
-      {
-        QgsDebugMsg( "Setting Raster Drawing Style to :: SingleBandGray" );
+        if ( cboxColorMap->currentText() != tr( "Grayscale" ) )
+        {
+          QgsDebugMsg( "Raster Drawing Style to :: SingleBandPseudoColor" );
 
-        mRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandGray );
-      }
-    }
-    //
-    // Paletted Image
-    //
-    else if ( mRasterLayer->rasterType() == QgsRasterLayer::Palette )
-    {
-      if ( cboxColorMap->currentText() == tr( "Grayscale" ) )
-      {
-        QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedSingleBandGray" );
-        QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" )
-                     .arg( cboGray->currentText() ).arg( mRasterLayer->grayBandName() ) );
+          mRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
+        }
+        else
+        {
+          QgsDebugMsg( "Setting Raster Drawing Style to :: SingleBandGray" );
 
-        mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedSingleBandGray );
+          mRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandGray );
+        }
       }
-      else if ( cboxColorMap->currentText() == tr( "Colormap" ) )
+      //
+      // Paletted Image
+      //
+      else if ( mRasterLayer->rasterType() == QgsRasterLayer::Palette )
       {
-        QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedColor" );
-        QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" ).arg( cboGray->currentText() ).arg( mRasterLayer->
-                     grayBandName() ) );
+        if ( cboxColorMap->currentText() == tr( "Grayscale" ) )
+        {
+          QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedSingleBandGray" );
+          QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" )
+                       .arg( cboGray->currentText() ).arg( mRasterLayer->grayBandName() ) );
 
-        mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedColor );
+          mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedSingleBandGray );
+        }
+        else if ( cboxColorMap->currentText() == tr( "Colormap" ) )
+        {
+          QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedColor" );
+          QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" ).arg( cboGray->currentText() ).arg( mRasterLayer->
+                       grayBandName() ) );
+
+          mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedColor );
+        }
+        else
+        {
+          QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedSingleBandPseudoColor" );
+
+          mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedSingleBandPseudoColor );
+        }
+
       }
-      else
+      //
+      // Mutltiband
+      //
+      else if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
       {
-        QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedSingleBandPseudoColor" );
+        if ( cboxColorMap->currentText() != tr( "Grayscale" ) )
+        {
+          QgsDebugMsg( "Setting Raster Drawing Style to ::MultiBandSingleBandPseudoColor " );
 
-        mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedSingleBandPseudoColor );
+          mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandSingleBandPseudoColor );
+        }
+        else
+        {
+          QgsDebugMsg( "Setting Raster Drawing Style to :: MultiBandSingleBandGray" );
+          QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" ).arg( cboGray->currentText() ).arg( mRasterLayer->
+                       grayBandName() ) );
+
+          mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandSingleBandGray );
+
+        }
       }
+    }                           //end of grayscale box enabled and rbtnsingleband checked
+    else                          //assume that rbtnThreeBand is checked and render in rgb color
+    {
+      //set the grayscale color table type if the groupbox is enabled
 
-    }
-    //
-    // Mutltiband
-    //
-    else if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
-    {
-      if ( cboxColorMap->currentText() != tr( "Grayscale" ) )
+      if ( mRasterLayer->rasterType() == QgsRasterLayer::Palette )
       {
-        QgsDebugMsg( "Setting Raster Drawing Style to ::MultiBandSingleBandPseudoColor " );
+        QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedMultiBandColor" );
 
-        mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandSingleBandPseudoColor );
+        mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedMultiBandColor );
       }
-      else
+      else if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
       {
-        QgsDebugMsg( "Setting Raster Drawing Style to :: MultiBandSingleBandGray" );
-        QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" ).arg( cboGray->currentText() ).arg( mRasterLayer->
-                     grayBandName() ) );
 
-        mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandSingleBandGray );
+        QgsDebugMsg( "Setting Raster Drawing Style to :: MultiBandColor" );
 
+        mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandColor );
       }
+
     }
-  }                           //end of grayscale box enabled and rbtnsingleband checked
-  else                          //assume that rbtnThreeBand is checked and render in rgb color
-  {
-    //set the grayscale color table type if the groupbox is enabled
 
-    if ( mRasterLayer->rasterType() == QgsRasterLayer::Palette )
+    //set whether the layer histogram should be inverted
+    if ( cboxInvertColorMap->isChecked() )
     {
-      QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedMultiBandColor" );
-
-      mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedMultiBandColor );
+      mRasterLayer->setInvertHistogram( true );
     }
-    else if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
+    else
     {
+      mRasterLayer->setInvertHistogram( false );
+    }
 
-      QgsDebugMsg( "Setting Raster Drawing Style to :: MultiBandColor" );
+    //now set the color -> band mapping combos to the correct values
+    mRasterLayer->setRedBandName( cboRed->currentText() );
+    mRasterLayer->setGreenBandName( cboGreen->currentText() );
+    mRasterLayer->setBlueBandName( cboBlue->currentText() );
+    mRasterLayer->setGrayBandName( cboGray->currentText() );
+    mRasterLayer->setTransparentBandName( cboxTransparencyBand->currentText() );
 
-      mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandColor );
+    //set the appropriate color shading type
+    //If UserDefined do nothing, user defined can only be set programatically
+    if ( cboxColorMap->currentText() == tr( "Pseudocolor" ) )
+    {
+      mRasterLayer->setColorShadingAlgorithm( QgsRasterLayer::PseudoColorShader );
     }
+    else if ( cboxColorMap->currentText() == tr( "Freak Out" ) )
+    {
+      mRasterLayer->setColorShadingAlgorithm( QgsRasterLayer::FreakOutShader );
+    }
+    else if ( cboxColorMap->currentText() == tr( "Colormap" ) )
+    {
+      mRasterLayer->setColorShadingAlgorithm( QgsRasterLayer::ColorRampShader );
+    }
 
-  }
+    //set the color scaling algorithm
+    //Since the maximum, minimum values are going to be set anyway, pass in false for the second parameter of setContrastEnahancementAlgorithm
+    //so the the look up tables are not generated for each band, since their parameters are about to change anyway.This will also generate the
+    //lookup tables for the three or one band(s) that are immediately needed
+    if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "Stretch To MinMax" ) )
+    {
+      mRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchToMinimumMaximum, false );
+    }
+    else if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "Stretch And Clip To MinMax" ) )
+    {
+      mRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchAndClipToMinimumMaximum, false );
+    }
+    else if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "Clip To MinMax" ) )
+    {
+      mRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::ClipToMinimumMaximum, false );
+    }
+    else if ( QgsContrastEnhancement::UserDefinedEnhancement == mRasterLayer->contrastEnhancementAlgorithm() )
+    {
+      //do nothing
+    }
+    else
+    {
+      mRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::NoEnhancement, false );
+    }
 
-  //set whether the layer histogram should be inverted
-  if ( cboxInvertColorMap->isChecked() )
-  {
-    mRasterLayer->setInvertHistogram( true );
-  }
-  else
-  {
-    mRasterLayer->setInvertHistogram( false );
-  }
-
-  //set transparency
-  mRasterLayer->setTransparency( static_cast < unsigned int >( 255 - sliderTransparency->value() ) );
-
-  //now set the color -> band mapping combos to the correct values
-  mRasterLayer->setRedBandName( cboRed->currentText() );
-  mRasterLayer->setGreenBandName( cboGreen->currentText() );
-  mRasterLayer->setBlueBandName( cboBlue->currentText() );
-  mRasterLayer->setGrayBandName( cboGray->currentText() );
-  mRasterLayer->setTransparentBandName( cboxTransparencyBand->currentText() );
-
-  //set the appropriate color shading type
-  //If UserDefined do nothing, user defined can only be set programatically
-  if ( cboxColorMap->currentText() == tr( "Pseudocolor" ) )
-  {
-    mRasterLayer->setColorShadingAlgorithm( QgsRasterLayer::PseudoColorShader );
-  }
-  else if ( cboxColorMap->currentText() == tr( "Freak Out" ) )
-  {
-    mRasterLayer->setColorShadingAlgorithm( QgsRasterLayer::FreakOutShader );
-  }
-  else if ( cboxColorMap->currentText() == tr( "Colormap" ) )
-  {
-    mRasterLayer->setColorShadingAlgorithm( QgsRasterLayer::ColorRampShader );
-  }
-
-  //set the color scaling algorithm
-  //Since the maximum, minimum values are going to be set anyway, pass in false for the second parameter of setContrastEnahancementAlgorithm
-  //so the the look up tables are not generated for each band, since their parameters are about to change anyway.This will also generate the
-  //lookup tables for the three or one band(s) that are immediately needed
-  if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "Stretch To MinMax" ) )
-  {
-    mRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchToMinimumMaximum, false );
-  }
-  else if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "Stretch And Clip To MinMax" ) )
-  {
-    mRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchAndClipToMinimumMaximum, false );
-  }
-  else if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "Clip To MinMax" ) )
-  {
-    mRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::ClipToMinimumMaximum, false );
-  }
-  else if ( QgsContrastEnhancement::UserDefinedEnhancement == mRasterLayer->contrastEnhancementAlgorithm() )
-  {
-    //do nothing
-  }
-  else
-  {
-    mRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::NoEnhancement, false );
-  }
-
-  //set the std deviations to be plotted and check for user defined Min Max values
-  if ( mRasterLayerIsGdal && rbtnThreeBand->isChecked() )
-  {
-    //Set min max based on user defined values if all are set and stdDev is 0.0
-    if ( rbtnThreeBandMinMax->isEnabled() && rbtnThreeBandMinMax->isChecked() && validUserDefinedMinMax() )
+    //set the std deviations to be plotted and check for user defined Min Max values
+    if ( rbtnThreeBand->isChecked() )
     {
-      mRasterLayer->setRGBMinimumMaximumEstimated( mRGBMinimumMaximumEstimated );
-      if ( mRasterLayer->redBandName() != TRSTRING_NOT_SET )
+      //Set min max based on user defined values if all are set and stdDev is 0.0
+      if ( rbtnThreeBandMinMax->isEnabled() && rbtnThreeBandMinMax->isChecked() && validUserDefinedMinMax() )
       {
-        mRasterLayer->setMinimumValue( cboRed->currentText(), leRedMin->text().toDouble(), false );
-        mRasterLayer->setMaximumValue( cboRed->currentText(), leRedMax->text().toDouble() );
+        mRasterLayer->setRGBMinimumMaximumEstimated( mRGBMinimumMaximumEstimated );
+        if ( mRasterLayer->redBandName() != TRSTRING_NOT_SET )
+        {
+          mRasterLayer->setMinimumValue( cboRed->currentText(), leRedMin->text().toDouble(), false );
+          mRasterLayer->setMaximumValue( cboRed->currentText(), leRedMax->text().toDouble() );
+        }
+        if ( mRasterLayer->greenBandName() != TRSTRING_NOT_SET )
+        {
+          mRasterLayer->setMinimumValue( cboGreen->currentText(), leGreenMin->text().toDouble(), false );
+          mRasterLayer->setMaximumValue( cboGreen->currentText(), leGreenMax->text().toDouble() );
+        }
+        if ( mRasterLayer->blueBandName() != TRSTRING_NOT_SET )
+        {
+          mRasterLayer->setMinimumValue( cboBlue->currentText(), leBlueMin->text().toDouble(), false );
+          mRasterLayer->setMaximumValue( cboBlue->currentText(), leBlueMax->text().toDouble() );
+        }
+        mRasterLayer->setStandardDeviations( 0.0 );
+        mRasterLayer->setUserDefinedRGBMinimumMaximum( true );
       }
-      if ( mRasterLayer->greenBandName() != TRSTRING_NOT_SET )
+      else if ( rbtnThreeBandStdDev->isEnabled() && rbtnThreeBandStdDev->isChecked() )
       {
-        mRasterLayer->setMinimumValue( cboGreen->currentText(), leGreenMin->text().toDouble(), false );
-        mRasterLayer->setMaximumValue( cboGreen->currentText(), leGreenMax->text().toDouble() );
+        mRasterLayer->setStandardDeviations( sboxThreeBandStdDev->value() );
+        mRasterLayer->setUserDefinedRGBMinimumMaximum( false );
       }
-      if ( mRasterLayer->blueBandName() != TRSTRING_NOT_SET )
+      else
       {
-        mRasterLayer->setMinimumValue( cboBlue->currentText(), leBlueMin->text().toDouble(), false );
-        mRasterLayer->setMaximumValue( cboBlue->currentText(), leBlueMax->text().toDouble() );
+        mRasterLayer->setStandardDeviations( 0.0 );
+        mRasterLayer->setUserDefinedRGBMinimumMaximum( false );
       }
-      mRasterLayer->setStandardDeviations( 0.0 );
-      mRasterLayer->setUserDefinedRGBMinimumMaximum( true );
     }
-    else if ( rbtnThreeBandStdDev->isEnabled() && rbtnThreeBandStdDev->isChecked() )
-    {
-      mRasterLayer->setStandardDeviations( sboxThreeBandStdDev->value() );
-      mRasterLayer->setUserDefinedRGBMinimumMaximum( false );
-    }
     else
     {
-      mRasterLayer->setStandardDeviations( 0.0 );
-      mRasterLayer->setUserDefinedRGBMinimumMaximum( false );
-    }
-  }
-  else if ( mRasterLayerIsGdal )
-  {
-    //Set min max based on user defined values if all are set and stdDev is 0.0
-    if ( rbtnSingleBandMinMax->isEnabled() && rbtnSingleBandMinMax->isChecked() && validUserDefinedMinMax() )
-    {
-      mRasterLayer->setGrayMinimumMaximumEstimated( mGrayMinimumMaximumEstimated );
-      if ( mRasterLayer->grayBandName() != TRSTRING_NOT_SET )
+      //Set min max based on user defined values if all are set and stdDev is 0.0
+      if ( rbtnSingleBandMinMax->isEnabled() && rbtnSingleBandMinMax->isChecked() && validUserDefinedMinMax() )
       {
-        mRasterLayer->setMinimumValue( cboGray->currentText(), leGrayMin->text().toDouble(), false );
-        mRasterLayer->setMaximumValue( cboGray->currentText(), leGrayMax->text().toDouble() );
+        mRasterLayer->setGrayMinimumMaximumEstimated( mGrayMinimumMaximumEstimated );
+        if ( mRasterLayer->grayBandName() != TRSTRING_NOT_SET )
+        {
+          mRasterLayer->setMinimumValue( cboGray->currentText(), leGrayMin->text().toDouble(), false );
+          mRasterLayer->setMaximumValue( cboGray->currentText(), leGrayMax->text().toDouble() );
+        }
+        mRasterLayer->setStandardDeviations( 0.0 );
+        mRasterLayer->setUserDefinedGrayMinimumMaximum( true );
       }
-      mRasterLayer->setStandardDeviations( 0.0 );
-      mRasterLayer->setUserDefinedGrayMinimumMaximum( true );
+      else if ( rbtnSingleBandStdDev->isEnabled() && rbtnSingleBandStdDev->isChecked() )
+      {
+        mRasterLayer->setStandardDeviations( sboxSingleBandStdDev->value() );
+        mRasterLayer->setUserDefinedGrayMinimumMaximum( false );
+      }
+      else
+      {
+        mRasterLayer->setStandardDeviations( 0.0 );
+        mRasterLayer->setUserDefinedGrayMinimumMaximum( false );
+      }
     }
-    else if ( rbtnSingleBandStdDev->isEnabled() && rbtnSingleBandStdDev->isChecked() )
-    {
-      mRasterLayer->setStandardDeviations( sboxSingleBandStdDev->value() );
-      mRasterLayer->setUserDefinedGrayMinimumMaximum( false );
-    }
-    else
-    {
-      mRasterLayer->setStandardDeviations( 0.0 );
-      mRasterLayer->setUserDefinedGrayMinimumMaximum( false );
-    }
-  }
 
-  QSettings myQSettings;
-  myQSettings.setValue( "/Raster/defaultRedBand", mDefaultRedBand );
-  myQSettings.setValue( "/Raster/defaultGreenBand", mDefaultGreenBand );
-  myQSettings.setValue( "/Raster/defaultBlueBand", mDefaultBlueBand );
+    QSettings myQSettings;
+    myQSettings.setValue( "/Raster/defaultRedBand", mDefaultRedBand );
+    myQSettings.setValue( "/Raster/defaultGreenBand", mDefaultGreenBand );
+    myQSettings.setValue( "/Raster/defaultBlueBand", mDefaultBlueBand );
 
-  myQSettings.setValue( "/Raster/defaultContrastEnhancementAlgorithm", mDefaultContrastEnhancementAlgorithm );
+    myQSettings.setValue( "/Raster/defaultContrastEnhancementAlgorithm", mDefaultContrastEnhancementAlgorithm );
 
-  myQSettings.setValue( "/Raster/defaultStandardDeviation", mDefaultStandardDeviation );
+    myQSettings.setValue( "/Raster/defaultStandardDeviation", mDefaultStandardDeviation );
 
-  QgsDebugMsg( "processing transparency tab" );
-  /*
-   * Transparent Pixel Tab
-   */
+    QgsDebugMsg( "processing transparency tab" );
+    /*
+     * Transparent Pixel Tab
+     */
 
-  //set NoDataValue
-  bool myDoubleOk = false;
-  if ( "" != leNoDataValue->text() )
-  {
-    double myNoDataValue = leNoDataValue->text().toDouble( &myDoubleOk );
-    if ( myDoubleOk )
+    //set NoDataValue
+    bool myDoubleOk = false;
+    if ( "" != leNoDataValue->text() )
     {
-      mRasterLayer->setNoDataValue( myNoDataValue );
+      double myNoDataValue = leNoDataValue->text().toDouble( &myDoubleOk );
+      if ( myDoubleOk )
+      {
+        mRasterLayer->setNoDataValue( myNoDataValue );
+      }
     }
-  }
 
-  //Walk through each row in table and test value. If not valid set to 0.0 and continue building transparency list
-  if ( rbtnThreeBand->isChecked() && QgsRasterLayer::MultiBandColor == mRasterLayer->drawingStyle() )
-  {
-    double myTransparentValue;
-    double myPercentTransparent;
-    QgsRasterTransparency::TransparentThreeValuePixel myTransparentPixel;
-    QList<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
-    for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
+    //Walk through each row in table and test value. If not valid set to 0.0 and continue building transparency list
+    if ( rbtnThreeBand->isChecked() && QgsRasterLayer::MultiBandColor == mRasterLayer->drawingStyle() )
     {
-      if ( !tableTransparency->item( myListRunner, 0 ) )
+      double myTransparentValue;
+      double myPercentTransparent;
+      QgsRasterTransparency::TransparentThreeValuePixel myTransparentPixel;
+      QList<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
+      for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
       {
-        myTransparentPixel.red = 0.0;
-        QTableWidgetItem* newItem = new QTableWidgetItem( "0.0" );
-        tableTransparency->setItem( myListRunner, 0, newItem );
-      }
-      else
-      {
-        myTransparentValue = tableTransparency->item( myListRunner, 0 )->text().toDouble( &myDoubleOk );
-        if ( myDoubleOk )
+        if ( !tableTransparency->item( myListRunner, 0 ) )
         {
-          myTransparentPixel.red = myTransparentValue;
+          myTransparentPixel.red = 0.0;
+          QTableWidgetItem* newItem = new QTableWidgetItem( "0.0" );
+          tableTransparency->setItem( myListRunner, 0, newItem );
         }
         else
         {
-          myTransparentPixel.red = 0.0;
-          tableTransparency->item( myListRunner, 0 )->setText( "0.0" );
+          myTransparentValue = tableTransparency->item( myListRunner, 0 )->text().toDouble( &myDoubleOk );
+          if ( myDoubleOk )
+          {
+            myTransparentPixel.red = myTransparentValue;
+          }
+          else
+          {
+            myTransparentPixel.red = 0.0;
+            tableTransparency->item( myListRunner, 0 )->setText( "0.0" );
+          }
         }
-      }
 
-      if ( !tableTransparency->item( myListRunner, 1 ) )
-      {
-        myTransparentPixel.green = 0.0;
-        QTableWidgetItem* newItem = new QTableWidgetItem( "0.0" );
-        tableTransparency->setItem( myListRunner, 1, newItem );
-      }
-      else
-      {
-        myTransparentValue = tableTransparency->item( myListRunner, 1 )->text().toDouble( &myDoubleOk );
-        if ( myDoubleOk )
+        if ( !tableTransparency->item( myListRunner, 1 ) )
         {
-          myTransparentPixel.green = myTransparentValue;
+          myTransparentPixel.green = 0.0;
+          QTableWidgetItem* newItem = new QTableWidgetItem( "0.0" );
+          tableTransparency->setItem( myListRunner, 1, newItem );
         }
         else
         {
-          myTransparentPixel.green = 0.0;
-          tableTransparency->item( myListRunner, 1 )->setText( "0.0" );
+          myTransparentValue = tableTransparency->item( myListRunner, 1 )->text().toDouble( &myDoubleOk );
+          if ( myDoubleOk )
+          {
+            myTransparentPixel.green = myTransparentValue;
+          }
+          else
+          {
+            myTransparentPixel.green = 0.0;
+            tableTransparency->item( myListRunner, 1 )->setText( "0.0" );
+          }
         }
-      }
 
-      if ( !tableTransparency->item( myListRunner, 2 ) )
-      {
-        myTransparentPixel.blue = 0.0;
-        QTableWidgetItem* newItem = new QTableWidgetItem( "0.0" );
-        tableTransparency->setItem( myListRunner, 2, newItem );
-      }
-      else
-      {
-        myTransparentValue = tableTransparency->item( myListRunner, 2 )->text().toDouble( &myDoubleOk );
-        if ( myDoubleOk )
+        if ( !tableTransparency->item( myListRunner, 2 ) )
         {
-          myTransparentPixel.blue = myTransparentValue;
+          myTransparentPixel.blue = 0.0;
+          QTableWidgetItem* newItem = new QTableWidgetItem( "0.0" );
+          tableTransparency->setItem( myListRunner, 2, newItem );
         }
         else
         {
-          myTransparentPixel.blue = 0.0;
-          tableTransparency->item( myListRunner, 2 )->setText( "0.0" );
+          myTransparentValue = tableTransparency->item( myListRunner, 2 )->text().toDouble( &myDoubleOk );
+          if ( myDoubleOk )
+          {
+            myTransparentPixel.blue = myTransparentValue;
+          }
+          else
+          {
+            myTransparentPixel.blue = 0.0;
+            tableTransparency->item( myListRunner, 2 )->setText( "0.0" );
+          }
         }
-      }
 
-      if ( !tableTransparency->item( myListRunner, 3 ) )
-      {
-        myTransparentPixel.percentTransparent = 100.0;
-        QTableWidgetItem* newItem = new QTableWidgetItem( "100.0" );
-        tableTransparency->setItem( myListRunner, 3, newItem );
-      }
-      else
-      {
-        QString myNumberFormatter;
-        myPercentTransparent = tableTransparency->item( myListRunner, 3 )->text().toDouble( &myDoubleOk );
-        if ( myDoubleOk )
+        if ( !tableTransparency->item( myListRunner, 3 ) )
         {
-          if ( myPercentTransparent > 100.0 )
-            myTransparentPixel.percentTransparent = 100.0;
-          else if ( myPercentTransparent < 0.0 )
-            myTransparentPixel.percentTransparent = 0.0;
-          else
-            myTransparentPixel.percentTransparent = myPercentTransparent;
-
-          tableTransparency->item( myListRunner, 3 )->setText( myNumberFormatter.sprintf( "%.2f", myTransparentPixel.percentTransparent ) );
+          myTransparentPixel.percentTransparent = 100.0;
+          QTableWidgetItem* newItem = new QTableWidgetItem( "100.0" );
+          tableTransparency->setItem( myListRunner, 3, newItem );
         }
         else
         {
-          myTransparentPixel.percentTransparent = 100.0;
-          tableTransparency->item( myListRunner, 3 )->setText( "100.0" );
+          QString myNumberFormatter;
+          myPercentTransparent = tableTransparency->item( myListRunner, 3 )->text().toDouble( &myDoubleOk );
+          if ( myDoubleOk )
+          {
+            if ( myPercentTransparent > 100.0 )
+              myTransparentPixel.percentTransparent = 100.0;
+            else if ( myPercentTransparent < 0.0 )
+              myTransparentPixel.percentTransparent = 0.0;
+            else
+              myTransparentPixel.percentTransparent = myPercentTransparent;
+
+            tableTransparency->item( myListRunner, 3 )->setText( myNumberFormatter.sprintf( "%.2f", myTransparentPixel.percentTransparent ) );
+          }
+          else
+          {
+            myTransparentPixel.percentTransparent = 100.0;
+            tableTransparency->item( myListRunner, 3 )->setText( "100.0" );
+          }
         }
+
+        myTransparentThreeValuePixelList.append( myTransparentPixel );
       }
 
-      myTransparentThreeValuePixelList.append( myTransparentPixel );
+      mRasterLayer->rasterTransparency()->setTransparentThreeValuePixelList( myTransparentThreeValuePixelList );
     }
-
-    mRasterLayer->rasterTransparency()->setTransparentThreeValuePixelList( myTransparentThreeValuePixelList );
-  }
-  else
-  {
-    double myTransparentValue;
-    double myPercentTransparent;
-    QgsRasterTransparency::TransparentSingleValuePixel myTransparentPixel;
-    QList<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
-    for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
+    else
     {
-      if ( !tableTransparency->item( myListRunner, 0 ) )
+      double myTransparentValue;
+      double myPercentTransparent;
+      QgsRasterTransparency::TransparentSingleValuePixel myTransparentPixel;
+      QList<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
+      for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
       {
-        myTransparentPixel.pixelValue = 0.0;
-        QTableWidgetItem* newItem = new QTableWidgetItem( "0.0" );
-        tableTransparency->setItem( myListRunner, 0, newItem );
-      }
-      else
-      {
-        myTransparentValue = tableTransparency->item( myListRunner, 0 )->text().toDouble( &myDoubleOk );
-        if ( myDoubleOk )
+        if ( !tableTransparency->item( myListRunner, 0 ) )
         {
-          myTransparentPixel.pixelValue = myTransparentValue;
+          myTransparentPixel.pixelValue = 0.0;
+          QTableWidgetItem* newItem = new QTableWidgetItem( "0.0" );
+          tableTransparency->setItem( myListRunner, 0, newItem );
         }
         else
         {
-          myTransparentPixel.pixelValue = 0.0;
-          tableTransparency->item( myListRunner, 0 )->setText( "0.0" );
+          myTransparentValue = tableTransparency->item( myListRunner, 0 )->text().toDouble( &myDoubleOk );
+          if ( myDoubleOk )
+          {
+            myTransparentPixel.pixelValue = myTransparentValue;
+          }
+          else
+          {
+            myTransparentPixel.pixelValue = 0.0;
+            tableTransparency->item( myListRunner, 0 )->setText( "0.0" );
+          }
         }
-      }
 
-      if ( !tableTransparency->item( myListRunner, 1 ) )
-      {
-        myTransparentPixel.percentTransparent = 100.0;
-        QTableWidgetItem* newItem = new QTableWidgetItem( "100.0" );
-        tableTransparency->setItem( myListRunner, 1, newItem );
-      }
-      else
-      {
-        QString myNumberFormatter;
-        myPercentTransparent = tableTransparency->item( myListRunner, 1 )->text().toDouble( &myDoubleOk );
-        if ( myDoubleOk )
+        if ( !tableTransparency->item( myListRunner, 1 ) )
         {
-          if ( myPercentTransparent > 100.0 )
-            myTransparentPixel.percentTransparent = 100.0;
-          else if ( myPercentTransparent < 0.0 )
-            myTransparentPixel.percentTransparent = 0.0;
-          else
-            myTransparentPixel.percentTransparent = myPercentTransparent;
-
-          tableTransparency->item( myListRunner, 1 )->setText( myNumberFormatter.sprintf( "%.2f", myTransparentPixel.percentTransparent ) );
+          myTransparentPixel.percentTransparent = 100.0;
+          QTableWidgetItem* newItem = new QTableWidgetItem( "100.0" );
+          tableTransparency->setItem( myListRunner, 1, newItem );
         }
         else
         {
-          myTransparentPixel.percentTransparent = 100.0;
-          tableTransparency->item( myListRunner, 1 )->setText( "100.0" );
+          QString myNumberFormatter;
+          myPercentTransparent = tableTransparency->item( myListRunner, 1 )->text().toDouble( &myDoubleOk );
+          if ( myDoubleOk )
+          {
+            if ( myPercentTransparent > 100.0 )
+              myTransparentPixel.percentTransparent = 100.0;
+            else if ( myPercentTransparent < 0.0 )
+              myTransparentPixel.percentTransparent = 0.0;
+            else
+              myTransparentPixel.percentTransparent = myPercentTransparent;
+
+            tableTransparency->item( myListRunner, 1 )->setText( myNumberFormatter.sprintf( "%.2f", myTransparentPixel.percentTransparent ) );
+          }
+          else
+          {
+            myTransparentPixel.percentTransparent = 100.0;
+            tableTransparency->item( myListRunner, 1 )->setText( "100.0" );
+          }
         }
+
+        myTransparentSingleValuePixelList.append( myTransparentPixel );
       }
 
-      myTransparentSingleValuePixelList.append( myTransparentPixel );
+      mRasterLayer->rasterTransparency()->setTransparentSingleValuePixelList( myTransparentSingleValuePixelList );
     }
 
-    mRasterLayer->rasterTransparency()->setTransparentSingleValuePixelList( myTransparentSingleValuePixelList );
-  }
-
-  QgsDebugMsg( "apply processing Colormap tab" );
-  /*
-   * ColorMap Tab
-   */
-  if ( cboxColorMap->currentText() == tr( "Colormap" ) )
-  {
-    QgsColorRampShader* myRasterShaderFunction = ( QgsColorRampShader* )mRasterLayer->rasterShader()->rasterShaderFunction();
-    if ( myRasterShaderFunction )
+    QgsDebugMsg( "apply processing Colormap tab" );
+    /*
+     * ColorMap Tab
+     */
+    if ( cboxColorMap->currentText() == tr( "Colormap" ) )
     {
-      //iterate through mColormapTreeWidget and set colormap info of layer
-      QList<QgsColorRampShader::ColorRampItem> myColorRampItems;
+      QgsColorRampShader* myRasterShaderFunction = ( QgsColorRampShader* )mRasterLayer->rasterShader()->rasterShaderFunction();
+      if ( myRasterShaderFunction )
+      {
+        //iterate through mColormapTreeWidget and set colormap info of layer
+        QList<QgsColorRampShader::ColorRampItem> myColorRampItems;
 
-      int myTopLevelItemCount = mColormapTreeWidget->topLevelItemCount();
-      QTreeWidgetItem* myCurrentItem;
-      for ( int i = 0; i < myTopLevelItemCount; ++i )
-      {
-        myCurrentItem = mColormapTreeWidget->topLevelItem( i );
-        if ( !myCurrentItem )
+        int myTopLevelItemCount = mColormapTreeWidget->topLevelItemCount();
+        QTreeWidgetItem* myCurrentItem;
+        for ( int i = 0; i < myTopLevelItemCount; ++i )
         {
-          continue;
+          myCurrentItem = mColormapTreeWidget->topLevelItem( i );
+          if ( !myCurrentItem )
+          {
+            continue;
+          }
+          QgsColorRampShader::ColorRampItem myNewColorRampItem;
+          myNewColorRampItem.value = myCurrentItem->text( 0 ).toDouble();
+          myNewColorRampItem.color = myCurrentItem->background( 1 ).color();
+          myNewColorRampItem.label = myCurrentItem->text( 2 );
+
+          myColorRampItems.append( myNewColorRampItem );
         }
-        QgsColorRampShader::ColorRampItem myNewColorRampItem;
-        myNewColorRampItem.value = myCurrentItem->text( 0 ).toDouble();
-        myNewColorRampItem.color = myCurrentItem->background( 1 ).color();
-        myNewColorRampItem.label = myCurrentItem->text( 2 );
 
-        myColorRampItems.append( myNewColorRampItem );
-      }
+        // sort the shader items
+        qSort( myColorRampItems );
 
-      // sort the shader items
-      qSort( myColorRampItems );
+        myRasterShaderFunction->setColorRampItemList( myColorRampItems );
+        //Reload table in GUI because it may have been sorted or contained invalid values
+        populateColorMapTable( myColorRampItems );
 
-      myRasterShaderFunction->setColorRampItemList( myColorRampItems );
-      //Reload table in GUI because it may have been sorted or contained invalid values
-      populateColorMapTable( myColorRampItems );
-
-      if ( cboxColorInterpolation->currentText() == tr( "Linear" ) )
-      {
-        myRasterShaderFunction->setColorRampType( QgsColorRampShader::INTERPOLATED );
+        if ( cboxColorInterpolation->currentText() == tr( "Linear" ) )
+        {
+          myRasterShaderFunction->setColorRampType( QgsColorRampShader::INTERPOLATED );
+        }
+        else if ( cboxColorInterpolation->currentText() == tr( "Discrete" ) )
+        {
+          myRasterShaderFunction->setColorRampType( QgsColorRampShader::DISCRETE );
+        }
+        else
+        {
+          myRasterShaderFunction->setColorRampType( QgsColorRampShader::EXACT );
+        }
       }
-      else if ( cboxColorInterpolation->currentText() == tr( "Discrete" ) )
-      {
-        myRasterShaderFunction->setColorRampType( QgsColorRampShader::DISCRETE );
-      }
       else
       {
-        myRasterShaderFunction->setColorRampType( QgsColorRampShader::EXACT );
+        QgsDebugMsg( "color ramp was NOT set because RasterShaderFunction was NULL" );
       }
     }
-    else
-    {
-      QgsDebugMsg( "color ramp was NOT set because RasterShaderFunction was NULL" );
-    }
   }
 
+  //set transparency
+  mRasterLayer->setTransparency( static_cast < unsigned int >( 255 - sliderTransparency->value() ) );
+
   QgsDebugMsg( "processing general tab" );
   /*
    * General Tab
    */
   mRasterLayer->setLayerName( leDisplayName->text() );
 
-
   // set up the scale based layer visibility stuff....
   mRasterLayer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
   mRasterLayer->setMinimumScale( leMinimumScale->text().toFloat() );
@@ -1440,68 +1442,71 @@
   mRasterLayer->triggerRepaint();
 
   //Because Min Max values can be set during the redraw if a strech is requested we need to resync after apply
-  if ( mRasterLayerIsGdal && QgsContrastEnhancement::NoEnhancement != mRasterLayer->contrastEnhancementAlgorithm() )
+  if ( mRasterLayerIsGdal )
   {
-    //set the stdDevs and min max values
-    if ( rbtnThreeBand->isChecked() )
+    if ( QgsContrastEnhancement::NoEnhancement != mRasterLayer->contrastEnhancementAlgorithm() )
     {
-      if ( rbtnThreeBandStdDev->isEnabled() )
+      //set the stdDevs and min max values
+      if ( rbtnThreeBand->isChecked() )
       {
-        sboxThreeBandStdDev->setValue( mRasterLayer->standardDeviations() );
-      }
-
-      if ( rbtnThreeBandMinMax->isEnabled() )
-      {
-        mRGBMinimumMaximumEstimated = mRasterLayer->isRGBMinimumMaximumEstimated();
-        if ( mRasterLayer->redBandName() != TRSTRING_NOT_SET )
+        if ( rbtnThreeBandStdDev->isEnabled() )
         {
-          leRedMin->setText( QString::number( mRasterLayer->minimumValue( mRasterLayer->redBandName() ) ) );
-          leRedMax->setText( QString::number( mRasterLayer->maximumValue( mRasterLayer->redBandName() ) ) );
+          sboxThreeBandStdDev->setValue( mRasterLayer->standardDeviations() );
         }
-        if ( mRasterLayer->greenBandName() != TRSTRING_NOT_SET )
+
+        if ( rbtnThreeBandMinMax->isEnabled() )
         {
-          leGreenMin->setText( QString::number( mRasterLayer->minimumValue( mRasterLayer->greenBandName() ) ) );
-          leGreenMax->setText( QString::number( mRasterLayer->maximumValue( mRasterLayer->greenBandName() ) ) );
+          mRGBMinimumMaximumEstimated = mRasterLayer->isRGBMinimumMaximumEstimated();
+          if ( mRasterLayer->redBandName() != TRSTRING_NOT_SET )
+          {
+            leRedMin->setText( QString::number( mRasterLayer->minimumValue( mRasterLayer->redBandName() ) ) );
+            leRedMax->setText( QString::number( mRasterLayer->maximumValue( mRasterLayer->redBandName() ) ) );
+          }
+          if ( mRasterLayer->greenBandName() != TRSTRING_NOT_SET )
+          {
+            leGreenMin->setText( QString::number( mRasterLayer->minimumValue( mRasterLayer->greenBandName() ) ) );
+            leGreenMax->setText( QString::number( mRasterLayer->maximumValue( mRasterLayer->greenBandName() ) ) );
+          }
+          if ( mRasterLayer->blueBandName() != TRSTRING_NOT_SET )
+          {
+            leBlueMin->setText( QString::number( mRasterLayer->minimumValue( mRasterLayer->blueBandName() ) ) );
+            leBlueMax->setText( QString::number( mRasterLayer->maximumValue( mRasterLayer->blueBandName() ) ) );
+          }
+          setMinimumMaximumEstimateWarning();
         }
-        if ( mRasterLayer->blueBandName() != TRSTRING_NOT_SET )
+      }
+      else
+      {
+        if ( rbtnSingleBandStdDev->isEnabled() )
         {
-          leBlueMin->setText( QString::number( mRasterLayer->minimumValue( mRasterLayer->blueBandName() ) ) );
-          leBlueMax->setText( QString::number( mRasterLayer->maximumValue( mRasterLayer->blueBandName() ) ) );
+          sboxSingleBandStdDev->setValue( mRasterLayer->standardDeviations() );
         }
-        setMinimumMaximumEstimateWarning();
-      }
-    }
-    else
-    {
-      if ( rbtnSingleBandStdDev->isEnabled() )
-      {
-        sboxSingleBandStdDev->setValue( mRasterLayer->standardDeviations() );
-      }
 
-      if ( rbtnSingleBandMinMax->isEnabled() )
-      {
-        mGrayMinimumMaximumEstimated = mRasterLayer->isGrayMinimumMaximumEstimated();
-        if ( mRasterLayer->grayBandName() != TRSTRING_NOT_SET )
+        if ( rbtnSingleBandMinMax->isEnabled() )
         {
-          leGrayMin->setText( QString::number( mRasterLayer->minimumValue( mRasterLayer->grayBandName() ) ) );
-          leGrayMax->setText( QString::number( mRasterLayer->maximumValue( mRasterLayer->grayBandName() ) ) );
+          mGrayMinimumMaximumEstimated = mRasterLayer->isGrayMinimumMaximumEstimated();
+          if ( mRasterLayer->grayBandName() != TRSTRING_NOT_SET )
+          {
+            leGrayMin->setText( QString::number( mRasterLayer->minimumValue( mRasterLayer->grayBandName() ) ) );
+            leGrayMax->setText( QString::number( mRasterLayer->maximumValue( mRasterLayer->grayBandName() ) ) );
+          }
+          setMinimumMaximumEstimateWarning();
         }
-        setMinimumMaximumEstimateWarning();
       }
     }
-  }
 
-  //GUI Cleanup
-  //Once the user has applied the changes, user defined function will not longer be a valid option so it should be
-  //removed from the list
-  if ( -1 != cboxColorMap->findText( tr( "User Defined" ) ) && tr( "User Defined" ) != cboxColorMap->currentText() )
-  {
-    cboxColorMap->removeItem( cboxColorMap->findText( tr( "User Defined" ) ) );
-  }
+    //GUI Cleanup
+    //Once the user has applied the changes, user defined function will not longer be a valid option so it should be
+    //removed from the list
+    if ( -1 != cboxColorMap->findText( tr( "User Defined" ) ) && tr( "User Defined" ) != cboxColorMap->currentText() )
+    {
+      cboxColorMap->removeItem( cboxColorMap->findText( tr( "User Defined" ) ) );
+    }
 
-  if ( -1 != cboxContrastEnhancementAlgorithm->findText( tr( "User Defined" ) ) && tr( "User Defined" ) != cboxContrastEnhancementAlgorithm->currentText() )
-  {
-    cboxContrastEnhancementAlgorithm->removeItem( cboxContrastEnhancementAlgorithm->findText( tr( "User Defined" ) ) );
+    if ( -1 != cboxContrastEnhancementAlgorithm->findText( tr( "User Defined" ) ) && tr( "User Defined" ) != cboxContrastEnhancementAlgorithm->currentText() )
+    {
+      cboxContrastEnhancementAlgorithm->removeItem( cboxContrastEnhancementAlgorithm->findText( tr( "User Defined" ) ) );
+    }
   }
 
   // notify the project we've made a change



More information about the QGIS-commit mailing list