[GRASS-SVN] r32888 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 19 08:39:13 EDT 2008


Author: martinl
Date: 2008-08-19 08:39:12 -0400 (Tue, 19 Aug 2008)
New Revision: 32888

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
Log:
wxGUI: update progress bar info via event

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-08-19 11:29:03 UTC (rev 32887)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-08-19 12:39:12 UTC (rev 32888)
@@ -34,6 +34,7 @@
 
 import wx
 import wx.aui
+
 from threading import Thread
 
 import globalvar
@@ -128,13 +129,13 @@
     Parent for BufferedWindow class (2D display mode) and
     GLWindow (3D display mode)
     """
-    def __init__(self, parent, id,
+    def __init__(self, parent, id=wx.ID_ANY,
                  pos=wx.DefaultPosition,
                  size=wx.DefaultSize,
                  style=wx.NO_FULL_REPAINT_ON_RESIZE,
                  Map=None, tree=None, gismgr=None):
-        pass
-
+        self.parent = parent # MapFrame
+        
     def EraseMap(self):
         """
         Erase the canvas (virtual method)
@@ -212,7 +213,6 @@
                            Map, tree, gismgr)
         wx.Window.__init__(self, parent, id, pos, size, style)
 
-        self.parent = parent
         self.Map = Map
         self.tree = tree
         self.gismanager = gismgr
@@ -637,9 +637,7 @@
             self.parent.onRenderGauge.Show()
             if self.parent.onRenderGauge.GetRange() > 0:
                 self.parent.onRenderGauge.SetValue(1)
-                self.parent.onRenderTimer.Start(100)
-            self.parent.onRenderCounter = 0
-
+        
         #
         # render background image if needed
         #
@@ -736,8 +734,6 @@
         #
         # hide process bar
         #
-        if self.parent.onRenderGauge.GetRange() > 0:
-            self.parent.onRenderTimer.Stop()
         self.parent.onRenderGauge.Hide()
 
         #
@@ -2402,7 +2398,6 @@
 
         self.gismanager = gismgr    # GIS Manager object
         self.Map        = Map       # instance of render.Map
-        self.Map.window = self
         self.tree       = tree      # GIS Manager layer tree object
         self.page       = page      # Notebook page holding the layer tree
         self.layerbook  = notebook  # GIS Manager layer tree notebook
@@ -2493,9 +2488,7 @@
         self.onRenderGauge = wx.Gauge(parent=self.statusbar, id=wx.ID_ANY,
                                       range=0, style=wx.GA_HORIZONTAL)
         self.onRenderGauge.Hide()
-        self.Bind(wx.EVT_TIMER, self.TimerOnRender)
-        self.onRenderTimer = wx.Timer(self)
-
+        
         self.StatusbarReposition() # reposition statusbar
 
         #
@@ -2520,7 +2513,8 @@
         #
         self.Bind(wx.EVT_ACTIVATE, self.OnFocus)
         self.Bind(wx.EVT_CLOSE,    self.OnCloseWindow)
-
+        self.Bind(render.EVT_UPDATE_PRGBAR, self.OnUpdateProgress)
+        
         #
         # Update fancy gui style
         #
@@ -2761,6 +2755,12 @@
         self.Map.region = self.Map.GetRegion() # g.region -upgc
         # self.Map.SetRegion() # adjust region to match display window
 
+    def OnUpdateProgress(self, event):
+        """Update progress bar info"""
+        self.onRenderGauge.SetValue(event.value)
+        
+        event.Skip()
+        
     def OnFocus(self, event):
         """
         Change choicebook page to match display.
@@ -2811,11 +2811,7 @@
         Re-display current map composition
         """
         self.MapWindow.UpdateMap(render=False)
-
-    def TimerOnRender(self, event):
-        """Update process bar"""
-        self.onRenderGauge.SetValue(self.onRenderCounter)
-
+        
     def OnRender(self, event):
         """
         Re-render map composition (each map layer)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2008-08-19 11:29:03 UTC (rev 32887)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2008-08-19 12:39:12 UTC (rev 32888)
@@ -33,6 +33,7 @@
 import tempfile
 
 import wx
+from wx.lib.newevent import NewEvent
 
 import globalvar
 import utils
@@ -40,6 +41,8 @@
 from debug import Debug as Debug
 from preferences import globalSettings as UserSettings
 
+wxUpdateProgressBar, EVT_UPDATE_PRGBAR = NewEvent()
+
 #
 # use g.pnmcomp for creating image composition or
 # wxPython functionality
@@ -318,9 +321,7 @@
     """
     Map composition (stack of map layers and overlays)
     """
-    def __init__(self, gisrc=None, window=None):
-        self.window = window # used for wx.SafeYield()
-        
+    def __init__(self, gisrc=None):
         # 
         # region/extent settigns
         #
@@ -818,6 +819,7 @@
             os.environ["GRASS_RENDER_IMMEDIATE"] = "TRUE"
 
         # render map layers
+        ilayer = 1
         for layer in self.layers + self.overlays:
             # skip dead or disabled map layers
             if layer == None or layer.active == False:
@@ -832,10 +834,9 @@
                     continue
             
             # update progress bar
-            if mapWindow is not None:
-                mapWindow.onRenderCounter += 1
-
-            wx.SafeYield(self.window)
+            wx.SafeYield(mapWindow)
+            event = wxUpdateProgressBar(value=ilayer)
+            wx.PostEvent(mapWindow, event)
             
             # add image to compositing list
             if layer.type != "overlay":
@@ -844,7 +845,8 @@
                 opacities.append(str(layer.opacity))
                 
             Debug.msg (3, "Map.Render() type=%s, layer=%s " % (layer.type, layer.name))
-
+            ilayer += 1
+        
         # ugly hack for MSYS
         if not subprocess.mswindows:
             mapstr = ",".join(maps)



More information about the grass-commit mailing list