Skip to content

Commit faa4a09

Browse files
authoredJul 23, 2017
Merge pull request #4877 from nyalldawson/layout_next
Layouts, chapter II
2 parents d570b43 + 54bf013 commit faa4a09

File tree

70 files changed

+6034
-58
lines changed

Some content is hidden

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

70 files changed

+6034
-58
lines changed
 

‎python/core/core_auto.sip

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,13 @@
153153
%Include composer/qgscomposermultiframecommand.sip
154154
%Include composer/qgscomposertexttable.sip
155155
%Include composer/qgspaperitem.sip
156-
%Include layout/qgslayout.sip
156+
%Include layout/qgslayoutcontext.sip
157157
%Include layout/qgslayoutmeasurement.sip
158158
%Include layout/qgslayoutmeasurementconverter.sip
159159
%Include layout/qgspagesizeregistry.sip
160160
%Include layout/qgslayoutpoint.sip
161161
%Include layout/qgslayoutsize.sip
162+
%Include layout/qgslayoututils.sip
162163
%Include metadata/qgslayermetadata.sip
163164
%Include metadata/qgslayermetadatavalidator.sip
164165
%Include processing/qgsprocessing.sip
@@ -378,8 +379,11 @@
378379
%Include gps/qgsgpsdetector.sip
379380
%Include gps/qgsnmeaconnection.sip
380381
%Include gps/qgsgpsdconnection.sip
382+
%Include layout/qgslayout.sip
381383
%Include layout/qgslayoutitem.sip
384+
%Include layout/qgslayoutitemmap.sip
382385
%Include layout/qgslayoutitemregistry.sip
386+
%Include layout/qgslayoutitemshape.sip
383387
%Include layout/qgslayoutobject.sip
384388
%Include symbology-ng/qgscptcityarchive.sip
385389
%Include symbology-ng/qgssvgcache.sip

‎python/core/layout/qgslayout.sip

Lines changed: 166 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
************************************************************************/
88

99

10-
class QgsLayout : QGraphicsScene
10+
11+
class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator
1112
{
1213
%Docstring
1314
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
@@ -24,7 +25,170 @@ class QgsLayout : QGraphicsScene
2425
ZMapTool,
2526
};
2627

27-
QgsLayout();
28+
QgsLayout( QgsProject *project );
29+
%Docstring
30+
Construct a new layout linked to the specified ``project``.
31+
%End
32+
33+
QgsProject *project() const;
34+
%Docstring
35+
The project associated with the layout. Used to get access to layers, map themes,
36+
relations and various other bits. It is never null.
37+
:rtype: QgsProject
38+
%End
39+
40+
QString name() const;
41+
%Docstring
42+
Returns the layout's name.
43+
.. seealso:: setName()
44+
:rtype: str
45+
%End
46+
47+
void setName( const QString &name );
48+
%Docstring
49+
Sets the layout's name.
50+
.. seealso:: name()
51+
%End
52+
53+
void setUnits( QgsUnitTypes::LayoutUnit units );
54+
%Docstring
55+
Sets the native measurement ``units`` for the layout. These also form the default unit
56+
for measurements for the layout.
57+
.. seealso:: units()
58+
.. seealso:: convertToLayoutUnits()
59+
%End
60+
61+
QgsUnitTypes::LayoutUnit units() const;
62+
%Docstring
63+
Returns the native units for the layout.
64+
.. seealso:: setUnits()
65+
.. seealso:: convertToLayoutUnits()
66+
:rtype: QgsUnitTypes.LayoutUnit
67+
%End
68+
69+
double convertToLayoutUnits( const QgsLayoutMeasurement &measurement ) const;
70+
%Docstring
71+
Converts a measurement into the layout's native units.
72+
:return: length of measurement in layout units
73+
.. seealso:: convertFromLayoutUnits()
74+
.. seealso:: units()
75+
:rtype: float
76+
%End
77+
78+
QSizeF convertToLayoutUnits( const QgsLayoutSize &size ) const;
79+
%Docstring
80+
Converts a size into the layout's native units.
81+
:return: size of measurement in layout units
82+
.. seealso:: convertFromLayoutUnits()
83+
.. seealso:: units()
84+
:rtype: QSizeF
85+
%End
86+
87+
QPointF convertToLayoutUnits( const QgsLayoutPoint &point ) const;
88+
%Docstring
89+
Converts a ``point`` into the layout's native units.
90+
:return: point in layout units
91+
.. seealso:: convertFromLayoutUnits()
92+
.. seealso:: units()
93+
:rtype: QPointF
94+
%End
95+
96+
QgsLayoutMeasurement convertFromLayoutUnits( const double length, const QgsUnitTypes::LayoutUnit unit ) const;
97+
%Docstring
98+
Converts a ``length`` measurement from the layout's native units to a specified target ``unit``.
99+
:return: length of measurement in specified units
100+
.. seealso:: convertToLayoutUnits()
101+
.. seealso:: units()
102+
:rtype: QgsLayoutMeasurement
103+
%End
104+
105+
QgsLayoutSize convertFromLayoutUnits( const QSizeF &size, const QgsUnitTypes::LayoutUnit unit ) const;
106+
%Docstring
107+
Converts a ``size`` from the layout's native units to a specified target ``unit``.
108+
:return: size of measurement in specified units
109+
.. seealso:: convertToLayoutUnits()
110+
.. seealso:: units()
111+
:rtype: QgsLayoutSize
112+
%End
113+
114+
QgsLayoutPoint convertFromLayoutUnits( const QPointF &point, const QgsUnitTypes::LayoutUnit unit ) const;
115+
%Docstring
116+
Converts a ``point`` from the layout's native units to a specified target ``unit``.
117+
:return: point in specified units
118+
.. seealso:: convertToLayoutUnits()
119+
.. seealso:: units()
120+
:rtype: QgsLayoutPoint
121+
%End
122+
123+
QgsLayoutContext &context();
124+
%Docstring
125+
Returns a reference to the layout's context, which stores information relating to the
126+
current context and rendering settings for the layout.
127+
:rtype: QgsLayoutContext
128+
%End
129+
130+
131+
virtual QgsExpressionContext createExpressionContext() const;
132+
133+
%Docstring
134+
Creates an expression context relating to the layout's current state. The context includes
135+
scopes for global, project, layout and layout context properties.
136+
:rtype: QgsExpressionContext
137+
%End
138+
139+
void setCustomProperty( const QString &key, const QVariant &value );
140+
%Docstring
141+
Set a custom property for the layout.
142+
\param key property key. If a property with the same key already exists it will be overwritten.
143+
\param value property value
144+
.. seealso:: customProperty()
145+
.. seealso:: removeCustomProperty()
146+
.. seealso:: customProperties()
147+
%End
148+
149+
QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
150+
%Docstring
151+
Read a custom property from the layout.
152+
\param key property key
153+
\param defaultValue default value to return if property with matching key does not exist
154+
:return: value of matching property
155+
.. seealso:: setCustomProperty()
156+
.. seealso:: removeCustomProperty()
157+
.. seealso:: customProperties()
158+
:rtype: QVariant
159+
%End
160+
161+
void removeCustomProperty( const QString &key );
162+
%Docstring
163+
Remove a custom property from the layout.
164+
\param key property key
165+
.. seealso:: setCustomProperty()
166+
.. seealso:: customProperty()
167+
.. seealso:: customProperties()
168+
%End
169+
170+
QStringList customProperties() const;
171+
%Docstring
172+
Return list of keys stored in custom properties for the layout.
173+
.. seealso:: setCustomProperty()
174+
.. seealso:: customProperty()
175+
.. seealso:: removeCustomProperty()
176+
:rtype: list of str
177+
%End
178+
179+
QgsLayoutItemMap *referenceMap() const;
180+
%Docstring
181+
:rtype: QgsLayoutItemMap
182+
%End
183+
184+
void setReferenceMap( QgsLayoutItemMap *map );
185+
186+
signals:
187+
188+
void variablesChanged();
189+
%Docstring
190+
Emitted whenever the expression variables stored in the layout have been changed.
191+
%End
28192

29193
};
30194

0 commit comments

Comments
 (0)
Please sign in to comment.