[GRASS-SVN] r40930 - in grass/branches/develbranch_6/visualization/nviz: . scripts src

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Feb 11 03:50:08 EST 2010


Author: hamish
Date: 2010-02-11 03:50:07 -0500 (Thu, 11 Feb 2010)
New Revision: 40930

Removed:
   grass/branches/develbranch_6/visualization/nviz/scripts/nviz
   grass/branches/develbranch_6/visualization/nviz/scripts/nviz.bat
Modified:
   grass/branches/develbranch_6/visualization/nviz/Makefile
   grass/branches/develbranch_6/visualization/nviz/src/Makefile
   grass/branches/develbranch_6/visualization/nviz/src/interface.h
   grass/branches/develbranch_6/visualization/nviz/src/nvizMain.c
   grass/branches/develbranch_6/visualization/nviz/src/nviz_init.c
Log:
Glynn: Make nviz binary a normal GRASS module, eliminate nviz.bat scripts
   (merge from trunk, #902)


Modified: grass/branches/develbranch_6/visualization/nviz/Makefile
===================================================================
--- grass/branches/develbranch_6/visualization/nviz/Makefile	2010-02-11 08:44:45 UTC (rev 40929)
+++ grass/branches/develbranch_6/visualization/nviz/Makefile	2010-02-11 08:50:07 UTC (rev 40930)
@@ -34,13 +34,8 @@
 # Install the scripts in the appropriate directory
 install:
 	-$(MKDIR) $(INSTALL_DIR)
-	$(INSTALL) src/nvwish$(EXE) $(INSTALL_DIR)/$(PROG)$(EXE)
-	$(INSTALL) scripts/$(PROG) $(GISBASE)/bin
-ifneq ($(strip $(MINGW)),)
-	$(INSTALL) scripts/nviz.bat $(GISBASE)/bin
-endif
 	-$(MKDIR) $(INSTALL_DIR)/scripts
-	for file in $(SCRIPTS) ; do $(INSTALL) $$file $(INSTALL_DIR)/scripts ; done
+	for file in $(SCRIPTS) ; do $(INSTALL_DATA) $$file $(INSTALL_DIR)/scripts ; done
 	-$(MKDIR) $(INSTALL_DIR)/bitmaps
 	-$(MKDIR) $(INSTALL_DIR)/bitmaps/flythrough
 	$(FIND) bitmaps -path '*/.svn' -prune -o -type f -print | \

Deleted: grass/branches/develbranch_6/visualization/nviz/scripts/nviz
===================================================================
--- grass/branches/develbranch_6/visualization/nviz/scripts/nviz	2010-02-11 08:44:45 UTC (rev 40929)
+++ grass/branches/develbranch_6/visualization/nviz/scripts/nviz	2010-02-11 08:50:07 UTC (rev 40930)
@@ -1,110 +0,0 @@
-#!/bin/sh
-
-############################################################################
-#
-# MODULE:       nviz
-# PURPOSE:      3D visualization and query of GRASS data
-# COPYRIGHT:    (C) 2003,2005 by the GRASS Development Team
-#
-#               This program is free software under the GNU General Public
-#               License (>=v2). Read the file COPYING that comes with GRASS
-#               for details.
-#############################################################################
-
-## template generated 'with nviz --script'
-#%Module
-#% description: nviz - Visualization and animation tool for GRASS data.
-#% keywords: raster, vector, visualization
-#%End
-#%Flag
-#% key: q
-#% description: Quickstart - Do not load any data
-#%End
-#%Flag
-#% key: k
-#% description: Exit after completing script launched from the command line
-#%End
-#%Flag
-#% key: x
-#% description: Start in Demo mode (skip the "please wait" message)
-#%End
-#%Flag
-#% key: v
-#% description: Verbose module output (default=quiet)
-#%End
-#%Option
-#% key: elevation
-#% type: string
-#% required: no
-#% multiple: yes
-#% key_desc: name
-#% description: Name of raster map(s) for Elevation
-#% gisprompt: old,cell,raster
-#% guisection: Raster
-#%End
-#%Option
-#% key: color
-#% type: string
-#% required: no
-#% multiple: yes
-#% description: Name of raster map(s) for Color
-#% gisprompt: old,cell,raster
-#% guisection: Raster
-#%End
-#%Option
-#% key: vector
-#% type: string
-#% required: no
-#% multiple: yes
-#% description: Name of vector lines/areas overlay map(s)
-#% gisprompt: old,vector,vector
-#% guisection: Vector
-#%End
-#%Option
-#% key: points
-#% type: string
-#% required: no
-#% multiple: yes
-#% description: Name of vector points overlay file(s)
-#% gisprompt: old,vector,vector
-#% guisection: Vector
-#%End
-#%Option
-#% key: volume
-#% type: string
-#% required: no
-#% multiple: yes
-#% description: Name of existing 3d raster map
-#% gisprompt: old,grid3,3d-raster
-#% guisection: Raster
-#%End
-#%Option
-#% key: path
-#% type: string
-#% required: no
-#% multiple: no
-#% description: Set alternative panel path
-#%End
-#%Option
-#% key: script
-#% type: string
-#% required: no
-#% multiple: no
-#% description: Execute script file at startup
-#%End
-#%Option
-#% key: state
-#% type: string
-#% required: no
-#% multiple: no
-#% description: Load previously saved state file
-#%End
-
-
-if [ $# -eq 0 ] ; then
-  ##nviz is opened in GUI
-  exec "$GISBASE/etc/nviz2.2/nviz" -f "$GISBASE/etc/nviz2.2/scripts/nviz2.2_script"
-  exit 0
-fi
-
-exec "$GISBASE/etc/nviz2.2/nviz" -f "$GISBASE/etc/nviz2.2/scripts/nviz2.2_script" ${1+"$@"}

Deleted: grass/branches/develbranch_6/visualization/nviz/scripts/nviz.bat
===================================================================
--- grass/branches/develbranch_6/visualization/nviz/scripts/nviz.bat	2010-02-11 08:44:45 UTC (rev 40929)
+++ grass/branches/develbranch_6/visualization/nviz/scripts/nviz.bat	2010-02-11 08:50:07 UTC (rev 40930)
@@ -1 +0,0 @@
-@"%GISBASE%\etc\nviz2.2\nviz.exe" -f "%GISBASE%\etc\nviz2.2\scripts\nviz2.2_script" %*

Modified: grass/branches/develbranch_6/visualization/nviz/src/Makefile
===================================================================
--- grass/branches/develbranch_6/visualization/nviz/src/Makefile	2010-02-11 08:44:45 UTC (rev 40929)
+++ grass/branches/develbranch_6/visualization/nviz/src/Makefile	2010-02-11 08:50:07 UTC (rev 40930)
@@ -3,13 +3,12 @@
 
 MODULE_TOPDIR = ../../..
 
+PGM = nviz
+
 include $(MODULE_TOPDIR)/include/Make/Platform.make
 include $(MODULE_TOPDIR)/include/Make/Grass.make
 include $(MODULE_TOPDIR)/include/Make/Rules.make
 
-# These should be set by the doconfigure script
-NVWISH_VER=NVWISH2.2
-
 ifeq ($(OPENGL_X11),1)
 OGL_LIBS := $(OPENGLULIB) $(OPENGLLIB) $(XLIBPATH) $(XLIB) -lXmu -lXext $(XEXTRALIBS) $(MATHLIB)
 endif
@@ -59,10 +58,9 @@
 
 EXTRA_CLEAN_FILES = nvwish$(EXE)
 
-#default: $(BIN)/$(PGM) htmlcmd
-default: nvwish$(EXE)
+default: $(BIN)/$(PGM)$(EXE)
 
-nvwish$(EXE): $(ARCH_OBJS) $(VECTDEP) $(BITMAPDEP) $(LINKMDEP) $(FORMDEP) $(DBMIDEP $(GISDEP)
+$(BIN)/$(PGM)$(EXE): $(ARCH_OBJS) $(VECTDEP) $(BITMAPDEP) $(LINKMDEP) $(FORMDEP) $(DBMIDEP $(GISDEP)
 	$(CC) $(LDFLAGS) -o $@ $(ARCH_OBJS) $(FMODE_OBJ) $(SURFLIB) $(XTRA_LDFLAGS) \
 		$(BITMAPLIB) $(LINKMLIB) $(VECTLIB) $(SITESLIB) $(FORMLIB) $(DBMILIB) \
 		$(G3DLIB) $(GISLIB) $(XDRLIB) \

Modified: grass/branches/develbranch_6/visualization/nviz/src/interface.h
===================================================================
--- grass/branches/develbranch_6/visualization/nviz/src/interface.h	2010-02-11 08:44:45 UTC (rev 40929)
+++ grass/branches/develbranch_6/visualization/nviz/src/interface.h	2010-02-11 08:50:07 UTC (rev 40930)
@@ -72,6 +72,12 @@
 -            this is the data type declaration section                   -
 ------------------------------------------------------------------------*/
 
+struct options {
+    struct Option *elev, *colr, *vct, *pnt, *vol;
+    struct Option *panel_path, *script, *state;
+    struct Flag *no_args, *script_kill, *demo, *verbose;
+};
+
 typedef struct
 {
     int id;

Modified: grass/branches/develbranch_6/visualization/nviz/src/nvizMain.c
===================================================================
--- grass/branches/develbranch_6/visualization/nviz/src/nvizMain.c	2010-02-11 08:44:45 UTC (rev 40929)
+++ grass/branches/develbranch_6/visualization/nviz/src/nvizMain.c	2010-02-11 08:50:07 UTC (rev 40930)
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <tk.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
 #include "interface.h"
 
 extern int NVIZ_AppInit(Tcl_Interp *);
@@ -48,17 +49,121 @@
  *----------------------------------------------------------------------
  */
 
-int main(int argc,		/* Number of command-line arguments. */
-	 char **argv)		/* Values of command-line arguments. */
+struct options opts;
+int script_mode;
+
+int main(int argc, char **argv)
 {
-    Tcl_FindExecutable(argv[0]);
+    struct GModule *module;
+    char *argv2[4];
+    char *source;
 
-    if (argc > 1) {
-	if (strstr(argv[argc - 1], "-h") != NULL)
-	    sprintf(argv[argc - 1], "--h");
+    G_gisinit(argv[0]);
+
+    if (argc >= 2 && strcmp(argv[1], "-f") == 0) {
+	script_mode = 1;
+	Tcl_FindExecutable(argv[0]);
+	Tk_Main(argc, argv, NVIZ_AppInit);
+	exit(EXIT_SUCCESS);
     }
 
-    Tk_Main(argc, argv, NVIZ_AppInit);
+    module = G_define_module();
+    module->keywords = _("raster, vector, visualization");
+    module->description =
+	_("nviz - Visualization and animation tool for GRASS data.");
 
+    opts.elev = G_define_standard_option(G_OPT_R_ELEV);
+    opts.elev->required = NO;
+    opts.elev->multiple = YES;
+    opts.elev->description = _("Name of raster map(s) for Elevation");
+    opts.elev->guisection = _("Raster");
+
+    opts.colr = G_define_option();
+    opts.colr->key = "color";
+    opts.colr->type = TYPE_STRING;
+    opts.colr->required = NO;
+    opts.colr->multiple = YES;
+    opts.colr->gisprompt = "old,cell,raster";
+    opts.colr->description = _("Name of raster map(s) for Color");
+    opts.colr->guisection = _("Raster");
+
+    opts.vct = G_define_option();
+    opts.vct->key = "vector";
+    opts.vct->type = TYPE_STRING;
+    opts.vct->required = NO;
+    opts.vct->multiple = YES;
+    opts.vct->gisprompt = "old,vector,vector";
+    opts.vct->description = _("Name of vector lines/areas overlay map(s)");
+    opts.vct->guisection = _("Vector");
+
+    opts.pnt = G_define_option();
+    opts.pnt->key = "points";
+    opts.pnt->type = TYPE_STRING;
+    opts.pnt->required = NO;
+    opts.pnt->multiple = YES;
+    opts.pnt->gisprompt = "old,vector,vector";
+    opts.pnt->description = _("Name of vector points overlay file(s)");
+    opts.pnt->guisection = _("Vector");
+
+    opts.vol = G_define_option();
+    opts.vol->key = "volume";
+    opts.vol->type = TYPE_STRING;
+    opts.vol->required = NO;
+    opts.vol->multiple = YES;
+    opts.vol->gisprompt = "old,grid3,3d-raster";
+    opts.vol->description = _("Name of existing 3d raster map");
+    opts.vol->guisection = _("Raster");
+
+    opts.no_args = G_define_flag();
+    opts.no_args->key = 'q';
+    opts.no_args->description = _("Quickstart - Do not load any data");
+
+    opts.script_kill = G_define_flag();
+    opts.script_kill->key = 'k';
+    opts.script_kill->description =
+	_("Exit after completing script launched from the command line");
+
+    opts.demo = G_define_flag();
+    opts.demo->key = 'x';
+    opts.demo->description =
+	_("Start in Demo mode (skip the \"please wait\" message)");
+
+    opts.verbose = G_define_flag();
+    opts.verbose->key = 'v';
+    opts.verbose->description = _("Verbose module output");
+
+    opts.panel_path = G_define_option();
+    opts.panel_path->key = "path";
+    opts.panel_path->type = TYPE_STRING;
+    opts.panel_path->required = NO;
+    opts.panel_path->description = _("Set alternative panel path");
+
+    opts.script = G_define_option();
+    opts.script->key = "script";
+    opts.script->type = TYPE_STRING;
+    opts.script->required = NO;
+    opts.script->description = _("Execute script file at startup");
+
+    opts.state = G_define_option();
+    opts.state->key = "state";
+    opts.state->type = TYPE_STRING;
+    opts.state->required = NO;
+    opts.state->description = _("Load previously saved state file");
+
+    if (G_parser(argc, argv))
+	exit(EXIT_FAILURE);
+
+    Tcl_FindExecutable(argv[0]);
+
+    G_asprintf(&source, "%s/etc/nviz2.2/scripts/nviz2.2_script", G_gisbase());
+
+    argv2[0] = argv[0];
+    argv2[1] = "-f";
+    argv2[2] = source;
+    argv2[3] = NULL;
+
+    Tk_Main(4, argv2, NVIZ_AppInit);
+
     exit(EXIT_SUCCESS);
 }
+

Modified: grass/branches/develbranch_6/visualization/nviz/src/nviz_init.c
===================================================================
--- grass/branches/develbranch_6/visualization/nviz/src/nviz_init.c	2010-02-11 08:44:45 UTC (rev 40929)
+++ grass/branches/develbranch_6/visualization/nviz/src/nviz_init.c	2010-02-11 08:50:07 UTC (rev 40930)
@@ -18,141 +18,18 @@
 update\n\
 grab .wait_ok.wait\n";
 
-int script_mode = 0;
+extern struct options opts;
+extern int script_mode;
 
-static int parse_command(Nv_data * data, Tcl_Interp * interp,	/* Current interpreter. */
-			 int argc, const char *cmd, const char *argv0,
-			 const char **argv)
+static int parse_command(Nv_data * data, Tcl_Interp * interp)
 {
-    struct Option *elev, *colr, *vct, *pnt, *vol;
-    struct Option *panel_path, *script, *state;
-    struct Flag *no_args, *script_kill, *demo, *verbose;
-    struct GModule *module;
     char *arglist[3], *autoload;
     int i, aload = 1;
-    char **argv2;
-    int argc2, ii, jj;
 
-    /*
-     * Flags and Options:
-     * -q : quickstart, starts nvwish without querying for the usual maps
-     *
-     * path : panel path, adds the given directory to the path to
-     *        search for panels
-     *
-     * script : script file, after starting nviz immediately plays the
-     *          named script
-     *
-     * -k : script kill, if this flag is set, then Nviz will exit after completing
-     *      a script started from the command line
-     *
-     * -x : demo mode, the usual "please wait" messages are nuked.
-     */
-
-    module = G_define_module();
-    module->keywords = _("raster, vector, visualization");
-    module->description =
-	_("nviz - Visualization and animation tool for GRASS data.");
-
-    elev = G_define_standard_option(G_OPT_R_ELEV);
-    elev->required = NO;
-    elev->multiple = YES;
-    elev->description = _("Name of raster map(s) for Elevation");
-    elev->guisection = _("Raster");
-
-    colr = G_define_option();
-    colr->key = "color";
-    colr->type = TYPE_STRING;
-    colr->required = NO;
-    colr->multiple = YES;
-    colr->gisprompt = "old,cell,raster";
-    colr->description = _("Name of raster map(s) for Color");
-    colr->guisection = _("Raster");
-
-    vct = G_define_option();
-    vct->key = "vector";
-    vct->type = TYPE_STRING;
-    vct->required = NO;
-    vct->multiple = YES;
-    vct->gisprompt = "old,vector,vector";
-    vct->description = _("Name of vector lines/areas overlay map(s)");
-    vct->guisection = _("Vector");
-
-    pnt = G_define_option();
-    pnt->key = "points";
-    pnt->type = TYPE_STRING;
-    pnt->required = NO;
-    pnt->multiple = YES;
-    pnt->gisprompt = "old,vector,vector";
-    pnt->description = _("Name of vector points overlay file(s)");
-    pnt->guisection = _("Vector");
-
-    vol = G_define_option();
-    vol->key = "volume";
-    vol->type = TYPE_STRING;
-    vol->required = NO;
-    vol->multiple = YES;
-    vol->gisprompt = "old,grid3,3d-raster";
-    vol->description = _("Name of existing 3d raster map");
-    vol->guisection = _("Raster");
-
-    no_args = G_define_flag();
-    no_args->key = 'q';
-    no_args->description = _("Quickstart - Do not load any data");
-
-    script_kill = G_define_flag();
-    script_kill->key = 'k';
-    script_kill->description =
-	_("Exit after completing script launched from the command line");
-
-    demo = G_define_flag();
-    demo->key = 'x';
-    demo->description =
-	_("Start in Demo mode (skip the \"please wait\" message)");
-
-    verbose = G_define_flag();
-    verbose->key = 'v';
-    verbose->description = _("Verbose module output");
-
-    panel_path = G_define_option();
-    panel_path->key = "path";
-    panel_path->type = TYPE_STRING;
-    panel_path->required = NO;
-    panel_path->description = _("Set alternative panel path");
-
-    script = G_define_option();
-    script->key = "script";
-    script->type = TYPE_STRING;
-    script->required = NO;
-    script->description = _("Execute script file at startup");
-
-    state = G_define_option();
-    state->key = "state";
-    state->type = TYPE_STRING;
-    state->required = NO;
-    state->description = _("Load previously saved state file");
-
-    jj = 0;
-    /*
-     * Routine to strip out script name passed to through argv
-     * If left in it treats it as a elev arg and tries to open
-     */
-    argv2 = G_malloc((argc + 2) * sizeof(char *));
-    argv2[0] = (char *) cmd;
-    for (ii = 0; ii < argc; ii++)
-	argv2[ii + 1] = (char *)argv[ii];
-    argv2[argc + 1] = NULL;
-    argc2 = argc + 1;
-
-    /* BUG?: warning: passing arg 2 of `G_parser' from incompatible pointer type */
-    if (G_parser(argc2, argv2))
-	exit(EXIT_FAILURE);
-    /* [?!]: Exit status is zero to avoid TCL complaints */
-
     G_debug(1, "nviz_init:parse_command()");
 
     /* please remove before GRASS 7 released */
-    if (verbose->answer) {
+    if (opts.verbose->answer) {
         putenv("GRASS_VERBOSE=3");
         G_warning(_("The '-v' flag is superseded and will be removed "
                     "in future. Please use '--verbose' instead."));
@@ -172,92 +49,83 @@
     }
 
     /* Put in the "please wait..." message unless we are in demo mode */
-    if ((strstr(cmd, "nviz") != NULL) && (!demo->answer)) {
+    if (!opts.demo->answer) {
 	if (Tcl_Eval(interp, startup_script) != TCL_OK)
 	    G_fatal_error("%s", Tcl_GetStringResult(interp));
-
     }
 
     G_verbose_message(" ");
     G_verbose_message(" ");
     G_verbose_message("Version: %s", GRASS_VERSION_STRING);
     G_verbose_message(" ");
-    G_verbose_message(
-		"Authors: Bill Brown, Terry Baker, Mark Astley, David Gerdes");
+    G_verbose_message("Authors: Bill Brown, Terry Baker, Mark Astley, David Gerdes");
     G_verbose_message("\tmodifications: Jaro Hofierka, Bob Covill");
     G_verbose_message(" ");
     G_verbose_message(" ");
-    G_verbose_message(
-		"Please cite one or more of the following references in publications");
+    G_verbose_message("Please cite one or more of the following references in publications");
     G_verbose_message("where the results of this program were used:");
-    G_verbose_message(
-		"Brown, W.M., Astley, M., Baker, T., Mitasova, H. (1995).");
-    G_verbose_message(
-		"GRASS as an Integrated GIS and Visualization System for");
-    G_verbose_message(
-		"Spatio-Temporal Modeling, Proceedings of Auto Carto 12, Charlotte, N.C.");
+    G_verbose_message("Brown, W.M., Astley, M., Baker, T., Mitasova, H. (1995).");
+    G_verbose_message("GRASS as an Integrated GIS and Visualization System for");
+    G_verbose_message("Spatio-Temporal Modeling, Proceedings of Auto Carto 12, Charlotte, N.C.");
     G_verbose_message(" ");
-    G_verbose_message(
-		"Mitasova, H., W.M. Brown, J. Hofierka, 1994, Multidimensional");
-    G_verbose_message(
-		"dynamic cartography. Kartograficke listy, 2, p. 37-50.");
+    G_verbose_message("Mitasova, H., W.M. Brown, J. Hofierka, 1994, Multidimensional");
+    G_verbose_message("dynamic cartography. Kartograficke listy, 2, p. 37-50.");
     G_verbose_message(" ");
-    G_verbose_message(
-		"Mitas L., Brown W. M., Mitasova H., 1997, Role of dynamic");
-    G_verbose_message(
-		"cartography in simulations of landscape processes based on multi-variate");
-    G_verbose_message(
-		"fields. Computers and Geosciences, Vol. 23, No. 4, pp. 437-446");
+    G_verbose_message("Mitas L., Brown W. M., Mitasova H., 1997, Role of dynamic");
+    G_verbose_message("cartography in simulations of landscape processes based on multi-variate");
+    G_verbose_message("fields. Computers and Geosciences, Vol. 23, No. 4, pp. 437-446");
     G_verbose_message(" ");
-    G_verbose_message(
-		"http://www2.gis.uiuc.edu:2280/modviz/viz/nviz.html");
+    G_verbose_message("http://www2.gis.uiuc.edu:2280/modviz/viz/nviz.html");
     G_verbose_message(" ");
     G_verbose_message("The papers are available at");
     G_verbose_message("http://www2.gis.uiuc.edu:2280/modviz/");
 
 
     /* Look for quickstart flag */
-    if (no_args->answer) {
-	elev->answers = colr->answers = vct->answers = pnt->answers =
-	    vol->answers = NULL;
+    if (opts.no_args->answer) {
+	opts.elev->answers = NULL;
+	opts.colr->answers = NULL;
+	opts.vct->answers = NULL;
+	opts.pnt->answers = NULL;
+	opts.vol->answers = NULL;
     }
 
 
     /* Look for scriptkill flag */
-    if (script_kill->answer) {
+    if (opts.script_kill->answer) {
 	if (Tcl_VarEval(interp, "set NvizScriptKill 1 ", NULL) != TCL_OK)
 	    G_fatal_error("%s", Tcl_GetStringResult(interp));
     }
 
     /* See if an alternative panel path is specified */
-    if (panel_path->answer) {
+    if (opts.panel_path->answer) {
 	/* If so then set the variable NvizAltPath to the alternative path
 	 */
-	if (Tcl_VarEval(interp, "set NvizAltPath ", panel_path->answer,
+	if (Tcl_VarEval(interp, "set NvizAltPath ", opts.panel_path->answer,
 			NULL) != TCL_OK)
 	    G_fatal_error("%s", Tcl_GetStringResult(interp));
     }
 
     /* Get State file from command line */
-    if (state->answer) {
-	if (Tcl_VarEval(interp, "set NvizLoadState ", state->answer,
+    if (opts.state->answer) {
+	if (Tcl_VarEval(interp, "set NvizLoadState ", opts.state->answer,
 			NULL) != TCL_OK)
 	    G_fatal_error("%s", Tcl_GetStringResult(interp));
     }
 
     /* See if a script file was specified */
-    if (script->answer) {
+    if (opts.script->answer) {
 	/* If so then set the variable NvizPlayScript to the file */
-	if (Tcl_VarEval(interp, "set NvizPlayScript ", script->answer,
+	if (Tcl_VarEval(interp, "set NvizPlayScript ", opts.script->answer,
 			NULL) != TCL_OK)
 	    G_fatal_error("%s", Tcl_GetStringResult(interp));
     }
 
 #ifdef XSCRIPT
-    AUTO_FILE = aut->answer;
+    AUTO_FILE = opts.aut->answer;
     /* either file name or NULL */
 
-    Write_script = swrit->answer;
+    Write_script = opts.swrit->answer;
 #endif
 
     /* Consult the user's .grassrc file to see if we should
@@ -273,13 +141,13 @@
 
     /* Parse answeres from user */
     /* Run check to make sure elev == colr */
-    if (elev->answers && colr->answers) {
+    if (opts.elev->answers && opts.colr->answers) {
 	int ee = 0, cc = 0;
 
-	for (i = 0; elev->answers[i]; i++) {
+	for (i = 0; opts.elev->answers[i]; i++) {
 	    ee = i;
 	}
-	for (i = 0; colr->answers[i]; i++) {
+	for (i = 0; opts.colr->answers[i]; i++) {
 	    cc = i;
 	}
 	if (ee != cc)
@@ -287,12 +155,12 @@
 		(_("Number of elevation files does not match number of colors files"));
     }
 
-    if (elev->answers) {
+    if (opts.elev->answers) {
 	char tmp[30];
 
-	for (i = 0; elev->answers[i]; i++) {
+	for (i = 0; opts.elev->answers[i]; i++) {
 	    arglist[1] = "surf";
-	    arglist[2] = elev->answers[i];
+	    arglist[2] = opts.elev->answers[i];
 
 	    if (Nnew_map_obj_cmd(data, interp, 3, arglist) != TCL_OK) {
 		G_warning(_("Loading data failed"));
@@ -302,14 +170,14 @@
 	    /* See if we should autoload the color file */
 	    if (aload) {
 		strncpy(tmp, Tcl_GetStringResult(interp), 29);
-		if (colr->answers) {
+		if (opts.colr->answers) {
 		    if (Tcl_VarEval(interp, tmp, " set_att color ",
-				    colr->answers[i], NULL) != TCL_OK)
+				    opts.colr->answers[i], NULL) != TCL_OK)
 			G_fatal_error("%s", Tcl_GetStringResult(interp));
 		}
 		else {
 		    if (Tcl_VarEval(interp, tmp, " set_att color ",
-				    elev->answers[i], NULL) != TCL_OK)
+				    opts.elev->answers[i], NULL) != TCL_OK)
 			G_fatal_error("%s", Tcl_GetStringResult(interp));
 		}
 	    }
@@ -319,8 +187,8 @@
 	    set_default_wirecolors(data, i);
     }
 
-    if (vct->answers) {
-	if (!elev->answers && GS_num_surfs() == 0) {
+    if (opts.vct->answers) {
+	if (!opts.elev->answers && GS_num_surfs() == 0) {
 	    int i;
 	    int *surf_list;
 
@@ -330,15 +198,15 @@
 	    surf_list = GS_get_surf_list(&i);
 	    GS_set_att_const(surf_list[0], ATT_TRANSP, 255);
 	}
-	for (i = 0; vct->answers[i]; i++) {
+	for (i = 0; opts.vct->answers[i]; i++) {
 	    arglist[1] = "vect";
-	    arglist[2] = vct->answers[i];
+	    arglist[2] = opts.vct->answers[i];
 	    Nnew_map_obj_cmd(data, interp, 3, arglist);
 	}
     }
 
-    if (pnt->answers) {
-	if (!elev->answers && GS_num_surfs() == 0) {
+    if (opts.pnt->answers) {
+	if (!opts.elev->answers && GS_num_surfs() == 0) {
 	    int i;
 	    int *surf_list;
 
@@ -348,17 +216,17 @@
 	    surf_list = GS_get_surf_list(&i);
 	    GS_set_att_const(surf_list[0], ATT_TRANSP, 255);
 	}
-	for (i = 0; pnt->answers[i]; i++) {
+	for (i = 0; opts.pnt->answers[i]; i++) {
 	    arglist[1] = "site";
-	    arglist[2] = pnt->answers[i];
+	    arglist[2] = opts.pnt->answers[i];
 	    Nnew_map_obj_cmd(data, interp, 3, arglist);
 	}
     }
 
-    if (vol->answers) {
-	for (i = 0; vol->answers[i]; i++) {
+    if (opts.vol->answers) {
+	for (i = 0; opts.vol->answers[i]; i++) {
 	    arglist[1] = "vol";
-	    arglist[2] = vol->answers[i];
+	    arglist[2] = opts.vol->answers[i];
 	    Nnew_map_obj_cmd(data, interp, 3, arglist);
 	}
     }
@@ -370,57 +238,6 @@
 }
 
 
-/*
- * Ngetargs: gets command line args from tcl. Tcl stores argv[0] by
- * itself and the rest of the args as a single string so Ngetargs goes
- * through some string manipulation to put all the args back into a single array
- * so that G_parser can deal with them without getting sick.
- */
-
-static int Ngetargs(Tcl_Interp * interp,	/* Current interpreter. */
-		    const char **p_cmd,
-		    const char **p_argv0,
-		    const char ***p_argv)
-{
-    const char *argv0, *argv, *cmd;
-    char *tmp;
-    int argc;
-
-    G_debug(2, "nviz_init:Ngetargs()");
-
-    argv0 = Tcl_GetVar(interp, "argv0", TCL_LEAVE_ERR_MSG);
-    argv = Tcl_GetVar(interp, "argv", TCL_LEAVE_ERR_MSG);
-    cmd = Tcl_GetNameOfExecutable();
-
-    G_debug(2, "nviz_init:argv0=%s", argv0);
-    G_debug(2, "nviz_init:argv=%s", argv);
-    G_debug(2, "nviz_init:cmd=%s", cmd);
-
-    *p_cmd = cmd;
-
-    tmp = G_store(argv0);
-    G_convert_dirseps_from_host(tmp);
-    argv0 = tmp;
-
-    *p_argv0 = argv0;
-
-    if (strstr(argv0, "script_tools") != NULL ||
-	strstr(argv0, "script_play") != NULL ||
-	strstr(argv0, "script_get_line") != NULL ||
-	strstr(argv0, "script_file_tools") != NULL) {
-	G_message(_("Entering script mode ..."));
-	script_mode = 1;
-	argv = "";
-    }
-
-    if (TCL_ERROR == Tcl_SplitList(interp, argv, &argc, p_argv))
-	exit(EXIT_FAILURE);
-
-    G_debug(2, "nviz_init:argc=%d", argc);
-
-    return (argc);
-}
-
 int make_red_yellow_ramp(int *ramp, int num, int minval, int maxval)
 {
     int g, i, incr;
@@ -508,10 +325,6 @@
 {
     static Nv_data data;
 
-    /*
-       char nviz_script[] = "source [exec g.gisenv GISBASE]/etc/nviz2.2/scripts/nviz2.2_script\n";
-     */
-
     /* compile in the home directory */
     Tcl_SetVar(interp, "src_boot", getenv("GISBASE"), TCL_GLOBAL_ONLY);
 
@@ -519,10 +332,8 @@
 
     Ninitdata(interp, &data);
 
-/*** ACS_MODIFY flythrough  ONE LINE ******************************************/
     togl_flythrough_init_tcl(interp, &data);
 
-/*** ACS_MODIFY pick  ONE LINE ************************************************/
     pick_init_tcl(interp, &data);
 
 /*** ACS_MODIFY site_attr  ONE LINE ************************************************/
@@ -531,26 +342,14 @@
 /*** ACS_MODIFY site_highlight  ONE LINE ************************************************/
     site_highlight_init_tcl(interp, &data);
 
-    /*
-       if (!script_mode)
-       Tcl_Eval(interp, nviz_script); *//* source nviz_script to start main window */
-
     return (TCL_OK);
 }
 
-void swap_togl();
+extern void swap_togl(void);
 
 int Ninitdata(Tcl_Interp *interp,	/* Current interpreter. */
 	      Nv_data *data)
 {
-    const char *cmd, *argv0;
-    const char **argv;
-    int argc;
-
-    argc = Ngetargs(interp, &cmd, &argv0, &argv);
-
-    G_gisinit(argv0);
-
     GS_libinit();
 
     GVL_libinit();		/* TODO */
@@ -559,7 +358,7 @@
     data->NumCplanes = 0;
     data->CurCplane = 0;
     if (!script_mode)
-	parse_command(data, interp, argc, cmd, argv0, argv);
+	parse_command(data, interp);
 
     return (TCL_OK);
 }



More information about the grass-commit mailing list