raster DrawingStyle to QgsRaster to avoid circular header include

This commit is contained in:
Radim Blazek 2013-06-12 10:50:06 +02:00
parent 3233d05f92
commit 9e14b8eef0
9 changed files with 67 additions and 65 deletions

View File

@ -70,6 +70,22 @@ class QgsRaster
ContrastEnhancementCumulativeCut
};
/** \brief This enumerator describes the different kinds of drawing we can do */
enum DrawingStyle
{
UndefinedDrawingStyle,
SingleBandGray, // a single band image drawn as a range of gray colors
SingleBandPseudoColor, // a single band image drawn using a pseudocolor algorithm
PalettedColor, // a "Palette" image drawn using color table
PalettedSingleBandGray, // a "Palette" layer drawn in gray scale
PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
PalettedMultiBandColor, // currently not supported
MultiBandSingleBandGray, // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
MultiBandSingleBandPseudoColor, // a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
MultiBandColor, // a layer containing 2 or more bands, mapped to RGB color space. In the case of a multiband with only two bands, one band will be mapped to more than one color.
SingleBandColorDataStyle // ARGB values rendered directly
};
static QString contrastEnhancementLimitsAsString( QgsRaster::ContrastEnhancementLimits theLimits );
static ContrastEnhancementLimits contrastEnhancementLimitsFromString( QString theLimits );

View File

@ -65,22 +65,6 @@ class QgsRasterLayer : QgsMapLayer
UserDefinedShader
};
/** \brief This enumerator describes the different kinds of drawing we can do */
enum DrawingStyle
{
UndefinedDrawingStyle,
SingleBandGray, // a single band image drawn as a range of gray colors
SingleBandPseudoColor, // a single band image drawn using a pseudocolor algorithm
PalettedColor, // a "Palette" image drawn using color table
PalettedSingleBandGray, // a "Palette" layer drawn in gray scale
PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
PalettedMultiBandColor, // currently not supported
MultiBandSingleBandGray, // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
MultiBandSingleBandPseudoColor, // a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
MultiBandColor, // a layer containing 2 or more bands, mapped to RGB color space. In the case of a multiband with only two bands, one band will be mapped to more than one color.
SingleBandColorDataStyle // ARGB values rendered directly
};
/** \brief This enumerator describes the type of raster layer */
enum LayerType
{

View File

@ -89,6 +89,22 @@ class CORE_EXPORT QgsRaster
ContrastEnhancementCumulativeCut
};
/** \brief This enumerator describes the different kinds of drawing we can do */
enum DrawingStyle
{
UndefinedDrawingStyle,
SingleBandGray, // a single band image drawn as a range of gray colors
SingleBandPseudoColor, // a single band image drawn using a pseudocolor algorithm
PalettedColor, // a "Palette" image drawn using color table
PalettedSingleBandGray, // a "Palette" layer drawn in gray scale
PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
PalettedMultiBandColor, // currently not supported
MultiBandSingleBandGray, // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
MultiBandSingleBandPseudoColor, // a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
MultiBandColor, // a layer containing 2 or more bands, mapped to RGB color space. In the case of a multiband with only two bands, one band will be mapped to more than one color.
SingleBandColorDataStyle // ARGB values rendered directly
};
static QString contrastEnhancementLimitsAsString( QgsRaster::ContrastEnhancementLimits theLimits );
static ContrastEnhancementLimits contrastEnhancementLimitsFromString( QString theLimits );

View File

@ -250,7 +250,7 @@ const QString QgsRasterLayer::bandName( int theBandNo )
return dataProvider()->generateBandName( theBandNo );
}
void QgsRasterLayer::setRendererForDrawingStyle( const DrawingStyle & theDrawingStyle )
void QgsRasterLayer::setRendererForDrawingStyle( const QgsRaster::DrawingStyle & theDrawingStyle )
{
setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( theDrawingStyle, mDataProvider ) );
}
@ -795,7 +795,7 @@ void QgsRasterLayer::init()
{
mRasterType = QgsRasterLayer::GrayOrUndefined;
setRendererForDrawingStyle( QgsRasterLayer::UndefinedDrawingStyle );
setRendererForDrawingStyle( QgsRaster::UndefinedDrawingStyle );
//Initialize the last view port structure, should really be a class
mLastViewPort.mWidth = 0;
@ -902,16 +902,16 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
QgsDebugMsg( "mRasterType = " + QString::number( mRasterType ) );
if ( mRasterType == ColorLayer )
{
QgsDebugMsg( "Setting drawing style to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
setRendererForDrawingStyle( SingleBandColorDataStyle );
QgsDebugMsg( "Setting drawing style to SingleBandColorDataStyle " + QString::number( QgsRaster::SingleBandColorDataStyle ) );
setRendererForDrawingStyle( QgsRaster::SingleBandColorDataStyle );
}
else if ( mRasterType == Palette && mDataProvider->colorInterpretation( 1 ) == QgsRaster::PaletteIndex )
{
setRendererForDrawingStyle( PalettedColor ); //sensible default
setRendererForDrawingStyle( QgsRaster::PalettedColor ); //sensible default
}
else if ( mRasterType == Palette && mDataProvider->colorInterpretation( 1 ) == QgsRaster::ContinuousPalette )
{
setRendererForDrawingStyle( SingleBandPseudoColor );
setRendererForDrawingStyle( QgsRaster::SingleBandPseudoColor );
// Load color table
QList<QgsColorRampShader::ColorRampItem> colorTable = mDataProvider->colorTable( 1 );
QgsSingleBandPseudoColorRenderer* r = dynamic_cast<QgsSingleBandPseudoColorRenderer*>( renderer() );
@ -928,11 +928,11 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
}
else if ( mRasterType == Multiband )
{
setRendererForDrawingStyle( MultiBandColor ); //sensible default
setRendererForDrawingStyle( QgsRaster::MultiBandColor ); //sensible default
}
else //GrayOrUndefined
{
setRendererForDrawingStyle( SingleBandGray ); //sensible default
setRendererForDrawingStyle( QgsRaster::SingleBandGray ); //sensible default
}
// Auto set alpha band
@ -1156,52 +1156,52 @@ void QgsRasterLayer::setDefaultContrastEnhancement()
void QgsRasterLayer::setDrawingStyle( QString const & theDrawingStyleQString )
{
QgsDebugMsg( "DrawingStyle = " + theDrawingStyleQString );
DrawingStyle drawingStyle;
QgsRaster::DrawingStyle drawingStyle;
if ( theDrawingStyleQString == "SingleBandGray" )//no need to tr() this its not shown in ui
{
drawingStyle = SingleBandGray;
drawingStyle = QgsRaster::SingleBandGray;
}
else if ( theDrawingStyleQString == "SingleBandPseudoColor" )//no need to tr() this its not shown in ui
{
drawingStyle = SingleBandPseudoColor;
drawingStyle = QgsRaster::SingleBandPseudoColor;
}
else if ( theDrawingStyleQString == "PalettedColor" )//no need to tr() this its not shown in ui
{
drawingStyle = PalettedColor;
drawingStyle = QgsRaster::PalettedColor;
}
else if ( theDrawingStyleQString == "PalettedSingleBandGray" )//no need to tr() this its not shown in ui
{
drawingStyle = PalettedSingleBandGray;
drawingStyle = QgsRaster::PalettedSingleBandGray;
}
else if ( theDrawingStyleQString == "PalettedSingleBandPseudoColor" )//no need to tr() this its not shown in ui
{
drawingStyle = PalettedSingleBandPseudoColor;
drawingStyle = QgsRaster::PalettedSingleBandPseudoColor;
}
else if ( theDrawingStyleQString == "PalettedMultiBandColor" )//no need to tr() this its not shown in ui
{
drawingStyle = PalettedMultiBandColor;
drawingStyle = QgsRaster::PalettedMultiBandColor;
}
else if ( theDrawingStyleQString == "MultiBandSingleBandGray" )//no need to tr() this its not shown in ui
{
drawingStyle = MultiBandSingleBandGray;
drawingStyle = QgsRaster::MultiBandSingleBandGray;
}
else if ( theDrawingStyleQString == "MultiBandSingleBandPseudoColor" )//no need to tr() this its not shown in ui
{
drawingStyle = MultiBandSingleBandPseudoColor;
drawingStyle = QgsRaster::MultiBandSingleBandPseudoColor;
}
else if ( theDrawingStyleQString == "MultiBandColor" )//no need to tr() this its not shown in ui
{
drawingStyle = MultiBandColor;
drawingStyle = QgsRaster::MultiBandColor;
}
else if ( theDrawingStyleQString == "SingleBandColorDataStyle" )//no need to tr() this its not shown in ui
{
QgsDebugMsg( "Setting drawingStyle to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
drawingStyle = SingleBandColorDataStyle;
QgsDebugMsg( "Setting drawingStyle to SingleBandColorDataStyle " + QString::number( QgsRaster::SingleBandColorDataStyle ) );
drawingStyle = QgsRaster::SingleBandColorDataStyle;
QgsDebugMsg( "Setted drawingStyle to " + QString::number( drawingStyle ) );
}
else
{
drawingStyle = UndefinedDrawingStyle;
drawingStyle = QgsRaster::UndefinedDrawingStyle;
}
setRendererForDrawingStyle( drawingStyle );
}
@ -1499,7 +1499,7 @@ bool QgsRasterLayer::readXml( const QDomNode& layer_node )
// old wms settings we need to correct
if ( res && mProviderKey == "wms" && ( !renderer() || renderer()->type() != "singlebandcolordata" ) )
{
setRendererForDrawingStyle( SingleBandColorDataStyle );
setRendererForDrawingStyle( QgsRaster::SingleBandColorDataStyle );
}
// Check timestamp

View File

@ -219,22 +219,6 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
UserDefinedShader
};
/** \brief This enumerator describes the different kinds of drawing we can do */
enum DrawingStyle
{
UndefinedDrawingStyle,
SingleBandGray, // a single band image drawn as a range of gray colors
SingleBandPseudoColor, // a single band image drawn using a pseudocolor algorithm
PalettedColor, // a "Palette" image drawn using color table
PalettedSingleBandGray, // a "Palette" layer drawn in gray scale
PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
PalettedMultiBandColor, // currently not supported
MultiBandSingleBandGray, // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
MultiBandSingleBandPseudoColor, // a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
MultiBandColor, // a layer containing 2 or more bands, mapped to RGB color space. In the case of a multiband with only two bands, one band will be mapped to more than one color.
SingleBandColorDataStyle // ARGB values rendered directly
};
/** \brief This enumerator describes the type of raster layer */
enum LayerType
{
@ -431,7 +415,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
bool update();
/**Sets corresponding renderer for style*/
void setRendererForDrawingStyle( const DrawingStyle & theDrawingStyle );
void setRendererForDrawingStyle( const QgsRaster::DrawingStyle & theDrawingStyle );
/** \brief Constant defining flag for XML and a constant that signals property not used */
const QString QSTRING_NOT_SET;

View File

@ -107,7 +107,7 @@ QList< QgsRasterRendererRegistryEntry > QgsRasterRendererRegistry::entries() con
return result;
}
QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( const QgsRasterLayer::DrawingStyle& theDrawingStyle, QgsRasterDataProvider* provider ) const
QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( const QgsRaster::DrawingStyle& theDrawingStyle, QgsRasterDataProvider* provider ) const
{
if ( !provider || provider->bandCount() < 1 )
{
@ -118,7 +118,7 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
QgsRasterRenderer* renderer = 0;
switch ( theDrawingStyle )
{
case QgsRasterLayer::PalettedColor:
case QgsRaster::PalettedColor:
{
int grayBand = 1; //reasonable default
QList<QgsColorRampShader::ColorRampItem> colorEntries = provider->colorTable( grayBand );
@ -148,8 +148,8 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
colorArraySize );
}
break;
case QgsRasterLayer::MultiBandSingleBandGray:
case QgsRasterLayer::SingleBandGray:
case QgsRaster::MultiBandSingleBandGray:
case QgsRaster::SingleBandGray:
{
int grayBand = 1;
renderer = new QgsSingleBandGrayRenderer( provider, grayBand );
@ -161,7 +161,7 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
(( QgsSingleBandGrayRenderer* )renderer )->setContrastEnhancement( ce );
break;
}
case QgsRasterLayer::SingleBandPseudoColor:
case QgsRaster::SingleBandPseudoColor:
{
int bandNo = 1;
double minValue = 0;
@ -172,7 +172,7 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
renderer = new QgsSingleBandPseudoColorRenderer( provider, bandNo, shader );
break;
}
case QgsRasterLayer::MultiBandColor:
case QgsRaster::MultiBandColor:
{
QSettings s;
@ -195,7 +195,7 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
renderer = new QgsMultiBandColorRenderer( provider, redBand, greenBand, blueBand );
break;
}
case QgsRasterLayer::SingleBandColorDataStyle:
case QgsRaster::SingleBandColorDataStyle:
{
renderer = new QgsSingleBandColorDataRenderer( provider, 1 );
break;

View File

@ -62,7 +62,7 @@ class CORE_EXPORT QgsRasterRendererRegistry
/**Creates a default renderer for a raster drawing style (considering user options such as default contrast enhancement).
Caller takes ownership*/
QgsRasterRenderer* defaultRendererForDrawingStyle( const QgsRasterLayer::DrawingStyle& theDrawingStyle, QgsRasterDataProvider* provider ) const;
QgsRasterRenderer* defaultRendererForDrawingStyle( const QgsRaster::DrawingStyle& theDrawingStyle, QgsRasterDataProvider* provider ) const;
protected:
QgsRasterRendererRegistry();

View File

@ -16,6 +16,7 @@
***************************************************************************/
#include "qgsmslayerbuilder.h"
#include "qgsraster.h"
#include "qgsrasterlayer.h"
#include "qgsrasterrendererregistry.h"
@ -94,7 +95,7 @@ void QgsMSLayerBuilder::clearRasterSymbology( QgsRasterLayer* rl ) const
if ( rl->rasterType() == QgsRasterLayer::GrayOrUndefined )
{
//rl->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRasterLayer::SingleBandPseudoColor, rl->dataProvider() ) );
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRaster::SingleBandPseudoColor, rl->dataProvider() ) );
}
}
}

View File

@ -30,6 +30,7 @@
#include "qgslogger.h"
#include "qgsmslayercache.h"
#include "qgsmsutils.h"
#include "qgsraster.h"
#include "qgsrasterlayer.h"
#include "qgsrasterrendererregistry.h"
#include "qgscolorrampshader.h"
@ -1498,7 +1499,7 @@ void QgsSLDParser::clearRasterSymbology( QgsRasterLayer* rl ) const
if ( rl->rasterType() == QgsRasterLayer::GrayOrUndefined )
{
//rl->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRasterLayer::SingleBandPseudoColor, rl->dataProvider() ) );
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRaster::SingleBandPseudoColor, rl->dataProvider() ) );
}
}
}