File: qgslayoutexporter.sip.in

package info (click to toggle)
qgis 3.40.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,183,800 kB
  • sloc: cpp: 1,595,841; python: 372,637; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 154
file content (460 lines) | stat: -rw-r--r-- 13,687 bytes parent folder | download | duplicates (7)
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
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/layout/qgslayoutexporter.h                                  *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/





class QgsLayoutExporter
{
%Docstring(signature="appended")
Handles rendering and exports of layouts to various formats.
%End

%TypeHeaderCode
#include "qgslayoutexporter.h"
%End
  public:




    struct PageExportDetails
    {
      QString directory;

      QString baseName;

      QString extension;

      int page;
    };

    QgsLayoutExporter( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutExporter, for the specified ``layout``.
%End

    virtual ~QgsLayoutExporter();

    QgsLayout *layout() const;
%Docstring
Returns the layout linked to this exporter.
%End

    void renderPage( QPainter *painter, int page ) const;
%Docstring
Renders a full page to a destination ``painter``.

The ``page`` argument specifies the page number to render. Page numbers
are 0 based, such that the first page in a layout is page 0.

.. seealso:: :py:func:`renderRegion`
%End

    QImage renderPageToImage( int page, QSize imageSize = QSize(), double dpi = -1 ) const;
%Docstring
Renders a full page to an image.

The ``page`` argument specifies the page number to render. Page numbers
are 0 based, such that the first page in a layout is page 0.

The optional ``imageSize`` parameter can specify the target image size,
in pixels. It is the caller's responsibility to ensure that the ratio of
the target image size matches the ratio of the corresponding layout page
size.

The ``dpi`` parameter is an optional dpi override. Set to -1 to use the
default layout print resolution. This parameter has no effect if
``imageSize`` is specified.

Returns the rendered image, or a null QImage if the image does not fit
into available memory.

.. seealso:: :py:func:`renderPage`

.. seealso:: :py:func:`renderRegionToImage`
%End

    void renderRegion( QPainter *painter, const QRectF &region ) const;
%Docstring
Renders a ``region`` from the layout to a ``painter``. This method can
be used to render sections of pages rather than full pages.

.. seealso:: :py:func:`renderPage`

.. seealso:: :py:func:`renderRegionToImage`
%End

    QImage renderRegionToImage( const QRectF &region, QSize imageSize = QSize(), double dpi = -1 ) const;
%Docstring
Renders a ``region`` of the layout to an image. This method can be used
to render sections of pages rather than full pages.

The optional ``imageSize`` parameter can specify the target image size,
in pixels. It is the caller's responsibility to ensure that the ratio of
the target image size matches the ratio of the specified region of the
layout.

The ``dpi`` parameter is an optional dpi override. Set to -1 to use the
default layout print resolution. This parameter has no effect if
``imageSize`` is specified.

Returns the rendered image, or a null QImage if the image does not fit
into available memory.

.. seealso:: :py:func:`renderRegion`

.. seealso:: :py:func:`renderPageToImage`
%End


    enum ExportResult /BaseType=IntEnum/
    {
      Success,
      Canceled,
      MemoryError,
      FileError,
      PrintError,
      SvgLayerError,
      IteratorError,
    };

    struct ImageExportSettings
    {
      ImageExportSettings();

      double dpi;

      QSize imageSize;

      bool cropToContents;

      QgsMargins cropMargins;

      QList< int > pages;

      bool generateWorldFile;

      bool exportMetadata;


      QgsLayoutRenderContext::Flags flags;

      QVector<qreal> predefinedMapScales;

    };

    ExportResult exportToImage( const QString &filePath, const QgsLayoutExporter::ImageExportSettings &settings );
%Docstring
Exports the layout to the ``filePath``, using the specified export
``settings``.

If the layout is a multi-page layout, then filenames for each page will
automatically be generated by appending "_1", "_2", etc to the image
file's base name.

Returns a result code indicating whether the export was successful or an
error was encountered. If an error code is returned,
:py:func:`~QgsLayoutExporter.errorFile` can be called to determine the
filename for the export which encountered the error.
%End


    static ExportResult exportToImage( QgsAbstractLayoutIterator *iterator, const QString &baseFilePath,
                                       const QString &extension, const QgsLayoutExporter::ImageExportSettings &settings,
                                       QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to raster images, with the specified
export ``settings``.

The ``baseFilePath`` argument gives a base file path, which is modified
by the iterator to obtain file paths for each iterator feature.

Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be
set to the error description.
%End


    struct PdfExportSettings
    {
      PdfExportSettings();

      double dpi;

      bool rasterizeWholeImage;

      bool forceVectorOutput;

      bool appendGeoreference;

      bool exportMetadata;

      QgsLayoutRenderContext::Flags flags;

      Qgis::TextRenderFormat textRenderFormat;

      bool simplifyGeometries;

      bool writeGeoPdf;

      bool exportLayersAsSeperateFiles;

      bool useIso32000ExtensionFormatGeoreferencing;

      bool useOgcBestPracticeFormatGeoreferencing;

      bool includeGeoPdfFeatures;

      QStringList exportThemes;

      QVector<qreal> predefinedMapScales;
    };

    ExportResult exportToPdf( const QString &filePath, const QgsLayoutExporter::PdfExportSettings &settings );
%Docstring
Exports the layout as a PDF to the ``filePath``, using the specified
export ``settings``.

Returns a result code indicating whether the export was successful or an
error was encountered.
%End

    static ExportResult exportToPdf( QgsAbstractLayoutIterator *iterator, const QString &fileName,
                                     const QgsLayoutExporter::PdfExportSettings &settings,
                                     QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to a single PDF file, with the specified
export ``settings``.

The ``fileName`` argument gives the destination file name for the output
PDF.

Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be
set to the error description.

.. seealso:: :py:func:`exportToPdfs`
%End

    static ExportResult exportToPdfs( QgsAbstractLayoutIterator *iterator, const QString &baseFilePath,
                                      const QgsLayoutExporter::PdfExportSettings &settings,
                                      QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to multiple PDF files, with the specified
export ``settings``.

The ``baseFilePath`` argument gives a base file path, which is modified
by the iterator to obtain file paths for each iterator feature.

Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be
set to the error description.

.. seealso:: :py:func:`exportToPdf`
%End


    struct PrintExportSettings
    {
      PrintExportSettings();

      double dpi;

      bool rasterizeWholeImage;

      QgsLayoutRenderContext::Flags flags;

      QVector<qreal> predefinedMapScales;

    };

%If (HAVE_QTPRINTER)

    ExportResult print( QPrinter &printer, const QgsLayoutExporter::PrintExportSettings &settings );
%Docstring
Prints the layout to a ``printer``, using the specified export
``settings``.

Returns a result code indicating whether the export was successful or an
error was encountered.
%End

    static ExportResult print( QgsAbstractLayoutIterator *iterator, QPrinter &printer,
                               const QgsLayoutExporter::PrintExportSettings &settings,
                               QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to a ``printer``, with the specified
export ``settings``.

Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be
set to the error description.
%End

%End

    struct SvgExportSettings
    {
      SvgExportSettings();

      double dpi;

      bool forceVectorOutput;

      bool cropToContents;

      QgsMargins cropMargins;

      bool exportAsLayers;

      bool exportLabelsToSeparateLayers;

      bool exportMetadata;

      QgsLayoutRenderContext::Flags flags;

      Qgis::TextRenderFormat textRenderFormat;

      bool simplifyGeometries;

      QVector<qreal> predefinedMapScales;
    };

    ExportResult exportToSvg( const QString &filePath, const QgsLayoutExporter::SvgExportSettings &settings );
%Docstring
Exports the layout as an SVG to the ``filePath``, using the specified
export ``settings``.

Returns a result code indicating whether the export was successful or an
error was encountered.
%End

    static ExportResult exportToSvg( QgsAbstractLayoutIterator *iterator, const QString &baseFilePath,
                                     const QgsLayoutExporter::SvgExportSettings &settings,
                                     QString &error /Out/, QgsFeedback *feedback = 0 );
%Docstring
Exports a layout ``iterator`` to SVG files, with the specified export
``settings``.

The ``baseFilePath`` argument gives a base file path, which is modified
by the iterator to obtain file paths for each iterator feature.

Returns a result code indicating whether the export was successful or an
error was encountered. If an error was obtained then ``error`` will be
set to the error description.
%End


    QString errorFile() const;
%Docstring
Returns the file name corresponding to the last error encountered during
an export.
%End

    QString errorMessage() const;
%Docstring
Returns a string describing the last error encountered during an export.

.. versionadded:: 3.38
%End

    QMap< QString, QgsLabelingResults * > labelingResults();
%Docstring
Returns the labeling results for all map items included in the export.
Map keys are the item UUIDs (see :py:func:`QgsLayoutItem.uuid()`).

Ownership of the results remains with the layout exporter.

.. versionadded:: 3.20
%End


    bool georeferenceOutput( const QString &file, QgsLayoutItemMap *referenceMap = 0,
                             const QRectF &exportRegion = QRectF(), double dpi = -1 ) const;
%Docstring
Georeferences a ``file`` (image of PDF) exported from the layout.

The ``referenceMap`` argument specifies a map item to use for
georeferencing. If left as ``None``, the default layout
:py:func:`QgsLayout.referenceMap()` will be used.

The ``exportRegion`` argument can be set to a valid rectangle to
indicate that only part of the layout was exported.

Similarly, the ``dpi`` can be set to the actual DPI of exported file, or
left as -1 to use the layout's default DPI.

The function will return ``True`` if the output was successfully
georeferenced.

.. seealso:: :py:func:`computeWorldFileParameters`
%End

    void computeWorldFileParameters( double &a, double &b, double &c, double &d, double &e, double &f, double dpi = -1 ) const;
%Docstring
Compute world file parameters. Assumes the whole page containing the
reference map item will be exported.

The ``dpi`` argument can be set to the actual DPI of exported file, or
left as -1 to use the layout's default DPI.
%End

    void computeWorldFileParameters( const QRectF &region, double &a, double &b, double &c, double &d, double &e, double &f, double dpi = -1 ) const;
%Docstring
Computes the world file parameters for a specified ``region`` of the
layout.

The ``dpi`` argument can be set to the actual DPI of exported file, or
left as -1 to use the layout's default DPI.
%End

    static bool requiresRasterization( const QgsLayout *layout );
%Docstring
Returns ``True`` if the specified ``layout`` contains visible items
which have settings that require rasterization of the entire export
layout in order to reproduce the desired appearance.

.. seealso:: :py:func:`containsAdvancedEffects`

.. versionadded:: 3.20
%End

    static bool containsAdvancedEffects( const QgsLayout *layout );
%Docstring
Returns ``True`` if the specified ``layout`` contains visible items
which have settings such as opacity which will prevent these individual
items from being exported as vector artwork.

.. seealso:: :py:func:`requiresRasterization`

.. versionadded:: 3.20
%End

  protected:

    virtual QString generateFileName( const PageExportDetails &details ) const;
%Docstring
Generates the file name for a page during export.

Subclasses can override this method to customize page file naming.
%End

};




/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/layout/qgslayoutexporter.h                                  *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/