-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@9561 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
ersts 2008-11-01 22:27:37 +00:00
parent 5cf0e49eae
commit 785dd83626
8 changed files with 81 additions and 196 deletions

View File

@ -1,68 +0,0 @@
class QgsColorTable
{
%TypeHeaderCode
#include <qgscolortable.h>
%End
public:
/**
* \brief Constructor.
* \param interp color table interpretation
*/
QgsColorTable ( int interp = Rgb );
/** \brief The destuctor. */
~QgsColorTable();
/** \brief Color table interpretation. */
// This is taken from GDAL, GPI_RGB is mapped to Rgba
enum Interp {
Gray = 0, // Use c1 as grayscale value.
Rgb, // Use c1 as red, c2 as green, c3 as blue
Rgba, // Use c1 as red, c2 as green, c3 as blue and c4 as alpha.
Cmyk, // Use c1 as cyan, c2 as magenta, c3 as yellow and c4 as black.
Hls // c1 hue, c2 lightness, c3 saturation; should be His ?
};
/**
* \brief Color table is defined
* \return true if at least one rule is defined
* \false no rule defined
*/
bool defined ( );
/** \brief Get color table interpretation */
int interpretation ( );
/** \brief Add a discrete color */
void add ( unsigned int index, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4 = 0 );
/** \brief Add a ramp rule */
void add ( double min, double max,
unsigned char min_c1, unsigned char min_c2, unsigned char min_c3, unsigned char min_c4,
unsigned char max_c1, unsigned char max_c2, unsigned char max_c3, unsigned char max_c4);
/** \brief Get color
* \return true color was found
* \return false color was no found
*/
bool color ( double value, int *c1, int *c2, int *c3 );
/** \brief Sort ramp rules */
void sort ( );
/** \brief Print to stderr - for debuging */
void print ( );
/** \brief Minimum value */
double rmin();
/** \brief Maximum value */
double rmax();
/** \brief Clear the color table */
void clear();
};

View File

@ -39,9 +39,9 @@ class QgsRasterBandStats
typedef QVector<int> HistogramVector;
//HistogramVector * histogramVector;
/** \brief whteher histogram values are estimated or completely calculated */
bool histogramEstimated;
bool isHistogramEstimated;
/** whehter histogram compuation should include out of range values */
bool histogramOutOfRange;
bool isHistogramOutOfRange;
/** Color table */
//QList<QgsColorRampShader::ColorRampItem> colorTable;
};

View File

@ -551,7 +551,8 @@ void QgsRasterLayerProperties::sync()
tabBar->setCurrentIndex( tabBar->indexOf( tabPageMetadata ) );
tabBar->removeTab( tabBar->indexOf( tabPageColormap ) );
tabBar->removeTab( tabBar->indexOf( tabPageSymbology ) );
tabBar->removeTab( tabBar->indexOf( tabPageTransparency ) );
gboxNoDataValue->setEnabled( false );
gboxCustomTransparency->setEnabled( false );
tabBar->removeTab( tabBar->indexOf( tabPageHistogram ) );
tabBar->removeTab( tabBar->indexOf( tabPagePyramids ) );
}

View File

@ -46,8 +46,8 @@ class CORE_EXPORT QgsRasterBandStats
stdDev = 0.0;
sum = 0.0;
elementCount = 0;
histogramEstimated = false;
histogramOutOfRange = false;
isHistogramEstimated = false;
isHistogramOutOfRange = false;
}
/** \brief The name of the band that these stats belong to. */
@ -64,10 +64,10 @@ class CORE_EXPORT QgsRasterBandStats
int elementCount;
/** \brief whteher histogram values are estimated or completely calculated */
bool histogramEstimated;
bool isHistogramEstimated;
/** whehter histogram compuation should include out of range values */
bool histogramOutOfRange;
bool isHistogramOutOfRange;
/** \brief Store the histogram for a given layer */
HistogramVector * histogramVector;

View File

@ -1136,10 +1136,14 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
QgsDebugMsg( QString( "origin y: %1" ).arg( myRasterViewPort->topLeftPoint.y() ) );
QgsDebugMsg( QString( "(int)origin y: %1" ).arg( static_cast<int>( myRasterViewPort->topLeftPoint.y() ) ) );
//Set the transparency for the whole layer
QImage myAlphaChannel( image->width(), image->height(), QImage::Format_Indexed8 );
myAlphaChannel.fill( ( uint ) mTransparencyLevel );
image->setAlphaChannel( myAlphaChannel );
// Since GDAL's RasterIO can't handle floating point, we have to round to
// the nearest pixel. Add 0.5 to get rounding instead of truncation
// out of static_cast<int>.
theQPainter->drawImage( static_cast<int>(
myRasterViewPort->topLeftPoint.x()
+ 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
//i.e if the histogram has never previously been generated or the user has
//selected a new number of bins.
if ( myRasterBandStats.histogramVector->size() != theBinCount ||
theIgnoreOutOfRangeFlag != myRasterBandStats.histogramOutOfRange ||
theHistogramEstimatedFlag != myRasterBandStats.histogramEstimated )
theIgnoreOutOfRangeFlag != myRasterBandStats.isHistogramOutOfRange ||
theHistogramEstimatedFlag != myRasterBandStats.isHistogramEstimated )
{
myRasterBandStats.histogramVector->clear();
myRasterBandStats.histogramEstimated = theHistogramEstimatedFlag;
myRasterBandStats.histogramOutOfRange = theIgnoreOutOfRangeFlag;
myRasterBandStats.isHistogramEstimated = theHistogramEstimatedFlag;
myRasterBandStats.isHistogramOutOfRange = theIgnoreOutOfRangeFlag;
int *myHistogramArray = new int[theBinCount];

View File

@ -277,8 +277,8 @@ QImage* QgsWmsProvider::draw( QgsRect const & viewExtent, int pixelWidth, int p
{
QgsDebugMsg( "Entering." );
QgsDebugMsg( "pixelWidth = " + QString( pixelWidth ) );
QgsDebugMsg( "pixelHeight = " + QString( pixelHeight ) );
QgsDebugMsg( "pixelWidth = " + QString::number( pixelWidth ) );
QgsDebugMsg( "pixelHeight = " + QString::number( pixelHeight ) );
QgsDebugMsg( "viewExtent: " + viewExtent.toString() );
// Can we reuse the previously cached image?

View File

@ -6,14 +6,16 @@
<x>0</x>
<y>0</y>
<width>576</width>
<height>588</height>
<height>627</height>
</rect>
</property>
<property name="windowTitle" >
<string>Raster Layer Properties</string>
</property>
<property name="windowIcon" >
<iconset/>
<iconset>
<normaloff/>
</iconset>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>
@ -50,7 +52,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
@ -70,7 +72,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
@ -107,16 +109,7 @@
</property>
<widget class="QWidget" name="rgb" >
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item row="0" column="0" >
@ -229,7 +222,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionFileSave.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
</property>
</widget>
</item>
@ -292,7 +286,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>119</width>
<height>16</height>
@ -523,16 +517,7 @@
</widget>
<widget class="QWidget" name="gray" >
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item row="0" column="0" >
@ -701,7 +686,7 @@
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
@ -748,7 +733,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>81</width>
<height>20</height>
@ -768,7 +753,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>111</width>
<height>20</height>
@ -792,10 +777,7 @@
<string>Contrast enhancement</string>
</property>
<layout class="QGridLayout" >
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
@ -842,7 +824,8 @@
<string/>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionFileSave.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
</property>
</widget>
</item>
@ -907,7 +890,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
@ -933,7 +916,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
@ -952,7 +935,7 @@
</widget>
</item>
<item row="0" column="1" >
<widget class="QGroupBox" name="groupBox_7" >
<widget class="QGroupBox" name="gboxNoDataValue" >
<property name="title" >
<string>No data value</string>
</property>
@ -971,7 +954,7 @@
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QGroupBox" name="groupBox_6" >
<widget class="QGroupBox" name="gboxCustomTransparency" >
<property name="title" >
<string>Custom transparency options</string>
</property>
@ -1036,16 +1019,7 @@
</item>
<item row="2" column="2" >
<layout class="QVBoxLayout" >
<property name="leftMargin" >
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>11</number>
</property>
<item>
@ -1057,7 +1031,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionNewAttribute.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionNewAttribute.png</normaloff>../../images/themes/default/mActionNewAttribute.png</iconset>
</property>
</widget>
</item>
@ -1073,7 +1048,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionContextHelp.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionContextHelp.png</normaloff>../../images/themes/default/mActionContextHelp.png</iconset>
</property>
</widget>
</item>
@ -1086,7 +1062,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionDeleteAttribute.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionDeleteAttribute.png</normaloff>../../images/themes/default/mActionDeleteAttribute.png</iconset>
</property>
</widget>
</item>
@ -1099,7 +1076,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionCopySelected.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionCopySelected.png</normaloff>../../images/themes/default/mActionCopySelected.png</iconset>
</property>
</widget>
</item>
@ -1108,7 +1086,7 @@
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>181</height>
@ -1125,7 +1103,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionFolder.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionFolder.png</normaloff>../../images/themes/default/mActionFolder.png</iconset>
</property>
</widget>
</item>
@ -1138,7 +1117,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionFileSave.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
</property>
</widget>
</item>
@ -1169,7 +1149,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>321</width>
<height>45</height>
@ -1203,7 +1183,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>41</width>
<height>27</height>
@ -1223,7 +1203,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionNewAttribute.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionNewAttribute.png</normaloff>../../images/themes/default/mActionNewAttribute.png</iconset>
</property>
</widget>
</item>
@ -1235,7 +1216,7 @@
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
@ -1252,7 +1233,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionFolder.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionFolder.png</normaloff>../../images/themes/default/mActionFolder.png</iconset>
</property>
</widget>
</item>
@ -1265,7 +1247,8 @@
<string>...</string>
</property>
<property name="icon" >
<iconset>../../images/themes/default/mActionFileSave.png</iconset>
<iconset>
<normaloff>../../images/themes/default/mActionFileSave.png</normaloff>../../images/themes/default/mActionFileSave.png</iconset>
</property>
</widget>
</item>
@ -1426,16 +1409,7 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>11</number>
</property>
<item row="0" column="3" >
@ -1493,16 +1467,7 @@
<string>Coordinate reference system</string>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>11</number>
</property>
<item row="0" column="1" >
@ -1527,7 +1492,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>21</width>
<height>20</height>
@ -1651,7 +1616,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>21</width>
<height>20</height>
@ -1666,16 +1631,7 @@
<string>Metadata</string>
</attribute>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>11</number>
</property>
<item row="0" column="0" >
@ -1711,10 +1667,11 @@
</sizepolicy>
</property>
<property name="html" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Verdana'; font-size:10pt; font-weight:400; font-style:normal;">
&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;">&lt;/p>&lt;/body>&lt;/html></string>
&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';">&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
</item>
@ -1826,16 +1783,7 @@ p, li { white-space: pre-wrap; }
<string>Chart Type</string>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>11</number>
</property>
<item row="0" column="1" >
@ -1925,7 +1873,7 @@ p, li { white-space: pre-wrap; }
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
@ -1985,7 +1933,7 @@ p, li { white-space: pre-wrap; }
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

View File

@ -73,9 +73,9 @@ void TestContrastEnhancements::clipMinMaxEnhancementTest()
// Original pixel value 0.0 Should be out of range thus clipped
QVERIFY( !myEnhancement.isValueInDisplayableRange( 0.0 ) );
//Original pixel value of 10.0 should be scaled to 10.0
QVERIFY( 10.0 == myEnhancement.enhanceValue( 10.0 ) ) ;
QVERIFY( 10.0 == myEnhancement.enhance( 10.0 ) ) ;
//Original pixel value of 240 should be scaled to 240
QVERIFY( 240.0 == myEnhancement.enhanceValue( 240.0 ) ) ;
QVERIFY( 240.0 == myEnhancement.enhance( 240.0 ) ) ;
}
void TestContrastEnhancements::linearMinMaxEnhancementWithClipTest()
@ -86,9 +86,9 @@ void TestContrastEnhancements::linearMinMaxEnhancementWithClipTest()
// Original pixel value 0.0 Should be out of range thus clipped
QVERIFY( !myEnhancement.isValueInDisplayableRange( 0.0 ) );
//Original pixel value of 10.0 should be scaled to 0.0
QVERIFY( 0.0 == myEnhancement.enhanceValue( 10.0 ) ) ;
QVERIFY( 0.0 == myEnhancement.enhance( 10.0 ) ) ;
//Original pixel value of 240 should be scaled to 255
QVERIFY( 255.0 == myEnhancement.enhanceValue( 240.0 ) ) ;
QVERIFY( 255.0 == myEnhancement.enhance( 240.0 ) ) ;
}
void TestContrastEnhancements::linearMinMaxEnhancementTest()
@ -98,9 +98,9 @@ void TestContrastEnhancements::linearMinMaxEnhancementTest()
//0 should be scaled to 10 and not clipped
QVERIFY( myEnhancement.isValueInDisplayableRange( 0.0 ) );
//Original pixel value of 10.0 should be scaled to 0.0
QVERIFY( 0.0 == myEnhancement.enhanceValue( 10.0 ) ) ;
QVERIFY( 0.0 == myEnhancement.enhance( 10.0 ) ) ;
//Original pixel value of 240 should be scaled to 255
QVERIFY( 255.0 == myEnhancement.enhanceValue( 240.0 ) ) ;
QVERIFY( 255.0 == myEnhancement.enhance( 240.0 ) ) ;
}
QTEST_MAIN( TestContrastEnhancements )
#include "moc_testcontrastenhancements.cxx"