Bladeren bron

wxGUI/vdigit pythonization: zbulk & feat conversion implemeneted

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@44913 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 jaren geleden
bovenliggende
commit
1b281dfa95
2 gewijzigde bestanden met toevoegingen van 45 en 11 verwijderingen
  1. 4 5
      gui/wxpython/gui_modules/toolbars.py
  2. 41 6
      gui/wxpython/gui_modules/wxvdigit.py

+ 4 - 5
gui/wxpython/gui_modules/toolbars.py

@@ -15,7 +15,7 @@ Classes:
  - HistogramToolbar
  - LayerManagerToolbar
 
-(C) 2007-2010 by the GRASS Development Team
+(C) 2007-2011 by the GRASS Development Team
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
 
@@ -1173,10 +1173,9 @@ class VDigitToolbar(AbstractToolbar):
 
     def OnZBulk(self, event):
         """!Z bulk-labeling selected lines/boundaries"""
-        if not self.parent.digit.driver.Is3D():
-            wx.MessageBox(parent = self.parent,
-                          message = _("Vector map is not 3D. Operation canceled."),
-                          caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
+        if not self.parent.digit.IsVector3D():
+            gcmd.GError(parent = self.parent,
+                        message = _("Vector map is not 3D. Operation canceled."))
             return
         
         if self.action['desc'] == 'zbulkLine': # select previous action

+ 41 - 6
gui/wxpython/gui_modules/wxvdigit.py

@@ -873,6 +873,14 @@ class IVDigit:
         
         return ids
 
+    def IsVector3D(self):
+        """!Check if open vector map is 3D
+        """
+        if not self._checkMap():
+            return False
+        
+        return Vect_is_3d(self.poMapInfo)
+    
     def GetLineCats(self, line=-1):
         """!Get layer/category pairs from given (selected) line
         
@@ -942,14 +950,27 @@ class IVDigit:
         @return number of modified features
         @return -1 on error
         """
-        ret = self.digit.TypeConvLines()
-
+        if not self._checkMap():
+            return -1
+        
+        nlines = Vect_get_num_lines(self.poMapInfo)
+        
+        # register changeset
+        changeset = self._addActionsBefore()
+        
+        poList = self._display.GetSelectedIList()
+        ret = Vedit_chtype_lines(self.poMapInfo, poList)
+        Vect_destroy_list(poList)
+        
         if ret > 0:
+            self._addActionsAfter(changeset, nlines)
             self.toolbar.EnableUndo()
-
+        else:
+            del self.changesets[changeset]
+        
         return ret
 
-    def Undo(self, level=-1):
+    def Undo(self, level = -1):
         """!Undo action
 
         @param level levels to undo (0 to revert all)
@@ -980,11 +1001,25 @@ class IVDigit:
         @return number of modified lines
         @return -1 on error
         """
-        ret = self.digit.ZBulkLabeling(pos1[0], pos1[1], pos2[0], pos2[1],
-                                       start, step)
+        if not self._checkMap():
+            return -1
+        
+        nlines = Vect_get_num_lines(self.poMapInfo)
+        
+        # register changeset
+        changeset = self._addActionsBefore()
+        
+        poList = self._display.GetSelectedIList()
+        ret = Vedit_bulk_labeling(self.poMapInfo, poList,
+                                  pos1[0], pos1[1], pos2[0], pos2[1],
+                                  start, step)
+        Vect_destroy_list(poList)
         
         if ret > 0:
+            self._addActionsAfter(changeset, nlines)
             self.toolbar.EnableUndo()
+        else:
+            del self.changesets[changeset]
         
         return ret