get_point.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 <stdio.h>
  19. #include <grass/display.h>
  20. #include "local_proto.h"
  21. /* button 1 is whereami: no return, keep looping
  22. * 2 is mark point, return 1 (ok)
  23. * 3 is done, return 0 (done)
  24. */
  25. int get_point(int *x, int *y, char *east, char *north)
  26. {
  27. int button;
  28. int curx, cury;
  29. curx = *x;
  30. cury = *y;
  31. do {
  32. if (curx >= 0 && cury >= 0)
  33. R_get_location_with_line(curx, cury, &curx, &cury, &button);
  34. else
  35. R_get_location_with_pointer(&curx, &cury, &button);
  36. if (button == 3)
  37. return (0);
  38. get_east_north(curx, cury, east, north);
  39. fprintf(stdout, "EAST: %-20s", east);
  40. fprintf(stdout, "NORTH: %s\n", north);
  41. instructions(1);
  42. } while (button == 1);
  43. *x = curx;
  44. *y = cury;
  45. return (1);
  46. }