QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
27 
42 class CORE_EXPORT QgsMapRendererCache : public QObject
43 {
44  Q_OBJECT
45  public:
46 
48 
53  void clear();
54 
60  bool init( const QgsRectangle &extent, double scale );
61 
70  void setCacheImage( const QString &cacheKey, const QImage &image, const QList< QgsMapLayer * > &dependentLayers = QList< QgsMapLayer * >() );
71 
77  bool hasCacheImage( const QString &cacheKey ) const;
78 
86  QImage cacheImage( const QString &cacheKey ) const;
87 
92  QList< QgsMapLayer * > dependentLayers( const QString &cacheKey ) const;
93 
98  void clearCacheImage( const QString &cacheKey );
99 
105  void invalidateCacheForLayer( QgsMapLayer *layer );
106 
107  private slots:
109  void layerRequestedRepaint();
110 
111  private:
112 
113  struct CacheParameters
114  {
115  QImage cachedImage;
116  QgsWeakMapLayerPointerList dependentLayers;
117  };
118 
120  void clearInternal();
121 
123  void dropUnusedConnections();
124 
125  QSet< QgsWeakMapLayerPointer > dependentLayers() const;
126 
127  mutable QMutex mMutex;
128  QgsRectangle mExtent;
129  double mScale = 0;
130 
132  QMap<QString, CacheParameters> mCachedImages;
134  QSet< QgsWeakMapLayerPointer > mConnectedLayers;
135 };
136 
137 
138 #endif // QGSMAPRENDERERCACHE_H
QgsWeakMapLayerPointerList
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.
Definition: qgsmaplayer.h:1677
qgsrectangle.h
QgsRectangle
Definition: qgsrectangle.h:41
QgsMapRendererCache
Definition: qgsmaprenderercache.h:42
qgsmaplayer.h
QgsMapLayer
Definition: qgsmaplayer.h:81