[QGIS Commit] r10701 - in trunk/qgis: python/core src/app src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat May 2 12:13:59 EDT 2009


Author: wonder
Date: 2009-05-02 12:13:59 -0400 (Sat, 02 May 2009)
New Revision: 10701

Modified:
   trunk/qgis/python/core/qgsvectorlayer.sip
   trunk/qgis/src/app/qgsmaptooldeletehole.cpp
   trunk/qgis/src/app/qgsmaptooldeletepart.cpp
   trunk/qgis/src/app/qgsmaptoolsimplify.cpp
   trunk/qgis/src/core/qgsvectorlayer.cpp
   trunk/qgis/src/core/qgsvectorlayer.h
Log:
Added changeGeometry() method as have been suggested on mailing list.


Modified: trunk/qgis/python/core/qgsvectorlayer.sip
===================================================================
--- trunk/qgis/python/core/qgsvectorlayer.sip	2009-05-02 15:37:35 UTC (rev 10700)
+++ trunk/qgis/python/core/qgsvectorlayer.sip	2009-05-02 16:13:59 UTC (rev 10701)
@@ -316,6 +316,10 @@
   /** 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);
 

Modified: trunk/qgis/src/app/qgsmaptooldeletehole.cpp
===================================================================
--- trunk/qgis/src/app/qgsmaptooldeletehole.cpp	2009-05-02 15:37:35 UTC (rev 10700)
+++ trunk/qgis/src/app/qgsmaptooldeletehole.cpp	2009-05-02 16:13:59 UTC (rev 10701)
@@ -111,8 +111,7 @@
 
   if (g->deleteHole( ringNum, partNum ))
   {
-    vlayer->deleteFeature( fId );
-    vlayer->addFeature(f);
+    vlayer->changeGeometry( fId, g );
     mCanvas->refresh();
   }
   

Modified: trunk/qgis/src/app/qgsmaptooldeletepart.cpp
===================================================================
--- trunk/qgis/src/app/qgsmaptooldeletepart.cpp	2009-05-02 15:37:35 UTC (rev 10700)
+++ trunk/qgis/src/app/qgsmaptooldeletepart.cpp	2009-05-02 16:13:59 UTC (rev 10701)
@@ -106,8 +106,7 @@
 
   if (g->deletePart( partNum ))
   {
-    vlayer->deleteFeature( fId );
-    vlayer->addFeature(f);
+    vlayer->changeGeometry( fId, g );
     mCanvas->refresh();
   }
   else

Modified: trunk/qgis/src/app/qgsmaptoolsimplify.cpp
===================================================================
--- trunk/qgis/src/app/qgsmaptoolsimplify.cpp	2009-05-02 15:37:35 UTC (rev 10700)
+++ trunk/qgis/src/app/qgsmaptoolsimplify.cpp	2009-05-02 16:13:59 UTC (rev 10701)
@@ -90,10 +90,9 @@
 {
   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();
 }
 

Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp	2009-05-02 15:37:35 UTC (rev 10700)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp	2009-05-02 16:13:59 UTC (rev 10701)
@@ -2553,6 +2553,20 @@
   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() )

Modified: trunk/qgis/src/core/qgsvectorlayer.h
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.h	2009-05-02 15:37:35 UTC (rev 10700)
+++ trunk/qgis/src/core/qgsvectorlayer.h	2009-05-02 16:13:59 UTC (rev 10701)
@@ -378,6 +378,10 @@
     /** 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 );
 



More information about the QGIS-commit mailing list