setup.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* D_setup (clear)
  2. *
  3. * This is a high level D call.
  4. * It does a full setup for the current graphics frame.
  5. *
  6. * Note: Connection to driver must already be made.
  7. *
  8. * clear values:
  9. * 1: clear frame (visually and coordinates)
  10. * 0: do not clear frame
  11. */
  12. #include <string.h>
  13. #include <grass/gis.h>
  14. #include <grass/raster.h>
  15. #include <grass/display.h>
  16. /*!
  17. * \brief graphics frame setup
  18. *
  19. * D_setup() sets the source coordinate system to the current region, and
  20. * adjusts the destination coordinate system to preserve the aspect
  21. * ratio.
  22. *
  23. * Performs a full setup for the current graphics frame:
  24. * 1) Makes sure there is a current graphics frame (will create a full-screen
  25. * one, if not);
  26. * 2) Sets the region coordinates so that the graphics frame and the active
  27. * module region agree (may change active module region to do this); and
  28. * 3) Performs graphic frame/region coordinate conversion initialization.
  29. *
  30. * If <b>clear</b> is true, the frame is cleared (same as running
  31. * <i>d.erase</i>.) Otherwise, it is not cleared.
  32. *
  33. * \param clear
  34. * \return none
  35. */
  36. void D_setup(int clear)
  37. {
  38. struct Cell_head region;
  39. double dt, db, dl, dr;
  40. D_get_window(&dt, &db, &dl, &dr);
  41. G_get_set_window(&region);
  42. Rast_set_window(&region);
  43. D_do_conversions(&region, dt, db, dl, dr);
  44. if (clear)
  45. D_erase(DEFAULT_BG_COLOR);
  46. }
  47. /*!
  48. * \brief
  49. *
  50. * D_setup_unity() sets the source coordinate system to match the
  51. * destination coordinate system, so that D_* functions use the same
  52. * coordinate system as R_* functions.
  53. *
  54. * If <b>clear</b> is true, the frame is cleared (same as running
  55. * <i>d.erase</i>.) Otherwise, it is not cleared.
  56. *
  57. * \param clear
  58. * \return none
  59. */
  60. void D_setup_unity(int clear)
  61. {
  62. double dt, db, dl, dr;
  63. D_get_window(&dt, &db, &dl, &dr);
  64. D_set_src(dt, db, dl, dr);
  65. D_set_dst(dt, db, dl, dr);
  66. D_update_conversions();
  67. if (clear)
  68. D_erase(DEFAULT_BG_COLOR);
  69. }
  70. /*!
  71. * \brief
  72. *
  73. * D_setup2() sets the source coordinate system to its arguments, and if
  74. * the <b>fit</b> argument is non-zero, adjusts the destination coordinate
  75. * system to preserve the aspect ratio.
  76. *
  77. * If <b>clear</b> is true, the frame is cleared (same as running
  78. * <i>d.erase</i>.) Otherwise, it is not cleared.
  79. *
  80. * \param clear
  81. * \param fit
  82. * \param s_top
  83. * \param s_bottom
  84. * \param s_left
  85. * \param s_right
  86. * \return none
  87. */
  88. void D_setup2(int clear, int fit, double st, double sb, double sl, double sr)
  89. {
  90. double dt, db, dl, dr;
  91. D_get_window(&dt, &db, &dl, &dr);
  92. D_set_src(st, sb, sl, sr);
  93. D_set_dst(dt, db, dl, dr);
  94. if (fit)
  95. D_fit_d_to_u();
  96. D_update_conversions();
  97. if (clear)
  98. D_erase(DEFAULT_BG_COLOR);
  99. }