Skip to content

Commit 9e14b8e

Browse files
committed
raster DrawingStyle to QgsRaster to avoid circular header include
1 parent 3233d05 commit 9e14b8e

File tree

9 files changed

+67
-65
lines changed

9 files changed

+67
-65
lines changed

python/core/raster/qgsraster.sip

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@ class QgsRaster
7070
ContrastEnhancementCumulativeCut
7171
};
7272

73+
/** \brief This enumerator describes the different kinds of drawing we can do */
74+
enum DrawingStyle
75+
{
76+
UndefinedDrawingStyle,
77+
SingleBandGray, // a single band image drawn as a range of gray colors
78+
SingleBandPseudoColor, // a single band image drawn using a pseudocolor algorithm
79+
PalettedColor, // a "Palette" image drawn using color table
80+
PalettedSingleBandGray, // a "Palette" layer drawn in gray scale
81+
PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
82+
PalettedMultiBandColor, // currently not supported
83+
MultiBandSingleBandGray, // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
84+
MultiBandSingleBandPseudoColor, // a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
85+
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.
86+
SingleBandColorDataStyle // ARGB values rendered directly
87+
};
88+
7389
static QString contrastEnhancementLimitsAsString( QgsRaster::ContrastEnhancementLimits theLimits );
7490
static ContrastEnhancementLimits contrastEnhancementLimitsFromString( QString theLimits );
7591

python/core/raster/qgsrasterlayer.sip

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,6 @@ class QgsRasterLayer : QgsMapLayer
6565
UserDefinedShader
6666
};
6767

68-
/** \brief This enumerator describes the different kinds of drawing we can do */
69-
enum DrawingStyle
70-
{
71-
UndefinedDrawingStyle,
72-
SingleBandGray, // a single band image drawn as a range of gray colors
73-
SingleBandPseudoColor, // a single band image drawn using a pseudocolor algorithm
74-
PalettedColor, // a "Palette" image drawn using color table
75-
PalettedSingleBandGray, // a "Palette" layer drawn in gray scale
76-
PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
77-
PalettedMultiBandColor, // currently not supported
78-
MultiBandSingleBandGray, // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
79-
MultiBandSingleBandPseudoColor, // a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
80-
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.
81-
SingleBandColorDataStyle // ARGB values rendered directly
82-
};
83-
8468
/** \brief This enumerator describes the type of raster layer */
8569
enum LayerType
8670
{

src/core/raster/qgsraster.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ class CORE_EXPORT QgsRaster
8989
ContrastEnhancementCumulativeCut
9090
};
9191

92+
/** \brief This enumerator describes the different kinds of drawing we can do */
93+
enum DrawingStyle
94+
{
95+
UndefinedDrawingStyle,
96+
SingleBandGray, // a single band image drawn as a range of gray colors
97+
SingleBandPseudoColor, // a single band image drawn using a pseudocolor algorithm
98+
PalettedColor, // a "Palette" image drawn using color table
99+
PalettedSingleBandGray, // a "Palette" layer drawn in gray scale
100+
PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
101+
PalettedMultiBandColor, // currently not supported
102+
MultiBandSingleBandGray, // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
103+
MultiBandSingleBandPseudoColor, // a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
104+
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.
105+
SingleBandColorDataStyle // ARGB values rendered directly
106+
};
107+
92108
static QString contrastEnhancementLimitsAsString( QgsRaster::ContrastEnhancementLimits theLimits );
93109
static ContrastEnhancementLimits contrastEnhancementLimitsFromString( QString theLimits );
94110

src/core/raster/qgsrasterlayer.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ const QString QgsRasterLayer::bandName( int theBandNo )
250250
return dataProvider()->generateBandName( theBandNo );
251251
}
252252

253-
void QgsRasterLayer::setRendererForDrawingStyle( const DrawingStyle & theDrawingStyle )
253+
void QgsRasterLayer::setRendererForDrawingStyle( const QgsRaster::DrawingStyle & theDrawingStyle )
254254
{
255255
setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( theDrawingStyle, mDataProvider ) );
256256
}
@@ -795,7 +795,7 @@ void QgsRasterLayer::init()
795795
{
796796
mRasterType = QgsRasterLayer::GrayOrUndefined;
797797

798-
setRendererForDrawingStyle( QgsRasterLayer::UndefinedDrawingStyle );
798+
setRendererForDrawingStyle( QgsRaster::UndefinedDrawingStyle );
799799

800800
//Initialize the last view port structure, should really be a class
801801
mLastViewPort.mWidth = 0;
@@ -902,16 +902,16 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
902902
QgsDebugMsg( "mRasterType = " + QString::number( mRasterType ) );
903903
if ( mRasterType == ColorLayer )
904904
{
905-
QgsDebugMsg( "Setting drawing style to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
906-
setRendererForDrawingStyle( SingleBandColorDataStyle );
905+
QgsDebugMsg( "Setting drawing style to SingleBandColorDataStyle " + QString::number( QgsRaster::SingleBandColorDataStyle ) );
906+
setRendererForDrawingStyle( QgsRaster::SingleBandColorDataStyle );
907907
}
908908
else if ( mRasterType == Palette && mDataProvider->colorInterpretation( 1 ) == QgsRaster::PaletteIndex )
909909
{
910-
setRendererForDrawingStyle( PalettedColor ); //sensible default
910+
setRendererForDrawingStyle( QgsRaster::PalettedColor ); //sensible default
911911
}
912912
else if ( mRasterType == Palette && mDataProvider->colorInterpretation( 1 ) == QgsRaster::ContinuousPalette )
913913
{
914-
setRendererForDrawingStyle( SingleBandPseudoColor );
914+
setRendererForDrawingStyle( QgsRaster::SingleBandPseudoColor );
915915
// Load color table
916916
QList<QgsColorRampShader::ColorRampItem> colorTable = mDataProvider->colorTable( 1 );
917917
QgsSingleBandPseudoColorRenderer* r = dynamic_cast<QgsSingleBandPseudoColorRenderer*>( renderer() );
@@ -928,11 +928,11 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
928928
}
929929
else if ( mRasterType == Multiband )
930930
{
931-
setRendererForDrawingStyle( MultiBandColor ); //sensible default
931+
setRendererForDrawingStyle( QgsRaster::MultiBandColor ); //sensible default
932932
}
933933
else //GrayOrUndefined
934934
{
935-
setRendererForDrawingStyle( SingleBandGray ); //sensible default
935+
setRendererForDrawingStyle( QgsRaster::SingleBandGray ); //sensible default
936936
}
937937

938938
// Auto set alpha band
@@ -1156,52 +1156,52 @@ void QgsRasterLayer::setDefaultContrastEnhancement()
11561156
void QgsRasterLayer::setDrawingStyle( QString const & theDrawingStyleQString )
11571157
{
11581158
QgsDebugMsg( "DrawingStyle = " + theDrawingStyleQString );
1159-
DrawingStyle drawingStyle;
1159+
QgsRaster::DrawingStyle drawingStyle;
11601160
if ( theDrawingStyleQString == "SingleBandGray" )//no need to tr() this its not shown in ui
11611161
{
1162-
drawingStyle = SingleBandGray;
1162+
drawingStyle = QgsRaster::SingleBandGray;
11631163
}
11641164
else if ( theDrawingStyleQString == "SingleBandPseudoColor" )//no need to tr() this its not shown in ui
11651165
{
1166-
drawingStyle = SingleBandPseudoColor;
1166+
drawingStyle = QgsRaster::SingleBandPseudoColor;
11671167
}
11681168
else if ( theDrawingStyleQString == "PalettedColor" )//no need to tr() this its not shown in ui
11691169
{
1170-
drawingStyle = PalettedColor;
1170+
drawingStyle = QgsRaster::PalettedColor;
11711171
}
11721172
else if ( theDrawingStyleQString == "PalettedSingleBandGray" )//no need to tr() this its not shown in ui
11731173
{
1174-
drawingStyle = PalettedSingleBandGray;
1174+
drawingStyle = QgsRaster::PalettedSingleBandGray;
11751175
}
11761176
else if ( theDrawingStyleQString == "PalettedSingleBandPseudoColor" )//no need to tr() this its not shown in ui
11771177
{
1178-
drawingStyle = PalettedSingleBandPseudoColor;
1178+
drawingStyle = QgsRaster::PalettedSingleBandPseudoColor;
11791179
}
11801180
else if ( theDrawingStyleQString == "PalettedMultiBandColor" )//no need to tr() this its not shown in ui
11811181
{
1182-
drawingStyle = PalettedMultiBandColor;
1182+
drawingStyle = QgsRaster::PalettedMultiBandColor;
11831183
}
11841184
else if ( theDrawingStyleQString == "MultiBandSingleBandGray" )//no need to tr() this its not shown in ui
11851185
{
1186-
drawingStyle = MultiBandSingleBandGray;
1186+
drawingStyle = QgsRaster::MultiBandSingleBandGray;
11871187
}
11881188
else if ( theDrawingStyleQString == "MultiBandSingleBandPseudoColor" )//no need to tr() this its not shown in ui
11891189
{
1190-
drawingStyle = MultiBandSingleBandPseudoColor;
1190+
drawingStyle = QgsRaster::MultiBandSingleBandPseudoColor;
11911191
}
11921192
else if ( theDrawingStyleQString == "MultiBandColor" )//no need to tr() this its not shown in ui
11931193
{
1194-
drawingStyle = MultiBandColor;
1194+
drawingStyle = QgsRaster::MultiBandColor;
11951195
}
11961196
else if ( theDrawingStyleQString == "SingleBandColorDataStyle" )//no need to tr() this its not shown in ui
11971197
{
1198-
QgsDebugMsg( "Setting drawingStyle to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
1199-
drawingStyle = SingleBandColorDataStyle;
1198+
QgsDebugMsg( "Setting drawingStyle to SingleBandColorDataStyle " + QString::number( QgsRaster::SingleBandColorDataStyle ) );
1199+
drawingStyle = QgsRaster::SingleBandColorDataStyle;
12001200
QgsDebugMsg( "Setted drawingStyle to " + QString::number( drawingStyle ) );
12011201
}
12021202
else
12031203
{
1204-
drawingStyle = UndefinedDrawingStyle;
1204+
drawingStyle = QgsRaster::UndefinedDrawingStyle;
12051205
}
12061206
setRendererForDrawingStyle( drawingStyle );
12071207
}
@@ -1499,7 +1499,7 @@ bool QgsRasterLayer::readXml( const QDomNode& layer_node )
14991499
// old wms settings we need to correct
15001500
if ( res && mProviderKey == "wms" && ( !renderer() || renderer()->type() != "singlebandcolordata" ) )
15011501
{
1502-
setRendererForDrawingStyle( SingleBandColorDataStyle );
1502+
setRendererForDrawingStyle( QgsRaster::SingleBandColorDataStyle );
15031503
}
15041504

15051505
// Check timestamp

src/core/raster/qgsrasterlayer.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,6 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
219219
UserDefinedShader
220220
};
221221

222-
/** \brief This enumerator describes the different kinds of drawing we can do */
223-
enum DrawingStyle
224-
{
225-
UndefinedDrawingStyle,
226-
SingleBandGray, // a single band image drawn as a range of gray colors
227-
SingleBandPseudoColor, // a single band image drawn using a pseudocolor algorithm
228-
PalettedColor, // a "Palette" image drawn using color table
229-
PalettedSingleBandGray, // a "Palette" layer drawn in gray scale
230-
PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
231-
PalettedMultiBandColor, // currently not supported
232-
MultiBandSingleBandGray, // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
233-
MultiBandSingleBandPseudoColor, // a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
234-
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.
235-
SingleBandColorDataStyle // ARGB values rendered directly
236-
};
237-
238222
/** \brief This enumerator describes the type of raster layer */
239223
enum LayerType
240224
{
@@ -431,7 +415,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
431415
bool update();
432416

433417
/**Sets corresponding renderer for style*/
434-
void setRendererForDrawingStyle( const DrawingStyle & theDrawingStyle );
418+
void setRendererForDrawingStyle( const QgsRaster::DrawingStyle & theDrawingStyle );
435419

436420
/** \brief Constant defining flag for XML and a constant that signals property not used */
437421
const QString QSTRING_NOT_SET;

src/core/raster/qgsrasterrendererregistry.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ QList< QgsRasterRendererRegistryEntry > QgsRasterRendererRegistry::entries() con
107107
return result;
108108
}
109109

110-
QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( const QgsRasterLayer::DrawingStyle& theDrawingStyle, QgsRasterDataProvider* provider ) const
110+
QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( const QgsRaster::DrawingStyle& theDrawingStyle, QgsRasterDataProvider* provider ) const
111111
{
112112
if ( !provider || provider->bandCount() < 1 )
113113
{
@@ -118,7 +118,7 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
118118
QgsRasterRenderer* renderer = 0;
119119
switch ( theDrawingStyle )
120120
{
121-
case QgsRasterLayer::PalettedColor:
121+
case QgsRaster::PalettedColor:
122122
{
123123
int grayBand = 1; //reasonable default
124124
QList<QgsColorRampShader::ColorRampItem> colorEntries = provider->colorTable( grayBand );
@@ -148,8 +148,8 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
148148
colorArraySize );
149149
}
150150
break;
151-
case QgsRasterLayer::MultiBandSingleBandGray:
152-
case QgsRasterLayer::SingleBandGray:
151+
case QgsRaster::MultiBandSingleBandGray:
152+
case QgsRaster::SingleBandGray:
153153
{
154154
int grayBand = 1;
155155
renderer = new QgsSingleBandGrayRenderer( provider, grayBand );
@@ -161,7 +161,7 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
161161
(( QgsSingleBandGrayRenderer* )renderer )->setContrastEnhancement( ce );
162162
break;
163163
}
164-
case QgsRasterLayer::SingleBandPseudoColor:
164+
case QgsRaster::SingleBandPseudoColor:
165165
{
166166
int bandNo = 1;
167167
double minValue = 0;
@@ -172,7 +172,7 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
172172
renderer = new QgsSingleBandPseudoColorRenderer( provider, bandNo, shader );
173173
break;
174174
}
175-
case QgsRasterLayer::MultiBandColor:
175+
case QgsRaster::MultiBandColor:
176176
{
177177
QSettings s;
178178

@@ -195,7 +195,7 @@ QgsRasterRenderer* QgsRasterRendererRegistry::defaultRendererForDrawingStyle( co
195195
renderer = new QgsMultiBandColorRenderer( provider, redBand, greenBand, blueBand );
196196
break;
197197
}
198-
case QgsRasterLayer::SingleBandColorDataStyle:
198+
case QgsRaster::SingleBandColorDataStyle:
199199
{
200200
renderer = new QgsSingleBandColorDataRenderer( provider, 1 );
201201
break;

src/core/raster/qgsrasterrendererregistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class CORE_EXPORT QgsRasterRendererRegistry
6262

6363
/**Creates a default renderer for a raster drawing style (considering user options such as default contrast enhancement).
6464
Caller takes ownership*/
65-
QgsRasterRenderer* defaultRendererForDrawingStyle( const QgsRasterLayer::DrawingStyle& theDrawingStyle, QgsRasterDataProvider* provider ) const;
65+
QgsRasterRenderer* defaultRendererForDrawingStyle( const QgsRaster::DrawingStyle& theDrawingStyle, QgsRasterDataProvider* provider ) const;
6666

6767
protected:
6868
QgsRasterRendererRegistry();

src/mapserver/qgsmslayerbuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
***************************************************************************/
1717

1818
#include "qgsmslayerbuilder.h"
19+
#include "qgsraster.h"
1920
#include "qgsrasterlayer.h"
2021
#include "qgsrasterrendererregistry.h"
2122

@@ -94,7 +95,7 @@ void QgsMSLayerBuilder::clearRasterSymbology( QgsRasterLayer* rl ) const
9495
if ( rl->rasterType() == QgsRasterLayer::GrayOrUndefined )
9596
{
9697
//rl->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
97-
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRasterLayer::SingleBandPseudoColor, rl->dataProvider() ) );
98+
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRaster::SingleBandPseudoColor, rl->dataProvider() ) );
9899
}
99100
}
100101
}

src/mapserver/qgssldparser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "qgslogger.h"
3131
#include "qgsmslayercache.h"
3232
#include "qgsmsutils.h"
33+
#include "qgsraster.h"
3334
#include "qgsrasterlayer.h"
3435
#include "qgsrasterrendererregistry.h"
3536
#include "qgscolorrampshader.h"
@@ -1498,7 +1499,7 @@ void QgsSLDParser::clearRasterSymbology( QgsRasterLayer* rl ) const
14981499
if ( rl->rasterType() == QgsRasterLayer::GrayOrUndefined )
14991500
{
15001501
//rl->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
1501-
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRasterLayer::SingleBandPseudoColor, rl->dataProvider() ) );
1502+
rl->setRenderer( QgsRasterRendererRegistry::instance()->defaultRendererForDrawingStyle( QgsRaster::SingleBandPseudoColor, rl->dataProvider() ) );
15021503
}
15031504
}
15041505
}

0 commit comments

Comments
 (0)