35 #include <grass/config.h> 37 #if defined(OPENGL_X11) || defined(OPENGL_WINDOWS) 40 #elif defined(OPENGL_AQUA) 41 #include <OpenGL/gl.h> 42 #include <OpenGL/glu.h> 45 #include <grass/gis.h> 46 #include <grass/raster.h> 47 #include <grass/ogsf.h> 48 #include <grass/glocale.h> 64 static int Surf_ID[MAX_SURFS];
65 static int Next_surf = 0;
66 static int SDref_surf = 0;
69 static float Default_const[MAX_ATTS];
70 static float Default_nulls[MAX_ATTS];
76 static float Region[4];
79 static struct Cell_head wind;
80 static int Buffermode;
81 static int Numlights = 0;
82 static int Resetlight = 1;
83 static int Modelshowing = 0;
103 Region[0] = wind.north;
104 Region[1] = wind.south;
105 Region[2] = wind.west;
106 Region[3] = wind.east;
109 if ((wind.east - wind.west) > (wind.north - wind.south)) {
110 Longdim = (wind.east - wind.west);
113 Longdim = (wind.north - wind.south);
116 Gv.scale = GS_UNIT_SIZE / Longdim;
118 G_debug(1,
"GS_libinit(): n=%f s=%f w=%f e=%f scale=%f first=%d",
119 Region[0], Region[1], Region[2], Region[3], Gv.scale, first);
145 G_debug(3,
"GS_get_longdim(): dim=%g", *dim);
177 G_debug(3,
"GS_set_att_defaults");
179 for (i = 0; i < MAX_ATTS; i++) {
180 Default_const[i] = defs[i];
181 Default_nulls[i] = null_defs[i];
199 G_debug(3,
"GS_surf_exists(): id=%d",
id);
206 for (i = 0; i < Next_surf && !found; i++) {
207 if (Surf_ID[i] ==
id) {
229 G_debug(3,
"GS_new_surface():");
231 if (Next_surf < MAX_SURFS) {
234 wind.south + wind.ns_res / 2., wind.rows, wind.cols,
235 wind.ew_res, wind.ns_res);
241 Surf_ID[Next_surf] = ns->gsurf_id;
244 G_debug(3,
" id=%d", ns->gsurf_id);
246 return (ns->gsurf_id);
277 for (i = 0; i < MAX_LIGHTS; i++) {
278 Gv.lights[i].position[
X] = Gv.lights[i].position[
Y] = 0.0;
279 Gv.lights[i].position[Z] = 1.0;
280 Gv.lights[i].position[W] = 0.0;
281 Gv.lights[i].color[0] = Gv.lights[i].color[1] =
282 Gv.lights[i].color[2] = 1.0;
283 Gv.lights[i].ambient[0] = Gv.lights[i].ambient[1] =
284 Gv.lights[i].ambient[2] = 0.2;
285 Gv.lights[i].shine = 32.0;
291 if (Numlights < MAX_LIGHTS) {
315 if (num < Numlights) {
316 Gv.lights[num].position[
X] = xpos;
317 Gv.lights[num].position[
Y] = ypos;
318 Gv.lights[num].position[Z] = zpos;
319 Gv.lights[num].position[W] = (float)local;
341 if (num < Numlights) {
342 *xpos = Gv.lights[num].position[
X];
343 *ypos = Gv.lights[num].position[
Y];
344 *zpos = Gv.lights[num].position[Z];
345 *local = (int)Gv.lights[num].position[W];
363 if (num < Numlights) {
364 Gv.lights[num].color[0] = red;
365 Gv.lights[num].color[1] = green;
366 Gv.lights[num].color[2] = blue;
385 if (num < Numlights) {
386 *red = Gv.lights[num].color[0];
387 *green = Gv.lights[num].color[1];
388 *blue = Gv.lights[num].color[2];
407 if (num < Numlights) {
408 Gv.lights[num].ambient[0] = red;
409 Gv.lights[num].ambient[1] = green;
410 Gv.lights[num].ambient[2] = blue;
429 if (num < Numlights) {
430 *red = Gv.lights[num].ambient[0];
431 *green = Gv.lights[num].ambient[1];
432 *blue = Gv.lights[num].ambient[2];
447 for (i = 0; i < Numlights; i++) {
461 for (i = 0; i < Numlights; i++) {
479 if (num < Numlights) {
516 G_debug(1,
"GS_get_modelposition1(): model position: %f %f %f",
517 pos[
X], pos[
Y], pos[Z]);
534 float dist, near_h, dir[3];
536 dist = 2. * Gd.nearclip;
538 near_h = 2.0 * tan(4.0 * atan(1.) * Gv.fov / 3600.) * dist;
544 if (*siz > Gd.nearclip) {
548 GS_v3dir(Gv.from_to[FROM], Gv.from_to[TO], dir);
550 pos[
X] = Gv.from_to[FROM][
X] + dir[
X] * dist;
551 pos[
Y] = Gv.from_to[FROM][
Y] + dir[
Y] * dist;
552 pos[Z] = Gv.from_to[FROM][Z] + dir[Z] * dist;
573 GLdouble modelMatrix[16], projMatrix[16];
580 pos2[
X] = (float)x - gs->ox + gs->x_trans;
581 pos2[Y] = (
float)y - gs->oy + gs->y_trans;
582 pos2[Z] = (float)z + gs->z_trans;
595 glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
596 glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
597 glGetIntegerv(GL_VIEWPORT, viewport);
600 GLdouble out_near[3], out_far[3];
604 z = (float)gs->zmax + gs->z_trans;
606 gluUnProject((GLdouble) pt[
X], (GLdouble) pt[Y], (GLdouble) 0.,
607 modelMatrix, projMatrix, viewport,
608 &out_near[
X], &out_near[
Y], &out_near[Z]);
609 gluUnProject((GLdouble) pt[X], (GLdouble) pt[Y], (GLdouble) 1.,
610 modelMatrix, projMatrix, viewport,
611 &out_far[X], &out_far[Y], &out_far[Z]);
615 factor = (out_near[Z] - z) / (out_near[Z] - out_far[Z]);
617 out[
X] = out_near[
X] - ((out_near[
X] - out_far[
X]) * factor);
618 out[
Y] = out_near[
Y] - ((out_near[
Y] - out_far[
Y]) * factor);
621 pos2[
X] = (float)out[X];
622 pos2[
Y] = (float)out[Y];
623 pos2[Z] = (float)out[Z];
649 style.size = siz / 200.;
650 pos[
X] = pt[
X] - gs->ox;
651 pos[
Y] = pt[
Y] - gs->oy;
661 pos[Z] = gs->att[ATT_TOPO].constant;
664 style.color = Gd.bgcol;
665 style.symbol = ST_GYRO;
760 float nv[3], pdir[2], mult;
761 float p1[2], p2[2], next[2];
774 if (pdir[X] == 0.0 && pdir[Y] == 0.0) {
778 p2[
X] = p1[
X] + (pdir[
X] * mult);
779 p2[
Y] = p1[
Y] + (pdir[
Y] * mult);
784 p2[
X] = p1[
X] + (nv[
X] * mult);
785 p2[
Y] = p1[
Y] + (nv[
Y] * mult);
802 p2[X], p2[Y], next, 3)) {
810 G_debug(3,
"GS_draw_flowline_at_xy(): dir: %f %f", nv[X], nv[Y]);
828 G_debug(3,
"GS_draw_fringe(): id: %d clr: %ld elev %f edges: %d %d %d %d",
829 id, clr, elev, where[0], where[1], where[2], where[3]);
850 float *range,
int *pt)
904 static float center[3];
922 tcenter[Z] *= Gv.vert_exag;
944 static float center[3], size;
945 float tcenter[3], tsize;
946 int i, wason[MAX_CPLANES];
950 for (i = 0; i < MAX_CPLANES; i++) {
977 for (i = 0; i < MAX_CPLANES; i++) {
1022 tmp[
X] = pt[
X] - gs->ox;
1023 tmp[
Y] = pt[
Y] - gs->oy;
1141 int GS_get_att(
int id,
int att,
int *
set,
float *constant,
char *mapname)
1151 if (src == CONST_ATT) {
1152 *constant = gs->att[att].constant;
1154 else if (src == MAP_ATT) {
1186 int offset, drow, dcol, vrow, vcol;
1211 sprintf(catstr, _(
"no category info"));
1222 offset =
DRC2OFF(gs, drow, dcol);
1227 drow, dcol, catstr));
1230 sprintf(catstr, _(
"no data"));
1249 int offset, drow, dcol, vrow, vcol;
1259 if (gs->norm_needupdate) {
1280 offset =
DRC2OFF(gs, drow, dcol);
1283 FNORM(gs->norms[offset], nv);
1313 int offset, drow, dcol, vrow, vcol;
1339 if (att == ATT_COLOR) {
1342 i = gs->att[att].constant;
1343 sprintf(valstr,
"R%d G%d B%d",
1347 sprintf(valstr,
"%f", gs->att[att].constant);
1363 offset =
DRC2OFF(gs, drow, dcol);
1366 if (att == ATT_COLOR) {
1370 &(gs->att[ATT_COLOR]), offset);
1371 sprintf(valstr,
"R%d G%d B%d",
1375 sprintf(valstr,
"%f", ftmp);
1381 sprintf(valstr,
"NULL");
1399 gs->mask_needupdate = 1;
1444 gs->att[ATT_MASK].constant = mode;
1445 gs->mask_needupdate = 1;
1469 *mode = gs->att[ATT_MASK].constant;
1492 gs->clientdata = clientd;
1514 return (gs->clientdata);
1544 *numsurfs = Next_surf;
1547 ret = (
int *)G_malloc(Next_surf *
sizeof(
int));
1549 for (i = 0; i < Next_surf; i++) {
1550 ret[i] = Surf_ID[i];
1573 G_debug(1,
"GS_delete_surface(): id=%d",
id);
1577 for (i = 0; i < Next_surf && !found; i++) {
1578 if (Surf_ID[i] ==
id) {
1581 for (j = i; j < Next_surf; j++) {
1582 Surf_ID[j] = Surf_ID[j + 1];
1612 unsigned int changed;
1615 struct Cell_head rast_head;
1616 int reuse, begin, hdata, ret, neg, has_null;
1619 G_debug(3,
"GS_load_att_map(): map=%s", filename);
1621 reuse = ret = neg = has_null = 0;
1628 gs->mask_needupdate = (ATT_MASK == att || ATT_TOPO == att ||
1629 (gs->nz_topo && ATT_TOPO == att) ||
1630 (gs->nz_color && ATT_COLOR == att));
1643 if (mapset ==
NULL) {
1645 G_warning(
"Raster map <%s> not found", filename);
1650 Rast_get_cellhd(filename, mapset, &rast_head);
1651 if (rast_head.north <= wind.south ||
1652 rast_head.south >= wind.north ||
1653 rast_head.east <= wind.west || rast_head.west >= wind.east) {
1655 G_warning(_(
"Raster map <%s> is outside of current region. Load failed."),
1659 while (!reuse && (0 < hdata)) {
1660 changed = CF_COLOR_PACKED;
1661 atty = ATTY_FLOAT | ATTY_CHAR | ATTY_INT | ATTY_SHORT | ATTY_MASK;
1663 if (0 < (hdata =
gsds_findh(filename, &changed, &atty, begin))) {
1665 G_debug(3,
"GS_load_att_map(): %s already has data handle %d.CF=%x",
1666 filename, hdata, changed);
1669 if (ATT_COLOR == att) {
1670 if ((changed == CF_COLOR_PACKED) ||
1671 (!changed && atty == ATTY_CHAR)) {
1675 else if (atty == ATTY_MASK && att != ATT_MASK) {
1680 else if (!changed) {
1689 gs->att[att].hdata = hdata;
1693 if (atty == ATTY_INT) {
1694 if (gs->att[att].lookup) {
1695 free(gs->att[att].lookup);
1696 gs->att[att].lookup =
NULL;
1701 G_debug(3,
"GS_load_att_map(): %s is being reused. hdata=%d",
1705 G_debug(3,
"GS_load_att_map(): %s not loaded in correct form - loading now",
1709 gs->att[att].hdata =
gsds_newh(filename);
1715 if (ATT_MASK == att) {
1723 if (att == ATT_COLOR && atty == ATTY_SHORT) {
1724 atty = (neg ? ATTY_INT : ATTY_SHORT);
1728 if (att == ATT_COLOR && atty == ATTY_SHORT) {
1733 G_fatal_error(_(
"GS_load_att_map(): Out of memory. Unable to load map"));
1739 G_fatal_error(_(
"GS_load_att_map(): Out of memory. Unable to load map"));
1747 G_fatal_error(_(
"GS_load_att_map(): Out of memory. Unable to load map"));
1751 tbuff->nm, &has_null);
1756 G_fatal_error(_(
"GS_load_att_map(): Out of memory. Unable to load map"));
1760 tbuff->nm, &has_null);
1764 G_fatal_error(_(
"GS_load_att_map(): Out of memory. Unable to load map"));
1768 tbuff->nm, &has_null);
1774 G_fatal_error(_(
"GS_load_att_map(): Out of memory. Unable to load map"));
1778 tbuff->nm, &has_null);
1788 G_debug(4,
" has_null=%d", has_null);
1799 if (ATT_COLOR == att) {
1801 if (ATTY_INT == atty) {
1804 gs->att[att].lookup =
NULL;
1808 Gs_build_lookup(filename, gs->att[att].lookup);
1812 if (ATTY_CHAR == atty) {
1813 if (!gs->att[att].lookup) {
1819 else if (ATTY_FLOAT == atty) {
1822 G_fatal_error(_(
"GS_load_att_map(): Out of memory. Unable to load map"));
1826 gs->rows, gs->cols);
1829 gs->att[att].lookup =
NULL;
1836 gs->att[att].lookup =
NULL;
1842 if (ATT_TOPO == att) {
1869 G_debug(3,
"GS_draw_surf(): id=%d",
id);
1875 if (gs->draw_mode & DM_POLY) {
1879 if (gs->draw_mode & DM_WIRE) {
1884 if (gs->draw_mode & DM_WIRE_POLY) {
1904 G_debug(3,
"GS_draw_wire(): id=%d",
id);
1925 for (i = 0; i < Next_surf; i++) {
1941 for (i = 0; i < Next_surf; i++) {
1963 if (gs->z_exag != exag) {
1964 gs->norm_needupdate = 1;
1981 G_debug(3,
"GS_set_global_exag");
1983 Gv.vert_exag = exag;
2002 G_debug(3,
"GS_global_exag(): %g", Gv.vert_exag);
2004 return (Gv.vert_exag);
2019 G_debug(3,
"GS_set_wire_color");
2024 gs->wire_color = colr;
2046 *colr = gs->wire_color;
2066 for (i = 0; i < Next_surf; i++) {
2088 G_debug(3,
"GS_set_drawmode(): id=%d mode=%d",
id, mode);
2093 gs->draw_mode = mode;
2117 *mode = gs->draw_mode;
2141 if (att == ATT_TOPO) {
2143 gs->mask_needupdate = 1;
2146 if (att == ATT_COLOR) {
2147 gs->nz_color = mode;
2148 gs->mask_needupdate = 1;
2174 if (att == ATT_TOPO) {
2175 *mode = gs->nz_topo;
2177 else if (att == ATT_COLOR) {
2178 *mode = gs->nz_color;
2203 for (i = 0; i < Next_surf; i++) {
2226 G_debug(3,
"GS_set_drawres() id=%d xyres=%d/%d xywire=%d/%d",
2227 id, xres, yres, xwire, ywire);
2229 if (xres < 1 || yres < 1 || xwire < 1 || ywire < 1) {
2236 if (gs->x_mod != xres || gs->y_mod != yres) {
2237 gs->norm_needupdate = 1;
2267 *xwire = gs->x_modw;
2268 *ywire = gs->y_modw;
2322 if (gs->zrange_nz == 0.0) {
2328 G_debug(3,
"GS_get_exag_guess(): %f %f", gs->zrange_nz, Longdim);
2330 while (gs->zrange_nz * guess / Longdim >= .25) {
2333 G_debug(3,
"GS_get_exag_guess(): %f", guess);
2336 while (gs->zrange_nz * guess / Longdim < .025) {
2339 G_debug(3,
"GS_get_exag_guess(): %f", guess);
2363 for (i = 0; i < Next_surf; i++) {
2371 if (gs->zmin_nz < *min) {
2375 if (gs->zmax_nz > *max) {
2381 G_debug(3,
"GS_get_zrange_nz(): min=%g max=%g", *min, *max);
2399 gs->x_trans = xtrans;
2400 gs->y_trans = ytrans;
2401 gs->z_trans = ztrans;
2404 G_debug(3,
"GS_set_trans(): id=%d, x=%f, y=%f, z=%f",
2405 id, xtrans, ytrans, ztrans);
2423 *xtrans = gs->x_trans;
2424 *ytrans = gs->y_trans;
2425 *ztrans = gs->z_trans;
2428 G_debug(3,
"GS_get_trans: id=%d, x=%f, y=%f, z=%f",
2429 id, *xtrans, *ytrans, *ztrans);
2443 G_debug(3,
"GS_default_draw_color");
2445 return ((
unsigned int)Gd.bgcol);
2455 return ((
unsigned int)Gd.bgcol);
2507 if (GSD_BACK == Buffermode) {
2524 G_debug(3,
"GS_set_focus(): %f,%f,%f", realto[0], realto[1], realto[2]);
2543 realto[
X] = realto[
X] - wind.west - (wind.ew_res / 2.);
2544 realto[
Y] = realto[
Y] - wind.south - (wind.ns_res / 2.);
2575 return (Gv.infocus);
2588 G_debug(3,
"GS_set_focus_center_map");
2593 center[
X] = (gs->xmax - gs->xmin) / 2.;
2594 center[
Y] = (gs->ymax - gs->ymin) / 2.;
2595 center[Z] = (gs->zmax_nz + gs->zmin_nz) / 2.;
2622 G_debug(3,
"GS_moveto(): %f,%f,%f", pt[0], pt[1], pt[2]);
2625 GS_v3eq(Gv.from_to[FROM], pt);
2635 GS_v3eq(Gv.from_to[FROM], pt);
2675 G_debug(3,
"GS_get_zextents(): id=%d",
id);
2692 int ret_surf, ret_vol;
2693 float surf_min, surf_max;
2694 float vol_min, vol_max;
2699 if (ret_surf > 0 && ret_vol > 0) {
2700 *min = (surf_min < vol_min) ? surf_min : vol_min;
2701 *max = (surf_max < vol_max) ? surf_max : vol_max;
2703 else if (ret_surf > 0) {
2707 else if (ret_vol > 0) {
2713 *min *= Gv.vert_exag;
2714 *max *= Gv.vert_exag;
2717 G_debug(3,
"GS_get_zrange(): min=%g max=%g", *min, *max);
2718 return ((ret_surf > 0 || ret_vol > 0) ? (1) : (-1));
2728 GS_v3eq(fr, Gv.from_to[FROM]);
2730 G_debug(3,
"GS_get_from(): %f,%f,%f", fr[0], fr[1], fr[2]);
2742 GS_v3eq(fr, Gv.from_to[FROM]);
2759 to[
X] = realto[
X] + wind.west + (wind.ew_res / 2.);
2760 to[
Y] = realto[
Y] + wind.south + (wind.ns_res / 2.);
2812 GS_v3dir(Gv.from_to[FROM], Gv.from_to[TO], dir);
2830 GS_v3eq(Gv.from_to[TO], Gv.from_to[FROM]);
2890 Gv.rotate.rot_angle = angle;
2891 Gv.rotate.rot_axes[0] =
x;
2892 Gv.rotate.rot_axes[1] = y;
2893 Gv.rotate.rot_axes[2] = z;
2894 Gv.rotate.do_rot = 1;
2904 Gv.rotate.do_rot = 0;
2914 for (i = 0; i < 16; i++) {
2915 if (i == 0 || i == 5 || i == 10 || i == 15)
2916 Gv.rotate.rotMatrix[i] = 1.0;
2918 Gv.rotate.rotMatrix[i] = 0.0;
2920 Gv.rotate.rot_angle = 0.0;
2921 Gv.rotate.rot_axes[0] = 0.0;
2922 Gv.rotate.rot_axes[1] = 0.0;
2923 Gv.rotate.rot_axes[2] = 0.0;
2924 Gv.rotate.do_rot = 0;
2934 for (i = 0; i < 16; i++) {
2935 matrix[i] = Gv.rotate.rotMatrix[i];
2946 for (i = 0; i < 16; i++) {
2947 Gv.rotate.rotMatrix[i] = matrix[i];
2984 G_debug(3,
"GS_set_viewport(): left=%d, right=%d, " 2985 "bottom=%d, top=%d", left, right, bottom, top);
3008 float x, y, z, len, los[2][3];
3016 realto[
X] = x - gs->ox + gs->x_trans;
3017 realto[
Y] = y - gs->oy + gs->y_trans;
3018 realto[Z] = z + gs->z_trans;
3029 realto[
X] = Gv.from_to[FROM][
X] + dir[
X];
3030 realto[
Y] = Gv.from_to[FROM][
Y] + dir[
Y];
3031 realto[Z] = Gv.from_to[FROM][Z] + dir[Z];
3058 float los[2][3], find_dist[MAX_SURFS], closest;
3059 Point3 point, tmp, finds[MAX_SURFS];
3060 int surfs[MAX_SURFS], i, iclose, numhits = 0;
3067 G_debug(3,
"gs_setlos_enterdata(los): returns false");
3071 for (i = 0; i < Next_surf; i++) {
3085 tmp[
X] += gs->x_trans;
3086 tmp[
Y] += gs->y_trans;
3087 tmp[Z] += gs->z_trans;
3090 GS_v3eq(finds[numhits], point);
3091 surfs[numhits] = Surf_ID[i];
3097 for (i = iclose = 0; i < numhits; i++) {
3098 closest = find_dist[iclose];
3100 if (find_dist[i] < closest) {
3106 *x = finds[iclose][
X];
3107 *y = finds[iclose][
Y];
3108 *z = finds[iclose][Z];
3109 *
id = surfs[iclose];
3112 G_debug(3,
"NumHits %d, next %d", numhits, Next_surf);
3151 geosurf *gsurfs[MAX_SURFS];
3198 int onstate[MAX_CPLANES], i;
3202 for (i = 0; i < MAX_CPLANES; i++) {
3245 zexag = doexag ? Gv.vert_exag : 1.;
3246 *sx = *sy = Gv.scale;
3247 *sz = Gv.scale * zexag;
3287 float *dist,
int use_exag)
3304 G_debug(3,
"GS_get_distance_alongsurf(): hs=%d p1=%f,%f p2=%f,%f",
3305 hs, x1, y1, x2, y2);
3350 static int first = 1;
3356 glMatrixMode(GL_MODELVIEW);
3375 glDepthRange(0.0, 1.0);
3376 glEnable(GL_DEPTH_TEST);
3377 glDepthFunc(GL_LEQUAL);
3386 Gv.from_to[FROM][
X] = Gv.from_to[FROM][
Y] =
3387 Gv.from_to[FROM][Z] = GS_UNIT_SIZE / 2.;
3389 Gv.from_to[TO][
X] = GS_UNIT_SIZE / 2.;
3390 Gv.from_to[TO][
Y] = GS_UNIT_SIZE / 2.;
3391 Gv.from_to[TO][Z] = 0.;
3392 Gv.from_to[TO][W] = Gv.from_to[FROM][W] = 1.;
3397 GS_v3eq(Gv.real_to, Gv.from_to[TO]);
3405 Gd.farclip = 10000.;
3423 col = col | 0xFF000000;
3435 glClearColor(((
float)((col) & 0xff)) / 255.,
3436 (
float)((col) >> 8 & 0xff) / 255.,
3437 (
float)((col) >> 16 & 0xff) / 255.,
3438 (
float)((col) >> 24 & 0xff) / 255.);
3439 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
3455 int left, right, bottom, top;
3462 glGetIntegerv(GL_VIEWPORT, tmp);
3464 right = tmp[0] + tmp[2] - 1;
3466 top = tmp[1] + tmp[3] - 1;
3468 G_debug(3,
"GS_get_aspect(): left=%d, right=%d, top=%d, bottom=%d",
3469 left, right, top, bottom);
3471 return ((
double)(right - left) / (top - bottom));
int GS_set_maskmode(int id, int mode)
Set mask mode.
void gsd_zwritemask(unsigned long n)
Write out z-mask.
void gsdiff_set_SDscale(float scale)
Set scale.
int GS_Set_ClientData(int id, void *clientd)
Set client data.
int GS_get_zextents(int id, float *min, float *max, float *mid)
Get z-extent for a single surface.
int gs_init_surf(geosurf *gs, double ox, double oy, int rows, int cols, double xres, double yres)
Initialize allocated geosurf struct.
int gs_los_intersect(int surfid, float **los, float *point)
Crude method of intersecting line of sight with closest part of surface.
void GS_set_nozero(int id, int att, int mode)
Set no-zero ?
void gs_delete_surf(int id)
Remove geosurf struct from list.
void gsd_calllist(int listno)
ADD.
void GS_get_to(float *to)
Get 'to' model coordinates.
int GS_get_fov(void)
Get fied of view.
#define DRC2OFF(gs, drow, dcol)
void gsd_cplane_settrans(int num, float tx, float ty, float tz)
ADD.
int GS_load_3dview(const char *vname, int surfid)
Load 3d view.
int gsd_wire_surf(geosurf *surf)
Draw surface wire.
int GS_set_SDscale(float scale)
Set ?
void GS_get_from(float *fr)
Get viewpoint 'from' position.
void GS_get_rotation_matrix(double *matrix)
Get rotation matrix.
void GS_get_modelposition(float *siz, float *pos)
Retrieves coordinates for lighting model position, at center of view.
void GS_alldraw_cplane_fences(void)
Draw all cplace fences ?
float gsdiff_get_SDscale(void)
Get scale.
int gsds_findh(const char *name, IFLAG *changes, IFLAG *types, int begin)
Get handle to gsds.
void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
Get axis scale.
int Gs_loadmap_as_char(struct Cell_head *wind, const char *map_name, unsigned char *buff, struct BM *nullmap, int *has_null)
Load raster map as integer map.
int gs_get_datacenter(float *cen)
Get data center point.
int GS_new_surface(void)
Add new surface.
int GS_v3normalize(float *v1, float *v2)
Change v2 so that v1v2 is a unit vector.
int gs_get_data_avg_zmax(float *azmax)
Get average z-max value.
int in_vregion(geosurf *gs, float *pt)
ADD.
void GS_getlight_color(int num, float *red, float *green, float *blue)
Get light color.
unsigned int GS_default_draw_color(void)
Get default draw color.
void GS_draw_list(GLuint list_id)
Draw pre-defined list.
void GS_get_drawres(int id, int *xres, int *yres, int *xwire, int *ywire)
Get draw resolution of surface.
void GS_moveto_real(float *pt)
Move position to (real)
void GS_draw_wire(int id)
Draw surface wire.
int GS_get_maskmode(int id, int *mode)
Get mask mode.
int gs_point_is_masked(geosurf *gs, float *pt)
Check if point is masked.
void * GS_Get_ClientData(int id)
Get client data.
void GS_draw_flowline_at_xy(int id, float x, float y)
Draw flow-line on surace.
void gsd_do_scale(int doexag)
Set current scale.
int GS_get_zrange(float *min, float *max, int doexag)
Get z-extent for all loaded surfaces.
int Gs_update_attrange(geosurf *gs, int desc)
Update no_zero ranges for attribute (actually no_null now)
int GS_draw_cplane_fence(int hs1, int hs2, int num)
Draw cplace fence ?
void gsd_cplane_off(int num)
Turn off clip plane.
void GS_set_rotation(double angle, double x, double y, double z)
Set rotation params.
int GS_get_exag_guess(int id, float *exag)
Get exag-value guess.
void GS_draw_lighting_model1(void)
Draw lighting model.
void GS_set_focus_real(float *realto)
Set real focus.
void GS_setlight_position(int num, float xpos, float ypos, float zpos, int local)
Set light position.
void GS_v3sub(float *v1, float *v2)
Subtract vectors.
int Gs_build_256lookup(const char *filename, int *buff)
Build color table (256)
void GS_set_fencecolor(int mode)
Set fence color.
int GS_v3dir(float *v1, float *v2, float *v3)
Get a normalized direction from v1 to v2, store in v3.
int GS_get_SDscale(float *scale)
Get ?
void GS_draw_all_list(void)
Draw all glLists.
int GS_v3norm(float *v1)
Change v1 so that it is a unit vector (2D)
int GS_get_wire_color(int id, int *colr)
Get wire color.
size_t gs_malloc_att_buff(geosurf *gs, int desc, int type)
Allocate attribute buffer.
void GS_set_Narrow(int *pt, int id, float *pos2)
Set decoration, north arrow ??
int GS_save_3dview(const char *vname, int surfid)
Save 3d view.
void GS_set_trans(int id, float xtrans, float ytrans, float ztrans)
Set translation (surface position)
int gs_calc_normals(geosurf *gs)
Calculate normals.
void gsd_colormode(int cm)
Set color mode.
void GS_zoom_setup(int *a, int *b, int *c, int *d, int *maxx, int *maxy)
Get zoom setup.
void GS_getlight_position(int num, float *xpos, float *ypos, float *zpos, int *local)
Get light position.
int gvl_get_zrange(float *min, float *max)
Get volume z-range value.
int GS_get_selected_point_on_surface(int sx, int sy, int *id, float *x, float *y, float *z)
Get selected point of surface.
void GS_v3add(float *v1, float *v2)
Sum vectors.
void gsd_surf2real(geosurf *gs, Point3 point)
Convert surface to real coordinates.
void GS_set_viewdir(float *dir)
Set viewdir.
void gsd_color_func(unsigned int col)
Set current color.
int GS_get_distance_alongsurf(int hs, float x1, float y1, float x2, float y2, float *dist, int use_exag)
Measure distance "as the ball rolls" between two points on surface.
void GS_set_global_exag(float exag)
Set global z-exag value.
int GS_set_att_const(int id, int att, float constant)
Set attribute constant.
void gsd_get_cplanes_state(int *onstate)
Get cplane state.
int gs_att_is_set(geosurf *surf, IFLAG att)
Check if attribute is set.
double GS_get_aspect(void)
Get aspect value.
int GS_draw_legend(const char *name, GLuint fontbase, int size, int *flags, float *range, int *pt)
Draw legend.
int GS_update_curmask(int id)
Update current mask.
void gs_set_defaults(geosurf *gs, float *defs, float *null_defs)
Set default attribute values.
void GS_init_rotation(void)
Reset scene rotation.
void gs_init(void)
Initialize library.
void Gs_pack_colors(const char *filename, int *buff, int rows, int cols)
Pack color table.
void GS_moveto(float *pt)
Move viewpoint.
int GS_surf_exists(int id)
void GS_set_focus(float *realto)
Set focus.
void gsd_translate(float dx, float dy, float dz)
Multiply the current matrix by a translation matrix.
void gsd_shademodel(int bool)
Set shaded model.
void GS_get_from_real(float *fr)
Get viewpoint 'from' real coordinates.
void GS_get_dims(int id, int *rows, int *cols)
Get dimension of surface.
int GS_setall_drawmode(int mode)
Set all draw-modes.
int gs_set_att_type(geosurf *gs, int desc, int type)
Set attribute type.
int GS_v2norm(float *v1)
Change v1 so that it is a unit vector (3D)
int GS_get_twist(void)
Get twist value.
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
void gsd_real2surf(geosurf *gs, Point3 point)
Convert real to surface coordinates.
int GS_get_focus(float *realto)
Get focus.
void gsd_real2model(Point3 point)
Convert real to model coordinates.
void GS_set_infocus(void)
Set focus.
void GS_set_nofocus(void)
Unset focus.
void GS_switchlight(int num, int on)
Switch on/off light.
geosurf * gsdiff_get_SDref(void)
ADD.
void gsd_pushmatrix(void)
Push the current matrix stack.
void GS_set_light_reset(int i)
void GS_unset_rotation(void)
Stop scene rotation.
void gsd_backface(int n)
ADD.
int gsd_surf(geosurf *surf)
ADD.
int GS_get_cat_at_xy(int id, int att, char *catstr, float x, float y)
Get surface category on given position.
int GS_set_SDsurf(int id)
Set surface as Scaled Difference surface.
void GS_set_viewport(int left, int right, int bottom, int top)
Set viewport.
char * gsds_get_name(int id)
Get name.
int GS_update_normals(int id)
Update normals.
void gv_update_drapesurfs(void)
Update drape surfaces.
int GS_get_norm_at_xy(int id, float x, float y, float *nv)
Get surface normal at x,y (real coordinates)
typbuff * gs_get_att_typbuff(geosurf *gs, int desc, int to_write)
Get attribute data buffer.
void GS_draw_X(int id, float *pt)
Draw place marker.
int Gs_loadmap_as_bitmap(struct Cell_head *wind, const char *map_name, struct BM *buff)
Load raster map as integer map.
void GS_set_twist(int t)
Set viewpoint twist value.
int gsds_free_data_buff(int id, int typ)
Free allocated buffer.
void GS_v3mult(float *v1, float k)
Multiple vectors.
void GS_getlight_ambient(int num, float *red, float *green, float *blue)
Get light ambient.
int GS_setall_drawres(int xres, int yres, int xwire, int ywire)
Set all draw resolutions.
int gs_setlos_enterdata(Point3 *los)
int gs_num_surfaces(void)
Get number of surfaces.
void gsd_switchlight(int num, int on)
Switch light on/off.
void GS_delete_list(GLuint list_id)
Delete pre-defined list.
int gs_los_intersect1(int surfid, float(*los)[3], float *point)
Crude method of intersecting line of sight with closest part of surface.
int G_debug(int level, const char *msg,...)
Print debugging message.
int GS_new_light(void)
Add new model light.
void GS_set_cplane_trans(int num, float dx, float dy, float dz)
Set cplace trans.
void gsd_deletelist(GLuint listno, int range)
Delete list.
void gsd_set_view(geoview *gv, geodisplay *gd)
Set view.
int gs_set_att_const(geosurf *gs, int desc, float constant)
Set attribute constant value.
void GS_set_wire_color(int id, int colr)
Set wire color.
int GS_get_region(float *n, float *s, float *w, float *e)
Get 2D region extent.
void GS_clear(int col)
Clear view.
int GS_num_surfs(void)
Get number of surfaces.
int gs_getall_surfaces(geosurf **gsurfs)
Get array of geosurf structs.
void gsd_swapbuffers(void)
Swap buffers.
void Gs_pack_colors_float(const char *filename, float *fbuf, int *ibuf, int rows, int cols)
Pack color table (floating-point map)
void GS_set_att_defaults(float *defs, float *null_defs)
Set default attributes for map objects.
int GS_get_longdim(float *dim)
Get largest dimension.
void gsd_draw_cplane_fence(geosurf *surf1, geosurf *surf2, int cpnum)
ADD.
int GS_set_drawmode(int id, int mode)
Set draw mode.
int Gs_loadmap_as_int(struct Cell_head *wind, const char *map_name, int *buff, struct BM *nullmap, int *has_null)
Load raster map as integer map.
int GS_get_drawmode(int id, int *mode)
Get draw mode.
int gsd_nline_onsurf(geosurf *gs, float *v1, float *v2, float *pt, int n)
Multiline on surface, fix z-values.
unsigned int GS_background_color(void)
Get background color.
void gsd_backbuffer(void)
Specify which color buffers are to be drawn into.
void GS_draw_fringe(int id, unsigned long clr, float elev, int *where)
Draw fringe around data (surface) at selected corners.
void GS_get_viewdir(float *dir)
Get viewdir.
void gsd_model2real(Point3 point)
Convert model to real coordinates.
int gs_get_zextents(geosurf *gs, float *min, float *max, float *mid)
Get z-extent values.
void GS_init_view(void)
Init viewpoint.
int GS_is_masked(int id, float *pt)
Check if point is masked ?
void GS_set_cplane_rot(int num, float dx, float dy, float dz)
Set cplace rotation.
void gsdiff_set_SDref(geosurf *gsref)
ADD.
int gs_set_att_src(geosurf *gs, int desc, int src)
Set attribute source.
void gsd_viewport(int l, int r, int b, int t)
Set the viewport.
int GS_get_att(int id, int att, int *set, float *constant, char *mapname)
Get attributes.
int _viewcell_tri_interp(geosurf *gs, Point3 pt)
ADD.
int Gs_get_cat_label(const char *filename, int drow, int dcol, char *catstr)
Get categories/labels.
int GS_load_att_map(int id, const char *filename, int att)
Load raster map as attribute.
void gsd_cplane_setrot(int num, float rx, float ry, float rz)
ADD.
void gsd_line_onsurf(geosurf *gs, float *v1, float *v2)
Line on surface, fix z-values.
void gsd_setfc(int mode)
ADD.
int Gs_loadmap_as_float(struct Cell_head *wind, const char *map_name, float *buff, struct BM *nullmap, int *has_null)
Load raster map as floating point map.
void GS_set_focus_center_map(int id)
Set focus to map center.
int gs_malloc_lookup(geosurf *gs, int desc)
Allocate attribute lookup.
void GS_draw_cplane(int num)
Draw cplace.
GLuint gsd_put_legend(const char *name, GLuint fontbase, int size, int *flags, float *rangef, int *pt)
Put legend.
void gsd_init_lightmodel(void)
Initialize model light.
float GS_global_exag(void)
Get global z-exag value.
geosurf * gs_get_surf(int id)
Get geosurf struct.
void GS_unset_cplane(int num)
Unset clip place (turn off)
void GS_set_draw(int where)
Sets which buffer to draw to.
int Gs_loadmap_as_short(struct Cell_head *wind, const char *map_name, short *buff, struct BM *nullmap, int *has_null)
Load raster map as integer map.
void GS_get_zrange_nz(float *min, float *max)
Get Z extents for all loaded surfaces.
void GS_set_rotation_matrix(double *matrix)
Set rotation matrix.
void GS_draw_surf(int id)
Draw surface.
void GS_draw_lighting_model(void)
Draw lighting model.
void G_get_set_window(struct Cell_head *window)
Get the current working window (region)
void GS_lights_off(void)
Switch off all lights.
void GS_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
Get translation values (surface position)
void GS_v3eq(float *v1, float *v2)
Copy vector values.
int gs_get_att_src(geosurf *gs, int desc)
Get attribute source.
void GS_alldraw_surf(void)
Draw all surfaces.
void gsd_linewidth(short n)
Set width of rasterized lines.
void GS_set_exag(int id, float exag)
Set Z exag for surface.
void GS_alldraw_wire(void)
Draw all wires.
int Gs_load_3dview(const char *vname, geoview *gv, geodisplay *gd, struct Cell_head *w, geosurf *defsurf)
Load 3dview.
void GS_setlight_ambient(int num, float red, float green, float blue)
Set light ambient.
void GS_set_fov(int fov)
Set field of view.
#define VCOL2DCOL(gs, vcol)
int GS_delete_surface(int id)
Delete surface.
int GS_transp_is_set(void)
Check if transparency is set.
void gsd_flush(void)
Mostly for flushing drawing commands accross a network.
void gpd_obj(geosurf *gs, gvstyle *style, Point3 pt)
Draw point representing object.
int GS_set_drawres(int id, int xres, int yres, int xwire, int ywire)
Set draw resolution for surface.
char * G_fully_qualified_name(const char *name, const char *mapset)
Get fully qualified element name.
const char * G_find_raster2(const char *name, const char *mapset)
Find a raster map (look but don't touch)
void gsd_popmatrix(void)
Pop the current matrix stack.
void gsd_bothbuffers(void)
ADD.
void GS_set_cplane(int num)
Set cplace.
int gs_init_normbuff(geosurf *gs)
Init geosurf normbuff.
int Gs_numtype(const char *filename, int *negflag)
Get map data type.
geosurf * gs_get_new_surface(void)
Allocate new geosurf struct.
void GS_draw_line_onsurf(int id, float x1, float y1, float x2, float y2)
Draw line on surface.
void gsd_display_fringe(geosurf *surf, unsigned long clr, float elev, int where[4])
Display fridge.
void GS_get_modelposition1(float pos[])
Retrieves coordinates for lighting model position, at center of view.
int gs_mapcolor(typbuff *cobuff, gsurf_att *coloratt, int offset)
Call this one when you already know att_src is MAP_ATT.
void gsd_cplane_on(int num)
ADD.
int GS_get_fencecolor(void)
Get fence color.
float GS_distance(float *from, float *to)
Calculate distance.
void GS_get_to_real(float *to)
Get 'to' real coordinates.
int Gs_save_3dview(const char *vname, geoview *gv, geodisplay *gd, struct Cell_head *w, geosurf *defsurf)
Save 3dview.
#define VROW2DROW(gs, vrow)
void gsd_frontbuffer(void)
Specify which color buffers are to be drawn into.
int GS_coordpair_repeats(float *p1, float *p2, int nhist)
ADD.
void gsd_deflight(int num, struct lightdefs *vals)
Define light.
int GS_has_transparency(void)
Check for transparency.
void GS_lights_on(void)
Switch on all lights.
int gsds_newh(const char *name)
Get handle to gsds.
int GS_get_SDsurf(int *id)
Get ?
void GS_setlight_color(int num, float red, float green, float blue)
Set light color.
int GS_unset_att(int id, int att)
Unset attribute.
int gsds_set_changed(int id, IFLAG reason)
ADD.
void gsd_scale(float xs, float ys, float zs)
Multiply the current matrix by a general scaling matrix.
int gs_get_zrange(float *min, float *max)
Get z-range.
int gs_distance_onsurf(geosurf *gs, float *p1, float *p2, float *dist, int use_exag)
Calculate distance on surface.
int GS_get_nozero(int id, int att, int *mode)
Get no-zero ?
int GS_get_light_reset(void)
void GS_unset_SDsurf(void)
Unset Scaled Difference surface.
void gsd_calllists(int listno)
ADD.
int gsd_get_los(float(*vect)[3], short sx, short sy)
ADD.
int GS_get_val_at_xy(int id, int att, char *valstr, float x, float y)
Get RGB color at given point.
int gsd_getViewport(GLint *, GLint *)
void G_warning(const char *msg,...)
Print a warning message to stderr.
int GS_draw_nline_onsurf(int id, float x1, float y1, float x2, float y2, float *lasp, int n)
Draw multiline on surface.
int gs_update_curmask(geosurf *surf)
Update current maps.
void gsd_drawsphere(float *center, unsigned long colr, float siz)
Draw sphere.
int * GS_get_surf_list(int *numsurfs)
Get surface list.
void GS_done_draw(void)
Draw done, swap buffers.
int GS_look_here(int sx, int sy)
Send screen coords sx and sy, lib traces through surfaces; sets new center to point of nearest inters...
void gsd_draw_cplane(int num)
Draw cplane.
void GS_libinit(void)
Initialize OGSF library.
#define GET_MAPATT(buff, offset, att)