瀏覽代碼

wxGUI: v.build.all added to the menu
fix running commands when module has no required parameter


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@43830 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 年之前
父節點
當前提交
b58f525aaf

+ 2 - 2
gui/wxpython/gui_modules/gdialogs.py

@@ -160,9 +160,9 @@ class MapsetDialog(ElementDialog):
                  location = None, id =  wx.ID_ANY):
                  location = None, id =  wx.ID_ANY):
         ElementDialog.__init__(self, parent, title, label = _("Name of mapset:"))
         ElementDialog.__init__(self, parent, title, label = _("Name of mapset:"))
         if location:
         if location:
-            self.SetTitle(self.GetTitle() + '<%s>' % location)
+            self.SetTitle(self.GetTitle() + ' <%s>' % location)
         else:
         else:
-            self.SetTitle(self.GetTitle() + '<%s>' % grass.gisenv()['LOCATION_NAME'])
+            self.SetTitle(self.GetTitle() + ' <%s>' % grass.gisenv()['LOCATION_NAME'])
         
         
         self.element = gselect.MapsetSelect(parent = self.panel, id = wx.ID_ANY,
         self.element = gselect.MapsetSelect(parent = self.panel, id = wx.ID_ANY,
                                             size = globalvar.DIALOG_GSELECT_SIZE)
                                             size = globalvar.DIALOG_GSELECT_SIZE)

+ 11 - 4
gui/wxpython/gui_modules/goutput.py

@@ -443,7 +443,7 @@ class GMConsole(wx.SplitterWindow):
         except IOError, e:
         except IOError, e:
             self.WriteError(str(e))
             self.WriteError(str(e))
             fileHistory = None
             fileHistory = None
-
+        
         cmdString = ' '.join(cmdlist)
         cmdString = ' '.join(cmdlist)
         if fileHistory:
         if fileHistory:
             try:
             try:
@@ -521,11 +521,18 @@ class GMConsole(wx.SplitterWindow):
                     tmpreg = os.getenv("GRASS_REGION")
                     tmpreg = os.getenv("GRASS_REGION")
                     if os.environ.has_key("GRASS_REGION"):
                     if os.environ.has_key("GRASS_REGION"):
                         del os.environ["GRASS_REGION"]
                         del os.environ["GRASS_REGION"]
-                
-                if len(cmdlist) == 1 and cmdlist[0] not in ('v.krige'):
+
+                if len(cmdlist) == 1:
                     import menuform
                     import menuform
+                    task = menuform.GUI().ParseInterface(cmdlist)
+                    if not task.has_required():
+                        task = None # run command
+                else:
+                    task = None
+                
+                if task and cmdlist[0] not in ('v.krige'):
                     # process GRASS command without argument
                     # process GRASS command without argument
-                    menuform.GUI().ParseCommand(cmdlist, parentframe=self)
+                    menuform.GUI().ParseCommand(cmdlist, parentframe = self)
                 else:
                 else:
                     # process GRASS command with argument
                     # process GRASS command with argument
                     self.cmdThread.RunCmd(GrassCmd,
                     self.cmdThread.RunCmd(GrassCmd,

+ 14 - 0
gui/wxpython/gui_modules/layertree.py

@@ -255,6 +255,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
             self.popupID13 = wx.NewId()
             self.popupID13 = wx.NewId()
             self.popupID14 = wx.NewId()
             self.popupID14 = wx.NewId()
             self.popupID15 = wx.NewId()
             self.popupID15 = wx.NewId()
+            self.popupID16 = wx.NewId()
 
 
         self.popupMenu = wx.Menu()
         self.popupMenu = wx.Menu()
 
 
@@ -324,10 +325,14 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                                     internal=True) == layer.GetName():
                                     internal=True) == layer.GetName():
                     self.popupMenu.Check(self.popupID14, True)
                     self.popupMenu.Check(self.popupID14, True)
             
             
+            self.popupMenu.Append(self.popupID16, text=_("Rebuild topology"))
+            self.Bind(wx.EVT_MENU, self.OnTopology, id=self.popupID16)
+
             if layer.GetMapset() != grass.gisenv()['MAPSET']:
             if layer.GetMapset() != grass.gisenv()['MAPSET']:
                 # only vector map in current mapset can be edited
                 # only vector map in current mapset can be edited
                 self.popupMenu.Enable (self.popupID5, False)
                 self.popupMenu.Enable (self.popupID5, False)
                 self.popupMenu.Enable (self.popupID6, False)
                 self.popupMenu.Enable (self.popupID6, False)
+                self.popupMenu.Enable (self.popupID16, False)
             elif digitToolbar and digitToolbar.GetLayer():
             elif digitToolbar and digitToolbar.GetLayer():
                 # vector map already edited
                 # vector map already edited
                 vdigitLayer = digitToolbar.GetLayer()
                 vdigitLayer = digitToolbar.GetLayer()
@@ -340,6 +345,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                     self.popupMenu.Enable(self.popupID1, False)
                     self.popupMenu.Enable(self.popupID1, False)
                     # disable 'bgmap'
                     # disable 'bgmap'
                     self.popupMenu.Enable(self.popupID14, False)
                     self.popupMenu.Enable(self.popupID14, False)
+                    # disable 'topology'
+                    self.popupMenu.Enable (self.popupID16, False)
                 else:
                 else:
                     # disable 'start editing'
                     # disable 'start editing'
                     self.popupMenu.Enable(self.popupID5, False)
                     self.popupMenu.Enable(self.popupID5, False)
@@ -388,6 +395,13 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         self.PopupMenu(self.popupMenu)
         self.PopupMenu(self.popupMenu)
         self.popupMenu.Destroy()
         self.popupMenu.Destroy()
 
 
+    def OnTopology(self, event):
+        """!Rebuild topology of selected vector map"""
+        mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
+        cmd = ['v.build',
+               'map=%s' % mapLayer.GetName()]
+        self.lmgr.goutput.RunCmd(cmd, switchPage = True)
+        
     def OnMetadata(self, event):
     def OnMetadata(self, event):
         """!Print metadata of raster/vector map layer
         """!Print metadata of raster/vector map layer
         TODO: Dialog to modify metadata
         TODO: Dialog to modify metadata

+ 15 - 9
gui/wxpython/gui_modules/menuform.py

@@ -356,7 +356,7 @@ class grassTask:
     parser and use by the interface constructor.
     parser and use by the interface constructor.
 
 
     Use as either grassTask() for empty definition or
     Use as either grassTask() for empty definition or
-    grassTask('grass.command' ) for parsed filling.
+    grassTask('grass.command') for parsed filling.
     """
     """
     def __init__(self, grassModule = None):
     def __init__(self, grassModule = None):
         self.path = grassModule
         self.path = grassModule
@@ -513,6 +513,14 @@ class grassTask:
         return { 'flags'  : self.flags,
         return { 'flags'  : self.flags,
                  'params' : self.params }
                  'params' : self.params }
     
     
+    def has_required(self):
+        """!Check if command has at least one required paramater"""
+        for p in self.params:
+            if p.get('required', False) == True:
+                return True
+        
+        return False
+
 class processTask:
 class processTask:
     """!A ElementTree handler for the --interface-description output,
     """!A ElementTree handler for the --interface-description output,
     as defined in grass-interface.dtd. Extend or modify this and the
     as defined in grass-interface.dtd. Extend or modify this and the
@@ -882,7 +890,7 @@ class mainFrame(wx.Frame):
 
 
         @param returncode command's return code (0 for success)
         @param returncode command's return code (0 for success)
         """
         """
-        if self.parent.GetName() != 'LayerTree' or \
+        if self.parent and self.parent.GetName() != 'LayerTree' or \
                 returncode != 0:
                 returncode != 0:
             return
             return
         
         
@@ -918,24 +926,23 @@ class mainFrame(wx.Frame):
         """!Run the command"""
         """!Run the command"""
         cmd = self.createCmd()
         cmd = self.createCmd()
         
         
-        if cmd == None or len(cmd) < 2:
+        if not cmd or len(cmd) < 1:
             return
             return
-
+        
         if self.standalone or cmd[0][0:2] != "d.":
         if self.standalone or cmd[0][0:2] != "d.":
             # Send any non-display command to parent window (probably wxgui.py)
             # Send any non-display command to parent window (probably wxgui.py)
-            # put to parents
-            # switch to 'Command output'
+            # put to parents switch to 'Command output'
             if self.notebookpanel.notebook.GetSelection() != self.notebookpanel.goutputId:
             if self.notebookpanel.notebook.GetSelection() != self.notebookpanel.goutputId:
                 self.notebookpanel.notebook.SetSelection(self.notebookpanel.goutputId)
                 self.notebookpanel.notebook.SetSelection(self.notebookpanel.goutputId)
             
             
             try:
             try:
                 if self.task.path:
                 if self.task.path:
                     cmd[0] = self.task.path # full path
                     cmd[0] = self.task.path # full path
+                
                 self.goutput.RunCmd(cmd, onDone = self.OnDone)
                 self.goutput.RunCmd(cmd, onDone = self.OnDone)
             except AttributeError, e:
             except AttributeError, e:
                 print >> sys.stderr, "%s: Propably not running in wxgui.py session?" % (e)
                 print >> sys.stderr, "%s: Propably not running in wxgui.py session?" % (e)
                 print >> sys.stderr, "parent window is: %s" % (str(self.parent))
                 print >> sys.stderr, "parent window is: %s" % (str(self.parent))
-            # Send any other command to the shell.
         else:
         else:
             gcmd.Command(cmd)
             gcmd.Command(cmd)
         
         
@@ -945,8 +952,7 @@ class mainFrame(wx.Frame):
                     self.btn_clipboard,
                     self.btn_clipboard,
                     self.btn_help):
                     self.btn_help):
             btn.Enable(False)
             btn.Enable(False)
-        ### self.btn_abort.Enable(True)
-
+        
     def OnAbort(self, event):
     def OnAbort(self, event):
         """!Abort running command"""
         """!Abort running command"""
         event = goutput.wxCmdAbort(aborted=True)
         event = goutput.wxCmdAbort(aborted=True)

+ 7 - 0
gui/wxpython/xml/menudata.xml

@@ -1855,6 +1855,13 @@
 	      <command>v.build</command>
 	      <command>v.build</command>
 	    </menuitem>
 	    </menuitem>
 	    <menuitem>
 	    <menuitem>
+	      <label>Rebuild topology on all vector maps</label>
+	      <help>Rebuilds topology on all vector maps in the current mapset..</help>
+	      <keywords>vector,topology</keywords>
+	      <handler>OnMenuCmd</handler>
+	      <command>v.build.all</command>
+	    </menuitem>
+	    <menuitem>
 	      <label>Clean vector map</label>
 	      <label>Clean vector map</label>
 	      <help>Toolset for cleaning topology of vector map.</help>
 	      <help>Toolset for cleaning topology of vector map.</help>
 	      <keywords>vector,topology</keywords>
 	      <keywords>vector,topology</keywords>