Skip to content

Commit

Permalink
Move creation of renderer classes out of drawing loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jan 8, 2012
1 parent 28313b6 commit 3c7cebe
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 118 deletions.
185 changes: 93 additions & 92 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -993,98 +993,6 @@ void QgsRasterLayerProperties::apply()
/*
* Symbology Tab
*/
//set the appropriate render style
if ( rbtnSingleBand->isChecked() )
{
//
// Grayscale
//
if ( mRasterLayer->rasterType() == QgsRasterLayer::GrayOrUndefined )
{

if ( cboxColorMap->currentText() != tr( "Grayscale" ) )
{
QgsDebugMsg( "Raster Drawing Style to :: SingleBandPseudoColor" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
}
else
{
QgsDebugMsg( "Setting Raster Drawing Style to :: SingleBandGray" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandGray );
}
}
//
// Paletted Image
//
else if ( mRasterLayer->rasterType() == QgsRasterLayer::Palette )
{
if ( cboxColorMap->currentText() == tr( "Grayscale" ) )
{
QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedSingleBandGray" );
QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" )
.arg( cboGray->currentText() ).arg( mRasterLayer->grayBandName() ) );

mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedSingleBandGray );
}
else if ( cboxColorMap->currentText() == tr( "Colormap" ) )
{
QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedColor" );
QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" ).arg( cboGray->currentText() ).arg( mRasterLayer->
grayBandName() ) );

mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedColor );
}
else
{
QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedSingleBandPseudoColor" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedSingleBandPseudoColor );
}

}
//
// Mutltiband
//
else if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
{
if ( cboxColorMap->currentText() != tr( "Grayscale" ) )
{
QgsDebugMsg( "Setting Raster Drawing Style to ::MultiBandSingleBandPseudoColor " );

mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandSingleBandPseudoColor );
}
else
{
QgsDebugMsg( "Setting Raster Drawing Style to :: MultiBandSingleBandGray" );
QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" ).arg( cboGray->currentText() ).arg( mRasterLayer->
grayBandName() ) );

mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandSingleBandGray );

}
}
} //end of grayscale box enabled and rbtnsingleband checked
else //assume that rbtnThreeBand is checked and render in rgb color
{
//set the grayscale color table type if the groupbox is enabled

if ( mRasterLayer->rasterType() == QgsRasterLayer::Palette )
{
QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedMultiBandColor" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedMultiBandColor );
}
else if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
{

QgsDebugMsg( "Setting Raster Drawing Style to :: MultiBandColor" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandColor );
}

}

//set whether the layer histogram should be inverted
mRasterLayer->setInvertHistogram( cboxInvertColorMap->isChecked() );
Expand Down Expand Up @@ -1476,6 +1384,99 @@ void QgsRasterLayerProperties::apply()
mRasterLayer->setResampler( new QgsCubicRasterResampler() );
}

//set the appropriate render style
if ( rbtnSingleBand->isChecked() )
{
//
// Grayscale
//
if ( mRasterLayer->rasterType() == QgsRasterLayer::GrayOrUndefined )
{

if ( cboxColorMap->currentText() != tr( "Grayscale" ) )
{
QgsDebugMsg( "Raster Drawing Style to :: SingleBandPseudoColor" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
}
else
{
QgsDebugMsg( "Setting Raster Drawing Style to :: SingleBandGray" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandGray );
}
}
//
// Paletted Image
//
else if ( mRasterLayer->rasterType() == QgsRasterLayer::Palette )
{
if ( cboxColorMap->currentText() == tr( "Grayscale" ) )
{
QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedSingleBandGray" );
QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" )
.arg( cboGray->currentText() ).arg( mRasterLayer->grayBandName() ) );

mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedSingleBandGray );
}
else if ( cboxColorMap->currentText() == tr( "Colormap" ) )
{
QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedColor" );
QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" ).arg( cboGray->currentText() ).arg( mRasterLayer->
grayBandName() ) );

mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedColor );
}
else
{
QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedSingleBandPseudoColor" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedSingleBandPseudoColor );
}

}
//
// Mutltiband
//
else if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
{
if ( cboxColorMap->currentText() != tr( "Grayscale" ) )
{
QgsDebugMsg( "Setting Raster Drawing Style to ::MultiBandSingleBandPseudoColor " );

mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandSingleBandPseudoColor );
}
else
{
QgsDebugMsg( "Setting Raster Drawing Style to :: MultiBandSingleBandGray" );
QgsDebugMsg( QString( "Combo value : %1 GrayBand Mapping : %2" ).arg( cboGray->currentText() ).arg( mRasterLayer->
grayBandName() ) );

mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandSingleBandGray );

}
}
} //end of grayscale box enabled and rbtnsingleband checked
else //assume that rbtnThreeBand is checked and render in rgb color
{
//set the grayscale color table type if the groupbox is enabled

if ( mRasterLayer->rasterType() == QgsRasterLayer::Palette )
{
QgsDebugMsg( "Setting Raster Drawing Style to :: PalettedMultiBandColor" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::PalettedMultiBandColor );
}
else if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
{

QgsDebugMsg( "Setting Raster Drawing Style to :: MultiBandColor" );

mRasterLayer->setDrawingStyle( QgsRasterLayer::MultiBandColor );
}
}
//set render style finished



//get the thumbnail for the layer
Expand Down

0 comments on commit 3c7cebe

Please sign in to comment.