Просмотр исходного кода

wxgui plots: bug fixing, error trapping, updating

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@49467 15284696-431f-4ddb-bdfa-cd5b030d7da7
Michael Barton 13 лет назад
Родитель
Сommit
0baa86e8b7

+ 13 - 13
gui/wxpython/wxplot/base.py

@@ -170,10 +170,10 @@ class BasePlotFrame(wx.Frame):
                
             self.raster[r] = UserSettings.Get(group = plottype, key = 'raster') # some default settings
             rdict[r] = {} # initialize sub-dictionaries for each raster in the list
+
             
-            if ret['units'] in ('(none)', '"none"', '', None):
-                rdict[r]['units'] = ''
-            else:
+            rdict[r]['units'] = ''
+            if ret['units'] not in ('(none)', '"none"', '', None):
                 rdict[r]['units'] = ret['units']
             
             rdict[r]['plegend'] = r.split('@')[0]
@@ -202,6 +202,7 @@ class BasePlotFrame(wx.Frame):
 
         rdict = {} # initialize a dictionary
         for rpair in rasterList:
+            print 'rpair = ' + str(rpair)
             idx = rasterList.index(rpair)
             
             try:
@@ -216,17 +217,14 @@ class BasePlotFrame(wx.Frame):
             rdict[rpair] = {} # initialize sub-dictionaries for each raster in the list
             rdict[rpair][0] = {}
             rdict[rpair][1] = {}
+            rdict[rpair][0]['units'] = ''
+            rdict[rpair][1]['units'] = ''
 
-            if ret0['units'] in ('(none)', '"none"', '', None):
-                rdict[rpair][0]['units'] = ''
-            else:
-                self.raster[rpair][0]['units'] = ret0['units']
-
-            if ret1['units'] in ('(none)', '"none"', '', None):
-                rdict[rpair][1]['units'] = ''
-            else:
-                self.raster[rpair][1]['units'] = ret1['units']
-
+            if ret0['units'] not in ('(none)', '"none"', '', None):
+                rdict[rpair][0]['units'] = ret0['units']
+            if ret1['units'] not in ('(none)', '"none"', '', None):
+                rdict[rpair][1]['units'] = ret1['units']
+                
             rdict[rpair]['plegend'] = rpair[0].split('@')[0] + ' vs ' + rpair[1].split('@')[0]
             rdict[rpair]['datalist'] = [] # list of cell value,frequency pairs for plotting histogram
             rdict[rpair]['ptype'] = 'dot'
@@ -242,6 +240,8 @@ class BasePlotFrame(wx.Frame):
                 b = randint(0, 255)
                 g = randint(0, 255)
                 rdict[rpair]['pcolor'] = ((r,g,b,255))
+
+        print 'rdict =' + str(rdict)
             
         return rdict
 

+ 6 - 1
gui/wxpython/wxplot/dialogs.py

@@ -469,8 +469,13 @@ class HistRasterDialog(wx.Dialog):
                                   group = '%s' % self.group, 
                                   quiet = True,
                                   flags = 'g').strip().split('\n')
-        if ret != None and ret != '':
+
+        if ret not in [None, '', ['']]:
             self.rasterList = ret
+        else:
+            wx.MessageBox(message = _("Selected group must be in current mapset"), 
+                          caption = _('Invalid input'), 
+                          style = wx.OK|wx.ICON_ERROR)
                                                                                             
     def OnSetBins(self, event):
         """!Bins for histogramming FP maps (=nsteps in r.stats)

+ 6 - 1
gui/wxpython/wxplot/histogram.py

@@ -152,13 +152,18 @@ class Histogram2Frame(BasePlotFrame):
                              read = True)
             
             if not ret:
+                print 'in stats loop'
                 return datalist
             
             for line in ret.splitlines():
                 cellval, histval = line.strip().split(',')
                 histval = histval.strip()
                 if self.raster[raster]['datatype'] != 'CELL':
-                    cellval = cellval.split('-')[0]
+                    if cellval[0] == '-':
+                        cellval = '-' + cellval.split('-')[1]
+                    else:
+                        cellval = cellval.split('-')[0]
+                    
                 if self.histtype == 'percent':
                     histval = histval.rstrip('%')
                     

+ 20 - 10
gui/wxpython/wxplot/scatter.py

@@ -140,17 +140,18 @@ class ScatterFrame(BasePlotFrame):
         #
         # set xlabel & ylabel based on raster maps of first pair to be plotted
         #
+        self.xlabel = _('Raster cell values')
+        self.ylabel = _('Raster cell values') 
+        
         units = self.raster[self.rasterList[0]][0]['units']
-        if units != '' and units != '(none)' and units != None:
-            self.xlabel = _('Raster cell values %s') % units
-        else:
-            self.xlabel = _('Raster cell values') 
+        if units != '':
+            self.xlabel += _(': %s') % units
 
         units = self.raster[self.rasterList[0]][1]['units']
-        if units != '' and units != '(none)' and units != None:
-            self.ylabel = _('Raster cell values %s') % units
-        else:
-            self.ylabel = _('Raster cell values') 
+        if units != '':
+            self.ylabel += _(': %s') % units
+            
+        print 'axis labels = ' + ' x:' + self.xlabel + ' y:' + self.ylabel
 
     def CreateDatalist(self, rpair):
         """!Build a list of cell value, frequency pairs for histogram
@@ -179,9 +180,18 @@ class ScatterFrame(BasePlotFrame):
             for line in ret.splitlines():
                 rast1, rast2 = line.strip().split(',')
                 rast1 = rast1.strip()
-                if '-' in rast1: rast1 = rast1.split('-')[0]
+                if '-' in rast1:
+                    if rast1[0] == '-':
+                        rast1 = '-' + rast1.split('-')[1]
+                    else:
+                        rast1 = rast1.split('-')[0]
+
                 rast2 = rast2.strip()
-                if '-' in rast2: rast2 = rast2.split('-')[0]
+                if '-' in rast2:
+                    if rast2[0] == '-':
+                        rast2 = '-' + rast2.split('-')[1]
+                    else:
+                        rast2 = rast2.split('-')[0]
                 
                 rast1 = rast1.encode('ascii', 'ignore')
                 rast2 = rast2.encode('ascii', 'ignore')