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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Sep 5 08:38:06 EDT 2008


Author: martinl
Date: 2008-09-05 08:38:06 -0400 (Fri, 05 Sep 2008)
New Revision: 33276

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
Log:
wxGUI: bug fix trac #282 -- r.what in wxGUI should not depend on computational region
	use `del os.environ[key] rather then os.unsetenv(key)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py	2008-09-05 10:59:23 UTC (rev 33275)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py	2008-09-05 12:38:06 UTC (rev 33276)
@@ -369,9 +369,9 @@
 
         if verbose_orig:
             os.environ["GRASS_VERBOSE"] = verbose_orig
-        else:
-            os.unsetenv("GRASS_VERBOSE")
-
+        elif os.environ.has_key("GRASS_VERBOSE"):
+            del os.environ["GRASS_VERBOSE"]
+            
     def __ReadOutput(self, stream):
         """Read stream and return list of lines
 
@@ -508,7 +508,7 @@
         if self.message_format:
             os.environ["GRASS_MESSAGE_FORMAT"] = self.message_format
         else:
-            os.unsetenv("GRASS_MESSAGE_FORMAT")
+            del os.environ["GRASS_MESSAGE_FORMAT"]
         
     def run(self):
         if len(self.cmd) == 0:

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2008-09-05 10:59:23 UTC (rev 33275)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2008-09-05 12:38:06 UTC (rev 33276)
@@ -243,7 +243,7 @@
         """Write out line in warning style"""
         self.WriteLog(line, style=self.cmd_output.StyleWarning)
 
-    def RunCmd(self, command):
+    def RunCmd(self, command, compReg=True):
         """
         Run in GUI GRASS (or other) commands typed into
         console command text widget, and send stdout output to output
@@ -255,6 +255,9 @@
         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
         """
         
         # map display window available ?
@@ -304,10 +307,13 @@
                 #
                 # other GRASS commands (r|v|g|...)
                 #
+                
                 # activate computational region (set with g.region)
                 # for all non-display commands.
-                tmpreg = os.getenv("GRASS_REGION")
-                os.unsetenv("GRASS_REGION")
+                if compReg:
+                    tmpreg = os.getenv("GRASS_REGION")
+                    del os.environ["GRASS_REGION"]
+                    
                 if len(cmdlist) == 1:
                     import menuform
                     # process GRASS command without argument
@@ -321,8 +327,9 @@
                     self.cmd_output_timer.Start(50)
 
                     return None
+                
                 # deactivate computational region and return to display settings
-                if tmpreg:
+                if compReg and tmpreg:
                     os.environ["GRASS_REGION"] = tmpreg
         else:
             # Send any other command to the shell. Send output to

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-09-05 10:59:23 UTC (rev 33275)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-09-05 12:38:06 UTC (rev 33276)
@@ -2280,7 +2280,8 @@
         match display extents
         """
         tmpreg = os.getenv("GRASS_REGION")
-        os.unsetenv("GRASS_REGION")
+        if tmpreg:
+            del os.environ["GRASS_REGION"]
 
         # We ONLY want to set extents here. Don't mess with resolution. Leave that
         # for user to set explicitly with g.region
@@ -2384,8 +2385,9 @@
                      "--o"]
 
         tmpreg = os.getenv("GRASS_REGION")
-        os.unsetenv("GRASS_REGION")
-
+        if tmpreg:
+            del os.environ["GRASS_REGION"]
+        
         p = gcmd.Command(cmdRegion)
 
         if tmpreg:
@@ -3331,6 +3333,10 @@
             elif type in ('vector', 'thememap', 'themechart'):
                 vectstr += "%s," % name
 
+        # use display region settings instead of computation region settings
+        tmpreg = os.getenv("GRASS_REGION")
+        os.environ["GRASS_REGION"] = self.Map.SetRegion(windres=False)
+        
         # build query commands for any selected rasters and vectors
         if raststr != '':
             rcmd = ['r.what', '--q',
@@ -3365,7 +3371,7 @@
         # parse query command(s)
         if self.gismanager:
             if rcmd:
-                self.gismanager.goutput.RunCmd(rcmd)
+                self.gismanager.goutput.RunCmd(rcmd, compReg=False)
             if vcmd:
                 self.gismanager.goutput.RunCmd(vcmd)
         else:
@@ -3374,6 +3380,10 @@
             if vcmd:
                 gcmd.Command(vcmd)
 
+        # restore GRASS_REGION
+        if tmpreg:
+            os.environ["GRASS_REGION"] = tmpreg
+        
     def QueryVector(self, x, y):
         """
         Query vector map layer features

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2008-09-05 10:59:23 UTC (rev 33275)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2008-09-05 12:38:06 UTC (rev 33276)
@@ -184,9 +184,9 @@
         if UserSettings.Get(group='display', key='driver', subkey='type') == 'cairo':
             gcmd.Command(['d.mon',
                           'stop=cairo'], stderr=None)
-            os.unsetenv("GRASS_CAIROFILE")
+            del os.environ["GRASS_CAIROFILE"]
         else:
-            os.unsetenv("GRASS_PNGFILE")
+            del os.environ["GRASS_PNGFILE"]
         
         self.force_render = False
         
@@ -580,7 +580,8 @@
         region = {}
 
         tmpreg = os.getenv("GRASS_REGION")
-        os.unsetenv("GRASS_REGION")
+        if tmpreg:
+            del os.environ["GRASS_REGION"]
 
         # use external gisrc if defined
         gisrc_orig = os.getenv("GISRC")
@@ -665,13 +666,7 @@
         # adjust region settings to match monitor
         if not windres:
             self.region = self.AdjustRegion()
-
-        #        newextents = self.AlignResolution()
-        #        self.region['n'] = newextents['n']
-        #        self.region['s'] = newextents['s']
-        #        self.region['e'] = newextents['e']
-        #        self.region['w'] = newextents['w']
-
+        
         # read values from wind file
         try:
             for key in self.wind.keys():
@@ -869,7 +864,7 @@
         os.environ["GRASS_HEIGHT"] = str(self.height)
         if UserSettings.Get(group='display', key='driver', subkey='type') == 'cairo':
             os.environ["GRASS_AUTO_WRITE"] = "TRUE"
-            os.unsetenv("GRASS_RENDER_IMMEDIATE")
+            del os.environ["GRASS_RENDER_IMMEDIATE"]
         else:
             os.environ["GRASS_PNG_AUTO_WRITE"] = "TRUE"
             os.environ["GRASS_PNG_READ"] = "FALSE"
@@ -907,12 +902,11 @@
 
 
         # render overlays
-
-        os.unsetenv("GRASS_REGION")
-
         if tmp_region:
             os.environ["GRASS_REGION"] = tmp_region
-
+        else:
+            del os.environ["GRASS_REGION"]
+        
         # run g.pngcomp to get composite image
         try:
             gcmd.Command(complist)



More information about the grass-commit mailing list