g3dwindow.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include <stdio.h>
  2. #include <grass/gis.h>
  3. #include <grass/G3d.h>
  4. #include "G3d_intern.h"
  5. /*---------------------------------------------------------------------------*/
  6. G3D_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 G3d_setWindowMap(G3D_Map * map, G3D_Region * window)
  19. {
  20. G3d_regionCopy(&(map->window), window);
  21. G3d_adjustRegion(&(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 G3d_setWindow(G3D_Region * window)
  34. {
  35. G3d_regionCopy(&g3d_window, window);
  36. G3d_adjustRegion(&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 G3d_getWindow(G3D_Region * window)
  48. {
  49. G3d_regionCopy(window, &g3d_window);
  50. }
  51. /*---------------------------------------------------------------------------*/
  52. G3D_Region *G3d_windowPtr()
  53. {
  54. return &g3d_window;
  55. }
  56. /*---------------------------------------------------------------------------*/
  57. /*!
  58. * \brief
  59. *
  60. * Returns 1 if window-coordinates <em>(north, west, bottom)</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 G3d_isValidLocationWindow(G3D_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. }