[GRASS-dev] [GRASS GIS] #902: nviz (tcl) fails on wingrass

#902: nviz (tcl) fails on wingrass
----------------------+-----------------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
----------------------+-----------------------------------------------------
Hi,

with the latest WinGrass nightly build installer (r40766), installed in
C:\Program Files\, nviz (tcl) fails to start.

even from the MSys command prompt there error is:

{{{
GRASS 6.4> nviz --help
Sorry <Files/GRASS-64-SNV/etc/nviz2.2/script/nviz2.2_script> is not a
valid option

Description
  nviz - Visualization and animation tool for GRASS data.

Keywords:
...
Usage:
...
}}}

If I reset $GISBASE beforehand to get rid of the space, it works:
{{{
GRASS 6.4> export GISBASE=/C/PROGRA~1/GRASS-64-SVN
}}}

I assume we could hardcode that conversion as part of the GRASS-
Installer.nsi (as follows), but it would be good to fix it properly.

{{{
;Get the short form of the install path (to allow for paths with spaces)
VAR /GLOBAL INST_DIR_SHORT
GetFullPathName /SHORT $INST_DIR_SHORT $INSTALL_DIR
}}}

also just to note that the nightly build process still is shipping
msys/grass70.* files and does not use a copy of msys.bat with all paths
"quoted" which causes (non-fatal) errors in the startup.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-releasebranch64
Resolution: | Keywords: wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by hellik):

Replying to [ticket:902 hamish]:
> Hi,
>
> with the latest WinGrass nightly build installer (r40766), installed in
C:\Program Files\, nviz (tcl) fails to start.
>
> even from the MSys command prompt there error is:
>
> {{{
> GRASS 6.4> nviz --help
> Sorry <Files/GRASS-64-SNV/etc/nviz2.2/script/nviz2.2_script> is not a
valid option
>
> Description
> nviz - Visualization and animation tool for GRASS data.
>
> Keywords:
> ...
> Usage:
> ...
> }}}
>
>
> If I reset $GISBASE beforehand to get rid of the space, it works:
> {{{
> GRASS 6.4> export GISBASE=/C/PROGRA~1/GRASS-64-SVN
> }}}
>
> I assume we could hardcode that conversion as part of the GRASS-
Installer.nsi (as follows), but it would be good to fix it properly.
>
> {{{
> ;Get the short form of the install path (to allow for paths with spaces)
> VAR /GLOBAL INST_DIR_SHORT
> GetFullPathName /SHORT $INST_DIR_SHORT $INSTALL_DIR
> }}}
>
>
> also just to note that the nightly build process still is shipping
msys/grass70.* files and does not use a copy of msys.bat with all paths
"quoted" which causes (non-fatal) errors in the startup.
>
>
> Hamish

i can confirm this on self compiled Wingrass64+65-installers installed in
C:\Program Files\, even if i use the msys.bat from ticket #629 with all
paths "quoted".

but nviz is working if I use the self compiled grass64+65 living in
c:\osgeo\apps\grass.

Helmut

p.s. i've integrated the msys from ticket #629 (with quoted paths) locally
into GRASS-Installer.nsi for Grass65. should i apply this for testing in
Grass65svn? I've tested it a little bit locally and it seems to work
(beside the nviz-issue).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Changes (by glynn):

  * keywords: wingrass =>
  * platform: MSWindows XP => All
  * version: svn-releasebranch64 => svn-trunk
  * cpu: x86-32 => All

Comment:

Replying to [ticket:902 hamish]:

> with the latest WinGrass nightly build installer (r40766), installed in
C:\Program Files\, nviz (tcl) fails to start.
>
> even from the MSys command prompt there error is:
>
{{{
GRASS 6.4> nviz --help
Sorry <Files/GRASS-64-SNV/etc/nviz2.2/script/nviz2.2_script> is not a
valid option
}}}

This is due to Ngetargs() in nviz_init.c.

It tries to reconstruct the command line with:
{{{
         sprintf(tmp2, "%s %s %s", cmd, argv0, tmp);
}}}
then convert it back to a list with Tcl_SplitList().

This could be hacked around by using braces, but it should probably be
using Tcl_ObjGetVar2(), Tcl_NewListObj() and Tcl_ListObjAppendList(). Or
simpler still, change Ngetargs to return `argv[0]` separately (and just
ignore `argv[1]`), and change parse_command() to match.

Oh, and it's broken in all versions for all platforms (spaces in pathnames
are uncommon on Unix, but not prohibited).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by glynn):

Replying to [comment:2 glynn]:

> Or simpler still, change Ngetargs to return `argv[0]` separately (and
just ignore `argv[1]`), and change parse_command() to match.

I've applied this solution to trunk in r40784.

And also eliminated a C99/gcc-ism: C89 requires the dimensions of an array
declaration to be a compile-time constant, so:
{{{
char *argv2[argc - 1];
}}}
isn't valid.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by neteler):

Replying to [comment:3 glynn]:
> Replying to [comment:2 glynn]:
>
> > Or simpler still, change Ngetargs to return `argv[0]` separately (and
just ignore `argv[1]`), and change parse_command() to match.
>
> I've applied this solution to trunk in r40784.

backported to 6.4 and 6.5: r40788 and r40789.

Markus

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by hamish):

Replying to [comment:1 hellik]:
> p.s. i've integrated the msys from ticket #629 (with quoted
> paths) locally into GRASS-Installer.nsi for Grass65. should i
> apply this for testing in Grass65svn? I've tested it a little
> bit locally and it seems to work (beside the nviz-issue).

sure, that's what the development branches are for. if you are worried
about it post the diff as an attachment to the trac system for further
eyeballs.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by hamish):

With today's daily build of the WinGrass installer (r40819) "`nviz -q`"
now works from the msys prompt. But it still doesn't work from the wxGUI.

When you select File -> NVIZ (Tcl/Tk) the module's GUI pops up and you can
set elev: elevation.dem by hand.

But then when you hit [Run] you get a popup error and an error in the
module gui output tab. The popup error reads:

Error in command execution nviz2.2_script
{{{
(X) Execution failed: 'nviz2.2_script elevation=elevation.dem'
Details:
Error:
}}}

and in the module GUI output tab it says:
{{{
'nviz2.2_script' is not recognized as an internal or external command,
operable program or batch file.
}}}

`nviz2.2_script` is at `$GISBASE/etc/nviz2.2/scripts/nviz2.2_script`
and `$GISBASE/bin/nviz.bat` calls it.

The gui popup window says "nviz2.2_script" as the program name in the
window's title bar.

----

From the GIS.m tcl tk gui menu it also fails, but there just with a (X) in
the main gui output window and other feedback. You can run "nviz -q" from
the stealth command region at the bottom of the output window + [Run]. in
doing that it picks up the nviz icon as well. You can also start it ok
from the GIS.m Map Display window toolbar.

----

there is nothing in the help page or Usage: text about it, but fwiw
`g.parser -s` has been backported to 6.5 but not 6.4.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by glynn):

Replying to [comment:6 hamish]:
> With today's daily build of the WinGrass installer (r40819) "`nviz -q`"
now works from the msys prompt. But it still doesn't work from the wxGUI.
>
> When you select File -> NVIZ (Tcl/Tk) the module's GUI pops up and you
can set elev: elevation.dem by hand.
>
> But then when you hit [Run] you get a popup error and an error in the
module gui output tab. The popup error reads:
>
> Error in command execution nviz2.2_script

Right. The "nviz" script doesn't invoke g.parser. It invokes
{{{
"$GISBASE/etc/nviz2.2/nviz" -f
"$GISBASE/etc/nviz2.2/scripts/nviz2.2_script"
}}}
and the nviz binary calls G_parser() (with argv[0] set to Tcl's $argv0,
which is the name of the script).

One solution is to simply force argv[0] to "nviz" unless script_mode is
set.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by hamish):

Replying to [comment:7 glynn]:
> One solution is to simply force argv[0] to "nviz" unless
> script_mode is set.

( source:grass/trunk/visualization/nviz/src/nviz_init.c, r40784)

I tried with DEBUG=2 but it dies before getting to the `G_debug(2,
"nviz_init:arg*` lines in nviz_init.c.

It dies in the same way on trunk + linux too.

  * "nviz" by itself on the command line dies with a segfault:
(all versions, all platforms)

{{{
GRASS7> gdb $GISBASE/etc/nviz2.2/nviz
(gdb) run -f $GISBASE/etc/nviz2.2/scripts/nviz2.2_script
}}}
{{{
(gdb) bt
#0 0x00007f4faac098dc in strstr () from /lib/libc.so.6
#1 0x000000000041b117 in parse_command (data=0x630b40, interp=0x10e82b0,
argc=0,
     argv0=0x1187a90 "/usr/local/src/grass/svn/trunk/dist.x86_64-unknown-
linux-gnu/etc/nviz2.2/scripts/nviz2.2_script", argv=0x10fa8b0) at
nviz_init.c:165
#2 0x000000000041be83 in Ninitdata (interp=0x10e82b0, data=0x630b40) at
nviz_init.c:543
#3 0x000000000041bddf in Ninit (interp=0x10e82b0, w=0x0) at
nviz_init.c:507
#4 0x000000000041abce in NVIZ_AppInit (interp=0x10e82b0) at
nvizAppInit.c:130
#5 0x00007f4fac4d47e6 in Tk_MainEx () from /usr/lib/libtk8.4.so.0
#6 0x000000000041ac82 in main (argc=3, argv=0x7fffb7eddc28) at
nvizMain.c:61

(gdb) bt full
#0 0x00007f4faac098dc in strstr () from /lib/libc.so.6
No symbol table info available.
#1 0x000000000041b117 in parse_command (data=0x630b40, interp=0x10e82b0,
argc=0,
     argv0=0x1187a90 "/usr/local/src/grass/svn/trunk/dist.x86_64-unknown-
linux-gnu/etc/nviz2.2/scripts/nviz2.2_script", argv=0x10fa8b0) at
nviz_init.c:165
         elev = (struct Option *) 0x7f4face2fca0
         colr = (struct Option *) 0x1187c00
         vct = (struct Option *) 0x1187fc0
         pnt = (struct Option *) 0x1188060
         vol = (struct Option *) 0x1188100
         panel_path = (struct Option *) 0x11881a0
         script = (struct Option *) 0x11884c0
         state = (struct Option *) 0x1188560
         no_args = (struct Flag *) 0x7f4face2fc70
         script_kill = (struct Flag *) 0x1187b70
         demo = (struct Flag *) 0x1187ca0
         module = (struct GModule *) 0x7f4face2fc40
         arglist = {0x0, 0x62f4d8 "\177eS®O\177", 0x0}
         autoload = 0x0
         i = 0
         aload = 1
         argv2 = (char **) 0x11882e0
         argc2 = 1
         ii = 0
         jj = 0
#2 0x000000000041be83 in Ninitdata (interp=0x10e82b0, data=0x630b40) at
nviz_init.c:543
         argv0 = 0x1187a90 "/usr/local/src/grass/svn/trunk/dist.x86_64-
unknown-linux-gnu/etc/nviz2.2/scripts/nviz2.2_script"
         argv = (const char **) 0x10fa8b0
         argc = 0
#3 0x000000000041bddf in Ninit (interp=0x10e82b0, w=0x0) at
nviz_init.c:507
         data = {Zrange = 0, XYrange = 0, NumCplanes = 0, CurCplane = 0,
Cp_on = {0, 0, 0, 0, 0, 0}, Cp_trans = {{
       0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},
Cp_rot = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0},
     {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, light = {{id = 0, brt = 0, r = 0, g
= 0, b = 0, ar = 0, ag = 0, ab = 0,
       x = 0, y = 0, z = 0, w = 0}, {id = 0, brt = 0, r = 0, g = 0, b = 0,
ar = 0, ag = 0, ab = 0, x = 0, y = 0,
       z = 0, w = 0}, {id = 0, brt = 0, r = 0, g = 0, b = 0, ar = 0, ag =
0, ab = 0, x = 0, y = 0, z = 0, w = 0}},
   BGcolor = 0}
#4 0x000000000041abce in NVIZ_AppInit (interp=0x10e82b0) at
nvizAppInit.c:130
No locals.
#5 0x00007f4fac4d47e6 in Tk_MainEx () from /usr/lib/libtk8.4.so.0
No symbol table info available.
#6 0x000000000041ac82 in main (argc=3, argv=0x7fffb7eddc28) at
nvizMain.c:61
}}}

what does ~/.nvizrc do? it is just ~/.nvwishrc by another name?

to be honest nviz's startup method is (and always has been) about as
confusing to me as the custom osgeo4w grass64.bat startup method is. I
think I need to slowly draw out a large flowchart for both :slight_smile:

thanks,
Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by glynn):

Replying to [comment:8 hamish]:

> > One solution is to simply force `argv[0]` to "nviz" unless
> > script_mode is set.
>
> ( source:grass/trunk/visualization/nviz/src/nviz_init.c, r40784)
>
> I tried with DEBUG=2 but it dies before getting to the `G_debug(2,
"nviz_init:arg*` lines in nviz_init.c.
>
> It dies in the same way on trunk + linux too.

Oops; moving `argv[0]` to a separate argument also needs this:
{{{
- if ((strstr(argv[0], "nviz") != NULL) && (!demo->answer)) {
+ if ((strstr(argv0, "nviz") != NULL) && (!demo->answer)) {
}}}

> what does ~/.nvizrc do? it is just ~/.nvwishrc by another name?

Yes. It's the setting for tcl_rcFilename.

> to be honest nviz's startup method is (and always has been) about as
confusing to me as the custom osgeo4w grass64.bat startup method is.

The documentation for embedding Tcl/Tk assumes that you want to write a
custom tclsh/wish, with the normal argument processing (i.e. -f), which
gets in the way of G_parser(). Apart from the lack of documentation on
doing otherwise, some of the NVIZ scripts require it to work that way
(i.e. scripts/script_* starting with "#!nviz -f").

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by glynn):

Replying to [comment:9 glynn]:
> Oops; moving `argv[0]` to a separate argument also needs this:
{{{
- if ((strstr(argv[0], "nviz") != NULL) && (!demo->answer)) {
+ if ((strstr(argv0, "nviz") != NULL) && (!demo->answer)) {
}}}

Actually, it needs to have the command passed separately; argv0 is the
name of the script. Fixed (hopefully) in r40835.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by hamish):

> Fixed (hopefully) in r40835.

nope.

trunk:
{{{
debian_stable@GRASS7> nviz
...
launches straight into the program, no module options UI.
}}}

{{{
debian_stable@GRASS7> nviz --ui
sh: /usr/local/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/nviz2.2/scripts/nviz2.2_script: nviz: bad interpreter: No such
file or directory
Traceback (most recent call last):
   File "/usr/local/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/wxpython/gui_modules/menuform.py", line 2058, in <module>
     GrassGUIApp(grassTask(sys.argv[1])).MainLoop()
   File "/usr/local/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/wxpython/gui_modules/menuform.py", line 350, in __init__
     processTask(tree =
etree.fromstring(getInterfaceDescription(grassModule)),
   File "/usr/local/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/wxpython/gui_modules/menuform.py", line 1858, in
getInterfaceDescription
     raise IOError, _("Unable to fetch interface description for command
'%s'.") % cmd
IOError: Unable to fetch interface description for command
'/usr/local/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/nviz2.2/scripts/nviz2.2_script'.
}}}

devbr65:
  * 6.5: GRASS_GUI=wxpython
{{{
G65> 'nviz' or 'nviz --ui'

sh: nviz2.2_script: command not found
Traceback (most recent call last):
   File "/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-
gnu/etc/wxpython/gui_modules/menuform.py", line 1891, in <module>
     GrassGUIApp( grassTask( sys.argv[1] ) ).MainLoop()
   File "/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-
gnu/etc/wxpython/gui_modules/menuform.py", line 313, in __init__
     processTask(tree =
etree.fromstring(getInterfaceDescription(grassModule)),
   File "/usr/local/src/grass/svn/grass65/dist.x86_64-unknown-linux-
gnu/etc/wxpython/gui_modules/menuform.py", line 1691, in
getInterfaceDescription
     raise IOError, _("Unable to fetch interface description for command
'%s'.") % cmd
IOError: Unable to fetch interface description for command
'nviz2.2_script'.
}}}

  * 6.5: GRASS_GUI=tcltk
{{{
G65> 'nviz' or 'nviz --ui'
...
nviz2.2_script elevation=elevation.dem
}}}
module options UI opens, but fails with red (X) in output tab but no other
message when you hit [Run].

  * nviz --help:
{{{
Usage:
  nviz2.2_script [-qkxv] [elevation=name[,name,...]]
    [color=string[,string,...]] [vector=string[,string,...]]
    [points=string[,string,...]] [volume=string[,string,...]] [path=string]
    [script=string] [state=string] [--verbose] [--quiet]
}}}

module name is wrong but options are right.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by glynn):

Replying to [comment:11 hamish]:

> > Fixed (hopefully) in r40835.
>
> nope.
>
> trunk:
{{{
debian_stable@GRASS7> nviz
...
launches straight into the program, no module options UI.
}}}

Not a bug, but a difference in G_parser() behaviour between 6.x and 7.0.
None of NVIZ' options are ->required=YES, so you aren't asked to provide
any. All modules now behave this way. Previously, specific modules would
use e.g.
{{{
     if (argc > 1 && G_parser(argc, argv))
        ...
}}}
to skip calling G_parser() altogether if no options were provided and none
were required (so you could run e.g. "d.erase" without being prompted for
the colour). But this has issues, e.g. module->overwrite not being set
from $GRASS_OVERWRITE.

>
{{{
debian_stable@GRASS7> nviz --ui
sh: /usr/local/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/nviz2.2/scripts/nviz2.2_script: nviz: bad interpreter: No such
file or directory
}}}

This appears to fix that:
{{{
--- visualization/nviz/src/nviz_init.c (revision 40851)
+++ visualization/nviz/src/nviz_init.c (working copy)
@@ -137,7 +137,7 @@
       * If left in it treats it as a elev arg and tries to open
       */
      argv2 = G_malloc((argc + 2) * sizeof(char *));
- argv2[0] = (char *)argv0;
+ argv2[0] = (char *)cmd;
      for (ii = 0; ii < argc; ii++)
         argv2[ii + 1] = (char *)argv[ii];
      argv2[argc + 1] = NULL;
}}}

devbr65:
> * 6.5: GRASS_GUI=wxpython
{{{
G65> 'nviz' or 'nviz --ui'

sh: nviz2.2_script: command not found
}}}

Odd; I can't see any significant differences between 6.5 and 7.0 in this
regard. I'll get back to the 6.5 issues once the latest 6.5 has compiled.

> * nviz --help:
{{{
Usage:
  nviz2.2_script [-qkxv] [elevation=name[,name,...]]
}}}
>
> module name is wrong but options are right.

This should be fixed by the argv0 -> cmd change.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:12&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by glynn):

Replying to [comment:11 hamish]:

> devbr65:
> * 6.5: GRASS_GUI=wxpython
{{{
G65> 'nviz' or 'nviz --ui'

sh: nviz2.2_script: command not found
}}}
>
>
> * 6.5: GRASS_GUI=tcltk
{{{
G65> 'nviz' or 'nviz --ui'
...
nviz2.2_script elevation=elevation.dem
}}}
> module options UI opens, but fails with red (X) in output tab but no
other message when you hit [Run].

Both of these are fixed by the argv0 -> cmd change. Committed as r40858
(6.5) and r40859 (7.0).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by hamish):

Ok, now it seems to work ok from the 6.5 command line and GUIs. So
backported to 6.4.

but still a weird problem in trunk:

  * G7> nviz --ui
  * (module option gui opens)
  * select raster elevation: elevation.dem@PERMANENT
  * [Run]
  * a window flashes open then closes again and this is written to the
module GUI output tab:
{{{
(Mon Feb 8 21:00:20 2010)
/usr/local/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/nviz2.2/nviz elevation=elevation.dem@PERMANENT
Error in startup script: couldn't read file
"elevation=elevation.dem@PERMANENT": no such file or
directory
(Mon Feb 8 21:00:20 2010) Command finished (0 sec)
}}}

If I try again, but with the --verbose flag turned on, the Please wait..
and NVIZ wish windows open (and stay open); the authors text is written to
the output tab ($Id$ seems broken); then it locks up after:
{{{
The papers are available at
http://www2.gis.uiuc.edu:2280/modviz/
Loading raster map <elevation.dem@PERMANENT>...
Loading raster map <elevation.dem@PERMANENT>...
Translating colors from raster map <elevation.dem@PERMANENT>...
}}}

Pressing the [Abort command] button writes the inconsistent stage warning
(which isn't really needed here [s/stage/state/?]) and stops it.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:14&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by hamish):

> the authors text is written to the output tab ($Id$ seems broken)

{{{
Version: @(#) 7.0.svn (2010)
}}}

from nviz_init.c
{{{
     G_verbose_message("Version: %s", GRASS_VERSION_STRING);
}}}

include/version.h:
{{{
#define GRASS_VERSION_STRING "@(#) 7.0.svn (2010)"
}}}

include/version.h.in:
{{{
#define GRASS_VERSION_STRING "@(#) @GRASS_VERSION_NUMBER@
(@GRASS_VERSION_DATE@)"
}}}

same thing, all versions. what's with the leading @(#)?

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:15&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by glynn):

Replying to [comment:14 hamish]:
> Ok, now it seems to work ok from the 6.5 command line and GUIs. So
backported to 6.4.
>
> but still a weird problem in trunk:
>
> * G7> nviz --ui
> * (module option gui opens)
> * select raster elevation: elevation.dem@PERMANENT
> * [Run]
> * a window flashes open then closes again and this is written to the
module GUI output tab:

Ugh. Try this:

{{{
--- visualization/nviz/src/nviz_init.c (revision 40859)
+++ visualization/nviz/src/nviz_init.c (working copy)
@@ -137,7 +137,7 @@
       * 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;
+ argv2[0] = "nviz";
      for (ii = 0; ii < argc; ii++)
         argv2[ii + 1] = (char *)argv[ii];
      argv2[argc + 1] = NULL;
}}}

No idea why it would work in 6.x without this.

I think that it might be better to change the startup, moving the top of
parse_command() (everything up to and including the G_parser() call) into
main(), so that it's a normal "GRASS module" main(). If G_parser()
indicates normal operation (i.e. not --help, --ui, etc), we call Tk_Main()
with "fabricated" argc and argv (i.e. insert the "-f nviz2.2_script"). For
--help, --ui etc, Tcl/Tk never gets involved.

This doesn't allow the nviz binary to be used to run arbitrary scripts,
but I'm not so sure that works anyhow.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:16&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by glynn):

Replying to [comment:16 glynn]:

> I think that it might be better to change the startup, moving the top of
parse_command() (everything up to and including the G_parser() call) into
main(), so that it's a normal "GRASS module" main(). If G_parser()
indicates normal operation (i.e. not --help, --ui, etc), we call Tk_Main()
with "fabricated" argc and argv (i.e. insert the "-f nviz2.2_script"). For
--help, --ui etc, Tcl/Tk never gets involved.
>
> This doesn't allow the nviz binary to be used to run arbitrary scripts,
but I'm not so sure that works anyhow.

I've done this for 7.0 in r40879. The nviz binary is installed into
$GISBASE/bin; the script and batch file aren't used. If argv[1] is '-f',
it behaves like "wish", otherwise it behaves like a GRASS module:
G_gisinit(), G_parser(), then calls Tk_Main() with argv = {"nviz", "-f",
".../nviz2.2_script", NULL}. It appears to do the right thing for all
cases (nviz, nviz -q, nviz --ui (then "Run"), nviz elevation.dem), at
least on Linux (compiling on Windows takes a while).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:17&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by hamish):

Latest from trunk tests out ok for me too on Linux.

> This doesn't allow the nviz binary to be used to run arbitrary
> scripts, but I'm not so sure that works anyhow.

do you mean nvwish running arbitrary Tcl scripts (no loss) or the ability
to use the script= option (which is used by d.nviz to set up the 'flight
path' for animations).

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:18&gt;
GRASS GIS <http://grass.osgeo.org>

#902: nviz (tcl) fails on wingrass
-----------------------+----------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: critical | Milestone: 6.4.0
Component: NVIZ | Version: svn-trunk
Resolution: | Keywords:
  Platform: All | Cpu: All
-----------------------+----------------------------------------------------
Comment (by hamish):

With the latest nightly WinGrass 6.4.0svn build (r40876), I get this error
message if 'nviz --ui' is called from the msys command line,
elev=elevation.dem@PERM, and the '-v' verbose flag is ticked (one -, not
two).

the command line in the module output tab is
{{{
nviz -v elevation=elevation.dem@PERMANENT
}}}

the popup window error is:
{{{
__Application initialization failed__

unknown or ambiguous visual name "elevation=elevation@PERMANENT": class
must be best, directcolor, grayscale, greyscale, pseudocolor, staticcolor,
staicgray, staticgrey, truecolor, or default
   [Ok]
}}}

then when you press [Ok]:
{{{
__Error in startup script__

can't read "src_boot": no such variable
   while executing
"source $src_boot/etc/nviz2.2/scripts/config.tcl"
   (file "c:/Program Files/GRASS-64-SVN\etc\nviz2.2\scripts\nviz2.2_script"
line 42)
    [Ok]
}}}

same if you use -v from the msys prompt.

If you make "-v" the last arg on the command line you get this error:
{{{
__Application initialization failed__

"-v" option requires an additional arguement
   [Ok]
}}}

This is the same error message you get if you do:
{{{
wish -v
}}}

I'd be inclined to make that -v in nviz a no-op, but I don't think it
would help in this case.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/902#comment:19&gt;
GRASS GIS <http://grass.osgeo.org>