quit.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <grass/gis.h>
  5. #include <grass/display.h>
  6. #include "local_proto.h"
  7. #include <grass/glocale.h>
  8. int quit(struct Cell_head *defwin, struct Cell_head *currwin)
  9. {
  10. int screen_x, screen_y, button;
  11. int hand = 0;
  12. double ux1, uy1, ux2, uy2, ew, ns;
  13. fprintf(stderr, "\n\nButtons:\n");
  14. fprintf(stderr, "Left: reset to default region\n");
  15. fprintf(stderr, "Middle: reset to region before d.zoom started\n");
  16. fprintf(stderr, "Right: Quit\n");
  17. R_get_location_with_pointer(&screen_x, &screen_y, &button);
  18. if (button == 1) {
  19. ew = defwin->east - defwin->west;
  20. ns = defwin->north - defwin->south;
  21. if (ns <= defwin->ns_res) {
  22. ns = 2 * defwin->ns_res;
  23. }
  24. if (ew <= defwin->ew_res) {
  25. ew = 2 * defwin->ew_res;
  26. }
  27. ux1 = defwin->east;
  28. ux2 = defwin->west;
  29. uy1 = defwin->north;
  30. uy2 = defwin->south;
  31. set_win(defwin, ux1, uy1, ux2, uy2, hand);
  32. return 0;
  33. }
  34. if (button == 2) {
  35. ew = currwin->east - currwin->west;
  36. ns = currwin->north - currwin->south;
  37. if (ns <= currwin->ns_res) {
  38. ns = 2 * currwin->ns_res;
  39. }
  40. if (ew <= currwin->ew_res) {
  41. ew = 2 * currwin->ew_res;
  42. }
  43. ux1 = currwin->east;
  44. ux2 = currwin->west;
  45. uy1 = currwin->north;
  46. uy2 = currwin->south;
  47. set_win(currwin, ux1, uy1, ux2, uy2, hand);
  48. return 0;
  49. }
  50. if (button == 3) {
  51. return 0;
  52. }
  53. return 0;
  54. }