vector.cpp 3.4 KB

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