소스 검색

wxGUI/mapcalc: fix 3D help, make overwrite option visible, find also interactive (3D) map calculator in command search

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@42247 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 15 년 전
부모
커밋
be36a6fb32
3개의 변경된 파일32개의 추가작업 그리고 16개의 파일을 삭제
  1. 16 12
      gui/wxpython/gui_modules/mcalc_builder.py
  2. 12 4
      gui/wxpython/wxgui.py
  3. 4 0
      gui/wxpython/xml/menudata.xml

+ 16 - 12
gui/wxpython/gui_modules/mcalc_builder.py

@@ -38,15 +38,22 @@ class MapCalcFrame(wx.Frame):
     r(3).mapcalc statements
     """
     def __init__(self, parent, id = wx.ID_ANY, title = _('Map calculator'), 
-                 rast3d = False, style = wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER, **kwargs):
+                 style = wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER, **kwargs):
         self.parent = parent
         if self.parent:
             self.log = self.parent.GetLogWindow()
         else:
             self.log = None
         
-        self.rast3d = rast3d
-        wx.Frame.__init__(self, parent, id = id, title = title, **kwargs)
+        # grass command
+        self.cmd = kwargs['cmd']
+
+        if self.cmd == 'r.mapcalc':
+            self.rast3d = False
+        if self.cmd == 'r3.mapcalc':
+            self.rast3d = True
+
+        wx.Frame.__init__(self, parent, id = id, title = title)
         self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
         
         self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
@@ -201,7 +208,7 @@ class MapCalcFrame(wx.Frame):
                                     style = wx.CB_DROPDOWN |
                                     wx.CB_READONLY | wx.TE_PROCESS_ENTER)
         
-        self.overwrite = wx.CheckBox(parent = self, id = wx.ID_ANY,
+        self.overwrite = wx.CheckBox(parent = self.panel, id = wx.ID_ANY,
                                      label=_("Allow output files to overwrite existing files"))
         self.overwrite.SetValue(UserSettings.Get(group='cmd', key='overwrite', subkey='enabled'))
         
@@ -308,7 +315,8 @@ class MapCalcFrame(wx.Frame):
         sizer.Add(item = expressSizer, proportion = 1,
                   flag = wx.EXPAND | wx.LEFT | wx.RIGHT,
                   border = 5)
-        sizer.Add(item = self.overwrite, flag = wx.EXPAND | wx.LEFT | wx.RIGHT,
+        sizer.Add(item = self.overwrite, proportion = 0,
+                  flag = wx.EXPAND | wx.LEFT | wx.RIGHT,
                       border = 5)
         sizer.Add(item = buttonSizer4, proportion = 0,
                   flag = wx.ALIGN_RIGHT | wx.ALL, border = 1)
@@ -400,13 +408,9 @@ class MapCalcFrame(wx.Frame):
         
         mctxt = self.text_mcalc.GetValue().strip().replace("\n"," ")
         mctxt = mctxt.replace(" " , "")
-        if self.rast3d:
-            prg = 'r3.mapcalc'
-        else:
-            prg = 'r.mapcalc'
 
         if self.log:
-            cmd = [prg, str('expression=%s = %s' % (name, mctxt))]
+            cmd = [self.cmd, str('expression=%s = %s' % (name, mctxt))]
             if self.overwrite.IsChecked():
                 cmd.append('--overwrite')
             self.log.RunCmd(cmd)
@@ -416,7 +420,7 @@ class MapCalcFrame(wx.Frame):
                 overwrite = True
             else:
                 overwrite = False
-            gcmd.RunCommand(prg,
+            gcmd.RunCommand(self.cmd,
                             expression = "%s=%s" % (name, mctxt),
                             overwrite = overwrite)
         
@@ -428,7 +432,7 @@ class MapCalcFrame(wx.Frame):
     def OnHelp(self, event):
         """!Launches r.mapcalc help
         """
-        gcmd.RunCommand('g.manual', entry = 'r.mapcalc')
+        gcmd.RunCommand('g.manual', parent = self, entry = self.cmd)
         
     def OnClose(self,event):
         """!Close window"""

+ 12 - 4
gui/wxpython/wxgui.py

@@ -956,18 +956,26 @@ class GMFrame(wx.Frame):
         self.profile.Refresh()
         self.profile.Update()
         
-    def OnMapCalculator(self, event):
+    def OnMapCalculator(self, event, cmd = ''):
         """!Init map calculator for interactive creation of mapcalc statements
         """
-        win = mapcalculator.MapCalcFrame(parent = self, title = _('GRASS GIS Map Calculator'))
+
+        if event:
+            cmd = self.GetMenuCmd(event)
+
+        win = mapcalculator.MapCalcFrame(parent = self, title = _('GRASS GIS Map Calculator'),
+                                         cmd=cmd[0])
         win.CentreOnScreen()
         win.Show()
         
-    def OnMapCalculator3D(self, event):
+    def OnMapCalculator3D(self, event, cmd =''):
         """!Init map calculator for interactive creation of mapcalc statements
         """
+        if event:
+            cmd = self.GetMenuCmd(event)
+
         win = mapcalculator.MapCalcFrame(parent = self, title = _('GRASS GIS Map Calculator (3D raster)'),
-                                         rast3d = True)
+                                         cmd=cmd[0])
         win.CentreOnScreen()
         win.Show()
         

+ 4 - 0
gui/wxpython/xml/menudata.xml

@@ -1006,7 +1006,9 @@
 	    <menuitem>
 	      <label>Interactive map calculator</label>
 	      <help>Map calculator for raster map algebra.</help>
+	      <keywords>raster,algebra</keywords>
 	      <handler>OnMapCalculator</handler>
+	      <command>r.mapcalc</command>
 	    </menuitem>
 	    <menuitem>
 	      <label>Map calculator</label>
@@ -2783,7 +2785,9 @@
 	    <menuitem>
 	      <label>Interactive map calculator</label>
 	      <help>Map calculator for raster map algebra.</help>
+	      <keywords>raster,algebra</keywords>
 	      <handler>OnMapCalculator3D</handler>
+	      <command>r3.mapcalc</command>
 	    </menuitem>
 	    <menuitem>
 	      <label>Map calculator</label>