Skip to content

Commit

Permalink
Keep mCachedGeometries up-to-date before the next repaint. This is im…
Browse files Browse the repository at this point in the history
…portant in cases where topological editing is enabled

git-svn-id: http://svn.osgeo.org/qgis/trunk@10794 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 14, 2009
1 parent 797afab commit deec403
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -1469,6 +1469,7 @@ bool QgsVectorLayer::addFeature( QgsFeature& f, bool alsoUpdateExtent )
// and add to the known added features.
f.setFeatureId( addedIdLowWaterMark );
mAddedFeatures.append( f );
mCachedGeometries[f.id()] = *(f.geometry());

setModified( true );

Expand Down Expand Up @@ -1502,6 +1503,7 @@ bool QgsVectorLayer::insertVertex( double x, double y, int atFeatureId, int befo
}

mChangedGeometries[atFeatureId].insertVertex( x, y, beforeVertex );
mCachedGeometries[atFeatureId] = mChangedGeometries[atFeatureId];

setModified( true, true ); // only geometry was changed

Expand Down Expand Up @@ -1531,6 +1533,7 @@ bool QgsVectorLayer::moveVertex( double x, double y, int atFeatureId, int atVert
}

mChangedGeometries[atFeatureId].moveVertex( x, y, atVertex );
mCachedGeometries[atFeatureId] = mChangedGeometries[atFeatureId];

setModified( true, true ); // only geometry was changed

Expand Down Expand Up @@ -1652,7 +1655,9 @@ int QgsVectorLayer::addIsland( const QList<QgsPoint>& ring )
QgsGeometryMap::iterator changedIt = mChangedGeometries.find( selectedFeatureId );
if ( changedIt != mChangedGeometries.end() )
{
return changedIt->addIsland( ring );
int returnValue = changedIt->addIsland( ring );
mCachedGeometries[selectedFeatureId] = *changedIt;
return returnValue;
}

//look if id of selected feature belongs to an added feature
Expand All @@ -1661,6 +1666,7 @@ int QgsVectorLayer::addIsland( const QList<QgsPoint>& ring )
if ( addedIt->id() == selectedFeatureId )
{
return addedIt->geometry()->addIsland( ring );
mCachedGeometries[selectedFeatureId] = *(addedIt->geometry());
}
}

Expand All @@ -1672,6 +1678,7 @@ int QgsVectorLayer::addIsland( const QList<QgsPoint>& ring )
if ( errorCode == 0 )
{
mChangedGeometries.insert( selectedFeatureId, *cachedIt );
mCachedGeometries[selectedFeatureId] = *cachedIt;
setModified( true, true );
}
return errorCode;
Expand Down Expand Up @@ -2572,6 +2579,7 @@ bool QgsVectorLayer::changeGeometry(int fid, QgsGeometry* geom)
}

mChangedGeometries[ fid ] = *geom;
mCachedGeometries[fid] = *geom;
setModified( true, true );
return true;
}
Expand Down Expand Up @@ -3236,7 +3244,7 @@ int QgsVectorLayer::snapWithContext( const QgsPoint& startPoint, double snapping
int n = 0;
QgsFeature f;

if ( mCachedGeometriesRect.contains( searchRect ) )
if (mCachedGeometriesRect.contains( searchRect ) )
{
QgsDebugMsg( "Using cached geometries for snapping." );

Expand Down

0 comments on commit deec403

Please sign in to comment.