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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 11 13:58:43 EDT 2010


Author: martinl
Date: 2010-10-11 10:58:42 -0700 (Mon, 11 Oct 2010)
New Revision: 43869

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: fix re-rendering when r.colors is called


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2010-10-11 16:41:19 UTC (rev 43868)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2010-10-11 17:58:42 UTC (rev 43869)
@@ -159,7 +159,6 @@
         self.panelPrompt = wx.Panel(parent = self, id = wx.ID_ANY)
         
         # initialize variables
-        self.Map             = None
         self.parent          = parent # GMFrame | CmdPanel | ?
         if notebook:
             self._notebook = notebook
@@ -421,13 +420,6 @@
         @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
-            self.Map = curr_disp.GetRender()
-        except:
-            curr_disp = None
-        
         # command given as a string ?
         try:
             cmdlist = command.strip().split(' ')
@@ -718,62 +710,68 @@
         # set focus on prompt
         if self.parent.GetName() == "LayerManager":
             self.btn_abort.Enable(False)
+            if event.cmd[0] in ('r.colors'):
+                display = self.parent.GetLayerTree().GetMapDisplay()
+                if display:
+                    display.GetWindow().UpdateMap(render = True)
+        
         else:
             # updated command dialog
             dialog = self.parent.parent
 
             if hasattr(self.parent.parent, "btn_abort"):
                 dialog.btn_abort.Enable(False)
-
+            
             if hasattr(self.parent.parent, "btn_cancel"):
                 dialog.btn_cancel.Enable(True)
-
+            
             if hasattr(self.parent.parent, "btn_clipboard"):
                 dialog.btn_clipboard.Enable(True)
-
+            
             if hasattr(self.parent.parent, "btn_help"):
                 dialog.btn_help.Enable(True)
-
+            
             if hasattr(self.parent.parent, "btn_run"):
                 dialog.btn_run.Enable(True)
             
-            if event.returncode == 0 and \
-                    not event.aborted and hasattr(dialog, "addbox") and \
-                    dialog.addbox.IsChecked():
-                # add created maps into layer tree
+            if event.returncode == 0 and not event.aborted:
                 winName = self.parent.parent.parent.GetName()
                 if winName == 'LayerManager':
-                    mapTree = self.parent.parent.parent.curr_page.maptree
+                    mapTree = self.parent.parent.parent.GetLayerTree()
+                elif winName == 'LayerTree':
+                    mapTree = self.parent.parent.parent
                 else: # GMConsole
-                    mapTree = self.parent.parent.parent.parent.curr_page.maptree
+                    mapTree = self.parent.parent.parent.parent.GetLayerTree()
                 
                 cmd = dialog.notebookpanel.createCmd(ignoreErrors = True)
-                for p in dialog.task.get_options()['params']:
-                    prompt = p.get('prompt', '')
-                    if prompt in ('raster', 'vector', '3d-raster') and \
-                       p.get('age', 'old') == 'new' and \
-                       p.get('value', None):
-                        name = utils.GetLayerNameFromCmd(cmd, fullyQualified=True, param = p.get('name', ''))
-                        
-                        if mapTree.GetMap().GetListOfLayers(l_name = name):
-                            continue
-                        
-                        if prompt == 'raster':
-                            lcmd = ['d.rast',
-                                    'map=%s' % name]
-                        else:
-                            lcmd = ['d.vect',
-                                    'map=%s' % name]
-                        mapTree.AddLayer(ltype = prompt,
-                                         lcmd = lcmd,
-                                         lname = name)
-                
+                if hasattr(dialog, "addbox") and dialog.addbox.IsChecked():
+                    # add created maps into layer tree
+                    for p in dialog.task.get_options()['params']:
+                        prompt = p.get('prompt', '')
+                        if prompt in ('raster', 'vector', '3d-raster') and \
+                                p.get('age', 'old') == 'new' and \
+                                p.get('value', None):
+                            name = utils.GetLayerNameFromCmd(cmd, fullyQualified=True, param = p.get('name', ''))
+                            
+                            if mapTree.GetMap().GetListOfLayers(l_name = name):
+                                continue
+                            
+                            if prompt == 'raster':
+                                lcmd = ['d.rast',
+                                        'map=%s' % name]
+                            else:
+                                lcmd = ['d.vect',
+                                        'map=%s' % name]
+                            mapTree.AddLayer(ltype = prompt,
+                                             lcmd = lcmd,
+                                             lname = name)
+            
             if hasattr(dialog, "get_dcmd") and \
                     dialog.get_dcmd is None and \
                     dialog.closebox.IsChecked():
                 time.sleep(1)
                 dialog.Close()
-
+        
         event.Skip()
         
     def OnProcessPendingOutputWindowEvents(self, event):

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-10-11 16:41:19 UTC (rev 43868)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-10-11 17:58:42 UTC (rev 43869)
@@ -477,7 +477,7 @@
     def has_required(self):
         """!Check if command has at least one required paramater"""
         for p in self.params:
-            if p.get('required', False) == True:
+            if p.get('required', 'no') == 'yes':
                 return True
         
         return False
@@ -850,12 +850,16 @@
 
         @param returncode command's return code (0 for success)
         """
-        if self.parent and self.parent.GetName() != 'LayerTree' or \
+        if self.parent and self.parent.GetName() not in ('LayerTree', 'LayerManager') or \
                 returncode != 0:
             return
         
         if cmd[0] in ('r.colors'):
-            display = self.parent.GetMapDisplay()
+            if self.parent.GetName() == 'LayerTree':
+                display = self.parent.GetMapDisplay()
+            else: # Layer Manager
+                display = self.parent.GetLayerTree().GetMapDisplay()
+            
             if display:
                 display.GetWindow().UpdateMap(render = True)
         

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2010-10-11 16:41:19 UTC (rev 43868)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2010-10-11 17:58:42 UTC (rev 43869)
@@ -381,6 +381,10 @@
 
         event.Skip()
 
+    def GetLayerTree(self):
+        """!Get current layer tree"""
+        return self.curr_page.maptree
+    
     def GetLogWindow(self):
         """!Get widget for command output"""
         return self.goutput



More information about the grass-commit mailing list