tbl_toggle.c 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <grass/gis.h>
  2. #include "colors.h"
  3. static int toggle_number;
  4. int table_toggle(char *name, char *mapset, struct Colors *colors)
  5. {
  6. CELL min, max;
  7. char *msg = '\0';
  8. char info[100];
  9. Rast_get_c_color_range(&min, &max, colors);
  10. Rast_free_colors(colors);
  11. sprintf(info, "Color range: %d to %d\n", min, max);
  12. toggle_number++;
  13. toggle_number &= 6;
  14. switch (toggle_number) {
  15. case 0:
  16. msg = "Original colors";
  17. Rast_read_colors(name, mapset, colors);
  18. break;
  19. case 1:
  20. msg = "Ramp colors";
  21. Rast_make_ramp_colors(colors, min, max);
  22. break;
  23. case 2:
  24. msg = "Grey scale colors";
  25. Rast_make_grey_scale_colors(colors, min, max);
  26. break;
  27. case 3:
  28. msg = "Random colors";
  29. Rast_make_random_colors(colors, min, max);
  30. break;
  31. case 4:
  32. msg = "Wave colors";
  33. Rast_make_wave_colors(colors, min, max);
  34. break;
  35. case 5:
  36. msg = "Aspect colors";
  37. Rast_make_aspect_colors(colors, min, max);
  38. break;
  39. }
  40. Write_message(2, msg);
  41. Write_message(3, info);
  42. return 0;
  43. }