gstypes.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /*
  2. * $Id$
  3. */
  4. /* gstypes.h
  5. Bill Brown, USACERL
  6. January 1993
  7. */
  8. #ifndef _GSTYPES_H
  9. #define _GSTYPES_H
  10. #include <grass/config.h>
  11. #include <grass/gsurf.h>
  12. #include <grass/bitmap.h>
  13. #if defined(OPENGL_X11) || defined(OPENGL_WINDOWS)
  14. #include <GL/gl.h>
  15. #endif
  16. #ifdef OPENGL_AQUA
  17. #include <OpenGL/gl.h>
  18. #endif
  19. /*#define TRACE_FUNCS*/
  20. /*#define DEBUG*/
  21. #define X 0
  22. #define Y 1
  23. #define Z 2
  24. #define W 3
  25. #define FROM 0
  26. #define TO 1
  27. /* colormodes */
  28. #define CM_COLOR 0
  29. #define CM_EMISSION 1
  30. #define CM_AMBIENT 2
  31. #define CM_DIFFUSE 3
  32. #define CM_SPECULAR 4
  33. #define CM_AD 5
  34. #define CM_NULL 6
  35. #define CM_WIRE CM_COLOR
  36. #define NULL_COLOR 0xFFFFFF
  37. /* attribute sizes - NOT YET USED */
  38. #define GS_CHAR8 char
  39. #define GS_SHORT16 short
  40. #define GS_INT32 int
  41. /* attribute ***types*** */
  42. #define ATTY_NULL 32 /* internal use only */
  43. #define ATTY_MASK 16 /* can't use this one for numbytes */
  44. #define ATTY_FLOAT 8 /* can't use this one for numbytes */
  45. #define ATTY_INT 4
  46. #define ATTY_SHORT 2
  47. #define ATTY_CHAR 1
  48. #define ATTY_ANY 63 /* internal use only */
  49. #define LEGAL_TYPE(t) \
  50. (t==ATTY_MASK || t==ATTY_FLOAT || t==ATTY_INT || t==ATTY_SHORT || t==ATTY_CHAR)
  51. #define MAXDIMS 4
  52. #define FUDGE(gs) ((gs->zmax_nz - gs->zmin_nz)/500.)
  53. #define DOT3( a, b ) ( (a)[X]*(b)[X] + (a)[Y]*(b)[Y] + (a)[Z]*(b)[Z] )
  54. /* changed flags for datasets */
  55. #define CF_NOT_CHANGED 0x000000
  56. #define CF_COLOR_PACKED 0x000001
  57. #define CF_USR_CHANGED 0x000010
  58. #define CF_CHARSCALED 0x000100
  59. #define NAME_SIZ 80
  60. #define MAX_TF 6
  61. #define MASK_TL 0x10000000
  62. #define MASK_TR 0x01000000
  63. #define MASK_BR 0x00100000
  64. #define MASK_BL 0x00010000
  65. #define MASK_NPTS 0x00000007
  66. #define OGSF_POINT 1
  67. #define OGSF_LINE 2
  68. #define OGSF_POLYGON 3
  69. typedef float Point4[4];
  70. typedef float Point3[3];
  71. typedef float Point2[2];
  72. typedef struct{
  73. float *fb;
  74. int *ib;
  75. short *sb;
  76. unsigned char *cb;
  77. struct BM *bm;
  78. struct BM *nm; /* null mask: set = null */
  79. float (*tfunc)(float, int);
  80. float k;
  81. } typbuff;
  82. typedef struct{ /* use hash table? */
  83. int n_elem; /* if n_elem == 256, index == NULL */
  84. char *index;
  85. int *value;
  86. } table256;
  87. typedef struct{ /* applied thusly: offset, mult, if(use_lookup) lookup */
  88. float offset;
  89. float mult;
  90. int use_lookup;
  91. table256 lookup;
  92. } transform;
  93. /* move this to dataset file? */
  94. typedef struct{
  95. int data_id;
  96. int dims[MAXDIMS];
  97. int ndims;
  98. int numbytes;
  99. char unique_name[NAME_SIZ];
  100. typbuff databuff;
  101. IFLAG changed;
  102. int need_reload;
  103. } dataset;
  104. /* maybe add transformation matrix? */
  105. typedef struct{
  106. IFLAG att_src; /* NOTSET_ATT, MAP_ATT, CONST_ATT, FUNC_ATT */
  107. IFLAG att_type; /* ATTY_INT, ATTY_SHORT, ATTY_CHAR, or ATTY_FLOAT */
  108. int hdata; /* handle to dataset */
  109. int (*user_func)();
  110. float constant;
  111. int *lookup; /* TODO: use transform instead */
  112. float min_nz, max_nz, range_nz;
  113. float default_null;
  114. } gsurf_att;
  115. typedef struct g_surf{
  116. int gsurf_id;
  117. int cols, rows;
  118. gsurf_att att[MAX_ATTS]; /* mask, topo, color, etc. */
  119. IFLAG draw_mode; /*DM_GOURAUD | DM_FRINGE | DM_POLY, DM_WIRE, DM_WIRE_POLY*/
  120. long wire_color; /* 0xBBGGRR or WC_COLOR_ATT */
  121. double ox, oy; /* real world origin (i.e., SW corner) */
  122. double xres, yres;
  123. float z_exag;
  124. float x_trans, y_trans, z_trans;
  125. float xmin, xmax, ymin, ymax, zmin, zmax, zminmasked;
  126. float xrange, yrange, zrange;
  127. float zmin_nz, zmax_nz, zrange_nz;
  128. int x_mod, y_mod, x_modw, y_modw; /*cells per viewcell, per wire viewcell*/
  129. int nz_topo, nz_color; /* no zero flags */
  130. int mask_needupdate, norm_needupdate;
  131. unsigned long *norms;
  132. struct BM *curmask;
  133. struct g_surf *next;
  134. void *clientdata;
  135. } geosurf;
  136. /* maybe put attribute info here instead of in geovect - allow a single
  137. vector file to have multiple attributes ? Cached lines should
  138. usually be stored as 2d, since they may be draped on multiple
  139. surfaces & Z will vary depending upon surface. */
  140. typedef struct g_line{
  141. int type;
  142. float norm[3];
  143. int dims, npts;
  144. Point3 *p3;
  145. Point2 *p2;
  146. struct g_line *next;
  147. } geoline;
  148. typedef struct g_vect{
  149. int gvect_id;
  150. int use_mem, n_lines;
  151. int drape_surf_id[MAX_SURFS]; /* if you want 'em flat, define the surface */
  152. int flat_val;
  153. int n_surfs;
  154. int color, width;
  155. char filename[NAME_SIZ];
  156. float x_trans, y_trans, z_trans;
  157. /* also maybe center & rotate? */
  158. geoline *lines;
  159. geoline *fastlines;
  160. int (*bgn_read)(), (*end_read)(), (*nxt_line)();
  161. struct g_vect *next;
  162. void *clientdata;
  163. } geovect;
  164. /* ACS_MODIFY one line site_attr ***********************************************/
  165. #define GPT_MAX_ATTR 8
  166. typedef struct g_point{
  167. int dims;
  168. Point3 p3;
  169. float fattr; /* may want to make these pointers or arrays for mult atts */
  170. int iattr;
  171. char *cattr;
  172. /* ACS_MODIFY_BEGIN site_attr **************************************************/
  173. int cat;
  174. int color[GPT_MAX_ATTR];
  175. float size[GPT_MAX_ATTR];
  176. int marker[GPT_MAX_ATTR];
  177. /* ACS_MODIFY_END site_attr ****************************************************/
  178. /* ACS_MODIFY_BEGIN highlight **************************************************/
  179. int highlight_color;
  180. int highlight_size;
  181. int highlight_marker;
  182. int highlight_color_value;
  183. float highlight_size_value;
  184. int highlight_marker_value;
  185. /* ACS_MODIFY_END highlight ****************************************************/
  186. struct g_point *next;
  187. } geopoint;
  188. typedef struct g_site{
  189. int gsite_id;
  190. int drape_surf_id[MAX_SURFS]; /* ditto */
  191. int n_surfs, n_sites;
  192. int color, width, marker, use_z, use_mem;
  193. int has_z, has_att; /* set when file loaded */
  194. int attr_mode; /* ST_ATT_COLOR, ST_ATT_MARKER, ST_ATT_SIZE, ST_ATT_NONE */
  195. /* ACS_MODIFY OneLine site_attr ************************************************/
  196. int use_attr[GPT_MAX_ATTR]; /* ST_ATT_COLOR, ST_ATT_MARKER, ST_ATT_SIZE, ST_ATT_NONE, for multiple attr's */
  197. char filename[NAME_SIZ];
  198. transform attr_trans;
  199. float size;
  200. float x_trans, y_trans, z_trans;
  201. geopoint *points;
  202. int (*bgn_read)(), (*end_read)(), (*nxt_site)();
  203. struct g_site *next;
  204. void *clientdata;
  205. } geosite;
  206. typedef struct
  207. {
  208. int data_id; /* id */
  209. IFLAG file_type; /* file type */
  210. unsigned int count; /* number of referencies to this file */
  211. char file_name[NAME_SIZ]; /* file name */
  212. IFLAG data_type;
  213. void *map; /* pointer to volume file descriptor */
  214. double min, max; /* minimum, maximum value in file */
  215. IFLAG status; /* current status */
  216. IFLAG mode; /* current read mode */
  217. void *buff; /* data buffer */
  218. } geovol_file;
  219. typedef struct{
  220. IFLAG att_src;
  221. int hfile;
  222. int (*user_func)();
  223. float constant;
  224. void *att_data;
  225. int changed;
  226. } geovol_isosurf_att;
  227. typedef struct{
  228. int inout_mode;
  229. geovol_isosurf_att att[MAX_ATTS];
  230. int data_desc;
  231. unsigned char *data;
  232. } geovol_isosurf;
  233. typedef struct{
  234. int dir;
  235. float x1, x2, y1, y2, z1, z2;
  236. unsigned char *data;
  237. int changed;
  238. int mode, transp;
  239. } geovol_slice;
  240. typedef struct g_vol{
  241. int gvol_id;
  242. struct g_vol *next;
  243. int hfile;
  244. int cols, rows, depths;
  245. double ox, oy, oz;
  246. double xres, yres, zres;
  247. double xmin, xmax, ymin, ymax, zmin, zmax;
  248. double xrange, yrange, zrange;
  249. float x_trans, y_trans, z_trans;
  250. int n_isosurfs;
  251. geovol_isosurf *isosurf[MAX_ISOSURFS];
  252. int isosurf_x_mod, isosurf_y_mod, isosurf_z_mod;
  253. IFLAG isosurf_draw_mode;
  254. int n_slices;
  255. geovol_slice *slice[MAX_SLICES];
  256. int slice_x_mod, slice_y_mod, slice_z_mod;
  257. IFLAG slice_draw_mode;
  258. void *clientdata;
  259. } geovol;
  260. struct lightdefs{
  261. float position[4]; /* X, Y, Z, (1=local/0=inf) */
  262. float color[3]; /* R, G, B */
  263. float ambient[3]; /* R, G, B */
  264. float emission[3]; /* R, G, B */
  265. float shine; /* 0. to 128. */
  266. };
  267. typedef struct{
  268. int coord_sys; /* latlon, equal area, etc */
  269. int view_proj; /* perspective, ortho */
  270. int infocus; /* fixed center of view - true or false */
  271. float from_to[2][4];
  272. int twist, fov, incl, look; /* 10ths of degrees */
  273. float real_to[4], vert_exag; /* a global Z exag */
  274. float scale;
  275. struct lightdefs lights[MAX_LIGHTS];
  276. } geoview;
  277. typedef struct{ /* need to add elements here for off_screen drawing */
  278. float nearclip, farclip, aspect;
  279. short left, right, bottom, top; /* Screen coordinates */
  280. int bgcol;
  281. } geodisplay;
  282. extern void (*Cxl_func)();
  283. extern void (*Swap_func)();
  284. /* Bring all the function prototypes */
  285. #include "ogsf_proto.h"
  286. #endif /* _GSTYPES_H */