Skip to content

Commit

Permalink
raster DrawingStyle to QgsRaster to avoid circular header include
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Jun 12, 2013
1 parent 3233d05 commit 9e14b8e
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 65 deletions.
16 changes: 16 additions & 0 deletions python/core/raster/qgsraster.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
16 changes: 0 additions & 16 deletions python/core/raster/qgsrasterlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
16 changes: 16 additions & 0 deletions src/core/raster/qgsraster.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
44 changes: 22 additions & 22 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() );
Expand All @@ -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
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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
Expand Down
18 changes: 1 addition & 17 deletions src/core/raster/qgsrasterlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/core/raster/qgsrasterrendererregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
Expand All @@ -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;
Expand All @@ -172,7 +172,7 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
renderer = new QgsSingleBandPseudoColorRenderer( provider, bandNo, shader );
break;
}
case QgsRasterLayer::MultiBandColor:
case QgsRaster::MultiBandColor:
{
QSettings s;

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterrendererregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/mapserver/qgsmslayerbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

#include "qgsmslayerbuilder.h"
#include "qgsraster.h"
#include "qgsrasterlayer.h"
#include "qgsrasterrendererregistry.h"

Expand Down Expand Up @@ -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() ) );
}
}
}
3 changes: 2 additions & 1 deletion src/mapserver/qgssldparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() ) );
}
}
}
Expand Down

0 comments on commit 9e14b8e

Please sign in to comment.