[GRASS-SVN] r31516 - in grass/branches/develbranch_6/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 24 17:00:31 EDT 2008


Author: martinl
Date: 2008-05-24 17:00:30 -0400 (Sat, 24 May 2008)
New Revision: 31516

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: check for input/map parameter type when calling module for menu, trac #177)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2008-05-24 20:02:10 UTC (rev 31515)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2008-05-24 21:00:30 UTC (rev 31516)
@@ -1348,6 +1348,7 @@
     """
     def __init__(self, parent=-1):
         self.parent = parent
+        self.grass_task = None
 
     def ParseCommand(self, cmd, gmpath=None, completed=None, parentframe=-1, show=True, modal=False):
         """
@@ -1435,6 +1436,31 @@
         # print >> sys.stderr, time.time() - start
         return cmd
 
+    def GetCommandInputMapParamKey(self, cmd):
+        """Get parameter key for input raster/vector map
+        
+        @param cmd module name
+        
+        @return parameter key
+        @return None on failure
+        """
+        # parse the interface decription
+        if not self.grass_task:
+            self.grass_task = grassTask()
+            handler = processTask(self.grass_task)
+            xml.sax.parseString(getInterfaceDescription(cmd), handler)
+
+            for p in self.grass_task.params:
+                if p.get('name', '') in ('input', 'map'):
+                    age = p.get('age', '')
+                    prompt = p.get('prompt', '')
+                    element = p.get('element', '') 
+                    if age == 'old' and \
+                            element in ('cell', 'grid3', 'vector') and \
+                            prompt in ('raster', '3d-raster', 'vector'):
+                        return p.get('name', None)
+        return None
+
 class StaticWrapText(wx.StaticText):
     """
     A Static Text field that wraps its text to fit its width, enlarging its height if necessary.

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2008-05-24 20:02:10 UTC (rev 31515)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2008-05-24 21:00:30 UTC (rev 31516)
@@ -432,10 +432,11 @@
         except:
             layer = None
         if layer and len(cmdlist) == 1: # only if no paramaters given
-            if type == 'raster' and cmdlist[0][0] == 'r' and cmdlist[0][1] != '3':
-                cmdlist.append(name) # TODO map/input=
-            elif type == 'vector' and cmdlist[0][0] == 'v':
-                cmdlist.append(name) # TODO map/input=
+            if (type == 'raster' and cmdlist[0][0] == 'r' and cmdlist[0][1] != '3') or \
+                    (type == 'vector' and cmdlist[0][0] == 'v'):
+                input = menuform.GUI().GetCommandInputMapParamKey(cmdlist[0])
+                if input:
+                    cmdlist.append("%s=%s" % (input, name))
 
         return cmdlist
 



More information about the grass-commit mailing list