@@ -46,10 +46,11 @@ class TestQgsRasterLayer: public QObject
46
46
void cleanup (){};// will be called after every testfunction.
47
47
48
48
void isValid ();
49
+ void pseudoColor ();
49
50
void checkDimensions ();
50
51
private:
51
52
void render (QString theFileName);
52
- QgsRasterLayer * mpLayer ;
53
+ QgsRasterLayer * mpRasterLayer ;
53
54
QgsMapRender * mpMapRenderer;
54
55
};
55
56
@@ -72,29 +73,41 @@ void TestQgsRasterLayer::initTestCase()
72
73
QString myFileName (TEST_DATA_DIR); // defined in CmakeLists.txt
73
74
myFileName = myFileName + QDir::separator () + " tenbytenraster.asc" ;
74
75
QFileInfo myRasterFileInfo ( myFileName );
75
- mpLayer = new QgsRasterLayer ( myRasterFileInfo.filePath (),
76
+ mpRasterLayer = new QgsRasterLayer ( myRasterFileInfo.filePath (),
76
77
myRasterFileInfo.completeBaseName () );
77
78
// Register the layer with the registry
78
- QgsMapLayerRegistry::instance ()->addMapLayer (mpLayer );
79
+ QgsMapLayerRegistry::instance ()->addMapLayer (mpRasterLayer );
79
80
// add the test layer to the maprender
80
81
mpMapRenderer = new QgsMapRender ();
81
82
QStringList myLayers;
82
- myLayers << mpLayer ->getLayerID ();
83
+ myLayers << mpRasterLayer ->getLayerID ();
83
84
mpMapRenderer->setLayerSet (myLayers);
84
85
}
85
86
86
87
void TestQgsRasterLayer::isValid ()
87
88
{
88
- QVERIFY ( mpLayer ->isValid () );
89
+ QVERIFY ( mpRasterLayer ->isValid () );
89
90
render (" raster_test.png" );
90
91
}
92
+
93
+ void TestQgsRasterLayer::pseudoColor ()
94
+ {
95
+ mpRasterLayer->setDrawingStyle (QgsRasterLayer::SINGLE_BAND_PSEUDO_COLOR);
96
+ mpRasterLayer->setColorShadingAlgorithm (QgsRasterLayer::PSEUDO_COLOR);
97
+ mpRasterLayer->setContrastEnhancementAlgorithm (
98
+ QgsContrastEnhancement::STRETCH_TO_MINMAX, false );
99
+ mpRasterLayer->setMinimumValue (mpRasterLayer->getGrayBandName (),0.0 , false );
100
+ mpRasterLayer->setMaximumValue (mpRasterLayer->getGrayBandName (),0.0 );
101
+ render (" raster_pseudo_test.png" );
102
+ }
103
+
91
104
void TestQgsRasterLayer::checkDimensions ()
92
105
{
93
- QVERIFY ( mpLayer ->getRasterXDim () == 10 );
94
- QVERIFY ( mpLayer ->getRasterYDim () == 10 );
106
+ QVERIFY ( mpRasterLayer ->getRasterXDim () == 10 );
107
+ QVERIFY ( mpRasterLayer ->getRasterYDim () == 10 );
95
108
// regression check for ticket #832
96
109
// note getRasterBandStats call is base 1
97
- QVERIFY ( mpLayer ->getRasterBandStats (1 ).elementCount == 100 );
110
+ QVERIFY ( mpRasterLayer ->getRasterBandStats (1 ).elementCount == 100 );
98
111
}
99
112
100
113
void TestQgsRasterLayer::render (QString theFileName)
@@ -107,9 +120,9 @@ void TestQgsRasterLayer::render(QString theFileName)
107
120
myPixmap.fill ( QColor ( " #98dbf9" ) );
108
121
QPainter myPainter ( &myPixmap );
109
122
mpMapRenderer->setOutputSize ( QSize ( 100 ,100 ),72 );
110
- mpMapRenderer->setExtent (mpLayer ->extent ());
123
+ mpMapRenderer->setExtent (mpRasterLayer ->extent ());
111
124
qDebug (" Extents set to:" );
112
- qDebug (mpLayer ->extent ().stringRep ());
125
+ qDebug (mpRasterLayer ->extent ().stringRep ());
113
126
QTime myTime;
114
127
myTime.start ();
115
128
mpMapRenderer->render ( &myPainter );
0 commit comments