Skip to content

Commit

Permalink
Merge pull request #5837 from nyalldawson/layout_next
Browse files Browse the repository at this point in the history
Layout raster image exports
  • Loading branch information
nyalldawson committed Dec 17, 2017
2 parents b630a40 + 492f9ea commit b59bd94
Show file tree
Hide file tree
Showing 127 changed files with 5,181 additions and 290 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -617,6 +617,7 @@
<file>themes/default/mIconQgsProjectFile.svg</file> <file>themes/default/mIconQgsProjectFile.svg</file>
<file>themes/default/mIconPythonFile.svg</file> <file>themes/default/mIconPythonFile.svg</file>
<file>themes/default/mIconQptFile.svg</file> <file>themes/default/mIconQptFile.svg</file>
<file>themes/default/mActionNewPage.svg</file>
</qresource> </qresource>
<qresource prefix="/images/tips"> <qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file> <file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
86 changes: 86 additions & 0 deletions images/themes/default/mActionNewPage.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 51 additions & 10 deletions python/core/layout/qgslayout.sip
Expand Up @@ -13,6 +13,12 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
%Docstring %Docstring
Base class for layouts, which can contain items such as maps, labels, scalebars, etc. 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 .. versionadded:: 3.0
%End %End


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


enum UndoCommand
{
UndoLayoutDpi,
UndoNone,
};

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


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


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


QgsLayoutItemMap *referenceMap() const; 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 ); 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(); QgsLayoutPageCollection *pageCollection();
%Docstring %Docstring
Expand All @@ -400,6 +423,20 @@ and other cosmetic items.
:param margin: optional marginal (in percent, e.g., 0.05 = 5% ) to add around items :param margin: optional marginal (in percent, e.g., 0.05 = 5% ) to add around items


:return: layout bounds, in layout units. :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 %End


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


signals: 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(); void variablesChanged();
%Docstring %Docstring
Emitted whenever the expression variables stored in the layout have been changed. Emitted whenever the expression variables stored in the layout have been changed.
Expand All @@ -567,9 +611,6 @@ Emitted when the layout's name is changed.


}; };





/************************************************************************ /************************************************************************
* This file has been generated automatically from * * This file has been generated automatically from *
* * * *
Expand Down
1 change: 1 addition & 0 deletions python/core/layout/qgslayoutcontext.sip
Expand Up @@ -27,6 +27,7 @@ class QgsLayoutContext : QObject
FlagOutlineOnly, FlagOutlineOnly,
FlagAntialiasing, FlagAntialiasing,
FlagUseAdvancedEffects, FlagUseAdvancedEffects,
FlagForceVectorOutput,
}; };
typedef QFlags<QgsLayoutContext::Flag> Flags; typedef QFlags<QgsLayoutContext::Flag> Flags;


Expand Down

0 comments on commit b59bd94

Please sign in to comment.