Skip to content

Commit cc15cdd

Browse files
committedDec 20, 2011
reload default color table
1 parent a3eb02c commit cc15cdd

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed
 

‎src/app/qgsrasterlayerproperties.cpp

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -882,35 +882,45 @@ void QgsRasterLayerProperties::syncColormapTab()
882882
return;
883883
}
884884

885-
if ( QgsRasterLayer::ColorRampShader != mRasterLayer->colorShadingAlgorithm() )
885+
QgsDebugMsg( QString( "colorShadingAlgorithm = %1" ).arg( mRasterLayer->colorShadingAlgorithmAsString() ) );
886+
if ( QgsRasterLayer::ColorRampShader == mRasterLayer->colorShadingAlgorithm() )
886887
{
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() );
897893

898-
sboxNumberOfEntries->setValue( mColormapTreeWidget->topLevelItemCount() );
894+
sboxNumberOfEntries->setValue( mColormapTreeWidget->topLevelItemCount() );
899895

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+
}
908910
}
909911
else
910912
{
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+
}
912923
}
913-
914924
}
915925

916926
bool QgsRasterLayerProperties::validUserDefinedMinMax()

0 commit comments

Comments
 (0)
Please sign in to comment.