Skip to content

Commit

Permalink
make band names consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jul 15, 2012
1 parent 87bdff9 commit f87777e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
22 changes: 9 additions & 13 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -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 );
Expand Down
13 changes: 5 additions & 8 deletions src/gui/raster/qgsrasterrendererwidget.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit f87777e

Please sign in to comment.