Prechádzať zdrojové kódy

Pythonized p.db, p.mon, p.cmd, p.rast, and p.vect.
Added an opacity= option to p.rast and p.vect.


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@39892 15284696-431f-4ddb-bdfa-cd5b030d7da7

Huidae Cho 15 rokov pred
rodič
commit
de5dc6b750

+ 65 - 0
gui/wxpython/scripts/p.cmd.py

@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE:       p.cmd
+# AUTHOR(S):    Martin Landa, Hamish Bowman
+#               Converted to Python by Huidae Cho
+# PURPOSE:      Wrapper for display commands and pX monitors
+# COPYRIGHT:    (C) 2009 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: Wrapper for display commands and pX monitors
+#% keywords: display
+#%End
+
+#%Option
+#% key: cmd
+#% type: string
+#% required: yes
+#% multiple: no
+#% label: Command to be performed
+#% description: Example: "d.rast map=elevation.dem@PERMANENT catlist=1300-1400 -i"
+#%End
+
+#%Option
+#% key: opacity
+#% type: string
+#% required: no
+#% multiple: no
+#% key_desc: val
+#% description: Opacity level in percentage
+#% answer: 100
+#%End
+
+import os
+import grass.script as grass
+
+def main():
+    cmd_file = grass.gisenv()["GRASS_PYCMDFILE"]
+
+    if cmd_file == "" or os.path.exists(cmd_file) == False:
+        grass.message(_("GRASS_PYCMDFILE - File not found. Run p.mon."), "e")
+        return
+
+    cmd = options["cmd"]
+    opacity = options["opacity"]
+
+    fp = open(cmd_file, "a")
+    fp.write("%s opacity=%s\n" % (cmd, opacity))
+    fp.close()
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()

+ 44 - 0
gui/wxpython/scripts/p.db.py

@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE:       p.db
+# AUTHOR(S):    Jachym Cepicky, Markus Neteler, Hamish Bowman
+#               Converted to Python by Huidae Cho
+# PURPOSE:      Start stand-alone attribute table manager
+# COPYRIGHT:    (C) 2009 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: Start stand-alone attribute table manager
+#% keywords: database
+#%End
+#%Option
+#% key: table
+#% type: string
+#% required: yes
+#% multiple: no
+#% description: Table name
+#%End
+
+import os
+import grass.script as grass
+
+def main():
+    table = options["table"]
+
+    os.spawnlp(os.P_NOWAIT, os.environ["GRASS_PYTHON"], os.environ["GRASS_PYTHON"], "%s/etc/wxpython/gui_modules/dbm.py" % os.environ["GISBASE"], table)
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()

+ 107 - 0
gui/wxpython/scripts/p.mon.py

@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE:       p.mon
+# AUTHOR(S):    Jachym Cepicky, Michael Barton, Martin Landa, Markus Neteler,
+#               Hamish Bowman
+#               Converted to Python by Huidae Cho
+# PURPOSE:      To establish and control use of a graphics display monitor.
+# COPYRIGHT:    (C) 2009 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: To establish and control use of a graphics display monitor.
+#% keywords: display
+#%End
+
+##%Flag
+##% key: l
+##% description: List all monitors
+##%End
+
+##%Flag
+##% key: L
+##% description: List all monitors (with current status)
+##%End
+
+##%Flag
+##% key: p
+##% description: Print name of currently selected monitor
+##%End
+
+##%Flag
+##% key: r
+##% description: Release currently selected monitor
+##%End
+
+##%Flag
+##% key: s
+##% description: Do not automatically select when starting
+##%End
+
+#%Option
+#% key: start
+#% type: string
+#% required: no
+#% multiple: no
+#% description: Name of graphics monitor to start (p0-p9)
+#%End
+
+##%Option
+##% key: stop
+##% type: string
+##% required: no
+##% multiple: no
+##% description: Name of graphics monitor to stop
+##%End
+
+##%Option
+##% key: select
+##% type: string
+##% required: no
+##% multiple: no
+##% description: Name of graphics monitor to select
+##%End
+
+##%Option
+##% key: unlock
+##% type: string
+##% required: no
+##% multiple: no
+##% description: Name of graphics monitor to unlock
+##%End
+
+import os
+import grass.script as grass
+
+def main():
+    start = options["start"]
+#    select = options["select"]
+#    stop = options["stop"]
+#    unlock = options["unlock"]
+
+    # create the command file
+    command_file = grass.tempfile()
+    os.system("g.gisenv set=GRASS_PYCMDFILE=%s" % command_file)
+
+    if start != "":
+        os.spawnlp(os.P_NOWAIT, os.environ["GRASS_PYTHON"], os.environ["GRASS_PYTHON"], "%s/etc/wxpython/gui_modules/mapdisp.py" % os.environ["GISBASE"], start, command_file)
+        return
+
+#    if stop != "" or select != "" or unlock != "":
+#        grass.message(_("Not implemented yet"), "w")
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()

+ 110 - 0
gui/wxpython/scripts/p.rast.py

@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE:       p.rast
+# AUTHOR(S):    Jachym Cepicky, Martin Landa, Hamish Bowman
+#               Converted to Python by Huidae Cho
+# PURPOSE:      Displays raster map layer in the active map display window.
+# COPYRIGHT:    (C) 2009 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: Displays raster map layer in the active map display window.
+#% keywords: display, raster
+#%end
+#%flag
+#% key: n
+#% description: Make null cells opaque
+#%end
+#%flag
+#% key: i
+#% description: Invert catlist
+#% guisection: Selection
+#%end
+#%option
+#% key: map
+#% type: string
+#% required: yes
+#% multiple: no
+#% key_desc: name
+#% description: Raster map to be displayed
+#% gisprompt: old,cell,raster
+#%end
+#%option
+#% key: catlist
+#% type: string
+#% required: no
+#% multiple: yes
+#% key_desc: cat[-cat]
+#% description: List of categories to be displayed (INT maps)
+#% guisection: Selection
+#%end
+#%option
+#% key: vallist
+#% type: string
+#% required: no
+#% multiple: yes
+#% key_desc: val[-val]
+#% description: List of values to be displayed (FP maps)
+#% guisection: Selection
+#%end
+#%option
+#% key: bg
+#% type: string
+#% required: no
+#% multiple: no
+#% key_desc: color
+#% description: Background color (for null)
+#% gisprompt: old_color,color,color
+#%end
+#%option
+#% key: opacity
+#% type: string
+#% required: no
+#% multiple: no
+#% key_desc: val
+#% answer: 100
+#% description: Set opacity between 0-100%
+#%end
+
+import sys
+import os
+import grass.script as grass
+
+def construct_command(cmd):
+    line = cmd
+    for key, val in options.iteritems():
+        if val != "":
+            line += " %s=%s" % (key, val)
+    for key, val in flags.iteritems():
+        if val == True:
+            line += " -%s" % key
+    return line
+
+def main():
+    cmd_file = grass.gisenv()["GRASS_PYCMDFILE"]
+
+    if cmd_file == "" or os.path.exists(cmd_file) == False:
+        grass.message(_("GRASS_PYCMDFILE - File not found. Run p.mon."), "e")
+        return
+
+    cmd = construct_command("d"+os.path.basename(sys.argv[0])[1:-3])
+
+    fp = open(cmd_file, "a")
+    fp.write("%s\n" % cmd)
+    fp.close()
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 367 - 0
gui/wxpython/scripts/p.vect.py