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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 31 04:50:35 EDT 2010


Author: martinl
Date: 2010-10-31 01:50:35 -0700 (Sun, 31 Oct 2010)
New Revision: 44118

Removed:
   grass/trunk/gui/wxpython/gui_modules/rules.py
Modified:
   grass/trunk/gui/wxpython/wxgui.py
   grass/trunk/gui/wxpython/xml/menudata.xml
Log:
wxGUI: interactive input for r.recode/r.reclass, etc. is managed by menuform.py no need for extra rules.py module


Deleted: grass/trunk/gui/wxpython/gui_modules/rules.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/rules.py	2010-10-31 08:46:46 UTC (rev 44117)
+++ grass/trunk/gui/wxpython/gui_modules/rules.py	2010-10-31 08:50:35 UTC (rev 44118)
@@ -1,170 +0,0 @@
-"""
-MODULE:     rules.py
-
-CLASSES:
-    * RulesText
-
-PURPOSE:    Dialog for interactive entry of rules for r.colors,
-            r.reclass, r.recode, and v.reclass
-
-AUTHORS:    The GRASS Development Team
-            Michael Barton (Arizona State University)
-
-COPYRIGHT:  (C) 2007 by the GRASS Development Team
-            This program is free software under the GNU General Public
-            License (>=v2). Read the file COPYING that comes with GRASS
-            for details.
-
-"""
-
-import os
-import sys
-
-import wx
-
-import gcmd
-import gselect
-import globalvar
-
-class RulesText(wx.Dialog):
-    def __init__(self, parent, id=wx.ID_ANY, title=_("Enter rules"),
-                 pos=wx.DefaultPosition, size=wx.DefaultSize,
-                 style=wx.DEFAULT_DIALOG_STYLE,
-                 cmd=None):
-        wx.Dialog.__init__(self, parent, id, title, pos, size, style)
-
-        """
-        Dialog for interactively entering rules
-        for map management commands
-
-        @param cmd command (given as list)
-        """
-        self.parent = parent
-        self.cmd = cmd # map management command
-        self.inmap = '' # input map to change
-        self.outmap = '' # output map for reclass/recode
-        self.rules = '' # rules for changing
-        self.overwrite = False
-
-        if self.cmd[0] == 'r.colors':
-            label1 = _('Create new color table using color rules')
-            label2 = _('Raster map:')
-            label3 = None
-            label4 = _('Enter color rules')
-            seltype = 'cell'
-        elif self.cmd[0] == 'r.reclass':
-            label1 = _('Reclassify raster map using rules')
-            label2 = _('Raster map to reclassify:')
-            label3 = _('Reclassified raster map:')
-            label4 = _('Enter reclassification rules')
-            seltype = 'cell'
-        elif self.cmd[0] == 'r.recode':
-            label1 = _('Recode raster map using rules')
-            label2 = _('Raster map to recode:')
-            label3 = _('Recoded raster map:')
-            label4 = _('Enter recoding rules')
-            seltype = 'cell'
-        elif self.cmd[0] == 'v.reclass':
-            label1 = _('Reclassify vector map using SQL rules')
-            label2 = _('Vector map to reclassify:')
-            label3 = _('Reclassified vector map:')
-            label4 = _('Enter reclassification rules')
-            seltype = 'vector'
-
-        # set window frame title
-        self.SetTitle(label1)
-
-        sizer = wx.BoxSizer(wx.VERTICAL)
-        boxSizer =  wx.GridBagSizer(hgap=5, vgap=5)
-        boxSizer.AddGrowableCol(0)
-
-        row = 0
-        boxSizer.Add(item=wx.StaticText(parent=self, id=wx.ID_ANY, label=label2),
-                     flag=wx.ALIGN_CENTER_VERTICAL,
-                     pos=(row,0))
-
-        self.selectionInput = gselect.Select(parent=self, id=wx.ID_ANY, size=globalvar.DIALOG_GSELECT_SIZE,
-                                             type=seltype)
-        boxSizer.Add(item=self.selectionInput,
-                     pos=(row,1))
-        row += 1
-
-        if self.cmd[0] != 'r.colors':
-            boxSizer.Add(item=wx.StaticText(parent=self, id=wx.ID_ANY, label=label3),
-                         flag=wx.ALIGN_CENTER_VERTICAL,
-                         pos=(row, 0))
-            self.selectionOutput = gselect.Select(parent=self, id=wx.ID_ANY, size=(300,-1),
-                                                  type=seltype)
-            self.selectionOutput.Bind(wx.EVT_TEXT, self.OnSelectionOutput)
-            boxSizer.Add(item=self.selectionOutput,
-                         pos=(row,1))
-            row += 1
-            # TODO remove (see Preferences dialog)
-            self.ovrwrtcheck = wx.CheckBox(parent=self, id=wx.ID_ANY, label=_('overwrite existing file'))
-            self.ovrwrtcheck.SetValue(self.overwrite)
-            boxSizer.Add(item=self.ovrwrtcheck,
-                         pos=(row, 1))
-            self.Bind(wx.EVT_CHECKBOX, self.OnOverwrite,   self.ovrwrtcheck)
-            row += 1
-
-        boxSizer.Add(item=wx.StaticText(parent=self, id=wx.ID_ANY, label=label4),
-                     flag=wx.ALIGN_CENTER_VERTICAL,
-                     pos=(row, 0))
-        helpbtn = wx.Button(parent=self, id=wx.ID_HELP)
-        boxSizer.Add(item=helpbtn, flag=wx.ALIGN_RIGHT, pos=(row, 1))
-        row += 1 
-
-        self.rulestxt = wx.TextCtrl(parent=self, id=wx.ID_ANY, value='',
-                                    pos=wx.DefaultPosition, size=(400,150),
-                                    style=wx.TE_MULTILINE |
-                                    wx.HSCROLL |
-                                    wx.TE_NOHIDESEL)
-        self.rulestxt.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL, 0, ''))
-        boxSizer.Add(item=self.rulestxt, pos=(row, 0), flag=wx.EXPAND, span=(1, 2))
-
-        sizer.Add(item=boxSizer, proportion=1,
-                  flag=wx.ALL ,border=10)
-
-        line = wx.StaticLine(parent=self, id=wx.ID_ANY, size=(20,-1), style=wx.LI_HORIZONTAL)
-        sizer.Add(item=line, proportion=0,
-                  flag=wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=5)
-
-        btnsizer = wx.StdDialogButtonSizer()
-
-        btn = wx.Button(self, wx.ID_OK)
-        btn.SetDefault()
-        btnsizer.AddButton(btn)
-
-        btn = wx.Button(self, wx.ID_CANCEL)
-        btnsizer.AddButton(btn)
-        btnsizer.Realize()
-
-        sizer.Add(item=btnsizer, proportion=0,
-                  flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
-
-        self.SetSizer(sizer)
-        sizer.Fit(self)
-
-        # bindings
-        self.Bind(wx.EVT_BUTTON, self.OnHelp, helpbtn)
-        self.selectionInput.Bind(wx.EVT_TEXT, self.OnSelectionInput)
-        self.Bind(wx.EVT_TEXT, self.OnRules,   self.rulestxt)
-
-    def OnSelectionInput(self, event):
-        self.inmap = event.GetString()
-
-    def OnSelectionOutput(self, event):
-        self.outmap = event.GetString()
-
-    def OnRules(self, event):
-        self.rules = event.GetString().strip()
-        if self.cmd[0] == 'r.recode':
-            self.rules = self.rules + '%s' % os.linesep
-
-    def OnHelp(self, event):
-        gcmd.RunCommand('g.manual',
-                        quiet = True,
-                        entry = self.cmd[0])
-
-    def OnOverwrite(self, event):
-        self.overwrite = event.IsChecked()

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2010-10-31 08:46:46 UTC (rev 44117)
+++ grass/trunk/gui/wxpython/wxgui.py	2010-10-31 08:50:35 UTC (rev 44118)
@@ -68,7 +68,6 @@
 import gui_modules.menuform as menuform
 import gui_modules.histogram as histogram
 import gui_modules.profile as profile
-import gui_modules.rules as rules
 import gui_modules.mcalc_builder as mapcalculator
 import gui_modules.gcmd as gcmd
 import gui_modules.georect as georect
@@ -888,40 +887,19 @@
         self.disp_idx = 0
         self.curr_page = None
         
-    def RulesCmd(self, event, cmd = ''):
+    def RulesCmd(self, event):
+        """!Launches dialog for commands that need rules input and
+        processes rules
         """
-        Launches dialog for commands that need rules
-        input and processes rules
-        """
-        if event:
-            cmd = self.GetMenuCmd(event)
-                
-        if cmd[0] == 'r.colors' or cmd[0] == 'vcolors':
-            ctable = colorrules.ColorTable(self, cmd=cmd[0])
-            ctable.Show()
+        cmd = self.GetMenuCmd(event)
+        
+        if cmd[0] == 'r.colors':
+            ctable = colorrules.ColorTable(self, raster = True)
         else:
-            dlg = rules.RulesText(self, cmd=cmd)
-            dlg.CenterOnScreen()
-            if dlg.ShowModal() == wx.ID_OK:
-                gtemp = utils.GetTempfile()
-                output = open(gtemp, "w")
-                try:
-                    output.write(dlg.rules)
-                finally:
-                    output.close()
-    
-                cmdlist = [cmd[0],
-                           'input=%s' % dlg.inmap,
-                           'output=%s' % dlg.outmap,
-                           'rules=%s' % gtemp]
-    
-                if dlg.overwrite == True:
-                    cmdlist.append('--o')
-    
-                dlg.Destroy()
-    
-                self.goutput.RunCmd(cmdlist)
-
+            ctable = colorrules.ColorTable(self, raster = False)
+        ctable.CentreOnScreen()
+        ctable.Show()
+        
     def OnInstallExtension(self, event):
         """!Install extension from GRASS Addons SVN repository"""
         win = InstallExtensionWindow(self, size = (550, 400))

Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml	2010-10-31 08:46:46 UTC (rev 44117)
+++ grass/trunk/gui/wxpython/xml/menudata.xml	2010-10-31 08:50:35 UTC (rev 44118)
@@ -937,7 +937,7 @@
 	    </menuitem>
 	    <menuitem>
 	      <label>Color rules</label>
-	      <help>Creates/modifies the color table associated with a raster map.</help>
+	      <help>Interactive management of raster color tables.</help>
 	      <keywords>raster,color table</keywords>
 	      <handler>RulesCmd</handler>
 	      <command>r.colors</command>
@@ -1512,34 +1512,20 @@
 	      <command>r.reclass.area</command>
 	    </menuitem>
 	    <menuitem>
-	      <label>Reclassify interactively</label>
+	      <label>Reclassify</label>
 	      <help>Reclassify raster map based on category values.</help>
 	      <keywords>raster,reclassification</keywords>
-	      <handler>RulesCmd</handler>
-	      <command>r.reclass</command>
-	    </menuitem>
-	    <menuitem>
-	      <label>Reclassify using rules file</label>
-	      <help>Reclassify raster map based on category values.</help>
-	      <keywords>raster,reclassification</keywords>
 	      <handler>OnMenuCmd</handler>
 	      <command>r.reclass</command>
 	    </menuitem>
 	    <separator />
 	    <menuitem>
-	      <label>Recode interactively</label>
+	      <label>Recode</label>
 	      <help>Recodes categorical raster maps.</help>
 	      <keywords>raster</keywords>
-	      <handler>RulesCmd</handler>
+	      <handler>OnMenuCmd</handler>
 	      <command>r.recode</command>
 	    </menuitem>
-	    <menuitem>
-	      <label>Recode using rules file</label>
-	      <help>r.recode.file - Use ascii rules file to recode categories in raster map</help>
-	      <keywords>raster,recode</keywords>
-	      <handler>OnMenuCmd</handler>
-	      <command>r.recode.file</command>
-	    </menuitem>
 	    <separator />
 	    <menuitem>
 	      <label>Rescale</label>
@@ -1989,10 +1975,10 @@
 	    </menuitem>
 	    <menuitem>
 	      <label>Color rules</label>
-	      <help>Set colors interactively by entering color rules</help>
+	      <help>Interacrive management of vector color tables.</help>
 	      <handler>RulesCmd</handler>
-	      <keywords>vector, colors</keywords>
-	      <command>vcolors</command>
+	      <keywords>vector,color table</keywords>
+	      <command>v.colors</command>
 	    </menuitem>
 	  </items>
 	</menu>
@@ -2244,16 +2230,9 @@
 	      <command>v.category</command>
 	    </menuitem>
 	    <menuitem>
-	      <label>Reclassify objects interactively</label>
+	      <label>Reclassify</label>
 	      <help>Changes vector category values for an existing vector map according to results of SQL queries or a value in attribute table column.</help>
 	      <keywords>vector,reclass,attributes</keywords>
-	      <handler>RulesCmd</handler>
-	      <command>v.reclass</command>
-	    </menuitem>
-	    <menuitem>
-	      <label>Reclassify objects using rules file</label>
-	      <help>Changes vector category values for an existing vector map according to results of SQL queries or a value in attribute table column.</help>
-	      <keywords>vector,reclass,attributes</keywords>
 	      <handler>OnMenuCmd</handler>
 	      <command>v.reclass</command>
 	    </menuitem>



More information about the grass-commit mailing list