21 #include <QtConcurrentMap> 38 : mSettings( settings )
81 static const double splitCoord = 180.0;
96 .arg( fabs( 1.0 - extent2.
width() / extent.
width() ) )
100 if ( fabs( 1.0 - extent2.
width() / extent.
width() ) < 0.5 &&
101 fabs( 1.0 - extent2.
height() / extent.
height() ) < 0.5 )
126 if ( ll.
x() > ur.
x() )
153 extent =
QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
162 extent =
QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
163 r2 =
QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
183 Q_UNUSED( cacheValid );
188 while ( li.hasPrevious() )
190 QString layerId = li.previous();
192 QgsDebugMsg(
"Rendering at layer item " + layerId );
202 QgsDebugMsg(
QString(
"layer %1: minscale:%2 maxscale:%3 scaledepvis:%4 blendmode:%5" )
212 QgsDebugMsg(
"Layer not rendered because it is not within the defined visibility scale range" );
227 if ( !r1.
isFinite() || !r2.isFinite() )
229 mErrors.
append(
Error( layerId,
tr(
"There was a problem transforming the layer's extent. Layer skipped." ) ) );
251 job.
opacity = 1.0 - vl->layerTransparency() / 100.0;
279 QImage * mypFlattenedImage =
nullptr;
283 if ( mypFlattenedImage->
isNull() )
286 delete mypFlattenedImage;
290 mypFlattenedImage->
fill( 0 );
292 job.
img = mypFlattenedImage;
299 if ( hasStyleOverride )
304 if ( hasStyleOverride )
383 if ( !settings.
value(
"/Map/logCanvasRefreshEvent",
false ).
toBool() )
391 qSort( tt.begin(), tt.end(), qGreater<int>() );
392 Q_FOREACH (
int t, tt )
bool restoreOverrideStyle()
Restore the original store after a call to setOverrideStyle()
const QgsMapSettings & mapSettings() const
Return map settings with which this job was started.
void setOpacity(qreal opacity)
A rectangle specified with double values.
Base class for all map layer types.
Abstract base class for map rendering implementations.
bool contains(const Key &key) const
void setCompositionMode(CompositionMode mode)
void setRenderHint(RenderHint hint, bool on)
QList< T > values() const
void setXMaximum(double x)
Set the maximum x value.
void cleanupJobs(LayerRenderJobs &jobs)
void updateLayerGeometryCaches()
called when rendering has finished to update all layers' geometry caches
static QImage composeImage(const QgsMapSettings &settings, const LayerRenderJobs &jobs)
QStringList mRequestedGeomCacheForLayers
list of layer IDs for which the geometry cache should be updated
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 QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
void clearCacheImage(const QString &layerId)
remove layer from the cache
bool contains(const QString &str, Qt::CaseSensitivity cs) const
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 QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context...
virtual bool isEditable() const override
Returns true if the provider is in editing mode.
QgsMapLayer::LayerType type() const
Get the type of the layer.
QString tr(const char *sourceText, const char *disambiguation, int n)
void setExtent(const QgsRectangle &extent)
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
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.
void setCoordinateTransform(const QgsCoordinateTransform *t)
Sets coordinate transformation.
QgsMapLayerStyleManager * styleManager() const
Get access to the layer's style manager.
static bool staticWillUseLayer(QgsVectorLayer *layer)
called to find out whether the layer is used for labeling
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
void setCacheImage(const QString &layerId, const QImage &img)
set cached image for the specified layer ID
void append(const T &value)
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void fill(uint pixelValue)
bool init(const QgsRectangle &extent, double scale)
initialize cache: set new parameters and erase cache if parameters have changed
double scale() const
Return the calculated scale of the map.
Errors errors() const
List of errors that happened during the rendering job - available when the rendering has been finishe...
double width() const
Width of the rectangle.
Enable anti-aliasing for map rendering.
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
QImage::Format outputImageFormat() const
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
void setPainter(QPainter *p)
QMap< Key, T >::iterator insert(const Key &key, const T &value)
const QgsCoordinateTransform * layerTransform(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS.
double minimumScale() const
Returns the minimum scale denominator at which the layer is visible.
double maximumScale() const
Returns the maximum scale denominator at which the layer is visible.
A class to represent a point.
QString toString() const
String representation of the point (x,y)
void setLabelingEngineV2(QgsLabelingEngineV2 *engine2)
Assign new labeling engine.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Implementation of threaded rendering for vector layers.
double xMaximum() const
Get the x maximum value (right side of rectangle)
QVariant value(const QString &key, const QVariant &defaultValue) const
QMap< QString, QString > layerStyleOverrides() const
Get map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
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) ...
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
QString layerID() const
Get access to the ID of the layer rendered by this class.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
void setLabelingEngine(QgsLabelingEngineInterface *iface)
QgsMapLayerRenderer * renderer
double xMinimum() const
Get the x minimum value (left side of rectangle)
QgsMapRendererQImageJob(const QgsMapSettings &settings)
double yMaximum() const
Get the y maximum value (top side of rectangle)
QImage cacheImage(const QString &layerId)
get cached image for the specified layer ID. Returns null image if it is not cached.
QString name
Read property of QString layerName.
QStringList errors() const
Return list of errors (problems) that happened during the rendering.
This class is responsible for keeping cache of rendered images of individual layers.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
bool setOverrideStyle(const QString &styleDef)
Temporarily apply a different style to the layer.
Custom exception class for Coordinate Reference System related exceptions.
const_iterator constEnd() const
const_iterator constBegin() const
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
Represents a vector layer which manages a vector based data sets.
QgsMapRendererCache * mCache
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
bool needTemporaryImage(QgsMapLayer *ml)
QSize outputSize() const
Return the size of the resulting map image.
bool isNull(const QVariant &v)
QgsMapRendererJob(const QgsMapSettings &settings)
double x() const
Get the x value of the point.
void setXMinimum(double x)
Set the minimum x value.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
double height() const
Height of the rectangle.
Structure keeping low-level rendering job information.
bool geographicFlag() const
Returns whether the CRS is a geographic CRS.
const T value(const Key &key) const
QList< Key > uniqueKeys() const