[GRASS-SVN] r56430 - in grass/trunk/gui/wxpython: lmgr mapdisp wxplot
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 27 03:57:26 PDT 2013
Author: martinl
Date: 2013-05-27 03:57:25 -0700 (Mon, 27 May 2013)
New Revision: 56430
Modified:
grass/trunk/gui/wxpython/lmgr/layertree.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/wxplot/base.py
grass/trunk/gui/wxpython/wxplot/histogram.py
grass/trunk/gui/wxpython/wxplot/profile.py
Log:
wxGUI: contex menu for rasters - switch from d.histogram-based dialog to
HistogramPlotFrame
Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py 2013-05-27 08:50:58 UTC (rev 56429)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py 2013-05-27 10:57:25 UTC (rev 56430)
@@ -35,7 +35,7 @@
from gui_core.forms import GUI
from mapdisp.frame import MapFrame
from core.render import Map
-from modules.histogram import HistogramFrame
+from wxplot.histogram import HistogramPlotFrame
from core.utils import GetLayerNameFromCmd, ltype2command
from wxplot.profile import ProfileFrame
from core.debug import Debug
@@ -646,7 +646,7 @@
self.profileFrame = self.mapdisplay.profile
if not self.profileFrame:
- self.profileFrame = ProfileFrame(parent = self.mapdisplay,
+ self.profileFrame = ProfileFrame(parent = self.mapdisplay, mapwindow = self.mapdisplay.GetMapWindow(),
rasterList = [mapLayer.GetName()])
# show new display
self.profileFrame.Show()
@@ -673,15 +673,12 @@
"raster map. No map name defined."))
return
- win = HistogramFrame(parent = self)
+ win = HistogramPlotFrame(parent = self, rasterList = [mapLayer.GetName()])
win.CentreOnScreen()
win.Show()
- win.SetHistLayer(mapLayer.GetName())
- win.HistWindow.UpdateHist()
- win.Refresh()
- win.Update()
-
+ win.OnSelectRaster(None)
+
def OnUnivariateStats(self, event):
"""!Univariate raster statistics"""
name = self.GetLayerInfo(self.layer_selected, key = 'maplayer').GetName()
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2013-05-27 08:50:58 UTC (rev 56429)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2013-05-27 10:57:25 UTC (rev 56430)
@@ -52,7 +52,7 @@
from mapdisp.mapwindow import BufferedWindow
from mapdisp.overlays import LegendController, BarscaleController
from modules.histogram import HistogramFrame
-from wxplot.histogram import Histogram2Frame
+from wxplot.histogram import HistogramPlotFrame
from wxplot.profile import ProfileFrame
from wxplot.scatter import ScatterFrame
@@ -955,7 +955,7 @@
if layer.type == 'raster':
rasters.append(layer.maplayer.name)
- win = ProfileFrame(parent = self, rasterList = rasters)
+ win = ProfileFrame(parent = self, mapwindow = self.GetMapWindow(), rasterList = rasters)
win.CentreOnParent()
win.Show()
@@ -1023,7 +1023,7 @@
if layer.maplayer.GetType() == 'raster':
raster.append(layer.maplayer.GetName())
- win = Histogram2Frame(parent = self, rasterList = raster)
+ win = HistogramPlotFrame(parent = self, rasterList = raster)
win.CentreOnParent()
win.Show()
# Open raster select dialog to make sure that a raster (and the desired raster)
Modified: grass/trunk/gui/wxpython/wxplot/base.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/base.py 2013-05-27 08:50:58 UTC (rev 56429)
+++ grass/trunk/gui/wxpython/wxplot/base.py 2013-05-27 10:57:25 UTC (rev 56430)
@@ -46,13 +46,13 @@
class BasePlotFrame(wx.Frame):
"""!Abstract PyPlot display frame class"""
- def __init__(self, parent = None, id = wx.ID_ANY, size = wx.Size(700, 400),
+ def __init__(self, parent = None, mapwindow = None, id = wx.ID_ANY, size = wx.Size(700, 400),
style = wx.DEFAULT_FRAME_STYLE, rasterList = [], **kwargs):
wx.Frame.__init__(self, parent, id, size = size, style = style, **kwargs)
- self.parent = parent # MapFrame for a plot type
- self.mapwin = self.parent.MapWindow
+ self.parent = parent # MapFrame for a plot type
+ self.mapwin = mapwindow
self.Map = Map() # instance of render.Map to be associated with display
self.rasterList = rasterList #list of rasters to plot
self.raster = {} # dictionary of raster maps and their plotting parameters
@@ -577,7 +577,8 @@
self.mapwin.UpdateMap(render = False, renderVector = False)
except:
pass
-
- self.mapwin.SetCursor(self.Parent.cursors["default"])
+
+ if self.mapwin:
+ self.mapwin.SetCursor(self.Parent.cursors["default"])
self.Destroy()
Modified: grass/trunk/gui/wxpython/wxplot/histogram.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/histogram.py 2013-05-27 08:50:58 UTC (rev 56429)
+++ grass/trunk/gui/wxpython/wxplot/histogram.py 2013-05-27 10:57:25 UTC (rev 56430)
@@ -4,8 +4,8 @@
@brief Histogramming using PyPlot
Classes:
- - histogram::Histogram2Frame
- - histogram::Histogram2Toolbar
+ - histogram::HistogramPlotFrame
+ - histogram::HistogramPlotToolbar
(C) 2011 by the GRASS Development Team
@@ -27,18 +27,17 @@
from wxplot.dialogs import HistRasterDialog, PlotStatsFrame
from core.gcmd import RunCommand, GException, GError
-class Histogram2Frame(BasePlotFrame):
+class HistogramPlotFrame(BasePlotFrame):
"""!Mainframe for displaying histogram of raster map. Uses wx.lib.plot.
"""
def __init__(self, parent, id = wx.ID_ANY, style = wx.DEFAULT_FRAME_STYLE,
- size = wx.Size(700, 400),
- rasterList = [], **kwargs):
+ size = wx.Size(700, 400), rasterList = [], **kwargs):
BasePlotFrame.__init__(self, parent, size = size, **kwargs)
- self.toolbar = Histogram2Toolbar(parent = self)
+ self.toolbar = HistogramPlotToolbar(parent = self)
self.SetToolBar(self.toolbar)
self.SetTitle(_("GRASS Histogramming Tool"))
-
+
#
# Init variables
#
@@ -51,12 +50,12 @@
self.maptype = 'raster' # default type of histogram to plot
self.histtype = 'count'
self.bins = 255
- self.colorList = ["blue", "green", "red", "yellow", "magenta", "cyan", \
- "aqua", "black", "grey", "orange", "brown", "purple", "violet", \
- "indigo"]
+ self.colorList = ["blue", "green", "red", "yellow", "magenta", "cyan",
+ "aqua", "black", "grey", "orange", "brown", "purple", "violet",
+ "indigo"]
self._initOpts()
-
+
if len(self.rasterList) > 0: # set raster name(s) from layer manager if a map is selected
self.InitRasterOpts(self.rasterList, self.plottype)
else:
@@ -72,7 +71,11 @@
create a list of cell value and count/percent/area pairs. This is passed to
plot to create a line graph of the histogram.
"""
- self.SetCursor(self.parent.cursors["default"])
+ try:
+ self.SetCursor(self.parent.cursors["default"])
+ except:
+ pass
+
self.SetGraphStyle()
self.SetupHistogram()
p = self.CreatePlotList()
@@ -232,7 +235,7 @@
if stats.Show() == wx.ID_CLOSE:
stats.Destroy()
-class Histogram2Toolbar(BaseToolbar):
+class HistogramPlotToolbar(BaseToolbar):
"""!Toolbar for histogramming raster map
"""
def __init__(self, parent):
Modified: grass/trunk/gui/wxpython/wxplot/profile.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/profile.py 2013-05-27 08:50:58 UTC (rev 56429)
+++ grass/trunk/gui/wxpython/wxplot/profile.py 2013-05-27 10:57:25 UTC (rev 56430)
@@ -42,10 +42,10 @@
class ProfileFrame(BasePlotFrame):
"""!Mainframe for displaying profile of one or more raster maps. Uses wx.lib.plot.
"""
- def __init__(self, parent, id = wx.ID_ANY, style = wx.DEFAULT_FRAME_STYLE,
+ def __init__(self, parent, mapwindow, id = wx.ID_ANY, style = wx.DEFAULT_FRAME_STYLE,
size = wx.Size(700, 400),
rasterList = [], **kwargs):
- BasePlotFrame.__init__(self, parent, size = size, **kwargs)
+ BasePlotFrame.__init__(self, parent, mapwindow = mapwindow, size = size, **kwargs)
self.toolbar = ProfileToolbar(parent = self)
self.SetToolBar(self.toolbar)
More information about the grass-commit
mailing list