Skip to content

Commit f46b458

Browse files
author
ersts
committedNov 5, 2008
-Major API changes applied to be consistent with the core
-Should only be minor updates if any to the raster classes from here on out git-svn-id: http://svn.osgeo.org/qgis/trunk@9564 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b0a539a commit f46b458

13 files changed

+5180
-5291
lines changed
 

‎python/core/qgscontrastenhancement.sip

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ class QgsContrastEnhancement
88
public:
99

1010
/** \brief This enumerator describes the types of contrast enhancement algorithms that can be used. */
11-
enum CONTRAST_ENHANCEMENT_ALGORITHM
11+
enum ContrastEnhancementAlgorithm
1212
{
13-
NO_STRETCH, //this should be the default color scaling algorithm
14-
STRETCH_TO_MINMAX, //linear histogram enhanceContrast
15-
STRETCH_AND_CLIP_TO_MINMAX,
16-
CLIP_TO_MINMAX,
17-
USER_DEFINED
13+
NoEnhancement, //this should be the default color scaling algorithm
14+
StretchToMinimumMaximum, //linear histogram enhanceContrast
15+
StretchAndClipToMinimumMaximum,
16+
ClipToMinimumMaximum,
17+
UserDefined
1818
};
1919

2020
/*! These are exactly the same as GDAL pixel data types */
@@ -58,7 +58,7 @@ public:
5858
/** \brief Return the minimum value for the contrast enhancement range. */
5959
double minimumValue();
6060

61-
CONTRAST_ENHANCEMENT_ALGORITHM getContrastEnhancementAlgorithm();
61+
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm();
6262

6363
/*
6464
*
@@ -68,7 +68,7 @@ public:
6868
/** \brief Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped) */
6969
bool isValueInDisplayableRange(double);
7070
/** \brief Set the contrast enhancement algorithm */
71-
void setContrastEnhancementAlgorithm(CONTRAST_ENHANCEMENT_ALGORITHM, bool generateTable=true);
71+
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm, bool generateTable=true);
7272
/** \brief A public method that allows the user to set their own custom contrast enhancment function */
7373
void setContrastEnhancementFunction(QgsContrastEnhancementFunction*);
7474
/** \brief Set the maximum value for the contrast enhancement range. */

‎python/core/qgsrasterlayer.sip

Lines changed: 390 additions & 461 deletions
Large diffs are not rendered by default.

‎src/app/legend/qgslegendlayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void QgsLegendLayer::vectorLayerSymbology( const QgsVectorLayer* layer, double w
391391
void QgsLegendLayer::rasterLayerSymbology( QgsRasterLayer* layer )
392392
{
393393
SymbologyList itemList;
394-
QPixmap legendpixmap = layer->getLegendQPixmap( true ).scaled( 20, 20, Qt::KeepAspectRatio );
394+
QPixmap legendpixmap = layer->legendAsPixmap( true ).scaled( 20, 20, Qt::KeepAspectRatio );
395395
itemList.push_back( std::make_pair( "", legendpixmap ) );
396396

397397
changeSymbologySettings( layer, itemList );
@@ -458,7 +458,7 @@ QPixmap QgsLegendLayer::getOriginalPixmap() const
458458
{
459459
QgsRasterLayer* rlayer = dynamic_cast<QgsRasterLayer*>( firstLayer );
460460
QPixmap myPixmap( 32, 32 );
461-
rlayer->drawThumbnail( &myPixmap );
461+
rlayer->thumbnailAsPixmap( &myPixmap );
462462
return myPixmap;
463463
}
464464
}

‎src/app/qgsrasterlayerproperties.cpp

Lines changed: 229 additions & 229 deletions
Large diffs are not rendered by default.

‎src/app/qgsrasterlayerproperties.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
158158
bool ignoreSpinBoxEvent;
159159

160160
/** \brief Flag to indicate if Gray minimum maximum values are actual minimum maximum values */
161-
bool mGrayActualMinimumMaximum;
161+
bool mGrayMinimumMaximumEstimated;
162162

163163
/** \brief Flag to indicate if RGB minimum maximum values are actual minimum maximum values */
164-
bool mRGBActualMinimumMaximum;
164+
bool mRGBMinimumMaximumEstimated;
165165

166166
/** \brief Pointer to the raster layer that this property dilog changes the behaviour of. */
167167
QgsRasterLayer * mRasterLayer;

‎src/core/composer/qgslegendmodel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int QgsLegendModel::addRasterLayerItem( QStandardItem* layerItem, QgsMapLayer* r
158158
return 2;
159159
}
160160

161-
QStandardItem* currentSymbolItem = new QStandardItem( QIcon( rasterLayer->getLegendQPixmap( true ) ), "" );
161+
QStandardItem* currentSymbolItem = new QStandardItem( QIcon( rasterLayer->legendAsPixmap( true ) ), "" );
162162

163163
int currentRowCount = layerItem->rowCount();
164164
layerItem->setChild( currentRowCount, 0, currentSymbolItem );
@@ -363,7 +363,7 @@ void QgsLegendModel::updateRasterClassificationItem( QStandardItem* classificati
363363
return;
364364
}
365365

366-
QStandardItem* currentSymbolItem = new QStandardItem( QIcon( rl->getLegendQPixmap( true ) ), "" );
366+
QStandardItem* currentSymbolItem = new QStandardItem( QIcon( rl->legendAsPixmap( true ) ), "" );
367367
parentItem->insertRow( 0, currentSymbolItem );
368368
parentItem->removeRow( 1 );
369369
}
@@ -585,7 +585,7 @@ bool QgsLegendModel::readXML( const QDomElement& legendModelElem, const QDomDocu
585585
QgsRasterLayer* rasterLayer = dynamic_cast<QgsRasterLayer*>( currentLayer );
586586
if ( rasterLayer )
587587
{
588-
childItem->setIcon( QIcon( rasterLayer->getLegendQPixmap( true ) ) );
588+
childItem->setIcon( QIcon( rasterLayer->legendAsPixmap( true ) ) );
589589
}
590590
layerItem->setChild( layerItem->rowCount(), 0, childItem );
591591
}

‎src/core/raster/qgscolorrampshader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ bool QgsColorRampShader::interpolatedColor( double theValue, int* theReturnRedVa
198198
return false;
199199
}
200200

201-
void QgsColorRampShader::setColorRampType( QgsColorRampShader::COLOR_RAMP_TYPE theColorRampType )
201+
void QgsColorRampShader::setColorRampType( QgsColorRampShader::ColorRamp_TYPE theColorRampType )
202202
{
203203
//When the ramp type changes we need to clear out the cache
204204
mColorCache.clear();

‎src/core/raster/qgscolorrampshader.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
4646
QColor color;
4747
};
4848

49-
enum COLOR_RAMP_TYPE
49+
enum ColorRamp_TYPE
5050
{
5151
INTERPOLATED,
5252
DISCRETE,
@@ -57,7 +57,7 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
5757
QList<QgsColorRampShader::ColorRampItem> colorRampItemList() const {return mColorRampItemList;}
5858

5959
/** \brief Get the color ramp type */
60-
QgsColorRampShader::COLOR_RAMP_TYPE colorRampType() {return mColorRampType;}
60+
QgsColorRampShader::ColorRamp_TYPE colorRampType() {return mColorRampType;}
6161

6262
/** \brief Get the color ramp type as a string */
6363
QString colorRampTypeAsQString();
@@ -69,7 +69,7 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
6969
void setColorRampItemList( const QList<QgsColorRampShader::ColorRampItem>& theList ) { mColorRampItemList = theList; } //TODO: sort on set
7070

7171
/** \brief Set the color ramp type*/
72-
void setColorRampType( QgsColorRampShader::COLOR_RAMP_TYPE theColorRampType );
72+
void setColorRampType( QgsColorRampShader::ColorRamp_TYPE theColorRampType );
7373

7474
/** \brief Set the color ramp type*/
7575
void setColorRampType( QString );
@@ -87,11 +87,12 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
8787
/** Current index from which to start searching the color table*/
8888
int mCurrentColorRampItemIndex;
8989

90+
//TODO: Consider pulling this out as a separate class and internally storing as a QMap rather than a QList
9091
/** This vector holds the information for classification based on values. Each item holds a value, a label and a color. The member mDiscreteClassification holds if one color is applied for all values between two class breaks (true) or if the item values are (linearly) interpolated for values between the item values (false)*/
9192
QList<QgsColorRampShader::ColorRampItem> mColorRampItemList;
9293

9394
/** \brief The color ramp type */
94-
QgsColorRampShader::COLOR_RAMP_TYPE mColorRampType;
95+
QgsColorRampShader::ColorRamp_TYPE mColorRampType;
9596

9697
/** \brief Cache of values that have already been looked up */
9798
QMap<double, QColor> mColorCache;
@@ -103,8 +104,10 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
103104

104105
/** Gets the color for a pixel value from the classification vector mValueClassification. Assigns the color of the lower class for every pixel between two class breaks.*/
105106
bool discreteColor( double, int*, int*, int* );
107+
106108
/** Gets the color for a pixel value from the classification vector mValueClassification. Assigns the color of the exact matching value in the color ramp item list */
107109
bool exactColor( double, int*, int*, int* );
110+
108111
/** Gets the color for a pixel value from the classification vector mValueClassification. Interpolates the color between two class breaks linearly.*/
109112
bool interpolatedColor( double, int*, int*, int* );
110113
};

‎src/core/raster/qgscontrastenhancement.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ QgsContrastEnhancement::QgsContrastEnhancement( QgsRasterDataType theDataType )
3131
mLookupTable = 0;
3232
mContrastEnhancementFunction = 0;
3333
mEnhancementDirty = false;
34-
mContrastEnhancementAlgorithm = NO_STRETCH;
34+
mContrastEnhancementAlgorithm = NoEnhancement;
3535
mRasterDataType = theDataType;
3636

3737
mMinimumValue = minimumValuePossible( mRasterDataType );
@@ -173,13 +173,13 @@ int QgsContrastEnhancement::enhanceContrast( double theValue )
173173
generateLookupTable();
174174
}
175175

176-
if ( mLookupTable && NO_STRETCH != mContrastEnhancementAlgorithm )
176+
if ( mLookupTable && NoEnhancement != mContrastEnhancementAlgorithm )
177177
{
178178
return mLookupTable[static_cast <int>( theValue + mLookupTableOffset )];
179179
}
180180
else
181181
{
182-
// Even if the contrast enhancement algorithms is set to NO_STRETCH
182+
// Even if the contrast enhancement algorithms is set to NoEnhancement
183183
// The input values will still have to be scaled for all data types
184184
// greater than 1 byte.
185185
return mContrastEnhancementFunction->enhance( theValue );
@@ -194,7 +194,7 @@ bool QgsContrastEnhancement::generateLookupTable()
194194
mEnhancementDirty = false;
195195

196196
if ( 0 == mContrastEnhancementFunction ) { return false; }
197-
if ( NO_STRETCH == mContrastEnhancementAlgorithm ) { return false; }
197+
if ( NoEnhancement == mContrastEnhancementAlgorithm ) { return false; }
198198
if ( QGS_Byte != mRasterDataType && QGS_UInt16 != mRasterDataType && QGS_Int16 != mRasterDataType ) { return false; }
199199
if ( !mLookupTable ) { return false; }
200200

@@ -234,24 +234,24 @@ bool QgsContrastEnhancement::isValueInDisplayableRange( double theValue )
234234
@param theAlgorithm The new contrast enhancement algorithm
235235
@param generateTable Flag to overide automatic look up table generation
236236
*/
237-
void QgsContrastEnhancement::setContrastEnhancementAlgorithm( CONTRAST_ENHANCEMENT_ALGORITHM theAlgorithm, bool generateTable )
237+
void QgsContrastEnhancement::setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm theAlgorithm, bool generateTable )
238238
{
239239
QgsDebugMsg( "called algorithm: " + QString::number(( int )theAlgorithm ) + " generate lookup table: " + QString::number(( int )generateTable ) );
240240

241241
if ( theAlgorithm != mContrastEnhancementAlgorithm )
242242
{
243243
switch ( theAlgorithm )
244244
{
245-
case STRETCH_TO_MINMAX :
245+
case StretchToMinimumMaximum :
246246
mContrastEnhancementFunction = new QgsLinearMinMaxEnhancement( mRasterDataType, mMinimumValue, mMaximumValue );
247247
break;
248-
case STRETCH_AND_CLIP_TO_MINMAX :
248+
case StretchAndClipToMinimumMaximum :
249249
mContrastEnhancementFunction = new QgsLinearMinMaxEnhancementWithClip( mRasterDataType, mMinimumValue, mMaximumValue );
250250
break;
251-
case CLIP_TO_MINMAX :
251+
case ClipToMinimumMaximum :
252252
mContrastEnhancementFunction = new QgsClipToMinMaxEnhancement( mRasterDataType, mMinimumValue, mMaximumValue );
253253
break;
254-
case USER_DEFINED :
254+
case UserDefined :
255255
//Do nothing
256256
break;
257257
default:
@@ -281,7 +281,7 @@ void QgsContrastEnhancement::setContrastEnhancementFunction( QgsContrastEnhancem
281281
if ( 0 != theFunction )
282282
{
283283
mContrastEnhancementFunction = theFunction;
284-
mContrastEnhancementAlgorithm = USER_DEFINED;
284+
mContrastEnhancementAlgorithm = UserDefined;
285285
generateLookupTable();
286286
}
287287
}

‎src/core/raster/qgscontrastenhancement.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ class QgsContrastEnhancementFunction;
2828
/** \ingroup core
2929
* Manipulates raster pixel values so that they enhanceContrast or clip into a
3030
* specified numerical range according to the specified
31-
* CONTRAST_ENHANCEMENT_ALGORITHM.
31+
* ContrastEnhancementAlgorithm.
3232
*/
3333
class CORE_EXPORT QgsContrastEnhancement
3434
{
3535

3636
public:
3737

3838
/** \brief This enumerator describes the types of contrast enhancement algorithms that can be used. */
39-
enum CONTRAST_ENHANCEMENT_ALGORITHM
39+
enum ContrastEnhancementAlgorithm
4040
{
41-
NO_STRETCH, //this should be the default color scaling algorithm
42-
STRETCH_TO_MINMAX, //linear histogram enhanceContrast
43-
STRETCH_AND_CLIP_TO_MINMAX,
44-
CLIP_TO_MINMAX,
45-
USER_DEFINED
41+
NoEnhancement, //this should be the default color scaling algorithm
42+
StretchToMinimumMaximum, //linear histogram enhanceContrast
43+
StretchAndClipToMinimumMaximum,
44+
ClipToMinimumMaximum,
45+
UserDefined
4646
};
4747

4848
/** These are exactly the same as GDAL pixel data types
@@ -94,7 +94,7 @@ class CORE_EXPORT QgsContrastEnhancement
9494
/** \brief Return the minimum value for the contrast enhancement range. */
9595
double minimumValue() const { return mMinimumValue; }
9696

97-
CONTRAST_ENHANCEMENT_ALGORITHM getContrastEnhancementAlgorithm() { return mContrastEnhancementAlgorithm; }
97+
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() { return mContrastEnhancementAlgorithm; }
9898

9999
/*
100100
*
@@ -108,7 +108,7 @@ class CORE_EXPORT QgsContrastEnhancement
108108
bool isValueInDisplayableRange( double );
109109

110110
/** \brief Set the contrast enhancement algorithm */
111-
void setContrastEnhancementAlgorithm( CONTRAST_ENHANCEMENT_ALGORITHM, bool generateTable = true );
111+
void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm, bool generateTable = true );
112112

113113
/** \brief A public method that allows the user to set their own custom contrast enhancment function */
114114
void setContrastEnhancementFunction( QgsContrastEnhancementFunction* );
@@ -121,7 +121,7 @@ class CORE_EXPORT QgsContrastEnhancement
121121

122122
private:
123123
/** \brief Current contrast enhancement algorithm */
124-
CONTRAST_ENHANCEMENT_ALGORITHM mContrastEnhancementAlgorithm;
124+
ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm;
125125

126126
/** \brief Pointer to the contrast enhancement function */
127127
QgsContrastEnhancementFunction* mContrastEnhancementFunction;

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 4009 additions & 3756 deletions
Large diffs are not rendered by default.

‎src/core/raster/qgsrasterlayer.h

Lines changed: 498 additions & 794 deletions
Large diffs are not rendered by default.

‎tests/src/core/testqgsrasterlayer.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ void TestQgsRasterLayer::isValid()
119119

120120
void TestQgsRasterLayer::pseudoColor()
121121
{
122-
mpRasterLayer->setDrawingStyle( QgsRasterLayer::SINGLE_BAND_PSEUDO_COLOR );
123-
mpRasterLayer->setColorShadingAlgorithm( QgsRasterLayer::PSEUDO_COLOR );
122+
mpRasterLayer->setDrawingStyle( QgsRasterLayer::SingleBandPseudoColor );
123+
mpRasterLayer->setColorShadingAlgorithm( QgsRasterLayer::PseudoColor );
124124
mpRasterLayer->setContrastEnhancementAlgorithm(
125-
QgsContrastEnhancement::STRETCH_TO_MINMAX, false );
126-
mpRasterLayer->setMinimumValue( mpRasterLayer->getGrayBandName(), 0.0, false );
127-
mpRasterLayer->setMaximumValue( mpRasterLayer->getGrayBandName(), 10.0 );
125+
QgsContrastEnhancement::StretchToMinimumMaximum, false );
126+
mpRasterLayer->setMinimumValue( mpRasterLayer->grayBandName(), 0.0, false );
127+
mpRasterLayer->setMaximumValue( mpRasterLayer->grayBandName(), 10.0 );
128128
mpMapRenderer->setExtent( mpRasterLayer->extent() );
129129
QVERIFY( render( "raster_pseudo" ) );
130130
}
@@ -149,11 +149,11 @@ void TestQgsRasterLayer::landsatBasic875Qml()
149149
}
150150
void TestQgsRasterLayer::checkDimensions()
151151
{
152-
QVERIFY( mpRasterLayer->getRasterXDim() == 10 );
153-
QVERIFY( mpRasterLayer->getRasterYDim() == 10 );
152+
QVERIFY( mpRasterLayer->width() == 10 );
153+
QVERIFY( mpRasterLayer->height() == 10 );
154154
// regression check for ticket #832
155-
// note getRasterBandStats call is base 1
156-
QVERIFY( mpRasterLayer->getRasterBandStats( 1 ).elementCount == 100 );
155+
// note bandStatistics call is base 1
156+
QVERIFY( mpRasterLayer->bandStatistics( 1 ).elementCount == 100 );
157157
}
158158

159159
void TestQgsRasterLayer::buildExternalOverviews()
@@ -174,7 +174,7 @@ void TestQgsRasterLayer::buildExternalOverviews()
174174
//
175175

176176
bool myInternalFlag = false;
177-
QgsRasterLayer::RasterPyramidList myPyramidList = mypLayer->buildRasterPyramidList();
177+
QgsRasterLayer::RasterPyramidList myPyramidList = mypLayer->buildPyramidList();
178178
for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ )
179179
{
180180
//mark to be pyramided
@@ -190,7 +190,7 @@ void TestQgsRasterLayer::buildExternalOverviews()
190190
//
191191
// Lets verify we have pyramids now...
192192
//
193-
myPyramidList = mypLayer->buildRasterPyramidList();
193+
myPyramidList = mypLayer->buildPyramidList();
194194
for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ )
195195
{
196196
//mark to be pyramided

0 commit comments

Comments
 (0)
Please sign in to comment.