[GRASS-SVN] r48041 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 1 12:16:39 EDT 2011


Author: martinl
Date: 2011-09-01 09:16:39 -0700 (Thu, 01 Sep 2011)
New Revision: 48041

Modified:
   grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
   grass/trunk/gui/wxpython/gui_modules/toolbars.py
Log:
wxGUI/vdigit: don't define default action (bug-fix)


Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py	2011-09-01 15:58:06 UTC (rev 48040)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_vdigit.py	2011-09-01 16:16:39 UTC (rev 48041)
@@ -20,6 +20,7 @@
 
 import dbm_dialogs
 
+import gcmd
 from debug import Debug
 from mapdisp_window import BufferedWindow
 from preferences import globalSettings as UserSettings
@@ -486,50 +487,52 @@
         try:
             mapLayer = self.toolbar.GetLayer().GetName()
         except:
-            wx.MessageBox(parent = self,
-                          message = _("No vector map selected for editing."),
-                          caption = _("Vector digitizer"),
-                          style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
+            gcmd.GMessage(parent = self,
+                          message = _("No vector map selected for editing."))
             event.Skip()
             return
-    
-        if self.toolbar.GetAction() not in ("moveVertex",
-                                            "addVertex",
-                                            "removeVertex",
-                                            "editLine"):
+        
+        action = self.toolbar.GetAction()
+        if not action:
+            return
+        
+        if action not in ("moveVertex",
+                          "addVertex",
+                          "removeVertex",
+                          "editLine"):
             # set pen
             self.pen = wx.Pen(colour = 'Red', width = 2, style = wx.SHORT_DASH)
             self.polypen = wx.Pen(colour = 'dark green', width = 2, style = wx.SOLID)
             
-        if self.toolbar.GetAction() in ("addVertex",
-                                        "removeVertex",
-                                        "splitLines"):
+        if action in ("addVertex",
+                      "removeVertex",
+                      "splitLines"):
             # unselect
             self.digit.GetDisplay().SetSelected([])
 
-        if self.toolbar.GetAction() == "addLine":
+        if action == "addLine":
             self.OnLeftDownAddLine(event)
             
-        elif self.toolbar.GetAction() == "editLine" and \
+        elif action == "editLine" and \
                 hasattr(self, "moveInfo"):
             self.OnLeftDownEditLine(event)
 
-        elif self.toolbar.GetAction() in ("moveLine", "moveVertex", "editLine") and \
+        elif action in ("moveLine", "moveVertex", "editLine") and \
                 not hasattr(self, "moveInfo"):
             self.OnLeftDownMoveLine(event)
         
-        elif self.toolbar.GetAction() in ("displayAttrs"
-                                          "displayCats"):
+        elif action in ("displayAttrs"
+                        "displayCats"):
             self.OnLeftDownDisplayCA(event)
             
-        elif self.toolbar.GetAction() in ("copyCats",
-                                          "copyAttrs"):
+        elif action in ("copyCats",
+                        "copyAttrs"):
             self.OnLeftDownCopyCA(event)
             
-        elif self.toolbar.GetAction() == "copyLine":
+        elif action == "copyLine":
             self.OnLeftDownCopyLine(event)
             
-        elif self.toolbar.GetAction() == "zbulkLine":
+        elif action == "zbulkLine":
             self.OnLeftDownBulkLine(event)
         
     def OnLeftUpVarious(self, event):

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2011-09-01 15:58:06 UTC (rev 48040)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2011-09-01 16:16:39 UTC (rev 48041)
@@ -1026,7 +1026,7 @@
             pdc.SetId(boxid)
             self.Draw(pdc, drawid = boxid, pdctype = 'box', coords = mousecoords)
         
-        elif self.mouse['box'] == "line" or self.mouse['box'] == 'point':
+        elif self.mouse['box'] == "line":
             self.lineid = wx.ID_NEW
             mousecoords = [begin[0], begin[1], \
                            end[0], end[1]]

Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py	2011-09-01 15:58:06 UTC (rev 48040)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py	2011-09-01 16:16:39 UTC (rev 48041)
@@ -506,9 +506,9 @@
         self.Bind(wx.EVT_TOOL, self.OnTool)
         
         # default action (digitize new point, line, etc.)
-        self.action = { 'desc' : 'addLine',
-                        'type' : 'point',
-                        'id'   : self.addPoint }
+        self.action = { 'desc' : '',
+                        'type' : '',
+                        'id'   : -1 }
         
         # list of available vector maps
         self.UpdateListOfLayers(updateTool = True)
@@ -534,7 +534,8 @@
         icons = Icons['vdigit']
         return self._getToolbarData(((None, ),
                                      ("addPoint", icons["addPoint"],
-                                      self.OnAddPoint),
+                                      self.OnAddPoint,
+                                      wx.ITEM_CHECK),
                                      ("addLine", icons["addLine"],
                                       self.OnAddLine,
                                       wx.ITEM_CHECK),
@@ -585,8 +586,8 @@
     
     def OnTool(self, event):
         """!Tool selected -> disable selected tool in map toolbar"""
-        id = self.parent.toolbars['map'].GetAction(type = 'id')
-        self.parent.toolbars['map'].ToggleTool(id, False)
+        aId = self.parent.toolbars['map'].GetAction(type = 'id')
+        self.parent.toolbars['map'].ToggleTool(aId, False)
         
         # set cursor
         cursor = self.parent.cursors["cross"]
@@ -597,8 +598,9 @@
         
         if event:
             # deselect previously selected tool
-            id = self.action.get('id', -1)
-            if id != event.GetId():
+            aId = self.action.get('id', -1)
+            if aId != event.GetId() and \
+                    self.action['id'] != -1:
                 self.ToggleTool(self.action['id'], False)
             else:
                 self.ToggleTool(self.action['id'], True)
@@ -607,10 +609,11 @@
             
             event.Skip()
         
-        self.ToggleTool(self.action['id'], True)
+        if self.action['id'] != -1:
+            self.ToggleTool(self.action['id'], True)
         
         # clear tmp canvas
-        if self.action['id'] != id:
+        if self.action['id'] != aId:
             self.parent.MapWindow.ClearLines(pdc = self.parent.MapWindow.pdcTmp)
             if self.digit and \
                     len(self.parent.MapWindow.digit.GetDisplay().GetSelected()) > 0:



More information about the grass-commit mailing list