File: make_colr.c

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (88 lines) | stat: -rw-r--r-- 2,782 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**********************************************************************
 *
 *   G_make_color (name, mapset, colors)
 *       char *name               name of map
 *       char *mapset             mapset containing name
 *       struct Colors *colors    struct to hold colors
 *
 *   Interactively prompts user for deciding which type of color
 *   lookup table is desired.
 *       Red, green, and blue color ramps
 *       Gray scale
 *       Rainbow colors
 *       Random colors
 *       Color wave
 *       Aspect colors
 *       Red through yellow to green
 *
 *   Returns -1 user canceled the request
 *            1 color table is ok
 **********************************************************************/

#include "gis.h"
#include "glocale.h"

int G_make_colors (name, mapset, pcolr)
    char *name ;
    char *mapset ;
    struct Colors *pcolr ;
{
    char buff[128] ;
    int answ ;
    struct FPRange range;
    DCELL min, max;

    G_init_colors (pcolr);

/* determine range cell values */
    if (G_read_fp_range (name, mapset, &range) < 0)
	return -1;
    G_get_fp_range_min_max (&range, &min, &max);
    if(G_is_d_null_value(&min) || G_is_d_null_value(&max))
    {
       sprintf(buff, _(" The raster map %s@%s is empty"), name, mapset);
       G_warning(buff);
       return -1;
    }

/* Prompting */
ASK:
    G_clear_screen() ;
    fprintf (stderr, _("\n\nColor table needed for file [%s] in mapset [%s].\n"),
	    name, mapset) ;

    fprintf (stderr, _("\nPlease identify the type desired:\n")) ;
    fprintf (stderr, _("    1:  Random colors\n")) ;
    fprintf (stderr, _("    2:  Red, green, and blue color ramps\n")) ;
    fprintf (stderr, _("    3:  Color wave\n")) ;
    fprintf (stderr, _("    4:  Gray scale\n")) ;
    fprintf (stderr, _("    5:  Aspect\n")) ;
    fprintf (stderr, _("    6:  Rainbow colors\n")) ;
    fprintf (stderr, _("    7:  Red through yellow to green\n"));
    fprintf (stderr, _("    8:  Green through yellow to red\n"));
    fprintf (stderr, _("RETURN  quit\n"));
    fprintf (stderr, "\n> ") ;

    for(;;)
    {
	if(!G_gets(buff)) goto ASK ;
	G_strip (buff);
	if (*buff == 0) return -1;
	if(sscanf(buff,"%d",&answ) != 1) answ = -1;

	switch (answ)
	{
	case 1: return G_make_random_colors (pcolr, (CELL) min, (CELL) max);
	case 2: return G_make_ramp_fp_colors (pcolr, min, max);
	case 3: return G_make_wave_fp_colors (pcolr, min, max);
	case 4: return G_make_grey_scale_fp_colors (pcolr, min, max);
	case 5: return G_make_aspect_fp_colors (pcolr, min, max);
	case 6: return G_make_rainbow_fp_colors (pcolr, min, max);
	case 7: return G_make_ryg_fp_colors (pcolr, min, max);
	case 8: return G_make_gyr_fp_colors (pcolr, min, max);
	default:
	    fprintf (stderr, _("\n%s invalid; Try again > "), buff) ;
	    break;
	}
    }
}