[GRASS-SVN] r34466 - grass/branches/develbranch_6/gui/wxpython/vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 24 00:54:55 EST 2008


Author: martinl
Date: 2008-11-24 00:54:55 -0500 (Mon, 24 Nov 2008)
New Revision: 34466

Modified:
   grass/branches/develbranch_6/gui/wxpython/vdigit/digit.cpp
   grass/branches/develbranch_6/gui/wxpython/vdigit/digit.h
   grass/branches/develbranch_6/gui/wxpython/vdigit/undo.cpp
Log:
wxGUI/vdigit: some minor fixes in undo


Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/digit.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/digit.cpp	2008-11-24 05:45:25 UTC (rev 34465)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/digit.cpp	2008-11-24 05:54:55 UTC (rev 34466)
@@ -32,7 +32,7 @@
 	InitCats();
     }
 
-    changesetCurrent = -1; // initial value for undo/redo
+    changesetEnd = changesetCurrent = -1; // initial value for undo/redo
 
     display->msgCaption = _("Digitization error");
     

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/digit.h
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/digit.h	2008-11-24 05:45:25 UTC (rev 34465)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/digit.h	2008-11-24 05:54:55 UTC (rev 34466)
@@ -36,7 +36,8 @@
 
     std::map<int, std::vector<action_meta> > changesets;
     int changesetCurrent;  /* first changeset to apply */
-
+    int changesetEnd;      /* last changeset to be applied */
+    
     int AddActionToChangeset(int, action_type, int);
     int ApplyChangeset(int, bool);
     void FreeChangeset(int);

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/undo.cpp
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/undo.cpp	2008-11-24 05:45:25 UTC (rev 34465)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/undo.cpp	2008-11-24 05:54:55 UTC (rev 34466)
@@ -55,7 +55,7 @@
     if (level < 0) { /* undo */
 	if (changesetCurrent + level < -1)
 	    return changesetCurrent;
-	for (int changeset = changesetCurrent; changeset >= changesetCurrent + level; --changeset) {
+	for (int changeset = changesetCurrent; changeset > changesetCurrent + level; --changeset) {
 	    ApplyChangeset(changeset, true);
 	}
     }
@@ -69,9 +69,14 @@
 
     changesetCurrent += level;
 
-    G_debug(2, "Digit.Undo(): changeset_current=%d",
-	    changesetCurrent);
-
+    G_debug(2, "Digit.Undo(): changeset_current=%d, changeset_last=%d, changeset_end=%d",
+	    changesetCurrent, changesetLast, changesetEnd);
+    
+    if (changesetCurrent == changesetEnd) {
+	changesetEnd = changesetLast;
+	return -1;
+    }
+    
     return changesetCurrent;
 }
 
@@ -92,13 +97,16 @@
     if (changeset < 0 || changeset > (int) changesets.size())
 	return -1;
 
+    if (changesetEnd < 0)
+	changesetEnd = changeset;
+    
     ret = 0;
     std::vector<action_meta> action = changesets[changeset];
     for (std::vector<action_meta>::const_reverse_iterator i = action.rbegin(), e = action.rend();
 	 i != e; ++i) {
 	type = (*i).type;
 	line = (*i).line;
-
+	
 	if ((undo && type == ADD) ||
 	    (!undo && type == DEL)) {
 	    if (Vect_line_alive(display->mapInfo, line)) {



More information about the grass-commit mailing list