[GRASS-SVN] r63397 - in grass/branches/releasebranch_7_0/gui/wxpython: mapdisp vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Dec 6 06:50:41 PST 2014


Author: mmetz
Date: 2014-12-06 06:50:41 -0800 (Sat, 06 Dec 2014)
New Revision: 63397

Modified:
   grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/main.py
   grass/branches/releasebranch_7_0/gui/wxpython/vdigit/g.gui.vdigit.py
   grass/branches/releasebranch_7_0/gui/wxpython/vdigit/preferences.py
   grass/branches/releasebranch_7_0/gui/wxpython/vdigit/toolbars.py
   grass/branches/releasebranch_7_0/gui/wxpython/vdigit/wxdigit.py
Log:
wxGUI: backport vdigit from trunk

Modified: grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/main.py	2014-12-06 13:49:51 UTC (rev 63396)
+++ grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/main.py	2014-12-06 14:50:41 UTC (rev 63397)
@@ -334,7 +334,10 @@
     def GetMapWindow(self):
         return self._mapframe.GetMapWindow()
 
+    def GetProgress(self):
+        return self._mapframe.GetProgressBar()
 
+
 class DMonFrame(MapFrame):
     def OnZoomToMap(self, event):
         layers = self.MapWindow.GetMap().GetListOfLayers()

Modified: grass/branches/releasebranch_7_0/gui/wxpython/vdigit/g.gui.vdigit.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/vdigit/g.gui.vdigit.py	2014-12-06 13:49:51 UTC (rev 63396)
+++ grass/branches/releasebranch_7_0/gui/wxpython/vdigit/g.gui.vdigit.py	2014-12-06 14:50:41 UTC (rev 63397)
@@ -21,11 +21,10 @@
 #%module
 #% description: Interactive editing and digitization of vector maps.
 #% keywords: general
-#% keywords: user interface
 #% keywords: GUI
 #% keywords: vector
 #% keywords: editing
-#% keywords: digitizer
+#% keywords: digitization
 #%end
 #%flag
 #% key: c
@@ -44,7 +43,7 @@
 from core.globalvar import CheckWxVersion
 from core.utils import _, GuiModuleMain
 from mapdisp.frame import MapFrame
-from core.giface import StandaloneGrassInterface
+from mapdisp.main import DMonGrassInterface
 from core.settings import UserSettings
 from vdigit.main import haveVDigit, errorMsg
 from grass.exceptions import CalledModuleError
@@ -52,9 +51,10 @@
 
 class VDigitMapFrame(MapFrame):
     def __init__(self, vectorMap):
-        MapFrame.__init__(self, parent = None, giface = StandaloneGrassInterface(),
+        MapFrame.__init__(self, parent = None, giface = DMonGrassInterface(None),
                           title = _("GRASS GIS Vector Digitizer"), size = (850, 600))
-
+        # this giface issue not solved yet, we must set mapframe aferwards
+        self._giface._mapframe = self
         # load vector map
         mapLayer = self.GetMap().AddLayer(ltype = 'vector',
                                           command = ['d.vect', 'map=%s' % vectorMap],

Modified: grass/branches/releasebranch_7_0/gui/wxpython/vdigit/preferences.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/vdigit/preferences.py	2014-12-06 13:49:51 UTC (rev 63396)
+++ grass/branches/releasebranch_7_0/gui/wxpython/vdigit/preferences.py	2014-12-06 14:50:41 UTC (rev 63397)
@@ -48,7 +48,7 @@
 
         # buttons
         btnApply = wx.Button(self, wx.ID_APPLY)
-        btnCancel = wx.Button(self, wx.ID_CANCEL)
+        btnCancel = wx.Button(self, wx.ID_CLOSE)
         btnSave = wx.Button(self, wx.ID_SAVE)
         btnSave.SetDefault()
 
@@ -62,16 +62,18 @@
         btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
         
         # sizers
-        btnSizer = wx.StdDialogButtonSizer()
-        btnSizer.AddButton(btnCancel)
-        btnSizer.AddButton(btnApply)
-        btnSizer.AddButton(btnSave)
-        btnSizer.Realize()
+        btnSizer = wx.wx.BoxSizer(wx.HORIZONTAL)
+        btnSizer.Add(btnCancel, proportion = 0,
+                     flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
+        btnSizer.Add(btnApply, proportion = 0,
+                     flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
+        btnSizer.Add(btnSave, proportion = 0,
+                     flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
         
         mainSizer = wx.BoxSizer(wx.VERTICAL)
         mainSizer.Add(item = notebook, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
         mainSizer.Add(item = btnSizer, proportion = 0,
-                      flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
+                      flag = wx.ALIGN_RIGHT, border = 5)
         
         self.Bind(wx.EVT_CLOSE, self.OnCancel)
         

Modified: grass/branches/releasebranch_7_0/gui/wxpython/vdigit/toolbars.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/vdigit/toolbars.py	2014-12-06 13:49:51 UTC (rev 63396)
+++ grass/branches/releasebranch_7_0/gui/wxpython/vdigit/toolbars.py	2014-12-06 14:50:41 UTC (rev 63397)
@@ -913,7 +913,7 @@
         if self.combo:
             self.combo.SetValue(mapLayer.GetName())
         if 'map' in self.parent.toolbars:
-            self.parent.toolbars['map'].combo.SetValue (_('Digitize'))
+            self.parent.toolbars['map'].combo.SetValue (_('Vector digitizer'))
         
         # here was dead code to enable vdigit button in toolbar
         # with if to ignore iclass

Modified: grass/branches/releasebranch_7_0/gui/wxpython/vdigit/wxdigit.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/vdigit/wxdigit.py	2014-12-06 13:49:51 UTC (rev 63396)
+++ grass/branches/releasebranch_7_0/gui/wxpython/vdigit/wxdigit.py	2014-12-06 14:50:41 UTC (rev 63397)
@@ -370,6 +370,13 @@
         return ret
     
     def _addChangeset(self):
+
+	# disable redo
+	changesetLast = len(self.changesets) - 1
+	if self.changesetCurrent < changesetLast and len(self.changesets) > 0:
+	    del self.changesets[self.changesetCurrent + 1:changesetLast + 1]
+            self.toolbar.EnableRedo(False)
+
         data = list()
         for i in range(Vect_get_num_updated_lines(self.poMapInfo) - 1, -1, -1):
             line = Vect_get_updated_line(self.poMapInfo, i)
@@ -398,8 +405,18 @@
         
         ret = 0
         actions = self.changesets[changeset]
-        
-        for action in actions:
+	
+        if undo:
+            firstaction = 0
+            lastaction = len(actions)
+            step = 1
+        else:
+            firstaction = len(actions) - 1
+            lastaction = -1
+            step = -1
+
+        for i in range(firstaction, lastaction, step):
+            action = actions[i]
             line = action['line']
             if action['offset'] > 0:
                 if Vect_line_alive(self.poMapInfo, line):
@@ -1548,13 +1565,11 @@
         if changesetLast < 0:
             return changesetLast
         
-        if level > 0 and self.changesetCurrent < 0:
-            self.changesetCurrent = 0
-        elif level < 0 and self.changesetCurrent > changesetLast:
+        if level < 0 and self.changesetCurrent > changesetLast:
             self.changesetCurrent = changesetLast
         elif level == 0:
             # 0 -> undo all
-            level = -1 * changesetLast + 1
+            level = -1 * self.changesetCurrent - 1
         
         Debug.msg(2, "Digit.Undo(): changeset_last=%d, changeset_current=%d, level=%d",
                   changesetLast, self.changesetCurrent, level)
@@ -1565,9 +1580,9 @@
             for changeset in range(self.changesetCurrent, self.changesetCurrent + level, -1):
                 self._applyChangeset(changeset, undo = True)
         elif level > 0: # redo 
-            if self.changesetCurrent + level > len(self.changesets):
+            if self.changesetCurrent + 1 > changesetLast:
                 return self.changesetCurrent
-            for changeset in range(self.changesetCurrent, self.changesetCurrent + level):
+            for changeset in range(self.changesetCurrent + 1, self.changesetCurrent + 1 + level):
                 self._applyChangeset(changeset, undo = False)
         
         self.changesetCurrent += level
@@ -1582,7 +1597,7 @@
         else:
             self.toolbar.EnableUndo(True)
         
-        if self.changesetCurrent <= changesetLast:
+        if self.changesetCurrent < changesetLast:
             self.toolbar.EnableRedo(True)
         else:
             self.toolbar.EnableRedo(False)
@@ -1766,13 +1781,9 @@
         if newline < 0:
             self._error.WriteLine()
             return (-1, None)
-        else:
-            fids.append(newline)
+
+	fids.append(newline)
         
-        # break at intersection
-        if self._settings['breakLines']:
-            self._breakLineAtIntersection(newline, self.poPoints)
-            
         # add centroids for left/right area
         if ftype & GV_AREA:
             left = right = -1
@@ -1802,13 +1813,13 @@
                 if Vect_get_point_in_area(self.poMapInfo, left, byref(x), byref(y)) == 0:
                     Vect_reset_line(bpoints)
                     Vect_append_point(bpoints, x.value, y.value, 0.0)
-                    newline = Vect_write_line(self.poMapInfo, GV_CENTROID,
+                    newc = Vect_write_line(self.poMapInfo, GV_CENTROID,
                                               bpoints, self.poCats)
-                    if newline < 0:
+                    if newc < 0:
                         self._error.WriteLine()
                         return (len(fids), fids)
                     else:
-                        fids.append(newline)
+                        fids.append(newc)
                     
             if right > 0 and \
                     Vect_get_area_centroid(self.poMapInfo, right) == 0:
@@ -1817,16 +1828,20 @@
                 if Vect_get_point_in_area(self.poMapInfo, right, byref(x), byref(y)) == 0:
                     Vect_reset_line(bpoints)
                     Vect_append_point(bpoints, x.value, y.value, 0.0)
-                    newline =  Vect_write_line(self.poMapInfo, GV_CENTROID,
+                    newc =  Vect_write_line(self.poMapInfo, GV_CENTROID,
                                                bpoints, self.poCats)
-                    if newline < 0:
+                    if newc < 0:
                         self._error.WriteLine()
                         return (len(fids, fids))
                     else:
-                        fids.append(newline)
+                        fids.append(newc)
                     
             Vect_destroy_line_struct(bpoints)
-        
+
+        # break line or boundary at intersection
+        if self._settings['breakLines']:
+            self._breakLineAtIntersection(newline, self.poPoints)
+
         self._addChangeset()
         
         if ftype & GV_AREA:



More information about the grass-commit mailing list