[GRASS-SVN] r44909 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 8 18:35:49 EST 2011


Author: martinl
Date: 2011-01-08 15:35:49 -0800 (Sat, 08 Jan 2011)
New Revision: 44909

Modified:
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/gui/wxpython/gui_modules/toolbars.py
   grass/trunk/gui/wxpython/gui_modules/wxvdigit.py
   grass/trunk/gui/wxpython/gui_modules/wxvdriver.py
Log:
wxGUI/vdigit: redirect messages to Layer Manager log area


Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2011-01-08 22:09:36 UTC (rev 44908)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2011-01-08 23:35:49 UTC (rev 44909)
@@ -569,6 +569,20 @@
         self.cmd_output.SetReadOnly(True)
         self.console_progressbar.SetValue(0)
 
+    def GetProgressBar(self):
+        """!Return progress bar widget"""
+        return self.console_progressbar
+    
+    def GetLog(self, err = False):
+        """!Get widget used for logging
+
+        @param err True to get stderr widget
+        """
+        if err:
+            return self.cmd_stderr
+        
+        return self.cmd_stdout
+    
     def SaveHistory(self, event):
         """!Save history of commands"""
         self.history = self.cmd_output.GetSelectedText()

Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py	2011-01-08 22:09:36 UTC (rev 44908)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py	2011-01-08 23:35:49 UTC (rev 44909)
@@ -624,9 +624,8 @@
             )
     
 class VDigitToolbar(AbstractToolbar):
+    """!Toolbar for digitization
     """
-    Toolbar for digitization
-    """
     def __init__(self, parent, mapcontent, layerTree = None, log = None):
         self.mapcontent    = mapcontent # Map class instance
         self.layerTree     = layerTree  # reference to layer tree associated to map display
@@ -670,8 +669,7 @@
         self.FixSize(width = 105)
         
     def ToolbarData(self):
-        """!
-        Toolbar data
+        """!Toolbar data
         """
         data = []
         
@@ -1343,9 +1341,11 @@
                                                   "closing and rebuilding topology of "
                                                   "vector map <%s>...") % self.mapLayer.GetName(),
                                                 0)
-            
+            self.parent.GetLayerManager().notebook.SetSelection(1)
             self.parent.digit.CloseMap()
-            
+            self.parent.GetLayerManager().GetLogWindow().GetProgressBar().SetValue(0)
+            self.parent.GetLayerManager().GetLogWindow().WriteCmdLog(_("Editing of vector map <%s> successfully finished") % \
+                                                                       self.mapLayer.GetName())
             # re-active layer 
             item = self.parent.tree.FindItemByData('maplayer', self.mapLayer)
             if item and self.parent.tree.IsItemChecked(item):

Modified: grass/trunk/gui/wxpython/gui_modules/wxvdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxvdigit.py	2011-01-08 22:09:36 UTC (rev 44908)
+++ grass/trunk/gui/wxpython/gui_modules/wxvdigit.py	2011-01-08 23:35:49 UTC (rev 44909)
@@ -110,9 +110,12 @@
         self.mapWindow = mapwindow
         
         if not mapwindow.parent.IsStandalone():
-            self.log = mapwindow.parent.GetLayerManager().goutput.cmd_stderr
+            goutput = mapwindow.parent.GetLayerManager().GetLogWindow()
+            log = goutput.GetLog(err = True)
+            progress = goutput.GetProgressBar()
         else:
-            self.log = sys.stderr
+            log = sys.stderr
+            progress = None
         
         self.toolbar = mapwindow.parent.toolbars['vdigit']
         
@@ -122,7 +125,8 @@
                                       deviceTmp = mapwindow.pdcTmp,
                                       mapObj    = mapwindow.Map,
                                       window    = mapwindow,
-                                      log       = self.log)
+                                      glog      = log,
+                                      gprogress = progress)
         
         # GRASS lib
         self.poPoints = Vect_new_line_struct()

Modified: grass/trunk/gui/wxpython/gui_modules/wxvdriver.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxvdriver.py	2011-01-08 22:09:36 UTC (rev 44908)
+++ grass/trunk/gui/wxpython/gui_modules/wxvdriver.py	2011-01-08 23:35:49 UTC (rev 44909)
@@ -28,16 +28,52 @@
 from grass.lib.vector import *
 from grass.lib.vedit  import *
 
+log      = None
+progress = None
+
+def print_error(msg, type):
+    """!Redirect stderr"""
+    global log
+    if log:
+        log.write(msg)
+    else:
+        print msg
+    
+    return 0
+
+def print_progress(value):
+    """!Redirect progress info"""
+    global progress
+    if progress:
+        progress.SetValue(value)
+    else:
+        print value
+    
+    return 0
+
+errtype = CFUNCTYPE(UNCHECKED(c_int), String, c_int)
+errfunc = errtype(print_error)
+pertype = CFUNCTYPE(UNCHECKED(c_int), c_int)
+perfunc = pertype(print_progress)
+
 class DisplayDriver:
-    def __init__(self, device, deviceTmp, mapObj, window, log = None):
+    def __init__(self, device, deviceTmp, mapObj, window, glog, gprogress):
         """Display driver used by vector digitizer
         
         @param device    wx.PseudoDC device where to draw vector objects
         @param deviceTmp wx.PseudoDC device where to draw temporary vector objects
         @param mapOng    Map Object (render.Map)
-        @param log       logging device (None to discard messages)
+        @param windiow   parent window for dialogs
+        @param glog      logging device (None to discard messages)
+        @param gprogress progress bar device (None to discard message)
         """
+        global errfunc, perfunc, log, progress
+        log = glog
+        progress = gprogress
+        
         G_gisinit('')             # initialize GRASS libs
+        G_set_error_routine(errfunc) 
+        G_set_percent_routine(perfunc)
         
         self.mapInfo   = None     # open vector map (Map_Info structure)
         self.poMapInfo = None     # pointer to self.mapInfo
@@ -121,6 +157,9 @@
         
     def __del__(self):
         """!Close currently open vector map"""
+        G_unset_error_routine()
+        G_unset_percent_routine()
+        
         if self.poMapInfo:
             self.CloseMap()
         



More information about the grass-commit mailing list