cplane.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*!
  2. \file cplane.c
  3. \brief Cutting plane subroutine
  4. (C) 2011 by the GRASS Development Team
  5. This program is free software under the GNU General Public
  6. License (>=v2). Read the file COPYING that comes with GRASS
  7. for details.
  8. \author Anna Kratochvilova <kratochanna gmail.com> (Google SoC 2010/2011)
  9. */
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <grass/glocale.h>
  13. #include "local_proto.h"
  14. /*!
  15. \brief Draw cutting planes and set their attributes
  16. \param params module parameters
  17. \param data nviz data
  18. */
  19. void draw_cplane(const struct GParams *params, nv_data * data)
  20. {
  21. int i, id, ncplanes;
  22. float trans_x, trans_y, trans_z;
  23. float rot_x, rot_y, rot_z;
  24. int fence;
  25. ncplanes = opt_get_num_answers(params->cplane);
  26. for (i = 0; i < ncplanes; i++) {
  27. id = atoi(params->cplane->answers[i]);
  28. if (id < 0 || id > Nviz_num_cplanes(data))
  29. G_fatal_error(_("Cutting plane number <%d> not found"), id);
  30. Nviz_on_cplane(data, id);
  31. trans_x = atof(params->cplane_pos->answers[i * 3 + 0]);
  32. trans_y = atof(params->cplane_pos->answers[i * 3 + 1]);
  33. trans_z = atof(params->cplane_pos->answers[i * 3 + 2]);
  34. Nviz_set_cplane_translation(data, id, trans_x, trans_y, trans_z);
  35. rot_x = 0;
  36. rot_y = atof(params->cplane_tilt->answers[i]);
  37. rot_z = atof(params->cplane_rot->answers[i]);
  38. Nviz_set_cplane_rotation(data, id, rot_x, rot_y, rot_z);
  39. }
  40. const char *shading = params->cplane_shading->answers[0];
  41. if (strcmp(shading, "clear") == 0)
  42. fence = 0;
  43. else if (strcmp(shading, "top") == 0)
  44. fence = 1;
  45. else if (strcmp(shading, "bottom") == 0)
  46. fence = 2;
  47. else if (strcmp(shading, "blend") == 0)
  48. fence = 3;
  49. else if (strcmp(shading, "shaded") == 0)
  50. fence = 4;
  51. else
  52. fence = 0;
  53. Nviz_set_fence_color(data, fence);
  54. return;
  55. }