Skip to content

Commit b59bd94

Browse files
authored
Merge pull request #5837 from nyalldawson/layout_next
Layout raster image exports
2 parents b630a40 + 492f9ea commit b59bd94

File tree

127 files changed

+5181
-290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+5181
-290
lines changed

images/images.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@
617617
<file>themes/default/mIconQgsProjectFile.svg</file>
618618
<file>themes/default/mIconPythonFile.svg</file>
619619
<file>themes/default/mIconQptFile.svg</file>
620+
<file>themes/default/mActionNewPage.svg</file>
620621
</qresource>
621622
<qresource prefix="/images/tips">
622623
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Lines changed: 86 additions & 0 deletions
Loading

python/core/layout/qgslayout.sip

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
1313
%Docstring
1414
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
1515

16+
While the raw QGraphicsScene API can be used to render the contents of a QgsLayout
17+
to a QPainter, it is recommended to instead use a QgsLayoutExporter to handle rendering
18+
layouts instead. QgsLayoutExporter automatically takes care of the intracacies of
19+
preparing the layout and paint devices for correct exports, respecting various
20+
user settings such as the layout context DPI.
21+
1622
.. versionadded:: 3.0
1723
%End
1824

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

42+
enum UndoCommand
43+
{
44+
UndoLayoutDpi,
45+
UndoNone,
46+
};
47+
3648
QgsLayout( QgsProject *project );
3749
%Docstring
3850
Construct a new layout linked to the specified ``project``.
@@ -66,12 +78,6 @@ relations and various other bits. It is never null.
6678
QgsLayoutModel *itemsModel();
6779
%Docstring
6880
Returns the items model attached to the layout.
69-
%End
70-
71-
QgsLayoutExporter &exporter();
72-
%Docstring
73-
Returns the layout's exporter, which is used for rendering the layout and exporting
74-
to various formats.
7581
%End
7682

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

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

383389
QgsLayoutItemMap *referenceMap() const;
390+
%Docstring
391+
Returns the map item which will be used to generate corresponding world files when the
392+
layout is exported. If no map was explicitly set via setReferenceMap(), the largest
393+
map in the layout will be returned (or None if there are no maps in the layout).
394+
395+
.. seealso:: :py:func:`setReferenceMap()`
396+
397+
.. seealso:: :py:func:`generateWorldFile()`
398+
%End
384399

385400
void setReferenceMap( QgsLayoutItemMap *map );
401+
%Docstring
402+
Sets the ``map`` item which will be used to generate corresponding world files when the
403+
layout is exported.
404+
405+
.. seealso:: :py:func:`referenceMap()`
406+
407+
.. seealso:: :py:func:`setGenerateWorldFile()`
408+
%End
386409

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

402425
:return: layout bounds, in layout units.
426+
427+
.. seealso:: :py:func:`pageItemBounds()`
428+
%End
429+
430+
QRectF pageItemBounds( int page, bool visibleOnly = false ) const;
431+
%Docstring
432+
Returns the bounding box of the items contained on a specified ``page``.
433+
A page number of 0 represents the first page in the layout.
434+
435+
Set ``visibleOnly`` to true to only include visible items.
436+
437+
The returned bounds are in layout units.
438+
439+
.. seealso:: :py:func:`layoutBounds()`
403440
%End
404441

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

542579
signals:
543580

581+
void changed();
582+
%Docstring
583+
Is emitted when properties of the layout change. This signal is only
584+
emitted for settings directly managed by the layout, and is not emitted
585+
when child items change.
586+
%End
587+
544588
void variablesChanged();
545589
%Docstring
546590
Emitted whenever the expression variables stored in the layout have been changed.
@@ -567,9 +611,6 @@ Emitted when the layout's name is changed.
567611

568612
};
569613

570-
571-
572-
573614
/************************************************************************
574615
* This file has been generated automatically from *
575616
* *

python/core/layout/qgslayoutcontext.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class QgsLayoutContext : QObject
2727
FlagOutlineOnly,
2828
FlagAntialiasing,
2929
FlagUseAdvancedEffects,
30+
FlagForceVectorOutput,
3031
};
3132
typedef QFlags<QgsLayoutContext::Flag> Flags;
3233

0 commit comments

Comments
 (0)