[GRASS-SVN] r35948 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Feb 19 07:36:08 EST 2009
Author: martinl
Date: 2009-02-19 07:36:08 -0500 (Thu, 19 Feb 2009)
New Revision: 35948
Modified:
grass/trunk/gui/wxpython/gui_modules/dbm.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/render.py
Log:
wxGUI: fix vector query
Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py 2009-02-19 11:47:15 UTC (rev 35947)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py 2009-02-19 12:36:08 UTC (rev 35948)
@@ -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/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2009-02-19 11:47:15 UTC (rev 35947)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2009-02-19 12:36:08 UTC (rev 35948)
@@ -1182,10 +1182,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:
@@ -1197,12 +1198,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:
@@ -1216,7 +1218,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)
@@ -1230,7 +1232,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/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2009-02-19 11:47:15 UTC (rev 35947)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2009-02-19 12:36:08 UTC (rev 35948)
@@ -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
@@ -140,11 +148,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"
@@ -199,8 +207,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)
@@ -278,7 +287,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