Kaynağa Gözat

wxGUI: check for input/map parameter type when calling module for menu, trac https://trac.osgeo.org/grass/ticket/177) [merge devbr r31516]

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@31517 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 17 yıl önce
ebeveyn
işleme
9f76356811
2 değiştirilmiş dosya ile 31 ekleme ve 4 silme
  1. 26 0
      gui/wxpython/gui_modules/menuform.py
  2. 5 4
      gui/wxpython/wxgui.py

+ 26 - 0
gui/wxpython/gui_modules/menuform.py

@@ -1348,6 +1348,7 @@ class GUI:
     """
     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 @@ class GUI:
         # 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.

+ 5 - 4
gui/wxpython/wxgui.py

@@ -432,10 +432,11 @@ class GMFrame(wx.Frame):
         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