[GRASS-SVN] r32674 - in grass/trunk: display/d.vect
gui/wxpython/gui_modules include lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 11 05:18:29 EDT 2008
Author: martinl
Date: 2008-08-11 05:18:29 -0400 (Mon, 11 Aug 2008)
New Revision: 32674
Modified:
grass/trunk/display/d.vect/main.c
grass/trunk/gui/wxpython/gui_modules/menuform.py
grass/trunk/include/gis.h
grass/trunk/lib/gis/parser.c
Log:
gislib: new GISPROMPT_DBCOLUMN, used in wxGUI menuform module
standardize column parameter in d.vect
(merge from devbr6, r32673)
Modified: grass/trunk/display/d.vect/main.c
===================================================================
--- grass/trunk/display/d.vect/main.c 2008-08-11 08:47:24 UTC (rev 32673)
+++ grass/trunk/display/d.vect/main.c 2008-08-11 09:18:29 UTC (rev 32674)
@@ -171,14 +171,10 @@
fcolor_opt->guisection = _("Colors");
fcolor_opt->gisprompt = GISPROMPT_COLOR;
- rgbcol_opt = G_define_option();
+ rgbcol_opt = G_define_standard_option(G_OPT_COLUMN);
rgbcol_opt->key = "rgb_column";
- rgbcol_opt->type = TYPE_STRING;
- rgbcol_opt->required = NO;
- rgbcol_opt->multiple = NO;
rgbcol_opt->guisection = _("Colors");
- rgbcol_opt->description =
- _("Name of color definition column (for use with -a flag)");
+ rgbcol_opt->description = _("Name of color definition column (for use with -a flag)");
rgbcol_opt->answer = "GRASSRGB";
zcol_opt = G_define_option();
Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py 2008-08-11 08:47:24 UTC (rev 32673)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py 2008-08-11 09:18:29 UTC (rev 32674)
@@ -1125,7 +1125,8 @@
which_sizer.Add(item=txt, proportion=0,
flag=wx.ADJUST_MINSIZE | wx.RIGHT | wx.LEFT | wx.TOP, border=5)
# element selection tree combobox (maps, icons, regions, etc.)
- if p.get('prompt','') != 'color' and p.get('element', '') != 'file':
+ if p.get('prompt','') not in ('color', 'dbcolumn') and \
+ p.get('element', '') != 'file':
if p.get('multiple','no') == 'yes':
multiple = True
else:
@@ -1146,6 +1147,18 @@
# we target the textctl here
p['wxId'] = selection.GetChildren()[0].GetId()
selection.Bind(wx.EVT_TEXT, self.OnSetValue)
+ # dbcolumn entry
+ elif p.get('prompt','') == 'dbcolumn':
+ columns = wx.ComboBox(parent=which_panel, id=wx.ID_ANY,
+ size=globalvar.DIALOG_COMBOBOX_SIZE,
+ style=wx.CB_SIMPLE | wx.CB_READONLY,
+ choices=[])
+ p['wxId'] = columns.GetId()
+ p['wxGetValue'] = columns.GetStringSelection
+ columns.Bind(wx.EVT_ENTER_WINDOW, self.OnDbColumn)
+ columns.Bind(wx.EVT_COMBOBOX, self.OnSetValue)
+ this_sizer.Add(item=columns, proportion=0,
+ flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT, border=5)
# color entry
elif p.get('prompt','') == 'color':
# Heuristic way of finding whether transparent is allowed
@@ -1349,10 +1362,50 @@
me = wx.FindWindowById( myId )
for porf in self.task.params + self.task.flags:
if 'wxId' in porf and type( porf[ 'wxId' ] ) == type( 1 ) and porf['wxId'] == myId:
- porf[ 'value' ] = me.GetValue()
-
+ if porf.has_key('wxGetValue') and porf['wxGetValue']:
+ porf['value'] = porf['wxGetValue']()
+ else:
+ porf['value'] = me.GetValue()
+
self.OnUpdateValues()
+ event.Skip()
+
+ def OnDbColumn(self, event):
+ """Get list of table columns"""
+ choices = []
+
+ mapName = utils.GetLayerNameFromCmd(self.task.getCmd(ignoreErrors=True))
+ if mapName != _('<required>'):
+ layer = 1
+ for p in self.task.params:
+ if p.get('name', '') == 'layer':
+ value = p.get('value', '1')
+ if value:
+ layer = int(value)
+ break
+
+ cmd = ['v.info',
+ 'map=%s' % mapName,
+ 'layer=%d' % layer,
+ '-c', '--q']
+
+ try:
+ for line in gcmd.Command(cmd).ReadStdOutput():
+ type, name = line.split('|')
+ choices.append(name.strip())
+ except gcmd.CmdError:
+ pass
+
+ win = self.FindWindowById(event.GetId())
+
+ win.SetItems(choices)
+
+ if len(choices) < 1:
+ win.SetValue('')
+
+ event.Skip()
+
def createCmd( self, ignoreErrors = False ):
"""
Produce a command line string (list) or feeding into GRASS.
Modified: grass/trunk/include/gis.h
===================================================================
--- grass/trunk/include/gis.h 2008-08-11 08:47:24 UTC (rev 32673)
+++ grass/trunk/include/gis.h 2008-08-11 09:18:29 UTC (rev 32674)
@@ -104,6 +104,7 @@
#define YES 1
#define NO 0
#define GISPROMPT_COLOR "color,grass,color"
+#define GISPROMPT_DBCOLUMN "dbcolumn,grass,dbcolumn"
/* File/directory name lengths */
#define GNAME_MAX 256
Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c 2008-08-11 08:47:24 UTC (rev 32673)
+++ grass/trunk/lib/gis/parser.c 2008-08-11 09:18:29 UTC (rev 32674)
@@ -321,8 +321,7 @@
Opt->type = TYPE_STRING;
Opt->key_desc = "sql_query";
Opt->required = NO;
- Opt->label =
- _("WHERE conditions of SQL statement without 'where' keyword");
+ Opt->label = _("WHERE conditions of SQL statement without 'where' keyword");
Opt->description = _("Example: income < 1000 and inhab >= 10000");
break;
case G_OPT_TABLE:
@@ -356,6 +355,7 @@
Opt->required = NO;
Opt->multiple = NO;
Opt->description = _("Name of attribute column");
+ Opt->gisprompt = GISPROMPT_DBCOLUMN;
break;
case G_OPT_COLUMNS:
Opt->key = "columns";
@@ -364,6 +364,7 @@
Opt->required = NO;
Opt->multiple = YES;
Opt->description = _("Name of attribute column(s)");
+ Opt->gisprompt = GISPROMPT_DBCOLUMN;
break;
/* imagery group */
More information about the grass-commit
mailing list