[GRASS-SVN] r39788 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 23 04:34:26 EST 2009
Author: martinl
Date: 2009-11-23 04:34:24 -0500 (Mon, 23 Nov 2009)
New Revision: 39788
Modified:
grass/trunk/gui/wxpython/gui_modules/gcmd.py
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/gui_modules/menuform.py
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: option to define default color table
(merge r39786 and r39787 from devbr6)
Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py 2009-11-23 09:30:21 UTC (rev 39787)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py 2009-11-23 09:34:24 UTC (rev 39788)
@@ -458,7 +458,7 @@
"""
Thread.__init__(self)
- self.cmd = cmd
+ self.cmd = cmd
# hack around platform-specific extension for binaries
if self.cmd[0] in globalvar.grassCmd['script']:
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2009-11-23 09:30:21 UTC (rev 39787)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2009-11-23 09:34:24 UTC (rev 39788)
@@ -34,6 +34,7 @@
import globalvar
import gcmd
import utils
+import menuform
from debug import Debug as Debug
from preferences import globalSettings as UserSettings
@@ -99,6 +100,20 @@
time.sleep(.1)
+ # set default color table for raster data
+ if UserSettings.Get(group='cmd', key='rasterColorTable', subkey='enabled') and \
+ args[0][0][:2] == 'r.':
+ moduleInterface = menuform.GUI().ParseCommand(args[0], show = None)
+ outputParam = moduleInterface.get_param(value = 'output', raiseError = False)
+ colorTable = UserSettings.Get(group='cmd', key='rasterColorTable', subkey='selection')
+ if outputParam and outputParam['prompt'] == 'raster':
+ argsColor = list(args)
+ argsColor[0] = [ 'r.colors',
+ 'map=%s' % outputParam['value'],
+ 'color=%s' % colorTable]
+ self.requestCmdColor = callable(*argsColor, **kwds)
+ self.resultQ.put((requestId, self.requestCmdColor.run()))
+
event = wxCmdDone(aborted = aborted,
returncode = returncode,
time = requestTime,
@@ -554,6 +569,7 @@
except KeyError:
# stopped deamon
pass
+
self.btn_abort.Enable(False)
if event.onDone:
event.onDone(returncode = event.returncode)
Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py 2009-11-23 09:30:21 UTC (rev 39787)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py 2009-11-23 09:34:24 UTC (rev 39788)
@@ -374,7 +374,7 @@
if value in val:
return p
else:
- if p[element] == value:
+ if p[element][:len(value)] == value:
return p
except KeyError:
pass
@@ -407,7 +407,7 @@
"""
param = self.get_flag(aFlag)
param['value'] = aValue
-
+
def getCmd(self, ignoreErrors = False):
"""
Produce an array of command name and arguments for feeding
@@ -1921,7 +1921,10 @@
cmd_validated = [cmd[0]]
for option in cmd[1:]:
if option[0] == '-': # flag
- self.grass_task.set_flag(option[1], True)
+ if option[1] == '-':
+ self.grass_task.set_flag(option[2:], True)
+ else:
+ self.grass_task.set_flag(option[1], True)
cmd_validated.append(option)
else: # parameter
try:
@@ -1943,27 +1946,30 @@
# update original command list
cmd = cmd_validated
-
- self.mf = mainFrame(parent=self.parent, ID=wx.ID_ANY,
- task_description=self.grass_task,
- get_dcmd=get_dcmd, layer=layer)
+ if show is not None:
+ self.mf = mainFrame(parent=self.parent, ID=wx.ID_ANY,
+ task_description=self.grass_task,
+ get_dcmd=get_dcmd, layer=layer)
+ else:
+ self.mf = None
+
if get_dcmd is not None:
# update only propwin reference
get_dcmd(dcmd=None, layer=layer, params=None,
propwin=self.mf)
- self.mf.notebookpanel.OnUpdateSelection(None)
+ if show is not None:
+ self.mf.notebookpanel.OnUpdateSelection(None)
+ if show is True:
+ if self.parent:
+ self.mf.CentreOnParent()
+ self.mf.Show(show)
+ self.mf.MakeModal(modal)
+ else:
+ self.mf.OnApply(None)
- if show:
- if self.parent:
- self.mf.CentreOnParent()
- self.mf.Show(show)
- self.mf.MakeModal(modal)
- else:
- self.mf.OnApply(None)
-
- return cmd
+ return self.grass_task
def GetCommandInputMapParamKey(self, cmd):
"""!Get parameter key for input raster/vector map
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2009-11-23 09:30:21 UTC (rev 39787)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2009-11-23 09:34:24 UTC (rev 39788)
@@ -176,6 +176,10 @@
'rasterOpaque' : {
'enabled' : False
},
+ 'rasterColorTable' : {
+ 'enabled' : False,
+ 'selection' : 'rainbow',
+ },
# d.vect
'showType': {
'point' : {
@@ -1225,7 +1229,30 @@
gridSizer.Add(item=rasterOpaque,
pos=(row, 0), span=(1, 2))
+
+ # default color table
+ row += 1
+ rasterCTCheck = wx.CheckBox(parent=panel, id=wx.ID_ANY,
+ label=_("Default color table"),
+ name='IsChecked')
+ rasterCTCheck.SetValue(self.settings.Get(group='cmd', key='rasterColorTable', subkey='enabled'))
+ self.winId['cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
+ rasterCTCheck.Bind(wx.EVT_CHECKBOX, self.OnCheckColorTable)
+ gridSizer.Add(item=rasterCTCheck,
+ pos=(row, 0))
+
+ rasterCTName = wx.Choice(parent=panel, id=wx.ID_ANY, size=(200, -1),
+ choices=utils.GetColorTables(),
+ name="GetStringSelection")
+ rasterCTName.SetStringSelection(self.settings.Get(group='cmd', key='rasterColorTable', subkey='selection'))
+ self.winId['cmd:rasterColorTable:selection'] = rasterCTName.GetId()
+ if not rasterCTCheck.IsChecked():
+ rasterCTName.Enable(False)
+
+ gridSizer.Add(item=rasterCTName,
+ pos=(row, 1))
+
sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
@@ -1634,6 +1661,14 @@
return panel
+ def OnCheckColorTable(self, event):
+ """!Set/unset default color table"""
+ win = self.FindWindowById(self.winId['cmd:rasterColorTable:selection'])
+ if event.IsChecked():
+ win.Enable()
+ else:
+ win.Enable(False)
+
def OnLoadEpsgCodes(self, event):
"""!Load EPSG codes from the file"""
win = self.FindWindowById(self.winId['projection:statusbar:projFile'])
Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py 2009-11-23 09:30:21 UTC (rev 39787)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py 2009-11-23 09:34:24 UTC (rev 39788)
@@ -589,3 +589,13 @@
listOfMapsets.insert(0, 'PERMANENT')
return listOfMapsets
+
+def GetColorTables():
+ """!Get list of color tables"""
+ ret = gcmd.RunCommand('r.colors',
+ read = True,
+ flags = 'l')
+ if not ret:
+ return list()
+
+ return ret.splitlines()
More information about the grass-commit
mailing list