mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
Remove map settings parameter from QgsComposition
Breaks the hard link between canvas and compositions! Fix #11077
This commit is contained in:
parent
b41f3a7860
commit
a188d14f48
@ -660,7 +660,10 @@ to use the QgsProperty framework objects.
|
|||||||
QgsComposition {#qgis_api_break_3_0_QgsComposition}
|
QgsComposition {#qgis_api_break_3_0_QgsComposition}
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
- constructor requires QgsProject instance as the second argument
|
- The constructor no longer takes a reference to a QgsMapSettings object. This is no longer
|
||||||
|
used by compositions. To set the layers to show in composer maps, the QgsComposerMap::setLayers()
|
||||||
|
method should be used instead.
|
||||||
|
- constructor requires QgsProject instance
|
||||||
- addItemsFromXML() has been renamed to addItemsFromXml()
|
- addItemsFromXML() has been renamed to addItemsFromXml()
|
||||||
- Constructor with QgsMapRenderer parameter has been removed. Use the variant with QgsMapSettings parameter.
|
- Constructor with QgsMapRenderer parameter has been removed. Use the variant with QgsMapSettings parameter.
|
||||||
- mapRenderer() has been removed. Use mapSettings() instead.
|
- mapRenderer() has been removed. Use mapSettings() instead.
|
||||||
@ -674,6 +677,7 @@ were removed. Use setSnapTolerance() and snapTolerance() instead.
|
|||||||
- worldFileMap() and setWorldFileMap() have been renamed to referenceMap() and setReferenceMap()
|
- worldFileMap() and setWorldFileMap() have been renamed to referenceMap() and setReferenceMap()
|
||||||
- dataDefinedProperty() and setDataDefinedProperty() now use the QgsProperty framework instead
|
- dataDefinedProperty() and setDataDefinedProperty() now use the QgsProperty framework instead
|
||||||
of QgsDataDefined objects.
|
of QgsDataDefined objects.
|
||||||
|
- mapSettings() was removed. Use QgsComposerMap::mapSettings() instead.
|
||||||
|
|
||||||
|
|
||||||
QgsCoordinateReferenceSystem {#qgis_api_break_3_0_QgsCoordinateReferenceSystem}
|
QgsCoordinateReferenceSystem {#qgis_api_break_3_0_QgsCoordinateReferenceSystem}
|
||||||
|
@ -40,7 +40,7 @@ class QgsComposition : QGraphicsScene, QgsExpressionContextGenerator
|
|||||||
Landscape
|
Landscape
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit QgsComposition( const QgsMapSettings& mapSettings, QgsProject* project );
|
explicit QgsComposition( QgsProject* project );
|
||||||
|
|
||||||
/** Composition atlas modes*/
|
/** Composition atlas modes*/
|
||||||
enum AtlasMode
|
enum AtlasMode
|
||||||
@ -366,10 +366,6 @@ class QgsComposition : QGraphicsScene, QgsExpressionContextGenerator
|
|||||||
/** Used to enable or disable advanced effects such as blend modes in a composition */
|
/** Used to enable or disable advanced effects such as blend modes in a composition */
|
||||||
void setUseAdvancedEffects( const bool effectsEnabled );
|
void setUseAdvancedEffects( const bool effectsEnabled );
|
||||||
|
|
||||||
//! Return setting of QGIS map canvas
|
|
||||||
//! @note added in 2.4
|
|
||||||
const QgsMapSettings& mapSettings() const;
|
|
||||||
|
|
||||||
QgsComposition::PlotStyle plotStyle() const;
|
QgsComposition::PlotStyle plotStyle() const;
|
||||||
void setPlotStyle( const QgsComposition::PlotStyle style );
|
void setPlotStyle( const QgsComposition::PlotStyle style );
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
|
|||||||
connect( mActionShowRulers, SIGNAL( triggered( bool ) ), this, SLOT( toggleRulers( bool ) ) );
|
connect( mActionShowRulers, SIGNAL( triggered( bool ) ), this, SLOT( toggleRulers( bool ) ) );
|
||||||
|
|
||||||
//init undo/redo buttons
|
//init undo/redo buttons
|
||||||
mComposition = new QgsComposition( mQgis->mapCanvas()->mapSettings(), QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
|
|
||||||
mActionUndo->setEnabled( false );
|
mActionUndo->setEnabled( false );
|
||||||
mActionRedo->setEnabled( false );
|
mActionRedo->setEnabled( false );
|
||||||
@ -3560,7 +3560,7 @@ void QgsComposer::readXml( const QDomElement& composerElem, const QDomDocument&
|
|||||||
createComposerView();
|
createComposerView();
|
||||||
|
|
||||||
//read composition settings
|
//read composition settings
|
||||||
mComposition = new QgsComposition( mQgis->mapCanvas()->mapSettings(), QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
QDomNodeList compositionNodeList = composerElem.elementsByTagName( QStringLiteral( "Composition" ) );
|
QDomNodeList compositionNodeList = composerElem.elementsByTagName( QStringLiteral( "Composition" ) );
|
||||||
if ( compositionNodeList.size() > 0 )
|
if ( compositionNodeList.size() > 0 )
|
||||||
{
|
{
|
||||||
|
@ -60,9 +60,8 @@
|
|||||||
#include "gdal.h"
|
#include "gdal.h"
|
||||||
#include "cpl_conv.h"
|
#include "cpl_conv.h"
|
||||||
|
|
||||||
QgsComposition::QgsComposition( const QgsMapSettings& mapSettings, QgsProject* project )
|
QgsComposition::QgsComposition( QgsProject* project )
|
||||||
: QGraphicsScene( nullptr )
|
: QGraphicsScene( nullptr )
|
||||||
, mMapSettings( mapSettings )
|
|
||||||
, mProject( project )
|
, mProject( project )
|
||||||
, mAtlasComposition( this )
|
, mAtlasComposition( this )
|
||||||
{
|
{
|
||||||
|
@ -104,8 +104,10 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
|
|||||||
Landscape
|
Landscape
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Construct a composition, using given map settings and project
|
/**
|
||||||
explicit QgsComposition( const QgsMapSettings& mapSettings, QgsProject* project );
|
* Construct a new composition linked to the specified project.
|
||||||
|
*/
|
||||||
|
explicit QgsComposition( QgsProject* project );
|
||||||
|
|
||||||
//! Composition atlas modes
|
//! Composition atlas modes
|
||||||
enum AtlasMode
|
enum AtlasMode
|
||||||
@ -443,10 +445,6 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
|
|||||||
//! Used to enable or disable advanced effects such as blend modes in a composition
|
//! Used to enable or disable advanced effects such as blend modes in a composition
|
||||||
void setUseAdvancedEffects( const bool effectsEnabled );
|
void setUseAdvancedEffects( const bool effectsEnabled );
|
||||||
|
|
||||||
//! Return setting of QGIS map canvas
|
|
||||||
//! @note added in 2.4
|
|
||||||
const QgsMapSettings& mapSettings() const { return mMapSettings; }
|
|
||||||
|
|
||||||
QgsComposition::PlotStyle plotStyle() const { return mPlotStyle; }
|
QgsComposition::PlotStyle plotStyle() const { return mPlotStyle; }
|
||||||
void setPlotStyle( const QgsComposition::PlotStyle style ) { mPlotStyle = style; }
|
void setPlotStyle( const QgsComposition::PlotStyle style ) { mPlotStyle = style; }
|
||||||
|
|
||||||
@ -862,8 +860,6 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene, public QgsExpressionCo
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Reference to map settings of QGIS main map
|
|
||||||
const QgsMapSettings& mMapSettings;
|
|
||||||
|
|
||||||
//! Pointer to associated project (not null)
|
//! Pointer to associated project (not null)
|
||||||
QgsProject* mProject;
|
QgsProject* mProject;
|
||||||
|
@ -1522,7 +1522,7 @@ bool QgsGeorefPluginGui::writePDFMapFile( const QString& fileName, const QgsGeor
|
|||||||
double paperHeight = s.value( QStringLiteral( "/Plugin-GeoReferencer/Config/HeightPDFMap" ), "420" ).toDouble();
|
double paperHeight = s.value( QStringLiteral( "/Plugin-GeoReferencer/Config/HeightPDFMap" ), "420" ).toDouble();
|
||||||
|
|
||||||
//create composition
|
//create composition
|
||||||
QgsComposition* composition = new QgsComposition( mCanvas->mapSettings(), QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
if ( mapRatio >= 1 )
|
if ( mapRatio >= 1 )
|
||||||
{
|
{
|
||||||
composition->setPaperSize( paperHeight, paperWidth );
|
composition->setPaperSize( paperHeight, paperWidth );
|
||||||
@ -1589,7 +1589,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
|
|||||||
}
|
}
|
||||||
|
|
||||||
//create composition A4 with 300 dpi
|
//create composition A4 with 300 dpi
|
||||||
QgsComposition* composition = new QgsComposition( mCanvas->mapSettings(), QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
composition->setPaperSize( 210, 297 ); //A4
|
composition->setPaperSize( 210, 297 ); //A4
|
||||||
composition->setPrintResolution( 300 );
|
composition->setPrintResolution( 300 );
|
||||||
composition->setNumPages( 2 );
|
composition->setNumPages( 2 );
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "qgspallabeling.h"
|
#include "qgspallabeling.h"
|
||||||
#include "qgsrenderer.h"
|
#include "qgsrenderer.h"
|
||||||
#include "qgsvectorlayer.h"
|
#include "qgsvectorlayer.h"
|
||||||
|
#include "qgsmapsettings.h"
|
||||||
|
|
||||||
#include "qgscomposition.h"
|
#include "qgscomposition.h"
|
||||||
#include "qgscomposerarrow.h"
|
#include "qgscomposerarrow.h"
|
||||||
@ -475,7 +476,7 @@ QgsComposition* QgsWmsProjectParser::initComposition( const QString& composerTem
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsComposition* composition = new QgsComposition( mapSettings, QgsProject::instance() ); //set resolution, paper size from composer element attributes
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() ); //set resolution, paper size from composer element attributes
|
||||||
if ( !composition->readXml( compositionElem, *( mProjectParser->xmlDocument() ) ) )
|
if ( !composition->readXml( compositionElem, *( mProjectParser->xmlDocument() ) ) )
|
||||||
{
|
{
|
||||||
delete composition;
|
delete composition;
|
||||||
@ -503,6 +504,8 @@ QgsComposition* QgsWmsProjectParser::initComposition( const QString& composerTem
|
|||||||
QgsComposerMap* map = qobject_cast< QgsComposerMap *>( *itemIt );
|
QgsComposerMap* map = qobject_cast< QgsComposerMap *>( *itemIt );
|
||||||
if ( map )
|
if ( map )
|
||||||
{
|
{
|
||||||
|
if ( !map->keepLayerSet() )
|
||||||
|
map->setLayers( mapSettings.layers() );
|
||||||
mapList.push_back( map );
|
mapList.push_back( map );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -126,10 +126,11 @@ void TestQgs25DRenderer::render()
|
|||||||
|
|
||||||
void TestQgs25DRenderer::renderComposition()
|
void TestQgs25DRenderer::renderComposition()
|
||||||
{
|
{
|
||||||
QgsComposition* composition = new QgsComposition( mMapSettings, QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
composition->setPaperSize( 297, 210 ); //A4 landscape
|
composition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
QgsComposerMap* map = new QgsComposerMap( composition, 20, 20, 200, 100 );
|
QgsComposerMap* map = new QgsComposerMap( composition, 20, 20, 200, 100 );
|
||||||
map->setFrameEnabled( true );
|
map->setFrameEnabled( true );
|
||||||
|
map->setLayers( QList< QgsMapLayer* >() << mpPolysLayer );
|
||||||
composition->addComposerMap( map );
|
composition->addComposerMap( map );
|
||||||
|
|
||||||
map->setNewExtent( mpPolysLayer->extent() );
|
map->setNewExtent( mpPolysLayer->extent() );
|
||||||
|
@ -43,7 +43,6 @@ class TestQgsAtlasComposition : public QObject
|
|||||||
, mLabel2( 0 )
|
, mLabel2( 0 )
|
||||||
, mAtlasMap( 0 )
|
, mAtlasMap( 0 )
|
||||||
, mOverview( 0 )
|
, mOverview( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
, mVectorLayer( 0 )
|
, mVectorLayer( 0 )
|
||||||
, mVectorLayer2( 0 )
|
, mVectorLayer2( 0 )
|
||||||
, mAtlas( 0 )
|
, mAtlas( 0 )
|
||||||
@ -84,7 +83,6 @@ class TestQgsAtlasComposition : public QObject
|
|||||||
QgsComposerLabel* mLabel2;
|
QgsComposerLabel* mLabel2;
|
||||||
QgsComposerMap* mAtlasMap;
|
QgsComposerMap* mAtlasMap;
|
||||||
QgsComposerMap* mOverview;
|
QgsComposerMap* mOverview;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QgsVectorLayer* mVectorLayer;
|
QgsVectorLayer* mVectorLayer;
|
||||||
QgsVectorLayer* mVectorLayer2;
|
QgsVectorLayer* mVectorLayer2;
|
||||||
QgsAtlasComposition* mAtlas;
|
QgsAtlasComposition* mAtlas;
|
||||||
@ -96,8 +94,6 @@ void TestQgsAtlasComposition::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create maplayers from testdata and add to layer registry
|
//create maplayers from testdata and add to layer registry
|
||||||
QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/france_parts.shp" );
|
QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/france_parts.shp" );
|
||||||
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
|
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
|
||||||
@ -115,9 +111,7 @@ void TestQgsAtlasComposition::initTestCase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestQgsAtlasComposition::~TestQgsAtlasComposition()
|
TestQgsAtlasComposition::~TestQgsAtlasComposition()
|
||||||
{
|
{}
|
||||||
delete mMapSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TestQgsAtlasComposition::cleanupTestCase()
|
void TestQgsAtlasComposition::cleanupTestCase()
|
||||||
@ -139,15 +133,12 @@ void TestQgsAtlasComposition::cleanupTestCase()
|
|||||||
void TestQgsAtlasComposition::init()
|
void TestQgsAtlasComposition::init()
|
||||||
{
|
{
|
||||||
//create composition with composer map
|
//create composition with composer map
|
||||||
mMapSettings->setLayers( QList<QgsMapLayer*>() << mVectorLayer );
|
|
||||||
mMapSettings->setCrsTransformEnabled( true );
|
|
||||||
mMapSettings->setMapUnits( QgsUnitTypes::DistanceMeters );
|
|
||||||
|
|
||||||
// select epsg:2154
|
// select epsg:2154
|
||||||
QgsCoordinateReferenceSystem crs;
|
QgsCoordinateReferenceSystem crs;
|
||||||
crs.createFromSrid( 2154 );
|
crs.createFromSrid( 2154 );
|
||||||
QgsProject::instance()->setCrs( crs );
|
QgsProject::instance()->setCrs( crs );
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
// fix the renderer, fill with green
|
// fix the renderer, fill with green
|
||||||
@ -163,6 +154,7 @@ void TestQgsAtlasComposition::init()
|
|||||||
// Make sure it doesn't try to render a map for caching onto a still 0-sized image
|
// Make sure it doesn't try to render a map for caching onto a still 0-sized image
|
||||||
mAtlasMap->setPreviewMode( QgsComposerMap::Rectangle );
|
mAtlasMap->setPreviewMode( QgsComposerMap::Rectangle );
|
||||||
mComposition->addComposerMap( mAtlasMap, false );
|
mComposition->addComposerMap( mAtlasMap, false );
|
||||||
|
mAtlasMap->setLayers( QList<QgsMapLayer*>() << mVectorLayer );
|
||||||
|
|
||||||
mAtlas = &mComposition->atlasComposition();
|
mAtlas = &mComposition->atlasComposition();
|
||||||
mAtlas->setCoverageLayer( mVectorLayer );
|
mAtlas->setCoverageLayer( mVectorLayer );
|
||||||
@ -174,6 +166,7 @@ void TestQgsAtlasComposition::init()
|
|||||||
mOverview->setFrameEnabled( true );
|
mOverview->setFrameEnabled( true );
|
||||||
mOverview->overview()->setFrameMap( mAtlasMap->id() );
|
mOverview->overview()->setFrameMap( mAtlasMap->id() );
|
||||||
mOverview->setPreviewMode( QgsComposerMap::Rectangle );
|
mOverview->setPreviewMode( QgsComposerMap::Rectangle );
|
||||||
|
mOverview->setLayers( QList<QgsMapLayer*>() << mVectorLayer );
|
||||||
mComposition->addComposerMap( mOverview, false );
|
mComposition->addComposerMap( mOverview, false );
|
||||||
mOverview->setNewExtent( QgsRectangle( 49670.718, 6415139.086, 699672.519, 7065140.887 ) );
|
mOverview->setNewExtent( QgsRectangle( 49670.718, 6415139.086, 699672.519, 7065140.887 ) );
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ class TestQgsComposerDD : public QObject
|
|||||||
public:
|
public:
|
||||||
TestQgsComposerDD()
|
TestQgsComposerDD()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
, mVectorLayer( 0 )
|
, mVectorLayer( 0 )
|
||||||
, mAtlasMap( 0 )
|
, mAtlasMap( 0 )
|
||||||
, mAtlas( 0 )
|
, mAtlas( 0 )
|
||||||
@ -54,7 +53,6 @@ class TestQgsComposerDD : public QObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QgsComposition *mComposition;
|
QgsComposition *mComposition;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QgsVectorLayer* mVectorLayer;
|
QgsVectorLayer* mVectorLayer;
|
||||||
QgsComposerMap* mAtlasMap;
|
QgsComposerMap* mAtlasMap;
|
||||||
QgsAtlasComposition* mAtlas;
|
QgsAtlasComposition* mAtlas;
|
||||||
@ -66,8 +64,6 @@ void TestQgsComposerDD::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create maplayers from testdata and add to layer registry
|
//create maplayers from testdata and add to layer registry
|
||||||
QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/france_parts.shp" );
|
QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/france_parts.shp" );
|
||||||
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
|
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
|
||||||
@ -79,15 +75,11 @@ void TestQgsComposerDD::initTestCase()
|
|||||||
mVectorLayer->setSimplifyMethod( simplifyMethod );
|
mVectorLayer->setSimplifyMethod( simplifyMethod );
|
||||||
|
|
||||||
//create composition with composer map
|
//create composition with composer map
|
||||||
mMapSettings->setLayers( QList<QgsMapLayer*>() << mVectorLayer );
|
|
||||||
mMapSettings->setCrsTransformEnabled( true );
|
|
||||||
mMapSettings->setMapUnits( QgsUnitTypes::DistanceMeters );
|
|
||||||
|
|
||||||
// select epsg:2154
|
// select epsg:2154
|
||||||
QgsCoordinateReferenceSystem crs;
|
QgsCoordinateReferenceSystem crs;
|
||||||
crs.createFromSrid( 2154 );
|
crs.createFromSrid( 2154 );
|
||||||
mMapSettings->setDestinationCrs( crs );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
// fix the renderer, fill with green
|
// fix the renderer, fill with green
|
||||||
@ -114,7 +106,6 @@ void TestQgsComposerDD::initTestCase()
|
|||||||
void TestQgsComposerDD::cleanupTestCase()
|
void TestQgsComposerDD::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
delete mVectorLayer;
|
delete mVectorLayer;
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
|
@ -34,7 +34,6 @@ class TestQgsComposerEffects : public QObject
|
|||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mComposerRect1( 0 )
|
, mComposerRect1( 0 )
|
||||||
, mComposerRect2( 0 )
|
, mComposerRect2( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -49,7 +48,6 @@ class TestQgsComposerEffects : public QObject
|
|||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
QgsComposerShape *mComposerRect1;
|
QgsComposerShape *mComposerRect1;
|
||||||
QgsComposerShape *mComposerRect2;
|
QgsComposerShape *mComposerRect2;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QString mReport;
|
QString mReport;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,11 +56,9 @@ void TestQgsComposerEffects::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create composition with two rectangles
|
//create composition with two rectangles
|
||||||
|
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposerRect1 = new QgsComposerShape( 20, 20, 150, 100, mComposition );
|
mComposerRect1 = new QgsComposerShape( 20, 20, 150, 100, mComposition );
|
||||||
mComposerRect1->setShapeType( QgsComposerShape::Rectangle );
|
mComposerRect1->setShapeType( QgsComposerShape::Rectangle );
|
||||||
@ -79,7 +75,6 @@ void TestQgsComposerEffects::initTestCase()
|
|||||||
void TestQgsComposerEffects::cleanupTestCase()
|
void TestQgsComposerEffects::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
QFile myFile( myReportFile );
|
QFile myFile( myReportFile );
|
||||||
|
@ -81,7 +81,7 @@ void TestQgsComposerGroup::initTestCase()
|
|||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
mMapSettings = new QgsMapSettings();
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
//create some items
|
//create some items
|
||||||
|
@ -51,14 +51,12 @@ class TestQgsComposerHtml : public QObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QgsComposition *mComposition;
|
QgsComposition *mComposition;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QString mReport;
|
QString mReport;
|
||||||
QFont mTestFont;
|
QFont mTestFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
TestQgsComposerHtml::TestQgsComposerHtml()
|
TestQgsComposerHtml::TestQgsComposerHtml()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -68,8 +66,7 @@ void TestQgsComposerHtml::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
mReport = QStringLiteral( "<h1>Composer HTML Tests</h1>\n" );
|
mReport = QStringLiteral( "<h1>Composer HTML Tests</h1>\n" );
|
||||||
@ -81,7 +78,6 @@ void TestQgsComposerHtml::initTestCase()
|
|||||||
void TestQgsComposerHtml::cleanupTestCase()
|
void TestQgsComposerHtml::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
QFile myFile( myReportFile );
|
QFile myFile( myReportFile );
|
||||||
|
@ -35,7 +35,6 @@ class TestQgsComposerLabel : public QObject
|
|||||||
TestQgsComposerLabel()
|
TestQgsComposerLabel()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mComposerLabel( 0 )
|
, mComposerLabel( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
, mVectorLayer( 0 )
|
, mVectorLayer( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -59,7 +58,6 @@ class TestQgsComposerLabel : public QObject
|
|||||||
private:
|
private:
|
||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
QgsComposerLabel* mComposerLabel;
|
QgsComposerLabel* mComposerLabel;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QgsVectorLayer* mVectorLayer;
|
QgsVectorLayer* mVectorLayer;
|
||||||
QString mReport;
|
QString mReport;
|
||||||
};
|
};
|
||||||
@ -69,8 +67,6 @@ void TestQgsComposerLabel::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create maplayers from testdata and add to layer registry
|
//create maplayers from testdata and add to layer registry
|
||||||
QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + '/' + "france_parts.shp" );
|
QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + '/' + "france_parts.shp" );
|
||||||
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
|
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
|
||||||
@ -78,9 +74,7 @@ void TestQgsComposerLabel::initTestCase()
|
|||||||
QStringLiteral( "ogr" ) );
|
QStringLiteral( "ogr" ) );
|
||||||
|
|
||||||
//create composition with composer map
|
//create composition with composer map
|
||||||
mMapSettings->setLayers( QList<QgsMapLayer*>() << mVectorLayer );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mMapSettings->setCrsTransformEnabled( false );
|
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposition->atlasComposition().setCoverageLayer( mVectorLayer );
|
mComposition->atlasComposition().setCoverageLayer( mVectorLayer );
|
||||||
|
|
||||||
@ -102,7 +96,6 @@ void TestQgsComposerLabel::cleanupTestCase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
delete mVectorLayer;
|
delete mVectorLayer;
|
||||||
|
|
||||||
QgsApplication::exitQgis();
|
QgsApplication::exitQgis();
|
||||||
|
@ -38,7 +38,6 @@ class TestQgsComposerMap : public QObject
|
|||||||
TestQgsComposerMap()
|
TestQgsComposerMap()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mComposerMap( 0 )
|
, mComposerMap( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
, mRasterLayer( 0 )
|
, mRasterLayer( 0 )
|
||||||
, mPointsLayer( 0 )
|
, mPointsLayer( 0 )
|
||||||
, mPolysLayer( 0 )
|
, mPolysLayer( 0 )
|
||||||
@ -60,7 +59,6 @@ class TestQgsComposerMap : public QObject
|
|||||||
private:
|
private:
|
||||||
QgsComposition *mComposition;
|
QgsComposition *mComposition;
|
||||||
QgsComposerMap *mComposerMap;
|
QgsComposerMap *mComposerMap;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QgsRasterLayer* mRasterLayer;
|
QgsRasterLayer* mRasterLayer;
|
||||||
QgsVectorLayer* mPointsLayer;
|
QgsVectorLayer* mPointsLayer;
|
||||||
QgsVectorLayer* mPolysLayer;
|
QgsVectorLayer* mPolysLayer;
|
||||||
@ -112,15 +110,12 @@ void TestQgsComposerMap::cleanupTestCase()
|
|||||||
|
|
||||||
void TestQgsComposerMap::init()
|
void TestQgsComposerMap::init()
|
||||||
{
|
{
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create composition with composer map
|
//create composition with composer map
|
||||||
mMapSettings->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mMapSettings->setCrsTransformEnabled( false );
|
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
||||||
mComposerMap->setFrameEnabled( true );
|
mComposerMap->setFrameEnabled( true );
|
||||||
|
mComposerMap->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
mComposition->addComposerMap( mComposerMap );
|
mComposition->addComposerMap( mComposerMap );
|
||||||
|
|
||||||
mReport = QStringLiteral( "<h1>Composer Map Tests</h1>\n" );
|
mReport = QStringLiteral( "<h1>Composer Map Tests</h1>\n" );
|
||||||
@ -129,7 +124,6 @@ void TestQgsComposerMap::init()
|
|||||||
void TestQgsComposerMap::cleanup()
|
void TestQgsComposerMap::cleanup()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsComposerMap::render()
|
void TestQgsComposerMap::render()
|
||||||
@ -262,7 +256,7 @@ void TestQgsComposerMap::dataDefinedLayers()
|
|||||||
ms.setLayers( QList<QgsMapLayer*>() << mRasterLayer << mPolysLayer << mPointsLayer << mLinesLayer );
|
ms.setLayers( QList<QgsMapLayer*>() << mRasterLayer << mPolysLayer << mPointsLayer << mLinesLayer );
|
||||||
ms.setCrsTransformEnabled( true );
|
ms.setCrsTransformEnabled( true );
|
||||||
|
|
||||||
mComposition = new QgsComposition( ms, QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
||||||
mComposerMap->setFrameEnabled( true );
|
mComposerMap->setFrameEnabled( true );
|
||||||
@ -338,14 +332,14 @@ void TestQgsComposerMap::dataDefinedLayers()
|
|||||||
void TestQgsComposerMap::dataDefinedStyles()
|
void TestQgsComposerMap::dataDefinedStyles()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
QgsMapSettings ms;
|
|
||||||
ms.setLayers( QList<QgsMapLayer*>() << mRasterLayer << mPolysLayer << mPointsLayer << mLinesLayer );
|
|
||||||
ms.setCrsTransformEnabled( true );
|
|
||||||
|
|
||||||
mComposition = new QgsComposition( ms, QgsProject::instance() );
|
QList<QgsMapLayer*> layers = QList<QgsMapLayer*>() << mRasterLayer << mPolysLayer << mPointsLayer << mLinesLayer;
|
||||||
|
|
||||||
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
||||||
mComposerMap->setFrameEnabled( true );
|
mComposerMap->setFrameEnabled( true );
|
||||||
|
mComposerMap->setLayers( layers );
|
||||||
mComposition->addComposerMap( mComposerMap );
|
mComposition->addComposerMap( mComposerMap );
|
||||||
|
|
||||||
QgsMapThemeCollection::MapThemeRecord rec;
|
QgsMapThemeCollection::MapThemeRecord rec;
|
||||||
@ -366,7 +360,7 @@ void TestQgsComposerMap::dataDefinedStyles()
|
|||||||
//test malformed style string
|
//test malformed style string
|
||||||
mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "5" ) ) );
|
mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "5" ) ) );
|
||||||
result = mComposerMap->layersToRender().toSet();
|
result = mComposerMap->layersToRender().toSet();
|
||||||
QCOMPARE( result, ms.layers().toSet() );
|
QCOMPARE( result, layers.toSet() );
|
||||||
|
|
||||||
//test valid preset
|
//test valid preset
|
||||||
mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'test preset'" ) ) );
|
mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'test preset'" ) ) );
|
||||||
@ -378,7 +372,7 @@ void TestQgsComposerMap::dataDefinedStyles()
|
|||||||
//test non-existent preset
|
//test non-existent preset
|
||||||
mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'bad preset'" ) ) );
|
mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'bad preset'" ) ) );
|
||||||
result = mComposerMap->layersToRender().toSet();
|
result = mComposerMap->layersToRender().toSet();
|
||||||
QCOMPARE( result, ms.layers().toSet() );
|
QCOMPARE( result, layers.toSet() );
|
||||||
|
|
||||||
//test that dd layer set overrides style layers
|
//test that dd layer set overrides style layers
|
||||||
mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'test preset'" ) ) );
|
mComposerMap->dataDefinedProperties().setProperty( QgsComposerObject::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'test preset'" ) ) );
|
||||||
|
@ -101,7 +101,7 @@ void TestQgsComposerMapGrid::init()
|
|||||||
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem( 32633 );
|
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem( 32633 );
|
||||||
mMapSettings->setDestinationCrs( crs );
|
mMapSettings->setDestinationCrs( crs );
|
||||||
mMapSettings->setCrsTransformEnabled( false );
|
mMapSettings->setCrsTransformEnabled( false );
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
||||||
mComposerMap->setFrameEnabled( true );
|
mComposerMap->setFrameEnabled( true );
|
||||||
|
@ -36,7 +36,6 @@ class TestQgsComposerMapOverview : public QObject
|
|||||||
TestQgsComposerMapOverview()
|
TestQgsComposerMapOverview()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mComposerMap( 0 )
|
, mComposerMap( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
, mRasterLayer( 0 )
|
, mRasterLayer( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -55,7 +54,6 @@ class TestQgsComposerMapOverview : public QObject
|
|||||||
private:
|
private:
|
||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
QgsComposerMap* mComposerMap;
|
QgsComposerMap* mComposerMap;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QgsRasterLayer* mRasterLayer;
|
QgsRasterLayer* mRasterLayer;
|
||||||
QString mReport;
|
QString mReport;
|
||||||
};
|
};
|
||||||
@ -65,8 +63,6 @@ void TestQgsComposerMapOverview::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create maplayers from testdata and add to layer registry
|
//create maplayers from testdata and add to layer registry
|
||||||
QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/rgb256x256.png" );
|
QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/rgb256x256.png" );
|
||||||
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
|
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
|
||||||
@ -75,12 +71,11 @@ void TestQgsComposerMapOverview::initTestCase()
|
|||||||
mRasterLayer->setRenderer( rasterRenderer );
|
mRasterLayer->setRenderer( rasterRenderer );
|
||||||
|
|
||||||
//create composition with composer map
|
//create composition with composer map
|
||||||
mMapSettings->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mMapSettings->setCrsTransformEnabled( false );
|
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
|
||||||
mComposerMap->setFrameEnabled( true );
|
mComposerMap->setFrameEnabled( true );
|
||||||
|
mComposerMap->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
mComposition->addComposerMap( mComposerMap );
|
mComposition->addComposerMap( mComposerMap );
|
||||||
|
|
||||||
mReport = QStringLiteral( "<h1>Composer Map Overview Tests</h1>\n" );
|
mReport = QStringLiteral( "<h1>Composer Map Overview Tests</h1>\n" );
|
||||||
@ -89,7 +84,6 @@ void TestQgsComposerMapOverview::initTestCase()
|
|||||||
void TestQgsComposerMapOverview::cleanupTestCase()
|
void TestQgsComposerMapOverview::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
delete mRasterLayer;
|
delete mRasterLayer;
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
@ -116,6 +110,7 @@ void TestQgsComposerMapOverview::overviewMap()
|
|||||||
{
|
{
|
||||||
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
||||||
overviewMap->setFrameEnabled( true );
|
overviewMap->setFrameEnabled( true );
|
||||||
|
overviewMap->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
mComposition->addComposerMap( overviewMap );
|
mComposition->addComposerMap( overviewMap );
|
||||||
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
|
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
|
||||||
overviewMap->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
|
overviewMap->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
|
||||||
@ -132,6 +127,7 @@ void TestQgsComposerMapOverview::overviewMapRotated()
|
|||||||
{
|
{
|
||||||
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
||||||
overviewMap->setFrameEnabled( true );
|
overviewMap->setFrameEnabled( true );
|
||||||
|
overviewMap->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
mComposition->addComposerMap( overviewMap );
|
mComposition->addComposerMap( overviewMap );
|
||||||
mComposerMap->setNewExtent( QgsRectangle( 96, -144, 160, -112 ) ); //zoom in
|
mComposerMap->setNewExtent( QgsRectangle( 96, -144, 160, -112 ) ); //zoom in
|
||||||
mComposerMap->setMapRotation( 30 );
|
mComposerMap->setMapRotation( 30 );
|
||||||
@ -150,6 +146,7 @@ void TestQgsComposerMapOverview::overviewMapRotated2()
|
|||||||
{
|
{
|
||||||
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
||||||
overviewMap->setFrameEnabled( true );
|
overviewMap->setFrameEnabled( true );
|
||||||
|
overviewMap->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
mComposition->addComposerMap( overviewMap );
|
mComposition->addComposerMap( overviewMap );
|
||||||
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
|
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
|
||||||
overviewMap->setMapRotation( 30 );
|
overviewMap->setMapRotation( 30 );
|
||||||
@ -167,6 +164,7 @@ void TestQgsComposerMapOverview::overviewMapBlending()
|
|||||||
{
|
{
|
||||||
QgsComposerMap* overviewMapBlend = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
QgsComposerMap* overviewMapBlend = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
||||||
overviewMapBlend->setFrameEnabled( true );
|
overviewMapBlend->setFrameEnabled( true );
|
||||||
|
overviewMapBlend->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
mComposition->addComposerMap( overviewMapBlend );
|
mComposition->addComposerMap( overviewMapBlend );
|
||||||
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
|
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
|
||||||
overviewMapBlend->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
|
overviewMapBlend->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
|
||||||
@ -185,6 +183,7 @@ void TestQgsComposerMapOverview::overviewMapInvert()
|
|||||||
{
|
{
|
||||||
QgsComposerMap* overviewMapInvert = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
QgsComposerMap* overviewMapInvert = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
||||||
overviewMapInvert->setFrameEnabled( true );
|
overviewMapInvert->setFrameEnabled( true );
|
||||||
|
overviewMapInvert->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
mComposition->addComposerMap( overviewMapInvert );
|
mComposition->addComposerMap( overviewMapInvert );
|
||||||
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
|
mComposerMap->setNewExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in
|
||||||
overviewMapInvert->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
|
overviewMapInvert->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
|
||||||
@ -203,6 +202,7 @@ void TestQgsComposerMapOverview::overviewMapCenter()
|
|||||||
{
|
{
|
||||||
QgsComposerMap* overviewMapCenter = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
QgsComposerMap* overviewMapCenter = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
|
||||||
overviewMapCenter->setFrameEnabled( true );
|
overviewMapCenter->setFrameEnabled( true );
|
||||||
|
overviewMapCenter->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
mComposition->addComposerMap( overviewMapCenter );
|
mComposition->addComposerMap( overviewMapCenter );
|
||||||
mComposerMap->setNewExtent( QgsRectangle( 192, -288, 320, -224 ) );
|
mComposerMap->setNewExtent( QgsRectangle( 192, -288, 320, -224 ) );
|
||||||
overviewMapCenter->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
|
overviewMapCenter->setNewExtent( QgsRectangle( 0, -256, 256, 0 ) );
|
||||||
|
@ -33,7 +33,6 @@ class TestQgsComposerModel : public QObject
|
|||||||
public:
|
public:
|
||||||
TestQgsComposerModel()
|
TestQgsComposerModel()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
, mItem1( 0 )
|
, mItem1( 0 )
|
||||||
, mItem2( 0 )
|
, mItem2( 0 )
|
||||||
, mItem3( 0 )
|
, mItem3( 0 )
|
||||||
@ -66,7 +65,6 @@ class TestQgsComposerModel : public QObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QgsComposition *mComposition;
|
QgsComposition *mComposition;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QgsComposerLabel *mItem1;
|
QgsComposerLabel *mItem1;
|
||||||
QgsComposerLabel *mItem2;
|
QgsComposerLabel *mItem2;
|
||||||
QgsComposerLabel *mItem3;
|
QgsComposerLabel *mItem3;
|
||||||
@ -77,8 +75,7 @@ void TestQgsComposerModel::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
}
|
}
|
||||||
@ -89,7 +86,6 @@ void TestQgsComposerModel::cleanupTestCase()
|
|||||||
delete mItem2;
|
delete mItem2;
|
||||||
delete mItem3;
|
delete mItem3;
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
QgsApplication::exitQgis();
|
QgsApplication::exitQgis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,13 +46,11 @@ class TestQgsComposerMultiFrame : public QObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QgsComposition *mComposition;
|
QgsComposition *mComposition;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QString mReport;
|
QString mReport;
|
||||||
};
|
};
|
||||||
|
|
||||||
TestQgsComposerMultiFrame::TestQgsComposerMultiFrame()
|
TestQgsComposerMultiFrame::TestQgsComposerMultiFrame()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,8 +59,7 @@ void TestQgsComposerMultiFrame::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
mReport = QStringLiteral( "<h1>Composer MultiFrame Tests</h1>\n" );
|
mReport = QStringLiteral( "<h1>Composer MultiFrame Tests</h1>\n" );
|
||||||
@ -71,7 +68,6 @@ void TestQgsComposerMultiFrame::initTestCase()
|
|||||||
void TestQgsComposerMultiFrame::cleanupTestCase()
|
void TestQgsComposerMultiFrame::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
QFile myFile( myReportFile );
|
QFile myFile( myReportFile );
|
||||||
|
@ -33,7 +33,6 @@ class TestQgsComposerObject : public QObject
|
|||||||
public:
|
public:
|
||||||
TestQgsComposerObject()
|
TestQgsComposerObject()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +51,6 @@ class TestQgsComposerObject : public QObject
|
|||||||
private:
|
private:
|
||||||
bool renderCheck( const QString& testName, QImage &image, int mismatchCount = 0 );
|
bool renderCheck( const QString& testName, QImage &image, int mismatchCount = 0 );
|
||||||
QgsComposition *mComposition;
|
QgsComposition *mComposition;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QString mReport;
|
QString mReport;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -62,8 +60,7 @@ void TestQgsComposerObject::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
mReport = QStringLiteral( "<h1>Composer Object Tests</h1>\n" );
|
mReport = QStringLiteral( "<h1>Composer Object Tests</h1>\n" );
|
||||||
@ -72,7 +69,6 @@ void TestQgsComposerObject::initTestCase()
|
|||||||
void TestQgsComposerObject::cleanupTestCase()
|
void TestQgsComposerObject::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
QFile myFile( myReportFile );
|
QFile myFile( myReportFile );
|
||||||
|
@ -37,7 +37,6 @@ class TestQgsComposerPaper : public QObject
|
|||||||
public:
|
public:
|
||||||
TestQgsComposerPaper()
|
TestQgsComposerPaper()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -54,7 +53,6 @@ class TestQgsComposerPaper : public QObject
|
|||||||
private:
|
private:
|
||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
QString mReport;
|
QString mReport;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
// QgsSingleSymbolRenderer* mSymbolRenderer;
|
// QgsSingleSymbolRenderer* mSymbolRenderer;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -65,8 +63,7 @@ void TestQgsComposerPaper::initTestCase()
|
|||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
//create empty composition
|
//create empty composition
|
||||||
mMapSettings = new QgsMapSettings();
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
mReport = QStringLiteral( "<h1>Composer Paper Tests</h1>\n" );
|
mReport = QStringLiteral( "<h1>Composer Paper Tests</h1>\n" );
|
||||||
@ -75,7 +72,6 @@ void TestQgsComposerPaper::initTestCase()
|
|||||||
void TestQgsComposerPaper::cleanupTestCase()
|
void TestQgsComposerPaper::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
QFile myFile( myReportFile );
|
QFile myFile( myReportFile );
|
||||||
|
@ -67,7 +67,6 @@ class TestQgsComposerPicture : public QObject
|
|||||||
private:
|
private:
|
||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
QgsComposerPicture* mComposerPicture;
|
QgsComposerPicture* mComposerPicture;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QString mReport;
|
QString mReport;
|
||||||
QString mPngImage;
|
QString mPngImage;
|
||||||
QString mSvgImage;
|
QString mSvgImage;
|
||||||
@ -77,7 +76,6 @@ class TestQgsComposerPicture : public QObject
|
|||||||
TestQgsComposerPicture::TestQgsComposerPicture()
|
TestQgsComposerPicture::TestQgsComposerPicture()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mComposerPicture( 0 )
|
, mComposerPicture( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -87,13 +85,11 @@ void TestQgsComposerPicture::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
mPngImage = QStringLiteral( TEST_DATA_DIR ) + "/sample_image.png";
|
mPngImage = QStringLiteral( TEST_DATA_DIR ) + "/sample_image.png";
|
||||||
mSvgImage = QStringLiteral( TEST_DATA_DIR ) + "/sample_svg.svg";
|
mSvgImage = QStringLiteral( TEST_DATA_DIR ) + "/sample_svg.svg";
|
||||||
mSvgParamsImage = QStringLiteral( TEST_DATA_DIR ) + "/svg_params.svg";
|
mSvgParamsImage = QStringLiteral( TEST_DATA_DIR ) + "/svg_params.svg";
|
||||||
|
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
mComposerPicture = new QgsComposerPicture( mComposition );
|
mComposerPicture = new QgsComposerPicture( mComposition );
|
||||||
@ -108,7 +104,6 @@ void TestQgsComposerPicture::cleanupTestCase()
|
|||||||
{
|
{
|
||||||
delete mComposerPicture;
|
delete mComposerPicture;
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
QFile myFile( myReportFile );
|
QFile myFile( myReportFile );
|
||||||
|
@ -41,7 +41,6 @@ class TestQgsComposerRotation : public QObject
|
|||||||
, mComposerRect( 0 )
|
, mComposerRect( 0 )
|
||||||
, mComposerLabel( 0 )
|
, mComposerLabel( 0 )
|
||||||
, mComposerMap( 0 )
|
, mComposerMap( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
, mRasterLayer( 0 )
|
, mRasterLayer( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -61,7 +60,6 @@ class TestQgsComposerRotation : public QObject
|
|||||||
QgsComposerShape* mComposerRect;
|
QgsComposerShape* mComposerRect;
|
||||||
QgsComposerLabel* mComposerLabel;
|
QgsComposerLabel* mComposerLabel;
|
||||||
QgsComposerMap* mComposerMap;
|
QgsComposerMap* mComposerMap;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QgsRasterLayer* mRasterLayer;
|
QgsRasterLayer* mRasterLayer;
|
||||||
QString mReport;
|
QString mReport;
|
||||||
};
|
};
|
||||||
@ -71,8 +69,6 @@ void TestQgsComposerRotation::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create maplayers from testdata and add to layer registry
|
//create maplayers from testdata and add to layer registry
|
||||||
QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/rgb256x256.png" );
|
QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/rgb256x256.png" );
|
||||||
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
|
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
|
||||||
@ -80,10 +76,7 @@ void TestQgsComposerRotation::initTestCase()
|
|||||||
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 );
|
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 );
|
||||||
mRasterLayer->setRenderer( rasterRenderer );
|
mRasterLayer->setRenderer( rasterRenderer );
|
||||||
|
|
||||||
mMapSettings->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mMapSettings->setCrsTransformEnabled( false );
|
|
||||||
|
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
mComposerRect = new QgsComposerShape( 70, 70, 150, 100, mComposition );
|
mComposerRect = new QgsComposerShape( 70, 70, 150, 100, mComposition );
|
||||||
@ -112,7 +105,6 @@ void TestQgsComposerRotation::cleanupTestCase()
|
|||||||
delete mComposerLabel;
|
delete mComposerLabel;
|
||||||
delete mComposerRect;
|
delete mComposerRect;
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
delete mRasterLayer;
|
delete mRasterLayer;
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
@ -173,6 +165,7 @@ void TestQgsComposerRotation::mapRotation()
|
|||||||
mComposition->addItem( mComposerMap );
|
mComposition->addItem( mComposerMap );
|
||||||
mComposerMap->setNewExtent( QgsRectangle( 0, -192, 256, -64 ) );
|
mComposerMap->setNewExtent( QgsRectangle( 0, -192, 256, -64 ) );
|
||||||
mComposerMap->setMapRotation( 90 );
|
mComposerMap->setMapRotation( 90 );
|
||||||
|
mComposerMap->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
|
|
||||||
QgsCompositionChecker checker( QStringLiteral( "composerrotation_maprotation" ), mComposition );
|
QgsCompositionChecker checker( QStringLiteral( "composerrotation_maprotation" ), mComposition );
|
||||||
checker.setControlPathPrefix( QStringLiteral( "composer_items" ) );
|
checker.setControlPathPrefix( QStringLiteral( "composer_items" ) );
|
||||||
@ -191,6 +184,7 @@ void TestQgsComposerRotation::mapItemRotation()
|
|||||||
mComposition->addItem( mComposerMap );
|
mComposition->addItem( mComposerMap );
|
||||||
mComposerMap->setNewExtent( QgsRectangle( 0, -192, 256, -64 ) );
|
mComposerMap->setNewExtent( QgsRectangle( 0, -192, 256, -64 ) );
|
||||||
mComposerMap->setItemRotation( 90, true );
|
mComposerMap->setItemRotation( 90, true );
|
||||||
|
mComposerMap->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
|
|
||||||
QgsCompositionChecker checker( QStringLiteral( "composerrotation_mapitemrotation" ), mComposition );
|
QgsCompositionChecker checker( QStringLiteral( "composerrotation_mapitemrotation" ), mComposition );
|
||||||
checker.setControlPathPrefix( QStringLiteral( "composer_items" ) );
|
checker.setControlPathPrefix( QStringLiteral( "composer_items" ) );
|
||||||
|
@ -41,7 +41,6 @@ class TestQgsComposerScaleBar : public QObject
|
|||||||
, mComposerMap( 0 )
|
, mComposerMap( 0 )
|
||||||
, mComposerScaleBar( 0 )
|
, mComposerScaleBar( 0 )
|
||||||
, mRasterLayer( 0 )
|
, mRasterLayer( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -61,7 +60,6 @@ class TestQgsComposerScaleBar : public QObject
|
|||||||
QgsComposerMap* mComposerMap;
|
QgsComposerMap* mComposerMap;
|
||||||
QgsComposerScaleBar* mComposerScaleBar;
|
QgsComposerScaleBar* mComposerScaleBar;
|
||||||
QgsRasterLayer* mRasterLayer;
|
QgsRasterLayer* mRasterLayer;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QString mReport;
|
QString mReport;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,8 +80,6 @@ void TestQgsComposerScaleBar::initTestCase()
|
|||||||
QgsProject::instance()->setCrs( destCRS );
|
QgsProject::instance()->setCrs( destCRS );
|
||||||
QgsProject::instance()->setEllipsoid( QStringLiteral( "WGS84" ) );
|
QgsProject::instance()->setEllipsoid( QStringLiteral( "WGS84" ) );
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create maplayers from testdata and add to layer registry
|
//create maplayers from testdata and add to layer registry
|
||||||
QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" );
|
QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" );
|
||||||
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
|
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
|
||||||
@ -92,14 +88,14 @@ void TestQgsComposerScaleBar::initTestCase()
|
|||||||
mRasterLayer->setRenderer( rasterRenderer );
|
mRasterLayer->setRenderer( rasterRenderer );
|
||||||
|
|
||||||
//create composition with composer map
|
//create composition with composer map
|
||||||
mMapSettings->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
|
||||||
|
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 150, 150 );
|
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 150, 150 );
|
||||||
mComposerMap->setFrameEnabled( true );
|
mComposerMap->setFrameEnabled( true );
|
||||||
mComposition->addComposerMap( mComposerMap );
|
mComposition->addComposerMap( mComposerMap );
|
||||||
mComposerMap->setNewExtent( QgsRectangle( 17.923, 30.160, 18.023, 30.260 ) );
|
mComposerMap->setNewExtent( QgsRectangle( 17.923, 30.160, 18.023, 30.260 ) );
|
||||||
|
mComposerMap->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
|
||||||
|
|
||||||
mComposerScaleBar = new QgsComposerScaleBar( mComposition );
|
mComposerScaleBar = new QgsComposerScaleBar( mComposition );
|
||||||
mComposerScaleBar->setSceneRect( QRectF( 20, 180, 50, 20 ) );
|
mComposerScaleBar->setSceneRect( QRectF( 20, 180, 50, 20 ) );
|
||||||
@ -121,7 +117,6 @@ void TestQgsComposerScaleBar::initTestCase()
|
|||||||
void TestQgsComposerScaleBar::cleanupTestCase()
|
void TestQgsComposerScaleBar::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
delete mRasterLayer;
|
delete mRasterLayer;
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
|
@ -37,7 +37,6 @@ class TestQgsComposerShapes : public QObject
|
|||||||
TestQgsComposerShapes()
|
TestQgsComposerShapes()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mComposerShape( 0 )
|
, mComposerShape( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -54,7 +53,6 @@ class TestQgsComposerShapes : public QObject
|
|||||||
private:
|
private:
|
||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
QgsComposerShape* mComposerShape;
|
QgsComposerShape* mComposerShape;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QString mReport;
|
QString mReport;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,10 +61,8 @@ void TestQgsComposerShapes::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create composition with two rectangles
|
//create composition with two rectangles
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposerShape = new QgsComposerShape( 20, 20, 150, 100, mComposition );
|
mComposerShape = new QgsComposerShape( 20, 20, 150, 100, mComposition );
|
||||||
mComposerShape->setBackgroundColor( QColor::fromRgb( 255, 150, 0 ) );
|
mComposerShape->setBackgroundColor( QColor::fromRgb( 255, 150, 0 ) );
|
||||||
@ -78,7 +74,6 @@ void TestQgsComposerShapes::initTestCase()
|
|||||||
void TestQgsComposerShapes::cleanupTestCase()
|
void TestQgsComposerShapes::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
QFile myFile( myReportFile );
|
QFile myFile( myReportFile );
|
||||||
|
@ -40,7 +40,6 @@ class TestQgsComposerTableV2 : public QObject
|
|||||||
public:
|
public:
|
||||||
TestQgsComposerTableV2()
|
TestQgsComposerTableV2()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
, mVectorLayer( 0 )
|
, mVectorLayer( 0 )
|
||||||
, mComposerAttributeTable( 0 )
|
, mComposerAttributeTable( 0 )
|
||||||
, mFrame1( 0 )
|
, mFrame1( 0 )
|
||||||
@ -79,7 +78,6 @@ class TestQgsComposerTableV2 : public QObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QgsVectorLayer* mVectorLayer;
|
QgsVectorLayer* mVectorLayer;
|
||||||
QgsComposerAttributeTableV2* mComposerAttributeTable;
|
QgsComposerAttributeTableV2* mComposerAttributeTable;
|
||||||
QgsComposerFrame* mFrame1;
|
QgsComposerFrame* mFrame1;
|
||||||
@ -95,8 +93,6 @@ void TestQgsComposerTableV2::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create maplayers from testdata and add to layer registry
|
//create maplayers from testdata and add to layer registry
|
||||||
QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" );
|
QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" );
|
||||||
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
|
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
|
||||||
@ -104,16 +100,11 @@ void TestQgsComposerTableV2::initTestCase()
|
|||||||
QStringLiteral( "ogr" ) );
|
QStringLiteral( "ogr" ) );
|
||||||
QgsProject::instance()->addMapLayer( mVectorLayer );
|
QgsProject::instance()->addMapLayer( mVectorLayer );
|
||||||
|
|
||||||
mMapSettings->setLayers( QList<QgsMapLayer*>() << mVectorLayer );
|
|
||||||
mMapSettings->setCrsTransformEnabled( false );
|
|
||||||
|
|
||||||
mReport = QStringLiteral( "<h1>Composer TableV2 Tests</h1>\n" );
|
mReport = QStringLiteral( "<h1>Composer TableV2 Tests</h1>\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsComposerTableV2::cleanupTestCase()
|
void TestQgsComposerTableV2::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
QFile myFile( myReportFile );
|
QFile myFile( myReportFile );
|
||||||
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
|
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
|
||||||
@ -128,7 +119,7 @@ void TestQgsComposerTableV2::cleanupTestCase()
|
|||||||
void TestQgsComposerTableV2::init()
|
void TestQgsComposerTableV2::init()
|
||||||
{
|
{
|
||||||
//create composition with composer map
|
//create composition with composer map
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 portrait
|
mComposition->setPaperSize( 297, 210 ); //A4 portrait
|
||||||
|
|
||||||
mComposerAttributeTable = new QgsComposerAttributeTableV2( mComposition, false );
|
mComposerAttributeTable = new QgsComposerAttributeTableV2( mComposition, false );
|
||||||
|
@ -67,7 +67,6 @@ class TestQgsComposerUtils : public QObject
|
|||||||
private:
|
private:
|
||||||
bool renderCheck( const QString& testName, QImage &image, int mismatchCount = 0 );
|
bool renderCheck( const QString& testName, QImage &image, int mismatchCount = 0 );
|
||||||
QgsComposition* mComposition;
|
QgsComposition* mComposition;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QString mReport;
|
QString mReport;
|
||||||
QFont mTestFont;
|
QFont mTestFont;
|
||||||
|
|
||||||
@ -75,7 +74,6 @@ class TestQgsComposerUtils : public QObject
|
|||||||
|
|
||||||
TestQgsComposerUtils::TestQgsComposerUtils()
|
TestQgsComposerUtils::TestQgsComposerUtils()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +83,7 @@ void TestQgsComposerUtils::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis(); //for access to test font
|
QgsApplication::initQgis(); //for access to test font
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
|
|
||||||
mReport = QStringLiteral( "<h1>Composer Utils Tests</h1>\n" );
|
mReport = QStringLiteral( "<h1>Composer Utils Tests</h1>\n" );
|
||||||
@ -100,7 +97,6 @@ void TestQgsComposerUtils::initTestCase()
|
|||||||
void TestQgsComposerUtils::cleanupTestCase()
|
void TestQgsComposerUtils::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QgsApplication::exitQgis();
|
QgsApplication::exitQgis();
|
||||||
|
|
||||||
@ -660,9 +656,7 @@ void TestQgsComposerUtils::createRenderContext()
|
|||||||
|
|
||||||
//create composition with no reference map
|
//create composition with no reference map
|
||||||
QgsRectangle extent( 2000, 2800, 2500, 2900 );
|
QgsRectangle extent( 2000, 2800, 2500, 2900 );
|
||||||
QgsMapSettings ms;
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
ms.setExtent( extent );
|
|
||||||
QgsComposition* composition = new QgsComposition( ms, QgsProject::instance() );
|
|
||||||
rc = QgsComposerUtils::createRenderContext( composition, &p );
|
rc = QgsComposerUtils::createRenderContext( composition, &p );
|
||||||
QGSCOMPARENEAR( rc.scaleFactor(), 150 / 25.4, 0.001 );
|
QGSCOMPARENEAR( rc.scaleFactor(), 150 / 25.4, 0.001 );
|
||||||
QCOMPARE( rc.painter(), &p );
|
QCOMPARE( rc.painter(), &p );
|
||||||
|
@ -61,14 +61,12 @@ class TestQgsComposition : public QObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QgsComposition *mComposition;
|
QgsComposition *mComposition;
|
||||||
QgsMapSettings *mMapSettings;
|
|
||||||
QString mReport;
|
QString mReport;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TestQgsComposition::TestQgsComposition()
|
TestQgsComposition::TestQgsComposition()
|
||||||
: mComposition( 0 )
|
: mComposition( 0 )
|
||||||
, mMapSettings( 0 )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,12 +75,8 @@ void TestQgsComposition::initTestCase()
|
|||||||
QgsApplication::init();
|
QgsApplication::init();
|
||||||
QgsApplication::initQgis();
|
QgsApplication::initQgis();
|
||||||
|
|
||||||
mMapSettings = new QgsMapSettings();
|
|
||||||
|
|
||||||
//create composition
|
//create composition
|
||||||
mMapSettings->setCrsTransformEnabled( true );
|
mComposition = new QgsComposition( QgsProject::instance() );
|
||||||
mMapSettings->setMapUnits( QgsUnitTypes::DistanceMeters );
|
|
||||||
mComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
|
||||||
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
mComposition->setPaperSize( 297, 210 ); //A4 landscape
|
||||||
mComposition->setNumPages( 3 );
|
mComposition->setNumPages( 3 );
|
||||||
|
|
||||||
@ -93,7 +87,6 @@ void TestQgsComposition::initTestCase()
|
|||||||
void TestQgsComposition::cleanupTestCase()
|
void TestQgsComposition::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete mComposition;
|
delete mComposition;
|
||||||
delete mMapSettings;
|
|
||||||
|
|
||||||
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
QString myReportFile = QDir::tempPath() + "/qgistest.html";
|
||||||
QFile myFile( myReportFile );
|
QFile myFile( myReportFile );
|
||||||
@ -273,7 +266,7 @@ void TestQgsComposition::pageIsEmpty()
|
|||||||
|
|
||||||
void TestQgsComposition::customProperties()
|
void TestQgsComposition::customProperties()
|
||||||
{
|
{
|
||||||
QgsComposition* composition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
|
|
||||||
QCOMPARE( composition->customProperty( "noprop", "defaultval" ).toString(), QString( "defaultval" ) );
|
QCOMPARE( composition->customProperty( "noprop", "defaultval" ).toString(), QString( "defaultval" ) );
|
||||||
QVERIFY( composition->customProperties().isEmpty() );
|
QVERIFY( composition->customProperties().isEmpty() );
|
||||||
@ -301,7 +294,7 @@ void TestQgsComposition::customProperties()
|
|||||||
|
|
||||||
void TestQgsComposition::writeRetrieveCustomProperties()
|
void TestQgsComposition::writeRetrieveCustomProperties()
|
||||||
{
|
{
|
||||||
QgsComposition* composition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
composition->setCustomProperty( QStringLiteral( "testprop" ), "testval" );
|
composition->setCustomProperty( QStringLiteral( "testprop" ), "testval" );
|
||||||
composition->setCustomProperty( QStringLiteral( "testprop2" ), 5 );
|
composition->setCustomProperty( QStringLiteral( "testprop2" ), 5 );
|
||||||
|
|
||||||
@ -320,7 +313,7 @@ void TestQgsComposition::writeRetrieveCustomProperties()
|
|||||||
QDomElement compositionElem = evalNodeList.at( 0 ).toElement();
|
QDomElement compositionElem = evalNodeList.at( 0 ).toElement();
|
||||||
|
|
||||||
//test reading node containing custom properties
|
//test reading node containing custom properties
|
||||||
QgsComposition* readComposition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
QgsComposition* readComposition = new QgsComposition( QgsProject::instance() );
|
||||||
QVERIFY( readComposition->readXml( compositionElem, doc ) );
|
QVERIFY( readComposition->readXml( compositionElem, doc ) );
|
||||||
|
|
||||||
//test retrieved custom properties
|
//test retrieved custom properties
|
||||||
@ -337,7 +330,7 @@ void TestQgsComposition::writeRetrieveCustomProperties()
|
|||||||
void TestQgsComposition::bounds()
|
void TestQgsComposition::bounds()
|
||||||
{
|
{
|
||||||
//add some items to a composition
|
//add some items to a composition
|
||||||
QgsComposition* composition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
QgsComposerShape* shape1 = new QgsComposerShape( composition );
|
QgsComposerShape* shape1 = new QgsComposerShape( composition );
|
||||||
shape1->setShapeType( QgsComposerShape::Rectangle );
|
shape1->setShapeType( QgsComposerShape::Rectangle );
|
||||||
composition->addComposerShape( shape1 );
|
composition->addComposerShape( shape1 );
|
||||||
@ -395,7 +388,7 @@ void TestQgsComposition::bounds()
|
|||||||
void TestQgsComposition::resizeToContents()
|
void TestQgsComposition::resizeToContents()
|
||||||
{
|
{
|
||||||
//add some items to a composition
|
//add some items to a composition
|
||||||
QgsComposition* composition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
QgsSimpleFillSymbolLayer* simpleFill = new QgsSimpleFillSymbolLayer();
|
QgsSimpleFillSymbolLayer* simpleFill = new QgsSimpleFillSymbolLayer();
|
||||||
QgsFillSymbol* fillSymbol = new QgsFillSymbol();
|
QgsFillSymbol* fillSymbol = new QgsFillSymbol();
|
||||||
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
||||||
@ -436,7 +429,7 @@ void TestQgsComposition::resizeToContentsMargin()
|
|||||||
{
|
{
|
||||||
//resize to contents, with margin
|
//resize to contents, with margin
|
||||||
|
|
||||||
QgsComposition* composition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
QgsSimpleFillSymbolLayer* simpleFill = new QgsSimpleFillSymbolLayer();
|
QgsSimpleFillSymbolLayer* simpleFill = new QgsSimpleFillSymbolLayer();
|
||||||
QgsFillSymbol* fillSymbol = new QgsFillSymbol();
|
QgsFillSymbol* fillSymbol = new QgsFillSymbol();
|
||||||
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
||||||
@ -477,7 +470,7 @@ void TestQgsComposition::resizeToContentsMultiPage()
|
|||||||
{
|
{
|
||||||
//resize to contents with multi-page composition, should result in a single page
|
//resize to contents with multi-page composition, should result in a single page
|
||||||
|
|
||||||
QgsComposition* composition = new QgsComposition( *mMapSettings, QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
QgsSimpleFillSymbolLayer* simpleFill = new QgsSimpleFillSymbolLayer();
|
QgsSimpleFillSymbolLayer* simpleFill = new QgsSimpleFillSymbolLayer();
|
||||||
QgsFillSymbol* fillSymbol = new QgsFillSymbol();
|
QgsFillSymbol* fillSymbol = new QgsFillSymbol();
|
||||||
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
fillSymbol->changeSymbolLayer( 0, simpleFill );
|
||||||
@ -521,9 +514,7 @@ void TestQgsComposition::resizeToContentsMultiPage()
|
|||||||
void TestQgsComposition::georeference()
|
void TestQgsComposition::georeference()
|
||||||
{
|
{
|
||||||
QgsRectangle extent( 2000, 2800, 2500, 2900 );
|
QgsRectangle extent( 2000, 2800, 2500, 2900 );
|
||||||
QgsMapSettings ms;
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
ms.setExtent( extent );
|
|
||||||
QgsComposition* composition = new QgsComposition( ms, QgsProject::instance() );
|
|
||||||
|
|
||||||
// no map
|
// no map
|
||||||
double* t = composition->computeGeoTransform( nullptr );
|
double* t = composition->computeGeoTransform( nullptr );
|
||||||
@ -590,8 +581,7 @@ void TestQgsComposition::georeference()
|
|||||||
|
|
||||||
void TestQgsComposition::variablesEdited()
|
void TestQgsComposition::variablesEdited()
|
||||||
{
|
{
|
||||||
QgsMapSettings ms;
|
QgsComposition c( QgsProject::instance() );
|
||||||
QgsComposition c( ms, QgsProject::instance() );
|
|
||||||
QSignalSpy spyVariablesChanged( &c, SIGNAL( variablesChanged() ) );
|
QSignalSpy spyVariablesChanged( &c, SIGNAL( variablesChanged() ) );
|
||||||
|
|
||||||
c.setCustomProperty( QStringLiteral( "not a variable" ), "1" );
|
c.setCustomProperty( QStringLiteral( "not a variable" ), "1" );
|
||||||
@ -605,9 +595,7 @@ void TestQgsComposition::variablesEdited()
|
|||||||
void TestQgsComposition::itemVariablesFunction()
|
void TestQgsComposition::itemVariablesFunction()
|
||||||
{
|
{
|
||||||
QgsRectangle extent( 2000, 2800, 2500, 2900 );
|
QgsRectangle extent( 2000, 2800, 2500, 2900 );
|
||||||
QgsMapSettings ms;
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
ms.setExtent( extent );
|
|
||||||
QgsComposition* composition = new QgsComposition( ms, QgsProject::instance() );
|
|
||||||
|
|
||||||
QgsExpression e( "map_get( item_variables( 'map_id' ), 'map_scale' )" );
|
QgsExpression e( "map_get( item_variables( 'map_id' ), 'map_scale' )" );
|
||||||
// no map
|
// no map
|
||||||
@ -644,9 +632,7 @@ void TestQgsComposition::itemVariablesFunction()
|
|||||||
void TestQgsComposition::referenceMap()
|
void TestQgsComposition::referenceMap()
|
||||||
{
|
{
|
||||||
QgsRectangle extent( 2000, 2800, 2500, 2900 );
|
QgsRectangle extent( 2000, 2800, 2500, 2900 );
|
||||||
QgsMapSettings ms;
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
ms.setExtent( extent );
|
|
||||||
QgsComposition* composition = new QgsComposition( ms, QgsProject::instance() );
|
|
||||||
|
|
||||||
// no maps
|
// no maps
|
||||||
QVERIFY( !composition->referenceMap() );
|
QVERIFY( !composition->referenceMap() );
|
||||||
|
@ -864,7 +864,6 @@ void TestQgsPaintEffect::composer()
|
|||||||
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
|
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
|
||||||
lineLayer->setSimplifyMethod( simplifyMethod );
|
lineLayer->setSimplifyMethod( simplifyMethod );
|
||||||
|
|
||||||
QgsMapSettings ms;
|
|
||||||
QgsSimpleLineSymbolLayer* line = new QgsSimpleLineSymbolLayer;
|
QgsSimpleLineSymbolLayer* line = new QgsSimpleLineSymbolLayer;
|
||||||
line->setColor( QColor( 255, 0, 0 ) );
|
line->setColor( QColor( 255, 0, 0 ) );
|
||||||
line->setWidth( 1.0 );
|
line->setWidth( 1.0 );
|
||||||
@ -878,15 +877,14 @@ void TestQgsPaintEffect::composer()
|
|||||||
renderer->setPaintEffect( effect );
|
renderer->setPaintEffect( effect );
|
||||||
|
|
||||||
lineLayer->setRenderer( renderer );
|
lineLayer->setRenderer( renderer );
|
||||||
ms.setLayers( QList<QgsMapLayer*>() << lineLayer );
|
|
||||||
ms.setCrsTransformEnabled( false );
|
|
||||||
|
|
||||||
QgsComposition* composition = new QgsComposition( ms, QgsProject::instance() );
|
QgsComposition* composition = new QgsComposition( QgsProject::instance() );
|
||||||
composition->setPaperSize( 50, 50 );
|
composition->setPaperSize( 50, 50 );
|
||||||
QgsComposerMap* composerMap = new QgsComposerMap( composition, 1, 1, 48, 48 );
|
QgsComposerMap* composerMap = new QgsComposerMap( composition, 1, 1, 48, 48 );
|
||||||
composerMap->setFrameEnabled( true );
|
composerMap->setFrameEnabled( true );
|
||||||
composition->addComposerMap( composerMap );
|
composition->addComposerMap( composerMap );
|
||||||
composerMap->setNewExtent( lineLayer->extent() );
|
composerMap->setNewExtent( lineLayer->extent() );
|
||||||
|
composerMap->setLayers( QList<QgsMapLayer*>() << lineLayer );
|
||||||
|
|
||||||
QImage outputImage( 591, 591, QImage::Format_RGB32 );
|
QImage outputImage( 591, 591, QImage::Format_RGB32 );
|
||||||
composition->setPlotStyle( QgsComposition::Print );
|
composition->setPlotStyle( QgsComposition::Print );
|
||||||
|
@ -41,18 +41,16 @@ class TestQgsAtlasComposition(unittest.TestCase):
|
|||||||
mVectorLayer = QgsVectorLayer(vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr")
|
mVectorLayer = QgsVectorLayer(vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr")
|
||||||
|
|
||||||
QgsProject.instance().addMapLayers([mVectorLayer])
|
QgsProject.instance().addMapLayers([mVectorLayer])
|
||||||
|
self.layers = [mVectorLayer]
|
||||||
|
|
||||||
# create composition with composer map
|
# create composition with composer map
|
||||||
self.mapSettings = QgsMapSettings()
|
|
||||||
layerStringList = [mVectorLayer]
|
|
||||||
self.mapSettings.setLayers(layerStringList)
|
|
||||||
|
|
||||||
# select epsg:2154
|
# select epsg:2154
|
||||||
crs = QgsCoordinateReferenceSystem()
|
crs = QgsCoordinateReferenceSystem()
|
||||||
crs.createFromSrid(2154)
|
crs.createFromSrid(2154)
|
||||||
QgsProject.instance().setCrs(crs)
|
QgsProject.instance().setCrs(crs)
|
||||||
|
|
||||||
self.mComposition = QgsComposition(self.mapSettings, QgsProject.instance())
|
self.mComposition = QgsComposition(QgsProject.instance())
|
||||||
self.mComposition.setPaperSize(297, 210)
|
self.mComposition.setPaperSize(297, 210)
|
||||||
|
|
||||||
# fix the renderer, fill with green
|
# fix the renderer, fill with green
|
||||||
@ -64,6 +62,7 @@ class TestQgsAtlasComposition(unittest.TestCase):
|
|||||||
# the atlas map
|
# the atlas map
|
||||||
self.mAtlasMap = QgsComposerMap(self.mComposition, 20, 20, 130, 130)
|
self.mAtlasMap = QgsComposerMap(self.mComposition, 20, 20, 130, 130)
|
||||||
self.mAtlasMap.setFrameEnabled(True)
|
self.mAtlasMap.setFrameEnabled(True)
|
||||||
|
self.mAtlasMap.setLayers([mVectorLayer])
|
||||||
self.mComposition.addComposerMap(self.mAtlasMap)
|
self.mComposition.addComposerMap(self.mAtlasMap)
|
||||||
|
|
||||||
# the atlas
|
# the atlas
|
||||||
@ -73,17 +72,18 @@ class TestQgsAtlasComposition(unittest.TestCase):
|
|||||||
self.mComposition.setAtlasMode(QgsComposition.ExportAtlas)
|
self.mComposition.setAtlasMode(QgsComposition.ExportAtlas)
|
||||||
|
|
||||||
# an overview
|
# an overview
|
||||||
mOverview = QgsComposerMap(self.mComposition, 180, 20, 50, 50)
|
self.mOverview = QgsComposerMap(self.mComposition, 180, 20, 50, 50)
|
||||||
mOverview.setFrameEnabled(True)
|
self.mOverview.setFrameEnabled(True)
|
||||||
mOverview.overview().setFrameMap(self.mAtlasMap.id())
|
self.mOverview.overview().setFrameMap(self.mAtlasMap.id())
|
||||||
self.mComposition.addComposerMap(mOverview)
|
self.mOverview.setLayers([mVectorLayer])
|
||||||
|
self.mComposition.addComposerMap(self.mOverview)
|
||||||
nextent = QgsRectangle(49670.718, 6415139.086, 699672.519, 7065140.887)
|
nextent = QgsRectangle(49670.718, 6415139.086, 699672.519, 7065140.887)
|
||||||
mOverview.setNewExtent(nextent)
|
self.mOverview.setNewExtent(nextent)
|
||||||
|
|
||||||
# set the fill symbol of the overview map
|
# set the fill symbol of the overview map
|
||||||
props2 = {"color": "127,0,0,127"}
|
props2 = {"color": "127,0,0,127"}
|
||||||
fillSymbol2 = QgsFillSymbol.createSimple(props2)
|
fillSymbol2 = QgsFillSymbol.createSimple(props2)
|
||||||
mOverview.overview().setFrameSymbol(fillSymbol2)
|
self.mOverview.overview().setFrameSymbol(fillSymbol2)
|
||||||
|
|
||||||
# header label
|
# header label
|
||||||
self.mLabel1 = QgsComposerLabel(self.mComposition)
|
self.mLabel1 = QgsComposerLabel(self.mComposition)
|
||||||
@ -282,9 +282,10 @@ class TestQgsAtlasComposition(unittest.TestCase):
|
|||||||
QgsProject.instance().addMapLayer(ptLayer)
|
QgsProject.instance().addMapLayer(ptLayer)
|
||||||
|
|
||||||
# add the point layer to the map settings
|
# add the point layer to the map settings
|
||||||
layers = self.mapSettings.layers()
|
layers = self.layers
|
||||||
layers = [ptLayer] + layers
|
layers = [ptLayer] + layers
|
||||||
self.mapSettings.setLayers(layers)
|
self.mAtlasMap.setLayers(layers)
|
||||||
|
self.mOverview.setLayers(layers)
|
||||||
|
|
||||||
# add a legend
|
# add a legend
|
||||||
legend = QgsComposerLegend(self.mComposition)
|
legend = QgsComposerLegend(self.mComposition)
|
||||||
@ -306,7 +307,7 @@ class TestQgsAtlasComposition(unittest.TestCase):
|
|||||||
self.mAtlas.endRender()
|
self.mAtlas.endRender()
|
||||||
|
|
||||||
# restore state
|
# restore state
|
||||||
self.mapSettings.setLayers([layers[1]])
|
self.mAtlasMap.setLayers([layers[1]])
|
||||||
self.mComposition.removeComposerItem(legend)
|
self.mComposition.removeComposerItem(legend)
|
||||||
QgsProject.instance().removeMapLayer(ptLayer.id())
|
QgsProject.instance().removeMapLayer(ptLayer.id())
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class TestQgsComposerEffects(unittest.TestCase):
|
|||||||
|
|
||||||
# create composition
|
# create composition
|
||||||
self.mMapSettings = QgsMapSettings()
|
self.mMapSettings = QgsMapSettings()
|
||||||
self.mComposition = QgsComposition(self.mMapSettings, QgsProject.instance())
|
self.mComposition = QgsComposition(QgsProject.instance())
|
||||||
self.mComposition.setPaperSize(297, 210)
|
self.mComposition.setPaperSize(297, 210)
|
||||||
|
|
||||||
self.mComposerRect1 = QgsComposerShape(20, 20, 150, 100, self.mComposition)
|
self.mComposerRect1 = QgsComposerShape(20, 20, 150, 100, self.mComposition)
|
||||||
|
@ -43,7 +43,7 @@ class TestQgsComposerHtml(unittest.TestCase):
|
|||||||
"""Run before each test."""
|
"""Run before each test."""
|
||||||
self.iface = get_iface()
|
self.iface = get_iface()
|
||||||
self.mapSettings = QgsMapSettings()
|
self.mapSettings = QgsMapSettings()
|
||||||
self.mComposition = QgsComposition(self.mapSettings, QgsProject.instance())
|
self.mComposition = QgsComposition(QgsProject.instance())
|
||||||
self.mComposition.setPaperSize(297, 210) # A4 landscape
|
self.mComposition.setPaperSize(297, 210) # A4 landscape
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
@ -29,7 +29,7 @@ class TestQgsComposerItem(unittest.TestCase):
|
|||||||
def testDataDefinedFrameColor(self):
|
def testDataDefinedFrameColor(self):
|
||||||
mapSettings = QgsMapSettings()
|
mapSettings = QgsMapSettings()
|
||||||
|
|
||||||
composition = QgsComposition(mapSettings, QgsProject.instance())
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition.setPaperSize(297, 210)
|
composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
item = QgsComposerLabel(composition)
|
item = QgsComposerLabel(composition)
|
||||||
@ -47,7 +47,7 @@ class TestQgsComposerItem(unittest.TestCase):
|
|||||||
def testDataDefinedBackgroundColor(self):
|
def testDataDefinedBackgroundColor(self):
|
||||||
mapSettings = QgsMapSettings()
|
mapSettings = QgsMapSettings()
|
||||||
|
|
||||||
composition = QgsComposition(mapSettings, QgsProject.instance())
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition.setPaperSize(297, 210)
|
composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
item = QgsComposerLabel(composition)
|
item = QgsComposerLabel(composition)
|
||||||
|
@ -38,7 +38,7 @@ class TestQgsComposerLabel(unittest.TestCase):
|
|||||||
mapSettings.setLayers([mVectorLayer])
|
mapSettings.setLayers([mVectorLayer])
|
||||||
mapSettings.setCrsTransformEnabled(False)
|
mapSettings.setCrsTransformEnabled(False)
|
||||||
|
|
||||||
mComposition = QgsComposition(mapSettings, QgsProject.instance())
|
mComposition = QgsComposition(QgsProject.instance())
|
||||||
mComposition.setPaperSize(297, 210)
|
mComposition.setPaperSize(297, 210)
|
||||||
|
|
||||||
mLabel = QgsComposerLabel(mComposition)
|
mLabel = QgsComposerLabel(mComposition)
|
||||||
|
@ -55,11 +55,12 @@ class TestQgsComposerLegend(unittest.TestCase):
|
|||||||
s = QgsMapSettings()
|
s = QgsMapSettings()
|
||||||
s.setLayers([point_layer])
|
s.setLayers([point_layer])
|
||||||
s.setCrsTransformEnabled(False)
|
s.setCrsTransformEnabled(False)
|
||||||
composition = QgsComposition(s, QgsProject.instance())
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition.setPaperSize(297, 210)
|
composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
composer_map = QgsComposerMap(composition, 20, 20, 80, 80)
|
composer_map = QgsComposerMap(composition, 20, 20, 80, 80)
|
||||||
composer_map.setFrameEnabled(True)
|
composer_map.setFrameEnabled(True)
|
||||||
|
composer_map.setLayers([point_layer])
|
||||||
composition.addComposerMap(composer_map)
|
composition.addComposerMap(composer_map)
|
||||||
composer_map.setNewExtent(point_layer.extent())
|
composer_map.setNewExtent(point_layer.extent())
|
||||||
|
|
||||||
@ -90,11 +91,12 @@ class TestQgsComposerLegend(unittest.TestCase):
|
|||||||
s = QgsMapSettings()
|
s = QgsMapSettings()
|
||||||
s.setLayers([point_layer])
|
s.setLayers([point_layer])
|
||||||
s.setCrsTransformEnabled(False)
|
s.setCrsTransformEnabled(False)
|
||||||
composition = QgsComposition(s, QgsProject.instance())
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition.setPaperSize(297, 210)
|
composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
composer_map = QgsComposerMap(composition, 20, 20, 80, 80)
|
composer_map = QgsComposerMap(composition, 20, 20, 80, 80)
|
||||||
composer_map.setFrameEnabled(True)
|
composer_map.setFrameEnabled(True)
|
||||||
|
composer_map.setLayers([point_layer])
|
||||||
composition.addComposerMap(composer_map)
|
composition.addComposerMap(composer_map)
|
||||||
composer_map.setNewExtent(point_layer.extent())
|
composer_map.setNewExtent(point_layer.extent())
|
||||||
|
|
||||||
@ -128,11 +130,12 @@ class TestQgsComposerLegend(unittest.TestCase):
|
|||||||
s = QgsMapSettings()
|
s = QgsMapSettings()
|
||||||
s.setLayers([point_layer])
|
s.setLayers([point_layer])
|
||||||
s.setCrsTransformEnabled(False)
|
s.setCrsTransformEnabled(False)
|
||||||
composition = QgsComposition(s, QgsProject.instance())
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition.setPaperSize(297, 210)
|
composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
composer_map = QgsComposerMap(composition, 20, 20, 80, 80)
|
composer_map = QgsComposerMap(composition, 20, 20, 80, 80)
|
||||||
composer_map.setFrameEnabled(True)
|
composer_map.setFrameEnabled(True)
|
||||||
|
composer_map.setLayers([point_layer])
|
||||||
composition.addComposerMap(composer_map)
|
composition.addComposerMap(composer_map)
|
||||||
composer_map.setNewExtent(point_layer.extent())
|
composer_map.setNewExtent(point_layer.extent())
|
||||||
|
|
||||||
@ -170,11 +173,12 @@ class TestQgsComposerLegend(unittest.TestCase):
|
|||||||
s = QgsMapSettings()
|
s = QgsMapSettings()
|
||||||
s.setLayers([point_layer])
|
s.setLayers([point_layer])
|
||||||
s.setCrsTransformEnabled(False)
|
s.setCrsTransformEnabled(False)
|
||||||
composition = QgsComposition(s, QgsProject.instance())
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition.setPaperSize(297, 210)
|
composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
composer_map = QgsComposerMap(composition, 20, 20, 80, 80)
|
composer_map = QgsComposerMap(composition, 20, 20, 80, 80)
|
||||||
composer_map.setFrameEnabled(True)
|
composer_map.setFrameEnabled(True)
|
||||||
|
composer_map.setLayers([point_layer])
|
||||||
composition.addComposerMap(composer_map)
|
composition.addComposerMap(composer_map)
|
||||||
composer_map.setNewExtent(point_layer.extent())
|
composer_map.setNewExtent(point_layer.extent())
|
||||||
|
|
||||||
@ -205,7 +209,7 @@ class TestQgsComposerLegend(unittest.TestCase):
|
|||||||
def testDataDefinedTitle(self):
|
def testDataDefinedTitle(self):
|
||||||
mapSettings = QgsMapSettings()
|
mapSettings = QgsMapSettings()
|
||||||
|
|
||||||
composition = QgsComposition(mapSettings, QgsProject.instance())
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition.setPaperSize(297, 210)
|
composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
legend = QgsComposerLegend(composition)
|
legend = QgsComposerLegend(composition)
|
||||||
@ -223,7 +227,7 @@ class TestQgsComposerLegend(unittest.TestCase):
|
|||||||
def testDataDefinedColumnCount(self):
|
def testDataDefinedColumnCount(self):
|
||||||
mapSettings = QgsMapSettings()
|
mapSettings = QgsMapSettings()
|
||||||
|
|
||||||
composition = QgsComposition(mapSettings, QgsProject.instance())
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition.setPaperSize(297, 210)
|
composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
legend = QgsComposerLegend(composition)
|
legend = QgsComposerLegend(composition)
|
||||||
|
@ -63,18 +63,17 @@ class TestQgsComposerMap(unittest.TestCase):
|
|||||||
QgsProject.instance().addMapLayers([self.raster_layer, self.vector_layer])
|
QgsProject.instance().addMapLayers([self.raster_layer, self.vector_layer])
|
||||||
|
|
||||||
# create composition with composer map
|
# create composition with composer map
|
||||||
self.mMapSettings = QgsMapSettings()
|
self.mComposition = QgsComposition(QgsProject.instance())
|
||||||
self.mMapSettings.setLayers([self.raster_layer])
|
|
||||||
self.mMapSettings.setCrsTransformEnabled(False)
|
|
||||||
self.mComposition = QgsComposition(self.mMapSettings, QgsProject.instance())
|
|
||||||
self.mComposition.setPaperSize(297, 210)
|
self.mComposition.setPaperSize(297, 210)
|
||||||
self.mComposerMap = QgsComposerMap(self.mComposition, 20, 20, 200, 100)
|
self.mComposerMap = QgsComposerMap(self.mComposition, 20, 20, 200, 100)
|
||||||
self.mComposerMap.setFrameEnabled(True)
|
self.mComposerMap.setFrameEnabled(True)
|
||||||
|
self.mComposerMap.setLayers([self.raster_layer])
|
||||||
self.mComposition.addComposerMap(self.mComposerMap)
|
self.mComposition.addComposerMap(self.mComposerMap)
|
||||||
|
|
||||||
def testOverviewMap(self):
|
def testOverviewMap(self):
|
||||||
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
|
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
|
||||||
overviewMap.setFrameEnabled(True)
|
overviewMap.setFrameEnabled(True)
|
||||||
|
overviewMap.setLayers([self.raster_layer])
|
||||||
self.mComposition.addComposerMap(overviewMap)
|
self.mComposition.addComposerMap(overviewMap)
|
||||||
# zoom in
|
# zoom in
|
||||||
myRectangle = QgsRectangle(96, -152, 160, -120)
|
myRectangle = QgsRectangle(96, -152, 160, -120)
|
||||||
@ -91,6 +90,7 @@ class TestQgsComposerMap(unittest.TestCase):
|
|||||||
def testOverviewMapBlend(self):
|
def testOverviewMapBlend(self):
|
||||||
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
|
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
|
||||||
overviewMap.setFrameEnabled(True)
|
overviewMap.setFrameEnabled(True)
|
||||||
|
overviewMap.setLayers([self.raster_layer])
|
||||||
self.mComposition.addComposerMap(overviewMap)
|
self.mComposition.addComposerMap(overviewMap)
|
||||||
# zoom in
|
# zoom in
|
||||||
myRectangle = QgsRectangle(96, -152, 160, -120)
|
myRectangle = QgsRectangle(96, -152, 160, -120)
|
||||||
@ -108,6 +108,7 @@ class TestQgsComposerMap(unittest.TestCase):
|
|||||||
def testOverviewMapInvert(self):
|
def testOverviewMapInvert(self):
|
||||||
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
|
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
|
||||||
overviewMap.setFrameEnabled(True)
|
overviewMap.setFrameEnabled(True)
|
||||||
|
overviewMap.setLayers([self.raster_layer])
|
||||||
self.mComposition.addComposerMap(overviewMap)
|
self.mComposition.addComposerMap(overviewMap)
|
||||||
# zoom in
|
# zoom in
|
||||||
myRectangle = QgsRectangle(96, -152, 160, -120)
|
myRectangle = QgsRectangle(96, -152, 160, -120)
|
||||||
@ -125,6 +126,7 @@ class TestQgsComposerMap(unittest.TestCase):
|
|||||||
def testOverviewMapCenter(self):
|
def testOverviewMapCenter(self):
|
||||||
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
|
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
|
||||||
overviewMap.setFrameEnabled(True)
|
overviewMap.setFrameEnabled(True)
|
||||||
|
overviewMap.setLayers([self.raster_layer])
|
||||||
self.mComposition.addComposerMap(overviewMap)
|
self.mComposition.addComposerMap(overviewMap)
|
||||||
# zoom in
|
# zoom in
|
||||||
myRectangle = QgsRectangle(192, -288, 320, -224)
|
myRectangle = QgsRectangle(192, -288, 320, -224)
|
||||||
@ -144,7 +146,7 @@ class TestQgsComposerMap(unittest.TestCase):
|
|||||||
# create composition with composer map
|
# create composition with composer map
|
||||||
map_settings = QgsMapSettings()
|
map_settings = QgsMapSettings()
|
||||||
map_settings.setLayers([self.vector_layer])
|
map_settings.setLayers([self.vector_layer])
|
||||||
composition = QgsComposition(map_settings, QgsProject.instance())
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition.setPaperSize(297, 210)
|
composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
# check that new maps inherit project CRS
|
# check that new maps inherit project CRS
|
||||||
@ -153,6 +155,7 @@ class TestQgsComposerMap(unittest.TestCase):
|
|||||||
map.setFrameEnabled(True)
|
map.setFrameEnabled(True)
|
||||||
rectangle = QgsRectangle(-13838977, 2369660, -8672298, 6250909)
|
rectangle = QgsRectangle(-13838977, 2369660, -8672298, 6250909)
|
||||||
map.setNewExtent(rectangle)
|
map.setNewExtent(rectangle)
|
||||||
|
map.setLayers([self.vector_layer])
|
||||||
composition.addComposerMap(map)
|
composition.addComposerMap(map)
|
||||||
|
|
||||||
self.assertEqual(map.crs().authid(), 'EPSG:4326')
|
self.assertEqual(map.crs().authid(), 'EPSG:4326')
|
||||||
|
@ -44,7 +44,7 @@ class TestQgsComposerMap(unittest.TestCase):
|
|||||||
crs = QgsCoordinateReferenceSystem(32633)
|
crs = QgsCoordinateReferenceSystem(32633)
|
||||||
self.mMapSettings.setDestinationCrs(crs)
|
self.mMapSettings.setDestinationCrs(crs)
|
||||||
self.mMapSettings.setCrsTransformEnabled(False)
|
self.mMapSettings.setCrsTransformEnabled(False)
|
||||||
self.mComposition = QgsComposition(self.mMapSettings, QgsProject.instance())
|
self.mComposition = QgsComposition(QgsProject.instance())
|
||||||
self.mComposition.setPaperSize(297, 210)
|
self.mComposition.setPaperSize(297, 210)
|
||||||
self.mComposerMap = QgsComposerMap(self.mComposition, 20, 20, 200, 100)
|
self.mComposerMap = QgsComposerMap(self.mComposition, 20, 20, 200, 100)
|
||||||
self.mComposerMap.setFrameEnabled(True)
|
self.mComposerMap.setFrameEnabled(True)
|
||||||
|
@ -59,8 +59,7 @@ class TestQgsComposerPicture(unittest.TestCase):
|
|||||||
self.pngImage = TEST_DATA_DIR + "/sample_image.png"
|
self.pngImage = TEST_DATA_DIR + "/sample_image.png"
|
||||||
|
|
||||||
# create composition
|
# create composition
|
||||||
self.mapSettings = QgsMapSettings()
|
self.composition = QgsComposition(QgsProject.instance())
|
||||||
self.composition = QgsComposition(self.mapSettings, QgsProject.instance())
|
|
||||||
self.composition.setPaperSize(297, 210)
|
self.composition.setPaperSize(297, 210)
|
||||||
|
|
||||||
self.composerPicture = QgsComposerPicture(self.composition)
|
self.composerPicture = QgsComposerPicture(self.composition)
|
||||||
@ -94,8 +93,7 @@ class TestQgsComposerPicture(unittest.TestCase):
|
|||||||
def testGridNorth(self):
|
def testGridNorth(self):
|
||||||
"""Test syncing picture to grid north"""
|
"""Test syncing picture to grid north"""
|
||||||
|
|
||||||
mapSettings = QgsMapSettings()
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition = QgsComposition(mapSettings, QgsProject.instance())
|
|
||||||
|
|
||||||
composerMap = QgsComposerMap(composition)
|
composerMap = QgsComposerMap(composition)
|
||||||
composerMap.setNewExtent(QgsRectangle(0, -256, 256, 0))
|
composerMap.setNewExtent(QgsRectangle(0, -256, 256, 0))
|
||||||
@ -118,8 +116,7 @@ class TestQgsComposerPicture(unittest.TestCase):
|
|||||||
def testTrueNorth(self):
|
def testTrueNorth(self):
|
||||||
"""Test syncing picture to true north"""
|
"""Test syncing picture to true north"""
|
||||||
|
|
||||||
mapSettings = QgsMapSettings()
|
composition = QgsComposition(QgsProject.instance())
|
||||||
composition = QgsComposition(mapSettings, QgsProject.instance())
|
|
||||||
|
|
||||||
composerMap = QgsComposerMap(composition)
|
composerMap = QgsComposerMap(composition)
|
||||||
composerMap.setCrs(QgsCoordinateReferenceSystem.fromEpsgId(3575))
|
composerMap.setCrs(QgsCoordinateReferenceSystem.fromEpsgId(3575))
|
||||||
|
@ -41,10 +41,8 @@ class TestQgsComposerPolygon(unittest.TestCase):
|
|||||||
"""Run once on class initialization."""
|
"""Run once on class initialization."""
|
||||||
unittest.TestCase.__init__(self, methodName)
|
unittest.TestCase.__init__(self, methodName)
|
||||||
|
|
||||||
self.mapSettings = QgsMapSettings()
|
|
||||||
|
|
||||||
# create composition
|
# create composition
|
||||||
self.mComposition = QgsComposition(self.mapSettings, QgsProject.instance())
|
self.mComposition = QgsComposition(QgsProject.instance())
|
||||||
self.mComposition.setPaperSize(297, 210)
|
self.mComposition.setPaperSize(297, 210)
|
||||||
|
|
||||||
# create
|
# create
|
||||||
|
@ -41,10 +41,8 @@ class TestQgsComposerPolyline(unittest.TestCase):
|
|||||||
"""Run once on class initialization."""
|
"""Run once on class initialization."""
|
||||||
unittest.TestCase.__init__(self, methodName)
|
unittest.TestCase.__init__(self, methodName)
|
||||||
|
|
||||||
self.mapSettings = QgsMapSettings()
|
|
||||||
|
|
||||||
# create composition
|
# create composition
|
||||||
self.mComposition = QgsComposition(self.mapSettings, QgsProject.instance())
|
self.mComposition = QgsComposition(QgsProject.instance())
|
||||||
self.mComposition.setPaperSize(297, 210)
|
self.mComposition.setPaperSize(297, 210)
|
||||||
|
|
||||||
# create
|
# create
|
||||||
|
@ -35,10 +35,8 @@ class TestQgsComposerShapes(unittest.TestCase):
|
|||||||
"""Run once on class initialization."""
|
"""Run once on class initialization."""
|
||||||
unittest.TestCase.__init__(self, methodName)
|
unittest.TestCase.__init__(self, methodName)
|
||||||
|
|
||||||
self.mapSettings = QgsMapSettings()
|
|
||||||
|
|
||||||
# create composition
|
# create composition
|
||||||
self.mComposition = QgsComposition(self.mapSettings, QgsProject.instance())
|
self.mComposition = QgsComposition(QgsProject.instance())
|
||||||
self.mComposition.setPaperSize(297, 210)
|
self.mComposition.setPaperSize(297, 210)
|
||||||
|
|
||||||
self.mComposerShape = QgsComposerShape(20, 20, 150, 100, self.mComposition)
|
self.mComposerShape = QgsComposerShape(20, 20, 150, 100, self.mComposition)
|
||||||
|
@ -57,7 +57,7 @@ class TestQgsComposition(unittest.TestCase):
|
|||||||
myText = 'Latitude: %s, Longitude: %s' % (myLatitude, myLongitude)
|
myText = 'Latitude: %s, Longitude: %s' % (myLatitude, myLongitude)
|
||||||
|
|
||||||
# Load the composition with the substitutions
|
# Load the composition with the substitutions
|
||||||
myComposition = QgsComposition(self.iface.mapCanvas().mapSettings(), QgsProject.instance())
|
myComposition = QgsComposition(QgsProject.instance())
|
||||||
mySubstitutionMap = {'replace-me': myText}
|
mySubstitutionMap = {'replace-me': myText}
|
||||||
myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt')
|
myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt')
|
||||||
with open(myFile) as f:
|
with open(myFile) as f:
|
||||||
@ -73,7 +73,7 @@ class TestQgsComposition(unittest.TestCase):
|
|||||||
|
|
||||||
def testNoSubstitutionMap(self):
|
def testNoSubstitutionMap(self):
|
||||||
"""Test that we can get a map if we use no text substitutions."""
|
"""Test that we can get a map if we use no text substitutions."""
|
||||||
myComposition = QgsComposition(self.iface.mapCanvas().mapSettings(), QgsProject.instance())
|
myComposition = QgsComposition(QgsProject.instance())
|
||||||
myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt')
|
myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt')
|
||||||
with open(myFile) as f:
|
with open(myFile) as f:
|
||||||
myTemplateContent = f.read()
|
myTemplateContent = f.read()
|
||||||
@ -101,11 +101,7 @@ class TestQgsComposition(unittest.TestCase):
|
|||||||
|
|
||||||
QgsProject.instance().addMapLayers([myRasterLayer])
|
QgsProject.instance().addMapLayers([myRasterLayer])
|
||||||
|
|
||||||
myMapSettings = QgsMapSettings()
|
myComposition = QgsComposition(QgsProject.instance())
|
||||||
myMapSettings.setLayers([myRasterLayer])
|
|
||||||
myMapSettings.setCrsTransformEnabled(False)
|
|
||||||
|
|
||||||
myComposition = QgsComposition(myMapSettings, QgsProject.instance())
|
|
||||||
myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt')
|
myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt')
|
||||||
with open(myFile) as f:
|
with open(myFile) as f:
|
||||||
myTemplateContent = f.read()
|
myTemplateContent = f.read()
|
||||||
@ -120,6 +116,7 @@ class TestQgsComposition(unittest.TestCase):
|
|||||||
|
|
||||||
myExtent = myRasterLayer.extent()
|
myExtent = myRasterLayer.extent()
|
||||||
myMap.setNewExtent(myExtent)
|
myMap.setNewExtent(myExtent)
|
||||||
|
myMap.setLayers([myRasterLayer])
|
||||||
|
|
||||||
myImagePath = os.path.join(str(QDir.tempPath()),
|
myImagePath = os.path.join(str(QDir.tempPath()),
|
||||||
'template_map_render_python.png')
|
'template_map_render_python.png')
|
||||||
|
@ -102,7 +102,7 @@ class TestComposerBase(TestQgsPalLabeling):
|
|||||||
|
|
||||||
def _set_up_composition(self, width, height, dpi):
|
def _set_up_composition(self, width, height, dpi):
|
||||||
# set up composition and add map
|
# set up composition and add map
|
||||||
self._c = QgsComposition(self._TestMapSettings, QgsProject.instance())
|
self._c = QgsComposition(QgsProject.instance())
|
||||||
""":type: QgsComposition"""
|
""":type: QgsComposition"""
|
||||||
# self._c.setUseAdvancedEffects(False)
|
# self._c.setUseAdvancedEffects(False)
|
||||||
self._c.setPrintResolution(dpi)
|
self._c.setPrintResolution(dpi)
|
||||||
@ -119,6 +119,7 @@ class TestComposerBase(TestQgsPalLabeling):
|
|||||||
""":type: QgsComposerMap"""
|
""":type: QgsComposerMap"""
|
||||||
self._cmap.setPreviewMode(QgsComposerMap.Render)
|
self._cmap.setPreviewMode(QgsComposerMap.Render)
|
||||||
self._cmap.setFrameEnabled(False)
|
self._cmap.setFrameEnabled(False)
|
||||||
|
self._cmap.setLayers(self._TestMapSettings.layers())
|
||||||
self._c.addComposerMap(self._cmap)
|
self._c.addComposerMap(self._cmap)
|
||||||
# now expand map to fill page and set its extent
|
# now expand map to fill page and set its extent
|
||||||
self._cmap.setSceneRect(QRectF(0, 0, paperw, paperw))
|
self._cmap.setSceneRect(QRectF(0, 0, paperw, paperw))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user