26#include "moc_qgsmaprenderersequentialjob.cpp"
28using namespace Qt::StringLiterals;
37 mImage.setDevicePixelRatio(
mSettings.devicePixelRatio() );
38 mImage.setDotsPerMeterX(
static_cast< int >( 1000 * settings.
outputDpi() / 25.4 ) );
39 mImage.setDotsPerMeterY(
static_cast< int >( 1000 * settings.
outputDpi() / 25.4 ) );
40 mImage.fill( Qt::transparent );
49 QgsDebugMsgLevel( u
"SEQUENTIAL destruct -- still running! (canceling)"_s, 5 );
53 Q_ASSERT( !mInternalJob && !mPainter );
57void QgsMapRendererSequentialJob::startPrivate()
62 mLabelingResults.reset();
70 Q_ASSERT( !mInternalJob && !mPainter );
72 mPainter =
new QPainter( &mImage );
82 mInternalJob->
start();
93 mInternalJob->cancel();
95 Q_ASSERT( !mInternalJob && !mPainter );
104 mInternalJob->cancelWithoutBlocking();
112 mInternalJob->waitForFinished();
117 return nullptr != mInternalJob;
122 return mUsedCachedLabels;
127 return mLabelingResults.release();
149 mLabelingResults.reset( mInternalJob->takeLabelingResults() );
150 mUsedCachedLabels = mInternalJob->usedCachedLabels();
155 mErrors = mInternalJob->errors();
159 mInternalJob->deleteLater();
160 mInternalJob =
nullptr;
Stores computed placement from labeling engine.
Job implementation that renders everything sequentially using a custom painter.
static QImage composeImage(const QgsMapSettings &settings, const std::vector< LayerRenderJob > &jobs, const LabelRenderJob &labelJob, const QgsMapRendererCache *cache=nullptr)
void setCache(QgsMapRendererCache *cache)
Assign a cache to be used for reading and storing rendered images of individual layers.
void setLabelSink(QgsLabelSink *sink)
Assigns the label sink which will take over responsibility for handling labels during the rendering j...
std::unique_ptr< QgsRenderedItemResults > mRenderedItemResults
void layerRendered(const QString &layerId)
Emitted when a layer has completed rendering.
QElapsedTimer mRenderingStart
QgsMapRendererCache * mCache
void finished()
emitted when asynchronous rendering is finished (or canceled).
void start()
Start the rendering job and immediately return.
void layerRenderingStarted(const QString &layerId)
Emitted just before rendering starts for a particular layer.
QStringList mLayersRedrawnFromCache
QgsLabelSink * labelSink() const
Returns the label sink associated to this rendering job.
QgsMapRendererQImageJob(const QgsMapSettings &settings)
bool usedCachedLabels() const final
Returns true if the render job was able to use a cached labeling solution.
~QgsMapRendererSequentialJob() override
void waitForFinished() final
Block until the job has finished.
void cancelWithoutBlocking() final
Triggers cancellation of the rendering job without blocking.
QgsLabelingResults * takeLabelingResults() final
Gets pointer to internal labeling engine (in order to get access to the results).
QImage renderedImage() final
Gets a preview/resulting image.
void cancel() final
Stop the rendering job - does not return until the job has terminated.
bool isActive() const final
Tell whether the rendering job is currently running in background.
QgsMapRendererSequentialJob(const QgsMapSettings &settings)
Contains configuration for rendering maps.
double outputDpi() const
Returns the DPI (dots per inch) used for conversion between real world units (e.g.
#define QgsDebugMsgLevel(str, level)