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