change_view.cpp 2.2 KB

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