Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
don't use color interpretation band names when band count > 1
  • Loading branch information
etiennesky committed Jul 14, 2012
1 parent 79d5dda commit 72c9f5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
18 changes: 11 additions & 7 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -244,19 +244,23 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
cboxTransparencyBand->addItem( tr( "None" ), -1 );
int nBands = provider->bandCount();
QString bandName;
for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1

if ( nBands == 1 )
{
bandName = provider->colorInterpretationName( i );
/* Color interpretation name only makes sense for 1-band rasters */
bandName = provider->colorInterpretationName( 1 );
if ( bandName == "Undefined" )
bandName = provider->generateBandName( 1 );
cboxTransparencyBand->addItem( bandName, 1 );
}
else if ( nBands > 1 )
{
for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1
{
cboxTransparencyBand->addItem( provider->generateBandName( i ), i );
}
else
{
bandName = provider->generateBandName( i );
cboxTransparencyBand->addItem( bandName, i );
}
}

if ( renderer )
{
cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->alphaBand() ) );
Expand Down
11 changes: 8 additions & 3 deletions src/gui/raster/qgsrasterrendererwidget.cpp
Expand Up @@ -34,11 +34,16 @@ QString QgsRasterRendererWidget::displayBandName( int band ) const
return name;
}

name = provider->colorInterpretationName( band );
if ( name == "Undefined" )
/* Color interpretation name only makes sense for 1-band rasters */
if ( provider->bandCount() <= 1 )
{
name = provider->generateBandName( band );
name = provider->colorInterpretationName( band );
if ( name != "Undefined" )
return name;
}

name = provider->generateBandName( band );

return name;
}

Expand Down

0 comments on commit 72c9f5a

Please sign in to comment.