21 #include <QtConcurrentMap>
36 : mSettings( settings )
74 static const double splitCoord = 180.0;
76 if ( layerCrsGeographic )
88 if ( ll.
x() > ur.
x() )
114 extent =
QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
123 extent =
QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
124 r2 =
QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
143 QgsDebugMsg( QString(
"CACHE VALID: %1" ).arg( cacheValid ) );
144 Q_UNUSED( cacheValid );
149 while ( li.hasPrevious() )
151 QString layerId = li.previous();
153 QgsDebugMsg(
"Rendering at layer item " + layerId );
159 mErrors.append(
Error( layerId,
"Layer not found in registry." ) );
163 QgsDebugMsg( QString(
"layer %1: minscale:%2 maxscale:%3 scaledepvis:%4 extent:%5 blendmode:%6" )
174 QgsDebugMsg(
"Layer not rendered because it is not within the defined visibility scale range" );
189 if ( !r1.
isFinite() || !r2.isFinite() )
191 mErrors.append(
Error( layerId,
"There was a problem transforming layer's' extent. Layer skipped." ) );
234 QImage * mypFlattenedImage = 0;
238 if ( mypFlattenedImage->isNull() )
241 delete mypFlattenedImage;
242 layerJobs.removeLast();
245 mypFlattenedImage->fill( 0 );
247 job.
img = mypFlattenedImage;
248 QPainter* mypPainter =
new QPainter( job.
img );
271 for ( LayerRenderJobs::iterator it = jobs.begin(); it != jobs.end(); ++it )
310 QPainter painter( &image );
312 for ( LayerRenderJobs::const_iterator it = jobs.constBegin(); it != jobs.constEnd(); ++it )
316 painter.setCompositionMode( job.
blendMode );
318 Q_ASSERT( job.
img != 0 );
319 painter.drawImage( 0, 0, *job.
img );
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.
double scale() const
Return the calculated scale of the map.
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)
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
QMap< QString, QgsGeometryCache > mGeometryCaches
map of geometry caches
float minimumScale() const
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
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
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
Read blend mode for layer.
virtual bool willUseLayer(QgsVectorLayer *layer)
called to find out whether the layer is used for labeling
bool hasScaleBasedVisibility() const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
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
QStringList errors() const
Return list of errors (problems) that happened during the rendering.
Enable anti-aliasin for map rendering.
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 geometry.
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.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
void setLabelingEngine(QgsLabelingEngineInterface *iface)
Added in QGIS v1.4.
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.
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.
QList< LayerRenderJob > LayerRenderJobs
Errors errors() const
List of errors that happened during the rendering job - available when the rendering has been finishe...
QPainter::CompositionMode blendMode
const QgsCoordinateTransform * layerTransfrom(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS.
bool init(QgsRectangle extent, double scale)
initialize cache: set new parameters and erase cache if parameters have changed
virtual bool isEditable() const
Returns true if the provider is in editing mode.
virtual QgsRectangle extent()
Return the extent of the layer.
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.