QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgsabstractgeopdfexporter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsabstractgeopdfexporter.h
3 --------------------------
4 begin : August 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSABSTRACTGEOPDFEXPORTER_H
17#define QGSABSTRACTGEOPDFEXPORTER_H
18
19#include "qgis_core.h"
22#include "qgsfeature.h"
23#include "qgspolygon.h"
24
25#include <QDateTime>
26#include <QList>
27#include <QMutex>
28#include <QPainter>
29#include <QTemporaryDir>
30
31#define SIP_NO_FILE
32
33class QgsGeospatialPdfRenderedFeatureHandler;
34
55{
56 public:
64
72
74
76
102
108 struct CORE_EXPORT ComponentLayerDetail
109 {
111 QString name;
112
114 QString mapLayerId;
115
117 QString group;
118
121
123 QPainter::CompositionMode compositionMode = QPainter::CompositionMode_SourceOver;
124
126 double opacity = 1.0;
127 };
128
151
153 {
160
167
170
172 QList< QgsAbstractGeospatialPdfExporter::ControlPoint > controlPoints;
173 };
174
182 void pushRenderedFeature( const QString &layerId, const QgsAbstractGeospatialPdfExporter::RenderedFeature &feature, const QString &group = QString() );
183
185 {
188
190 double dpi = 300;
191
193 QList< QgsAbstractGeospatialPdfExporter::GeoReferencedSection > georeferencedSections;
194
196 QString author;
197
199 QString producer;
200
202 QString creator;
203
206
208 QString subject;
209
211 QString title;
212
215
224
235
239 bool includeFeatures = true;
240
253 QMap< QString, QString > customLayerTreeGroups;
254
260 QMap< QString, QString > layerIdToPdfLayerTreeNameMap;
261
268 QMap< QString, bool > initialLayerVisibility;
269
279 QStringList layerOrder;
280
292
298 QSet< QString > mutuallyExclusiveGroups;
299 };
300
314 bool finalize( const QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > &components, const QString &destinationFile, const ExportDetails &details );
315
319 QString errorMessage() const { return mErrorMessage; }
320
324 QString generateTemporaryFilepath( const QString &filename ) const;
325
332 static bool compositionModeSupported( QPainter::CompositionMode mode );
333
334 protected:
339 {
341 QString name;
342
344 QString mapLayerId;
345
347 QString group;
348
351
354
357 };
358
359 private:
360 QMutex mMutex;
361 QMap< QString, QMap< QString, QgsFeatureList > > mCollatedFeatures;
362
366 virtual VectorComponentDetail componentDetailForLayerId( const QString &layerId ) = 0;
367
368 QList< VectorComponentDetail > mVectorComponents;
369
370 QString mErrorMessage;
371 QTemporaryDir mTemporaryDir;
372
373
374 bool saveTemporaryLayers();
375
376 QString createCompositionXml( const QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > &components, const ExportDetails &details );
377
381 static QString compositionModeToString( QPainter::CompositionMode mode );
382
385};
386
387#endif //QGSABSTRACTGEOPDFEXPORTER_H
static QString geospatialPDFAvailabilityExplanation()
Returns a user-friendly, translated string explaining why Geospatial PDF export support is not availa...
bool finalize(const QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > &components, const QString &destinationFile, const ExportDetails &details)
To be called after the rendering operation is complete.
void pushRenderedFeature(const QString &layerId, const QgsAbstractGeospatialPdfExporter::RenderedFeature &feature, const QString &group=QString())
Called multiple times during the rendering operation, whenever a feature associated with the specifie...
virtual ~QgsAbstractGeospatialPdfExporter()=default
QString errorMessage() const
Returns the last error message encountered during the export.
static bool geospatialPDFCreationAvailable()
Returns true if the current QGIS build is capable of Geospatial PDF support.
QMap< QString, QStringList > KeywordMap
Map of vocabulary string to keyword list.
Represents a coordinate reference system (CRS).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
A geometry is the spatial representation of a feature.
Represents a 2D point.
Definition qgspointxy.h:62
Polygon geometry type.
Definition qgspolygon.h:37
A rectangle specified with double values.
Contains details of a particular input component to be used during PDF composition.
QString mapLayerId
Associated map layer ID, or an empty string if this component layer is not associated with a map laye...
QString group
Optional group name, for arranging layers in top-level groups.
QString name
User-friendly name for the generated PDF layer.
QPainter::CompositionMode compositionMode
Component composition mode.
QString sourcePdfPath
File path to the (already created) PDF to use as the source for this component layer.
QgsPointXY pagePoint
Coordinate on the page of the control point, in millimeters.
QgsPointXY geoPoint
Georeferenced coordinate of the control point, in CRS units.
ControlPoint(const QgsPointXY &pagePoint, const QgsPointXY &geoPoint)
Constructor for ControlPoint, at the specified pagePoint (in millimeters) and geoPoint (in CRS units)...
QMap< QString, QString > customLayerTreeGroups
Optional map of map layer ID to custom logical layer tree group in created PDF file.
QMap< QString, bool > initialLayerVisibility
Optional map of map layer ID to initial visibility state.
QList< QgsAbstractGeospatialPdfExporter::GeoReferencedSection > georeferencedSections
List of georeferenced sections.
QStringList layerOrder
Optional list of layer IDs, in the order desired to appear in the generated Geospatial PDF file.
QMap< QString, QString > layerIdToPdfLayerTreeNameMap
Optional map of map layer ID to custom layer tree name to show in the created PDF file.
QgsAbstractMetadataBase::KeywordMap keywords
Metadata keyword map.
bool useOgcBestPracticeFormatGeoreferencing
true if OGC "best practice" format georeferencing should be used.
QStringList layerTreeGroupOrder
Specifies the ordering of layer tree groups in the generated Geospatial PDF file.
QDateTime creationDateTime
Metadata creation datetime.
bool includeFeatures
true if feature vector information (such as attributes) should be exported.
bool useIso32000ExtensionFormatGeoreferencing
true if ISO32000 extension format georeferencing should be used.
QSet< QString > mutuallyExclusiveGroups
Contains a list of group names which should be considered as mutually exclusive.
QgsRectangle pageBoundsMm
Bounds of the georeferenced section on the page, in millimeters.
QgsCoordinateReferenceSystem crs
Coordinate reference system for georeferenced section.
QList< QgsAbstractGeospatialPdfExporter::ControlPoint > controlPoints
List of control points corresponding to this georeferenced section.
QgsPolygon pageBoundsPolygon
Bounds of the georeferenced section on the page, in millimeters, as a free-form polygon.
Contains information about a feature rendered inside the PDF.
QgsGeometry renderedBounds
Bounds, in PDF units, of rendered feature.
RenderedFeature(const QgsFeature &feature, const QgsGeometry &renderedBounds)
Constructor for RenderedFeature.
Contains information relating to a single PDF layer in the Geospatial PDF export.
QString name
User-friendly name for the generated PDF layer.
QString sourceVectorPath
File path to the (already created) vector dataset to use as the source for this component layer.
QString sourceVectorLayer
Layer name in vector dataset to use as the source.