GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GS2.c
Go to the documentation of this file.
1 
31 #include <stdlib.h>
32 #include <string.h>
33 #include <math.h>
34 
35 #include <grass/config.h>
36 
37 #if defined(OPENGL_X11) || defined(OPENGL_WINDOWS)
38 #include <GL/gl.h>
39 #include <GL/glu.h>
40 #elif defined(OPENGL_AQUA)
41 #include <OpenGL/gl.h>
42 #include <OpenGL/glu.h>
43 #endif
44 
45 #include <grass/gis.h>
46 #include <grass/gstypes.h>
47 #include <grass/glocale.h>
48 
49 #include "gsget.h"
50 #include "rowcol.h"
51 #include "rgbpack.h"
52 
53 /* Hack to make NVIZ2.2 query functions.("What's Here" and "Look at")
54  * to work.
55  * Uses gs_los_intersect1() instead of gs_los_intersect().
56  * Pierre de Mouveaux - 31 oct. 1999. p_de_mouveaux@hotmail.com.
57  */
58 #define NVIZ_HACK 1
59 
60 int gsd_getViewport(GLint *, GLint *);
61 
62 /* array of surface ids */
63 static int Surf_ID[MAX_SURFS];
64 static int Next_surf = 0;
65 static int SDref_surf = 0;
66 
67 /* attributes array */
68 static float Default_const[MAX_ATTS];
69 static float Default_nulls[MAX_ATTS];
70 
71 /* largest dimension */
72 static float Longdim;
73 
74 /* N, S, W, E */
75 static float Region[4];
76 static geoview Gv;
77 static geodisplay Gd;
78 static struct Cell_head wind;
79 static int Buffermode;
80 static int Numlights = 0;
81 static int Resetlight = 1;
82 static int Modelshowing = 0;
83 
84 void void_func(void)
85 {
86  return;
87 }
88 
96 void GS_libinit(void)
97 {
98  static int first = 1;
99 
100  G_get_set_window(&wind);
101 
102  Region[0] = wind.north;
103  Region[1] = wind.south;
104  Region[2] = wind.west;
105  Region[3] = wind.east;
106 
107  /* scale largest dimension to GS_UNIT_SIZE */
108  if ((wind.east - wind.west) > (wind.north - wind.south)) {
109  Longdim = (wind.east - wind.west);
110  }
111  else {
112  Longdim = (wind.north - wind.south);
113  }
114 
115  Gv.scale = GS_UNIT_SIZE / Longdim;
116 
117  G_debug(1, "GS_libinit(): n=%f s=%f w=%f e=%f scale=%f first=%d",
118  Region[0], Region[1], Region[2], Region[3], Gv.scale, first);
119 
122 
123 
124  if (first) {
125  gs_init();
126  }
127 
128  first = 0;
129 
130  return;
131 }
132 
140 int GS_get_longdim(float *dim)
141 {
142  *dim = Longdim;
143 
144  G_debug(3, "GS_get_longdim(): dim=%g", *dim);
145 
146  return (1);
147 }
148 
156 int GS_get_region(float *n, float *s, float *w, float *e)
157 {
158  *n = Region[0];
159  *s = Region[1];
160  *w = Region[2];
161  *e = Region[3];
162 
163  return (1);
164 }
165 
172 void GS_set_att_defaults(float *defs, float *null_defs)
173 {
174  int i;
175 
176  G_debug(3, "GS_set_att_defaults");
177 
178  for (i = 0; i < MAX_ATTS; i++) {
179  Default_const[i] = defs[i];
180  Default_nulls[i] = null_defs[i];
181  }
182 
183  return;
184 }
185 
194 int GS_surf_exists(int id)
195 {
196  int i, found = 0;
197 
198  G_debug(3, "GS_surf_exists(): id=%d", id);
199 
200 
201  if (NULL == gs_get_surf(id)) {
202  return (0);
203  }
204 
205  for (i = 0; i < Next_surf && !found; i++) {
206  if (Surf_ID[i] == id) {
207  found = 1;
208  }
209  }
210 
211  return (found);
212 }
213 
224 int GS_new_surface(void)
225 {
226  geosurf *ns;
227 
228  G_debug(3, "GS_new_surface():");
229 
230  if (Next_surf < MAX_SURFS) {
231  ns = gs_get_new_surface();
232  gs_init_surf(ns, wind.west + wind.ew_res / 2.,
233  wind.south + wind.ns_res / 2., wind.rows, wind.cols,
234  wind.ew_res, wind.ns_res);
235  gs_set_defaults(ns, Default_const, Default_nulls);
236 
237  /* make default shine current */
238  gs_set_att_src(ns, ATT_SHINE, CONST_ATT);
239 
240  Surf_ID[Next_surf] = ns->gsurf_id;
241  ++Next_surf;
242 
243  G_debug(3, " id=%d", ns->gsurf_id);
244 
245  return (ns->gsurf_id);
246  }
247 
248 
249 
250  return (-1);
251 }
253 {
254  Resetlight = i;
255  if (i)
256  Numlights = 0;
257 }
259 {
260  return Resetlight;
261 }
268 int GS_new_light(void)
269 {
270  int i;
271 
272  if (GS_get_light_reset()) {
273 
275 
276  for (i = 0; i < MAX_LIGHTS; i++) {
277  Gv.lights[i].position[X] = Gv.lights[i].position[Y] = 0.0;
278  Gv.lights[i].position[Z] = 1.0;
279  Gv.lights[i].position[W] = 0.0; /* infinite */
280  Gv.lights[i].color[0] = Gv.lights[i].color[1] =
281  Gv.lights[i].color[2] = 1.0;
282  Gv.lights[i].ambient[0] = Gv.lights[i].ambient[1] =
283  Gv.lights[i].ambient[2] = 0.2;
284  Gv.lights[i].shine = 32.0;
285  }
286 
288  }
289 
290  if (Numlights < MAX_LIGHTS) {
291  gsd_deflight(Numlights + 1, &(Gv.lights[Numlights]));
292  gsd_switchlight(Numlights + 1, 1);
293 
294  return ++Numlights;
295  }
296 
297  return -1;
298 }
299 
309 void GS_setlight_position(int num, float xpos, float ypos, float zpos,
310  int local)
311 {
312  if (num) {
313  num -= 1;
314  if (num < Numlights) {
315  Gv.lights[num].position[X] = xpos;
316  Gv.lights[num].position[Y] = ypos;
317  Gv.lights[num].position[Z] = zpos;
318  Gv.lights[num].position[W] = (float)local;
319 
320  gsd_deflight(num + 1, &(Gv.lights[num]));
321  }
322  }
323 
324  return;
325 }
326 
327 
335 void GS_getlight_position(int num, float *xpos, float *ypos, float *zpos,
336  int *local)
337 {
338  if (num) {
339  num -= 1;
340  if (num < Numlights) {
341  *xpos = Gv.lights[num].position[X];
342  *ypos = Gv.lights[num].position[Y];
343  *zpos = Gv.lights[num].position[Z];
344  *local = (int)Gv.lights[num].position[W];
345 
346  }
347  }
348 
349  return;
350 }
351 
358 void GS_setlight_color(int num, float red, float green, float blue)
359 {
360  if (num) {
361  num -= 1;
362  if (num < Numlights) {
363  Gv.lights[num].color[0] = red;
364  Gv.lights[num].color[1] = green;
365  Gv.lights[num].color[2] = blue;
366 
367  gsd_deflight(num + 1, &(Gv.lights[num]));
368  }
369  }
370 
371  return;
372 }
373 
380 void GS_getlight_color(int num, float *red, float *green, float *blue)
381 {
382  if (num) {
383  num -= 1;
384  if (num < Numlights) {
385  *red = Gv.lights[num].color[0];
386  *green = Gv.lights[num].color[1];
387  *blue = Gv.lights[num].color[2];
388  }
389  }
390 
391  return;
392 }
393 
402 void GS_setlight_ambient(int num, float red, float green, float blue)
403 {
404  if (num) {
405  num -= 1;
406  if (num < Numlights) {
407  Gv.lights[num].ambient[0] = red;
408  Gv.lights[num].ambient[1] = green;
409  Gv.lights[num].ambient[2] = blue;
410 
411  gsd_deflight(num + 1, &(Gv.lights[num]));
412  }
413  }
414 
415  return;
416 }
417 
424 void GS_getlight_ambient(int num, float *red, float *green, float *blue)
425 {
426  if (num) {
427  num -= 1;
428  if (num < Numlights) {
429  *red = Gv.lights[num].ambient[0];
430  *green = Gv.lights[num].ambient[1];
431  *blue = Gv.lights[num].ambient[2];
432  }
433  }
434 
435  return;
436 }
437 
438 
442 void GS_lights_off(void)
443 {
444  int i;
445 
446  for (i = 0; i < Numlights; i++) {
447  gsd_switchlight(i + 1, 0);
448  }
449 
450  return;
451 }
452 
456 void GS_lights_on(void)
457 {
458  int i;
459 
460  for (i = 0; i < Numlights; i++) {
461  gsd_switchlight(i + 1, 1);
462  }
463 
464  return;
465 }
466 
473 void GS_switchlight(int num, int on)
474 {
475  if (num) {
476  num -= 1;
477 
478  if (num < Numlights) {
479  gsd_switchlight(num + 1, on);
480  }
481  }
482 
483  return;
484 }
485 
493 {
494  return (gs_att_is_set(NULL, ATT_TRANSP) || (FC_GREY == gsd_getfc()));
495 }
496 
503 {
504  /* TODO: Still needs work to handle other cases */
505  /* this is a quick hack to get lighting adjustments debugged */
506  /*
507  GS_v3dir(Gv.from_to[FROM], Gv.from_to[TO], center);
508  GS_v3mult(center, 1000);
509  GS_v3add(center, Gv.from_to[FROM]);
510  */
511 
512  gs_get_datacenter(pos);
513  gs_get_data_avg_zmax(&(pos[Z]));
514 
515  G_debug(1, "GS_get_modelposition1(): model position: %f %f %f",
516  pos[X], pos[Y], pos[Z]);
517 
518  return;
519 }
520 
531 void GS_get_modelposition(float *siz, float *pos)
532 {
533  float dist, near_h, dir[3];
534 
535  dist = 2. * Gd.nearclip;
536 
537  near_h = 2.0 * tan(4.0 * atan(1.) * Gv.fov / 3600.) * dist;
538  *siz = near_h / 8.0;
539 
540  /* prevent clipping - would only happen if fov > ~127 degrees, at
541  fov = 2.0 * atan(2.0) */
542 
543  if (*siz > Gd.nearclip) {
544  *siz = Gd.nearclip;
545  }
546 
547  GS_v3dir(Gv.from_to[FROM], Gv.from_to[TO], dir);
548 
549  pos[X] = Gv.from_to[FROM][X] + dir[X] * dist;
550  pos[Y] = Gv.from_to[FROM][Y] + dir[Y] * dist;
551  pos[Z] = Gv.from_to[FROM][Z] + dir[Z] * dist;
552 
553  return;
554 }
555 
556 
568 void GS_set_Narrow(int *pt, int id, float *pos2)
569 {
570  geosurf *gs;
571  float x, y, z;
572  GLdouble modelMatrix[16], projMatrix[16];
573  GLint viewport[4];
574 
575  if (GS_get_selected_point_on_surface(pt[X], pt[Y], &id, &x, &y, &z)) {
576  gs = gs_get_surf(id);
577  if (gs) {
578  z = gs->zmax;
579  pos2[X] = (float)x - gs->ox + gs->x_trans;
580  pos2[Y] = (float)y - gs->oy + gs->y_trans;
581  pos2[Z] = (float)z + gs->z_trans;
582 
583  return;
584  }
585  }
586  else {
587  gs = gs_get_surf(id);
588 
589  /* Need to get model matrix, etc
590  * to run gluUnProject
591  */
592  gsd_pushmatrix();
593  gsd_do_scale(1);
594  glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
595  glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
596  glGetIntegerv(GL_VIEWPORT, viewport);
597 
598  if (gs) {
599  GLdouble out_near[3], out_far[3];
600  GLdouble factor;
601  GLdouble out[3];
602 
603  z = (float)gs->zmax + gs->z_trans;
604 
605  gluUnProject((GLdouble) pt[X], (GLdouble) pt[Y], (GLdouble) 0.,
606  modelMatrix, projMatrix, viewport,
607  &out_near[X], &out_near[Y], &out_near[Z]);
608  gluUnProject((GLdouble) pt[X], (GLdouble) pt[Y], (GLdouble) 1.,
609  modelMatrix, projMatrix, viewport,
610  &out_far[X], &out_far[Y], &out_far[Z]);
611 
612  glPopMatrix();
613 
614  factor = (out_near[Z] - z) / (out_near[Z] - out_far[Z]);
615 
616  out[X] = out_near[X] - ((out_near[X] - out_far[X]) * factor);
617  out[Y] = out_near[Y] - ((out_near[Y] - out_far[Y]) * factor);
618  out[Z] = z;
619 
620  pos2[X] = (float)out[X];
621  pos2[Y] = (float)out[Y];
622  pos2[Z] = (float)out[Z];
623 
624  return;
625 
626  }
627  }
628  return;
629 }
630 
637 void GS_draw_X(int id, float *pt)
638 {
639  geosurf *gs;
640  Point3 pos;
641  float siz;
642 
643  if ((gs = gs_get_surf(id))) {
644  GS_get_longdim(&siz);
645  siz /= 200.;
646  pos[X] = pt[X] - gs->ox;
647  pos[Y] = pt[Y] - gs->oy;
648  _viewcell_tri_interp(gs, pos);
649 
650  gsd_pushmatrix();
651 
652  gsd_do_scale(1);
653  gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans);
654  gsd_linewidth(1);
655 
656  if (CONST_ATT == gs_get_att_src(gs, ATT_TOPO)) {
657  pos[Z] = gs->att[ATT_TOPO].constant;
658  gs = NULL; /* tells gpd_obj to use given Z val */
659  }
660 
661  gpd_obj(gs, Gd.bgcol, siz, ST_GYRO, pos);
662  gsd_flush();
663 
664  gsd_popmatrix();
665  }
666 
667  return;
668 }
669 
676 void GS_draw_line_onsurf(int id, float x1, float y1, float x2, float y2)
677 {
678  float p1[2], p2[2];
679  geosurf *gs;
680 
681  if ((gs = gs_get_surf(id))) {
682  p1[X] = x1 - gs->ox;
683  p1[Y] = y1 - gs->oy;
684  p2[X] = x2 - gs->ox;
685  p2[Y] = y2 - gs->oy;
686 
687  gsd_pushmatrix();
688 
689  gsd_do_scale(1);
690  gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans);
691  gsd_linewidth(1);
692 
694  gsd_line_onsurf(gs, p1, p2);
695 
696  gsd_popmatrix();
697  gsd_flush();
698  }
699 
700  return;
701 }
702 
715 int GS_draw_nline_onsurf(int id, float x1, float y1, float x2, float y2,
716  float *lasp, int n)
717 {
718  float p1[2], p2[2];
719  geosurf *gs;
720  int ret = 0;
721 
722  if ((gs = gs_get_surf(id))) {
723  p1[X] = x1 - gs->ox;
724  p1[Y] = y1 - gs->oy;
725  p2[X] = x2 - gs->ox;
726  p2[Y] = y2 - gs->oy;
727 
728  gsd_pushmatrix();
729 
730  gsd_do_scale(1);
731  gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans);
732  gsd_linewidth(1);
734  ret = gsd_nline_onsurf(gs, p1, p2, lasp, n);
735  gsd_surf2real(gs, lasp);
736 
737  gsd_popmatrix();
738  gsd_flush();
739  }
740 
741  return (ret);
742 }
743 
753 void GS_draw_flowline_at_xy(int id, float x, float y)
754 {
755  geosurf *gs;
756  float nv[3], pdir[2], mult;
757  float p1[2], p2[2], next[2];
758  int i = 0;
759 
760  if ((gs = gs_get_surf(id))) {
761  p1[X] = x;
762  p1[Y] = y;
763  /* multiply by 1.5 resolutions to ensure a crossing ? */
764  mult = .1 * (VXRES(gs) > VYRES(gs) ? VXRES(gs) : VYRES(gs));
765 
766  GS_coordpair_repeats(p1, p1, 50);
767 
768  while (1 == GS_get_norm_at_xy(id, p1[X], p1[Y], nv)) {
769  if (nv[Z] == 1.0) {
770  if (pdir[X] == 0.0 && pdir[Y] == 0.0) {
771  break;
772  }
773 
774  p2[X] = p1[X] + (pdir[X] * mult);
775  p2[Y] = p1[Y] + (pdir[Y] * mult);
776  }
777  else {
778  /* use previous direction */
779  GS_v2norm(nv);
780  p2[X] = p1[X] + (nv[X] * mult);
781  p2[Y] = p1[Y] + (nv[Y] * mult);
782  pdir[X] = nv[X];
783  pdir[Y] = nv[Y];
784  }
785 
786  if (i > 2000) {
787  break;
788  }
789 
790  if (GS_coordpair_repeats(p1, p2, 0)) {
791  break;
792  }
793 
794  /* Think about this: */
795  /* degenerate line means edge or level edge ? */
796  /* next is filled with last point drawn */
797  if (2 > GS_draw_nline_onsurf(id, p1[X], p1[Y],
798  p2[X], p2[Y], next, 3)) {
799  break;
800  }
801 
802  p1[X] = next[X];
803  p1[Y] = next[Y];
804  }
805 
806  G_debug(3, "GS_draw_flowline_at_xy(): dir: %f %f", nv[X], nv[Y]);
807  }
808 
809  return;
810 }
811 
820 void GS_draw_fringe(int id, unsigned long clr, float elev, int *where)
821 {
822  geosurf *gs;
823 
824  G_debug(3, "GS_draw_fringe(): id: %d clr: %ld elev %f edges: %d %d %d %d",
825  id, clr, elev, where[0], where[1], where[2], where[3]);
826  if ((gs = gs_get_surf(id)))
827  gsd_display_fringe(gs, clr, elev, where);
828 
829 }
830 
831 
845 int GS_draw_legend(const char *name, GLuint fontbase, int size, int *flags,
846  float *range, int *pt)
847 {
848  int list_no;
849 
850  list_no = gsd_put_legend(name, fontbase, size, flags, range, pt);
851 
852  return (list_no);
853 }
854 
863 void GS_draw_list(GLuint list_id)
864 {
865  gsd_calllist(list_id);
866  glFlush();
867  return;
868 }
869 
877 {
878  gsd_calllists(0); /* not sure if 0 is right - MN */
879  glFlush();
880  return;
881 }
882 
888 void GS_delete_list(GLuint list_id)
889 {
890  gsd_deletelist(list_id, 1);
891 
892  return;
893 }
894 
899 {
900  static float center[3];
901  float tcenter[3];
902 
903  if (!Modelshowing) {
904  GS_get_modelposition1(center);
905  }
906 
907  GS_v3eq(tcenter, center);
908 
909  gsd_zwritemask(0x0);
910  gsd_backface(1);
911 
912  gsd_colormode(CM_AD);
913  gsd_shademodel(DM_GOURAUD);
914  gsd_pushmatrix();
915  gsd_do_scale(1);
916 
917  if (Gv.vert_exag) {
918  tcenter[Z] *= Gv.vert_exag;
919  gsd_scale(1.0, 1.0, 1. / Gv.vert_exag);
920  }
921 
922  gsd_drawsphere(tcenter, 0xDDDDDD, (float)(Longdim / 10.));
923  gsd_popmatrix();
924  Modelshowing = 1;
925 
926  gsd_backface(0);
927  gsd_zwritemask(0xffffffff);
928 
929  return;
930 }
931 
939 {
940  static float center[3], size;
941  float tcenter[3], tsize;
942  int i, wason[MAX_CPLANES];
943 
944  gsd_get_cplanes_state(wason);
945 
946  for (i = 0; i < MAX_CPLANES; i++) {
947  if (wason[i]) {
948  gsd_cplane_off(i);
949  }
950  }
951 
952 
953  if (!Modelshowing) {
954  GS_get_modelposition(&size, center);
955  }
956 
957  GS_v3eq(tcenter, center);
958  tsize = size;
959 
960  gsd_zwritemask(0x0);
961  gsd_backface(1);
962 
963  gsd_colormode(CM_DIFFUSE);
964  gsd_shademodel(DM_GOURAUD);
965  gsd_pushmatrix();
966  gsd_drawsphere(tcenter, 0xDDDDDD, tsize);
967  gsd_popmatrix();
968  Modelshowing = 1;
969 
970  gsd_backface(0);
971  gsd_zwritemask(0xffffffff);
972 
973  for (i = 0; i < MAX_CPLANES; i++) {
974  if (wason[i]) {
975  gsd_cplane_on(i);
976  }
977  }
978 
979  gsd_flush();
980 
981  return;
982 }
983 
994 int GS_update_curmask(int id)
995 {
996  geosurf *gs;
997 
998  gs = gs_get_surf(id);
999  return (gs_update_curmask(gs));
1000 }
1001 
1012 int GS_is_masked(int id, float *pt)
1013 {
1014  geosurf *gs;
1015  Point3 tmp;
1016 
1017  if ((gs = gs_get_surf(id))) {
1018  tmp[X] = pt[X] - gs->ox;
1019  tmp[Y] = pt[Y] - gs->oy;
1020 
1021  return (gs_point_is_masked(gs, tmp));
1022  }
1023 
1024  return (-1);
1025 }
1026 
1031 {
1033  SDref_surf = 0;
1034 
1035  return;
1036 }
1037 
1046 int GS_set_SDsurf(int id)
1047 {
1048  geosurf *gs;
1049 
1050  if ((gs = gs_get_surf(id))) {
1051  gsdiff_set_SDref(gs);
1052  SDref_surf = id;
1053 
1054  return (1);
1055  }
1056 
1057  return (0);
1058 }
1059 
1067 int GS_set_SDscale(float scale)
1068 {
1069  gsdiff_set_SDscale(scale);
1070 
1071  return (1);
1072 }
1073 
1082 int GS_get_SDsurf(int *id)
1083 {
1084  geosurf *gs;
1085 
1086  if ((gs = gsdiff_get_SDref())) {
1087  *id = SDref_surf;
1088 
1089  return (1);
1090  }
1091 
1092  return (0);
1093 }
1094 
1102 int GS_get_SDscale(float *scale)
1103 {
1104  *scale = gsdiff_get_SDscale();
1105 
1106  return (1);
1107 }
1108 
1117 {
1118  geosurf *gs;
1119 
1120  gs = gs_get_surf(id);
1121 
1122  return (gs_calc_normals(gs));
1123 }
1124 
1137 int GS_get_att(int id, int att, int *set, float *constant, char *mapname)
1138 {
1139  int src;
1140  geosurf *gs;
1141 
1142  gs = gs_get_surf(id);
1143  if (gs) {
1144  if (-1 != (src = gs_get_att_src(gs, att))) {
1145  *set = src;
1146 
1147  if (src == CONST_ATT) {
1148  *constant = gs->att[att].constant;
1149  }
1150  else if (src == MAP_ATT) {
1151  strcpy(mapname, gsds_get_name(gs->att[att].hdata));
1152  }
1153 
1154  return (1);
1155  }
1156 
1157  return (-1);
1158  }
1159 
1160  return (-1);
1161 }
1162 
1180 int GS_get_cat_at_xy(int id, int att, char *catstr, float x, float y)
1181 {
1182  int offset, drow, dcol, vrow, vcol;
1183  float ftmp, pt[3];
1184  typbuff *buff;
1185  geosurf *gs;
1186 
1187  *catstr = '\0';
1188  gs = gs_get_surf(id);
1189 
1190  if (NULL == gs) {
1191  return -1;
1192  }
1193 
1194  pt[X] = x;
1195  pt[Y] = y;
1196 
1197  gsd_real2surf(gs, pt);
1198  if (gs_point_is_masked(gs, pt)) {
1199  return -1;
1200  }
1201 
1202  if (!in_vregion(gs, pt)) {
1203  return -1;
1204  }
1205 
1206  if (MAP_ATT != gs_get_att_src(gs, att)) {
1207  sprintf(catstr, _("no category info"));
1208  return -1;
1209  }
1210 
1211  buff = gs_get_att_typbuff(gs, att, 0);
1212 
1213  vrow = Y2VROW(gs, pt[Y]);
1214  vcol = X2VCOL(gs, pt[X]);
1215  drow = VROW2DROW(gs, vrow);
1216  dcol = VCOL2DCOL(gs, vcol);
1217 
1218  offset = DRC2OFF(gs, drow, dcol);
1219 
1220  if (GET_MAPATT(buff, offset, ftmp)) {
1221  return
1222  (Gs_get_cat_label(gsds_get_name(gs->att[att].hdata),
1223  drow, dcol, catstr));
1224  }
1225 
1226  sprintf(catstr, _("no data"));
1227 
1228  return 1;
1229 }
1230 
1243 int GS_get_norm_at_xy(int id, float x, float y, float *nv)
1244 {
1245  int offset, drow, dcol, vrow, vcol;
1246  float pt[3];
1247  geosurf *gs;
1248 
1249  gs = gs_get_surf(id);
1250 
1251  if (NULL == gs) {
1252  return (-1);
1253  }
1254 
1255  if (gs->norm_needupdate) {
1256  gs_calc_normals(gs);
1257  }
1258 
1259  pt[X] = x;
1260  pt[Y] = y;
1261 
1262  gsd_real2surf(gs, pt);
1263  if (gs_point_is_masked(gs, pt)) {
1264  return (-1);
1265  }
1266 
1267  if (!in_vregion(gs, pt)) {
1268  return (-1);
1269  }
1270 
1271  vrow = Y2VROW(gs, pt[Y]);
1272  vcol = X2VCOL(gs, pt[X]);
1273  drow = VROW2DROW(gs, vrow);
1274  dcol = VCOL2DCOL(gs, vcol);
1275 
1276  offset = DRC2OFF(gs, drow, dcol);
1277 
1278  if (gs->norms) {
1279  FNORM(gs->norms[offset], nv);
1280  }
1281  else {
1282  /* otherwise must be a constant */
1283  nv[0] = 0.0;
1284  nv[1] = 0.0;
1285  nv[2] = 1.0;
1286  }
1287 
1288  return (1);
1289 }
1290 
1307 int GS_get_val_at_xy(int id, int att, char *valstr, float x, float y)
1308 {
1309  int offset, drow, dcol, vrow, vcol;
1310  float ftmp, pt[3];
1311  typbuff *buff;
1312  geosurf *gs;
1313 
1314  *valstr = '\0';
1315  gs = gs_get_surf(id);
1316 
1317  if (NULL == gs) {
1318  return -1;
1319  }
1320 
1321  pt[X] = x;
1322  pt[Y] = y;
1323 
1324  gsd_real2surf(gs, pt);
1325 
1326  if (gs_point_is_masked(gs, pt)) {
1327  return -1;
1328  }
1329 
1330  if (!in_vregion(gs, pt)) {
1331  return (-1);
1332  }
1333 
1334  if (CONST_ATT == gs_get_att_src(gs, att)) {
1335  if (att == ATT_COLOR) {
1336  int r, g, b, i;
1337 
1338  i = gs->att[att].constant;
1339  sprintf(valstr, "R%d G%d B%d",
1340  INT_TO_RED(i, r), INT_TO_GRN(i, g), INT_TO_BLU(i, b));
1341  }
1342  else {
1343  sprintf(valstr, "%f", gs->att[att].constant);
1344  }
1345 
1346  return 1;
1347  }
1348  else if (MAP_ATT != gs_get_att_src(gs, att)) {
1349  return -1;
1350  }
1351 
1352  buff = gs_get_att_typbuff(gs, att, 0);
1353 
1354  vrow = Y2VROW(gs, pt[Y]);
1355  vcol = X2VCOL(gs, pt[X]);
1356  drow = VROW2DROW(gs, vrow);
1357  dcol = VCOL2DCOL(gs, vcol);
1358 
1359  offset = DRC2OFF(gs, drow, dcol);
1360 
1361  if (GET_MAPATT(buff, offset, ftmp)) {
1362  if (att == ATT_COLOR) {
1363  int r, g, b, i;
1364 
1365  i = gs_mapcolor(gs_get_att_typbuff(gs, ATT_COLOR, 0),
1366  &(gs->att[ATT_COLOR]), offset);
1367  sprintf(valstr, "R%d G%d B%d",
1368  INT_TO_RED(i, r), INT_TO_GRN(i, g), INT_TO_BLU(i, b));
1369  }
1370  else {
1371  sprintf(valstr, "%f", ftmp);
1372  }
1373 
1374  return (1);
1375  }
1376 
1377  sprintf(valstr, "NULL");
1378 
1379  return (1);
1380 }
1381 
1390 int GS_unset_att(int id, int att)
1391 {
1392  geosurf *gs;
1393 
1394  gs = gs_get_surf(id);
1395  gs->mask_needupdate = 1;
1396 
1397  return (gs_set_att_src(gs, att, NOTSET_ATT));
1398 }
1399 
1409 int GS_set_att_const(int id, int att, float constant)
1410 {
1411  geosurf *gs;
1412  int ret;
1413 
1414  gs = gs_get_surf(id);
1415  ret = (gs_set_att_const(gs, att, constant));
1416 
1417  Gs_update_attrange(gs, att);
1418 
1419  return (ret);
1420 }
1421 
1433 int GS_set_maskmode(int id, int mode)
1434 {
1435  geosurf *gs;
1436 
1437  gs = gs_get_surf(id);
1438 
1439  if (gs) {
1440  gs->att[ATT_MASK].constant = mode;
1441  gs->mask_needupdate = 1;
1442 
1443  return (mode);
1444  }
1445 
1446  return (-1);
1447 }
1448 
1458 int GS_get_maskmode(int id, int *mode)
1459 {
1460  geosurf *gs;
1461 
1462  gs = gs_get_surf(id);
1463 
1464  if (gs) {
1465  *mode = gs->att[ATT_MASK].constant;
1466 
1467  return (1);
1468  }
1469 
1470  return (-1);
1471 }
1472 
1482 int GS_Set_ClientData(int id, void *clientd)
1483 {
1484  geosurf *gs;
1485 
1486  gs = gs_get_surf(id);
1487  if (gs) {
1488  gs->clientdata = clientd;
1489 
1490  return (1);
1491  }
1492 
1493  return (-1);
1494 }
1495 
1504 void *GS_Get_ClientData(int id)
1505 {
1506  geosurf *gs;
1507 
1508  gs = gs_get_surf(id);
1509  if (gs) {
1510  return (gs->clientdata);
1511  }
1512 
1513  return (NULL);
1514 }
1515 
1521 int GS_num_surfs(void)
1522 {
1523  return (gs_num_surfaces());
1524 }
1525 
1536 int *GS_get_surf_list(int *numsurfs)
1537 {
1538  int i, *ret;
1539 
1540  *numsurfs = Next_surf;
1541 
1542  if (Next_surf) {
1543  ret = (int *)G_malloc(Next_surf * sizeof(int));
1544 
1545  for (i = 0; i < Next_surf; i++) {
1546  ret[i] = Surf_ID[i];
1547  }
1548 
1549  return (ret);
1550  }
1551 
1552  return (NULL);
1553 }
1554 
1564 {
1565  int i, j, found;
1566 
1567  found = FALSE;
1568 
1569  G_debug(1, "GS_delete_surface(): id=%d", id);
1570 
1571  if (GS_surf_exists(id)) {
1572  gs_delete_surf(id);
1573  for (i = 0; i < Next_surf && !found; i++) {
1574  if (Surf_ID[i] == id) {
1575  found = TRUE;
1576 
1577  for (j = i; j < Next_surf; j++) {
1578  Surf_ID[j] = Surf_ID[j + 1];
1579  }
1580  }
1581  }
1582 
1584 
1585  if (found) {
1586  --Next_surf;
1587  return 1;
1588  }
1589  }
1590 
1591  return -1;
1592 }
1593 
1594 
1605 int GS_load_att_map(int id, const char *filename, int att)
1606 {
1607  geosurf *gs;
1608  unsigned int changed;
1609  unsigned int atty;
1610  const char *mapset;
1611  struct Cell_head rast_head;
1612  int reuse, begin, hdata, ret, neg, has_null;
1613  typbuff *tbuff;
1614 
1615  G_debug(3, "GS_load_att_map(): map=%s", filename);
1616 
1617  reuse = ret = neg = has_null = 0;
1618  gs = gs_get_surf(id);
1619 
1620  if (NULL == gs) {
1621  return -1;
1622  }
1623 
1624  gs->mask_needupdate = (ATT_MASK == att || ATT_TOPO == att ||
1625  (gs->nz_topo && ATT_TOPO == att) ||
1626  (gs->nz_color && ATT_COLOR == att));
1627 
1628  gs_set_att_src(gs, att, MAP_ATT);
1629 
1630  /* Check against maps already loaded in memory */
1631  /* if to be color attribute:
1632  - if packed color for another surface, OK to reuse
1633  - if unchanged, ok to reuse IF it's of type char (will have lookup)
1634  */
1635  begin = hdata = 1;
1636 
1637  /* Get MAPSET to ensure names are fully qualified */
1638  mapset = G_find_cell2(filename, "");
1639  if (mapset == NULL) {
1640  /* Check for valid filename */
1641  G_warning("Raster map <%s> not found", filename);
1642  return -1;
1643  }
1644 
1645  /* Check to see if map is in Region */
1646  G_get_cellhd(filename, mapset, &rast_head);
1647  if (rast_head.north <= wind.south ||
1648  rast_head.south >= wind.north ||
1649  rast_head.east <= wind.west || rast_head.west >= wind.east) {
1650 
1651  G_warning(_("Raster map <%s> is outside of current region. Load failed."),
1652  G_fully_qualified_name(filename, mapset));
1653  }
1654 
1655  while (!reuse && (0 < hdata)) {
1656  changed = CF_COLOR_PACKED;
1657  atty = ATTY_FLOAT | ATTY_CHAR | ATTY_INT | ATTY_SHORT | ATTY_MASK;
1658 
1659  if (0 < (hdata = gsds_findh(filename, &changed, &atty, begin))) {
1660 
1661  G_debug(3, "GS_load_att_map(): %s already has data handle %d.CF=%x",
1662  filename, hdata, changed);
1663 
1664  /* handle found */
1665  if (ATT_COLOR == att) {
1666  if ((changed == CF_COLOR_PACKED) ||
1667  (!changed && atty == ATTY_CHAR)) {
1668  reuse = 1;
1669  }
1670  }
1671  else if (atty == ATTY_MASK && att != ATT_MASK) {
1672  reuse = 0;
1673  /* should also free mask data & share new - but need backward
1674  reference? */
1675  }
1676  else if (!changed) {
1677  reuse = 1;
1678  }
1679  }
1680 
1681  begin = 0;
1682  }
1683 
1684  if (reuse) {
1685  gs->att[att].hdata = hdata;
1686  gs_set_att_type(gs, att, atty); /* ?? */
1687 
1688  /* free lookup & set to NULL! */
1689  if (atty == ATTY_INT) {
1690  if (gs->att[att].lookup) {
1691  free(gs->att[att].lookup);
1692  gs->att[att].lookup = NULL;
1693  }
1694  }
1695  /* TODO: FIX THIS stuff with lookup sharing! */
1696 
1697  G_debug(3, "GS_load_att_map(): %s is being reused. hdata=%d",
1698  filename, hdata);
1699  }
1700  else {
1701  G_debug(3, "GS_load_att_map(): %s not loaded in correct form - loading now",
1702  filename);
1703 
1704  /* not loaded - need to get new dataset handle */
1705  gs->att[att].hdata = gsds_newh(filename);
1706 
1707  tbuff = gs_get_att_typbuff(gs, att, 1);
1708 
1709  /* TODO: Provide mechanism for loading certain attributes at
1710  specified sizes, allow to scale or cap, or scale non-zero */
1711  if (ATT_MASK == att) {
1712  atty = ATTY_MASK;
1713  }
1714  else {
1715  atty = Gs_numtype(filename, &neg);
1716  }
1717 
1718 #ifdef MAYBE_LATER
1719  if (att == ATT_COLOR && atty == ATTY_SHORT) {
1720  atty = (neg ? ATTY_INT : ATTY_SHORT);
1721  }
1722 #endif
1723 
1724  if (att == ATT_COLOR && atty == ATTY_SHORT) {
1725  atty = ATTY_INT;
1726  }
1727 
1728  if (0 > gs_malloc_att_buff(gs, att, ATTY_NULL)) {
1729  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1730  }
1731 
1732  switch (atty) {
1733  case ATTY_MASK:
1734  if (0 > gs_malloc_att_buff(gs, att, ATTY_MASK)) {
1735  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1736  }
1737 
1738  ret = Gs_loadmap_as_bitmap(&wind, filename, tbuff->bm);
1739 
1740  break;
1741  case ATTY_CHAR:
1742  if (0 > gs_malloc_att_buff(gs, att, ATTY_CHAR)) {
1743  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1744  }
1745 
1746  ret = Gs_loadmap_as_char(&wind, filename, tbuff->cb,
1747  tbuff->nm, &has_null);
1748 
1749  break;
1750  case ATTY_SHORT:
1751  if (0 > gs_malloc_att_buff(gs, att, ATTY_SHORT)) {
1752  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1753  }
1754 
1755  ret = Gs_loadmap_as_short(&wind, filename, tbuff->sb,
1756  tbuff->nm, &has_null);
1757  break;
1758  case ATTY_FLOAT:
1759  if (0 > gs_malloc_att_buff(gs, att, ATTY_FLOAT)) {
1760  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1761  }
1762 
1763  ret = Gs_loadmap_as_float(&wind, filename, tbuff->fb,
1764  tbuff->nm, &has_null);
1765 
1766  break;
1767  case ATTY_INT:
1768  default:
1769  if (0 > gs_malloc_att_buff(gs, att, ATTY_INT)) {
1770  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1771  }
1772 
1773  ret = Gs_loadmap_as_int(&wind, filename, tbuff->ib,
1774  tbuff->nm, &has_null);
1775  break;
1776 
1777  } /* Done with switch */
1778 
1779  if (ret == -1) {
1780  gsds_free_data_buff(gs->att[att].hdata, ATTY_NULL);
1781  return -1;
1782  }
1783 
1784  G_debug(4, " has_null=%d", has_null);
1785 
1786  if (!has_null) {
1787  gsds_free_data_buff(gs->att[att].hdata, ATTY_NULL);
1788  }
1789  else {
1790  gs_update_curmask(gs);
1791  }
1792 
1793  } /* end if not reuse */
1794 
1795  if (ATT_COLOR == att) {
1796 #ifdef MAYBE_LATER
1797  if (ATTY_INT == atty) {
1798  Gs_pack_colors(filename, tbuff->ib, gs->rows, gs->cols);
1799  gsds_set_changed(gs->att[att].hdata, CF_COLOR_PACKED);
1800  gs->att[att].lookup = NULL;
1801  }
1802  else {
1803  gs_malloc_lookup(gs, att);
1804  Gs_build_lookup(filename, gs->att[att].lookup);
1805  }
1806 #else
1807 
1808  if (ATTY_CHAR == atty) {
1809  if (!gs->att[att].lookup) {
1810  /* might already exist if reusing */
1811  gs_malloc_lookup(gs, att);
1812  Gs_build_256lookup(filename, gs->att[att].lookup);
1813  }
1814  }
1815  else if (ATTY_FLOAT == atty) {
1816  if (!reuse) {
1817  if (0 > gs_malloc_att_buff(gs, att, ATTY_INT)) {
1818  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1819  }
1820 
1821  Gs_pack_colors_float(filename, tbuff->fb, tbuff->ib,
1822  gs->rows, gs->cols);
1823  gsds_set_changed(gs->att[att].hdata, CF_COLOR_PACKED);
1824  gsds_free_data_buff(gs->att[att].hdata, ATTY_FLOAT);
1825  gs->att[att].lookup = NULL;
1826  }
1827  }
1828  else {
1829  if (!reuse) {
1830  Gs_pack_colors(filename, tbuff->ib, gs->rows, gs->cols);
1831  gsds_set_changed(gs->att[att].hdata, CF_COLOR_PACKED);
1832  gs->att[att].lookup = NULL;
1833  }
1834  }
1835 #endif
1836  }
1837 
1838  if (ATT_TOPO == att) {
1839  gs_init_normbuff(gs);
1840  /* S_DIFF: should also check here to see if this surface is a
1841  reference surface for scaled differences, if so update references
1842  to it */
1843  }
1844 
1845  if (ret < 0) {
1846  G_warning(_("Loading failed"));
1847  }
1848 
1849  if (-1 == Gs_update_attrange(gs, att)) {
1850  G_warning(_("Error finding range"));
1851  }
1852 
1853  return ret;
1854 }
1855 
1861 void GS_draw_surf(int id)
1862 {
1863  geosurf *gs;
1864 
1865  G_debug(3, "GS_draw_surf(): id=%d", id);
1866 
1867  gs = gs_get_surf(id);
1868  if (gs) {
1869  gsd_shademodel(gs->draw_mode & DM_GOURAUD);
1870 
1871  if (gs->draw_mode & DM_POLY) {
1872  gsd_surf(gs);
1873  }
1874 
1875  if (gs->draw_mode & DM_WIRE) {
1876  gsd_wire_surf(gs);
1877  }
1878 
1879  /* TODO: write wire/poly draw routines */
1880  if (gs->draw_mode & DM_WIRE_POLY) {
1881  gsd_surf(gs);
1882  gsd_wire_surf(gs);
1883  }
1884  }
1885 
1886  return;
1887 }
1888 
1896 void GS_draw_wire(int id)
1897 {
1898  geosurf *gs;
1899 
1900  G_debug(3, "GS_draw_wire(): id=%d", id);
1901 
1902  gs = gs_get_surf(id);
1903 
1904  if (gs) {
1905  gsd_wire_surf(gs);
1906  }
1907 
1908  return;
1909 }
1910 
1917 {
1918  geosurf *gs;
1919  int i;
1920 
1921  for (i = 0; i < Next_surf; i++) {
1922  if ((gs = gs_get_surf(Surf_ID[i]))) {
1923  gsd_wire_surf(gs);
1924  }
1925  }
1926 
1927  return;
1928 }
1929 
1934 {
1935  int i;
1936 
1937  for (i = 0; i < Next_surf; i++) {
1938  GS_draw_surf(Surf_ID[i]);
1939  }
1940 
1941  return;
1942 }
1943 
1950 void GS_set_exag(int id, float exag)
1951 {
1952  geosurf *gs;
1953 
1954  G_debug(3, "GS_set_exag");
1955 
1956  gs = gs_get_surf(id);
1957 
1958  if (gs) {
1959  if (gs->z_exag != exag) {
1960  gs->norm_needupdate = 1;
1961  }
1962 
1963  gs->z_exag = exag;
1964  }
1965 
1966  return;
1967 }
1968 
1974 void GS_set_global_exag(float exag)
1975 {
1976 
1977  G_debug(3, "GS_set_global_exag");
1978 
1979  Gv.vert_exag = exag;
1980  /* GL_NORMALIZE */
1981  /* Only need to update norms gs_norms.c
1982  * if exag is used in norm equation which
1983  * it is not! If GL_NORMALIZE is disabled
1984  * will need to include.
1985  gs_setall_norm_needupdate();
1986  */
1987 
1988  return;
1989 }
1990 
1996 float GS_global_exag(void)
1997 {
1998  G_debug(3, "GS_global_exag(): %g", Gv.vert_exag);
1999 
2000  return (Gv.vert_exag);
2001 }
2002 
2011 void GS_set_wire_color(int id, int colr)
2012 {
2013  geosurf *gs;
2014 
2015  G_debug(3, "GS_set_wire_color");
2016 
2017  gs = gs_get_surf(id);
2018 
2019  if (gs) {
2020  gs->wire_color = colr;
2021  }
2022 
2023  return;
2024 }
2025 
2035 int GS_get_wire_color(int id, int *colr)
2036 {
2037  geosurf *gs;
2038 
2039  gs = gs_get_surf(id);
2040 
2041  if (gs) {
2042  *colr = gs->wire_color;
2043 
2044  return (1);
2045  }
2046 
2047  return (-1);
2048 }
2049 
2059 {
2060  int i;
2061 
2062  for (i = 0; i < Next_surf; i++) {
2063  if (0 != GS_set_drawmode(Surf_ID[i], mode)) {
2064  return (-1);
2065  }
2066  }
2067 
2068  return (0);
2069 }
2070 
2080 int GS_set_drawmode(int id, int mode)
2081 {
2082  geosurf *gs;
2083 
2084  G_debug(3, "GS_set_drawmode(): id=%d mode=%d", id, mode);
2085 
2086  gs = gs_get_surf(id);
2087 
2088  if (gs) {
2089  gs->draw_mode = mode;
2090 
2091  return (0);
2092  }
2093 
2094  return (-1);
2095 }
2096 
2106 int GS_get_drawmode(int id, int *mode)
2107 {
2108  geosurf *gs;
2109 
2110  gs = gs_get_surf(id);
2111 
2112  if (gs) {
2113  *mode = gs->draw_mode;
2114 
2115  return (1);
2116  }
2117 
2118  return (-1);
2119 }
2120 
2128 void GS_set_nozero(int id, int att, int mode)
2129 {
2130  geosurf *gs;
2131 
2132  G_debug(3, "GS_set_nozero");
2133 
2134  gs = gs_get_surf(id);
2135 
2136  if (gs) {
2137  if (att == ATT_TOPO) {
2138  gs->nz_topo = mode;
2139  gs->mask_needupdate = 1;
2140  }
2141 
2142  if (att == ATT_COLOR) {
2143  gs->nz_color = mode;
2144  gs->mask_needupdate = 1;
2145  }
2146  }
2147 
2148  return;
2149 }
2150 
2161 int GS_get_nozero(int id, int att, int *mode)
2162 {
2163  geosurf *gs;
2164 
2165  G_debug(3, "GS_set_nozero");
2166 
2167  gs = gs_get_surf(id);
2168 
2169  if (gs) {
2170  if (att == ATT_TOPO) {
2171  *mode = gs->nz_topo;
2172  }
2173  else if (att == ATT_COLOR) {
2174  *mode = gs->nz_color;
2175  }
2176  else {
2177  return (-1);
2178  }
2179 
2180  return (1);
2181  }
2182 
2183  return (-1);
2184 }
2185 
2195 int GS_setall_drawres(int xres, int yres, int xwire, int ywire)
2196 {
2197  int i;
2198 
2199  for (i = 0; i < Next_surf; i++) {
2200  if (0 != GS_set_drawres(Surf_ID[i], xres, yres, xwire, ywire)) {
2201  return (-1);
2202  }
2203  }
2204 
2205  return (0);
2206 }
2207 
2218 int GS_set_drawres(int id, int xres, int yres, int xwire, int ywire)
2219 {
2220  geosurf *gs;
2221 
2222  G_debug(3, "GS_set_drawres() id=%d xyres=%d/%d xywire=%d/%d",
2223  id, xres, yres, xwire, ywire);
2224 
2225  if (xres < 1 || yres < 1 || xwire < 1 || ywire < 1) {
2226  return (-1);
2227  }
2228 
2229  gs = gs_get_surf(id);
2230 
2231  if (gs) {
2232  if (gs->x_mod != xres || gs->y_mod != yres) {
2233  gs->norm_needupdate = 1;
2234  }
2235 
2236  gs->x_mod = xres;
2237  gs->y_mod = yres;
2238  gs->x_modw = xwire;
2239  gs->y_modw = ywire;
2240  }
2241 
2242  return (0);
2243 }
2244 
2252 void GS_get_drawres(int id, int *xres, int *yres, int *xwire, int *ywire)
2253 {
2254  geosurf *gs;
2255 
2256  G_debug(3, "GS_get_drawres");
2257 
2258  gs = gs_get_surf(id);
2259 
2260  if (gs) {
2261  *xres = gs->x_mod;
2262  *yres = gs->y_mod;
2263  *xwire = gs->x_modw;
2264  *ywire = gs->y_modw;
2265  }
2266 
2267  return;
2268 }
2269 
2276 void GS_get_dims(int id, int *rows, int *cols)
2277 {
2278  geosurf *gs;
2279 
2280  gs = gs_get_surf(id);
2281 
2282  if (gs) {
2283  *rows = gs->rows;
2284  *cols = gs->cols;
2285  }
2286 
2287  return;
2288 }
2289 
2303 int GS_get_exag_guess(int id, float *exag)
2304 {
2305  geosurf *gs;
2306  float guess;
2307 
2308  gs = gs_get_surf(id);
2309  guess = 1.0;
2310 
2311  /* if gs is type const return guess = 1.0 */
2312  if (CONST_ATT == gs_get_att_src(gs, ATT_TOPO)) {
2313  *exag = guess;
2314  return (1);
2315  }
2316 
2317  if (gs) {
2318  if (gs->zrange_nz == 0.0) {
2319  *exag = 0.0;
2320 
2321  return (1);
2322  }
2323 
2324  G_debug(3, "GS_get_exag_guess(): %f %f", gs->zrange_nz, Longdim);
2325 
2326  while (gs->zrange_nz * guess / Longdim >= .25) {
2327  guess *= .1;
2328 
2329  G_debug(3, "GS_get_exag_guess(): %f", guess);
2330  }
2331 
2332  while (gs->zrange_nz * guess / Longdim < .025) {
2333  guess *= 10.;
2334 
2335  G_debug(3, "GS_get_exag_guess(): %f", guess);
2336  }
2337 
2338  *exag = guess;
2339 
2340  return (1);
2341  }
2342 
2343  return (-1);
2344 }
2345 
2354 void GS_get_zrange_nz(float *min, float *max)
2355 {
2356  int i, first = 1;
2357  geosurf *gs;
2358 
2359  for (i = 0; i < Next_surf; i++) {
2360  if ((gs = gs_get_surf(Surf_ID[i]))) {
2361  if (first) {
2362  first = 0;
2363  *min = gs->zmin_nz;
2364  *max = gs->zmax_nz;
2365  }
2366 
2367  if (gs->zmin_nz < *min) {
2368  *min = gs->zmin_nz;
2369  }
2370 
2371  if (gs->zmax_nz > *max) {
2372  *max = gs->zmax_nz;
2373  }
2374  }
2375  }
2376 
2377  G_debug(3, "GS_get_zrange_nz(): min=%g max=%g", *min, *max);
2378 
2379  return;
2380 }
2381 
2388 void GS_set_trans(int id, float xtrans, float ytrans, float ztrans)
2389 {
2390  geosurf *gs;
2391 
2392  G_debug(3, "GS_set_trans");
2393 
2394  gs = gs_get_surf(id);
2395 
2396  if (gs) {
2397  gs->x_trans = xtrans;
2398  gs->y_trans = ytrans;
2399  gs->z_trans = ztrans;
2400  }
2401 
2402  return;
2403 }
2404 
2411 void GS_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
2412 {
2413  geosurf *gs;
2414 
2415  G_debug(3, "GS_get_trans");
2416 
2417  gs = gs_get_surf(id);
2418 
2419  if (gs) {
2420  *xtrans = gs->x_trans;
2421  *ytrans = gs->y_trans;
2422  *ztrans = gs->z_trans;
2423  }
2424 
2425  return;
2426 }
2427 
2428 
2434 unsigned int GS_default_draw_color(void)
2435 {
2436 
2437  G_debug(3, "GS_default_draw_color");
2438 
2439  return ((unsigned int)Gd.bgcol);
2440 }
2441 
2447 unsigned int GS_background_color(void)
2448 {
2449  return ((unsigned int)Gd.bgcol);
2450 }
2451 
2457 void GS_set_draw(int where)
2458 {
2459  Buffermode = where;
2460 
2461  switch (where) {
2462  case GSD_BOTH:
2463  gsd_frontbuffer(1);
2464  gsd_backbuffer(1);
2465 
2466  break;
2467  case GSD_FRONT:
2468  gsd_frontbuffer(1);
2469  gsd_backbuffer(0);
2470 
2471  break;
2472  case GSD_BACK:
2473  default:
2474  gsd_frontbuffer(0);
2475  gsd_backbuffer(1);
2476 
2477  break;
2478  }
2479 
2480  return;
2481 }
2482 
2483 /*
2484  \brief Ready to draw
2485  */
2486 void GS_ready_draw(void)
2487 {
2488 
2489  G_debug(3, "GS_ready_draw");
2490 
2491  gsd_set_view(&Gv, &Gd);
2492 
2493  return;
2494 }
2495 
2499 void GS_done_draw(void)
2500 {
2501 
2502  G_debug(3, "GS_done_draw");
2503 
2504  if (GSD_BACK == Buffermode) {
2505  gsd_swapbuffers();
2506  }
2507 
2508  gsd_flush();
2509 
2510  return;
2511 }
2512 
2518 void GS_set_focus(float *realto)
2519 {
2520 
2521  G_debug(3, "GS_set_focus(): %f,%f,%f", realto[0], realto[1], realto[2]);
2522 
2523  Gv.infocus = 1;
2524  GS_v3eq(Gv.real_to, realto);
2525 
2526  gsd_set_view(&Gv, &Gd);
2527 
2528  return;
2529 }
2530 
2536 void GS_set_focus_real(float *realto)
2537 {
2538 
2539  G_get_set_window(&wind);
2540  realto[X] = realto[X] - wind.west - (wind.ew_res / 2.);
2541  realto[Y] = realto[Y] - wind.south - (wind.ns_res / 2.);
2542 
2543  Gv.infocus = 1;
2544  GS_v3eq(Gv.real_to, realto);
2545 
2546  gsd_set_view(&Gv, &Gd);
2547 
2548  return;
2549 }
2550 
2551 
2561 int GS_get_focus(float *realto)
2562 {
2563 
2564  G_debug(3, "GS_get_focus");
2565 
2566  if (Gv.infocus) {
2567  if (realto) {
2568  GS_v3eq(realto, Gv.real_to);
2569  }
2570  }
2571 
2572  return (Gv.infocus);
2573 }
2574 
2581 {
2582  float center[3];
2583  geosurf *gs;
2584 
2585  G_debug(3, "GS_set_focus_center_map");
2586 
2587  gs = gs_get_surf(id);
2588 
2589  if (gs) {
2590  center[X] = (gs->xmax - gs->xmin) / 2.;
2591  center[Y] = (gs->ymax - gs->ymin) / 2.;
2592  center[Z] = (gs->zmax_nz + gs->zmin_nz) / 2.;
2593 
2594  /* not yet working
2595  buff = gs_get_att_typbuff(gs, ATT_TOPO, 0);
2596  offset = gs->rows*gs->cols/2 + gs->cols/2;
2597  if (buff)
2598  {
2599  if (GET_MAPATT(buff, offset, tmp))
2600  {
2601  center[Z] = tmp;
2602  }
2603  }
2604  */
2605 
2606  GS_set_focus(center);
2607  }
2608 }
2609 
2615 void GS_moveto(float *pt)
2616 {
2617  float ft[3];
2618 
2619  G_debug(3, "GS_moveto(): %f,%f,%f", pt[0], pt[1], pt[2]);
2620 
2621  if (Gv.infocus) {
2622  GS_v3eq(Gv.from_to[FROM], pt);
2623  /*
2624  GS_v3eq(Gv.from_to[TO], Gv.real_to);
2625  */
2626  GS_v3normalize(Gv.from_to[FROM], Gv.from_to[TO]);
2627  /* update inclination, look_dir if we're keeping these */
2628  }
2629  else {
2630  GS_v3eq(ft, Gv.from_to[TO]);
2631  GS_v3sub(ft, Gv.from_to[FROM]);
2632  GS_v3eq(Gv.from_to[FROM], pt);
2633  GS_v3eq(Gv.from_to[TO], pt);
2634  GS_v3add(Gv.from_to[TO], ft);
2635  }
2636 
2637  return;
2638 }
2639 
2645 void GS_moveto_real(float *pt)
2646 {
2647  gsd_real2model(pt);
2648  GS_moveto(pt);
2649 
2650  return;
2651 }
2652 
2664 int GS_get_zextents(int id, float *min, float *max, float *mid)
2665 {
2666  geosurf *gs;
2667 
2668  if (NULL == (gs = gs_get_surf(id))) {
2669  return (-1);
2670  }
2671 
2672  G_debug(3, "GS_get_zextents(): id=%d", id);
2673 
2674  return (gs_get_zextents(gs, min, max, mid));
2675 }
2676 
2687 int GS_get_zrange(float *min, float *max, int doexag)
2688 {
2689  int ret_surf, ret_vol;
2690  float surf_min, surf_max;
2691  float vol_min, vol_max;
2692 
2693  ret_surf = gs_get_zrange(&surf_min, &surf_max);
2694  ret_vol = gvl_get_zrange(&vol_min, &vol_max);
2695 
2696  if (ret_surf > 0 && ret_vol > 0) {
2697  *min = (surf_min < vol_min) ? surf_min : vol_min;
2698  *max = (surf_max < vol_max) ? surf_max : vol_max;
2699  }
2700  else if (ret_surf > 0) {
2701  *min = surf_min;
2702  *max = surf_max;
2703  }
2704  else if (ret_vol > 0) {
2705  *min = vol_min;
2706  *max = vol_max;
2707  }
2708 
2709  if (doexag) {
2710  *min *= Gv.vert_exag;
2711  *max *= Gv.vert_exag;
2712  }
2713 
2714  G_debug(3, "GS_get_zrange(): min=%g max=%g", *min, *max);
2715  return ((ret_surf > 0 || ret_vol > 0) ? (1) : (-1));
2716 }
2717 
2723 void GS_get_from(float *fr)
2724 {
2725  GS_v3eq(fr, Gv.from_to[FROM]);
2726 
2727  G_debug(3, "GS_get_from(): %f,%f,%f", fr[0], fr[1], fr[2]);
2728 
2729  return;
2730 }
2731 
2737 void GS_get_from_real(float *fr)
2738 {
2739  GS_v3eq(fr, Gv.from_to[FROM]);
2740  gsd_model2real(fr);
2741 
2742  return;
2743 }
2744 
2750 void GS_get_to_real(float *to)
2751 {
2752  float realto[3];
2753 
2754  G_get_set_window(&wind);
2755  GS_get_focus(realto);
2756  to[X] = realto[X] + wind.west + (wind.ew_res / 2.);
2757  to[Y] = realto[Y] + wind.south + (wind.ns_res / 2.);
2758  to[Z] = realto[Z];
2759 
2760  return;
2761 }
2762 
2763 
2770 void GS_zoom_setup(int *a, int *b, int *c, int *d, int *maxx, int *maxy)
2771 {
2772  GLint tmp[4];
2773  GLint num[2];
2774 
2775  gsd_getViewport(tmp, num);
2776  *a = tmp[0];
2777  *b = tmp[1];
2778  *c = tmp[2];
2779  *d = tmp[3];
2780  *maxx = num[0];
2781  *maxy = num[1];
2782 
2783  return;
2784 }
2785 
2793 void GS_get_to(float *to)
2794 {
2795  G_debug(3, "GS_get_to");
2796 
2797  GS_v3eq(to, Gv.from_to[TO]);
2798 
2799  return;
2800 }
2801 
2807 void GS_get_viewdir(float *dir)
2808 {
2809  GS_v3dir(Gv.from_to[FROM], Gv.from_to[TO], dir);
2810 
2811  return;
2812 }
2813 
2821 void GS_set_viewdir(float *dir)
2822 {
2823  float tmp[3];
2824 
2825  GS_v3eq(tmp, dir);
2826  GS_v3norm(tmp);
2827  GS_v3eq(Gv.from_to[TO], Gv.from_to[FROM]);
2828  GS_v3add(Gv.from_to[TO], tmp);
2829 
2830  GS_set_nofocus();
2831  gsd_set_view(&Gv, &Gd);
2832 
2833  return;
2834 }
2835 
2841 void GS_set_fov(int fov)
2842 {
2843  Gv.fov = fov;
2844 
2845  return;
2846 }
2847 
2853 int GS_get_fov(void)
2854 {
2855  return (Gv.fov);
2856 }
2857 
2863 int GS_get_twist(void)
2864 {
2865  return (Gv.twist);
2866 }
2867 
2875 void GS_set_twist(int t)
2876 {
2877  Gv.twist = t;
2878 
2879  return;
2880 }
2881 
2885 void GS_set_rotation(double angle, double x, double y, double z)
2886 {
2887  Gv.rotate.rot_angle = angle;
2888  Gv.rotate.rot_axes[0] = x;
2889  Gv.rotate.rot_axes[1] = y;
2890  Gv.rotate.rot_axes[2] = z;
2891  Gv.rotate.do_rot = 1;
2892 
2893  return;
2894 }
2895 
2900 {
2901  Gv.rotate.do_rot = 0;
2902 }
2903 
2908 {
2909  int i;
2910 
2911  for (i = 0; i < 16; i++) {
2912  if (i == 0 || i == 5 || i == 10 || i == 15)
2913  Gv.rotate.rotMatrix[i] = 1.0;
2914  else
2915  Gv.rotate.rotMatrix[i] = 0.0;
2916  }
2917  Gv.rotate.rot_angle = 0.0;
2918  Gv.rotate.rot_axes[0] = 0.0;
2919  Gv.rotate.rot_axes[1] = 0.0;
2920  Gv.rotate.rot_axes[2] = 0.0;
2921  Gv.rotate.do_rot = 0;
2922 
2923 }
2927 void GS_get_rotation_matrix(double *matrix)
2928 {
2929  int i;
2930 
2931  for (i = 0; i < 16; i++) {
2932  matrix[i] = Gv.rotate.rotMatrix[i];
2933  }
2934 }
2935 
2939 void GS_set_rotation_matrix(double *matrix)
2940 {
2941  int i;
2942 
2943  for (i = 0; i < 16; i++) {
2944  Gv.rotate.rotMatrix[i] = matrix[i];
2945  }
2946 }
2947 
2951 void GS_set_nofocus(void)
2952 {
2953  G_debug(3, "GS_set_nofocus");
2954 
2955  Gv.infocus = 0;
2956 
2957  return;
2958 }
2959 
2965 void GS_set_infocus(void)
2966 {
2967  G_debug(3, "GS_set_infocus");
2968 
2969  Gv.infocus = 1;
2970 
2971  return;
2972 }
2973 
2979 void GS_set_viewport(int left, int right, int bottom, int top)
2980 {
2981  G_debug(3, "GS_set_viewport(): left=%d, right=%d, "
2982  "bottom=%d, top=%d", left, right, bottom, top);
2983 
2984  gsd_viewport(left, right, bottom, top);
2985 
2986  return;
2987 }
2988 
3003 int GS_look_here(int sx, int sy)
3004 {
3005  float x, y, z, len, los[2][3];
3006  Point3 realto, dir;
3007  int id;
3008  geosurf *gs;
3009 
3010  if (GS_get_selected_point_on_surface(sx, sy, &id, &x, &y, &z)) {
3011  gs = gs_get_surf(id);
3012  if (gs) {
3013  realto[X] = x - gs->ox + gs->x_trans;
3014  realto[Y] = y - gs->oy + gs->y_trans;
3015  realto[Z] = z + gs->z_trans;
3016  GS_set_focus(realto);
3017 
3018  return (1);
3019  }
3020  }
3021  else {
3022  if (gsd_get_los(los, (short)sx, (short)sy)) {
3023  len = GS_distance(Gv.from_to[FROM], Gv.real_to);
3024  GS_v3dir(los[FROM], los[TO], dir);
3025  GS_v3mult(dir, len);
3026  realto[X] = Gv.from_to[FROM][X] + dir[X];
3027  realto[Y] = Gv.from_to[FROM][Y] + dir[Y];
3028  realto[Z] = Gv.from_to[FROM][Z] + dir[Z];
3029  GS_set_focus(realto);
3030 
3031  return (1);
3032  }
3033  }
3034 
3035  return (0);
3036 }
3037 
3052 int GS_get_selected_point_on_surface(int sx, int sy, int *id, float *x,
3053  float *y, float *z)
3054 {
3055  float los[2][3], find_dist[MAX_SURFS], closest;
3056  Point3 point, tmp, finds[MAX_SURFS];
3057  int surfs[MAX_SURFS], i, iclose, numhits = 0;
3058  geosurf *gs;
3059 
3060  /* returns surface-world coords */
3061  gsd_get_los(los, (short)sx, (short)sy);
3062 
3063  if (!gs_setlos_enterdata(los)) {
3064  G_debug(3, "gs_setlos_enterdata(los): returns false");
3065  return (0);
3066  }
3067 
3068  for (i = 0; i < Next_surf; i++) {
3069  G_debug(3, "id=%d", i);
3070 
3071  gs = gs_get_surf(Surf_ID[i]);
3072 
3073  /* los_intersect expects surf-world coords (xy transl, no scaling) */
3074 
3075 #if NVIZ_HACK
3076  if (gs_los_intersect1(Surf_ID[i], los, point)) {
3077 #else
3078  if (gs_los_intersect(Surf_ID[i], los, point)) {
3079 #endif
3080  if (!gs_point_is_masked(gs, point)) {
3081  GS_v3eq(tmp, point);
3082  tmp[X] += gs->x_trans;
3083  tmp[Y] += gs->y_trans;
3084  tmp[Z] += gs->z_trans;
3085  find_dist[numhits] = GS_distance(los[FROM], tmp);
3086  gsd_surf2real(gs, point);
3087  GS_v3eq(finds[numhits], point);
3088  surfs[numhits] = Surf_ID[i];
3089  numhits++;
3090  }
3091  }
3092  }
3093 
3094  for (i = iclose = 0; i < numhits; i++) {
3095  closest = find_dist[iclose];
3096 
3097  if (find_dist[i] < closest) {
3098  iclose = i;
3099  }
3100  }
3101 
3102  if (numhits) {
3103  *x = finds[iclose][X];
3104  *y = finds[iclose][Y];
3105  *z = finds[iclose][Z];
3106  *id = surfs[iclose];
3107  }
3108 
3109  G_debug(3, "NumHits %d, next %d", numhits, Next_surf);
3110 
3111  return (numhits);
3112 }
3113 
3120 void GS_set_cplane_rot(int num, float dx, float dy, float dz)
3121 {
3122  gsd_cplane_setrot(num, dx, dy, dz);
3123 
3124  return;
3125 }
3126 
3133 void GS_set_cplane_trans(int num, float dx, float dy, float dz)
3134 {
3135  gsd_cplane_settrans(num, dx, dy, dz);
3136 
3137  return;
3138 }
3139 
3140 
3147 {
3148  geosurf *gsurfs[MAX_SURFS];
3149  int nsurfs;
3150 
3151  nsurfs = gs_num_surfaces();
3152  if (2 == nsurfs) {
3153  /* testing */
3154  gs_getall_surfaces(gsurfs);
3155  gsd_draw_cplane_fence(gsurfs[0], gsurfs[1], num);
3156  }
3157  else {
3158  gsd_draw_cplane(num);
3159  }
3160 
3161  return;
3162 }
3163 
3173 int GS_draw_cplane_fence(int hs1, int hs2, int num)
3174 {
3175  geosurf *gs1, *gs2;
3176 
3177  if (NULL == (gs1 = gs_get_surf(hs1))) {
3178  return (0);
3179  }
3180 
3181  if (NULL == (gs2 = gs_get_surf(hs2))) {
3182  return (0);
3183  }
3184 
3185  gsd_draw_cplane_fence(gs1, gs2, num);
3186 
3187  return (1);
3188 }
3189 
3194 {
3195  int onstate[MAX_CPLANES], i;
3196 
3197  gsd_get_cplanes_state(onstate);
3198 
3199  for (i = 0; i < MAX_CPLANES; i++) {
3200  if (onstate[i]) {
3201  GS_draw_cplane_fence(Surf_ID[0], Surf_ID[1], i);
3202  }
3203  }
3204 
3205  return;
3206 }
3207 
3214 {
3215  gsd_cplane_on(num);
3216 
3217  return;
3218 }
3219 
3226 {
3227  gsd_cplane_off(num);
3228 
3229  return;
3230 }
3231 
3238 void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
3239 {
3240  float zexag;
3241 
3242  zexag = doexag ? Gv.vert_exag : 1.;
3243  *sx = *sy = Gv.scale;
3244  *sz = Gv.scale * zexag;
3245 
3246  return;
3247 }
3248 
3255 {
3256  gsd_setfc(mode);
3257 
3258  return;
3259 }
3260 
3267 {
3268  return gsd_getfc();
3269 }
3270 
3283 int GS_get_distance_alongsurf(int hs, float x1, float y1, float x2, float y2,
3284  float *dist, int use_exag)
3285 {
3286  geosurf *gs;
3287  float p1[2], p2[2];
3288 
3289  gs = gs_get_surf(hs);
3290  if (gs == NULL) {
3291  return 0;
3292  }
3293 
3294  p1[X] = x1;
3295  p1[Y] = y1;
3296  p2[X] = x2;
3297  p2[Y] = y2;
3298  gsd_real2surf(gs, p1);
3299  gsd_real2surf(gs, p2);
3300 
3301  G_debug(3, "GS_get_distance_alongsurf(): hs=%d p1=%f,%f p2=%f,%f",
3302  hs, x1, y1, x2, y2);
3303  return gs_distance_onsurf(gs, p1, p2, dist, use_exag);
3304 }
3305 
3314 int GS_save_3dview(const char *vname, int surfid)
3315 {
3316  return (Gs_save_3dview(vname, &Gv, &Gd, &wind, gs_get_surf(surfid)));
3317 }
3318 
3327 int GS_load_3dview(const char *vname, int surfid)
3328 {
3329 
3330  return (Gs_load_3dview(vname, &Gv, &Gd, &wind, gs_get_surf(surfid)));
3331 
3332  /* what to do about lights - I guess, delete all &
3333  create any that exist in 3dview file */
3334 }
3335 
3336 /************************************************************************
3337 * Following routines use Graphics Library
3338 ************************************************************************/
3339 
3345 void GS_init_view(void)
3346 {
3347  static int first = 1;
3348 
3349  G_debug(3, "GS_init_view");
3350 
3351  if (first) {
3352  first = 0;
3353  glMatrixMode(GL_MODELVIEW);
3354 
3355  /* OGLXXX doublebuffer: use GLX_DOUBLEBUFFER in attriblist */
3356  /* glxChooseVisual(*dpy, screen, *attriblist); */
3357  /* OGLXXX
3358  * ZMIN not needed -- always 0.
3359  * ZMAX not needed -- always 1.
3360  * getgdesc other posiblilties:
3361  * glxGetConfig();
3362  * glxGetCurrentContext();
3363  * glxGetCurrentDrawable();
3364  * GLint gdtmp;
3365  * getgdesc other posiblilties:
3366  * glxGetConfig();
3367  * glxGetCurrentContext();
3368  * glxGetCurrentDrawable();
3369  * GLint gdtmp;
3370  * glDepthRange params must be scaled to [0, 1]
3371  */
3372  glDepthRange(0.0, 1.0);
3373  glEnable(GL_DEPTH_TEST);
3374  glDepthFunc(GL_LEQUAL);
3375  /* } */
3376 
3377  /* replace these with something meaningful */
3378  Gv.fov = 450;
3379  Gv.twist = 0;
3380 
3381  GS_init_rotation();
3382 
3383  Gv.from_to[FROM][X] = Gv.from_to[FROM][Y] =
3384  Gv.from_to[FROM][Z] = GS_UNIT_SIZE / 2.;
3385 
3386  Gv.from_to[TO][X] = GS_UNIT_SIZE / 2.;
3387  Gv.from_to[TO][Y] = GS_UNIT_SIZE / 2.;
3388  Gv.from_to[TO][Z] = 0.;
3389  Gv.from_to[TO][W] = Gv.from_to[FROM][W] = 1.;
3390 
3391  Gv.real_to[W] = 1.;
3392  Gv.vert_exag = 1.;
3393 
3394  GS_v3eq(Gv.real_to, Gv.from_to[TO]);
3395  GS_v3normalize(Gv.from_to[FROM], Gv.from_to[TO]);
3396 
3397  /*
3398  Gd.nearclip = 50;
3399  Gd.farclip = 10000.;
3400  */
3401  Gd.nearclip = 10.;
3402  Gd.farclip = 10000.;
3403  Gd.aspect = (float)GS_get_aspect();
3404 
3405  GS_set_focus(Gv.real_to);
3406  }
3407 
3408  return;
3409 }
3410 
3416 void GS_clear(int col)
3417 {
3418  G_debug(3, "GS_clear");
3419 
3420  col = col | 0xFF000000;
3421 
3422  /* OGLXXX
3423  * change glClearDepth parameter to be in [0, 1]
3424  * ZMAX not needed -- always 1.
3425  * getgdesc other posiblilties:
3426  * glxGetConfig();
3427  * glxGetCurrentContext();
3428  * glxGetCurrentDrawable();
3429  * GLint gdtmp;
3430  */
3431  glClearDepth(1.0);
3432  glClearColor(((float)((col) & 0xff)) / 255.,
3433  (float)((col) >> 8 & 0xff) / 255.,
3434  (float)((col) >> 16 & 0xff) / 255.,
3435  (float)((col) >> 24 & 0xff) / 255.);
3436  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
3437 
3438  Gd.bgcol = col;
3439  Modelshowing = 0;
3440  gsd_flush();
3441 
3442  return;
3443 }
3444 
3450 double GS_get_aspect(void)
3451 {
3452  int left, right, bottom, top;
3453  GLint tmp[4];
3454 
3455  /* OGLXXX
3456  * get GL_VIEWPORT:
3457  * You can probably do better than this.
3458  */
3459  glGetIntegerv(GL_VIEWPORT, tmp);
3460  left = tmp[0];
3461  right = tmp[0] + tmp[2] - 1;
3462  bottom = tmp[1];
3463  top = tmp[1] + tmp[3] - 1;
3464 
3465  G_debug(3, "GS_get_aspect(): left=%d, right=%d, top=%d, bottom=%d",
3466  left, right, top, bottom);
3467 
3468  return ((double)(right - left) / (top - bottom));
3469 }
3470 
3479 {
3480  /* OGLXXX
3481  * getgdesc other posiblilties:
3482  * glxGetConfig();
3483  * glxGetCurrentContext();
3484  * glxGetCurrentDrawable();
3485  * GLint gdtmp;
3486  * blending is ALWAYS supported.
3487  * This function returns whether it is enabled.
3488  * return((glGetIntegerv(GL_BLEND, &gdtmp), gdtmp));
3489  */
3490 
3491  return (1);
3492 }
int GS_get_fencecolor(void)
Get fence color.
Definition: GS2.c:3266
void GS_set_exag(int id, float exag)
Set Z exag for surface.
Definition: GS2.c:1950
#define VXRES(gs)
Definition: rowcol.h:7
void gsd_zwritemask(unsigned long n)
Write out z-mask.
Definition: gsd_prim.c:231
void GS_setlight_ambient(int num, float red, float green, float blue)
Set light ambient.
Definition: GS2.c:402
void GS_set_fov(int fov)
Set field of view.
Definition: GS2.c:2841
void gsdiff_set_SDscale(float scale)
Set scale.
Definition: gsdiff.c:42
void GS_get_to_real(float *to)
Get &#39;to&#39; real coordinates.
Definition: GS2.c:2750
int Gs_build_256lookup(const char *filename, int *buff)
Build color table (256)
Definition: Gs3.c:627
void GS_set_trans(int id, float xtrans, float ytrans, float ztrans)
Set trans ?
Definition: GS2.c:2388
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void GS_zoom_setup(int *a, int *b, int *c, int *d, int *maxx, int *maxy)
Get zoom setup.
Definition: GS2.c:2770
int gs_init_surf(geosurf *gs, double ox, double oy, int rows, int cols, double xres, double yres)
Initialize allocated geosurf struct.
Definition: gs.c:232
int GS_transp_is_set(void)
Check if transparency is set.
Definition: GS2.c:492
void GS_getlight_position(int num, float *xpos, float *ypos, float *zpos, int *local)
Get light position.
Definition: GS2.c:335
int gs_los_intersect(int surfid, float **los, float *point)
Definition: gs_query.c:191
int GS_unset_att(int id, int att)
Unset attribute.
Definition: GS2.c:1390
int GS_get_nozero(int id, int att, int *mode)
Get no-zero ?
Definition: GS2.c:2161
void gs_delete_surf(int id)
Remove geosurf struct from list.
Definition: gs.c:463
int GS_get_light_reset(void)
Definition: GS2.c:258
void GS_unset_SDsurf(void)
Unset Scaled Difference surface.
Definition: GS2.c:1030
void gsd_calllist(int listno)
ADD.
Definition: gsd_prim.c:1154
int GS_get_distance_alongsurf(int hs, float x1, float y1, float x2, float y2, float *dist, int use_exag)
Measure distance &quot;as the ball rolls&quot; between two points on surface.
Definition: GS2.c:3283
float b
Definition: named_colr.c:8
void GS_set_global_exag(float exag)
Set global z-exag value.
Definition: GS2.c:1974
int Gs_save_3dview(const char *vname, geoview *gv, geodisplay *gd, struct Cell_head *w, geosurf *defsurf)
Save 3dview.
Definition: Gs3.c:906
int GS_v3normalize(float *v1, float *v2)
Change v2 so that v1v2 is a unit vector.
Definition: GS_util.c:322
#define DRC2OFF(gs, drow, dcol)
Definition: rowcol.h:15
void gsd_cplane_settrans(int num, float tx, float ty, float tz)
ADD.
Definition: gsd_cplane.c:229
int gsd_wire_surf(geosurf *surf)
Draw surface wire.
Definition: gsd_wire.c:47
void GS_get_modelposition1(float pos[])
Retrieves coordinates for lighting model position, at center of view.
Definition: GS2.c:502
struct triple * point
Definition: dataquad.c:294
void GS_init_rotation(void)
Reset scene rotation.
Definition: GS2.c:2907
float gsdiff_get_SDscale(void)
Get scale.
Definition: gsdiff.c:54
int gsds_findh(const char *name, IFLAG *changes, IFLAG *types, int begin)
Get handle to gsds.
Definition: gsds.c:188
int G_get_cellhd(const char *name, const char *mapset, struct Cell_head *cellhd)
Read the raster header.
Definition: get_cellhd.c:45
int G_get_set_window(struct Cell_head *window)
Get the current working window.
Definition: set_window.c:30
#define FALSE
Definition: dbfopen.c:117
int gs_get_datacenter(float *cen)
Get data center point.
Definition: gs.c:1232
void GS_get_from_real(float *fr)
Get viewpoint &#39;from&#39; real coordinates.
Definition: GS2.c:2737
int gs_get_data_avg_zmax(float *azmax)
Get average z-max value.
Definition: gs.c:1203
int GS_setall_drawmode(int mode)
Set all draw-modes.
Definition: GS2.c:2058
int in_vregion(geosurf *gs, float *pt)
ADD.
Definition: gsdrape.c:696
int GS_set_maskmode(int id, int mode)
Set mask mode.
Definition: GS2.c:1433
int GS_has_transparency(void)
Check for transparency.
Definition: GS2.c:3478
void GS_setlight_color(int num, float red, float green, float blue)
Set light color.
Definition: GS2.c:358
int GS_get_selected_point_on_surface(int sx, int sy, int *id, float *x, float *y, float *z)
Get selected point of surface.
Definition: GS2.c:3052
string name
Definition: render.py:1314
int gs_point_is_masked(geosurf *gs, float *pt)
Check if point is masked.
Definition: gs.c:1317
#define min(x, y)
Definition: draw2.c:68
void gsd_do_scale(int doexag)
Set current scale.
Definition: gsd_views.c:355
int GS_get_val_at_xy(int id, int att, char *valstr, float x, float y)
Get RGB color at given point.
Definition: GS2.c:1307
void gsd_cplane_off(int num)
Turn off clip plane.
Definition: gsd_cplane.c:126
int GS_draw_legend(const char *name, GLuint fontbase, int size, int *flags, float *range, int *pt)
Draw legend.
Definition: GS2.c:845
int GS_update_curmask(int id)
Update current mask.
Definition: GS2.c:994
int GS_v3norm(float *v1)
Change v1 so that it is a unit vector (2D)
Definition: GS_util.c:246
float r
Definition: named_colr.c:8
int GS_surf_exists(int id)
Definition: GS2.c:194
void GS_set_focus(float *realto)
Set focus.
Definition: GS2.c:2518
void GS_done_draw(void)
Draw done, swap buffers.
Definition: GS2.c:2499
void gpd_obj(geosurf *gs, int color, float size, int marker, Point3 pt)
ADD.
Definition: gpd.c:202
void GS_get_from(float *fr)
Get viewpoint &#39;from&#39; position.
Definition: GS2.c:2723
void GS_v3add(float *v1, float *v2)
Sum vectors.
Definition: GS_util.c:195
int GS_get_twist(void)
Get twist value.
Definition: GS2.c:2863
int gs_malloc_att_buff(geosurf *gs, int desc, int type)
Allocate attribute buffer.
Definition: gs.c:717
long num
Definition: g3dcats.c:93
#define Y(x)
Definition: display/draw.c:246
void GS_v3sub(float *v1, float *v2)
Subtract vectors.
Definition: GS_util.c:212
tuple pos
Definition: tools.py:1367
int GS_new_surface(void)
Add new surface.
Definition: GS2.c:224
int GS_v3dir(float *v1, float *v2, float *v3)
Get a normalized direction from v1 to v2, store in v3.
Definition: GS_util.c:353
int gs_calc_normals(geosurf *gs)
Calculate normals.
Definition: gs_norms.c:124
void gsd_colormode(int cm)
Set color mode.
Definition: gsd_prim.c:88
int gsd_getfc(void)
ADD.
Definition: gsd_surf.c:1220
void GS_switchlight(int num, int on)
Switch on/off light.
Definition: GS2.c:473
int gvl_get_zrange(float *min, float *max)
Get volume z-range value.
Definition: gvl.c:475
void gsd_surf2real(geosurf *gs, Point3 point)
Convert surface to real coordinates.
Definition: gsd_views.c:464
#define INT_TO_RED(i, r)
Definition: gsd_prim.c:43
#define X(y)
Definition: display/draw.c:248
int Gs_loadmap_as_bitmap(struct Cell_head *wind, const char *map_name, struct BM *buff)
Load raster map as integer map.
Definition: Gs3.c:559
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.
Definition: Gs3.c:449
void gsd_color_func(unsigned int col)
Set current color.
Definition: gsd_prim.c:689
void GS_delete_list(GLuint list_id)
Delete pre-defined list.
Definition: GS2.c:888
void gsd_get_cplanes_state(int *onstate)
Get cplane state.
Definition: gsd_cplane.c:142
int gs_att_is_set(geosurf *surf, IFLAG att)
Check if attribute is set.
Definition: gs.c:149
void GS_set_rotation(double angle, double x, double y, double z)
Set rotation params.
Definition: GS2.c:2885
int y
Definition: plot.c:34
int GS_get_cat_at_xy(int id, int att, char *catstr, float x, float y)
Get surface category on given position.
Definition: GS2.c:1180
int GS_set_SDsurf(int id)
Set surface as Scaled Difference surface.
Definition: GS2.c:1046
#define max(x, y)
Definition: draw2.c:69
int GS_set_SDscale(float scale)
Set ?
Definition: GS2.c:1067
void GS_set_viewport(int left, int right, int bottom, int top)
Set viewport.
Definition: GS2.c:2979
void gs_set_defaults(geosurf *gs, float *defs, float *null_defs)
Set default attribute values.
Definition: gs.c:441
void gs_init(void)
Initialize library.
Definition: gs.c:47
void GS_get_rotation_matrix(double *matrix)
Get rotation matrix.
Definition: GS2.c:2927
int GS_get_region(float *n, float *s, float *w, float *e)
Get 2D region extent.
Definition: GS2.c:156
void GS_clear(int col)
Clear view.
Definition: GS2.c:3416
int GS_get_SDscale(float *scale)
Get ?
Definition: GS2.c:1102
void gsd_translate(float dx, float dy, float dz)
Multiply the current matrix by a translation matrix.
Definition: gsd_prim.c:526
void gsd_shademodel(int bool)
Set shaded model.
Definition: gsd_prim.c:409
int Gs_update_attrange(geosurf *gs, int desc)
Update no_zero ranges for attribute (actually no_null now)
Definition: Gs3.c:1140
void GS_getlight_color(int num, float *red, float *green, float *blue)
Get light color.
Definition: GS2.c:380
int GS_get_wire_color(int id, int *colr)
Get wire color.
Definition: GS2.c:2035
void GS_set_att_defaults(float *defs, float *null_defs)
Set default attributes for map objects.
Definition: GS2.c:172
int gs_set_att_type(geosurf *gs, int desc, int type)
Set attribute type.
Definition: gs.c:803
int GS_set_drawmode(int id, int mode)
Set draw mode.
Definition: GS2.c:2080
#define VYRES(gs)
Definition: rowcol.h:8
unsigned int GS_background_color(void)
Get background color.
Definition: GS2.c:2447
void GS_get_drawres(int id, int *xres, int *yres, int *xwire, int *ywire)
Get draw resolution of surface.
Definition: GS2.c:2252
int GS_setall_drawres(int xres, int yres, int xwire, int ywire)
Set all draw resolutions.
Definition: GS2.c:2195
tuple size
value.Bind(wx.EVT_TEXT, self.OnVolumeIsosurfMap)
Definition: tools.py:2334
void gsd_real2surf(geosurf *gs, Point3 point)
Convert real to surface coordinates.
Definition: gsd_views.c:480
void gsd_real2model(Point3 point)
Convert real to model coordinates.
Definition: gsd_views.c:373
void GS_draw_fringe(int id, unsigned long clr, float elev, int *where)
Draw fringe around data (surface) at selected corners.
Definition: GS2.c:820
geosurf * gsdiff_get_SDref(void)
ADD.
Definition: gsdiff.c:77
int GS_get_zrange(float *min, float *max, int doexag)
Get z-extent for all loaded surfaces.
Definition: GS2.c:2687
int GS_draw_cplane_fence(int hs1, int hs2, int num)
Draw cplace fence ?
Definition: GS2.c:3173
char buff[1024]
Definition: g3dcats.c:89
void gsd_pushmatrix(void)
Push the current matrix stack.
Definition: gsd_prim.c:498
void Gs_pack_colors_float(const char *filename, float *fbuf, int *ibuf, int rows, int cols)
Pack color table (floating-point map)
Definition: Gs3.c:756
#define INT_TO_GRN(i, g)
Definition: gsd_prim.c:44
void GS_init_view(void)
Init viewpoint.
Definition: GS2.c:3345
void GS_set_cplane_trans(int num, float dx, float dy, float dz)
Set cplace trans.
Definition: GS2.c:3133
void GS_set_cplane_rot(int num, float dx, float dy, float dz)
Set cplace rotation.
Definition: GS2.c:3120
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.
Definition: Gs3.c:189
void GS_set_focus_real(float *realto)
Set real focus.
Definition: GS2.c:2536
int GS_v2norm(float *v1)
Change v1 so that it is a unit vector (3D)
Definition: GS_util.c:271
void GS_set_fencecolor(int mode)
Set fence color.
Definition: GS2.c:3254
void GS_set_wire_color(int id, int colr)
Set wire color.
Definition: GS2.c:2011
double GS_get_aspect(void)
Get aspect value.
Definition: GS2.c:3450
void gsd_backface(int n)
ADD.
Definition: gsd_prim.c:244
void GS_draw_all_list(void)
Draw all glLists.
Definition: GS2.c:876
void GS_set_focus_center_map(int id)
Set focus to map center.
Definition: GS2.c:2580
int gsd_surf(geosurf *surf)
ADD.
Definition: gsd_surf.c:81
char * gsds_get_name(int id)
Get name.
Definition: gsds.c:303
void GS_v3mult(float *v1, float k)
Multiple vectors.
Definition: GS_util.c:229
void gv_update_drapesurfs(void)
Update drape surfaces.
Definition: gv.c:150
typbuff * gs_get_att_typbuff(geosurf *gs, int desc, int to_write)
Get attribute data buffer.
Definition: gs.c:681
void GS_set_Narrow(int *pt, int id, float *pos2)
Set decoration, north arrow ??
Definition: GS2.c:568
tuple id
self.OnVectorSurface(event)
Definition: tools.py:3426
int GS_get_drawmode(int id, int *mode)
Get draw mode.
Definition: GS2.c:2106
int GS_save_3dview(const char *vname, int surfid)
Save 3d view.
Definition: GS2.c:3314
char * G_find_cell2(const char *name, const char *mapset)
find a raster map (look but don&#39;t touch)
Definition: find_cell.c:83
void GS_unset_cplane(int num)
Unset clip place (turn off)
Definition: GS2.c:3225
void gsd_backbuffer(int bool)
Specify which color buffers are to be drawn into.
Definition: gsd_prim.c:464
int Gs_get_cat_label(const char *filename, int drow, int dcol, char *catstr)
Get categories/labels.
Definition: Gs3.c:827
int gsds_free_data_buff(int id, int typ)
Free allocated buffer.
Definition: gsds.c:369
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.
Definition: Gs3.c:114
#define Y2VROW(gs, py)
Definition: rowcol.h:25
#define X2VCOL(gs, px)
Definition: rowcol.h:26
#define TRUE
Definition: dbfopen.c:118
int gs_setlos_enterdata(Point3 *los)
Definition: gs_query.c:529
void Gs_pack_colors(const char *filename, int *buff, int rows, int cols)
Pack color table.
Definition: Gs3.c:687
int gs_num_surfaces(void)
Get number of surfaces.
Definition: gs.c:127
void GS_set_viewdir(float *dir)
Set viewdir.
Definition: GS2.c:2821
void gsd_switchlight(int num, int on)
Switch light on/off.
Definition: gsd_prim.c:868
void GS_set_infocus(void)
Set focus.
Definition: GS2.c:2965
void GS_set_nofocus(void)
Unset focus.
Definition: GS2.c:2951
int gs_los_intersect1(int surfid, float(*los)[3], float *point)
Definition: gs_query.c:52
int GS_set_att_const(int id, int att, float constant)
Set attribute constant.
Definition: GS2.c:1409
void GS_alldraw_surf(void)
Draw all surfaces.
Definition: GS2.c:1933
#define INT_TO_BLU(i, b)
Definition: gsd_prim.c:45
void GS_set_light_reset(int i)
Definition: GS2.c:252
void gsd_deletelist(GLuint listno, int range)
Delete list.
Definition: gsd_prim.c:1134
void gsd_set_view(geoview *gv, geodisplay *gd)
Set view.
Definition: gsd_views.c:146
int gs_set_att_const(geosurf *gs, int desc, float constant)
Set attribute constant value.
Definition: gs.c:872
float g
Definition: named_colr.c:8
void GS_moveto(float *pt)
Move viewpoint.
Definition: GS2.c:2615
int GS_set_drawres(int id, int xres, int yres, int xwire, int ywire)
Set draw resolution for surface.
Definition: GS2.c:2218
int gs_getall_surfaces(geosurf **gsurfs)
Get array of geosurf structs.
Definition: gs.c:108
int
Definition: g3dcolor.c:48
void GS_get_dims(int id, int *rows, int *cols)
Get dimension of surface.
Definition: GS2.c:2276
void gsd_swapbuffers(void)
Swap buffers.
Definition: gsd_prim.c:474
int GS_update_normals(int id)
Update normals.
Definition: GS2.c:1116
void GS_get_zrange_nz(float *min, float *max)
Get Z extents for all loaded surfaces.
Definition: GS2.c:2354
void GS_set_rotation_matrix(double *matrix)
Set rotation matrix.
Definition: GS2.c:2939
int Gs_load_3dview(const char *vname, geoview *gv, geodisplay *gd, struct Cell_head *w, geosurf *defsurf)
Load 3dview.
Definition: Gs3.c:1004
void GS_set_cplane(int num)
Set cplace.
Definition: GS2.c:3213
void GS_draw_X(int id, float *pt)
ADD.
Definition: GS2.c:637
void gsd_draw_cplane_fence(geosurf *surf1, geosurf *surf2, int cpnum)
ADD.
Definition: gsd_cplane.c:247
int gsd_nline_onsurf(geosurf *gs, float *v1, float *v2, float *pt, int n)
Multiline on surface, fix z-values.
Definition: gsd_objs.c:236
int GS_get_focus(float *realto)
Get focus.
Definition: GS2.c:2561
void gsd_model2real(Point3 point)
Convert model to real coordinates.
Definition: gsd_views.c:393
void GS_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
Get trans ?
Definition: GS2.c:2411
void GS_getlight_ambient(int num, float *red, float *green, float *blue)
Get light ambient.
Definition: GS2.c:424
int first
Definition: form/open.c:25
void gsd_frontbuffer(int bool)
Specify which color buffers are to be drawn into.
Definition: gsd_prim.c:450
void GS_alldraw_wire(void)
Draw all wires.
Definition: GS2.c:1916
int gs_get_zextents(geosurf *gs, float *min, float *max, float *mid)
Get z-extent values.
Definition: gs.c:998
void gsdiff_set_SDref(geosurf *gsref)
ADD.
Definition: gsdiff.c:64
int gs_set_att_src(geosurf *gs, int desc, int src)
Set attribute source.
Definition: gs.c:827
void gsd_viewport(int l, int r, int b, int t)
Set the viewport.
Definition: gsd_prim.c:1057
void GS_unset_rotation(void)
Stop scene rotation.
Definition: GS2.c:2899
int Gs_numtype(const char *filename, int *negflag)
Get map data type.
Definition: Gs3.c:252
int _viewcell_tri_interp(geosurf *gs, Point3 pt)
ADD.
Definition: gsdrape.c:467
void gsd_cplane_setrot(int num, float rx, float ry, float rz)
ADD.
Definition: gsd_cplane.c:211
void gsd_line_onsurf(geosurf *gs, float *v1, float *v2)
Line on surface, fix z-values.
Definition: gsd_objs.c:190
void GS_lights_on(void)
Switch on all lights.
Definition: GS2.c:456
int GS_get_SDsurf(int *id)
Get ?
Definition: GS2.c:1082
void gsd_setfc(int mode)
ADD.
Definition: gsd_surf.c:1208
int gs_malloc_lookup(geosurf *gs, int desc)
Allocate attribute lookup.
Definition: gs.c:746
GLuint gsd_put_legend(const char *name, GLuint fontbase, int size, int *flags, float *rangef, int *pt)
Put legend.
Definition: gsd_legend.c:201
int GS_get_norm_at_xy(int id, float x, float y, float *nv)
Get surface normal at x,y (real coordinates)
Definition: GS2.c:1243
void void_func(void)
Definition: GS2.c:84
void gsd_init_lightmodel(void)
Initialize model light.
Definition: gsd_prim.c:710
int GS_num_surfs(void)
Get number of surfaces.
Definition: GS2.c:1521
geosurf * gs_get_surf(int id)
Get geosurf struct.
Definition: gs.c:62
void GS_set_twist(int t)
Set viewpoint twist value.
Definition: GS2.c:2875
return NULL
Definition: dbfopen.c:1394
int GS_draw_nline_onsurf(int id, float x1, float y1, float x2, float y2, float *lasp, int n)
Draw multiline on surface.
Definition: GS2.c:715
void GS_v3eq(float *v1, float *v2)
Copy vector values.
Definition: GS_util.c:178
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
void(* Cxl_func)()
Definition: GSX.c:21
tuple cols
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...
Definition: GS2.c:3003
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: gis/debug.c:51
void GS_get_viewdir(float *dir)
Get viewdir.
Definition: GS2.c:2807
int gs_get_att_src(geosurf *gs, int desc)
Get attribute source.
Definition: gs.c:656
void gsd_linewidth(short n)
Set width of rasterized lines.
Definition: gsd_prim.c:257
int GS_new_light(void)
Add new model light.
Definition: GS2.c:268
int GS_Set_ClientData(int id, void *clientd)
Set client data.
Definition: GS2.c:1482
#define VCOL2DCOL(gs, vcol)
Definition: rowcol.h:30
void(* Swap_func)()
Definition: GSX.c:22
void free(void *)
int GS_get_zextents(int id, float *min, float *max, float *mid)
Get z-extent for a single surface.
Definition: GS2.c:2664
void gsd_flush(void)
Mostly for flushing drawing commands accross a network.
Definition: gsd_prim.c:74
void GS_set_nozero(int id, int att, int mode)
Set no-zero ?
Definition: GS2.c:2128
void GS_draw_cplane(int num)
Draw cplace.
Definition: GS2.c:3146
char * G_fully_qualified_name(const char *name, const char *mapset)
fully qualified file name
Definition: nme_in_mps.c:118
int gsd_getViewport(GLint *, GLint *)
void gsd_popmatrix(void)
Pop the current matrix stack.
Definition: gsd_prim.c:488
int GS_get_longdim(float *dim)
Get largest dimension.
Definition: GS2.c:140
#define FNORM(i, nv)
Definition: gsget.h:50
int GS_coordpair_repeats(float *p1, float *p2, int nhist)
ADD.
Definition: GS_util.c:443
int gs_init_normbuff(geosurf *gs)
Init geosurf normbuff.
Definition: gs.c:306
int * GS_get_surf_list(int *numsurfs)
Get surface list.
Definition: GS2.c:1536
float GS_distance(float *from, float *to)
Calculate distance.
Definition: GS_util.c:141
geosurf * gs_get_new_surface(void)
Allocate new geosurf struct.
Definition: gs.c:193
#define FROM
Definition: y.tab.c:161
int GS_load_3dview(const char *vname, int surfid)
Load 3d view.
Definition: GS2.c:3327
void gsd_display_fringe(geosurf *surf, unsigned long clr, float elev, int where[4])
Display fridge.
Definition: gsd_fringe.c:51
void GS_libinit(void)
Initialize OGSF library.
Definition: GS2.c:96
void GS_draw_surf(int id)
Draw surface.
Definition: GS2.c:1861
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int gs_mapcolor(typbuff *cobuff, gsurf_att *coloratt, int offset)
Call this one when you already know att_src is MAP_ATT.
Definition: gs.c:969
void GS_get_modelposition(float *siz, float *pos)
Retrieves coordinates for lighting model position, at center of view.
Definition: GS2.c:531
void gsd_cplane_on(int num)
ADD.
Definition: gsd_cplane.c:104
tuple range
Definition: tools.py:1406
int GS_is_masked(int id, float *pt)
Check if point is masked ?
Definition: GS2.c:1012
void GS_ready_draw(void)
Definition: GS2.c:2486
#define VROW2DROW(gs, vrow)
Definition: rowcol.h:29
int GS_get_att(int id, int att, int *set, float *constant, char *mapname)
Get attributes.
Definition: GS2.c:1137
unsigned int GS_default_draw_color(void)
Get default draw color.
Definition: GS2.c:2434
void gsd_deflight(int num, struct lightdefs *vals)
Define light.
Definition: gsd_prim.c:827
int GS_load_att_map(int id, const char *filename, int att)
Load raster map as attribute.
Definition: GS2.c:1605
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.
Definition: Gs3.c:334
int gsds_newh(const char *name)
Get handle to gsds.
Definition: gsds.c:219
void GS_moveto_real(float *pt)
Move position to (real)
Definition: GS2.c:2645
int gsds_set_changed(int id, IFLAG reason)
ADD.
Definition: gsds.c:634
void gsd_scale(float xs, float ys, float zs)
Multiply the current matrix by a general scaling matrix.
Definition: gsd_prim.c:512
int gs_get_zrange(float *min, float *max)
Get z-range.
Definition: gs.c:1088
int gs_distance_onsurf(geosurf *gs, float *p1, float *p2, float *dist, int use_exag)
Calculate distance on surface.
Definition: gs.c:1417
void GS_draw_wire(int id)
Draw surface wire.
Definition: GS2.c:1896
int GS_delete_surface(int id)
Delete surface.
Definition: GS2.c:1563
int GS_get_maskmode(int id, int *mode)
Get mask mode.
Definition: GS2.c:1458
int n
Definition: dataquad.c:291
void * GS_Get_ClientData(int id)
Get client data.
Definition: GS2.c:1504
void gsd_calllists(int listno)
ADD.
Definition: gsd_prim.c:1167
int gsd_get_los(float(*vect)[3], short sx, short sy)
ADD.
Definition: gsd_views.c:40
void GS_draw_flowline_at_xy(int id, float x, float y)
Draw flow-line on surace.
Definition: GS2.c:753
float GS_global_exag(void)
Get global z-exag value.
Definition: GS2.c:1996
void GS_get_to(float *to)
Get &#39;to&#39; model coordinates.
Definition: GS2.c:2793
int GS_get_fov(void)
Get fied of view.
Definition: GS2.c:2853
int GS_get_exag_guess(int id, float *exag)
Get exag-value guess.
Definition: GS2.c:2303
string set
void GS_set_draw(int where)
Sets which buffer to draw to.
Definition: GS2.c:2457
int gs_update_curmask(geosurf *surf)
Update current maps.
Definition: gs_bm.c:232
void GS_draw_lighting_model1(void)
Draw lighting model.
Definition: GS2.c:898
void GS_setlight_position(int num, float xpos, float ypos, float zpos, int local)
Set light position.
Definition: GS2.c:309
void gsd_drawsphere(float *center, unsigned long colr, float siz)
Draw sphere.
Definition: gsd_objs.c:566
void GS_alldraw_cplane_fences(void)
Draw all cplace fences ?
Definition: GS2.c:3193
void GS_draw_line_onsurf(int id, float x1, float y1, float x2, float y2)
Draw line on surface.
Definition: GS2.c:676
void GS_draw_lighting_model(void)
Draw lighting model.
Definition: GS2.c:938
void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
Get axis scale.
Definition: GS2.c:3238
tuple mode
Definition: tools.py:1481
void gsd_draw_cplane(int num)
Draw cplane.
Definition: gsd_cplane.c:296
void GS_lights_off(void)
Switch off all lights.
Definition: GS2.c:442
#define GET_MAPATT(buff, offset, att)
Definition: gsget.h:27
void GS_draw_list(GLuint list_id)
Draw pre-defined list.
Definition: GS2.c:863