Skip to content
Permalink
Browse files

Merge pull request #5837 from nyalldawson/layout_next

Layout raster image exports
  • Loading branch information
nyalldawson committed Dec 17, 2017
2 parents b630a40 + 492f9ea commit b59bd94e874ca0873fa4d2ccb5c962dc9f2ad7b6
Showing with 5,181 additions and 290 deletions.
  1. +1 −0 images/images.qrc
  2. +86 −0 images/themes/default/mActionNewPage.svg
  3. +51 −10 python/core/layout/qgslayout.sip
  4. +1 −0 python/core/layout/qgslayoutcontext.sip
  5. +246 −2 python/core/layout/qgslayoutexporter.sip
  6. +24 −5 python/core/layout/qgslayoutitem.sip
  7. +5 −6 python/core/layout/qgslayoutitemmap.sip
  8. +1 −1 python/core/layout/qgslayoutitempage.sip
  9. +2 −0 python/core/layout/qgslayoutitempicture.sip
  10. +56 −0 python/core/layout/qgslayoutpagecollection.sip
  11. +6 −0 python/core/layout/qgslayoututils.sip
  12. +5 −0 python/gui/layout/qgslayoutdesignerinterface.sip
  13. +3 −0 python/gui/layout/qgslayoutview.sip
  14. +2 −0 src/app/CMakeLists.txt
  15. +1 −0 src/app/layout/qgslayoutaddpagesdialog.cpp
  16. +2 −0 src/app/layout/qgslayoutappmenuprovider.cpp
  17. +366 −4 src/app/layout/qgslayoutdesignerdialog.cpp
  18. +27 −0 src/app/layout/qgslayoutdesignerdialog.h
  19. +2 −0 src/app/layout/qgslayoutguidewidget.cpp
  20. +1 −0 src/app/layout/qgslayouthtmlwidget.cpp
  21. +187 −0 src/app/layout/qgslayoutimageexportoptionsdialog.cpp
  22. +144 −0 src/app/layout/qgslayoutimageexportoptionsdialog.h
  23. +1 −0 src/app/layout/qgslayoutmapwidget.cpp
  24. +36 −2 src/app/layout/qgslayoutpagepropertieswidget.cpp
  25. +3 −0 src/app/layout/qgslayoutpagepropertieswidget.h
  26. +1 −0 src/app/layout/qgslayoutpolygonwidget.cpp
  27. +1 −0 src/app/layout/qgslayoutpolylinewidget.cpp
  28. +128 −0 src/app/layout/qgslayoutpropertieswidget.cpp
  29. +12 −0 src/app/layout/qgslayoutpropertieswidget.h
  30. +12 −0 src/app/qgisapp.cpp
  31. +3 −0 src/app/qgisapp.h
  32. +3 −0 src/core/composer/qgslayoutmanager.cpp
  33. +66 −10 src/core/layout/qgslayout.cpp
  34. +42 −16 src/core/layout/qgslayout.h
  35. +1 −0 src/core/layout/qgslayoutaligner.cpp
  36. +3 −0 src/core/layout/qgslayoutcontext.h
  37. +731 −4 src/core/layout/qgslayoutexporter.cpp
  38. +295 −2 src/core/layout/qgslayoutexporter.h
  39. +2 −0 src/core/layout/qgslayoutgridsettings.cpp
  40. +2 −0 src/core/layout/qgslayoutguidecollection.cpp
  41. +83 −16 src/core/layout/qgslayoutitem.cpp
  42. +25 −5 src/core/layout/qgslayoutitem.h
  43. +2 −0 src/core/layout/qgslayoutitemgroup.cpp
  44. +132 −36 src/core/layout/qgslayoutitemmap.cpp
  45. +3 −4 src/core/layout/qgslayoutitemmap.h
  46. +7 −3 src/core/layout/qgslayoutitemmapgrid.cpp
  47. +5 −2 src/core/layout/qgslayoutitempage.cpp
  48. +1 −1 src/core/layout/qgslayoutitempage.h
  49. +8 −0 src/core/layout/qgslayoutitempicture.cpp
  50. +1 −0 src/core/layout/qgslayoutitempicture.h
  51. +1 −0 src/core/layout/qgslayoutitemundocommand.cpp
  52. +2 −0 src/core/layout/qgslayoutmultiframe.cpp
  53. +1 −1 src/core/layout/qgslayoutobject.h
  54. +210 −2 src/core/layout/qgslayoutpagecollection.cpp
  55. +74 −0 src/core/layout/qgslayoutpagecollection.h
  56. +1 −0 src/core/layout/qgslayoutsnapper.cpp
  57. +1 −0 src/core/layout/qgslayouttable.cpp
  58. +21 −6 src/core/layout/qgslayoututils.cpp
  59. +7 −0 src/core/layout/qgslayoututils.h
  60. +2 −1 src/core/qgsmultirenderchecker.cpp
  61. +6 −0 src/gui/layout/qgslayoutdesignerinterface.h
  62. +1 −0 src/gui/layout/qgslayoutitemwidget.cpp
  63. +1 −0 src/gui/layout/qgslayoutmousehandles.cpp
  64. +4 −1 src/gui/layout/qgslayoutnewitempropertiesdialog.cpp
  65. +1 −0 src/gui/layout/qgslayoutruler.cpp
  66. +15 −0 src/gui/layout/qgslayoutview.cpp
  67. +10 −0 src/gui/layout/qgslayoutview.h
  68. +1 −0 src/gui/layout/qgslayoutviewtooladditem.cpp
  69. +1 −0 src/gui/layout/qgslayoutviewtooleditnodes.cpp
  70. +1 −0 src/gui/layout/qgslayoutviewtoolmoveitemcontent.cpp
  71. +2 −1 src/gui/layout/qgslayoutviewtoolselect.cpp
  72. +41 −1 src/ui/layout/qgslayoutdesignerbase.ui
  73. +340 −0 src/ui/layout/qgslayoutimageexportoptions.ui
  74. +85 −33 src/ui/layout/qgslayoutpagepropertieswidget.ui
  75. +248 −15 src/ui/layout/qgslayoutwidgetbase.ui
  76. +57 −1 src/ui/qgisapp.ui
  77. +230 −55 tests/src/core/testqgslayout.cpp
  78. +19 −0 tests/src/core/testqgslayoutitem.cpp
  79. +1 −0 tests/src/core/testqgslayoutitemgroup.cpp
  80. +89 −15 tests/src/core/testqgslayoutmap.cpp
  81. +2 −0 tests/src/core/testqgslayoutmultiframe.cpp
  82. +1 −0 tests/src/core/testqgslayoutpage.cpp
  83. +27 −16 tests/src/core/testqgslayoututils.cpp
  84. +5 −0 tests/src/python/CMakeLists.txt
  85. +3 −2 tests/src/python/qgslayoutchecker.py
  86. +3 −0 tests/src/python/test_qgslayout.py
  87. +382 −0 tests/src/python/test_qgslayoutexporter.py
  88. +38 −0 tests/src/python/test_qgslayoutframe.py
  89. +22 −1 tests/src/python/test_qgslayoutitem.py
  90. +6 −1 tests/src/python/test_qgslayoutlabel.py
  91. +7 −1 tests/src/python/test_qgslayoutlegend.py
  92. +53 −3 tests/src/python/test_qgslayoutmap.py
  93. +33 −0 tests/src/python/test_qgslayoutpage.py
  94. +216 −2 tests/src/python/test_qgslayoutpagecollection.py
  95. +4 −1 tests/src/python/test_qgslayoutpicture.py
  96. +6 −1 tests/src/python/test_qgslayoutpolygon.py
  97. +6 −1 tests/src/python/test_qgslayoutpolyline.py
  98. +33 −0 tests/src/python/test_qgslayoutscalebar.py
  99. +33 −0 tests/src/python/test_qgslayoutshape.py
  100. BIN ...tdata/control_images/composer_map/expected_layoutmap_rasterized/expected_layoutmap_rasterized.png
  101. BIN .../control_images/composer_map/expected_layoutmap_rasterized/expected_layoutmap_rasterized_mask.png
  102. BIN ...trol_images/composer_mapgrid/expected_composermap_grid/{ → default}/expected_composermap_grid.png
  103. BIN ...images/composer_mapgrid/expected_composermap_grid/{ → default}/expected_composermap_grid_mask.png
  104. BIN ...ta/control_images/composer_mapgrid/expected_composermap_grid/fedora/expected_composermap_grid.png
  105. BIN ...ntrol_images/composer_mapgrid/expected_composermap_grid/fedora/expected_composermap_grid_mask.png
  106. BIN ...mposer_mapgrid/expected_composermap_gridreprojected/expected_composermap_gridreprojected_mask.png
  107. BIN ...apoverview/expected_composermap_overview_blending/expected_composermap_overview_blending_mask.png
  108. BIN ...composer_paper/expected_composerpaper_markerborder/layout/expected_composerpaper_markerborder.png
  109. BIN ...l_images/composer_shapes/expected_composershapes_ellipse/expected_composershapes_ellipse_mask.png
  110. BIN .../composer_shapes/expected_composershapes_roundedrect/expected_composershapes_roundedrect_mask.png
  111. BIN ..._layoutexporter_exporttoimagecropped_page1/expected_layoutexporter_exporttoimagecropped_page1.png
  112. BIN ..._layoutexporter_exporttoimagecropped_page2/expected_layoutexporter_exporttoimagecropped_page2.png
  113. BIN ...expected_layoutexporter_exporttoimagedpi_page1/expected_layoutexporter_exporttoimagedpi_page1.png
  114. BIN ...expected_layoutexporter_exporttoimagedpi_page2/expected_layoutexporter_exporttoimagedpi_page2.png
  115. BIN ...pected_layoutexporter_exporttoimagesize_page2/expected_layoutexporter_exporttoimagesize_page2.png
  116. BIN ..._images/layout_exporter/expected_layoutexporter_renderpage/expected_layoutexporter_renderpage.png
  117. BIN ...ges/layout_exporter/expected_layoutexporter_renderregion/expected_layoutexporter_renderregion.png
  118. BIN ..._exporter/expected_layoutexporter_rendertoimagepage/expected_layoutexporter_rendertoimagepage.png
  119. BIN ...expected_layoutexporter_rendertoimageregiondpi/expected_layoutexporter_rendertoimageregiondpi.png
  120. BIN ...xporter_rendertoimageregionoverridedpi/expected_layoutexporter_rendertoimageregionoverridedpi.png
  121. BIN ...pected_layoutexporter_rendertoimageregionsize/expected_layoutexporter_rendertoimageregionsize.png
  122. BIN ...ages/layout_scalebar/expected_layoutscalebar_doublebox/expected_layoutscalebar_doublebox_mask.png
  123. BIN ...s/layout_scalebar/expected_layoutscalebar_numeric/fedora/expected_layoutscalebar_numeric_mask.png
  124. BIN ...s/layout_scalebar/expected_layoutscalebar_numeric/travis/expected_layoutscalebar_numeric_mask.png
  125. BIN ...ages/layout_scalebar/expected_layoutscalebar_singlebox/expected_layoutscalebar_singlebox_mask.png
  126. BIN ...scalebar/expected_layoutscalebar_singlebox_alpha/expected_layoutscalebar_singlebox_alpha_mask.png
  127. BIN ...control_images/layout_scalebar/expected_layoutscalebar_tick/expected_layoutscalebar_tick_mask.png
@@ -617,6 +617,7 @@
<file>themes/default/mIconQgsProjectFile.svg</file>
<file>themes/default/mIconPythonFile.svg</file>
<file>themes/default/mIconQptFile.svg</file>
<file>themes/default/mActionNewPage.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="24"
width="24"
version="1.1"
id="svg8"
sodipodi:docname="mActionNewPage.svg"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1016"
id="namedview10"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="23.59322"
inkscape:cy="4.0677966"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg8" />
<g
fill-rule="evenodd"
stroke="#727272"
stroke-linejoin="round"
transform="translate(0 -1028.3622)"
id="g6">
<path
d="m4.5 1050.8618v-21h10l5 5v16.0004z"
fill="#fff"
id="path2" />
<path
d="m14.5 1029.8618v5h5z"
fill="#f0f0f0"
id="path4" />
</g>
<g
id="g16"
transform="translate(33)">
<rect
style="fill:#c4a000"
id="rect10"
y="13"
x="-20"
width="11"
rx="2.0114901"
height="11" />
<path
style="fill:#fcffff"
inkscape:connector-curvature="0"
id="path12"
d="m -15,14 v 2.0625 c -0.537663,0.111041 -1.024662,0.383291 -1.375,0.78125 l -1.78125,-1.03125 -0.5,0.875 1.78125,1.03125 C -16.957063,17.966182 -17,18.225145 -17,18.5 c 0,0.274855 0.04294,0.533818 0.125,0.78125 l -1.78125,1.03125 0.5,0.875 1.78125,-1.03125 c 0.352503,0.40042 0.832682,0.670182 1.375,0.78125 V 23 h 1 v -2.0625 c 0.537663,-0.111041 1.024662,-0.383291 1.375,-0.78125 l 1.78125,1.03125 0.5,-0.875 -1.78125,-1.03125 C -12.042937,19.033818 -12,18.774855 -12,18.5 c 0,-0.274855 -0.04294,-0.533818 -0.125,-0.78125 l 1.78125,-1.03125 -0.5,-0.875 -1.78125,1.03125 C -12.977503,16.44333 -13.457682,16.173568 -14,16.0625 V 14 Z m 0.5,3.5 c 0.552,0 1,0.448 1,1 0,0.552 -0.448,1 -1,1 -0.552,0 -1,-0.448 -1,-1 0,-0.552 0.448,-1 1,-1 z" />
<path
style="opacity:0.3;fill:#fcffff;fill-rule:evenodd"
inkscape:connector-curvature="0"
id="path14"
d="m -19,19 9,-0.0096 c 0,0 0,0 0,-2 C -10,14 -11,14 -14.5,14 c -3.5,0 -4.5,0 -4.5,3 0,2 0,2 0,2 z" />
</g>
</svg>
@@ -13,6 +13,12 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
%Docstring
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.

While the raw QGraphicsScene API can be used to render the contents of a QgsLayout
to a QPainter, it is recommended to instead use a QgsLayoutExporter to handle rendering
layouts instead. QgsLayoutExporter automatically takes care of the intracacies of
preparing the layout and paint devices for correct exports, respecting various
user settings such as the layout context DPI.

.. versionadded:: 3.0
%End

@@ -33,6 +39,12 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
ZSnapIndicator,
};

enum UndoCommand
{
UndoLayoutDpi,
UndoNone,
};

QgsLayout( QgsProject *project );
%Docstring
Construct a new layout linked to the specified ``project``.
@@ -66,12 +78,6 @@ relations and various other bits. It is never null.
QgsLayoutModel *itemsModel();
%Docstring
Returns the items model attached to the layout.
%End

QgsLayoutExporter &exporter();
%Docstring
Returns the layout's exporter, which is used for rendering the layout and exporting
to various formats.
%End

QString name() const;
@@ -176,7 +182,7 @@ z order list. This should be called after any stacking changes
which deferred z-order updates.
%End

QgsLayoutItem *itemByUuid( const QString &uuid, bool includeTemplateUuids = false );
QgsLayoutItem *itemByUuid( const QString &uuid, bool includeTemplateUuids = false ) const;
%Docstring
Returns the layout item with matching ``uuid`` unique identifier, or a None
if a matching item could not be found.
@@ -381,8 +387,25 @@ Return list of keys stored in custom properties for the layout.
%End

QgsLayoutItemMap *referenceMap() const;
%Docstring
Returns the map item which will be used to generate corresponding world files when the
layout is exported. If no map was explicitly set via setReferenceMap(), the largest
map in the layout will be returned (or None if there are no maps in the layout).

.. seealso:: :py:func:`setReferenceMap()`

.. seealso:: :py:func:`generateWorldFile()`
%End

void setReferenceMap( QgsLayoutItemMap *map );
%Docstring
Sets the ``map`` item which will be used to generate corresponding world files when the
layout is exported.

.. seealso:: :py:func:`referenceMap()`

.. seealso:: :py:func:`setGenerateWorldFile()`
%End

QgsLayoutPageCollection *pageCollection();
%Docstring
@@ -400,6 +423,20 @@ and other cosmetic items.
:param margin: optional marginal (in percent, e.g., 0.05 = 5% ) to add around items

:return: layout bounds, in layout units.

.. seealso:: :py:func:`pageItemBounds()`
%End

QRectF pageItemBounds( int page, bool visibleOnly = false ) const;
%Docstring
Returns the bounding box of the items contained on a specified ``page``.
A page number of 0 represents the first page in the layout.

Set ``visibleOnly`` to true to only include visible items.

The returned bounds are in layout units.

.. seealso:: :py:func:`layoutBounds()`
%End

void addLayoutItem( QgsLayoutItem *item /Transfer/ );
@@ -541,6 +578,13 @@ Updates the scene bounds of the layout.

signals:

void changed();
%Docstring
Is emitted when properties of the layout change. This signal is only
emitted for settings directly managed by the layout, and is not emitted
when child items change.
%End

void variablesChanged();
%Docstring
Emitted whenever the expression variables stored in the layout have been changed.
@@ -567,9 +611,6 @@ Emitted when the layout's name is changed.

};




/************************************************************************
* This file has been generated automatically from *
* *
@@ -27,6 +27,7 @@ class QgsLayoutContext : QObject
FlagOutlineOnly,
FlagAntialiasing,
FlagUseAdvancedEffects,
FlagForceVectorOutput,
};
typedef QFlags<QgsLayoutContext::Flag> Flags;

0 comments on commit b59bd94

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