1 /*************************************************************************** 2 qgslayoutgeopdfexporter.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 QGSLAYOUTGEOPDFEXPORTER_H 17 #define QGSLAYOUTGEOPDFEXPORTER_H 18 19 #include "qgis_core.h" 20 #include "qgsabstractgeopdfexporter.h" 21 #include "qgslayoutitemmap.h" 22 #include <QList> 23 #include <QTemporaryDir> 24 25 #define SIP_NO_FILE 26 27 class QgsLayout; 28 class QgsGeoPdfRenderedFeatureHandler; 29 30 /** 31 * \class QgsLayoutGeoPdfExporter 32 * \ingroup core 33 * 34 * \brief Handles GeoPDF export specific setup, cleanup and processing steps. 35 * 36 * This class is a low level implementation detail only. Generally, you should use the high level interface exposed by 37 * QgsLayoutExporter instead. 38 * 39 * \warning QgsLayoutGeoPdfExporter is designed to be a short lived object. It should be created for a 40 * single layout export operation only, and then immediately destroyed. Failure to correctly 41 * destroy the object after exporting a layout will leave the layout in an inconsistent, unstable state. 42 * 43 * \note Not available in Python bindings 44 * 45 * \since QGIS 3.10 46 */ 47 class CORE_EXPORT QgsLayoutGeoPdfExporter : public QgsAbstractGeoPdfExporter 48 { 49 public: 50 51 /** 52 * Constructor for QgsLayoutGeoPdfExporter, associated with the specified \a layout. 53 */ 54 QgsLayoutGeoPdfExporter( QgsLayout *layout ); 55 56 ~QgsLayoutGeoPdfExporter() override; 57 58 /** 59 * Returns any custom layer tree groups defined in the layer's settings. 60 */ customLayerTreeGroups()61 QMap< QString, QString > customLayerTreeGroups() const { return mCustomLayerTreeGroups; } 62 63 /** 64 * Optional map of map layer ID to initial visibility state. If a layer ID is not present in this, 65 * it will default to being initially visible when opening the PDF. 66 * 67 * \since QGIS 3.14 68 */ initialLayerVisibility()69 QMap< QString, bool > initialLayerVisibility() const { return mInitialLayerVisibility; } 70 71 /** 72 * Optional list of map layer IDs in the order they should be shown in the generated GeoPDF layer tree. 73 * Layer IDs earlier in the list will appear higher in the GeoPDF layer tree. 74 * 75 * \since QGIS 3.14 76 */ layerOrder()77 QStringList layerOrder() const { return mLayerOrder; } 78 79 private: 80 81 VectorComponentDetail componentDetailForLayerId( const QString &layerId ) override; 82 83 QgsLayout *mLayout = nullptr; 84 QHash< QgsLayoutItemMap *, QgsGeoPdfRenderedFeatureHandler * > mMapHandlers; 85 86 QMap< QString, bool > mInitialLayerVisibility; 87 QMap< QString, QString > mCustomLayerTreeGroups; 88 QStringList mLayerOrder; 89 90 friend class TestQgsLayoutGeoPdfExport; 91 }; 92 93 #endif //QGSLAYOUTGEOPDFEXPORTER_H 94 95 96 97