Browse Source

wxGUI: histogram component fixed (sync'ed with devbr6, https://trac.osgeo.org/grass/changeset/31410)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@31411 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 17 years ago
parent
commit
3dcb2a5304

+ 1 - 0
gui/wxpython/gui_modules/globalvar.py

@@ -81,6 +81,7 @@ DIALOG_GSELECT_SIZE = (400, -1)
 DIALOG_TEXTCTRL_SIZE = (400, -1)
 
 MAP_WINDOW_SIZE = (680, 520)
+HIST_WINDOW_SIZE = (500, 350)
 
 """File name extension binaries/scripts"""
 if subprocess.mswindows:

+ 16 - 16
gui/wxpython/gui_modules/histogram.py

@@ -35,6 +35,7 @@ sys.path.append(gmpath)
 import render
 import menuform
 import disp_print
+import utils
 from gui_modules.preferences import SetDefaultFont as SetDefaultFont
 from debug import Debug as Debug
 from icon import Icons as Icons
@@ -92,7 +93,10 @@ class BufferedWindow(wx.Window):
 
         self.pdc = wx.PseudoDC()
         self._Buffer = '' # will store an off screen empty bitmap for saving to file
-        self.Map.SetRegion() # make sure that extents are updated at init
+
+        # make sure that extents are updated at init
+        self.Map.region = self.Map.GetRegion()
+        self.Map.SetRegion() 
 
         self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x:None)
 
@@ -294,7 +298,7 @@ class HistFrame(wx.Frame):
         self.iconsize = (16, 16)
 
         # Init variables
-        self.params = {} # previously set histogram parameters
+        self.params = {}  # previously set histogram parameters
         self.propwin = '' # ID of properties dialog
 
         self.font = ""
@@ -371,24 +375,23 @@ class HistFrame(wx.Frame):
         self.Map.geom = self.width, self.height
 
     def OnOptions(self, event):
-        global gmpath
-        completed = ''
+        """Change histogram settings"""
 
-        menuform.GUI().ParseCommand(['d.histogram'], gmpath,
-                                    completed=(self.GetOptData, "hist", self.params),
-                                    parentframe=None)
+        cmd = ['d.histogram']
+        if self.mapname != '':
+            cmd.append('map=%s' % self.mapname)
 
+        menuform.GUI().ParseCommand(cmd,
+                                    completed=(self.GetOptData, None, self.params),
+                                    parentframe=self)
 
     def GetOptData(self, dcmd, layer, params, propwin):
         """
         Callback method for histogram command generated by
         dialog created in menuform.py
         """
-
-        # Reset comand and rendering options in render.Map. Always render decoration.
-        # Showing/hiding handled by PseudoDC
-
-        self.SetHistLayer(dcmd)
+        if dcmd:
+            self.SetHistLayer(dcmd)
         self.params = params
         self.propwin = propwin
 
@@ -398,10 +401,7 @@ class HistFrame(wx.Frame):
         """
         Set histogram layer
         """
-
-        for item in cmd:
-            if 'map=' in item:
-                self.mapname = item.split('=')[1]
+        self.mapname = utils.GetLayerNameFromCmd(cmd)
 
         self.layer = self.Map.ChangeLayer(layer=self.layer, type="command", name='histogram',
                                           command=cmd,

+ 1 - 1
gui/wxpython/gui_modules/mapdisp.py

@@ -3267,7 +3267,7 @@ class MapFrame(wx.Frame):
         Init histogram display canvas and tools
         """
         self.histogram = histogram.HistFrame(self,
-                                             id=wx.ID_ANY, pos=wx.DefaultPosition, size=(400,300),
+                                             id=wx.ID_ANY, size=globalvar.HIST_WINDOW_SIZE,
                                              style=wx.DEFAULT_FRAME_STYLE)
 
         #show new display

+ 1 - 1
gui/wxpython/gui_modules/wxgui_utils.py

@@ -370,7 +370,7 @@ class LayerTree(CT.CustomTreeCtrl):
         if not self.histogramFrame:
             self.histogramFrame = histogram.HistFrame(self,
                                                       id=wx.ID_ANY,
-                                                      pos=wx.DefaultPosition, size=(400, 300),
+                                                      pos=wx.DefaultPosition, size=globalvar.HIST_WINDOW_SIZE,
                                                       style=wx.DEFAULT_FRAME_STYLE)
             # show new display
             self.histogramFrame.Show()