Browse Source

wxGUI/vdigit: don't define default action (bug-fix)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48041 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 years ago
parent
commit
a5406afe32

+ 24 - 21
gui/wxpython/gui_modules/mapdisp_vdigit.py

@@ -20,6 +20,7 @@ import wx
 
 import dbm_dialogs
 
+import gcmd
 from debug import Debug
 from mapdisp_window import BufferedWindow
 from preferences import globalSettings as UserSettings
@@ -486,50 +487,52 @@ class VDigitWindow(BufferedWindow):
         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):

+ 1 - 1
gui/wxpython/gui_modules/mapdisp_window.py

@@ -1026,7 +1026,7 @@ class BufferedWindow(MapWindow, wx.Window):
             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]]

+ 13 - 10
gui/wxpython/gui_modules/toolbars.py

@@ -506,9 +506,9 @@ class VDigitToolbar(AbstractToolbar):
         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 @@ class VDigitToolbar(AbstractToolbar):
         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 @@ class VDigitToolbar(AbstractToolbar):
     
     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 @@ class VDigitToolbar(AbstractToolbar):
         
         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 @@ class VDigitToolbar(AbstractToolbar):
             
             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: