nviz.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #ifndef GRASS_NVIZ_H
  2. #define GRASS_NVIZ_H
  3. #include <grass/config.h>
  4. /*** Windows headers ***/
  5. #if defined(OPENGL_WINDOWS)
  6. # define WIN32_LEAN_AND_MEAN
  7. # include <windows.h>
  8. # undef WIN32_LEAN_AND_MEAN
  9. # include <winnt.h>
  10. /*** X Window System headers ***/
  11. #elif defined(OPENGL_X11)
  12. # include <X11/Xlib.h>
  13. # include <X11/Xutil.h>
  14. # include <X11/Xatom.h> /* for XA_RGB_DEFAULT_MAP atom */
  15. # if defined(__vms)
  16. # include <X11/StdCmap.h> /* for XmuLookupStandardColormap */
  17. # else
  18. # include <X11/Xmu/StdCmap.h> /* for XmuLookupStandardColormap */
  19. # endif
  20. # include <GL/glx.h>
  21. /*** Mac headers ***/
  22. #elif defined(OPENGL_AQUA)
  23. # define Cursor QDCursor
  24. # include <AGL/agl.h>
  25. # undef Cursor
  26. # include <ApplicationServices/ApplicationServices.h>
  27. #else /* make sure only one platform defined */
  28. # error Unsupported platform, or confused platform defines...
  29. #endif
  30. #include <grass/gsurf.h>
  31. #include <grass/gstypes.h>
  32. #define MAP_OBJ_UNDEFINED 0
  33. #define MAP_OBJ_SURF 1
  34. #define MAP_OBJ_VOL 2
  35. #define MAP_OBJ_VECT 3
  36. #define MAP_OBJ_SITE 4
  37. #define DRAW_COARSE 0
  38. #define DRAW_FINE 1
  39. #define DRAW_BOTH 2
  40. /* quick draw mode */
  41. #define DRAW_QUICK_SURFACE 0x01
  42. #define DRAW_QUICK_VLINES 0x02
  43. #define DRAW_QUICK_VPOINTS 0x04
  44. #define DRAW_QUICK_VOLUME 0x08
  45. #define RANGE (5 * GS_UNIT_SIZE)
  46. #define RANGE_OFFSET (2 * GS_UNIT_SIZE)
  47. #define ZRANGE (3 * GS_UNIT_SIZE)
  48. #define ZRANGE_OFFSET (1 * GS_UNIT_SIZE)
  49. #define DEFAULT_SURF_COLOR 0x33BBFF
  50. #define RED_MASK 0x000000FF
  51. #define GRN_MASK 0x0000FF00
  52. #define BLU_MASK 0x00FF0000
  53. #define FORMAT_PPM 1
  54. #define FORMAT_TIF 2
  55. /* data structures */
  56. typedef struct
  57. {
  58. int id;
  59. float brt;
  60. float r, g, b;
  61. float ar, ag, ab; /* ambient rgb */
  62. float x, y, z, w; /* position */
  63. } light_data;
  64. struct fringe_data
  65. {
  66. int id;
  67. unsigned long color;
  68. float elev;
  69. int where[4];
  70. };
  71. typedef struct
  72. {
  73. /* ranges */
  74. float zrange, xyrange;
  75. /* cplanes */
  76. int num_cplanes;
  77. int cur_cplane, cp_on[MAX_CPLANES];
  78. float cp_trans[MAX_CPLANES][3];
  79. float cp_rot[MAX_CPLANES][3];
  80. /* light */
  81. light_data light[MAX_LIGHTS];
  82. /* fringe */
  83. int num_fringes;
  84. struct fringe_data **fringe;
  85. /* background color */
  86. int bgcolor;
  87. } nv_data;
  88. struct render_window
  89. {
  90. #if defined(OPENGL_X11)
  91. Display *displayId; /* display connection */
  92. GLXContext contextId; /* GLX rendering context */
  93. GLXPixmap windowId;
  94. Pixmap pixmap;
  95. #elif defined(OPENGL_AQUA)
  96. AGLPixelFormat pixelFmtId;
  97. AGLContext contextId;
  98. AGLPbuffer windowId;
  99. #elif defined(OPENGL_WINDOWS)
  100. HDC displayId; /* display context */
  101. HGLRC contextId; /* rendering context */
  102. HBITMAP bitmapId;
  103. #endif
  104. };
  105. /* change_view.c */
  106. int Nviz_resize_window(int, int);
  107. int Nviz_update_ranges(nv_data *);
  108. int Nviz_set_viewpoint_position(double, double);
  109. int Nviz_set_viewpoint_height(double);
  110. int Nviz_set_viewpoint_persp(int);
  111. int Nviz_set_viewpoint_twist(int);
  112. int Nviz_change_exag(nv_data *, double);
  113. /* cplanes_obj.c */
  114. int Nviz_new_cplane(nv_data *, int);
  115. int Nviz_off_cplane(nv_data *, int);
  116. int Nviz_draw_cplane(nv_data *, int, int);
  117. /* draw.c */
  118. int Nviz_draw_all_surf(nv_data *);
  119. int Nviz_draw_all_vect();
  120. int Nviz_draw_all_site();
  121. int Nviz_draw_all_vol();
  122. int Nviz_draw_all(nv_data *);
  123. int Nviz_draw_quick(nv_data *, int);
  124. /* exag.c */
  125. int Nviz_get_exag_height(double *, double *, double *);
  126. double Nviz_get_exag();
  127. /* lights.c */
  128. int Nviz_set_light_position(nv_data *, int, double, double, double, double);
  129. int Nviz_set_light_bright(nv_data *, int, double);
  130. int Nviz_set_light_color(nv_data *, int, int, int, int);
  131. int Nviz_set_light_ambient(nv_data *, int, double);
  132. int Nviz_init_light(nv_data *, int);
  133. int Nviz_new_light(nv_data *);
  134. /* map_obj.c */
  135. int Nviz_new_map_obj(int, const char *, double, nv_data *);
  136. int Nviz_set_attr(int, int, int, int, const char *, double, nv_data *);
  137. void Nviz_set_surface_attr_default();
  138. int Nviz_set_vpoint_attr_default();
  139. int Nviz_set_volume_attr_default();
  140. int Nviz_unset_attr(int, int, int);
  141. /* nviz.c */
  142. void Nviz_init_data(nv_data *);
  143. void Nviz_destroy_data(nv_data *);
  144. void Nviz_set_bgcolor(nv_data *, int);
  145. int Nviz_get_bgcolor(nv_data *);
  146. int Nviz_color_from_str(const char *);
  147. struct fringe_data *Nviz_new_fringe(nv_data *, int, unsigned long,
  148. double, int, int, int, int);
  149. struct fringe_data *Nviz_set_fringe(nv_data *, int, unsigned long,
  150. double, int, int, int, int);
  151. /* position.c */
  152. void Nviz_init_view(nv_data *);
  153. int Nviz_set_focus_state(int);
  154. int Nviz_set_focus_map(int, int);
  155. /* render.c */
  156. struct render_window *Nviz_new_render_window();
  157. void Nviz_init_render_window(struct render_window *);
  158. void Nviz_destroy_render_window(struct render_window *);
  159. int Nviz_create_render_window(struct render_window *, void *, int, int);
  160. int Nviz_make_current_render_window(const struct render_window *);
  161. #endif /* GRASS_NVIZ_H */