[GRASS-SVN] r39786 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 23 04:15:53 EST 2009
Author: martinl
Date: 2009-11-23 04:15:46 -0500 (Mon, 23 Nov 2009)
New Revision: 39786
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: option to define default color table
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py 2009-11-23 07:42:49 UTC (rev 39785)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py 2009-11-23 09:15:46 UTC (rev 39786)
@@ -453,7 +453,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/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2009-11-23 07:42:49 UTC (rev 39785)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2009-11-23 09:15:46 UTC (rev 39786)
@@ -34,6 +34,7 @@
import globalvar
import gcmd
import utils
+import menuform
from debug import Debug as Debug
from preferences import globalSettings as UserSettings
@@ -98,6 +99,19 @@
time.sleep(.1)
+ # set default color table for raster data
+ if 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,
@@ -560,6 +574,7 @@
except KeyError:
# stopped deamon
pass
+
self.btn_abort.Enable(False)
if event.onDone:
event.onDone(returncode = event.returncode)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2009-11-23 07:42:49 UTC (rev 39785)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2009-11-23 09:15:46 UTC (rev 39786)
@@ -331,7 +331,7 @@
def get_param(self, value, element='name', raiseError=True):
"""!Find and return a param by name."""
for p in self.params:
- if p[element] == value:
+ if p[element][:len(value)] == value:
return p
if raiseError:
raise ValueError, _("Parameter not found: %s") % \
@@ -361,7 +361,7 @@
"""
param = self.get_flag(aFlag)
param['value'] = aValue
-
+
def getCmd(self, ignoreErrors = False):
"""
Produce an array of command name and arguments for feeding
@@ -1753,7 +1753,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:
@@ -1775,27 +1778,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/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2009-11-23 07:42:49 UTC (rev 39785)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2009-11-23 09:15:46 UTC (rev 39786)
@@ -176,6 +176,9 @@
'rasterOverlay' : {
'enabled' : True
},
+ 'rasterColorTable' : {
+ 'selection' : 'rainbow',
+ },
# d.vect
'showType': {
'point' : {
@@ -1235,7 +1238,23 @@
gridSizer.Add(item=rasterOverlay,
pos=(row, 0), span=(1, 2))
+
+ # default color table
+ row += 1
+ gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
+ label=_("Default color table:")),
+ flag=wx.ALIGN_LEFT |
+ wx.ALIGN_CENTER_VERTICAL,
+ pos=(row, 0))
+ colorTable = wx.Choice(parent=panel, id=wx.ID_ANY, size=(200, -1),
+ choices=utils.GetColorTables(),
+ name="GetStringSelection")
+ colorTable.SetStringSelection(self.settings.Get(group='cmd', key='rasterColorTable', subkey='selection'))
+ self.winId['cmd:rasterColorTable:selection'] = colorTable.GetId()
+ gridSizer.Add(item=colorTable,
+ 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)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2009-11-23 07:42:49 UTC (rev 39785)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2009-11-23 09:15:46 UTC (rev 39786)
@@ -593,3 +593,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