QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsmaprenderercache.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaprenderercache.h
3 --------------------------------------
4 Date : December 2013
5 Copyright : (C) 2013 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMAPRENDERERCACHE_H
17#define QGSMAPRENDERERCACHE_H
18
19#include "qgis_core.h"
20#include <QMap>
21#include <QImage>
22#include <QMutex>
23
24#include "qgsrectangle.h"
25#include "qgsmaplayer.h"
26#include "qgsmaptopixel.h"
27
28
47class CORE_EXPORT QgsMapRendererCache : public QObject
48{
49 Q_OBJECT
50 public:
51
53
58 void clear();
59
67 Q_DECL_DEPRECATED bool init( const QgsRectangle &extent, double scale ) SIP_DEPRECATED;
68
76 bool updateParameters( const QgsRectangle &extent, const QgsMapToPixel &mtp );
77
90 void setCacheImage( const QString &cacheKey, const QImage &image, const QList< QgsMapLayer * > &dependentLayers = QList< QgsMapLayer * >() );
91
105 void setCacheImageWithParameters( const QString &cacheKey,
106 const QImage &image,
107 const QgsRectangle &extent,
108 const QgsMapToPixel &mapToPixel,
109 const QList< QgsMapLayer * > &dependentLayers = QList< QgsMapLayer * >() );
110
118 bool hasCacheImage( const QString &cacheKey ) const;
119
133 bool hasAnyCacheImage( const QString &cacheKey, double minimumScaleThreshold = 0, double maximumScaleThreshold = 0 ) const;
134
142 QImage cacheImage( const QString &cacheKey ) const;
143
156 QImage transformedCacheImage( const QString &cacheKey, const QgsMapToPixel &mtp ) const;
157
162 QList< QgsMapLayer * > dependentLayers( const QString &cacheKey ) const;
163
168 void clearCacheImage( const QString &cacheKey );
169
175 void invalidateCacheForLayer( QgsMapLayer *layer );
176
177 private slots:
179 void layerRequestedRepaint();
180
181 private:
182
183 struct CacheParameters
184 {
185 QImage cachedImage;
186 QgsWeakMapLayerPointerList dependentLayers;
187 QgsRectangle cachedExtent;
188 QgsMapToPixel cachedMtp;
189 };
190
192 void clearInternal();
193
195 void dropUnusedConnections();
196
197 QSet< QgsWeakMapLayerPointer > dependentLayers() const;
198
199 mutable QMutex mMutex;
200 QgsRectangle mExtent;
201 QgsMapToPixel mMtp;
202
203 double mScale = -1.0; //DEPRECATED
204
206 QMap<QString, CacheParameters> mCachedImages;
208 QSet< QgsWeakMapLayerPointer > mConnectedLayers;
209};
210
211
212#endif // QGSMAPRENDERERCACHE_H
Base class for all map layer types.
Definition qgsmaplayer.h:74
This class is responsible for keeping cache of rendered images resulting from a map rendering job.
Perform transforms between map coordinates and device coordinates.
A rectangle specified with double values.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.