[GRASS-SVN] r49410 - in grass/trunk: gui/wxpython/core
gui/wxpython/mapdisp gui/wxpython/nviz include/defs lib/ogsf
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 28 14:10:58 EST 2011
Author: annakrat
Date: 2011-11-28 11:10:58 -0800 (Mon, 28 Nov 2011)
New Revision: 49410
Modified:
grass/trunk/gui/wxpython/core/render.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/nviz/mapwindow.py
grass/trunk/gui/wxpython/nviz/wxnviz.py
grass/trunk/include/defs/ogsf.h
grass/trunk/lib/ogsf/GVL2.c
Log:
wxNviz: update 3d region when switching to 3d view
Modified: grass/trunk/gui/wxpython/core/render.py
===================================================================
--- grass/trunk/gui/wxpython/core/render.py 2011-11-28 18:58:14 UTC (rev 49409)
+++ grass/trunk/gui/wxpython/core/render.py 2011-11-28 19:10:58 UTC (rev 49410)
@@ -588,7 +588,7 @@
def GetRegion(self, rast = [], zoom = False, vect = [], regionName = None,
n = None, s = None, e = None, w = None, default = False,
- update = False):
+ update = False, add3d = False):
"""!Get region settings (g.region -upgc)
Optionally extent, raster or vector map layer can be given.
@@ -600,6 +600,7 @@
@param n,s,e,w force extent
@param default force default region settings
@param update if True update current display region settings
+ @param add3d add 3d region settings
@return region settings as directory, e.g. {
'n':'4928010', 's':'4913700', 'w':'589980',...}
@@ -624,6 +625,9 @@
if default:
cmd['flags'] += 'd'
+ if add3d:
+ cmd['flags'] += '3'
+
if regionName:
cmd['region'] = regionName
@@ -693,7 +697,7 @@
"""
return self.region
- def SetRegion(self, windres = False):
+ def SetRegion(self, windres = False, windres3 = False):
"""!Render string for GRASS_REGION env. variable, so that the
images will be rendered from desired zoom level.
@@ -706,10 +710,16 @@
grass_region = ""
if windres:
- compRegion = self.GetRegion()
+ compRegion = self.GetRegion(add3d = windres3)
region = copy.copy(self.region)
for key in ('nsres', 'ewres', 'cells'):
region[key] = compRegion[key]
+ if windres3:
+ for key in ('nsres3', 'ewres3', 'tbres', 'cells3',
+ 'cols3', 'rows3', 'depths'):
+ if key in compRegion:
+ region[key] = compRegion[key]
+
else:
# adjust region settings to match monitor
region = self.AdjustRegion()
@@ -717,6 +727,7 @@
# read values from wind file
try:
for key in self.wind.keys():
+
if key == 'north':
grass_region += "north: %s; " % \
(region['n'])
@@ -753,6 +764,24 @@
grass_region += 'rows: %d; ' % \
region['rows']
continue
+ elif key == "n-s resol3" and windres3:
+ grass_region += "n-s resol3: %f; " % \
+ (region['nsres3'])
+ elif key == "e-w resol3" and windres3:
+ grass_region += "e-w resol3: %f; " % \
+ (region['ewres3'])
+ elif key == "t-b resol" and windres3:
+ grass_region += "t-b resol: %f; " % \
+ (region['tbres'])
+ elif key == "cols3" and windres3:
+ grass_region += "cols3: %d; " % \
+ (region['cols3'])
+ elif key == "rows3" and windres3:
+ grass_region += "rows3: %d; " % \
+ (region['rows3'])
+ elif key == "depths" and windres3:
+ grass_region += "depths: %d; " % \
+ (region['depths'])
else:
grass_region += key + ": " + self.wind[key] + "; "
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2011-11-28 18:58:14 UTC (rev 49409)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2011-11-28 19:10:58 UTC (rev 49410)
@@ -326,7 +326,7 @@
self.MapWindow3D.UpdateView(None)
else:
self.MapWindow = self.MapWindow3D
- os.environ['GRASS_REGION'] = self.Map.SetRegion(windres = True)
+ os.environ['GRASS_REGION'] = self.Map.SetRegion(windres = True, windres3 = True)
self.MapWindow3D.GetDisplay().Init()
del os.environ['GRASS_REGION']
Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py 2011-11-28 18:58:14 UTC (rev 49409)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py 2011-11-28 19:10:58 UTC (rev 49410)
@@ -128,8 +128,8 @@
logerr = sys.stderr
# create nviz instance - use display region instead of computational
- os.environ['GRASS_REGION'] = self.Map.SetRegion(windres = True)
+ os.environ['GRASS_REGION'] = self.Map.SetRegion(windres = True, windres3 = True)
self.nvizThread = NvizThread(logerr,
self.parent.GetProgressBar(),
logmsg)
Modified: grass/trunk/gui/wxpython/nviz/wxnviz.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/wxnviz.py 2011-11-28 18:58:14 UTC (rev 49409)
+++ grass/trunk/gui/wxpython/nviz/wxnviz.py 2011-11-28 19:10:58 UTC (rev 49410)
@@ -124,6 +124,7 @@
Rast__init_window()
GS_libinit()
GVL_libinit()
+ GVL_init_region()
def ResizeWindow(self, width, height):
"""!GL canvas resized
Modified: grass/trunk/include/defs/ogsf.h
===================================================================
--- grass/trunk/include/defs/ogsf.h 2011-11-28 18:58:14 UTC (rev 49409)
+++ grass/trunk/include/defs/ogsf.h 2011-11-28 19:10:58 UTC (rev 49410)
@@ -231,6 +231,7 @@
/* GVL2.c */
void GVL_libinit(void);
+void GVL_init_region(void);
int GVL_get_region(float *, float *, float *, float *, float *, float *);
void *GVL_get_window();
int GVL_vol_exists(int);
Modified: grass/trunk/lib/ogsf/GVL2.c
===================================================================
--- grass/trunk/lib/ogsf/GVL2.c 2011-11-28 18:58:14 UTC (rev 49409)
+++ grass/trunk/lib/ogsf/GVL2.c 2011-11-28 19:10:58 UTC (rev 49410)
@@ -50,6 +50,25 @@
}
/*!
+ \brief Initialize 3D region
+
+ Set region extent (N,S,W,E,T,B)
+ */
+void GVL_init_region(void)
+{
+ Rast3d_read_window(&wind3, NULL);
+
+ Region[0] = wind3.north;
+ Region[1] = wind3.south;
+ Region[2] = wind3.west;
+ Region[3] = wind3.east;
+ Region[4] = wind3.top;
+ Region[5] = wind3.bottom;
+
+ return;
+}
+
+/*!
\brief Get region extent settings
\param[out] n,s,w,e north, south, west, east
More information about the grass-commit
mailing list