make_colr.c

Go to the documentation of this file.
00001 /**********************************************************************
00002  *
00003  *   G_make_color (name, mapset, colors)
00004  *       char *name               name of map
00005  *       char *mapset             mapset containing name
00006  *       struct Colors *colors    struct to hold colors
00007  *
00008  *   Interactively prompts user for deciding which type of color
00009  *   lookup table is desired.
00010  *       Red, green, and blue color ramps
00011  *       Gray scale
00012  *       Rainbow colors
00013  *       Random colors
00014  *       Color wave
00015  *       Aspect colors
00016  *       Red through yellow to green
00017  *
00018  *   Returns -1 user canceled the request
00019  *            1 color table is ok
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 /* determine range cell values */
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 /* Prompting */
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 }

Generated on Wed Dec 19 14:59:06 2007 for GRASS by  doxygen 1.5.4