[GRASS-SVN] r54714 - in grass/trunk/gui/wxpython: core lmgr mapdisp
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jan 19 12:43:32 PST 2013
Author: annakrat
Date: 2013-01-19 12:43:32 -0800 (Sat, 19 Jan 2013)
New Revision: 54714
Modified:
grass/trunk/gui/wxpython/core/render.py
grass/trunk/gui/wxpython/core/utils.py
grass/trunk/gui/wxpython/lmgr/frame.py
grass/trunk/gui/wxpython/lmgr/layertree.py
grass/trunk/gui/wxpython/mapdisp/main.py
Log:
support more d. commands
Modified: grass/trunk/gui/wxpython/core/render.py
===================================================================
--- grass/trunk/gui/wxpython/core/render.py 2013-01-19 20:22:39 UTC (rev 54713)
+++ grass/trunk/gui/wxpython/core/render.py 2013-01-19 20:43:32 UTC (rev 54714)
@@ -126,11 +126,7 @@
(self.type, self.name))
# prepare command for each layer
- layertypes = ('raster', 'rgb', 'his', 'shaded', 'rastarrow', 'rastnum',
- 'vector','thememap','themechart',
- 'grid', 'geodesic', 'rhumb', 'labels',
- 'command', 'rastleg','maplegend',
- 'overlay', 'wms')
+ layertypes = utils.command2ltype.values() + ['overlay', 'command']
if self.type not in layertypes:
raise GException(_("<%(name)s>: layer type <%(type)s> is not supported") % \
@@ -257,11 +253,7 @@
def SetType(self, ltype):
"""!Set layer type"""
- if ltype not in ('raster', '3d-raster', 'vector',
- 'overlay', 'command',
- 'shaded', 'rgb', 'his', 'rastarrow', 'rastnum','maplegend',
- 'thememap', 'themechart', 'grid', 'labels',
- 'geodesic','rhumb', 'wms'):
+ if ltype not in utils.command2ltype.values() + ['overlay', 'command']:
raise GException(_("Unsupported map layer type '%s'") % ltype)
if ltype == 'wms' and not isinstance(self.renderMgr, RenderWMSMgr):
Modified: grass/trunk/gui/wxpython/core/utils.py
===================================================================
--- grass/trunk/gui/wxpython/core/utils.py 2013-01-19 20:22:39 UTC (rev 54713)
+++ grass/trunk/gui/wxpython/core/utils.py 2013-01-19 20:43:32 UTC (rev 54714)
@@ -909,6 +909,34 @@
label = _('Select Color')
return (rgb, label)
+command2ltype = {'d.rast' : 'raster',
+ 'd.rast3d' : '3d-raster',
+ 'd.rgb' : 'rgb',
+ 'd.his' : 'his',
+ 'd.shadedmap' : 'shaded',
+ 'd.legend' : 'rastleg',
+ 'd.rast.arrow' : 'rastarrow',
+ 'd.rast.num' : 'rastnum',
+ 'd.rast.leg' : 'maplegend',
+ 'd.vect' : 'vector',
+ 'd.thematic.area': 'thememap',
+ 'd.vect.chart' : 'themechart',
+ 'd.grid' : 'grid',
+ 'd.geodesic' : 'geodesic',
+ 'd.rhumbline' : 'rhumb',
+ 'd.labels' : 'labels',
+ 'd.barscale' : 'barscale',
+ 'd.redraw' : 'redraw',
+ 'd.wms' : 'wms',
+ 'd.histogram' : 'histogram',
+ 'd.colortable' : 'colortable',
+ 'd.graph' : 'graph'
+ }
+ltype2command = {}
+for (cmd, ltype) in command2ltype.items():
+ ltype2command[ltype] = cmd
+
+
def GetGEventAttribsForHandler(method, event):
"""!Get attributes from event, which can be used by handler method.
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2013-01-19 20:22:39 UTC (rev 54713)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2013-01-19 20:43:32 UTC (rev 54714)
@@ -42,7 +42,7 @@
from core.gcmd import RunCommand, GError, GMessage, GException
from core.settings import UserSettings, GetDisplayVectSettings
-from core.utils import SetAddOnPath, GetLayerNameFromCmd
+from core.utils import SetAddOnPath, GetLayerNameFromCmd, command2ltype
from core.events import EVT_SHOW_NOTIFICATION, EVT_MAP_CREATED
from gui_core.preferences import MapsetAccess, PreferencesDialog, EVT_SETTINGS_CHANGED
from lmgr.layertree import LayerTree, LMIcons
@@ -594,25 +594,7 @@
self.NewDisplay(show = True)
try:
# display GRASS commands
- layertype = {'d.rast' : 'raster',
- 'd.rast3d' : '3d-raster',
- 'd.rgb' : 'rgb',
- 'd.his' : 'his',
- 'd.shaded' : 'shaded',
- 'd.legend' : 'rastleg',
- 'd.rast.arrow' : 'rastarrow',
- 'd.rast.num' : 'rastnum',
- 'd.rast.leg' : 'maplegend',
- 'd.vect' : 'vector',
- 'd.thematic.area': 'thememap',
- 'd.vect.chart' : 'themechart',
- 'd.grid' : 'grid',
- 'd.geodesic' : 'geodesic',
- 'd.rhumbline' : 'rhumb',
- 'd.labels' : 'labels',
- 'd.barscale' : 'barscale',
- 'd.redraw' : 'redraw',
- 'd.wms' : 'wms'}[command[0]]
+ layertype = command2ltype[command[0]]
except KeyError:
GMessage(parent = self,
message = _("Command '%s' not yet implemented in the WxGUI. "
Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py 2013-01-19 20:22:39 UTC (rev 54713)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py 2013-01-19 20:43:32 UTC (rev 54714)
@@ -35,7 +35,7 @@
from mapdisp.frame import MapFrame
from core.render import Map
from modules.histogram import HistogramFrame
-from core.utils import GetLayerNameFromCmd
+from core.utils import GetLayerNameFromCmd, ltype2command
from wxplot.profile import ProfileFrame
from core.debug import Debug
from core.settings import UserSettings, GetDisplayVectSettings
@@ -1077,57 +1077,22 @@
completed = (self.GetOptData,layer,params))
self.SetLayerInfo(layer, key = 'cmd', value = module.GetCmd())
- elif ltype == 'raster':
- cmd = ['d.rast']
- if UserSettings.Get(group = 'rasterLayer', key = 'opaque', subkey = 'enabled'):
- cmd.append('-n')
-
- elif ltype == '3d-raster':
- cmd = ['d.rast3d']
-
- elif ltype == 'rgb':
- cmd = ['d.rgb']
- if UserSettings.Get(group = 'rasterLayer', key = 'opaque', subkey = 'enabled'):
- cmd.append('-n')
-
- elif ltype == 'his':
- cmd = ['d.his']
-
- elif ltype == 'shaded':
- cmd = ['d.shadedmap']
-
- elif ltype == 'rastarrow':
- cmd = ['d.rast.arrow']
-
- elif ltype == 'rastnum':
- cmd = ['d.rast.num']
-
- elif ltype == 'vector':
- cmd = ['d.vect'] + GetDisplayVectSettings()
-
- elif ltype == 'thememap':
+ else:
+ cmd = [ltype2command[ltype]]
+ if ltype == 'raster':
+ if UserSettings.Get(group = 'rasterLayer', key = 'opaque', subkey = 'enabled'):
+ cmd.append('-n')
+ elif ltype == 'rgb':
+ if UserSettings.Get(group = 'rasterLayer', key = 'opaque', subkey = 'enabled'):
+ cmd.append('-n')
+ elif ltype == 'vector':
+ cmd.append(GetDisplayVectSettings())
+
+ # ltype == 'thememap':
# -s flag requested, otherwise only first thematic category is displayed
# should be fixed by C-based d.thematic.* modules
- cmd = ['d.thematic.area']
- elif ltype == 'themechart':
- cmd = ['d.vect.chart']
-
- elif ltype == 'grid':
- cmd = ['d.grid']
-
- elif ltype == 'geodesic':
- cmd = ['d.geodesic']
-
- elif ltype == 'rhumb':
- cmd = ['d.rhumbline']
-
- elif ltype == 'labels':
- cmd = ['d.labels']
- elif ltype == 'wms':
- cmd = ['d.wms']
-
if cmd:
GUI(parent = self, centreOnParent = False).ParseCommand(cmd,
completed = (self.GetOptData,layer,params))
Modified: grass/trunk/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/main.py 2013-01-19 20:22:39 UTC (rev 54713)
+++ grass/trunk/gui/wxpython/mapdisp/main.py 2013-01-19 20:43:32 UTC (rev 54714)
@@ -90,14 +90,16 @@
for line in fd.readlines():
cmd = utils.split(line.strip())
ltype = None
- if cmd[0] == 'd.rast':
- ltype = 'raster'
- elif cmd[0] == 'd.vect':
- ltype = 'vector'
-
+
+ try:
+ ltype = utils.command2ltype[cmd[0]]
+ except KeyError:
+ grass.warning(_("Unsupported command %s.") % cmd[0])
+ continue
+
name = utils.GetLayerNameFromCmd(cmd, fullyQualified = True,
layerType = ltype)[0]
-
+
self.AddLayer(ltype = ltype, command = cmd, active = False, name = name)
nlayers += 1
except IOError, e:
More information about the grass-commit
mailing list