@@ -882,35 +882,45 @@ void QgsRasterLayerProperties::syncColormapTab()
882
882
return ;
883
883
}
884
884
885
- if ( QgsRasterLayer::ColorRampShader != mRasterLayer ->colorShadingAlgorithm () )
885
+ QgsDebugMsg ( QString ( " colorShadingAlgorithm = %1" ).arg ( mRasterLayer ->colorShadingAlgorithmAsString () ) );
886
+ if ( QgsRasterLayer::ColorRampShader == mRasterLayer ->colorShadingAlgorithm () )
886
887
{
887
- return ;
888
- }
889
-
890
- QgsColorRampShader* myRasterShaderFunction = ( QgsColorRampShader* )mRasterLayer ->rasterShader ()->rasterShaderFunction ();
891
- if ( !myRasterShaderFunction )
892
- {
893
- return ;
894
- }
895
- // restore the colormap tab if layer has custom symbology
896
- populateColorMapTable ( myRasterShaderFunction->colorRampItemList () );
888
+ QgsColorRampShader* myRasterShaderFunction = ( QgsColorRampShader* )mRasterLayer ->rasterShader ()->rasterShaderFunction ();
889
+ if ( myRasterShaderFunction )
890
+ {
891
+ // restore the colormap tab if layer has custom symbology
892
+ populateColorMapTable ( myRasterShaderFunction->colorRampItemList () );
897
893
898
- sboxNumberOfEntries->setValue ( mColormapTreeWidget ->topLevelItemCount () );
894
+ sboxNumberOfEntries->setValue ( mColormapTreeWidget ->topLevelItemCount () );
899
895
900
- // restor state of 'color interpolation' combo box
901
- if ( QgsColorRampShader::INTERPOLATED == myRasterShaderFunction->colorRampType () )
902
- {
903
- cboxColorInterpolation->setCurrentIndex ( cboxColorInterpolation->findText ( tr ( " Linear" ) ) );
904
- }
905
- else if ( QgsColorRampShader::DISCRETE == myRasterShaderFunction->colorRampType () )
906
- {
907
- cboxColorInterpolation->setCurrentIndex ( cboxColorInterpolation->findText ( tr ( " Discrete" ) ) );
896
+ // restor state of 'color interpolation' combo box
897
+ if ( QgsColorRampShader::INTERPOLATED == myRasterShaderFunction->colorRampType () )
898
+ {
899
+ cboxColorInterpolation->setCurrentIndex ( cboxColorInterpolation->findText ( tr ( " Linear" ) ) );
900
+ }
901
+ else if ( QgsColorRampShader::DISCRETE == myRasterShaderFunction->colorRampType () )
902
+ {
903
+ cboxColorInterpolation->setCurrentIndex ( cboxColorInterpolation->findText ( tr ( " Discrete" ) ) );
904
+ }
905
+ else
906
+ {
907
+ cboxColorInterpolation->setCurrentIndex ( cboxColorInterpolation->findText ( tr ( " Exact" ) ) );
908
+ }
909
+ }
908
910
}
909
911
else
910
912
{
911
- cboxColorInterpolation->setCurrentIndex ( cboxColorInterpolation->findText ( tr ( " Exact" ) ) );
913
+ // load default color table if any so that user can return to it if previously switched to different shader, PseudoColorShader or FreakOutShader for example
914
+ // It would be better however to restore possibly previously modified color table
915
+ QgsDebugMsg ( " use default color table" );
916
+ QList<QgsColorRampShader::ColorRampItem> myColorRampList;
917
+ if ( mRasterLayer ->readColorTable ( 1 , &myColorRampList ) )
918
+ {
919
+ populateColorMapTable ( myColorRampList );
920
+ // INTERPOLATED is used as default for Palette raster type
921
+ cboxColorInterpolation->setCurrentIndex ( cboxColorInterpolation->findText ( tr ( " Linear" ) ) );
922
+ }
912
923
}
913
-
914
924
}
915
925
916
926
bool QgsRasterLayerProperties::validUserDefinedMinMax ()
0 commit comments