change_view.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**
  2. \file change_view.cpp
  3. \brief Experimental C++ wxWidgets Nviz prototype -- Change viewport
  4. Used by wxGUI Nviz extension.
  5. Copyright: (C) by the GRASS Development Team
  6. This program is free software under the GNU General Public
  7. License (>=v2). Read the file COPYING that comes with GRASS
  8. for details.
  9. \author Martin Landa <landa.martin gmail.com> (Google SoC 2008)
  10. \date 2008
  11. */
  12. #include "nviz.h"
  13. /*!
  14. \brief GL canvas resized
  15. \param width window width
  16. \param height window height
  17. \return 1 on success
  18. \return 0 on failure (window resized by dafault to 20x20 px)
  19. */
  20. int Nviz::ResizeWindow(int width, int height)
  21. {
  22. int ret;
  23. ret = Nviz_resize_window(width, height);
  24. G_debug(1, "Nviz::ResizeWindow(): width=%d height=%d",
  25. width, height);
  26. return ret;
  27. }
  28. /*!
  29. \brief Set default view (based on loaded data)
  30. \return z-exag value, default, min and max height
  31. */
  32. std::vector<double> Nviz::SetViewDefault()
  33. {
  34. std::vector<double> ret;
  35. float hdef, hmin, hmax, z_exag;
  36. /* determine z-exag */
  37. z_exag = Nviz_get_exag();
  38. ret.push_back(z_exag);
  39. Nviz_change_exag(data,
  40. z_exag);
  41. /* determine height */
  42. Nviz_get_exag_height(&hdef, &hmin, &hmax);
  43. ret.push_back(hdef);
  44. ret.push_back(hmin);
  45. ret.push_back(hmax);
  46. G_debug(1, "Nviz::SetViewDefault(): hdef=%f, hmin=%f, hmax=%f",
  47. hdef, hmin, hmax);
  48. return ret;
  49. }
  50. /*!
  51. \brief Change view settings
  52. \param x,y position
  53. \param height
  54. \param persp perpective
  55. \param twist
  56. \return 1 on success
  57. */
  58. int Nviz::SetView(float x, float y,
  59. float height, float persp, float twist)
  60. {
  61. Nviz_set_viewpoint_height(data,
  62. height);
  63. Nviz_set_viewpoint_position(data,
  64. x, y);
  65. Nviz_set_viewpoint_twist(data,
  66. twist);
  67. Nviz_set_viewpoint_persp(data,
  68. persp);
  69. G_debug(1, "Nviz::SetView(): x=%f, y=%f, height=%f, persp=%f, twist=%f",
  70. x, y, height, persp, twist);
  71. return 1;
  72. }
  73. /*!
  74. \brief Set z-exag value
  75. \param z_exag value
  76. \return 1
  77. */
  78. int Nviz::SetZExag(float z_exag)
  79. {
  80. int ret;
  81. ret = Nviz_change_exag(data, z_exag);
  82. G_debug(1, "Nviz::SetZExag(): z_exag=%f", z_exag);
  83. return ret;
  84. }