[GRASS-SVN] r35110 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 29 23:09:08 EST 2008


Author: cmbarton
Date: 2008-12-29 23:09:08 -0500 (Mon, 29 Dec 2008)
New Revision: 35110

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/profile.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py
Log:
Fixing bugs in profile module (hanging/crashing with many transect nodes, and nodes off map) and making interface a little more robust (including better enforcement of proper profiling steps: 1) choose map to profile, 2) draw transect, 3) create profile)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2008-12-30 04:00:12 UTC (rev 35109)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2008-12-30 04:09:08 UTC (rev 35110)
@@ -3738,6 +3738,9 @@
                                             id=wx.ID_ANY, pos=wx.DefaultPosition, size=(700,300),
                                             style=wx.DEFAULT_FRAME_STYLE, rasterList=raster)
         self.profile.Show()
+        # Open raster select dialog to make sure that a raster (and the desired raster)
+        # is selected to be profiled
+        self.profile.OnSelectRaster(None)
 
     def FormatDist(self, dist):
         """Format length numbers and units in a nice way,

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/profile.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/profile.py	2008-12-30 04:00:12 UTC (rev 35109)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/profile.py	2008-12-30 04:09:08 UTC (rev 35110)
@@ -55,6 +55,7 @@
 from debug import Debug as Debug
 from icon import Icons as Icons
 from preferences import globalSettings as UserSettings
+import grass
 
 class ProfileFrame(wx.Frame):
     """
@@ -250,11 +251,12 @@
         #
         # create list of coordinate points for r.profile
         #
+                
         dist = 0
         cumdist = 0
         self.coordstr = ''
         lasteast = lastnorth = None
-
+        
         if len(self.mapwin.polycoords) > 0:
             for point in self.mapwin.polycoords:
                 # build string of coordinate points for r.profile
@@ -272,13 +274,13 @@
         #
         # create datalist for each raster map
         #
+        
         for r in self.raster.itervalues():
             if r['name'] == '':
                 continue
             r['datalist'] = self.CreateDatalist(r['name'], self.coordstr)
             r['plegend'] = _('Profile of %s') % r['name']
 
-
             p = gcmd.Command(['r.info',
                               'map=%s' % r['name'],
                               '-u',
@@ -295,6 +297,7 @@
         #
         self.ylabel = ''
         i = 0
+        
         for r in self.raster.itervalues():
             if r['name'] == '':
                 continue
@@ -309,6 +312,7 @@
         #
         # create list of coordinates for transect segment markers
         #
+
         if len(self.mapwin.polycoords) > 0:
             for point in self.mapwin.polycoords:
                 # get value of raster cell at coordinate point
@@ -400,16 +404,18 @@
         Build a list of distance, value pairs for points along transect
         """
         datalist = []
+        import subprocess
+        
         try:
-            cmdlist = ['r.profile',
-                       'input=%s' % raster,
-                       'profile=%s' % coords,
-                       'null=nan',
-                       '--quiet']
-            p = gcmd.Command(cmdlist)
-            for outline in p.ReadStdOutput():
+            p = grass.read_command("r.profile",
+                       input=raster,
+                       profile=coords,
+                       null="nan",
+                       quiet=True
+                       )
+            for outline in p.strip().split('\n'):
                 dist, elev = outline.split(' ')
-                datalist.append((dist,elev))
+                if elev != 'nan': datalist.append((dist,elev))
 
             return datalist
         except gcmd.CmdError, e:
@@ -424,7 +430,7 @@
         segments, these are drawn as points. Profile transect is drawn, using
         methods in mapdisp.py
         """
-        
+    
         if len(self.mapwin.polycoords) == 0 or self.raster[0]['name'] == '':
             dlg = wx.MessageDialog(parent=self,
                                    message=_('You must draw a transect to profile in the map display window.'),

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py	2008-12-30 04:00:12 UTC (rev 35109)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py	2008-12-30 04:09:08 UTC (rev 35110)
@@ -1244,12 +1244,12 @@
                 
         # tool, label, bitmap, kind, shortHelp, longHelp, handler
         return   (
+            (self.addraster, 'raster', Icons["addrast"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["addrast"].GetLabel(), Icons["addrast"].GetDesc(),
+             self.parent.OnSelectRaster),
             (self.transect, 'transect', Icons["transect"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["transect"].GetLabel(), Icons["transect"].GetDesc(),
              self.parent.OnDrawTransect),
-            (self.addraster, 'raster', Icons["addrast"].GetBitmap(),
-             wx.ITEM_NORMAL, Icons["addrast"].GetLabel(), Icons["addrast"].GetDesc(),
-             self.parent.OnSelectRaster),
             (self.draw, 'profiledraw', Icons["profiledraw"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["profiledraw"].GetLabel(), Icons["profiledraw"].GetDesc(),
              self.parent.OnCreateProfile),



More information about the grass-commit mailing list