[GRASS-SVN] r50304 - grass/trunk/gui/wxpython/vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jan 19 12:42:27 EST 2012
Author: martinl
Date: 2012-01-19 09:42:27 -0800 (Thu, 19 Jan 2012)
New Revision: 50304
Modified:
grass/trunk/gui/wxpython/vdigit/toolbars.py
grass/trunk/gui/wxpython/vdigit/wxdigit.py
Log:
wxGUI/digit: implement `redo` tool
Modified: grass/trunk/gui/wxpython/vdigit/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/toolbars.py 2012-01-19 17:30:56 UTC (rev 50303)
+++ grass/trunk/gui/wxpython/vdigit/toolbars.py 2012-01-19 17:42:27 UTC (rev 50304)
@@ -46,6 +46,7 @@
self.comboid = self.combo = None
self.undo = -1
+ self.redo = -1
# only one dialog can be open
self.settingsDialog = None
@@ -70,14 +71,16 @@
self.combo.Show()
# disable undo/redo
- if self.undo:
+ if self.undo > 0:
self.EnableTool(self.undo, False)
+ if self.redo > 0:
+ self.EnableTool(self.redo, False)
# toogle to pointer by default
self.OnTool(None)
self.FixSize(width = 105)
-
+
def _toolbarData(self):
"""!Toolbar data
"""
@@ -133,9 +136,12 @@
label = _('Additional tools '
'(copy, flip, connect, etc.)'),
desc = _('Left: Select; Ctrl+Left: Unselect; Right: Confirm')),
- 'undo' : MetaIcon(img = 'undo',
- label = _('Undo'),
- desc = _('Undo previous changes')),
+ 'undo' : MetaIcon(img = 'undo',
+ label = _('Undo'),
+ desc = _('Undo previous changes')),
+ 'redo' : MetaIcon(img = 'redo',
+ label = _('Redo'),
+ desc = _('Redo previous changes')),
}
if not self.tools or 'selector' in self.tools:
@@ -207,6 +213,9 @@
if not self.tools or 'undo' in self.tools:
data.append(("undo", icons["undo"],
self.OnUndo))
+ if not self.tools or 'redo' in self.tools:
+ data.append(("redo", icons["redo"],
+ self.OnRedo))
if not self.tools or 'settings' in self.tools:
data.append(("settings", icons["settings"],
self.OnSettings))
@@ -386,21 +395,36 @@
event.Skip()
+ def OnRedo(self, event):
+ """!Undo previous changes"""
+ self.digit.Undo(level = 1)
+
+ event.Skip()
+
def EnableUndo(self, enable = True):
"""!Enable 'Undo' in toolbar
@param enable False for disable
"""
- # iclass has no undo, we need to check it
- if self.FindById(self.undo) is None:
+ self._enableTool(self.undo, enable)
+
+ def EnableRedo(self, enable = True):
+ """!Enable 'Redo' in toolbar
+
+ @param enable False for disable
+ """
+ self._enableTool(self.redo, enable)
+
+ def _enableTool(self, tool, enable):
+ if not self.FindById(tool):
return
if enable:
- if self.GetToolEnabled(self.undo) is False:
- self.EnableTool(self.undo, True)
+ if self.GetToolEnabled(tool) is False:
+ self.EnableTool(tool, True)
else:
- if self.GetToolEnabled(self.undo) is True:
- self.EnableTool(self.undo, False)
+ if self.GetToolEnabled(tool) is True:
+ self.EnableTool(tool, False)
def OnSettings(self, event):
"""!Show settings dialog"""
@@ -724,6 +748,7 @@
fType = self.digit.GetFeatureType()
self.EnableAll()
self.EnableUndo(False)
+ self.EnableRedo(False)
if fType == 'Point':
for tool in (self.addLine, self.addBoundary, self.addCentroid,
Modified: grass/trunk/gui/wxpython/vdigit/wxdigit.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/wxdigit.py 2012-01-19 17:30:56 UTC (rev 50303)
+++ grass/trunk/gui/wxpython/vdigit/wxdigit.py 2012-01-19 17:42:27 UTC (rev 50304)
@@ -171,7 +171,6 @@
# undo/redo
self.changesets = list()
self.changesetCurrent = -1 # first changeset to apply
- self.changesetEnd = -1 # last changeset to be applied
if self.poMapInfo:
self.InitCats()
@@ -351,17 +350,12 @@
if changeset < 0 or changeset >= len(self.changesets):
return -1
- if self.changesetEnd < 0:
- self.changesetEnd = changeset
-
ret = 0
actions = self.changesets[changeset]
- for action in actions:
- add = bool(action['offset'] > 0)
+ for action in actions:
line = action['line']
- if (undo and add) or \
- (not undo and not add):
+ if action['offset'] > 0:
if Vect_line_alive(self.poMapInfo, line):
Debug.msg(3, "IVDigit._applyChangeset(): changeset=%d, action=add, line=%d -> deleted",
changeset, line)
@@ -1216,13 +1210,11 @@
if changesetLast < 0:
return changesetLast
- if self.changesetCurrent == -2: # value uninitialized
- self.changesetCurrent = changesetLast
-
if level > 0 and self.changesetCurrent < 0:
self.changesetCurrent = 0
-
- if level == 0:
+ elif level < 0 and self.changesetCurrent > changesetLast:
+ self.changesetCurrent = changesetLast
+ elif level == 0:
# 0 -> undo all
level = -1 * changesetLast + 1
@@ -1241,19 +1233,22 @@
self._applyChangeset(changeset, undo = False)
self.changesetCurrent += level
-
- Debug.msg(2, "Digit.Undo(): changeset_current=%d, changeset_last=%d, changeset_end=%d",
- self.changesetCurrent, changesetLast, self.changesetEnd)
- if self.changesetCurrent == self.changesetEnd:
- self.changesetEnd = changesetLast
- return -1
+ Debug.msg(2, "Digit.Undo(): changeset_current=%d, changeset_last=%d",
+ self.changesetCurrent, changesetLast)
self.mapWindow.UpdateMap(render = False)
if self.changesetCurrent < 0: # disable undo tool
self.toolbar.EnableUndo(False)
+ else:
+ self.toolbar.EnableUndo(True)
+ if self.changesetCurrent <= changesetLast:
+ self.toolbar.EnableRedo(True)
+ else:
+ self.toolbar.EnableRedo(False)
+
def ZBulkLines(self, pos1, pos2, start, step):
"""!Z-bulk labeling
More information about the grass-commit
mailing list