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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Feb 19 07:39:58 EST 2009


Author: martinl
Date: 2009-02-19 07:39:58 -0500 (Thu, 19 Feb 2009)
New Revision: 35949

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
Log:
wxGUI: fix vector query	
       (merge from trunk, r35948)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2009-02-19 12:36:08 UTC (rev 35948)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/dbm.py	2009-02-19 12:39:58 UTC (rev 35949)
@@ -1610,7 +1610,7 @@
         self.listOfCommands.append(('v.db.addcol',
                                     { 'map' : self.vectorName,
                                       'layer' : self.layer,
-                                      'columns' : (name, type) }
+                                      'columns' : '%s %s' % (name, type) }
                                     ))
         # apply changes
         self.ApplyCommands()

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2009-02-19 12:36:08 UTC (rev 35948)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2009-02-19 12:39:58 UTC (rev 35949)
@@ -1187,10 +1187,11 @@
         posWindow = self.ClientToScreen((x + self.MapWindow.dialogOffset,
                                          y + self.MapWindow.dialogOffset))
 
-        qdist = 10.0 * ((self.Map.region['e'] - self.Map.region['w']) / \
-                            self.Map.width)
+        qdist = 10.0 * ((self.Map.region['e'] - self.Map.region['w']) /
+                        self.Map.width)
+        
         east, north = self.MapWindow.Pixel2Cell((x, y))
-
+        
         mapName = self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].name
         
         if self.dialogs['attributes'] is None:
@@ -1202,12 +1203,13 @@
         else:
             # selection changed?
             if not self.dialogs['attributes'].mapDBInfo or \
-                   self.dialogs['attributes'].mapDBInfo.map != mapName:
+                    self.dialogs['attributes'].mapDBInfo.map != mapName:
                 self.dialogs['attributes'].UpdateDialog(map=mapName, query=((east, north), qdist))
             else:
                 self.dialogs['attributes'].UpdateDialog(query=((east, north), qdist))
-
+                
         cats = self.dialogs['attributes'].GetCats()
+        
         try:
             qlayer = self.Map.GetListOfLayers(l_name=globalvar.QUERYLAYER)[0]
         except IndexError:
@@ -1221,7 +1223,7 @@
                                                         addLayer=False))
             else:
                 qlayer = self.AddTmpVectorMapLayer(mapName, cats, useId=False)
-
+            
             # set opacity based on queried layer
             opacity = self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].GetOpacity(float=True)
             qlayer.SetOpacity(opacity)
@@ -1235,7 +1237,7 @@
                 self.MapWindow.UpdateMap(render=False, renderVector=False)
             if self.dialogs['attributes'].IsShown():
                 self.dialogs['attributes'].Hide()
-
+        
     def OnQuery(self, event):
         """Query tools menu"""
         if self.toolbars['map']:

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2009-02-19 12:36:08 UTC (rev 35948)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2009-02-19 12:39:58 UTC (rev 35949)
@@ -64,6 +64,8 @@
     def __init__(self, type, cmd, name=None,
                  active=True, hidden=False, opacity=1.0):
         """
+        @todo pass cmd as tuple instead of list
+        
         @param type layer type ('raster', 'vector', 'overlay', 'command', etc.)
         @param cmd GRASS command to render layer,
         given as list, e.g. ['d.rast', 'map=elevation at PERMANENT']
@@ -74,8 +76,14 @@
         """
         self.type = type
         self.name = name
-        self.cmd  = utils.CmdToTuple(cmd)
 
+        if self.type == 'command':
+            self.cmd = []
+            for c in cmd:
+                self.cmd.append(utils.CmdToTuple(c))
+        else:
+            self.cmd  = utils.CmdToTuple(cmd)
+        
         self.active  = active
         self.hidden  = hidden
         self.opacity = opacity
@@ -156,11 +164,11 @@
         try:
             if self.type == 'command':
                 read = False
-                for cmd in self.cmd:
-                    ret = gcmd.RunCommand(self.cmd[0],
+                for c in self.cmd:
+                    ret = gcmd.RunCommand(c[0],
                                           quiet = True,
-                                          **self.cmd[1])
-                    if ret.returncode != 0:
+                                          **c[1])
+                    if ret != 0:
                         break
                     if not read:
                         os.environ["GRASS_PNG_READ"] = "TRUE"
@@ -219,8 +227,9 @@
         if string:
             if self.type == 'command':
                 scmd = []
-                for cmd in self.cmd:
-                    scmd.append(utils.GetCmdString(self.cmd))
+                for c in self.cmd:
+                    scmd.append(utils.GetCmdString(c))
+                
                 return ';'.join(scmd)
             else:
                 return utils.GetCmdString(self.cmd)
@@ -298,7 +307,12 @@
         
     def SetCmd(self, cmd):
         """Set new command for layer"""
-        self.cmd = utils.CmdToTuple(cmd)
+        if self.type == 'command':
+            self.cmd = []
+            for c in cmd:
+                self.cmd.append(utils.CmdToTuple(c))
+        else:
+            self.cmd  = utils.CmdToTuple(cmd)
         Debug.msg(3, "Layer.SetCmd(): cmd='%s'" % self.GetCmd(string=True))
         
         # for re-rendering



More information about the grass-commit mailing list