Skip to content
Permalink
Browse files

Tests for grid blending, grid color labels, vector feature blending a…

…nd vector layer transparency
  • Loading branch information
nyalldawson committed May 13, 2013
1 parent 6249818 commit 6342b74d60566fade93c0da38abb310d52894ee7
@@ -45,12 +45,15 @@ class TestQgsBlendModes: public QObject
void cleanup() {};// will be called after every testfunction.

void vectorBlending();
void featureBlending();
void vectorLayerTransparency();
void rasterBlending();
private:
bool imageCheck( QString theType ); //as above
QgsMapRenderer * mpMapRenderer;
QgsMapLayer * mpPointsLayer;
QgsMapLayer * mpPolysLayer;
QgsVectorLayer * mpLinesLayer;
QgsRasterLayer* mRasterLayer1;
QgsRasterLayer* mRasterLayer2;
QString mTestDataDir;
@@ -85,6 +88,14 @@ void TestQgsBlendModes::initTestCase()
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPolysLayer );

//create a line layer that will be used in tests
QString myLinesFileName = mTestDataDir + "lines.shp";
QFileInfo myLineFileInfo( myLinesFileName );
mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(),
myLineFileInfo.completeBaseName(), "ogr" );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpLinesLayer );

//create two raster layers
QFileInfo rasterFileInfo( mTestDataDir + "landsat.tif" );
mRasterLayer1 = new QgsRasterLayer( rasterFileInfo.filePath(),
@@ -121,6 +132,35 @@ void TestQgsBlendModes::vectorBlending()
QVERIFY( imageCheck( "vector_blendmodes" ) );
}

void TestQgsBlendModes::featureBlending()
{
//Add two vector layers
QStringList myLayers;
myLayers << mpLinesLayer->id();
myLayers << mpPolysLayer->id();
mpMapRenderer->setLayerSet( myLayers );

//Set feature blending modes for point layer
mpLinesLayer->setFeatureBlendMode( QPainter::CompositionMode_Plus );
mpMapRenderer->setExtent( mpPointsLayer->extent() );
QVERIFY( imageCheck( "vector_featureblendmodes" ) );
}

void TestQgsBlendModes::vectorLayerTransparency()
{
//Add two vector layers
QStringList myLayers;
myLayers << mpLinesLayer->id();
myLayers << mpPolysLayer->id();
mpMapRenderer->setLayerSet( myLayers );
mpLinesLayer->setFeatureBlendMode( QPainter::CompositionMode_SourceOver );

//Set feature blending modes for point layer
mpLinesLayer->setLayerTransparency( 50 );
mpMapRenderer->setExtent( mpPointsLayer->extent() );
QVERIFY( imageCheck( "vector_layertransparency" ) );
}

void TestQgsBlendModes::rasterBlending()
{
//Add two raster layers to map renderer
@@ -107,13 +107,16 @@ void TestQgsComposerMap::grid()
mComposerMap->setGridIntervalY( 2000 );
mComposerMap->setShowGridAnnotation( true );
mComposerMap->setGridPenWidth( 0.5 );
mComposerMap->setGridPenColor( QColor( 0, 255, 0 ) );
mComposerMap->setGridAnnotationPrecision( 0 );
mComposerMap->setGridAnnotationPosition( QgsComposerMap::Disabled, QgsComposerMap::Left );
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Right );
mComposerMap->setGridAnnotationPosition( QgsComposerMap::Disabled, QgsComposerMap::Top );
mComposerMap->setGridAnnotationPosition( QgsComposerMap::OutsideMapFrame, QgsComposerMap::Bottom );
mComposerMap->setGridAnnotationDirection( QgsComposerMap::Horizontal, QgsComposerMap::Right );
mComposerMap->setGridAnnotationDirection( QgsComposerMap::Horizontal, QgsComposerMap::Bottom );
mComposerMap->setAnnotationFontColor( QColor( 255, 0, 0, 150 ) );
mComposerMap->setGridBlendMode( QPainter::CompositionMode_Overlay );
QgsCompositionChecker checker( "Composer map grid", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
"control_images" + QDir::separator() + "expected_composermap" + QDir::separator() + "composermap_landsat_grid.png" ) );
bool testResult = checker.testComposition();
@@ -200,6 +203,10 @@ void TestQgsComposerMap::uniqueId()

void TestQgsComposerMap::zebraStyle()
{
mComposerMap->setGridPenColor( QColor( 0, 0, 0 ) );
mComposerMap->setAnnotationFontColor( QColor( 0, 0, 0, 0 ) );
mComposerMap->setGridBlendMode( QPainter::CompositionMode_SourceOver );

mComposerMap->setGridFrameStyle( QgsComposerMap::Zebra );
mComposerMap->setGridEnabled( true );

Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 6342b74

Please sign in to comment.
You can’t perform that action at this time.