30#include <QMutexLocker> 
   31#include <QDomDocument> 
   40      : mExporter( exporter )
 
   42      , mLayerIds( layerIds )
 
   50      const double pageHeightPdfUnits = pageSizeInches.
height() * 72;
 
   51      const double pageWidthPdfUnits = pageSizeInches.
width() * 72;
 
   53      QTransform mapTransform;
 
   54      QPolygonF mapRectPoly = QPolygonF( QRectF( 0, 0, map->rect().width(), map->rect().height() ) );
 
   56      mapRectPoly.pop_back();
 
   58      QPolygonF mapRectInLayout = map->mapToScene( mapRectPoly );
 
   61      QTransform::quadToQuad( mapRectPoly, mapRectInLayout, mMapToLayoutTransform );
 
   64      mLayoutToPdfTransform = QTransform::fromTranslate( 0, pageHeightPdfUnits ).scale( pageWidthPdfUnits / pageSizeLayoutUnits.width(),
 
   65                              -pageHeightPdfUnits / pageSizeLayoutUnits.height() );
 
   74      if ( !mLayerIds.contains( layerId ) )
 
   77      const QString theme = ( mMap->mExportThemes.isEmpty() || mMap->mExportThemeIt == mMap->mExportThemes.end() ) ? QString() : *mMap->mExportThemeIt;
 
   82      transformed.
transform( pixelToMapItemTransform );
 
   84      transformed.
transform( mMapToLayoutTransform );
 
   86      transformed.
transform( mLayoutToPdfTransform );
 
  100    QTransform mMapToLayoutTransform;
 
  101    QTransform mLayoutToPdfTransform;
 
  104    QStringList mLayerIds;
 
  112  QStringList exportableLayerIds;
 
  113  const QMap< QString, QgsMapLayer * > layers = mLayout->
project()->
mapLayers( 
true );
 
  114  for ( 
auto it = layers.constBegin(); it != layers.constEnd(); ++it )
 
  118      const QVariant visibility = ml->customProperty( QStringLiteral( 
"geopdf/initiallyVisible" ), true );
 
  119      mInitialLayerVisibility.insert( ml->id(), !visibility.isValid() ? true : visibility.toBool() );
 
  122        const QVariant v = ml->customProperty( QStringLiteral( 
"geopdf/includeFeatures" ) );
 
  123        if ( !v.isValid() || v.toBool() )
 
  125          exportableLayerIds << ml->id();
 
  129      const QString groupName = ml->customProperty( QStringLiteral( 
"geopdf/groupName" ) ).toString();
 
  130      if ( !groupName.isEmpty() )
 
  131        mCustomLayerTreeGroups.insert( ml->id(), groupName );
 
  136  QList< QgsLayoutItemMap * > maps;
 
  140    QgsGeoPdfRenderedFeatureHandler *handler = 
new QgsGeoPdfRenderedFeatureHandler( map, 
this, exportableLayerIds );
 
  141    mMapHandlers.insert( map, handler );
 
  145  mLayerTreeGroupOrder = mLayout->
customProperty( QStringLiteral( 
"pdfGroupOrder" ) ).toStringList();
 
  148  QStringList geoPdfLayerOrder;
 
  149  const QString presetLayerOrder = mLayout->
customProperty( QStringLiteral( 
"pdfLayerOrder" ) ).toString();
 
  150  if ( !presetLayerOrder.isEmpty() )
 
  151    geoPdfLayerOrder = presetLayerOrder.split( QStringLiteral( 
"~~~" ) );
 
  154  for ( 
auto it = geoPdfLayerOrder.rbegin(); it != geoPdfLayerOrder.rend(); ++it )
 
  167    mLayerOrder << layer->id();
 
 
  173  for ( 
auto it = mMapHandlers.constBegin(); it != mMapHandlers.constEnd(); ++it )
 
  175    it.key()->removeRenderedFeatureHandler( it.value() );
 
 
  183  VectorComponentDetail detail;
 
  185  detail.
name = layer ? layer->
name() : layerId;
 
  186  detail.mapLayerId = layerId;
 
  187  if ( 
const QgsVectorLayer *vl = qobject_cast< const QgsVectorLayer * >( layer ) )
 
  189    detail.displayAttribute = vl->displayField();
 
QVariant variable(const QString &name) const
Fetches a matching variable from the context.
 
static const QString ALL_ATTRIBUTES
A special attribute that if set matches all attributes.
 
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
 
A geometry is the spatial representation of a feature.
 
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
 
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
 
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas.
 
Handles GeoPDF export specific setup, cleanup and processing steps.
 
QStringList layerOrder() const
Optional list of map layer IDs in the order they should be shown in the generated GeoPDF layer tree.
 
QgsLayoutGeoPdfExporter(QgsLayout *layout)
Constructor for QgsLayoutGeoPdfExporter, associated with the specified layout.
 
~QgsLayoutGeoPdfExporter() override
 
Layout graphical items for displaying a map.
 
void addRenderedFeatureHandler(QgsRenderedFeatureHandlerInterface *handler)
Adds a rendered feature handler to use while rendering the map.
 
QgsLayoutSize pageSize() const
Returns the size of the page.
 
int page() const
Returns the page the item is currently on, with the first page returning 0.
 
QgsLayoutMeasurement convert(QgsLayoutMeasurement measurement, Qgis::LayoutUnit targetUnits) const
Converts a measurement from one unit to another.
 
const QgsLayout * layout() const
Returns the layout the object is attached to.
 
QgsLayoutItemPage * page(int pageNumber)
Returns a specific page (by pageNumber) from the collection.
 
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
 
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
 
double height() const
Returns the height of the size.
 
double width() const
Returns the width of the size.
 
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
 
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
 
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout.
 
void layoutItems(QList< T * > &itemList) const
Returns a list of layout items of a specific type.
 
double convertToLayoutUnits(QgsLayoutMeasurement measurement) const
Converts a measurement into the layout's native units.
 
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from the layout.
 
QgsProject * project() const
The project associated with the layout.
 
Base class for all map layer types.
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
 
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
 
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
 
Contains information about the context of a rendering operation.
 
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
 
QgsExpressionContext & expressionContext()
Gets the expression context.
 
An interface for classes which provider custom handlers for features rendered as part of a map render...
 
virtual QSet< QString > usedAttributes(QgsVectorLayer *layer, const QgsRenderContext &context) const
Returns a list of attributes required by this handler, for the specified layer.
 
virtual void handleRenderedFeature(const QgsFeature &feature, const QgsGeometry &renderedBounds, const QgsRenderedFeatureHandlerInterface::RenderedFeatureContext &context)=0
Called whenever a feature is rendered during a map render job.
 
Represents a vector layer which manages a vector based data sets.
 
Contains information about a feature rendered inside the PDF.
 
Contains information relating to a single PDF layer in the GeoPDF export.
 
const QgsRenderContext & renderContext
The render context which was used while rendering feature.