window.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include <stdio.h>
  2. #include <grass/gis.h>
  3. #include <grass/raster3d.h>
  4. #include "raster3d_intern.h"
  5. /*---------------------------------------------------------------------------*/
  6. RASTER3D_Region g3d_window;
  7. /*---------------------------------------------------------------------------*/
  8. /*!
  9. * \brief
  10. *
  11. * Sets the window for <em>map</em> to <em>window</em>.
  12. * Can be used multiple times for the same map.
  13. *
  14. * \param map
  15. * \param window
  16. * \return void
  17. */
  18. void Rast3d_set_window_map(RASTER3D_Map * map, RASTER3D_Region * window)
  19. {
  20. Rast3d_region_copy(&(map->window), window);
  21. Rast3d_adjust_region(&(map->window));
  22. }
  23. /*---------------------------------------------------------------------------*/
  24. /*!
  25. * \brief
  26. *
  27. * Sets the default window used for every map opened later in the program.
  28. * Can be used multiple times in the same program.
  29. *
  30. * \param window
  31. * \return void
  32. */
  33. void Rast3d_set_window(RASTER3D_Region * window)
  34. {
  35. Rast3d_region_copy(&g3d_window, window);
  36. Rast3d_adjust_region(&g3d_window);
  37. }
  38. /*---------------------------------------------------------------------------*/
  39. /*!
  40. * \brief
  41. *
  42. * Stores the current default window in <em>window</em>.
  43. *
  44. * \param window
  45. * \return void
  46. */
  47. void Rast3d_get_window(RASTER3D_Region * window)
  48. {
  49. Rast3d_region_copy(window, &g3d_window);
  50. }
  51. /*---------------------------------------------------------------------------*/
  52. RASTER3D_Region *Rast3d_window_ptr()
  53. {
  54. return &g3d_window;
  55. }
  56. /*---------------------------------------------------------------------------*/
  57. /*!
  58. * \brief
  59. *
  60. * Returns 1 if window-coordinates <em>(north, east and top)</em> are
  61. * inside the window of <em>map</em>. Returns 0 otherwise.
  62. *
  63. * \param map
  64. * \param north
  65. * \param east
  66. * \param top
  67. * \return int
  68. */
  69. int Rast3d_isValidLocationWindow(RASTER3D_Map * map, double north, double east, double top)
  70. {
  71. return ((north >= map->window.south) && (north <= map->window.north) &&
  72. (east >= map->window.west) && (east <= map->window.east) &&
  73. (((top >= map->window.bottom) && (top <= map->window.top)) ||
  74. ((top <= map->window.bottom) && (top >= map->window.top))));
  75. }