Browse Source

wxGUI: some minor vdigit fixes

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

+ 12 - 14
gui/wxpython/gui_modules/mapdisp_vdigit.py

@@ -116,7 +116,8 @@ class VDigitWindow(BufferedWindow):
             self.digit.GetDisplay().DrawMap()
             self.digit.GetDisplay().DrawMap()
         
         
         # translate tmp objects (pointer position)
         # translate tmp objects (pointer position)
-        if self.toolbar.GetAction() == 'moveLine':
+        if self.toolbar.GetAction() == 'moveLine' and \
+                hasattr(self, "moveInfo"):
             if self.moveInfo.has_key('beginDiff'):
             if self.moveInfo.has_key('beginDiff'):
                 # move line
                 # move line
                 for id in self.moveInfo['id']:
                 for id in self.moveInfo['id']:
@@ -284,11 +285,11 @@ class VDigitWindow(BufferedWindow):
         """!Left mouse button pressed - vector digitizer move
         """!Left mouse button pressed - vector digitizer move
         feature/vertex, edit linear feature
         feature/vertex, edit linear feature
         """
         """
-        self.moveInfo = {}
+        self.moveInfo = dict()
         # geographic coordinates of initial position (left-down)
         # geographic coordinates of initial position (left-down)
         self.moveInfo['begin'] = None
         self.moveInfo['begin'] = None
         # list of ids to modify    
         # list of ids to modify    
-        self.moveInfo['id'] = []
+        self.moveInfo['id'] = list()
         
         
         if self.toolbar.GetAction() in ["moveVertex", "editLine"]:
         if self.toolbar.GetAction() in ["moveVertex", "editLine"]:
             # set pen
             # set pen
@@ -416,7 +417,6 @@ class VDigitWindow(BufferedWindow):
         if self.mouse["use"] != "pointer" or not self.toolbar:
         if self.mouse["use"] != "pointer" or not self.toolbar:
             return
             return
         
         
-        digitClass = self.parent.digit
         if (self.toolbar.GetAction() == "addLine" and \
         if (self.toolbar.GetAction() == "addLine" and \
                 self.toolbar.GetAction('type') in ["line", "boundary", "area"]) or \
                 self.toolbar.GetAction('type') in ["line", "boundary", "area"]) or \
                 self.toolbar.GetAction() == "editLine":
                 self.toolbar.GetAction() == "editLine":
@@ -507,11 +507,9 @@ class VDigitWindow(BufferedWindow):
                 hasattr(self, "moveInfo"):
                 hasattr(self, "moveInfo"):
             self.OnLeftDownEditLine(event)
             self.OnLeftDownEditLine(event)
 
 
-        elif self.toolbar.GetAction() in ("moveLine", 
-                                          "moveVertex",
-                                          "editLine") and \
-                                          not hasattr(self, "moveInfo"):
-                                          self.OnLeftDownVDigitMoveLine(event)
+        elif self.toolbar.GetAction() in ("moveLine", "moveVertex", "editLine") and \
+                not hasattr(self, "moveInfo"):
+            self.OnLeftDownMoveLine(event)
         
         
         elif self.toolbar.GetAction() in ("displayAttrs"
         elif self.toolbar.GetAction() in ("displayAttrs"
                                           "displayCats"):
                                           "displayCats"):
@@ -589,7 +587,7 @@ class VDigitWindow(BufferedWindow):
                     self.copyCatsIds = self.digit.GetDisplay().GetSelected()
                     self.copyCatsIds = self.digit.GetDisplay().GetSelected()
         
         
         elif self.toolbar.GetAction() == "queryLine":
         elif self.toolbar.GetAction() == "queryLine":
-            selected = digitClass.SelectLinesByQuery(bbox = (pos1, pos2))
+            selected = self.digit.SelectLinesByQuery(bbox = (pos1, pos2))
             nselected = len(selected)
             nselected = len(selected)
             if nselected > 0:
             if nselected > 0:
                 self.digit.GetDisplay().SetSelected(selected)
                 self.digit.GetDisplay().SetSelected(selected)
@@ -612,8 +610,8 @@ class VDigitWindow(BufferedWindow):
                         nselected = 1
                         nselected = 1
         
         
         if nselected > 0:
         if nselected > 0:
-            if self.toolbar.GetAction() in ("moveLine",
-                                            "moveVertex"):
+            if self.toolbar.GetAction() in ("moveLine", "moveVertex") and \
+                    hasattr(self, "moveInfo"):
                 # get pseudoDC id of objects which should be redrawn
                 # get pseudoDC id of objects which should be redrawn
                 if self.toolbar.GetAction() == "moveLine":
                 if self.toolbar.GetAction() == "moveLine":
                     # -> move line
                     # -> move line
@@ -758,8 +756,8 @@ class VDigitWindow(BufferedWindow):
             self.UpdateMap(render = False)
             self.UpdateMap(render = False)
         
         
     def OnLeftUp(self, event):
     def OnLeftUp(self, event):
-        if hasattr(self, "infoMove"):
-            if len(digitClass.GetDisplay().GetSelected()) == 0:
+        if hasattr(self, "moveInfo"):
+            if len(self.digit.GetDisplay().GetSelected()) == 0:
                 self.moveInfo['begin'] = self.Pixel2Cell(self.mouse['begin']) # left down
                 self.moveInfo['begin'] = self.Pixel2Cell(self.mouse['begin']) # left down
             
             
             # eliminate initial mouse moving efect
             # eliminate initial mouse moving efect

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

@@ -12,9 +12,9 @@ This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 for details.
 
 
+@author Martin Landa <landa.martin gmail.com>
 @author Michael Barton
 @author Michael Barton
 @author Jachym Cepicky
 @author Jachym Cepicky
-@author Martin Landa <landa.martin gmail.com>
 """
 """
 
 
 import os
 import os
@@ -474,7 +474,7 @@ class BufferedWindow(MapWindow, wx.Window):
                 # draw to the dc
                 # draw to the dc
                 self.pdc.DrawToDC(dc)
                 self.pdc.DrawToDC(dc)
                 
                 
-                if isinstace(self, VDigitWindow):
+                if hasattr(self, "digit"):
                     # decorate with GDDC (transparency)
                     # decorate with GDDC (transparency)
                     try:
                     try:
                         gcdc = wx.GCDC(dc)
                         gcdc = wx.GCDC(dc)

+ 6 - 5
gui/wxpython/gui_modules/menuform.py

@@ -33,7 +33,7 @@ pythonw on a Mac.
 @todo
 @todo
  - verify option value types
  - verify option value types
 
 
-Copyright(C) 2000-2010 by the GRASS Development Team
+Copyright(C) 2000-2011 by the GRASS Development Team
 This program is free software under the GPL(>=v2) Read the file
 This program is free software under the GPL(>=v2) Read the file
 COPYING coming with GRASS for details.
 COPYING coming with GRASS for details.
 
 
@@ -370,10 +370,11 @@ class UpdateQThread(Thread):
             self.request = callable(*args, **kwds)
             self.request = callable(*args, **kwds)
 
 
             self.resultQ.put((requestId, self.request.run()))
             self.resultQ.put((requestId, self.request.run()))
-                        
-            event = wxUpdateDialog(data = self.request.data)
-            wx.PostEvent(self.parent, event)
-
+           
+            if self.request:
+                event = wxUpdateDialog(data = self.request.data)
+                wx.PostEvent(self.parent, event)
+        
 class grassTask:
 class grassTask:
     """!This class holds the structures needed for both filling by the
     """!This class holds the structures needed for both filling by the
     parser and use by the interface constructor.
     parser and use by the interface constructor.