Skip to content
Permalink
Browse files

Added changeGeometry() method as have been suggested on mailing list.

git-svn-id: http://svn.osgeo.org/qgis/trunk@10701 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed May 2, 2009
1 parent cbc57dc commit c245c644aefd67c2935bb5710861a352ccdc5146
@@ -316,6 +316,10 @@ public:
/** Make layer editable */
bool startEditing();

/** change feature's geometry
@note added in version 1.2 */
bool changeGeometry(int fid, QgsGeometry* geom);

/** changed an attribute value (but does not commit it */
bool changeAttributeValue(int fid, int field, QVariant value, bool emitSignal = true);

@@ -111,8 +111,7 @@ void QgsMapToolDeleteHole::deleteHole( int fId, int beforeVertexNr, QgsVectorLay

if (g->deleteHole( ringNum, partNum ))
{
vlayer->deleteFeature( fId );
vlayer->addFeature(f);
vlayer->changeGeometry( fId, g );
mCanvas->refresh();
}

@@ -106,8 +106,7 @@ void QgsMapToolDeletePart::deletePart( int fId, int beforeVertexNr, QgsVectorLay

if (g->deletePart( partNum ))
{
vlayer->deleteFeature( fId );
vlayer->addFeature(f);
vlayer->changeGeometry( fId, g );
mCanvas->refresh();
}
else
@@ -90,9 +90,8 @@ void QgsMapToolSimplify::storeSimplified()
{
QgsVectorLayer * vlayer = currentVectorLayer();
QgsSimplifyFeature::simplifyLine(mSelectedFeature, mTolerance);
// TODO(md): change geometry of feature instead of delete+add
vlayer->deleteFeature( mSelectedFeature.id() );
vlayer->addFeature(mSelectedFeature);

vlayer->changeGeometry( mSelectedFeature.id(), mSelectedFeature.geometry() );

mCanvas->refresh();
}
@@ -2553,6 +2553,20 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
return true;
}


bool QgsVectorLayer::changeGeometry(int fid, QgsGeometry* geom)
{
if ( !mEditable || !mDataProvider )
{
return false;
}

mChangedGeometries[ fid ] = *geom;
setModified( true, true );
return true;
}


bool QgsVectorLayer::changeAttributeValue( int fid, int field, QVariant value, bool emitSignal )
{
if ( !isEditable() )
@@ -378,6 +378,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Make layer editable */
bool startEditing();

/** change feature's geometry
@note added in version 1.2 */
bool changeGeometry(int fid, QgsGeometry* geom);

/** changed an attribute value (but does not commit it) */
bool changeAttributeValue( int fid, int field, QVariant value, bool emitSignal = true );

0 comments on commit c245c64

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