[GRASS-SVN] r42251 - in grass/trunk/gui/wxpython: gui_modules xml

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 13 18:24:07 EDT 2010


Author: martinl
Date: 2010-05-13 18:24:06 -0400 (Thu, 13 May 2010)
New Revision: 42251

Modified:
   grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py
   grass/trunk/gui/wxpython/xml/menudata.xml
Log:
wxGUI/mcalc: run command from dialog, simplify menu


Modified: grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py	2010-05-13 21:39:34 UTC (rev 42250)
+++ grass/trunk/gui/wxpython/gui_modules/mcalc_builder.py	2010-05-13 22:24:06 UTC (rev 42251)
@@ -26,6 +26,7 @@
 
 import gcmd
 import gselect
+import menuform
 try:
     import subprocess
 except:
@@ -130,7 +131,10 @@
         self.btn_run = wx.Button(parent = self.panel, id = wx.ID_ANY, label = _("&Run"))
         self.btn_run.SetDefault()
         self.btn_close = wx.Button(parent = self.panel, id = wx.ID_CLOSE)
-
+        self.btn_cmd = wx.Button(parent = self.panel, id = wx.ID_ANY,
+                                 label = _("Command dialog"))
+        self.btn_cmd.SetToolTipString(_('Open %s dialog') % self.cmd)
+        
         self.btn = dict()        
         self.btn['pow'] = wx.Button(parent = self.panel, id = wx.ID_ANY, label = "^")
         self.btn['pow'].SetToolTipString(_('exponent'))
@@ -222,7 +226,8 @@
         self.btn_clear.Bind(wx.EVT_BUTTON, self.OnClear)
         self.btn_run.Bind(wx.EVT_BUTTON, self.OnMCalcRun)
         self.btn_help.Bind(wx.EVT_BUTTON, self.OnHelp)
-        
+        self.btn_cmd.Bind(wx.EVT_BUTTON, self.OnCmdDialog)
+
         self.mapselect.Bind(wx.EVT_TEXT, self.OnSelect)
         self.function.Bind(wx.EVT_COMBOBOX, self.OnSelect)
         self.function.Bind(wx.EVT_TEXT_ENTER, self.OnSelect)
@@ -266,25 +271,29 @@
         buttonSizer2.Add(item = self.btn['not'], pos = (4,1))
 
         operandSizer = wx.StaticBoxSizer(self.operandBox, wx.HORIZONTAL)
+        
         buttonSizer3 = wx.GridBagSizer(7, 1)
+        
         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.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),
-                         span = (1,1), flag = wx.ALIGN_LEFT)
-        buttonSizer3.Add(item = self.btn_clear, pos = (6,1),
-                         span = (1,1), flag = wx.ALIGN_RIGHT)
+                         flag = wx.ALIGN_LEFT)
+        buttonSizer3.Add(item = self.btn_clear, pos = (6, 1),
+                         flag = wx.ALIGN_RIGHT)
         
         buttonSizer4 = wx.BoxSizer(wx.HORIZONTAL)
+        buttonSizer4.Add(item = self.btn_cmd,
+                         flag = wx.ALL, border = 5)
         buttonSizer4.Add(item = self.btn_close,
                          flag = wx.ALL, border = 5)
         buttonSizer4.Add(item = self.btn_run,
@@ -319,7 +328,7 @@
                   flag = wx.EXPAND | wx.LEFT | wx.RIGHT,
                       border = 5)
         sizer.Add(item = buttonSizer4, proportion = 0,
-                  flag = wx.ALIGN_RIGHT | wx.ALL, border = 1)
+                  flag = wx.ALL | wx.ALIGN_RIGHT, border = 1)
         
         self.panel.SetAutoLayout(True)        
         self.panel.SetSizer(sizer)
@@ -438,9 +447,22 @@
         """!Close window"""
         self.Destroy()
 
+    def OnCmdDialog(self, event):
+        """!Shows command dialog"""
+        name = self.newmaptxt.GetValue().strip()
+        mctxt = self.text_mcalc.GetValue().strip().replace("\n"," ")
+        mctxt = mctxt.replace(" " , "")
+        expr = name
+        if expr:
+            expr += '='
+        expr += mctxt
+        
+        menuform.GUI().ParseCommand(cmd = [self.cmd, 'expression=' + expr],
+                                    parentframe = self)
+        
 if __name__ == "__main__":
     app = wx.App(0)
-    frame = MapCalcFrame(None)
+    frame = MapCalcFrame(None, cmd = 'r.mapcalc')
     frame.Show()
     app.MainLoop()
 

Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml	2010-05-13 21:39:34 UTC (rev 42250)
+++ grass/trunk/gui/wxpython/xml/menudata.xml	2010-05-13 22:24:06 UTC (rev 42251)
@@ -1000,26 +1000,14 @@
 	  <handler>OnMenuCmd</handler>
 	  <command>r.mask</command>
 	</menuitem>
+	<menuitem>
+	  <label>Raster calculator</label>
+	  <help>Raster map calculator.</help>
+	  <keywords>raster,algebra</keywords>
+	  <handler>OnMapCalculator</handler>
+	  <command>r.mapcalc</command>
+	</menuitem>
 	<menu>
-	  <label>Map algebra</label>
-	  <items>
-	    <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>
-	      <help>Raster map calculator.</help>
-	      <keywords>raster,algebra</keywords>
-	      <handler>OnMenuCmd</handler>
-	      <command>r.mapcalc</command>
-	    </menuitem>
-	  </items>
-	</menu>
-	<menu>
 	  <label>Neighborhood analysis</label>
 	  <items>
 	    <menuitem>
@@ -2779,26 +2767,14 @@
 	  <handler>OnMenuCmd</handler>
 	  <command>r3.mask</command>
 	</menuitem>
-	<menu>
-	  <label>Map algebra</label>
-	  <items>
-	    <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>
-	      <help>Raster map calculator.</help>
-	      <keywords>raster,algebra</keywords>
-	      <handler>OnMenuCmd</handler>
-	      <command>r3.mapcalc</command>
-	    </menuitem>
-	  </items>
-	</menu>
 	<menuitem>
+	  <label>Volume calculator</label>
+	  <help>Raster map calculator.</help>
+	  <keywords>raster,algebra</keywords>
+	  <handler>OnMapCalculator</handler>
+	  <command>r3.mapcalc</command>
+	</menuitem>
+	<menuitem>
 	  <label>Cross section</label>
 	  <help>Creates cross section 2D raster map from 3d raster map based on 2D elevation map</help>
 	  <keywords>raster3d,voxel</keywords>



More information about the grass-commit mailing list