Skip to content

Commit f33aeb6

Browse files
author
ersts
committedNov 1, 2008
-Fix missed api updates in the unit tests
-Patched minor debug error in WMS provider -Added ability to set transparency for WMS layer, closes ticket #1348. This patch needs to be reviewed on other platforms however as there seems to be a slight bug with QImage::setAlphaChannel git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9561 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

8 files changed

+81
-196
lines changed

8 files changed

+81
-196
lines changed
 

‎python/core/qgscolortable.sip

Lines changed: 0 additions & 68 deletions
This file was deleted.

‎python/core/qgsrasterbandstats.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class QgsRasterBandStats
3939
typedef QVector<int> HistogramVector;
4040
//HistogramVector * histogramVector;
4141
/** \brief whteher histogram values are estimated or completely calculated */
42-
bool histogramEstimated;
42+
bool isHistogramEstimated;
4343
/** whehter histogram compuation should include out of range values */
44-
bool histogramOutOfRange;
44+
bool isHistogramOutOfRange;
4545
/** Color table */
4646
//QList<QgsColorRampShader::ColorRampItem> colorTable;
4747
};

‎src/app/qgsrasterlayerproperties.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@ void QgsRasterLayerProperties::sync()
551551
tabBar->setCurrentIndex( tabBar->indexOf( tabPageMetadata ) );
552552
tabBar->removeTab( tabBar->indexOf( tabPageColormap ) );
553553
tabBar->removeTab( tabBar->indexOf( tabPageSymbology ) );
554-
tabBar->removeTab( tabBar->indexOf( tabPageTransparency ) );
554+
gboxNoDataValue->setEnabled( false );
555+
gboxCustomTransparency->setEnabled( false );
555556
tabBar->removeTab( tabBar->indexOf( tabPageHistogram ) );
556557
tabBar->removeTab( tabBar->indexOf( tabPagePyramids ) );
557558
}

‎src/core/raster/qgsrasterbandstats.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class CORE_EXPORT QgsRasterBandStats
4646
stdDev = 0.0;
4747
sum = 0.0;
4848
elementCount = 0;
49-
histogramEstimated = false;
50-
histogramOutOfRange = false;
49+
isHistogramEstimated = false;
50+
isHistogramOutOfRange = false;
5151
}
5252

5353
/** \brief The name of the band that these stats belong to. */
@@ -64,10 +64,10 @@ class CORE_EXPORT QgsRasterBandStats
6464
int elementCount;
6565

6666
/** \brief whteher histogram values are estimated or completely calculated */
67-
bool histogramEstimated;
67+
bool isHistogramEstimated;
6868

6969
/** whehter histogram compuation should include out of range values */
70-
bool histogramOutOfRange;
70+
bool isHistogramOutOfRange;
7171

7272
/** \brief Store the histogram for a given layer */
7373
HistogramVector * histogramVector;

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,10 +1136,14 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
11361136
QgsDebugMsg( QString( "origin y: %1" ).arg( myRasterViewPort->topLeftPoint.y() ) );
11371137
QgsDebugMsg( QString( "(int)origin y: %1" ).arg( static_cast<int>( myRasterViewPort->topLeftPoint.y() ) ) );
11381138

1139+
//Set the transparency for the whole layer
1140+
QImage myAlphaChannel( image->width(), image->height(), QImage::Format_Indexed8 );
1141+
myAlphaChannel.fill( ( uint ) mTransparencyLevel );
1142+
image->setAlphaChannel( myAlphaChannel );
1143+
11391144
// Since GDAL's RasterIO can't handle floating point, we have to round to
11401145
// the nearest pixel. Add 0.5 to get rounding instead of truncation
11411146
// out of static_cast<int>.
1142-
11431147
theQPainter->drawImage( static_cast<int>(
11441148
myRasterViewPort->topLeftPoint.x()
11451149
+ 0.5 // try simulating rounding instead of truncation, to avoid off-by-one errors
@@ -4516,12 +4520,12 @@ void QgsRasterLayer::populateHistogram( int theBandNo, int theBinCount, bool the
45164520
//i.e if the histogram has never previously been generated or the user has
45174521
//selected a new number of bins.
45184522
if ( myRasterBandStats.histogramVector->size() != theBinCount ||
4519-
theIgnoreOutOfRangeFlag != myRasterBandStats.histogramOutOfRange ||
4520-
theHistogramEstimatedFlag != myRasterBandStats.histogramEstimated )
4523+
theIgnoreOutOfRangeFlag != myRasterBandStats.isHistogramOutOfRange ||
4524+
theHistogramEstimatedFlag != myRasterBandStats.isHistogramEstimated )
45214525
{
45224526
myRasterBandStats.histogramVector->clear();
4523-
myRasterBandStats.histogramEstimated = theHistogramEstimatedFlag;
4524-
myRasterBandStats.histogramOutOfRange = theIgnoreOutOfRangeFlag;
4527+
myRasterBandStats.isHistogramEstimated = theHistogramEstimatedFlag;
4528+
myRasterBandStats.isHistogramOutOfRange = theIgnoreOutOfRangeFlag;
45254529
int *myHistogramArray = new int[theBinCount];
45264530

45274531

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ QImage* QgsWmsProvider::draw( QgsRect const & viewExtent, int pixelWidth, int p
277277
{
278278
QgsDebugMsg( "Entering." );
279279

280-
QgsDebugMsg( "pixelWidth = " + QString( pixelWidth ) );
281-
QgsDebugMsg( "pixelHeight = " + QString( pixelHeight ) );
280+
QgsDebugMsg( "pixelWidth = " + QString::number( pixelWidth ) );
281+
QgsDebugMsg( "pixelHeight = " + QString::number( pixelHeight ) );
282282
QgsDebugMsg( "viewExtent: " + viewExtent.toString() );
283283

284284
// Can we reuse the previously cached image?

‎src/ui/qgsrasterlayerpropertiesbase.ui

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

‎tests/src/core/testcontrastenhancements.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ void TestContrastEnhancements::clipMinMaxEnhancementTest()
7373
// Original pixel value 0.0 Should be out of range thus clipped
7474
QVERIFY( !myEnhancement.isValueInDisplayableRange( 0.0 ) );
7575
//Original pixel value of 10.0 should be scaled to 10.0
76-
QVERIFY( 10.0 == myEnhancement.enhanceValue( 10.0 ) ) ;
76+
QVERIFY( 10.0 == myEnhancement.enhance( 10.0 ) ) ;
7777
//Original pixel value of 240 should be scaled to 240
78-
QVERIFY( 240.0 == myEnhancement.enhanceValue( 240.0 ) ) ;
78+
QVERIFY( 240.0 == myEnhancement.enhance( 240.0 ) ) ;
7979
}
8080

8181
void TestContrastEnhancements::linearMinMaxEnhancementWithClipTest()
@@ -86,9 +86,9 @@ void TestContrastEnhancements::linearMinMaxEnhancementWithClipTest()
8686
// Original pixel value 0.0 Should be out of range thus clipped
8787
QVERIFY( !myEnhancement.isValueInDisplayableRange( 0.0 ) );
8888
//Original pixel value of 10.0 should be scaled to 0.0
89-
QVERIFY( 0.0 == myEnhancement.enhanceValue( 10.0 ) ) ;
89+
QVERIFY( 0.0 == myEnhancement.enhance( 10.0 ) ) ;
9090
//Original pixel value of 240 should be scaled to 255
91-
QVERIFY( 255.0 == myEnhancement.enhanceValue( 240.0 ) ) ;
91+
QVERIFY( 255.0 == myEnhancement.enhance( 240.0 ) ) ;
9292
}
9393

9494
void TestContrastEnhancements::linearMinMaxEnhancementTest()
@@ -98,9 +98,9 @@ void TestContrastEnhancements::linearMinMaxEnhancementTest()
9898
//0 should be scaled to 10 and not clipped
9999
QVERIFY( myEnhancement.isValueInDisplayableRange( 0.0 ) );
100100
//Original pixel value of 10.0 should be scaled to 0.0
101-
QVERIFY( 0.0 == myEnhancement.enhanceValue( 10.0 ) ) ;
101+
QVERIFY( 0.0 == myEnhancement.enhance( 10.0 ) ) ;
102102
//Original pixel value of 240 should be scaled to 255
103-
QVERIFY( 255.0 == myEnhancement.enhanceValue( 240.0 ) ) ;
103+
QVERIFY( 255.0 == myEnhancement.enhance( 240.0 ) ) ;
104104
}
105105
QTEST_MAIN( TestContrastEnhancements )
106106
#include "moc_testcontrastenhancements.cxx"

0 commit comments

Comments
 (0)
Please sign in to comment.