change_view.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 height, z-exag value
  31. */
  32. std::vector<double> Nviz::SetViewDefault()
  33. {
  34. std::vector<double> ret;
  35. float vp_height, 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(&vp_height, NULL, NULL);
  43. ret.push_back(vp_height);
  44. /*
  45. SetView(VIEW_DEFAULT_POS_X, VIEW_DEFAULT_POS_Y,
  46. vp_height, VIEW_DEFAULT_PERSP, VIEW_DEFAULT_TWIST);
  47. */
  48. G_debug(1, "Nviz::SetViewDefault()");
  49. return ret;
  50. }
  51. /*!
  52. \brief Change view settings
  53. \param x,y position
  54. \param height
  55. \param persp perpective
  56. \param twist
  57. \return 1 on success
  58. */
  59. int Nviz::SetView(float x, float y,
  60. float height, float persp, float twist)
  61. {
  62. Nviz_set_viewpoint_height(data,
  63. height);
  64. Nviz_set_viewpoint_position(data,
  65. x, y);
  66. Nviz_set_viewpoint_twist(data,
  67. twist);
  68. Nviz_set_viewpoint_persp(data,
  69. persp);
  70. G_debug(1, "Nviz::SetView(): x=%f, y=%f, height=%f, persp=%f, twist=%f",
  71. x, y, height, persp, twist);
  72. return 1;
  73. }
  74. /*!
  75. \brief Set z-exag value
  76. \param z_exag value
  77. \return 1
  78. */
  79. int Nviz::SetZExag(float z_exag)
  80. {
  81. int ret;
  82. ret = Nviz_change_exag(data, z_exag);
  83. G_debug(1, "Nviz::SetZExag(): z_exag=%f", z_exag);
  84. return ret;
  85. }