[GRASS-SVN] r32673 - in grass/branches/develbranch_6:
display/d.vect gui/wxpython/gui_modules include lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 11 04:47:24 EDT 2008
Author: martinl
Date: 2008-08-11 04:47:24 -0400 (Mon, 11 Aug 2008)
New Revision: 32673
Modified:
grass/branches/develbranch_6/display/d.vect/main.c
grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
grass/branches/develbranch_6/include/gis.h
grass/branches/develbranch_6/lib/gis/parser.c
Log:
gislib: new GISPROMPT_DBCOLUMN, used in wxGUI menuform module
standardize column parameter in d.vect
Modified: grass/branches/develbranch_6/display/d.vect/main.c
===================================================================
--- grass/branches/develbranch_6/display/d.vect/main.c 2008-08-11 00:06:32 UTC (rev 32672)
+++ grass/branches/develbranch_6/display/d.vect/main.c 2008-08-11 08:47:24 UTC (rev 32673)
@@ -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/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2008-08-11 00:06:32 UTC (rev 32672)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2008-08-11 08:47:24 UTC (rev 32673)
@@ -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/branches/develbranch_6/include/gis.h
===================================================================
--- grass/branches/develbranch_6/include/gis.h 2008-08-11 00:06:32 UTC (rev 32672)
+++ grass/branches/develbranch_6/include/gis.h 2008-08-11 08:47:24 UTC (rev 32673)
@@ -99,6 +99,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/branches/develbranch_6/lib/gis/parser.c
===================================================================
--- grass/branches/develbranch_6/lib/gis/parser.c 2008-08-11 00:06:32 UTC (rev 32672)
+++ grass/branches/develbranch_6/lib/gis/parser.c 2008-08-11 08:47:24 UTC (rev 32673)
@@ -325,8 +325,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:
@@ -360,6 +359,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";
@@ -368,6 +368,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