Skip to content
Permalink
Browse files

[GRASS] keep added features symbol updated

  • Loading branch information
blazek committed Oct 2, 2015
1 parent d054e48 commit 00ea5b4c4d264c9ce770c25c6784ac69f02b6c4f
Showing with 50 additions and 1 deletion.
  1. +48 −1 src/providers/grass/qgsgrassprovider.cpp
  2. +2 −0 src/providers/grass/qgsgrassprovider.h
@@ -1324,6 +1324,11 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid )
QgsDebugMsg( QString( "newCats[%1] = %2" ).arg( fid ).arg( newCat ) );
}
}

if ( type == GV_BOUNDARY )
{
setAddedFeaturesSymbol();
}
}

Vect_destroy_line_struct( points );
@@ -1358,9 +1363,12 @@ void QgsGrassProvider::onFeatureDeleted( QgsFeatureId fid )
}
}

int type = 0;
mLayer->map()->lockReadWrite();
G_TRY
{
type = Vect_read_line( map(), 0, 0, realLine ); // to know if symbols have to be updated

Vect_delete_line( map(), realLine );
// oldLids are maping to the very first, original version (used by undo)
int oldestLid = oldLid;
@@ -1377,6 +1385,11 @@ void QgsGrassProvider::onFeatureDeleted( QgsFeatureId fid )
QgsDebugMsg( QString( "Cannot delete line : %1" ).arg( e.what() ) );
}
mLayer->map()->unlockReadWrite();

if ( type == GV_BOUNDARY )
{
setAddedFeaturesSymbol();
}
}

void QgsGrassProvider::onGeometryChanged( QgsFeatureId fid, QgsGeometry &geom )
@@ -1392,7 +1405,7 @@ void QgsGrassProvider::onGeometryChanged( QgsFeatureId fid, QgsGeometry &geom )
struct line_pnts *points = Vect_new_line_struct();
struct line_cats *cats = Vect_new_cats_struct();

int type;
int type = 0;
G_TRY
{
type = Vect_read_line( map(), points, cats, realLine );
@@ -1450,6 +1463,11 @@ void QgsGrassProvider::onGeometryChanged( QgsFeatureId fid, QgsGeometry &geom )

Vect_destroy_line_struct( points );
Vect_destroy_cats_struct( cats );

if ( type == GV_BOUNDARY )
{
setAddedFeaturesSymbol();
}
}

void QgsGrassProvider::onAttributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
@@ -1536,6 +1554,35 @@ void QgsGrassProvider::onAttributeDeleted( int idx )
}
}

void QgsGrassProvider::setAddedFeaturesSymbol()
{
QgsDebugMsg( "entered" );
if ( !mEditBuffer )
{
return;
}
QgsFeatureMap& features = const_cast<QgsFeatureMap&>( mEditBuffer->addedFeatures() );
Q_FOREACH ( QgsFeatureId fid, features.keys() )
{
QgsFeature feature = features[fid];
if ( !feature.geometry() || !feature.geometry()->geometry() ||
feature.geometry()->geometry()->wkbType() != QgsWKBTypes::LineString )
{
continue;
}
int lid = QgsGrassFeatureIterator::lidFromFid( fid );
int realLid = lid;
if ( mLayer->map()->newLids().contains( lid ) )
{
realLid = mLayer->map()->newLids().value( lid );
}
QgsDebugMsg( QString( "fid = %1 lid = %2 realLid = %3" ).arg( fid ).arg( lid ).arg( realLid ) );
QgsGrassVectorMap::TopoSymbol symbol = mLayer->map()->topoSymbol( realLid );
feature.setAttribute( QgsGrassVectorMap::topoSymbolFieldName(), symbol );
features[fid] = feature;
}
}

void QgsGrassProvider::onUndoIndexChanged( int index )
{
Q_UNUSED( index )
@@ -404,6 +404,8 @@ class GRASS_LIB_EXPORT QgsGrassProvider : public QgsVectorDataProvider
struct Map_info * map();
void setMapset();
bool openLayer();
// update topo symbol of new features
void setAddedFeaturesSymbol();

QgsGrassObject mGrassObject;
// field part of layer or -1 if no field specified

0 comments on commit 00ea5b4

Please sign in to comment.
You can’t perform that action at this time.