set_window.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*!
  2. * \file gis/set_window.c
  3. *
  4. * \brief GIS Library - Set window (map region)
  5. *
  6. * (C) 2001-2009 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public License
  9. * (>=v2). Read the file COPYING that comes with GRASS for details.
  10. *
  11. * \author Original author CERL
  12. */
  13. #include <grass/gis.h>
  14. #include <grass/glocale.h>
  15. #include "G.h"
  16. /*!
  17. * \brief Get the current working window (region)
  18. *
  19. * The current working window values are returned in the structure
  20. * <i>window</i>.
  21. *
  22. * \param[in,out] window window structure to be set
  23. */
  24. void G_get_set_window(struct Cell_head *window)
  25. {
  26. G__init_window();
  27. G_copy(window, &G__.window, sizeof(*window));
  28. }
  29. /*!
  30. * \brief Establishes 'window' as the current working window.
  31. *
  32. * \param window window to become operative window
  33. *
  34. * \return -1 on error
  35. * \return 1 on success
  36. */
  37. int G_set_window(struct Cell_head *window)
  38. {
  39. const char *err;
  40. /* adjust window, check for valid window */
  41. /* adjust the real one, not a copy
  42. G_copy (&twindow, window, sizeof(struct Cell_head));
  43. window = &twindow;
  44. */
  45. if ((err = G_adjust_Cell_head(window, 0, 0))) {
  46. G_warning("G_set_window(): %s", err);
  47. return -1;
  48. }
  49. /* copy the window to the current window */
  50. G_copy((char *)&G__.window, (char *)window, sizeof(*window));
  51. G__.window_set = 1;
  52. return 1;
  53. }