00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <grass/gis.h>
00023 #include <grass/glocale.h>
00024
00025 int G_make_colors (char *name, char *mapset, struct Colors *pcolr)
00026
00027 {
00028 char buff[128] ;
00029 int answ ;
00030 struct FPRange range;
00031 DCELL min, max;
00032
00033 G_init_colors (pcolr);
00034
00035
00036 if (G_read_fp_range (name, mapset, &range) < 0)
00037 return -1;
00038 G_get_fp_range_min_max (&range, &min, &max);
00039 if(G_is_d_null_value(&min) || G_is_d_null_value(&max))
00040 {
00041 sprintf(buff, _(" The raster map %s@%s is empty"), name, mapset);
00042 G_warning(buff);
00043 return -1;
00044 }
00045
00046
00047 ASK:
00048 G_clear_screen() ;
00049 fprintf (stderr, _("\n\nColor table needed for file [%s] in mapset [%s].\n"),
00050 name, mapset) ;
00051
00052 fprintf (stderr, _("\nPlease identify the type desired:\n")) ;
00053 fprintf (stderr, _(" 1: Random colors\n")) ;
00054 fprintf (stderr, _(" 2: Red, green, and blue color ramps\n")) ;
00055 fprintf (stderr, _(" 3: Color wave\n")) ;
00056 fprintf (stderr, _(" 4: Gray scale\n")) ;
00057 fprintf (stderr, _(" 5: Aspect\n")) ;
00058 fprintf (stderr, _(" 6: Rainbow colors\n")) ;
00059 fprintf (stderr, _(" 7: Red through yellow to green\n"));
00060 fprintf (stderr, _(" 8: Green through yellow to red\n"));
00061 fprintf (stderr, _("RETURN quit\n"));
00062 fprintf (stderr, "\n> ") ;
00063
00064 for(;;)
00065 {
00066 if(!G_gets(buff)) goto ASK ;
00067 G_strip (buff);
00068 if (*buff == 0) return -1;
00069 if(sscanf(buff,"%d",&answ) != 1) answ = -1;
00070
00071 switch (answ)
00072 {
00073 case 1: return G_make_random_colors (pcolr, (CELL) min, (CELL) max);
00074 case 2: return G_make_ramp_fp_colors (pcolr, min, max);
00075 case 3: return G_make_wave_fp_colors (pcolr, min, max);
00076 case 4: return G_make_grey_scale_fp_colors (pcolr, min, max);
00077 case 5: return G_make_aspect_fp_colors (pcolr, min, max);
00078 case 6: return G_make_rainbow_fp_colors (pcolr, min, max);
00079 case 7: return G_make_ryg_fp_colors (pcolr, min, max);
00080 case 8: return G_make_gyr_fp_colors (pcolr, min, max);
00081 default:
00082 fprintf (stderr, _("\n%s invalid; Try again > "), buff) ;
00083 break;
00084 }
00085 }
00086 }