[GRASS-SVN] r48861 - in grass/branches/develbranch_6/gui: scripts
wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 19 16:39:37 EDT 2011
Author: martinl
Date: 2011-10-19 13:39:36 -0700 (Wed, 19 Oct 2011)
New Revision: 48861
Added:
grass/branches/develbranch_6/gui/scripts/r.mapcalc_wrapper
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
Log:
add r.mapcalc_wrapper for GUI
Added: grass/branches/develbranch_6/gui/scripts/r.mapcalc_wrapper
===================================================================
--- grass/branches/develbranch_6/gui/scripts/r.mapcalc_wrapper (rev 0)
+++ grass/branches/develbranch_6/gui/scripts/r.mapcalc_wrapper 2011-10-19 20:39:36 UTC (rev 48861)
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+############################################################################
+#
+# MODULE: r.mapcalc_wrapper
+# AUTHOR(S): Martin Landa <landa.martin gmail.com>
+# PURPOSE: Simulate standard g.parser interface for GUI
+# COPYRIGHT: (C) 2011 by The GRASS Development Team
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+############################################################################
+
+#%module
+#% description: Raster map calculator.
+#% keywords: raster, algebra
+#%end
+#%option
+#% key: expression
+#% type: string
+#% required: no
+#% multiple: no
+#% description: Expression to evaluate
+#% guisection: Expression
+#%end
+#%option
+#% key: file
+#% type: string
+#% required: no
+#% multiple: no
+#% key_desc: name
+#% description: File containing expression(s) to evaluate
+#% gisprompt: old,file,input
+#% guisection: Expression
+#%end
+
+if [ -z "$GISBASE" ] ; then
+ echo "You must be in GRASS GIS to run this program." 1>&2
+ exit 1
+fi
+
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+ exec g.parser "$0" "$@"
+fi
+
+if [ -n "$GIS_OPT_FILE" ] ; then
+ exec r.mapcalc < "$GIS_OPT_FILE"
+else
+ if [ -n "$GIS_OPT_EXPRESSION" ] ; then
+ exec r.mapcalc "$GIS_OPT_EXPRESSION"
+ else
+ exec g.message -e message="Either <expression> or <file> option must be given"
+ exit 1
+ fi
+fi
+
+exit 0
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py 2011-10-19 19:39:24 UTC (rev 48860)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py 2011-10-19 20:39:36 UTC (rev 48861)
@@ -152,7 +152,10 @@
if gui_scripts:
os.environ["PATH"] = os.getenv("PATH") + os.pathsep + os.path.join(gisbase, 'etc', 'gui', 'scripts')
os.environ["PATH"] = os.getenv("PATH") + os.pathsep + os.path.join(gisbase, 'etc', 'wxpython', 'scripts')
- cmd = cmd + os.listdir(os.path.join(gisbase, 'etc', 'gui', 'scripts'))
+ for script in os.listdir(os.path.join(gisbase, 'etc', 'gui', 'scripts')):
+ patt = "_wrapper"
+ if script[-len(patt):] != patt: # ignore wrappers
+ cmd.append(script)
if addons and os.getenv('GRASS_ADDON_PATH'):
path = os.getenv('GRASS_ADDON_PATH')
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2011-10-19 19:39:24 UTC (rev 48860)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2011-10-19 20:39:36 UTC (rev 48861)
@@ -1241,11 +1241,6 @@
# add action to canvas
width, height = self.canvas.GetSize()
- if cmd[0] == 'r.mapcalc':
- GMessage(parent = self,
- message = _("Module r.mapcalc cannot be used in the model. "
- "Use r.mapcalculator instead."))
- return
action = ModelAction(self.model, cmd = cmd, x = width/2, y = height/2,
id = self.model.GetNextId())
@@ -1747,6 +1742,9 @@
width = UserSettings.Get(group='modeler', key='action', subkey=('size', 'width'))
if not height:
height = UserSettings.Get(group='modeler', key='action', subkey=('size', 'height'))
+
+ if cmd[0] in ('r.mapcalc', 'v.type'):
+ cmd[0] += '_wrapper'
if cmd:
self.task = menuform.GUI(show = None).ParseCommand(cmd = cmd)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py 2011-10-19 19:39:24 UTC (rev 48860)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py 2011-10-19 20:39:36 UTC (rev 48861)
@@ -794,7 +794,11 @@
cmd = text.strip().split(' ')[0]
if not self.cmdDesc or cmd != self.cmdDesc.get_name():
- if cmd in ('r.mapcalc', 'r3.mapcalc'):
+ if cmd in ('r.mapcalc', 'v.type'):
+ cmd = cmd + '_wrapper'
+
+ if cmd in ('r.mapcalc', 'r3.mapcalc') and \
+ self.parent.parent.GetName() == 'LayerManager':
self.parent.parent.OnMapCalculator(event = None, cmd = [cmd])
# add command to history & clean prompt
self.UpdateCmdHistory([cmd])
More information about the grass-commit
mailing list