[GRASS-SVN] r62122 - grass/trunk/gui/wxpython/vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 27 19:53:26 PDT 2014


Author: annakrat
Date: 2014-09-27 19:53:26 -0700 (Sat, 27 Sep 2014)
New Revision: 62122

Modified:
   grass/trunk/gui/wxpython/vdigit/toolbars.py
Log:
wxGUI/digitizer: fix selecting area tools

Modified: grass/trunk/gui/wxpython/vdigit/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/toolbars.py	2014-09-28 01:46:15 UTC (rev 62121)
+++ grass/trunk/gui/wxpython/vdigit/toolbars.py	2014-09-28 02:53:26 UTC (rev 62122)
@@ -73,6 +73,7 @@
         self.action = { 'desc' : '',
                         'type' : '',
                         'id'   : -1 }
+        self._currentAreaActionType = None
         
         # list of available vector maps
         self.UpdateListOfLayers(updateTool = True)
@@ -306,6 +307,9 @@
     def OnAddBoundary(self, event):
         """Add boundary to the vector map layer"""
         Debug.msg (2, "VDigitToolbar.OnAddBoundary()")
+
+        self._toggleAreaIfNeeded()
+
          # reset temp line
         if self.action['desc'] != 'addLine' or \
                 self.action['type'] != 'boundary':
@@ -320,11 +324,14 @@
                         'type' : "boundary",
                         'id'   : self.addArea }
         self.MapWindow.mouse['box'] = 'line'
+        self._currentAreaActionType = 'boundary'
         
     def OnAddCentroid(self, event):
         """Add centroid to the vector map layer"""
         Debug.msg (2, "VDigitToolbar.OnAddCentroid()")
 
+        self._toggleAreaIfNeeded()
+
         # update icon and tooltip
         self.SetToolNormalBitmap(self.addArea, self.icons['addCentroid'].GetBitmap())
         self.SetToolShortHelp(self.addArea, self.icons['addCentroid'].GetLabel())
@@ -334,10 +341,15 @@
                         'type' : "centroid",
                         'id'   : self.addArea }
         self.MapWindow.mouse['box'] = 'point'
+        self._currentAreaActionType = 'centroid'
 
     def OnAddArea(self, event):
         """Add area to the vector map layer"""
+
         Debug.msg (2, "VDigitToolbar.OnAddArea()")
+
+        self._toggleAreaIfNeeded()
+
         # update icon and tooltip
         self.SetToolNormalBitmap(self.addArea, self.icons['addArea'].GetBitmap())
         self.SetToolShortHelp(self.addArea, self.icons['addArea'].GetLabel())
@@ -347,18 +359,24 @@
                         'type' : "area",
                         'id'   : self.addArea }
         self.MapWindow.mouse['box'] = 'line'
+        self._currentAreaActionType = 'area'
 
+    def _toggleAreaIfNeeded(self):
+        """In some cases, the area tool is not toggled, we have to do it manually."""
+        if not self.GetToolState(self.addArea):
+            self.ToggleTool(self.addArea, True)
+            self.toolSwitcher.ToolChanged(self.addArea)
+
     def OnAddAreaTool(self, event):
         """Area tool activated."""
         Debug.msg (2, "VDigitToolbar.OnAddAreaTool()")
-        
+
         # we need the previous id
-        if 'type' not in self.action or \
-                self.action['type'] in ('area', ''): # default action
+        if not self._currentAreaActionType or self._currentAreaActionType == 'area': # default action
             self.OnAddArea(event)
-        elif self.action['type'] == 'boundary':
+        elif self._currentAreaActionType == 'boundary':
             self.OnAddBoundary(event)
-        elif self.action['type'] == 'centroid':
+        elif self._currentAreaActionType == 'centroid':
             self.OnAddCentroid(event)
 
     def OnAddAreaMenu(self, event):



More information about the grass-commit mailing list