[GRASS-SVN] r33277 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Sep 5 08:41:04 EDT 2008
Author: martinl
Date: 2008-09-05 08:41:04 -0400 (Fri, 05 Sep 2008)
New Revision: 33277
Modified:
grass/trunk/gui/wxpython/gui_modules/gcmd.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
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)
(merge from devbr6, r33276)
Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py 2008-09-05 12:38:06 UTC (rev 33276)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py 2008-09-05 12:41:04 UTC (rev 33277)
@@ -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/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-09-05 12:38:06 UTC (rev 33276)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-09-05 12:41:04 UTC (rev 33277)
@@ -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/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-09-05 12:38:06 UTC (rev 33276)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-09-05 12:41:04 UTC (rev 33277)
@@ -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/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2008-09-05 12:38:06 UTC (rev 33276)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2008-09-05 12:41:04 UTC (rev 33277)
@@ -175,7 +175,7 @@
#
# stop monitor
#
- os.unsetenv("GRASS_PNGFILE")
+ del os.environ["GRASS_PNGFILE"]
self.force_render = False
@@ -569,7 +569,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")
@@ -654,13 +655,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():
@@ -899,12 +894,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