32 , mLabelingEngine( nullptr )
33 , mLabelingEngineV2( nullptr )
35 , mRenderSynchronously( false )
46 delete mLabelingEngine;
47 mLabelingEngine =
nullptr;
49 delete mLabelingEngineV2;
50 mLabelingEngineV2 =
nullptr;
66 QgsDebugMsg(
"Preparing list of layer jobs for rendering" );
81 delete mLabelingEngine;
82 mLabelingEngine =
nullptr;
84 delete mLabelingEngineV2;
85 mLabelingEngineV2 =
nullptr;
100 mLayerJobs =
prepareJobs( mPainter, mLabelingEngine, mLabelingEngineV2 );
104 if ( mRenderSynchronously )
154 it->context.setRenderingStopped(
true );
155 if ( it->renderer && it->renderer->feedback() )
156 it->renderer->feedback()->cancel();
185 if ( mLabelingEngine )
187 else if ( mLabelingEngineV2 )
197 connect( &mFutureWatcher, SIGNAL(
finished() ), &loop, SLOT( quit() ) );
204 mRenderSynchronously =
true;
207 mRenderSynchronously =
false;
237 catch ( std::exception & e )
244 QgsDebugMsg(
"Caught unhandled unknown exception" );
312 #if !defined(QGIS_DISABLE_DEPRECATED) 318 if ( labelingEngine2 )
324 labelingEngine2->
run( renderContext );
336 while ( li.hasPrevious() )
343 QString layerId = li.previous();
382 labelingEngine->
exit();
393 * vl->cache() = cache;
410 (( vl->
blendMode() != QPainter::CompositionMode_SourceOver )
QgsMapRendererCustomPainterJob(const QgsMapSettings &settings, QPainter *painter)
QString fromAscii(const char *str, int size)
void setOpacity(qreal opacity)
void finished()
emitted when asynchronous rendering is finished (or canceled).
static void drawNewLabeling(const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsPalLabeling *labelingEngine)
void setRenderingStopped(bool stopped)
A rectangle specified with double values.
Base class for all map layer types.
Job implementation that renders everything sequentially using a custom painter.
Abstract base class for map rendering implementations.
virtual void drawLabels(QgsRenderContext &rendererContext)
Draw labels.
void fillRect(const QRectF &rectangle, const QBrush &brush)
void setCompositionMode(CompositionMode mode)
void setRenderHint(RenderHint hint, bool on)
void cleanupJobs(LayerRenderJobs &jobs)
QgsLabelingResults * takeResults()
Return pointer to recently computed results (in drawLabeling()) and pass the ownership of results to ...
void updateLayerGeometryCaches()
called when rendering has finished to update all layers' geometry caches
void loadEngineSettings()
load/save engine settings to project file
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID.
void logRenderingTime(const LayerRenderJobs &jobs)
static bool reprojectToLayerExtent(const QgsMapLayer *ml, const QgsCoordinateTransform *ct, QgsRectangle &extent, QgsRectangle &r2)
Convenience function to project an extent into the layer source CRS, but also split it into two exten...
QMap< QString, QgsGeometryCache > mGeometryCaches
map of geometry caches
QColor backgroundColor() const
Get the background color of the map.
const_iterator constBegin() const
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
bool renderingStopped() const
The QgsLabelingEngineV2 class provides map labeling functionality.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
virtual void cancel() override
Stop the rendering job - does not return until the job has terminated.
void readSettingsFromProject()
Read configuration of the labeling engine from the current project file.
Enable layer transparency and blending effects.
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
QgsMapLayer::LayerType type() const
Get the type of the layer.
void setExtent(const QgsRectangle &extent)
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
Enable drawing of labels on top of the map.
The QgsMapSettings class contains configuration for rendering of the map.
void setCoordinateTransform(const QgsCoordinateTransform *t)
Sets coordinate transformation.
double qgsRound(double x)
A round function which returns a double to guard against overflows.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
virtual void start() override
Start the rendering job and immediately return.
int exec(QFlags< QEventLoop::ProcessEventsFlag > flags)
double scale() const
Return the calculated scale of the map.
static void staticRender(QgsMapRendererCustomPainterJob *self)
virtual void drawLabeling(QgsRenderContext &context) override
called when the map is drawn and labels should be placed
const_iterator constEnd() const
Enable anti-aliasing for map rendering.
QPaintDevice * device() const
void setPainter(QPainter *p)
QFuture< T > run(Function function,...)
int layerTransparency() const
Returns the current transparency for the vector layer.
const QgsCoordinateTransform * layerTransform(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS.
void setFuture(const QFuture< T > &future)
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
~QgsMapRendererCustomPainterJob()
virtual void cancelWithoutBlocking() override
Triggers cancellation of the rendering job without blocking.
void setMapSettings(const QgsMapSettings &mapSettings)
Associate map settings instance.
void run(QgsRenderContext &context)
compute the labeling with given map settings and providers
static void drawOldLabeling(const QgsMapSettings &settings, QgsRenderContext &renderContext)
const Key key(const T &value) const
double outputDpi() const
Return DPI used for conversion between real world units (e.g.
static void drawLabeling(const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsPalLabeling *labelingEngine, QgsLabelingEngineV2 *labelingEngine2, QPainter *painter)
typedef ProcessEventsFlags
Contains information about the context of a rendering operation.
virtual bool render()=0
Do the rendering (based on data stored in the class)
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
LayerRenderJobs prepareJobs(QPainter *painter, QgsPalLabeling *labelingEngine, QgsLabelingEngineV2 *labelingEngine2)
int renderingTime
time it took to render the layer in ms (it is -1 if not rendered or still rendering) ...
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
void setLabelingEngine(QgsLabelingEngineInterface *iface)
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
QgsMapLayerRenderer * renderer
bool forceRasterRender() const
Returns whether the renderer must render as a raster.
Class that stores computed placement from labeling engine.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
virtual QgsLabelingResults * takeLabelingResults() override
Get pointer to internal labeling engine (in order to get access to the results)
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
QPainter::CompositionMode blendMode
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
virtual void waitForFinished() override
Block until the job has finished.
Represents a vector layer which manages a vector based data sets.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
bool needTemporaryImage(QgsMapLayer *ml)
void waitForFinishedWithEventLoop(const QEventLoop::ProcessEventsFlags &flags=QEventLoop::AllEvents)
Wait for the job to be finished - and keep the thread's event loop running while waiting.
Defines a qgis exception class.
void renderSynchronously()
Render the map synchronously in this thread.
QgsLabelingResults * takeResults()
Return pointer to recently computed results and pass the ownership of results to the caller...
QSize outputSize() const
Return the size of the resulting map image.
QByteArray toAscii() const
virtual void exit() override
called when we're done with rendering
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
Structure keeping low-level rendering job information.
const T value(const Key &key) const
virtual bool isActive() const override
Tell whether the rendering job is currently running in background.