/
qgslayout.sip
557 lines (454 loc) · 17.7 KB
/
qgslayout.sip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayout.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoObjectInterface
{
%Docstring
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgslayout.h"
%End
public:
enum ZValues
{
ZPage,
ZItem,
ZGrid,
ZGuide,
ZSmartGuide,
ZMouseHandles,
ZViewTool,
ZSnapIndicator,
};
QgsLayout( QgsProject *project );
%Docstring
Construct a new layout linked to the specified ``project``.
If the layout is a "new" layout (as opposed to a layout which will
restore a previous state from XML) then initializeDefaults() should be
called on the new layout.
%End
~QgsLayout();
void initializeDefaults();
%Docstring
Initializes an empty layout, e.g. by adding a default page to the layout. This should be called after creating
a new layout.
%End
void clear();
%Docstring
Clears the layout.
Calling this method removes all items and pages from the layout.
%End
QgsProject *project() const;
%Docstring
The project associated with the layout. Used to get access to layers, map themes,
relations and various other bits. It is never null.
:rtype: QgsProject
%End
QgsLayoutModel *itemsModel();
%Docstring
Returns the items model attached to the layout.
:rtype: QgsLayoutModel
%End
QgsLayoutExporter &exporter();
%Docstring
Returns the layout's exporter, which is used for rendering the layout and exporting
to various formats.
:rtype: QgsLayoutExporter
%End
QString name() const;
%Docstring
Returns the layout's name.
.. seealso:: :py:func:`setName()`
:rtype: str
%End
void setName( const QString &name );
%Docstring
Sets the layout's name.
.. seealso:: :py:func:`name()`
%End
QList<QgsLayoutItem *> selectedLayoutItems( const bool includeLockedItems = true );
%Docstring
Returns list of selected layout items.
If ``includeLockedItems`` is set to true, then locked items will also be included
in the returned list.
:rtype: list of QgsLayoutItem
%End
void setSelectedItem( QgsLayoutItem *item );
%Docstring
Clears any selected items and sets ``item`` as the current selection.
%End
void deselectAll();
%Docstring
Clears any selected items in the layout.
Call this method rather than QGraphicsScene.clearSelection, as the latter does
not correctly emit signals to allow the layout's model to update.
%End
bool raiseItem( QgsLayoutItem *item, bool deferUpdate = false );
%Docstring
Raises an ``item`` up the z-order.
Returns true if the item was successfully raised.
If ``deferUpdate`` is true, the scene will not be visibly updated
to reflect the new stacking order. This allows multiple
raiseItem() calls to be made in sequence without the cost of
updating the scene for each one.
.. seealso:: :py:func:`lowerItem()`
.. seealso:: :py:func:`updateZValues()`
:rtype: bool
%End
bool lowerItem( QgsLayoutItem *item, bool deferUpdate = false );
%Docstring
Lowers an ``item`` down the z-order.
Returns true if the item was successfully lowered.
If ``deferUpdate`` is true, the scene will not be visibly updated
to reflect the new stacking order. This allows multiple
raiseItem() calls to be made in sequence without the cost of
updating the scene for each one.
.. seealso:: :py:func:`raiseItem()`
.. seealso:: :py:func:`updateZValues()`
:rtype: bool
%End
bool moveItemToTop( QgsLayoutItem *item, bool deferUpdate = false );
%Docstring
Raises an ``item`` up to the top of the z-order.
Returns true if the item was successfully raised.
If ``deferUpdate`` is true, the scene will not be visibly updated
to reflect the new stacking order. This allows multiple
raiseItem() calls to be made in sequence without the cost of
updating the scene for each one.
.. seealso:: :py:func:`moveItemToBottom()`
.. seealso:: :py:func:`updateZValues()`
:rtype: bool
%End
bool moveItemToBottom( QgsLayoutItem *item, bool deferUpdate = false );
%Docstring
Lowers an ``item`` down to the bottom of the z-order.
Returns true if the item was successfully lowered.
If ``deferUpdate`` is true, the scene will not be visibly updated
to reflect the new stacking order. This allows multiple
raiseItem() calls to be made in sequence without the cost of
updating the scene for each one.
.. seealso:: :py:func:`moveItemToTop()`
.. seealso:: :py:func:`updateZValues()`
:rtype: bool
%End
void updateZValues( const bool addUndoCommands = true );
%Docstring
Resets the z-values of items based on their position in the internal
z order list. This should be called after any stacking changes
which deferred z-order updates.
%End
QgsLayoutItem *itemByUuid( const QString &uuid );
%Docstring
Returns the layout item with matching ``uuid`` unique identifier, or a None
if a matching item could not be found.
.. seealso:: :py:func:`multiFrameByUuid()`
:rtype: QgsLayoutItem
%End
QgsLayoutMultiFrame *multiFrameByUuid( const QString &uuid ) const;
%Docstring
Returns the layout multiframe with matching ``uuid`` unique identifier, or a None
if a matching multiframe could not be found.
.. seealso:: :py:func:`itemByUuid()`
:rtype: QgsLayoutMultiFrame
%End
QgsLayoutItem *layoutItemAt( QPointF position, const bool ignoreLocked = false ) const;
%Docstring
Returns the topmost layout item at a specified ``position``. Ignores paper items.
If ``ignoreLocked`` is set to true any locked items will be ignored.
:rtype: QgsLayoutItem
%End
QgsLayoutItem *layoutItemAt( QPointF position, const QgsLayoutItem *belowItem, const bool ignoreLocked = false ) const;
%Docstring
Returns the topmost composer item at a specified ``position`` which is below a specified ``item``. Ignores paper items.
If ``ignoreLocked`` is set to true any locked items will be ignored.
:rtype: QgsLayoutItem
%End
void setUnits( QgsUnitTypes::LayoutUnit units );
%Docstring
Sets the native measurement ``units`` for the layout. These also form the default unit
for measurements for the layout.
.. seealso:: :py:func:`units()`
.. seealso:: :py:func:`convertToLayoutUnits()`
%End
QgsUnitTypes::LayoutUnit units() const;
%Docstring
Returns the native units for the layout.
.. seealso:: :py:func:`setUnits()`
.. seealso:: :py:func:`convertToLayoutUnits()`
:rtype: QgsUnitTypes.LayoutUnit
%End
double convertToLayoutUnits( const QgsLayoutMeasurement &measurement ) const;
%Docstring
Converts a measurement into the layout's native units.
:return: length of measurement in layout units
.. seealso:: :py:func:`convertFromLayoutUnits()`
.. seealso:: :py:func:`units()`
:rtype: float
%End
QSizeF convertToLayoutUnits( const QgsLayoutSize &size ) const;
%Docstring
Converts a size into the layout's native units.
:return: size of measurement in layout units
.. seealso:: :py:func:`convertFromLayoutUnits()`
.. seealso:: :py:func:`units()`
:rtype: QSizeF
%End
QPointF convertToLayoutUnits( const QgsLayoutPoint &point ) const;
%Docstring
Converts a ``point`` into the layout's native units.
:return: point in layout units
.. seealso:: :py:func:`convertFromLayoutUnits()`
.. seealso:: :py:func:`units()`
:rtype: QPointF
%End
QgsLayoutMeasurement convertFromLayoutUnits( const double length, const QgsUnitTypes::LayoutUnit unit ) const;
%Docstring
Converts a ``length`` measurement from the layout's native units to a specified target ``unit``.
:return: length of measurement in specified units
.. seealso:: :py:func:`convertToLayoutUnits()`
.. seealso:: :py:func:`units()`
:rtype: QgsLayoutMeasurement
%End
QgsLayoutSize convertFromLayoutUnits( const QSizeF &size, const QgsUnitTypes::LayoutUnit unit ) const;
%Docstring
Converts a ``size`` from the layout's native units to a specified target ``unit``.
:return: size of measurement in specified units
.. seealso:: :py:func:`convertToLayoutUnits()`
.. seealso:: :py:func:`units()`
:rtype: QgsLayoutSize
%End
QgsLayoutPoint convertFromLayoutUnits( const QPointF &point, const QgsUnitTypes::LayoutUnit unit ) const;
%Docstring
Converts a ``point`` from the layout's native units to a specified target ``unit``.
:return: point in specified units
.. seealso:: :py:func:`convertToLayoutUnits()`
.. seealso:: :py:func:`units()`
:rtype: QgsLayoutPoint
%End
QgsLayoutContext &context();
%Docstring
Returns a reference to the layout's context, which stores information relating to the
current context and rendering settings for the layout.
:rtype: QgsLayoutContext
%End
QgsLayoutSnapper &snapper();
%Docstring
Returns a reference to the layout's snapper, which stores handles layout snap grids and lines
and snapping points to the nearest matching point.
:rtype: QgsLayoutSnapper
%End
QgsLayoutGridSettings &gridSettings();
%Docstring
Returns a reference to the layout's grid settings, which stores settings relating
to grid appearance, spacing and offsets.
:rtype: QgsLayoutGridSettings
%End
QgsLayoutGuideCollection &guides();
%Docstring
Returns a reference to the layout's guide collection, which manages page snap guides.
:rtype: QgsLayoutGuideCollection
%End
virtual QgsExpressionContext createExpressionContext() const;
%Docstring
Creates an expression context relating to the layout's current state. The context includes
scopes for global, project, layout and layout context properties.
:rtype: QgsExpressionContext
%End
void setCustomProperty( const QString &key, const QVariant &value );
%Docstring
Set a custom property for the layout.
\param key property key. If a property with the same key already exists it will be overwritten.
\param value property value
.. seealso:: :py:func:`customProperty()`
.. seealso:: :py:func:`removeCustomProperty()`
.. seealso:: :py:func:`customProperties()`
%End
QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
%Docstring
Read a custom property from the layout.
\param key property key
\param defaultValue default value to return if property with matching key does not exist
:return: value of matching property
.. seealso:: :py:func:`setCustomProperty()`
.. seealso:: :py:func:`removeCustomProperty()`
.. seealso:: :py:func:`customProperties()`
:rtype: QVariant
%End
void removeCustomProperty( const QString &key );
%Docstring
Remove a custom property from the layout.
\param key property key
.. seealso:: :py:func:`setCustomProperty()`
.. seealso:: :py:func:`customProperty()`
.. seealso:: :py:func:`customProperties()`
%End
QStringList customProperties() const;
%Docstring
Return list of keys stored in custom properties for the layout.
.. seealso:: :py:func:`setCustomProperty()`
.. seealso:: :py:func:`customProperty()`
.. seealso:: :py:func:`removeCustomProperty()`
:rtype: list of str
%End
QgsLayoutItemMap *referenceMap() const;
%Docstring
:rtype: QgsLayoutItemMap
%End
void setReferenceMap( QgsLayoutItemMap *map );
QgsLayoutPageCollection *pageCollection();
%Docstring
Returns a pointer to the layout's page collection, which stores and manages
page items in the layout.
:rtype: QgsLayoutPageCollection
%End
QRectF layoutBounds( bool ignorePages = false, double margin = 0.0 ) const;
%Docstring
Calculates the bounds of all non-gui items in the layout. Ignores snap lines, mouse handles
and other cosmetic items.
\param ignorePages set to true to ignore page items
\param margin optional marginal (in percent, e.g., 0.05 = 5% ) to add around items
:return: layout bounds, in layout units.
:rtype: QRectF
%End
void addLayoutItem( QgsLayoutItem *item /Transfer/ );
%Docstring
Adds an ``item`` to the layout. This should be called instead of the base class addItem()
method. Ownership of the item is transferred to the layout.
%End
void removeLayoutItem( QgsLayoutItem *item );
%Docstring
Removes an ``item`` from the layout. This should be called instead of the base class removeItem()
method.
The item will also be deleted.
%End
void addMultiFrame( QgsLayoutMultiFrame *multiFrame /Transfer/ );
%Docstring
Adds a ``multiFrame`` to the layout. The object is owned by the layout until removeMultiFrame() is called.
.. seealso:: :py:func:`removeMultiFrame()`
.. seealso:: :py:func:`multiFrames()`
%End
void removeMultiFrame( QgsLayoutMultiFrame *multiFrame );
%Docstring
Removes a ``multiFrame`` from the layout (but does not delete it).
.. seealso:: :py:func:`addMultiFrame()`
.. seealso:: :py:func:`multiFrames()`
%End
QList< QgsLayoutMultiFrame * > multiFrames() const;
%Docstring
Returns a list of multi frames contained in the layout.
.. seealso:: :py:func:`addMultiFrame()`
.. seealso:: :py:func:`removeMultiFrame()`
:rtype: list of QgsLayoutMultiFrame
%End
bool saveAsTemplate( const QString &path, const QgsReadWriteContext &context ) const;
%Docstring
Saves the layout as a template at the given file ``path``.
Returns true if save was successful.
.. seealso:: loadFromTemplate()
:rtype: bool
%End
QList< QgsLayoutItem * > loadFromTemplate( const QDomDocument &document, const QgsReadWriteContext &context, bool clearExisting = true, bool *ok /Out/ = 0 );
%Docstring
Load a layout template ``document``.
By default this method will clear all items from the existing layout and real all layout
settings from the template. Setting ``clearExisting`` to false will only add new items
from the template, without overwriting the existing items or layout settings.
If ``ok`` is specified, it will be set to true if the load was successful.
Returns a list of loaded items.
:rtype: list of QgsLayoutItem
%End
QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const;
%Docstring
Returns the layout's state encapsulated in a DOM element.
.. seealso:: :py:func:`readXml()`
:rtype: QDomElement
%End
bool readXml( const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context );
%Docstring
Sets the collection's state from a DOM element. ``layoutElement`` is the DOM node corresponding to the layout.
.. seealso:: :py:func:`writeXml()`
:rtype: bool
%End
QList< QgsLayoutItem * > addItemsFromXml( const QDomElement &parentElement, const QDomDocument &document,
const QgsReadWriteContext &context,
QPointF *position = 0, bool pasteInPlace = false );
%Docstring
Add items from an XML representation to the layout. Used for project file reading and pasting items from clipboard.
The ``position`` argument is optional, and if it is not specified the items will be restored to their
original position from the XML serialization. If specified, the items will be positioned such that the top-left
bounds of all added items is located at this ``position``.
The ``pasteInPlace`` argument determines whether the serialized position should be respected, but remapped to the
origin of the page corresponding to the page at ``position``.
A list of the newly added items is returned.
:rtype: list of QgsLayoutItem
%End
QgsLayoutUndoStack *undoStack();
%Docstring
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout
and it's associated objects.
:rtype: QgsLayoutUndoStack
%End
virtual QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id = 0, QUndoCommand *parent = 0 ) /Factory/;
QgsLayoutItemGroup *groupItems( const QList<QgsLayoutItem *> &items );
%Docstring
Creates a new group from a list of layout ``items`` and adds the group to the layout.
If grouping was not possible, a None will be returned.
.. seealso:: :py:func:`ungroupItems()`
:rtype: QgsLayoutItemGroup
%End
QList<QgsLayoutItem *> ungroupItems( QgsLayoutItemGroup *group );
%Docstring
Ungroups items by removing them from an item ``group`` and removing the group from the
layout. Child items will remain in the layout and will not be deleted.
Returns a list of the items removed from the group, or an empty list if ungrouping
was not successful.
.. seealso:: :py:func:`groupItems()`
:rtype: list of QgsLayoutItem
%End
public slots:
void refresh();
%Docstring
Forces the layout, and all items contained within it, to refresh. For instance, this causes maps to redraw
and rebuild cached images, html items to reload their source url, and attribute tables
to refresh their contents. Calling this also triggers a recalculation of all data defined
attributes within the layout.
.. seealso:: :py:func:`refreshed()`
%End
void updateBounds();
%Docstring
Updates the scene bounds of the layout.
%End
signals:
void variablesChanged();
%Docstring
Emitted whenever the expression variables stored in the layout have been changed.
%End
void selectedItemChanged( QgsLayoutItem *selected );
%Docstring
Emitted whenever the selected item changes.
If None, no item is selected.
%End
void refreshed();
%Docstring
Is emitted when the layout has been refreshed and items should also be refreshed
and updated.
%End
void nameChanged( const QString &name );
%Docstring
Emitted when the layout's name is changed.
.. seealso:: setName()
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayout.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/