[GRASS-SVN] r30705 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Mar 23 13:51:57 EDT 2008


Author: martinl
Date: 2008-03-23 13:51:57 -0400 (Sun, 23 Mar 2008)
New Revision: 30705

Modified:
   grass/trunk/gui/wxpython/gui_modules/debug.py
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/render.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: minor cleaning in render (Map/MapFrame class) initialization

Modified: grass/trunk/gui/wxpython/gui_modules/debug.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/debug.py	2008-03-23 17:23:11 UTC (rev 30704)
+++ grass/trunk/gui/wxpython/gui_modules/debug.py	2008-03-23 17:51:57 UTC (rev 30705)
@@ -52,6 +52,10 @@
         if self.debuglevel > 0 and level > 0 and level <= self.debuglevel:
             print >> sys.stderr, "GUI D%d/%d: %s" % (level, self.debuglevel, message)
 
+    def get_level(self):
+        """Return current GUI debug level"""
+        return self.debuglevel
+
 # Debug instance
 Debug = DebugMsg()
 

Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-03-23 17:23:11 UTC (rev 30704)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-03-23 17:51:57 UTC (rev 30705)
@@ -58,7 +58,9 @@
         self.cmd_stderr = GMStderr(self.cmd_output,
                                    self.console_progressbar,
                                    self.parent.notebook)
-        sys.stderr = self.cmd_stderr
+        if Debug.get_level() == 0:
+            # don't redirect when debugging is enabled
+            sys.stderr = self.cmd_stderr
         
         # buttons
         self.console_clear = wx.Button(parent=self, id=wx.ID_CLEAR)

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-03-23 17:23:11 UTC (rev 30704)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-03-23 17:51:57 UTC (rev 30705)
@@ -211,12 +211,10 @@
         self.zoomtype = 1   # 1 zoom in, 0 no zoom, -1 zoom out
         self.hitradius = 10 # distance for selecting map decorations
 
-        self.Map.SetRegion() # make sure that extents are updated at init
-
         # OnSize called to make sure the buffer is initialized.
         # This might result in OnSize getting called twice on some
         # platforms at initialization, but little harm done.
-        self.OnSize(None)
+        ### self.OnSize(None)
 
         # create PseudoDC used for background map, map decorations like scales and legends
         self.pdc = wx.PseudoDC()
@@ -2151,8 +2149,6 @@
                 georect -- is window used by georectifier
         """
 
-        Debug.msg (1, "MapFrame.__init__(): size=%d,%d" % (size[0], size[1]))
-
         wx.Frame.__init__(self, parent, id, title, pos, size, style)
 
         self.gismanager = gismgr    # GIS Manager object
@@ -2240,21 +2236,21 @@
         self.Bind(wx.EVT_TIMER, self.TimerOnRender)
         self.onRenderTimer = wx.Timer(self)
 
-        self.Map.SetRegion() # set region
-
         self.StatusbarReposition() # reposition statusbar
 
         #
-        # Init map display
+        # Init map display (buffered DC & set default cursor)
         #
-        self.__InitDisplay() # initialize region values
-
-        # initialize buffered DC & set default cursor
         self.MapWindow = BufferedWindow(self, id=wx.ID_ANY, Map=self.Map, tree=self.tree, gismgr=self.gismanager)
         self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
         self.MapWindow.SetCursor(self.cursors["default"])
 
         #
+        # initialize region values
+        #
+        self.__InitDisplay() 
+
+        #
         # Decoration overlays
         #
         self.ovlchk = self.MapWindow.ovlchk
@@ -2381,8 +2377,8 @@
 
         Debug.msg(2, "MapFrame.__InitDisplay():")
         self.Map.ChangeMapSize(self.GetClientSize())
-        self.Map.GetRegion() # g.region -upg
-        self.Map.SetRegion() # adjust region to match display window
+        self.Map.region = self.Map.GetRegion() # g.region -upgc
+        # self.Map.SetRegion() # adjust region to match display window
 
     def OnFocus(self, event):
         """

Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py	2008-03-23 17:23:11 UTC (rev 30704)
+++ grass/trunk/gui/wxpython/gui_modules/render.py	2008-03-23 17:51:57 UTC (rev 30705)
@@ -21,6 +21,7 @@
 import sys
 import glob
 import math
+# import time
 try:
     import subprocess
 except:
@@ -220,6 +221,10 @@
         # setting some initial env. variables
         self.InitGisEnv() # g.gisenv
         self.InitRegion()
+
+        #
+        # GRASS environment variable (for rendering)
+        #
         os.environ["GRASS_TRANSPARENT"] = "TRUE"
         os.environ["GRASS_BACKGROUNDCOLOR"] = "ffffff"
 
@@ -236,7 +241,8 @@
         #
         # setting region ('g.region -upg')
         #
-        self.region = self.GetRegion()
+        ### not needed here (MapFrame.OnSize())
+        # self.region = self.GetRegion()
 
         #
         # read WIND file
@@ -246,7 +252,8 @@
         #
         # setting resolution
         #
-        self.SetRegion()
+        # not needed here (MapFrame.OnSize())
+        # self.SetRegion()
 
     def InitGisEnv(self):
         """
@@ -608,6 +615,8 @@
         @return name of file with rendered image or None
         """
 
+        # startTime = time.time()
+
         maps = []
         masks =[]
         opacities = []
@@ -696,6 +705,8 @@
 
         Debug.msg (2, "Map.Render() force=%s file=%s" % (force, self.mapfile))
 
+        # print time.time() - startTime
+
         return self.mapfile
 
     def AddLayer(self, type, command, name=None,

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-03-23 17:23:11 UTC (rev 30704)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-03-23 17:51:57 UTC (rev 30705)
@@ -1013,7 +1013,7 @@
         """Create new layer tree, which will
         create an associated map display frame
         """
-        Debug.msg(3, "GMFrame.NewDisplay(): idx=%d" % self.disp_idx)
+        Debug.msg(1, "GMFrame.NewDisplay(): idx=%d" % self.disp_idx)
 
         # make a new page in the bookcontrol for the layer tree (on page 0 of the notebook)
         self.pg_panel = wx.Panel(self.gm_cb, id=wx.ID_ANY, style= wx.EXPAND)



More information about the grass-commit mailing list