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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Apr 18 05:53:30 EDT 2010


Author: martinl
Date: 2010-04-18 05:53:30 -0400 (Sun, 18 Apr 2010)
New Revision: 41916

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI/modeler: running process
(merge r41915 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-04-18 09:45:23 UTC (rev 41915)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-04-18 09:53:30 UTC (rev 41916)
@@ -53,10 +53,10 @@
 import utils
 import goutput
 import gselect
-from debug import Debug
-from gcmd import GMessage, GError
-from gdialogs import ElementDialog, GetImageHandlers
-from preferences import PreferencesBaseDialog, globalSettings as UserSettings
+from debug        import Debug
+from gcmd         import GMessage, GError
+from gdialogs     import ElementDialog, GetImageHandlers
+from preferences  import PreferencesBaseDialog, globalSettings as UserSettings
 from grass.script import core as grass
 
 class Model(object):
@@ -285,8 +285,9 @@
         
         self.model = Model(self.canvas)
         
-        self.goutput = goutput.GMConsole(parent = self, pageid = 1)
-                
+        self.goutput = goutput.GMConsole(parent = self, pageid = 1,
+                                         notebook = self.notebook)
+        
         self.modelPage   = self.notebook.AddPage(self.canvas, text=_('Model'))
         self.commandPage = self.notebook.AddPage(self.goutput, text=_('Command output'))
         wx.CallAfter(self.notebook.SetSelection, 0)
@@ -547,8 +548,9 @@
             if ret != wx.ID_YES:
                 return
         
+        self.goutput.cmdThread.SetId(-1)
         for action in self.model.GetActions():
-            self.SetStatusText(_('Running model...'), 0)        
+            self.SetStatusText(_('Running model...'), 0) 
             self.goutput.RunCmd(command = action.GetLog(string = False),
                                 onDone = self.OnDone)
         
@@ -1054,8 +1056,11 @@
         
     def _setBrush(self, isvalid):
         """!Set brush"""
-        if isvalid:
+        if isvalid is None:
             color = UserSettings.Get(group='modeler', key='action',
+                                     subkey=('color', 'running'))
+        elif isvalid:
+            color = UserSettings.Get(group='modeler', key='action',
                                      subkey=('color', 'valid'))
         else:
             color = UserSettings.Get(group='modeler', key='action',
@@ -1125,10 +1130,13 @@
         
         return None
 
-    def Update(self):
+    def Update(self, running = False):
         """!Update action"""
-        self._setBrush(self.isValid)
-        
+        if running:
+            self._setBrush(None)
+        else:
+            self._setBrush(self.isValid)
+            
 class ModelData(ogl.EllipseShape):
     """!Data item class"""
     def __init__(self, parent, x, y, name = '', value = '', prompt = '', width = None, height = None):

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2010-04-18 09:45:23 UTC (rev 41915)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2010-04-18 09:53:30 UTC (rev 41916)
@@ -38,7 +38,7 @@
 import menuform
 import prompt
 
-from debug import Debug as Debug
+from debug       import Debug
 from preferences import globalSettings as UserSettings
 
 wxCmdOutput,   EVT_CMD_OUTPUT   = NewEvent()
@@ -75,6 +75,10 @@
         
         return CmdThread.requestId
 
+    def SetId(self, id):
+        """!Set starting id"""
+        CmdThread.requestId = id
+        
     def run(self):
         while True:
             requestId, callable, onDone, args, kwds = self.requestQ.get()
@@ -112,7 +116,7 @@
                     argsColor = list(args)
                     argsColor[0] = [ 'r.colors',
                                      'map=%s' % outputParam['value'],
-                                     'color=%s' % colorTable]
+                                     'color=%s' % colorTable ]
                     self.requestCmdColor = callable(*argsColor, **kwds)
                     self.resultQ.put((requestId, self.requestCmdColor.run()))
             
@@ -375,26 +379,24 @@
         """!Write message in error style"""
         self.WriteLog(line, style=self.cmd_output.StyleError, switchPage = True)
 
-    def RunCmd(self, command, compReg=True, switchPage=False,
+    def RunCmd(self, command, compReg = True, switchPage = False,
                onDone = None):
-        """
-        Run in GUI GRASS (or other) commands typed into
-        console command text widget, and send stdout output to output
-        text widget.
+        """!Run in GUI GRASS (or other) commands typed into console
+        command text widget, and send stdout output to output text
+        widget.
 
         Command is transformed into a list for processing.
 
-        TODO: Display commands (*.d) are captured and
-        processed separately by mapdisp.py. Display commands are
-        rendered in map display widget that currently has
-        the focus (as indicted by mdidx).
+        @todo Display commands (*.d) are captured and processed
+        separately by mapdisp.py. Display commands are rendered in map
+        display widget that currently has the focus (as indicted by
+        mdidx).
 
         @param command command (list)
         @param compReg if true use computation region
         @param switchPage switch to output page
         @param onDone function to be called when command is finished
         """
-        
         # map display window available ?
         try:
             curr_disp = self.parent.curr_page.maptree.mapdisplay
@@ -462,7 +464,7 @@
                                                       layerType = 'vector')
                 else:
                     lname = None
-
+                
                 if self.parent.GetName() == "LayerManager":                
                     self.parent.curr_page.maptree.AddLayer(ltype=layertype,
                                                            lname=lname,
@@ -487,7 +489,7 @@
                     tmpreg = os.getenv("GRASS_REGION")
                     if os.environ.has_key("GRASS_REGION"):
                         del os.environ["GRASS_REGION"]
-                    
+                
                 if len(cmdlist) == 1 and cmdlist[0] not in ('v.krige.py'):
                     import menuform
                     # process GRASS command without argument
@@ -500,7 +502,7 @@
                                           self.cmd_stdout, self.cmd_stderr)                                          
                     self.btn_abort.Enable()
                     self.cmd_output_timer.Start(50)
-
+                    
                     return None
                 
                 # deactivate computational region and return to display settings
@@ -658,13 +660,18 @@
     def OnCmdAbort(self, event):
         """!Abort running command"""
         self.cmdThread.abort()
-                
+        
     def OnCmdRun(self, event):
         """!Run command"""
+        if self.parent.GetName() == 'Modeler':
+            self.parent.GetModel().GetActions()[event.pid].Update(running = True)
         self.WriteCmdLog('(%s)\n%s' % (str(time.ctime()), ' '.join(event.cmd)))
         
     def OnCmdDone(self, event):
         """!Command done (or aborted)"""
+        if self.parent.GetName() == 'Modeler':
+            self.parent.GetModel().GetActions()[event.pid].Update(running = False)
+        
         if event.aborted:
             # Thread aborted (using our convention of None return)
             self.WriteLog(_('Please note that the data are left in incosistent stage '

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2010-04-18 09:45:23 UTC (rev 41915)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2010-04-18 09:53:30 UTC (rev 41916)
@@ -9,7 +9,7 @@
  - GMFrame
  - GMApp
 
-(C) 2006-2009 by the GRASS Development Team
+(C) 2006-2010 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
@@ -107,7 +107,7 @@
         self.parent    = parent
         self.baseTitle = title
         self.iconsize  = (16, 16)
-
+        
         wx.Frame.__init__(self, parent=parent, id=id, size=(550, 450),
                           style=wx.DEFAULT_FRAME_STYLE)
                           



More information about the grass-commit mailing list