QGIS/src/core/qgsgeometrycache.cpp
Martin Dobias 2fcf556c3c Do the rendering of map layers within special classes
This is an important change: new class (QgsMapLayerRenderer) is introduced
and it keeps all information from layer which is necessary for rendering.
Thanks to that, any changes to map layer will have no impact on rendering that
may be currently underway: if the user changes renderer, rendering will
not crash because it is using a different instance.

Work in progress: only vector layers, no labeling, no diagrams, iterator
still uses some bits from QgsVectorLayer.

Another change: QgsFeatureRendererV2, QgsSymbolV2 do not get access
to QgsVectorLayer - only to fields they need. Point displacement renderer
did more extensive use of QgsVectorLayer - currently it is not functional.
2013-11-20 16:01:12 +07:00

39 lines
874 B
C++

#include "qgsgeometrycache.h"
#include "qgsvectorlayereditbuffer.h"
QgsGeometryCache::QgsGeometryCache()
{
}
QgsGeometryCache::~QgsGeometryCache()
{
// Destroy any cached geometries and clear the references to them
deleteCachedGeometries();
}
bool QgsGeometryCache::geometry( QgsFeatureId fid, QgsGeometry& geometry )
{
// no need to check changed geometries because all changed geometries are also cached
// first time this geometry has changed since last commit
if ( !mCachedGeometries.contains( fid ) )
return false;
geometry = mCachedGeometries[fid];
return true;
}
void QgsGeometryCache::cacheGeometry( QgsFeatureId fid, const QgsGeometry& geom )
{
mCachedGeometries[fid] = geom;
}
void QgsGeometryCache::deleteCachedGeometries()
{
// Destroy any cached geometries
mCachedGeometries.clear();
mCachedGeometriesRect = QgsRectangle();
}