Skip to content
Permalink
Browse files

make band names consistent

  • Loading branch information
alexbruy committed Jul 15, 2012
1 parent 87bdff9 commit f87777ea692648f8fe67a48d471209393a39bfff
Showing with 14 additions and 21 deletions.
  1. +9 −13 src/app/qgsrasterlayerproperties.cpp
  2. +5 −8 src/gui/raster/qgsrasterrendererwidget.cpp
@@ -244,29 +244,25 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
cboxTransparencyBand->addItem( tr( "None" ), -1 );
int nBands = provider->bandCount();
QString bandName;

if ( nBands == 1 )
{
/* 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
{
for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1
bandName = provider->generateBandName( i );

QString colorInterp = provider->colorInterpretationName( i );
if ( colorInterp != "Undefined" )
{
bandName = provider->generateBandName( i );
cboxTransparencyBand->addItem( bandName, i );
bandName.append( QString( " (%1)" ).arg( colorInterp ) );
}
cboxTransparencyBand->addItem( bandName, i );
}

if ( renderer )
{
cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->alphaBand() ) );
}
}


//insert renderer widgets into registry
QgsRasterRendererRegistry::instance()->insertWidgetFunction( "paletted", QgsPalettedRendererWidget::create );
QgsRasterRendererRegistry::instance()->insertWidgetFunction( "multibandcolor", QgsMultiBandColorRendererWidget::create );
@@ -34,16 +34,13 @@ QString QgsRasterRendererWidget::displayBandName( int band ) const
return name;
}

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

name = provider->generateBandName( band );

QString colorInterp = provider->colorInterpretationName( band );
if ( colorInterp != "Undefined" )
{
name.append( QString( " (%1)" ).arg( colorInterp ) );
}
return name;
}

0 comments on commit f87777e

Please sign in to comment.
You can’t perform that action at this time.