QGIS API Documentation 3.39.0-Master (bca3cdb6021)
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
46class CORE_EXPORT QgsMapRendererCache : public QObject
47{
48 Q_OBJECT
49 public:
50
52
57 void clear();
58
66 Q_DECL_DEPRECATED bool init( const QgsRectangle &extent, double scale ) SIP_DEPRECATED;
67
75 bool updateParameters( const QgsRectangle &extent, const QgsMapToPixel &mtp );
76
89 void setCacheImage( const QString &cacheKey, const QImage &image, const QList< QgsMapLayer * > &dependentLayers = QList< QgsMapLayer * >() );
90
104 void setCacheImageWithParameters( const QString &cacheKey,
105 const QImage &image,
106 const QgsRectangle &extent,
107 const QgsMapToPixel &mapToPixel,
108 const QList< QgsMapLayer * > &dependentLayers = QList< QgsMapLayer * >() );
109
116 bool hasCacheImage( const QString &cacheKey ) const;
117
131 bool hasAnyCacheImage( const QString &cacheKey, double minimumScaleThreshold = 0, double maximumScaleThreshold = 0 ) const;
132
140 QImage cacheImage( const QString &cacheKey ) const;
141
154 QImage transformedCacheImage( const QString &cacheKey, const QgsMapToPixel &mtp ) const;
155
159 QList< QgsMapLayer * > dependentLayers( const QString &cacheKey ) const;
160
165 void clearCacheImage( const QString &cacheKey );
166
172 void invalidateCacheForLayer( QgsMapLayer *layer );
173
174 private slots:
176 void layerRequestedRepaint();
177
178 private:
179
180 struct CacheParameters
181 {
182 QImage cachedImage;
183 QgsWeakMapLayerPointerList dependentLayers;
184 QgsRectangle cachedExtent;
185 QgsMapToPixel cachedMtp;
186 };
187
189 void clearInternal();
190
192 void dropUnusedConnections();
193
194 QSet< QgsWeakMapLayerPointer > dependentLayers() const;
195
196 mutable QMutex mMutex;
197 QgsRectangle mExtent;
198 QgsMapToPixel mMtp;
199
200 double mScale = -1.0; //DEPRECATED
201
203 QMap<QString, CacheParameters> mCachedImages;
205 QSet< QgsWeakMapLayerPointer > mConnectedLayers;
206};
207
208
209#endif // QGSMAPRENDERERCACHE_H
Base class for all map layer types.
Definition qgsmaplayer.h:76
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.