|
@@ -147,6 +147,8 @@ class MapCalcFrame(wx.Frame):
|
|
self.btn_load = wx.Button(parent = self.panel, id = wx.ID_ANY,
|
|
self.btn_load = wx.Button(parent = self.panel, id = wx.ID_ANY,
|
|
label = _("&Load"))
|
|
label = _("&Load"))
|
|
self.btn_load.SetToolTipString(_('Load expression from file'))
|
|
self.btn_load.SetToolTipString(_('Load expression from file'))
|
|
|
|
+ self.btn_copy = wx.Button(parent=self.panel, id=wx.ID_COPY)
|
|
|
|
+ self.btn_copy.SetToolTipString(_("Copy the current command string to the clipboard"))
|
|
|
|
|
|
self.btn = dict()
|
|
self.btn = dict()
|
|
self.btn['pow'] = wx.Button(parent = self.panel, id = wx.ID_ANY, label = "^")
|
|
self.btn['pow'] = wx.Button(parent = self.panel, id = wx.ID_ANY, label = "^")
|
|
@@ -253,12 +255,14 @@ class MapCalcFrame(wx.Frame):
|
|
self.btn_help.Bind(wx.EVT_BUTTON, self.OnHelp)
|
|
self.btn_help.Bind(wx.EVT_BUTTON, self.OnHelp)
|
|
self.btn_save.Bind(wx.EVT_BUTTON, self.OnSaveExpression)
|
|
self.btn_save.Bind(wx.EVT_BUTTON, self.OnSaveExpression)
|
|
self.btn_load.Bind(wx.EVT_BUTTON, self.OnLoadExpression)
|
|
self.btn_load.Bind(wx.EVT_BUTTON, self.OnLoadExpression)
|
|
|
|
+ self.btn_copy.Bind(wx.EVT_BUTTON, self.OnCopy)
|
|
|
|
|
|
self.mapselect.Bind(wx.EVT_TEXT, self.OnSelectTextEvt)
|
|
self.mapselect.Bind(wx.EVT_TEXT, self.OnSelectTextEvt)
|
|
self.function.Bind(wx.EVT_COMBOBOX, self._return_funct)
|
|
self.function.Bind(wx.EVT_COMBOBOX, self._return_funct)
|
|
self.function.Bind(wx.EVT_TEXT_ENTER, self.OnSelect)
|
|
self.function.Bind(wx.EVT_TEXT_ENTER, self.OnSelect)
|
|
self.newmaptxt.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
|
|
self.newmaptxt.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
|
|
self.text_mcalc.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
|
|
self.text_mcalc.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
|
|
|
|
+ self.overwrite.Bind(wx.EVT_CHECKBOX, self.OnUpdateStatusBar)
|
|
|
|
|
|
self._layout()
|
|
self._layout()
|
|
|
|
|
|
@@ -335,6 +339,8 @@ class MapCalcFrame(wx.Frame):
|
|
flag = wx.ALL, border = 5)
|
|
flag = wx.ALL, border = 5)
|
|
buttonSizer4.Add(item = self.btn_save,
|
|
buttonSizer4.Add(item = self.btn_save,
|
|
flag = wx.ALL, border = 5)
|
|
flag = wx.ALL, border = 5)
|
|
|
|
+ buttonSizer4.Add(item = self.btn_copy,
|
|
|
|
+ flag = wx.ALL, border = 5)
|
|
buttonSizer4.AddSpacer(30)
|
|
buttonSizer4.AddSpacer(30)
|
|
buttonSizer4.Add(item = self.btn_help,
|
|
buttonSizer4.Add(item = self.btn_help,
|
|
flag = wx.ALL, border = 5)
|
|
flag = wx.ALL, border = 5)
|
|
@@ -442,14 +448,23 @@ class MapCalcFrame(wx.Frame):
|
|
|
|
|
|
def OnUpdateStatusBar(self, event):
|
|
def OnUpdateStatusBar(self, event):
|
|
"""!Update statusbar text"""
|
|
"""!Update statusbar text"""
|
|
|
|
+ command = self._getCommand()
|
|
|
|
+ self.SetStatusText(command)
|
|
|
|
+ event.Skip()
|
|
|
|
+
|
|
|
|
+ def _getCommand(self):
|
|
|
|
+ """!Returns entire command as string."""
|
|
expr = self.text_mcalc.GetValue().strip().replace("\n", " ")
|
|
expr = self.text_mcalc.GetValue().strip().replace("\n", " ")
|
|
cmd = 'r.mapcalc'
|
|
cmd = 'r.mapcalc'
|
|
if self.rast3d:
|
|
if self.rast3d:
|
|
cmd = 'r3.mapcalc'
|
|
cmd = 'r3.mapcalc'
|
|
- self.SetStatusText("{cmd} '{new} = {expr}'".format(cmd=cmd, expr=expr,
|
|
|
|
- new=self.newmaptxt.GetValue()))
|
|
|
|
- event.Skip()
|
|
|
|
-
|
|
|
|
|
|
+ overwrite = ''
|
|
|
|
+ if self.overwrite.IsChecked():
|
|
|
|
+ overwrite = ' --overwrite'
|
|
|
|
+ return '{cmd} "{new} = {expr}"{overwrite}'.format(cmd=cmd, expr=expr,
|
|
|
|
+ new=self.newmaptxt.GetValue(),
|
|
|
|
+ overwrite=overwrite)
|
|
|
|
+
|
|
def _addSomething(self, what):
|
|
def _addSomething(self, what):
|
|
"""!Inserts operators, map names, and functions into text area
|
|
"""!Inserts operators, map names, and functions into text area
|
|
"""
|
|
"""
|
|
@@ -583,7 +598,16 @@ class MapCalcFrame(wx.Frame):
|
|
self.text_mcalc.SetInsertionPointEnd()
|
|
self.text_mcalc.SetInsertionPointEnd()
|
|
|
|
|
|
dlg.Destroy()
|
|
dlg.Destroy()
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ def OnCopy(self, event):
|
|
|
|
+ command = self._getCommand()
|
|
|
|
+ cmddata = wx.TextDataObject()
|
|
|
|
+ cmddata.SetText(command)
|
|
|
|
+ if wx.TheClipboard.Open():
|
|
|
|
+ wx.TheClipboard.SetData(cmddata)
|
|
|
|
+ wx.TheClipboard.Close()
|
|
|
|
+ self.SetStatusText(_("'{cmd}' copied to clipboard").format(cmd=command))
|
|
|
|
+
|
|
def OnClear(self, event):
|
|
def OnClear(self, event):
|
|
"""!Clears text area
|
|
"""!Clears text area
|
|
"""
|
|
"""
|