|
@@ -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"""
|