瀏覽代碼

wxGUI: fix histogramming / profile tools (launch from mapdisp)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@50323 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 年之前
父節點
當前提交
cd411d66a3

+ 17 - 20
gui/wxpython/lmgr/frame.py

@@ -1189,28 +1189,25 @@ class GMFrame(wx.Frame):
         
         win.Show()
         
-    def DispHistogram(self, event):
+    def OnHistogram(self, event):
+        """!Init histogram display canvas and tools
         """
-        Init histogram display canvas and tools
-        """
-        self.histogram = HistFrame(self, id = wx.ID_ANY, pos = wx.DefaultPosition, size = (400,300),
-                                   style = wx.DEFAULT_FRAME_STYLE)
-
-        #show new display
-        self.histogram.Show()
-        self.histogram.Refresh()
-        self.histogram.Update()
-
-    def DispProfile(self, event):
-        """
-        Init profile canvas and tools
+        win = HistogramFrame(self)
+        
+        win.CentreOnParent()
+        win.Show()
+        win.Refresh()
+        win.Update()
+        
+    def OnProfile(self, event):
+        """!Launch profile tool
         """
-        self.profile = profile.ProfileFrame(self,
-                                           id = wx.ID_ANY, pos = wx.DefaultPosition, size = (400,300),
-                                           style = wx.DEFAULT_FRAME_STYLE)
-        self.profile.Show()
-        self.profile.Refresh()
-        self.profile.Update()
+        win = profile.ProfileFrame(parent = self)
+        
+        win.CentreOnParent()
+        win.Show()
+        win.Refresh()
+        win.Update()
         
     def OnMapCalculator(self, event, cmd = ''):
         """!Init map calculator for interactive creation of mapcalc statements

+ 23 - 26
gui/wxpython/mapdisp/frame.py

@@ -980,19 +980,20 @@ class MapFrame(SingleMapFrame):
         return dist
 
     def OnProfile(self, event):
-        """!Init profile canvas and tools
+        """!Launch profile tool
         """
         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.profile = ProfileFrame(self, size = wx.Size(700, 300),
-                                    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)
+        win = ProfileFrame(parent = self, rasterList = raster)
+        
+        win.CentreOnParent()
+        win.Show()
+        # Open raster select dialog to make sure that a raster (and
+        # the desired raster) is selected to be profiled
+        win.OnSelectRaster(None)
 
     def FormatDist(self, dist):
         """!Format length numbers and units in a nice way,
@@ -1055,14 +1056,12 @@ class MapFrame(SingleMapFrame):
                 continue
             raster.append(self.tree.GetPyData(layer)[0]['maplayer'].GetName())
 
-        self.histogramPyPlot = Histogram2Frame(self, id = wx.ID_ANY, 
-                                               pos = wx.DefaultPosition, size = (700,300),
-                                               style = wx.DEFAULT_FRAME_STYLE, 
-                                               rasterList = raster)
-        self.histogramPyPlot.Show()
+        win = Histogram2Frame(parent = self, rasterList = raster)
+        win.CentreOnParent
+        win.Show()
         # Open raster select dialog to make sure that a raster (and the desired raster)
         # is selected to be histogrammed
-        self.histogramPyPlot.OnSelectRaster(None)
+        win.OnSelectRaster(None)
         
     def OnScatterplot(self, event):
         """!Init PyPlot scatterplot display canvas and tools
@@ -1073,26 +1072,24 @@ class MapFrame(SingleMapFrame):
             if self.tree.GetPyData(layer)[0]['maplayer'].GetType() != 'raster':
                 continue
             raster.append(self.tree.GetPyData(layer)[0]['maplayer'].GetName())
-
-        self.scatterplot = ScatterFrame(self, id = wx.ID_ANY, 
-                                                pos = wx.DefaultPosition, size = (700,300),
-                                                style = wx.DEFAULT_FRAME_STYLE, 
-                                                rasterList = raster)
-        self.scatterplot.Show()
+            
+        win = ScatterFrame(parent = self, rasterList = raster)
+        
+        win.CentreOnParent()
+        win.Show()
         # Open raster select dialog to make sure that at least 2 rasters (and the desired rasters)
         # are selected to be plotted
-        self.scatterplot.OnSelectRaster(None)
+        win.OnSelectRaster(None)
 
     def OnHistogram(self, event):
         """!Init histogram display canvas and tools
         """
-        self.histogram = HistogramFrame(parent = self, id = wx.ID_ANY, size = globalvar.HIST_WINDOW_SIZE,
-                                        style = wx.DEFAULT_FRAME_STYLE)
+        win = HistogramFrame(self)
         
-        # show new display
-        self.histogram.Show()
-        self.histogram.Refresh()
-        self.histogram.Update()
+        win.CentreOnParent()
+        win.Show()
+        win.Refresh()
+        win.Update()
        
     def OnAddBarscale(self, event):
         """!Handler for scale/arrow map decoration menu selection.

+ 2 - 1
gui/wxpython/modules/histogram.py

@@ -264,8 +264,9 @@ class HistogramFrame(wx.Frame):
     """
     def __init__(self, parent = None, id = wx.ID_ANY,
                  title = _("GRASS GIS Histogramming Tool (d.histogram)"),
+                 size = wx.Size(500, 350),
                  style = wx.DEFAULT_FRAME_STYLE, **kwargs):
-        wx.Frame.__init__(self, parent, id, title, style = style, **kwargs)
+        wx.Frame.__init__(self, parent, id, title, size = size, style = style, **kwargs)
         self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
         
         self.Map   = Map()         # instance of render.Map to be associated with display

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

@@ -46,7 +46,7 @@ PlotIcons = {
 
 class BasePlotFrame(wx.Frame):
     """!Abstract PyPlot display frame class"""
-    def __init__(self, parent = None, id = wx.ID_ANY, size = (700, 300),
+    def __init__(self, parent = 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)

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

@@ -28,10 +28,12 @@ from wxplot.dialogs    import HistRasterDialog, PlotStatsFrame
 from core.gcmd         import RunCommand, GException, GError
 
 class Histogram2Frame(BasePlotFrame):
-    def __init__(self, parent, id, pos, style, size, rasterList = []):
-        """!Mainframe for displaying histogram of raster map. Uses wx.lib.plot.
-        """
-        BasePlotFrame.__init__(self, parent)
+    """!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):
+        BasePlotFrame.__init__(self, parent, size = size, **kwargs)
         
         self.toolbar = Histogram2Toolbar(parent = self)
         self.SetToolBar(self.toolbar)

+ 2 - 1
gui/wxpython/wxplot/profile.py

@@ -43,8 +43,9 @@ 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, 
+                 size = wx.Size(700, 400),
                  rasterList = [], **kwargs):
-        BasePlotFrame.__init__(self, parent, **kwargs)
+        BasePlotFrame.__init__(self, parent, size = size, **kwargs)
 
         self.toolbar = ProfileToolbar(parent = self)
         self.SetToolBar(self.toolbar)

+ 4 - 3
gui/wxpython/wxplot/scatter.py

@@ -30,9 +30,10 @@ from core.gcmd         import RunCommand, GException, GError
 class ScatterFrame(BasePlotFrame):
     """!Mainframe for displaying bivariate scatter plot of two raster maps. Uses wx.lib.plot.
     """
-    def __init__(self, parent, id, pos, style, size, rasterList = []):
-
-        BasePlotFrame.__init__(self, parent)
+    def __init__(self, parent, id = wx.ID_ANY, style = wx.DEFAULT_FRAME_STYLE, 
+                 size = wx.Size(700, 400),
+                 rasterList = [], **kwargs):
+        BasePlotFrame.__init__(self, parent, size = size, **kwargs)
         
         self.toolbar = ScatterToolbar(parent = self)
         self.SetToolBar(self.toolbar)

+ 1 - 1
gui/wxpython/xml/menudata.xml

@@ -2626,7 +2626,7 @@
 	<menuitem>
 	  <label>Histogram</label>
 	  <help>Generate histogram of image</help>
-	  <handler>DispHistogram</handler>
+	  <handler>OnHistogram</handler>
 	</menuitem>
 	<menuitem>
 	  <label>Spectral response</label>