|
|
|
@ -1065,6 +1065,7 @@ void TestQgsLayoutMap::testLayeredExport()
|
|
|
|
|
|
|
|
|
|
map->setBackgroundEnabled( false );
|
|
|
|
|
map->overview()->setEnabled( true );
|
|
|
|
|
map->overview()->setStackingPosition( QgsLayoutItemMapItem::StackAboveMapLabels );
|
|
|
|
|
map->startLayeredExport();
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
map->createStagedRenderJob( map->extent(), QSize( 512, 512 ), 72 );
|
|
|
|
@ -1117,6 +1118,67 @@ void TestQgsLayoutMap::testLayeredExport()
|
|
|
|
|
QVERIFY( !map->nextExportPart() );
|
|
|
|
|
map->stopLayeredExport();
|
|
|
|
|
|
|
|
|
|
map->overview()->setStackingPosition( QgsLayoutItemMapItem::StackBelowMapLabels );
|
|
|
|
|
QgsLayoutItemMap *map2 = new QgsLayoutItemMap( &l );
|
|
|
|
|
map2->attemptSetSceneRect( QRectF( 20, 20, 200, 100 ) );
|
|
|
|
|
map2->setFrameEnabled( false );
|
|
|
|
|
map2->setBackgroundEnabled( false );
|
|
|
|
|
map2->setCrs( linesLayer->crs() );
|
|
|
|
|
map2->zoomToExtent( linesLayer->extent() );
|
|
|
|
|
map2->setLayers( QList<QgsMapLayer *>() << linesLayer );
|
|
|
|
|
l.addLayoutItem( map2 );
|
|
|
|
|
map->overview()->setLinkedMap( map2 );
|
|
|
|
|
map->startLayeredExport();
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
map->createStagedRenderJob( map->extent(), QSize( 512, 512 ), 72 );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: lines" ) );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapLayerId, linesLayer->id() );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapTheme.isEmpty() );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Overview" ) );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapLayerId, map->overview()->mapLayer()->id() );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapTheme.isEmpty() );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
// labels
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Labels" ) );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapTheme.isEmpty() );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Grids" ) );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapTheme.isEmpty() );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Frame" ) );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapTheme.isEmpty() );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
|
|
|
|
|
map->overview()->setStackingPosition( QgsLayoutItemMapItem::StackAboveMapLabels );
|
|
|
|
|
|
|
|
|
|
// add second layer
|
|
|
|
|
map->setLayers( QList<QgsMapLayer *>() << linesLayer << pointsLayer );
|
|
|
|
|
map->startLayeredExport();
|
|
|
|
@ -1390,6 +1452,147 @@ void TestQgsLayoutMap::testLayeredExport()
|
|
|
|
|
QVERIFY( !map->nextExportPart() );
|
|
|
|
|
map->stopLayeredExport();
|
|
|
|
|
|
|
|
|
|
map->overview()->setStackingPosition( QgsLayoutItemMapItem::StackBelowMapLabels );
|
|
|
|
|
map->startLayeredExport();
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
map->createStagedRenderJob( map->extent(), QSize( 512, 512 ), 72 );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Background" ) );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapTheme.isEmpty() );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset2): lines" ) );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapLayerId, linesLayer->id() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset2" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QCOMPARE( map->themeToRender( QgsExpressionContext() ), QStringLiteral( "test preset2" ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset2): points" ) );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapLayerId, pointsLayer->id() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset2" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QCOMPARE( map->themeToRender( QgsExpressionContext() ), QStringLiteral( "test preset2" ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset2): Overview" ) );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapLayerId, map->overview()->mapLayer()->id() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset2" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
// labels
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset2): Labels" ) );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset2" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QCOMPARE( map->themeToRender( QgsExpressionContext() ), QStringLiteral( "test preset2" ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
// "test preset"
|
|
|
|
|
map->createStagedRenderJob( map->extent(), QSize( 512, 512 ), 72 );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset): lines" ) );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapLayerId, linesLayer->id() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QCOMPARE( map->themeToRender( QgsExpressionContext() ), QStringLiteral( "test preset" ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset): Overview" ) );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapLayerId, map->overview()->mapLayer()->id() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
// labels
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset): Labels" ) );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QCOMPARE( map->themeToRender( QgsExpressionContext() ), QStringLiteral( "test preset" ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
map->createStagedRenderJob( map->extent(), QSize( 512, 512 ), 72 );
|
|
|
|
|
// "test preset 3"
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset3): points" ) );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapLayerId, pointsLayer->id() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset3" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QCOMPARE( map->themeToRender( QgsExpressionContext() ), QStringLiteral( "test preset3" ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset3): Overview" ) );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapLayerId, map->overview()->mapLayer()->id() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset3" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
// labels
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset3): Labels" ) );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset3" ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QCOMPARE( map->themeToRender( QgsExpressionContext() ), QStringLiteral( "test preset3" ) );
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Grids" ) );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapTheme.isEmpty() );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( map->themeToRender( QgsExpressionContext() ).isEmpty() );
|
|
|
|
|
|
|
|
|
|
QVERIFY( map->nextExportPart() );
|
|
|
|
|
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Frame" ) );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
|
|
|
|
|
QVERIFY( map->exportLayerDetails().mapTheme.isEmpty() );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::OverviewMapExtent ) );
|
|
|
|
|
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Frame ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
|
|
|
|
|
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
|
|
|
|
|
QVERIFY( !map->nextExportPart() );
|
|
|
|
|
map->stopLayeredExport();
|
|
|
|
|
|
|
|
|
|
map->overview()->setStackingPosition( QgsLayoutItemMapItem::StackAboveMapLabels );
|
|
|
|
|
|
|
|
|
|
// but if map is already set to a particular map theme, it DOESN'T follow the theme iteration
|
|
|
|
|
map->setFollowVisibilityPreset( true );
|
|
|
|
|
map->setFollowVisibilityPresetName( QStringLiteral( "test preset" ) );
|
|
|
|
|