[GRASS-SVN] r46839 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 29 06:29:14 EDT 2011
Author: lucadelu
Date: 2011-06-29 03:29:14 -0700 (Wed, 29 Jun 2011)
New Revision: 46839
Modified:
grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py
Log:
braces handling improvement; logical workflow improvement for functions
Modified: grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py 2011-06-29 10:05:38 UTC (rev 46838)
+++ grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py 2011-06-29 10:29:14 UTC (rev 46839)
@@ -67,47 +67,47 @@
# variables
#
self.heading = _('mapcalc statement')
- self.funct_list = [
- 'abs(x)',
- 'acos(x)',
- 'asin(x)',
- 'atan(x)',
- 'atan(x,y)',
- 'cos(x)',
- 'double(x)',
- 'eval([x,y,...,]z)',
- 'exp(x)',
- 'exp(x,y)',
- 'float(x)',
- 'graph(x,x1,y1[x2,y2..])',
- 'if(x)',
- 'if(x,a)',
- 'if(x,a,b)',
- 'if(x,a,b,c)',
- 'int(x)',
- 'isnull(x)',
- 'log(x)',
- 'log(x,b)',
- 'max(x,y[,z...])',
- 'median(x,y[,z...])',
- 'min(x,y[,z...])',
- 'mode(x,y[,z...])',
- 'not(x)',
- 'pow(x,y)',
- 'rand(a,b)',
- 'round(x)',
- 'sin(x)',
- 'sqrt(x)',
- 'tan(x)',
- 'xor(x,y)',
- 'row()',
- 'col()',
- 'x()',
- 'y()',
- 'ewres()',
- 'nsres()',
- 'null()'
- ]
+ self.funct_dict = {
+ 'abs(x)':'abs()',
+ 'acos(x)':'acos()',
+ 'asin(x)':'asin()',
+ 'atan(x)':'atan()',
+ 'atan(x,y)':'atan( , )',
+ 'cos(x)':'cos()',
+ 'double(x)':'double()',
+ 'eval([x,y,...,]z)':'eval()',
+ 'exp(x)':'exp()',
+ 'exp(x,y)':'exp( , )',
+ 'float(x)':'float()',
+ 'graph(x,x1,y1[x2,y2..])':'graph( , , )',
+ 'if(x)':'if()',
+ 'if(x,a)':'if( , )',
+ 'if(x,a,b)':'if( , , )',
+ 'if(x,a,b,c)':'if( , , , )',
+ 'int(x)':'if()',
+ 'isnull(x)':'isnull()',
+ 'log(x)':'log(',
+ 'log(x,b)':'log( , )',
+ 'max(x,y[,z...])':'max( , )',
+ 'median(x,y[,z...])':'median( , )',
+ 'min(x,y[,z...])':'min( , )',
+ 'mode(x,y[,z...])':'mode( , )',
+ 'not(x)':'not()',
+ 'pow(x,y)':'pow( , )',
+ 'rand(a,b)':'rand( , )',
+ 'round(x)':'round()',
+ 'sin(x)':'sin()',
+ 'sqrt(x)':'sqrt()',
+ 'tan(x)':'tan()',
+ 'xor(x,y)':'xor( , )',
+ 'row()':'row()',
+ 'col()':'col()',
+ 'x()':'x()',
+ 'y()':'y()',
+ 'ewres()':'ewres()',
+ 'nsres()':'nsres()',
+ 'null()':'null()'
+ }
if self.rast3d:
indx = self.funct_list.index('y()') +1
@@ -156,8 +156,8 @@
self.btn['mult'] = wx.Button(parent = self.panel, id = wx.ID_ANY, label = "*")
self.btn['mult'].SetToolTipString(_('multiply'))
- self.btn['paren'] = wx.Button(parent = self.panel, id = wx.ID_ANY, label = "( )")
-
+ self.btn['parenl'] = wx.Button(parent = self.panel, id = wx.ID_ANY, label = "(")
+ self.btn['parenr'] = wx.Button(parent = self.panel, id = wx.ID_ANY, label = ")")
self.btn['lshift'] = wx.Button(parent = self.panel, id = wx.ID_ANY, label = "<<")
self.btn['lshift'].SetToolTipString(_('left shift'))
self.btn['rshift'] = wx.Button(parent = self.panel, id = wx.ID_ANY, label = ">>")
@@ -221,7 +221,7 @@
self.functlabel = wx.StaticText(parent = self.panel, id = wx.ID_ANY,
label = _('Insert mapcalc function'))
self.function = wx.ComboBox(parent = self.panel, id = wx.ID_ANY,
- size = (250, -1), choices = self.funct_list,
+ size = (250, -1), choices = self.funct_dict.keys(),
style = wx.CB_DROPDOWN |
wx.CB_READONLY | wx.TE_PROCESS_ENTER)
@@ -250,7 +250,7 @@
self.btn_load.Bind(wx.EVT_BUTTON, self.OnLoadExpression)
self.mapselect.Bind(wx.EVT_TEXT, self.OnSelect)
- self.function.Bind(wx.EVT_COMBOBOX, self.OnSelect)
+ self.function.Bind(wx.EVT_COMBOBOX, self._return_funct)
self.function.Bind(wx.EVT_TEXT_ENTER, self.OnSelect)
self.newmaptxt.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
self.text_mcalc.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
@@ -258,7 +258,11 @@
self._layout()
self.SetMinSize(self.GetBestSize())
-
+
+ def _return_funct(self,event):
+ i = event.GetString()
+ self._addSomething(self.funct_dict[i])
+
def _layout(self):
sizer = wx.BoxSizer(wx.VERTICAL)
@@ -296,24 +300,28 @@
operandSizer = wx.StaticBoxSizer(self.operandBox, wx.HORIZONTAL)
buttonSizer3 = wx.GridBagSizer(7, 1)
-
- buttonSizer3.Add(item = self.newmaplabel, pos = (0, 0),
+ buttonSizer3.Add(item = self.newmaplabel, pos = (0,0),
span = (1, 2), flag = wx.ALIGN_CENTER)
- buttonSizer3.Add(item = self.newmaptxt, pos = (1, 0),
+ buttonSizer3.Add(item = self.newmaptxt, pos = (1,0),
span = (1, 2))
- buttonSizer3.Add(item = self.mapsellabel, pos = (2, 0),
- span = (1, 2), flag = wx.ALIGN_CENTER)
- buttonSizer3.Add(item = self.mapselect, pos = (3, 0),
- span = (1, 2))
- buttonSizer3.Add(item = self.functlabel, pos = (4, 0),
- span = (1, 2), flag = wx.ALIGN_CENTER)
- buttonSizer3.Add(item = self.function, pos = (5, 0),
- span = (1, 2))
- buttonSizer3.Add(item = self.btn['paren'], pos = (6, 0),
- flag = wx.ALIGN_LEFT)
- buttonSizer3.Add(item = self.btn_clear, pos = (6, 1),
- flag = wx.ALIGN_RIGHT)
-
+ buttonSizer3.Add(item = self.functlabel, pos = (2,0),
+ span = (1,2), flag = wx.ALIGN_CENTER)
+ buttonSizer3.Add(item = self.function, pos = (3,0),
+ span = (1,2))
+ buttonSizer3.Add(item = self.mapsellabel, pos = (4,0),
+ span = (1,2), flag = wx.ALIGN_CENTER)
+ buttonSizer3.Add(item = self.mapselect, pos = (5,0),
+ span = (1,2))
+ threebutton = wx.GridBagSizer(1, 2)
+ threebutton.Add(item = self.btn['parenl'], pos = (0,0),
+ span = (1,1), flag = wx.ALIGN_LEFT)
+ threebutton.Add(item = self.btn['parenr'], pos = (0,1),
+ span = (1,1), flag = wx.ALIGN_CENTER)
+ threebutton.Add(item = self.btn_clear, pos = (0,2),
+ span = (1,1), flag = wx.ALIGN_RIGHT)
+ buttonSizer3.Add(item = threebutton, pos = (6,0),
+ span = (1,1), flag = wx.ALIGN_CENTER)
+
buttonSizer4 = wx.BoxSizer(wx.HORIZONTAL)
buttonSizer4.Add(item = self.btn_cmd,
flag = wx.ALL, border = 5)
@@ -397,7 +405,8 @@
elif event.GetId() == self.btn['and'].GetId(): mark = "&&"
elif event.GetId() == self.btn['andnull'].GetId(): mark = "&&&"
elif event.GetId() == self.btn['cond'].GetId(): mark = " ? : "
- elif event.GetId() == self.btn['paren'].GetId(): mark = "( )"
+ elif event.GetId() == self.btn['parenl'].GetId(): mark = "("
+ elif event.GetId() == self.btn['parenr'].GetId(): mark = ")"
self._addSomething(mark)
def OnSelect(self, event):
More information about the grass-commit
mailing list