Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3c4eb9
commit 1a294df
Showing
6 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*************************************************************************** | ||
qgslayoutgeopdfexporter.cpp | ||
-------------------------- | ||
begin : August 2019 | ||
copyright : (C) 2019 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgslayoutgeopdfexporter.h" | ||
#include "qgsrenderedfeaturehandlerinterface.h" | ||
#include "qgsfeaturerequest.h" | ||
#include "qgslayout.h" | ||
#include "qgslogger.h" | ||
|
||
class QgsGeoPdfRenderedFeatureHandler: public QgsRenderedFeatureHandlerInterface | ||
{ | ||
public: | ||
void handleRenderedFeature( const QgsFeature &feature, const QgsGeometry &renderedBounds, const QgsRenderedFeatureHandlerInterface::RenderedFeatureContext &context ) override | ||
{ | ||
QgsDebugMsg( QStringLiteral( "%1: %2" ).arg( context.renderContext->expressionContext().variable( QStringLiteral( "layer_id" ) ).toString() ).arg( feature.attribute( 0 ).toString() ) ); | ||
} | ||
|
||
QSet<QString> usedAttributes( QgsVectorLayer *, const QgsRenderContext & ) const override | ||
{ | ||
return QSet< QString >() << QgsFeatureRequest::ALL_ATTRIBUTES; | ||
} | ||
}; | ||
|
||
|
||
QgsLayoutGeoPdfExporter::QgsLayoutGeoPdfExporter( QgsLayout *layout ) | ||
: mLayout( layout ) | ||
, mHandler( qgis::make_unique< QgsGeoPdfRenderedFeatureHandler >() ) | ||
{ | ||
// on construction, we install a rendered feature handler on layout item maps | ||
mLayout->layoutItems( mMaps ); | ||
for ( QgsLayoutItemMap *map : qgis::as_const( mMaps ) ) | ||
{ | ||
map->addRenderedFeatureHandler( mHandler.get() ); | ||
} | ||
} | ||
|
||
QgsLayoutGeoPdfExporter::~QgsLayoutGeoPdfExporter() | ||
{ | ||
// cleanup - remove rendered feature handler from all maps | ||
for ( QgsLayoutItemMap *map : qgis::as_const( mMaps ) ) | ||
{ | ||
map->removeRenderedFeatureHandler( mHandler.get() ); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/*************************************************************************** | ||
qgslayoutgeopdfexporter.h | ||
-------------------------- | ||
begin : August 2019 | ||
copyright : (C) 2019 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSLAYOUTGEOPDFEXPORTER_H | ||
#define QGSLAYOUTGEOPDFEXPORTER_H | ||
|
||
#include "qgis_core.h" | ||
#include "qgslayoutitemmap.h" | ||
#include <QList> | ||
|
||
#define SIP_NO_FILE | ||
|
||
class QgsLayout; | ||
class QgsGeoPdfRenderedFeatureHandler; | ||
|
||
/** | ||
* \class QgsLayoutGeoPdfExporter | ||
* \ingroup core | ||
* | ||
* Handles GeoPDF export specific setup, cleanup and processing steps. | ||
* | ||
* This class is a low level implementation detail only. Generally, you should use the high level interface exposed by | ||
* QgsLayoutExporter instead. | ||
* | ||
* \warning QgsLayoutGeoPdfExporter is designed to be a short lived object. It should be created for a | ||
* single layout export operation only, and then immediately destroyed. Failure to correctly | ||
* destroy the object after exporting a layout will leave the layout in an inconsistent, unstable state. | ||
* | ||
* \note Not available in Python bindings | ||
* | ||
* \since QGIS 3.10 | ||
*/ | ||
class CORE_EXPORT QgsLayoutGeoPdfExporter | ||
{ | ||
public: | ||
|
||
QgsLayoutGeoPdfExporter( QgsLayout *layout ); | ||
|
||
|
||
~QgsLayoutGeoPdfExporter(); | ||
|
||
private: | ||
|
||
QgsLayout *mLayout = nullptr; | ||
QList< QgsLayoutItemMap * > mMaps; | ||
|
||
std::unique_ptr< QgsGeoPdfRenderedFeatureHandler > mHandler; | ||
|
||
}; | ||
|
||
#endif //QGSLAYOUTGEOPDFEXPORTER_H | ||
|
||
|
||
|