[GRASS-SVN] r51772 - grass/branches/develbranch_6/gui/wxpython/modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 26 07:28:15 EDT 2012


Author: annakrat
Date: 2012-05-26 04:28:15 -0700 (Sat, 26 May 2012)
New Revision: 51772

Modified:
   grass/branches/develbranch_6/gui/wxpython/modules/histogram.py
Log:
wxGUI: fix histogram tool (the one using the d.histogram) (merged from trunk, r51753)

Modified: grass/branches/develbranch_6/gui/wxpython/modules/histogram.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/modules/histogram.py	2012-05-26 11:24:15 UTC (rev 51771)
+++ grass/branches/develbranch_6/gui/wxpython/modules/histogram.py	2012-05-26 11:28:15 UTC (rev 51772)
@@ -282,8 +282,15 @@
         self.toolbar = HistogramToolbar(parent = self)
         self.SetToolBar(self.toolbar)
 
+        # find selected map
+        self.mapname = None
+        if not parent.IsStandalone():
+            tree = parent.GetLayerManager().GetLayerTree()
+
+            if tree.layer_selected and tree.GetPyData(tree.layer_selected)[0]['type'] == 'raster':
+                self.mapname = tree.GetPyData(tree.layer_selected)[0]['maplayer'].name
+
         # Add statusbar
-        self.mapname = ''
         self.statusbar = self.CreateStatusBar(number = 1, style = 0)
         # self.statusbar.SetStatusWidths([-2, -1])
         hist_frame_statusbar_fields = ["Histogramming %s" % self.mapname]
@@ -305,7 +312,11 @@
         # Add layer to the map
         self.layer = self.Map.AddLayer(type = "command", name = 'histogram', command = ['d.histogram'],
                                        l_active = False, l_hidden = False, l_opacity = 1, l_render = False)
-        
+        if self.mapname:
+            self.SetHistLayer(self.mapname, None)
+        else:
+            self.OnErase(None)
+
     def InitDisplay(self):
         """!Initialize histogram display, set dimensions and region
         """
@@ -317,10 +328,9 @@
         cmd = ['d.histogram']
         if self.mapname != '':
             cmd.append('map=%s' % self.mapname)
-        
-        GUI(parent = self).ParseCommand(cmd,
-                                        completed = (self.GetOptData, None, self.params))
-        
+        module = GUI(parent = self)
+        module.ParseCommand(cmd, completed = (self.GetOptData, None, self.params))
+
     def GetOptData(self, dcmd, layer, params, propwin):
         """!Callback method for histogram command generated by dialog
         created in menuform.py
@@ -333,19 +343,19 @@
                        message = _("Raster map <%s> not found") % name)
                 return
             
-            self.SetHistLayer(name)
+            self.SetHistLayer(name, dcmd)
         self.params = params
         self.propwin = propwin
-        
         self.HistWindow.UpdateHist()
         
-    def SetHistLayer(self, name):
+    def SetHistLayer(self, name, cmd = None):
         """!Set histogram layer
         """
         self.mapname = name
-        
+        if not cmd:
+            cmd = ['d.histogram',('map=%s' % self.mapname)]
         self.layer = self.Map.ChangeLayer(layer = self.layer,
-                                          command = [['d.histogram', 'map=%s' % self.mapname],],
+                                          command = [cmd],
                                           active = True)
         
         return self.layer



More information about the grass-commit mailing list