[GRASS-SVN] r43830 - in grass/trunk/gui/wxpython: gui_modules xml

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Oct 9 14:24:44 EDT 2010


Author: martinl
Date: 2010-10-09 18:24:44 +0000 (Sat, 09 Oct 2010)
New Revision: 43830

Modified:
   grass/trunk/gui/wxpython/gui_modules/gdialogs.py
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/gui/wxpython/gui_modules/layertree.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/xml/menudata.xml
Log:
wxGUI: v.build.all added to the menu
       fix running commands when module has no required parameter


Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2010-10-09 18:20:48 UTC (rev 43829)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2010-10-09 18:24:44 UTC (rev 43830)
@@ -160,9 +160,9 @@
                  location = None, id =  wx.ID_ANY):
         ElementDialog.__init__(self, parent, title, label = _("Name of mapset:"))
         if location:
-            self.SetTitle(self.GetTitle() + '<%s>' % location)
+            self.SetTitle(self.GetTitle() + ' <%s>' % location)
         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,
                                             size = globalvar.DIALOG_GSELECT_SIZE)

Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2010-10-09 18:20:48 UTC (rev 43829)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2010-10-09 18:24:44 UTC (rev 43830)
@@ -443,7 +443,7 @@
         except IOError, e:
             self.WriteError(str(e))
             fileHistory = None
-
+        
         cmdString = ' '.join(cmdlist)
         if fileHistory:
             try:
@@ -521,11 +521,18 @@
                     tmpreg = os.getenv("GRASS_REGION")
                     if os.environ.has_key("GRASS_REGION"):
                         del os.environ["GRASS_REGION"]
+
+                if len(cmdlist) == 1:
+                    import menuform
+                    task = menuform.GUI().ParseInterface(cmdlist)
+                    if not task.has_required():
+                        task = None # run command
+                else:
+                    task = None
                 
-                if len(cmdlist) == 1 and cmdlist[0] not in ('v.krige'):
-                    import menuform
+                if task and cmdlist[0] not in ('v.krige'):
                     # process GRASS command without argument
-                    menuform.GUI().ParseCommand(cmdlist, parentframe=self)
+                    menuform.GUI().ParseCommand(cmdlist, parentframe = self)
                 else:
                     # process GRASS command with argument
                     self.cmdThread.RunCmd(GrassCmd,

Modified: grass/trunk/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/layertree.py	2010-10-09 18:20:48 UTC (rev 43829)
+++ grass/trunk/gui/wxpython/gui_modules/layertree.py	2010-10-09 18:24:44 UTC (rev 43830)
@@ -255,6 +255,7 @@
             self.popupID13 = wx.NewId()
             self.popupID14 = wx.NewId()
             self.popupID15 = wx.NewId()
+            self.popupID16 = wx.NewId()
 
         self.popupMenu = wx.Menu()
 
@@ -324,10 +325,14 @@
                                     internal=True) == layer.GetName():
                     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']:
                 # only vector map in current mapset can be edited
                 self.popupMenu.Enable (self.popupID5, False)
                 self.popupMenu.Enable (self.popupID6, False)
+                self.popupMenu.Enable (self.popupID16, False)
             elif digitToolbar and digitToolbar.GetLayer():
                 # vector map already edited
                 vdigitLayer = digitToolbar.GetLayer()
@@ -340,6 +345,8 @@
                     self.popupMenu.Enable(self.popupID1, False)
                     # disable 'bgmap'
                     self.popupMenu.Enable(self.popupID14, False)
+                    # disable 'topology'
+                    self.popupMenu.Enable (self.popupID16, False)
                 else:
                     # disable 'start editing'
                     self.popupMenu.Enable(self.popupID5, False)
@@ -388,6 +395,13 @@
         self.PopupMenu(self.popupMenu)
         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):
         """!Print metadata of raster/vector map layer
         TODO: Dialog to modify metadata

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-10-09 18:20:48 UTC (rev 43829)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-10-09 18:24:44 UTC (rev 43830)
@@ -356,7 +356,7 @@
     parser and use by the interface constructor.
 
     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):
         self.path = grassModule
@@ -513,6 +513,14 @@
         return { 'flags'  : self.flags,
                  '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:
     """!A ElementTree handler for the --interface-description output,
     as defined in grass-interface.dtd. Extend or modify this and the
@@ -882,7 +890,7 @@
 
         @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:
             return
         
@@ -918,24 +926,23 @@
         """!Run the command"""
         cmd = self.createCmd()
         
-        if cmd == None or len(cmd) < 2:
+        if not cmd or len(cmd) < 1:
             return
-
+        
         if self.standalone or cmd[0][0:2] != "d.":
             # 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:
                 self.notebookpanel.notebook.SetSelection(self.notebookpanel.goutputId)
             
             try:
                 if self.task.path:
                     cmd[0] = self.task.path # full path
+                
                 self.goutput.RunCmd(cmd, onDone = self.OnDone)
             except AttributeError, e:
                 print >> sys.stderr, "%s: Propably not running in wxgui.py session?" % (e)
                 print >> sys.stderr, "parent window is: %s" % (str(self.parent))
-            # Send any other command to the shell.
         else:
             gcmd.Command(cmd)
         
@@ -945,8 +952,7 @@
                     self.btn_clipboard,
                     self.btn_help):
             btn.Enable(False)
-        ### self.btn_abort.Enable(True)
-
+        
     def OnAbort(self, event):
         """!Abort running command"""
         event = goutput.wxCmdAbort(aborted=True)

Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml	2010-10-09 18:20:48 UTC (rev 43829)
+++ grass/trunk/gui/wxpython/xml/menudata.xml	2010-10-09 18:24:44 UTC (rev 43830)
@@ -1855,6 +1855,13 @@
 	      <command>v.build</command>
 	    </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>
 	      <help>Toolset for cleaning topology of vector map.</help>
 	      <keywords>vector,topology</keywords>



More information about the grass-commit mailing list