[GRASS-SVN] r51695 - in grass/trunk/gui/wxpython: core nviz

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 24 05:53:00 EDT 2012


Author: annakrat
Date: 2012-05-24 02:52:58 -0700 (Thu, 24 May 2012)
New Revision: 51695

Modified:
   grass/trunk/gui/wxpython/core/settings.py
   grass/trunk/gui/wxpython/nviz/mapwindow.py
Log:
wxNviz: revert changes in zexag and improve its behaviour for latlon projections

Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py	2012-05-24 09:46:44 UTC (rev 51694)
+++ grass/trunk/gui/wxpython/core/settings.py	2012-05-24 09:52:58 UTC (rev 51695)
@@ -807,7 +807,7 @@
         self.internalSettings['nviz']['view']['height'] = {}
         self.internalSettings['nviz']['view']['height']['value'] = -1
         self.internalSettings['nviz']['view']['z-exag'] = {}
-        self.internalSettings['nviz']['view']['z-exag']['original'] = 1
+        self.internalSettings['nviz']['view']['z-exag']['llRatio'] = 1
         self.internalSettings['nviz']['view']['rotation'] = None
         self.internalSettings['nviz']['view']['focus'] = {}
         self.internalSettings['nviz']['view']['focus']['x'] = -1

Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py	2012-05-24 09:46:44 UTC (rev 51694)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py	2012-05-24 09:52:58 UTC (rev 51695)
@@ -1080,9 +1080,8 @@
         view = self.view
         iview = self.iview
         if zexag and 'value' in view['z-exag']:
-            self._display.SetZExag(self.iview['z-exag']['original'] * view['z-exag']['value'])
+            self._display.SetZExag(view['z-exag']['value'] / iview['z-exag']['llRatio'])
         
-        
         self._display.SetView(view['position']['x'], view['position']['y'],
                               iview['height']['value'],
                               view['persp']['value'],
@@ -1753,18 +1752,29 @@
 
     def ResetView(self):
         """!Reset to default view"""
-        self.iview['z-exag']['original'], \
+        zexagOriginal, \
             self.iview['height']['value'], \
             self.iview['height']['min'], \
             self.iview['height']['max'] = self._display.SetViewDefault()
-            
-        ## set initial z-exag value at 1X    
-        self.view['z-exag']['value'] = 1.0
         
+        ## hack for latlon projection
+        ## TODO find more precise way or better rewrite it in OGSF
+        self.iview['z-exag']['llRatio'] = 1
+        if grass.locn_is_latlong():
+            self.iview['z-exag']['llRatio'] = \
+                math.pi / 180 * 6371000 * math.cos((grass.region()['n'] + grass.region()['s']) / 2)
+
+        self.view['z-exag']['value'] = round(zexagOriginal * self.iview['z-exag']['llRatio'])
         self.view['z-exag']['min'] = UserSettings.Get(group = 'nviz', key = 'view',
-                                                      subkey = ('z-exag', 'min'))        
+                                                      subkey = ('z-exag', 'min'))
         zexagMax = UserSettings.Get(group = 'nviz', key = 'view',
-                                    subkey = ('z-exag', 'max'))        
+                                    subkey = ('z-exag', 'max'))
+        if zexagMax <= self.view['z-exag']['value']:
+            self.view['z-exag']['max'] = self.view['z-exag']['value'] * 2
+        elif self.view['z-exag']['value'] < 1: 
+            self.view['z-exag']['max'] = 10 * self.view['z-exag']['value'] 
+        else: 
+            self.view['z-exag']['max'] = zexagMax
         
         self.view['position']['x'] = UserSettings.Get(group = 'nviz', key = 'view',
                                                  subkey = ('position', 'x'))



More information about the grass-commit mailing list