gstypes.h 9.1 KB

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