[GRASS-SVN] r48042 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 1 12:17:36 EDT 2011


Author: martinl
Date: 2011-09-01 09:17:36 -0700 (Thu, 01 Sep 2011)
New Revision: 48042

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


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_vdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_vdigit.py	2011-09-01 16:16:39 UTC (rev 48041)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_vdigit.py	2011-09-01 16:17:36 UTC (rev 48042)
@@ -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/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py	2011-09-01 16:16:39 UTC (rev 48041)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py	2011-09-01 16:17:36 UTC (rev 48042)
@@ -999,7 +999,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/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2011-09-01 16:16:39 UTC (rev 48041)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2011-09-01 16:17:36 UTC (rev 48042)
@@ -482,9 +482,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)
@@ -510,7 +510,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),
@@ -561,8 +562,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"]
@@ -573,8 +574,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)
@@ -583,10 +585,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