get_line.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /****************************************************************************
  2. *
  3. * MODULE: r.digit
  4. *
  5. * AUTHOR(S): Michael Shapiro - CERL
  6. *
  7. * PURPOSE: Interactive tool used to draw and save vector features
  8. * on a graphics monitor using a pointing device (mouse)
  9. * and save to a raster map.
  10. *
  11. * COPYRIGHT: (C) 2006 by the GRASS Development Team
  12. *
  13. * This program is free software under the GNU General Public
  14. * License (>=v2). Read the file COPYING that comes with GRASS
  15. * for details.
  16. *
  17. ***************************************************************************/
  18. #include <grass/gis.h>
  19. #include <grass/display.h>
  20. #include "local_proto.h"
  21. int get_line(FILE * fd, struct Categories *labels)
  22. {
  23. int x, y;
  24. int px = 0, py = 0;
  25. int any;
  26. char east[256], north[256];
  27. instructions(0);
  28. x = y = -9999;
  29. any = 0;
  30. while (get_point(&x, &y, east, north)) {
  31. if (!any) {
  32. fprintf(fd, "LINE\n");
  33. any = 1;
  34. }
  35. else {
  36. black_and_white_line(px, py, x, y);
  37. R_flush();
  38. }
  39. px = x;
  40. py = y;
  41. fprintf(fd, " %s %s\n", east, north);
  42. }
  43. get_category(fd, "line", labels);
  44. return any;
  45. }