vector.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. \file vector.cpp
  3. \brief Experimental C++ wxWidgets Nviz prototype -- vector mode and attributes
  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 Set mode of vector overlay
  15. \param id vector id
  16. \param color_str color string
  17. \param width line width
  18. \param flat
  19. */
  20. int Nviz::SetVectorLineMode(int id, const char *color_str,
  21. int width, int flat)
  22. {
  23. int color;
  24. if(!GV_vect_exists(id))
  25. return 0;
  26. G_debug(1, "Nviz::SetVectorMode(): id=%d, color=%s, width=%d, flat=%d",
  27. id, color_str, width, flat);
  28. color = Nviz_color_from_str(color_str);
  29. /* use memory by default */
  30. if (GV_set_vectmode(id, 1, color, width, flat) < 0)
  31. return 0;
  32. return 1;
  33. }
  34. /**
  35. \brief Set vector height above surface
  36. \param id vector set id
  37. \param height
  38. \return 1 on success
  39. \return 0 on failure
  40. */
  41. int Nviz::SetVectorHeight(int id, float height)
  42. {
  43. if(!GV_vect_exists(id))
  44. return 0;
  45. G_debug(1, "Nviz::SetVectorHeight(): id=%d, height=%f",
  46. id, height);
  47. GV_set_trans(id, 0.0, 0.0, height);
  48. return 1;
  49. }
  50. /**
  51. \brief Set reference surface of vector set
  52. \param id vector set id
  53. \param surf_id surface id
  54. \return 1 on success
  55. \return 0 on failure
  56. */
  57. int Nviz::SetVectorSurface(int id, int surf_id)
  58. {
  59. if (!GS_surf_exists(surf_id) || !GV_vect_exists(id))
  60. return 0;
  61. if (GV_select_surf(id, surf_id) < 0)
  62. return 0;
  63. return 1;
  64. }