00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <grass/gis.h>
00024 #include <grass/glocale.h>
00025
00026 int G_ask_colors(const char *name, const char *mapset, struct Colors *pcolr)
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 sprintf(buff, _(" The raster map %s@%s is empty"), name, mapset);
00041 G_warning(buff);
00042 return -1;
00043 }
00044
00045
00046 ASK:
00047 G_clear_screen();
00048 fprintf(stderr,
00049 _("\n\nColor table needed for file [%s] in mapset [%s].\n"), name,
00050 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 if (!G_gets(buff))
00066 goto ASK;
00067 G_strip(buff);
00068 if (*buff == 0)
00069 return -1;
00070 if (sscanf(buff, "%d", &answ) != 1)
00071 answ = -1;
00072
00073 switch (answ) {
00074 case 1:
00075 return G_make_random_colors(pcolr, (CELL) min, (CELL) max);
00076 case 2:
00077 return G_make_ramp_fp_colors(pcolr, min, max);
00078 case 3:
00079 return G_make_wave_fp_colors(pcolr, min, max);
00080 case 4:
00081 return G_make_grey_scale_fp_colors(pcolr, min, max);
00082 case 5:
00083 return G_make_aspect_fp_colors(pcolr, min, max);
00084 case 6:
00085 return G_make_rainbow_fp_colors(pcolr, min, max);
00086 case 7:
00087 return G_make_ryg_fp_colors(pcolr, min, max);
00088 case 8:
00089 return G_make_gyr_fp_colors(pcolr, min, max);
00090 default:
00091 fprintf(stderr, _("\n%s invalid; Try again > "), buff);
00092 break;
00093 }
00094 }
00095 }