21 #include <QtConcurrentMap>
37 : mSettings( settings )
80 static const double splitCoord = 180.0;
82 if ( layerCrsGeographic )
94 if ( ll.
x() > ur.
x() )
120 extent =
QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
129 extent =
QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
130 r2 =
QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
150 Q_UNUSED( cacheValid );
155 while ( li.hasPrevious() )
157 QString layerId = li.previous();
159 QgsDebugMsg(
"Rendering at layer item " + layerId );
169 QgsDebugMsg(
QString(
"layer %1: minscale:%2 maxscale:%3 scaledepvis:%4 blendmode:%5" )
179 QgsDebugMsg(
"Layer not rendered because it is not within the defined visibility scale range" );
194 if ( !r1.
isFinite() || !r2.isFinite() )
196 mErrors.
append(
Error( layerId,
tr(
"There was a problem transforming the layer's extent. Layer skipped." ) ) );
239 QImage * mypFlattenedImage = 0;
243 if ( mypFlattenedImage->
isNull() )
246 delete mypFlattenedImage;
250 mypFlattenedImage->
fill( 0 );
252 job.
img = mypFlattenedImage;
259 if ( hasStyleOverride )
264 if ( hasStyleOverride )
330 Q_ASSERT( job.
img != 0 );
bool restoreOverrideStyle()
Restore the original store after a call to setOverrideStyle()
A rectangle specified with double values.
Base class for all map layer types.
QgsMapLayer::LayerType type() const
Get the type of the layer.
Abstract base class for map rendering implementations.
bool contains(const Key &key) const
double scale() const
Return the calculated scale of the map.
void setCompositionMode(CompositionMode mode)
virtual bool willUseLayer(QgsVectorLayer *layer) override
called to find out whether the layer is used for labeling
void setRenderHint(RenderHint hint, bool on)
void setXMaximum(double x)
Set the maximum x value.
void cleanupJobs(LayerRenderJobs &jobs)
const QgsCoordinateTransform * layerTransform(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS.
void updateLayerGeometryCaches()
called when rendering has finished to update all layers' geometry caches
static QImage composeImage(const QgsMapSettings &settings, const LayerRenderJobs &jobs)
bool isFinite() const
Returns true if the rectangle has finite boundaries.
double yMaximum() const
Get the y maximum value (top side of rectangle)
QStringList mRequestedGeomCacheForLayers
list of layer IDs for which the geometry cache should be updated
QgsMapLayerStyleManager * styleManager() const
Get access to the layer's style manager.
QMap< QString, QgsGeometryCache > mGeometryCaches
map of geometry caches
float minimumScale() const
Returns the minimum scale denominator at which the layer is visible.
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
QMap< QString, QString > layerStyleOverrides() const
Get map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context...
void setCacheImage(QString layerId, const QImage &img)
set cached image for the specified layer ID
virtual bool isEditable() const override
Returns true if the provider is in editing mode.
QString tr(const char *sourceText, const char *disambiguation, int n)
void setExtent(const QgsRectangle &extent)
LayerRenderJobs prepareJobs(QPainter *painter, QgsPalLabeling *labelingEngine)
void setCache(QgsMapRendererCache *cache)
Assign a cache to be used for reading and storing rendered images of individual layers.
The QgsMapSettings class contains configuration for rendering of the map.
QString layerID() const
Get access to the ID of the layer rendered by this class.
void setCoordinateTransform(const QgsCoordinateTransform *t)
Sets coordinate transformation.
const QString & name() const
Get the display name of the layer.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
void append(const T &value)
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
void fill(uint pixelValue)
QSize outputSize() const
Return the size of the resulting map image.
double xMaximum() const
Get the x maximum value (right side of rectangle)
void clearCacheImage(QString layerId)
remove layer from the cache
bool renderingStopped() const
float maximumScale() const
Returns the maximum scale denominator at which the layer is visible.
QStringList errors() const
Return list of errors (problems) that happened during the rendering.
Enable anti-aliasin for map rendering.
const QgsMapSettings & mapSettings() const
Return map settings with which this job was started.
QImage cacheImage(QString layerId)
get cached image for the specified layer ID. Returns null image if it is not cached.
void setPainter(QPainter *p)
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
A class to represent a point.
QColor backgroundColor() const
Get the background color of the map.
Implementation of threaded rendering for vector layers.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
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)
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
void setLabelingEngine(QgsLabelingEngineInterface *iface)
QImage::Format outputImageFormat() const
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
QgsMapLayerRenderer * renderer
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
QgsMapRendererQImageJob(const QgsMapSettings &settings)
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
This class is responsible for keeping cache of rendered images of individual layers.
bool setOverrideStyle(const QString &styleDef)
Temporarily apply a different style to the layer.
static bool reprojectToLayerExtent(const QgsCoordinateTransform *ct, bool layerCrsGeographic, QgsRectangle &extent, QgsRectangle &r2)
Convenience function to project an extent into the layer source CRS, but also split it into two exten...
Custom exception class for Coordinate Reference System related exceptions.
const_iterator constEnd() const
const_iterator constBegin() const
Errors errors() const
List of errors that happened during the rendering job - available when the rendering has been finishe...
QPainter::CompositionMode blendMode
bool init(QgsRectangle extent, double scale)
initialize cache: set new parameters and erase cache if parameters have changed
Represents a vector layer which manages a vector based data sets.
bool geographicFlag() const
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
QgsMapRendererCache * mCache
double xMinimum() const
Get the x minimum value (left side of rectangle)
bool needTemporaryImage(QgsMapLayer *ml)
bool isNull(const QVariant &v)
QgsMapRendererJob(const QgsMapSettings &settings)
void setXMinimum(double x)
Set the minimum x value.
Structure keeping low-level rendering job information.
const T value(const Key &key) const