[GRASS-SVN] r48410 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Sep 22 11:22:35 EDT 2011
Author: martinl
Date: 2011-09-22 08:22:35 -0700 (Thu, 22 Sep 2011)
New Revision: 48410
Modified:
grass/trunk/gui/wxpython/gui_modules/histogram2.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
Log:
wxGUI: fix calling Histogram and HistogramPyPlot
Modified: grass/trunk/gui/wxpython/gui_modules/histogram2.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/histogram2.py 2011-09-22 13:26:28 UTC (rev 48409)
+++ grass/trunk/gui/wxpython/gui_modules/histogram2.py 2011-09-22 15:22:35 UTC (rev 48410)
@@ -57,7 +57,7 @@
"standard Python distribution). See the Numeric Python site "
"(http://numpy.scipy.org) for information on downloading source or "
"binaries.")
- print >> sys.stderr, "profile.py: " + msg
+ print >> sys.stderr, "histogram2.py: " + msg
class HistFrame(wx.Frame):
"""!Mainframe for displaying profile of raster map. Uses wx.lib.plot.
@@ -377,15 +377,16 @@
try:
ret = gcmd.RunCommand("r.stats",
- input=raster,
- flags=freqflag,
- nsteps=self.bins,
- fs=',',
- quiet=True,
- read = True)
+ parent = self,
+ input=raster,
+ flags=freqflag,
+ nsteps=self.bins,
+ fs=',',
+ quiet = True,
+ read = True)
if not ret:
- return dataset
+ return datalist
for line in ret.splitlines():
cellval, histval = line.strip().split(',')
@@ -1376,4 +1377,4 @@
def OnCancel(self, event):
"""!Button 'Cancel' pressed"""
self.Close()
-
\ No newline at end of file
+
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-09-22 13:26:28 UTC (rev 48409)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-09-22 15:22:35 UTC (rev 48410)
@@ -45,8 +45,6 @@
import gcmd
import dbm
import dbm_dialogs
-import histogram
-import histogram2
import profile
import globalvar
import utils
@@ -56,7 +54,8 @@
from preferences import globalSettings as UserSettings
from mapdisp_window import BufferedWindow
-
+from histogram import HistFrame
+from histogram2 import HistFrame as HistFramePyPlot
from grass.script import core as grass
# for standalone app
@@ -1544,12 +1543,12 @@
histogram2 = wx.MenuItem(toolsmenu, wx.ID_ANY, _("Create histogram with PyPlot"))
histogram2.SetBitmap(icons["histogram"].GetBitmap(self.iconsize))
toolsmenu.AppendItem(histogram2)
- self.Bind(wx.EVT_MENU, self.Histogram2, histogram2)
+ self.Bind(wx.EVT_MENU, self.OnHistogramPyPlot, histogram2)
histogram = wx.MenuItem(toolsmenu, wx.ID_ANY, icons["histogram"].GetLabel())
histogram.SetBitmap(icons["histogram"].GetBitmap(self.iconsize))
toolsmenu.AppendItem(histogram)
- self.Bind(wx.EVT_MENU, self.Histogram, histogram)
+ self.Bind(wx.EVT_MENU, self.OnHistogram, histogram)
# Popup the menu. If an item is selected then its handler
# will be called before PopupMenu returns.
@@ -1704,33 +1703,35 @@
return (outdist, outunits)
- def Histogram(self, event):
+ def OnHistogramPyPlot(self, event):
"""!Init PyPlot histogram display canvas and tools
"""
raster = []
- if self.tree.layer_selected and \
- self.tree.GetPyData(self.tree.layer_selected)[0]['type'] == 'raster':
- raster.append(self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].name)
-
- self.histogram2 = histogram2.HistFrame(self,
- id = wx.ID_ANY, pos = wx.DefaultPosition, size = (700,300),
- style = wx.DEFAULT_FRAME_STYLE, rasterList = raster)
- self.histogram2.Show()
- # Open raster select dialog to make sure that a raster (and the desired raster)
- # is selected to be histogrammed
- self.histogram2.OnSelectRaster(None)
-
- def Histogram2(self, event):
+ for layer in self.tree.GetSelections():
+ if self.tree.GetPyData(layer)[0]['maplayer'].GetType() != 'raster':
+ continue
+ raster.append(self.tree.GetPyData(layer)[0]['maplayer'].GetName())
+ print raster
+ self.histogramPyPlot = HistFramePyPlot(parent = self, id = wx.ID_ANY, size = globalvar.HIST_WINDOW_SIZE,
+ style = wx.DEFAULT_FRAME_STYLE, rasterList = raster)
+ self.histogramPyPlot.Show()
+ # Open raster select dialog to make sure that a raster (and
+ # the desired raster) is selected to be histogrammed
+ if not raster:
+ self.histogramPyPlot.OnSelectRaster(None)
+ else:
+ self.histogramPyPlot.OnCreateHist(None)
+
+ def OnHistogram(self, event):
"""!Init histogram display canvas and tools
"""
- self.histogram2 = histogram2.HistFrame(self,
- id = wx.ID_ANY, size = globalvar.HIST_WINDOW_SIZE,
- style = wx.DEFAULT_FRAME_STYLE)
-
- #show new display
- self.histogram2.Show()
- self.histogram2.Refresh()
-
+ self.histogram = HistFrame(parent = self, id = wx.ID_ANY, size = globalvar.HIST_WINDOW_SIZE,
+ style = wx.DEFAULT_FRAME_STYLE)
+
+ # show new display
+ self.histogram.Show()
+ self.histogram.Refresh()
+
def OnDecoration(self, event):
"""!Decorations overlay menu
"""
More information about the grass-commit
mailing list