vector.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /**
  2. \file nviz/vector.cpp
  3. \brief wxNviz extension (3D view mode) - vector attributes
  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 Set mode of vector line overlay
  13. \param id vector id
  14. \param color_str color string
  15. \param width line width
  16. \param flat display flat or on surface
  17. \return -1 vector set not found
  18. \return -2 on failure
  19. \return 1 on success
  20. */
  21. int Nviz::SetVectorLineMode(int id, const char *color_str,
  22. int width, int flat)
  23. {
  24. int color;
  25. if(!GV_vect_exists(id))
  26. return -1;
  27. G_debug(1, "Nviz::SetVectorMode(): id=%d, color=%s, width=%d, flat=%d",
  28. id, color_str, width, flat);
  29. color = Nviz_color_from_str(color_str);
  30. /* use memory by default */
  31. if (GV_set_vectmode(id, 1, color, width, flat) < 0)
  32. return -2;
  33. return 1;
  34. }
  35. /**
  36. \brief Set vector height above surface (lines)
  37. \param id vector set id
  38. \param height
  39. \return -1 vector set not found
  40. \return 1 on success
  41. */
  42. int Nviz::SetVectorLineHeight(int id, float height)
  43. {
  44. if(!GV_vect_exists(id))
  45. return -1;
  46. G_debug(1, "Nviz::SetVectorLineHeight(): id=%d, height=%f",
  47. id, height);
  48. GV_set_trans(id, 0.0, 0.0, height);
  49. return 1;
  50. }
  51. /**
  52. \brief Set reference surface of vector set (lines)
  53. \param id vector set id
  54. \param surf_id surface id
  55. \return 1 on success
  56. \return -1 vector set not found
  57. \return -2 surface not found
  58. \return -3 on failure
  59. */
  60. int Nviz::SetVectorLineSurface(int id, int surf_id)
  61. {
  62. if (!GV_vect_exists(id))
  63. return -1;
  64. if (!GS_surf_exists(surf_id))
  65. return -2;
  66. if (GV_select_surf(id, surf_id) < 0)
  67. return -3;
  68. return 1;
  69. }
  70. /**
  71. \brief Set mode of vector point overlay
  72. \param id vector id
  73. \param color_str color string
  74. \param width line width
  75. \param flat
  76. \return -1 vector set not found
  77. */
  78. int Nviz::SetVectorPointMode(int id, const char *color_str,
  79. int width, float size, int marker)
  80. {
  81. int color;
  82. if(!GP_site_exists(id))
  83. return -1;
  84. G_debug(1, "Nviz::SetVectorPointMode(): id=%d, color=%s, "
  85. "width=%d, size=%f, marker=%d",
  86. id, color_str, width, size, marker);
  87. color = Nviz_color_from_str(color_str);
  88. if (GP_set_style(id, color, width, size, marker) < 0)
  89. return -2;
  90. return 1;
  91. }
  92. /**
  93. \brief Set vector height above surface (points)
  94. \param id vector set id
  95. \param height
  96. \return -1 vector set not found
  97. \return 1 on success
  98. */
  99. int Nviz::SetVectorPointHeight(int id, float height)
  100. {
  101. if(!GP_site_exists(id))
  102. return -1;
  103. G_debug(1, "Nviz::SetVectorPointHeight(): id=%d, height=%f",
  104. id, height);
  105. GP_set_trans(id, 0.0, 0.0, height);
  106. return 1;
  107. }
  108. /**
  109. \brief Set reference surface of vector set (points)
  110. \param id vector set id
  111. \param surf_id surface id
  112. \return 1 on success
  113. \return -1 vector set not found
  114. \return -2 surface not found
  115. \return -3 on failure
  116. */
  117. int Nviz::SetVectorPointSurface(int id, int surf_id)
  118. {
  119. if (!GP_site_exists(id))
  120. return -1;
  121. if (!GS_surf_exists(surf_id))
  122. return -2;
  123. if (GP_select_surf(id, surf_id) < 0)
  124. return -3;
  125. return 1;
  126. }