|
| 1 | + |
| 2 | +/** abstract base class renderer jobs that asynchronously start map rendering */ |
| 3 | +class QgsMapRendererJob : QObject |
| 4 | +{ |
| 5 | +%TypeHeaderCode |
| 6 | +#include <qgsmaprendererjob.h> |
| 7 | +%End |
| 8 | + |
| 9 | + public: |
| 10 | + |
| 11 | + QgsMapRendererJob( const QgsMapSettings& settings ); |
| 12 | + |
| 13 | + virtual ~QgsMapRendererJob(); |
| 14 | + |
| 15 | + //! Start the rendering job and immediately return. |
| 16 | + //! Does nothing if the rendering is already in progress. |
| 17 | + virtual void start() = 0; |
| 18 | + |
| 19 | + //! Stop the rendering job - does not return until the job has terminated. |
| 20 | + //! Does nothing if the rendering is not active. |
| 21 | + virtual void cancel() = 0; |
| 22 | + |
| 23 | + //! Block until the job has finished. |
| 24 | + virtual void waitForFinished() = 0; |
| 25 | + |
| 26 | + //! Tell whether the rendering job is currently running in background. |
| 27 | + virtual bool isActive() const = 0; |
| 28 | + |
| 29 | + //! Get pointer to internal labeling engine (in order to get access to the results) |
| 30 | + virtual QgsLabelingResults* takeLabelingResults() = 0 /Transfer/; |
| 31 | + |
| 32 | + struct Error |
| 33 | + { |
| 34 | + Error( const QString& lid, const QString& msg ); |
| 35 | + |
| 36 | + QString layerID; |
| 37 | + QString message; |
| 38 | + }; |
| 39 | + |
| 40 | + typedef QList<QgsMapRendererJob::Error> Errors; |
| 41 | + |
| 42 | + //! List of errors that happened during the rendering job - available when the rendering has been finished |
| 43 | + Errors errors() const; |
| 44 | + |
| 45 | + |
| 46 | + //! Assign a cache to be used for reading and storing rendered images of individual layers. |
| 47 | + //! Does not take ownership of the object. |
| 48 | + void setCache( QgsMapRendererCache* cache ); |
| 49 | + |
| 50 | + //! Set which vector layers should be cached while rendering |
| 51 | + //! @note The way how geometries are cached is really suboptimal - this method may be removed in future releases |
| 52 | + void setRequestedGeometryCacheForLayers( const QStringList& layerIds ); |
| 53 | + |
| 54 | + //! Find out how log it took to finish the job (in miliseconds) |
| 55 | + int renderingTime() const; |
| 56 | + |
| 57 | + signals: |
| 58 | + |
| 59 | + //! emitted when asynchronous rendering is finished (or canceled). |
| 60 | + void finished(); |
| 61 | + |
| 62 | +}; |
| 63 | + |
| 64 | + |
| 65 | +/** Intermediate base class adding functionality that allows client to query the rendered image. |
| 66 | + * The image can be queried even while the rendering is still in progress to get intermediate result |
| 67 | + */ |
| 68 | +class QgsMapRendererQImageJob : QgsMapRendererJob |
| 69 | +{ |
| 70 | +%TypeHeaderCode |
| 71 | +#include <qgsmaprendererjob.h> |
| 72 | +%End |
| 73 | + |
| 74 | + public: |
| 75 | + QgsMapRendererQImageJob( const QgsMapSettings& settings ); |
| 76 | + |
| 77 | + //! Get a preview/resulting image |
| 78 | + virtual QImage renderedImage() = 0; |
| 79 | +}; |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | +/** job implementation that renders everything sequentially in one thread */ |
| 84 | +class QgsMapRendererSequentialJob : QgsMapRendererQImageJob |
| 85 | +{ |
| 86 | +%TypeHeaderCode |
| 87 | +#include <qgsmaprendererjob.h> |
| 88 | +%End |
| 89 | + |
| 90 | + public: |
| 91 | + QgsMapRendererSequentialJob( const QgsMapSettings& settings ); |
| 92 | + ~QgsMapRendererSequentialJob(); |
| 93 | + |
| 94 | + virtual void start(); |
| 95 | + virtual void cancel(); |
| 96 | + virtual void waitForFinished(); |
| 97 | + virtual bool isActive() const; |
| 98 | + |
| 99 | + virtual QgsLabelingResults* takeLabelingResults() /Transfer/; |
| 100 | + |
| 101 | + // from QgsMapRendererJobWithPreview |
| 102 | + virtual QImage renderedImage(); |
| 103 | + |
| 104 | + public slots: |
| 105 | + |
| 106 | + void internalFinished(); |
| 107 | +}; |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | +/** job implementation that renders all layers in parallel */ |
| 113 | +class QgsMapRendererParallelJob : QgsMapRendererQImageJob |
| 114 | +{ |
| 115 | +%TypeHeaderCode |
| 116 | +#include <qgsmaprendererjob.h> |
| 117 | +%End |
| 118 | + |
| 119 | + public: |
| 120 | + QgsMapRendererParallelJob( const QgsMapSettings& settings ); |
| 121 | + ~QgsMapRendererParallelJob(); |
| 122 | + |
| 123 | + virtual void start(); |
| 124 | + virtual void cancel(); |
| 125 | + virtual void waitForFinished(); |
| 126 | + virtual bool isActive() const; |
| 127 | + |
| 128 | + virtual QgsLabelingResults* takeLabelingResults() /Transfer/; |
| 129 | + |
| 130 | + // from QgsMapRendererJobWithPreview |
| 131 | + virtual QImage renderedImage(); |
| 132 | +}; |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | +/** job implementation that renders everything sequentially using a custom painter. |
| 137 | + * The returned image is always invalid (because there is none available). |
| 138 | + */ |
| 139 | +class QgsMapRendererCustomPainterJob : QgsMapRendererJob |
| 140 | +{ |
| 141 | +%TypeHeaderCode |
| 142 | +#include <qgsmaprendererjob.h> |
| 143 | +%End |
| 144 | + |
| 145 | + public: |
| 146 | + QgsMapRendererCustomPainterJob( const QgsMapSettings& settings, QPainter* painter ); |
| 147 | + ~QgsMapRendererCustomPainterJob(); |
| 148 | + |
| 149 | + virtual void start(); |
| 150 | + virtual void cancel(); |
| 151 | + virtual void waitForFinished(); |
| 152 | + virtual bool isActive() const; |
| 153 | + virtual QgsLabelingResults* takeLabelingResults() /Transfer/; |
| 154 | + |
| 155 | + // TODO wrap??? const LayerRenderJobs& jobs() const; |
| 156 | +}; |
0 commit comments