[GRASS5] v.digit color name mismatch

I found the source of the incorrect behavior of the
v.digit->Customize->Color menu. The color names do not match the colors
used in the display fo the following reason:

The colors used in the display are defined in the file
<grass_dir>/src/include/colors.h:

#define D_COLOR_LIST:
"red,orange,yellow,green,blue,indigo,violet,white,black,gray,brown,magenta,
aqua,grey"

The color names used in v.digit are defined in the file
<grass_dir>/src/mapdev/v.digit/color.c:

static char *color_names = {
     " ",
     " white",
     " black",
     " yellow",
     " blue",
     " red",
     " green",
     " orange",
     " grey",
     " magenta",
     " aqua",
     " indigo",
     " violet",
     " brown",
     " ",
     " "
};

To fix it, edit the color_names list to match the D_COLOR_LIST and
recompile v.digit.

Hi Chris,

I see that you are working on v.digit, I would like to only note
that work on v.digit in 5.1 was also started:
http://mpa.itc.it/radim/g51/v.digit3.png

Radim

----- Original Message -----
From: "Radim Blazek" <blazek@itc.it>
To: <cheg01@attbi.com>; <grass5@grass.itc.it>
Sent: Monday, February 24, 2003 12:53 AM
Subject: Re: [GRASS5] v.digit color name mismatch

Hi Chris,

I see that you are working on v.digit, I would like to only note
that work on v.digit in 5.1 was also started:
http://mpa.itc.it/radim/g51/v.digit3.png

Radim

I suspect that 5.0 will continue to have a large user base for some years
to come. Is there an expeced release date for 5.1?

cheg01@attbi.com wrote:

----- Original Message -----
From: "Radim Blazek" <blazek@itc.it>
To: <cheg01@attbi.com>; <grass5@grass.itc.it>
Sent: Monday, February 24, 2003 12:53 AM
Subject: Re: [GRASS5] v.digit color name mismatch

Hi Chris,

I see that you are working on v.digit, I would like to only note
that work on v.digit in 5.1 was also started:
http://mpa.itc.it/radim/g51/v.digit3.png

Radim

I suspect that 5.0 will continue to have a large user base for some years
to come. Is there an expeced release date for 5.1?

Chris, if you are doing anything with vector modules I are greatly encourage you to look at 5.1
and coordinate your work with Radim. The vector capabilities in 5.0 are not adequate
and we all need to work on getting 5.0 merged with 5.1 as soon as possible so that we can have a working version
of GRASS5.1 with everything in it - I expect that people will switch to GRASS5.1 as soon as it becomes
usable because of its vector and database support, so I would not put much effort in fixing 5.0 vector stuff.
This is just my view, others may see it differently.

Helena

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5

Cheg,
thanks for your help!

Can you add your solution to bug report #1670?

https://intevation.de/rt/webrt?serial_num=1670&display=History
This is possible using email.
mail to grass-bugs a t intevation.de
having the following string within the subject line:
  [bug #1670]

If you can produce a patch against CVS head
somebody with CVS access will commit it.

Thanks again,
  Bernhard

On Sun, Feb 23, 2003 at 09:59:49PM -0800, cheg01@attbi.com wrote:

I found the source of the incorrect behavior of the
v.digit->Customize->Color menu. The color names do not match the colors
used in the display fo the following reason:

The colors used in the display are defined in the file
<grass_dir>/src/include/colors.h:

#define D_COLOR_LIST:
"red,orange,yellow,green,blue,indigo,violet,white,black,gray,brown,magenta,
aqua,grey"

The color names used in v.digit are defined in the file
<grass_dir>/src/mapdev/v.digit/color.c:

static char *color_names = {
     " ",
     " white",
     " black",
     " yellow",
     " blue",
     " red",
     " green",
     " orange",
     " grey",
     " magenta",
     " aqua",
     " indigo",
     " violet",
     " brown",
     " ",
     " "
};

To fix it, edit the color_names list to match the D_COLOR_LIST and
recompile v.digit.

On Mon, Feb 24, 2003 at 10:16:09AM -0500, Helena Mitasova wrote:

cheg01@attbi.com wrote:

>----- Original Message -----
>From: "Radim Blazek" <blazek@itc.it>
>To: <cheg01@attbi.com>; <grass5@grass.itc.it>
>Sent: Monday, February 24, 2003 12:53 AM
>Subject: Re: [GRASS5] v.digit color name mismatch

>>I see that you are working on v.digit, I would like to only note
>>that work on v.digit in 5.1 was also started:
>>http://mpa.itc.it/radim/g51/v.digit3.png

>I suspect that 5.0 will continue to have a large user base for some years
>to come. Is there an expeced release date for 5.1?

I also believe that 5.0.x will be the stable version around for a while.

There is no expected release date on 5.1.x
and note that 5.1.x will always be experimental.
So the first releases will be releases of experimental versions.
5.2.0 will be the next stable release and this is a bit away.

However we try to get 5.1.x out and stable as fast
as possible which you probably should count in quarter of years.
Any help is appreciated.

Chris, if you are doing anything with vector modules I are greatly
encourage you to look at 5.1
and coordinate your work with Radim. The vector capabilities in 5.0 are
not adequate
and we all need to work on getting 5.0 merged with 5.1 as soon as
possible so that we can have a working version
of GRASS5.1 with everything in it - I expect that people will switch to
GRASS5.1 as soon as it becomes
usable because of its vector and database support, so I would not put
much effort in fixing 5.0 vector stuff.
This is just my view, others may see it differently.

We need people who fix bugs in 5.0.x and do maintance releases.
Vector support is not bad in principle it just could be a lot better.

People interested in developing and advancing 5.1.x are of
course wanted and Radim does a very good job in this area.

Thus Chris can pick his choice and help GRASS one or the other
or both ways. :slight_smile:

On Sun, Feb 23, 2003 at 09:59:49PM -0800, cheg01@attbi.com wrote:

I found the source of the incorrect behavior of the
v.digit->Customize->Color menu. The color names do not match the colors
used in the display fo the following reason:

The colors used in the display are defined in the file
<grass_dir>/src/include/colors.h:

#define D_COLOR_LIST:
"red,orange,yellow,green,blue,indigo,violet,white,black,gray,brown,magenta,
aqua,grey"

The color names used in v.digit are defined in the file
<grass_dir>/src/mapdev/v.digit/color.c:

static char *color_names = {
     " ",
     " white",
     " black",
     " yellow",
     " blue",
     " red",
     " green",
     " orange",
     " grey",
     " magenta",
     " aqua",
     " indigo",
     " violet",
     " brown",
     " ",
     " "
};

And, for another source of names in a different ordering,
we can look to: src/libes/gis/named_colr.c

static struct
{
    char *name;
    float r,g,b;
}colors =
{
    {"white", 1.00, 1.00, 1.00},
    {"black", 0.00, 0.00, 0.00},
    {"red", 1.00, 0.00, 0.00},
    {"green", 0.00, 1.00, 0.00},
    {"blue", 0.00, 0.00, 1.00},
    {"yellow", 1.00, 1.00, 0.00},
    {"magenta", 1.00, 0.00, 1.00},
    {"cyan", 0.00, 1.00, 1.00},
    {"aqua", 0.00, 0.75, 0.75},
    {"grey", 0.75, 0.75, 0.75},
    {"gray", 0.75, 0.75, 0.75},
    {"orange", 1.00, 0.50, 0.00},
    {"brown", 0.75, 0.50, 0.25},
    {"purple", 0.50, 0.00, 1.00},
    {"violet", 0.50, 0.00, 1.00},
    {"indigo", 0.00, 0.50, 1.00},

    {"",0.0,0.0,0.0} /* do not delete */
};

In this file is a G_color_name (int) function that returns the name
corresponding to the index, and this order differs from
D_translate_color ("name") which returns the defined macro numbers
from "colors.h".

There is no corresponding D_translate_color, but it would be trivial
to add (making D_translate_color be a wrapper, for say,
G_color_index(const char *name)).

I propose: making D_COLOR_LIST a macro yielding the name of a pointer to
string literal which will be defined in named_colr.c:

Renumber/reorder the color name macros in colors.h to match the colors
struct above.

Add the function G_color_index and make D_translate_color() a
simple wrapper for it.

I have a sneaking suspicion that will break something where the color
index can't be zero... (display code?)

Finally, the initialize.c file in v.digit can harmonize with the
colors.c file over the names and numbers of colors...

Then again... maybe the bugfix approach is better for 5.0 ...

--
echo ">gra.fcw@2ztr< eryyvZ .T pveR" | rot13 | reverse

Eric G. Miller wrote:

I have a sneaking suspicion that will break something where the color
index can't be zero... (display code?)

R_raster() uses index zero for transparent pixels (e.g. "d.rast -o").

--
Glynn Clements <glynn.clements@virgin.net>

Several new bug reports on v.digit came up a few days ago:

***************************************************************
#1676: Subject: Debug menu in v.digit

Platform: GNU/Linux/i386
grass obtained from: Trento Italy site
grass binary for platform: Compiled from Sources
GRASS Version: 5.0.1

The 'n - Display node info' option of the Debug menu in v.digit seems
inactive.
Aldo Clerici

***************************************************************
This is true, the d_node_info code in lines 228-238 of debug.c does
nothing. Should probably drop the "n - Display node info" menu item from
the Debug menu.

***************************************************************
#1674: Subject: Toolbox menu in v.digit

Platform: GNU/Linux/i386
grass obtained from: Trento Italy site
grass binary for platform: Compiled from Sources
GRASS Version: 5.0.1

In the 'n - Display Node lines' option in the Toolbox menu of v.digit, the
functions of the middle (Next line) and right (Quit) buttons are inverted.
Aldo Clerici

***************************************************************
It seems to be related to the following code:

In local_proto.h:

ifndef ANOTHER_BUTTON
# define MIDDLEB 2
# define RIGHTB 3
#else
# define MIDDLEB 3
# define RIGHTB 2
#endif

*************************

In mouse_yn.c

#ifdef ANOTHER_BUTTON
Write_base(14, " Middle: Quit") ;
Write_base(15, " Right: Next line") ;
#else
Write_base(14, " Middle: Next line") ;
Write_base(15, " Right: Quit") ;
#endif

*************************
In node_lines.c
Lines 59-77
next_line = map->Node[node_num].n_lines - 1;
Next = 3;
prev_line = 0;
first = 1;
do {
     prev_line = next_line;
     switch (Next) {
  case 1: /* prev */
      next_line = (next_line == 0 ?
    map->Node[node_num].n_lines -1 : next_line-1);
      break;
  case 2: /* end */
      /* shouldn't get here */
      break;
  case 3: /* next */
      next_line = (next_line == map->Node[node_num].n_lines -1 ?
        0 : next_line+1);
      break;
     }

****************************
and Lines 106-107

} while (2 != (Next = mouse_next_prev ("Select Next line:")));
display_line(map->Line[line_num].type, &Gpoints, line_num, map);
    }
****************************
So if ANOTHER_BUTTON is defined:
right button=2, middle button=3
on the menu, middle button =quit, right button=next line
middle button increments and shows next line
right button exits loop

So if ANOTHER_BUTTON is not defined:
right button=3, middle button=2
on the menu, right button =quit, middle button=next line
right button increments and shows next line
middle button exits loop

I think the solution is to swap the contents of case 2 and 3 in the first
loop, change "Next=3" to "Next=2" at line 58 and change "2 !=" to "3 !=" at
line 106 of node_lines.c.

***************************************************************
#1670: Subject: Color menu in v.digit

Platform: GNU/Linux/i386
grass obtained from: Trento Italy site
grass binary for platform: Compiled from Sources
GRASS Version: 5.0.1

The color names reported in the right column of the Color Menu in v.digit
don't meet the colors displayed in the monitor.
Aldo Clerici
***************************************************************
I found a solution to this a few days ago and I'm working on generating a
patch.