GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71817
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gs2.c
Go to the documentation of this file.
1 /*!
2  \file lib/ogsf/gs2.c
3 
4  \brief OGSF library - loading and manipulating surfaces (higher level functions)
5 
6  GRASS OpenGL gsurf OGSF Library
7 
8  Plans for handling color maps:
9  NOW:
10  if able to load as unsigned char, make lookup table containing palette
11  otherwise, load directly as packed color, set lookup = NULL
12  MAYBE LATER:
13  if able to load as POSITIVE short, make lookup table containing palette
14  - may want to calculate savings first (ie, numcells > 32768)
15  (not exactly, it's Friday & time to go home - figure it later)
16  otherwise, load directly as packed color, set lookup = NULL
17  MESSY! - need to fix up!
18 
19  (C) 1999-2008 by the GRASS Development Team
20 
21  This program is free software under the
22  GNU General Public License (>=v2).
23  Read the file COPYING that comes with GRASS
24  for details.
25 
26  \author Bill Brown USACERL (1993)
27  \author Pierre de Mouveaux <p_de_mouveaux hotmail.com> (updated October 1999)
28  \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
29  */
30 
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/raster.h>
47 #include <grass/ogsf.h>
48 #include <grass/glocale.h>
49 
50 #include "gsget.h"
51 #include "rowcol.h"
52 #include "rgbpack.h"
53 
54 /* Hack to make NVIZ2.2 query functions.("What's Here" and "Look at")
55  * to work.
56  * Uses gs_los_intersect1() instead of gs_los_intersect().
57  * Pierre de Mouveaux - 31 oct. 1999. p_de_mouveaux@hotmail.com.
58  */
59 #define NVIZ_HACK 1
60 
61 int gsd_getViewport(GLint *, GLint *);
62 
63 /* array of surface ids */
64 static int Surf_ID[MAX_SURFS];
65 static int Next_surf = 0;
66 static int SDref_surf = 0;
67 
68 /* attributes array */
69 static float Default_const[MAX_ATTS];
70 static float Default_nulls[MAX_ATTS];
71 
72 /* largest dimension */
73 static float Longdim;
74 
75 /* N, S, W, E */
76 static float Region[4];
77 static geoview Gv;
78 static geodisplay Gd;
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;
84 
85 void void_func(void)
86 {
87  return;
88 }
89 
90 /*!
91  \brief Initialize OGSF library
92 
93  Get region settings - wind
94 
95  Set Region (NSWE array) and compute scale
96  */
97 void GS_libinit(void)
98 {
99  static int first = 1;
100 
101  G_get_set_window(&wind);
102 
103  Region[0] = wind.north;
104  Region[1] = wind.south;
105  Region[2] = wind.west;
106  Region[3] = wind.east;
107 
108  /* scale largest dimension to GS_UNIT_SIZE */
109  if ((wind.east - wind.west) > (wind.north - wind.south)) {
110  Longdim = (wind.east - wind.west);
111  }
112  else {
113  Longdim = (wind.north - wind.south);
114  }
115 
116  Gv.scale = GS_UNIT_SIZE / Longdim;
117 
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);
120 
123 
124 
125  if (first) {
126  gs_init();
127  }
128 
129  first = 0;
130 
131  return;
132 }
133 
134 /*!
135  \brief Get largest dimension
136 
137  \param[out] dim dimension
138 
139  \return 1
140  */
141 int GS_get_longdim(float *dim)
142 {
143  *dim = Longdim;
144 
145  G_debug(3, "GS_get_longdim(): dim=%g", *dim);
146 
147  return (1);
148 }
149 
150 /*!
151  \brief Get 2D region extent
152 
153  \param[out] n,s,w,e extent values
154 
155  \return 1
156  */
157 int GS_get_region(float *n, float *s, float *w, float *e)
158 {
159  *n = Region[0];
160  *s = Region[1];
161  *w = Region[2];
162  *e = Region[3];
163 
164  return (1);
165 }
166 
167 /*!
168  \brief Set default attributes for map objects
169 
170  \param defs attributes array (dim MAX_ATTS)
171  \param null_defs null attributes array (dim MAX_ATTS)
172  */
173 void GS_set_att_defaults(float *defs, float *null_defs)
174 {
175  int i;
176 
177  G_debug(3, "GS_set_att_defaults");
178 
179  for (i = 0; i < MAX_ATTS; i++) {
180  Default_const[i] = defs[i];
181  Default_nulls[i] = null_defs[i];
182  }
183 
184  return;
185 }
186 
187 /*!
188  Check if surface exists
189 
190  \param id surface id
191 
192  \return 0 not found
193  \return 1 found
194  */
195 int GS_surf_exists(int id)
196 {
197  int i, found = 0;
198 
199  G_debug(3, "GS_surf_exists(): id=%d", id);
200 
201 
202  if (NULL == gs_get_surf(id)) {
203  return (0);
204  }
205 
206  for (i = 0; i < Next_surf && !found; i++) {
207  if (Surf_ID[i] == id) {
208  found = 1;
209  }
210  }
211 
212  return (found);
213 }
214 
215 /*!
216  \brief Add new surface
217 
218  Note that origin has 1/2 cell added to represent center of cells
219  because library assumes that east - west = (cols - 1) * ew_res,
220  since left and right columns are on the edges.
221 
222  \return surface id
223  \return -1 on error (MAX_SURFS exceded)
224  */
225 int GS_new_surface(void)
226 {
227  geosurf *ns;
228 
229  G_debug(3, "GS_new_surface():");
230 
231  if (Next_surf < MAX_SURFS) {
232  ns = gs_get_new_surface();
233  gs_init_surf(ns, wind.west + wind.ew_res / 2.,
234  wind.south + wind.ns_res / 2., wind.rows, wind.cols,
235  wind.ew_res, wind.ns_res);
236  gs_set_defaults(ns, Default_const, Default_nulls);
237 
238  /* make default shine current */
240 
241  Surf_ID[Next_surf] = ns->gsurf_id;
242  ++Next_surf;
243 
244  G_debug(3, " id=%d", ns->gsurf_id);
245 
246  return (ns->gsurf_id);
247  }
248 
249 
250 
251  return (-1);
252 }
254 {
255  Resetlight = i;
256  if (i)
257  Numlights = 0;
258 }
260 {
261  return Resetlight;
262 }
263 /*!
264  \brief Add new model light
265 
266  \return light model id
267  \return -1 on error (MAX_LIGHTS exceded)
268  */
269 int GS_new_light(void)
270 {
271  int i;
272 
273  if (GS_get_light_reset()) {
274 
276 
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; /* infinite */
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;
286  }
287 
289  }
290 
291  if (Numlights < MAX_LIGHTS) {
292  gsd_deflight(Numlights + 1, &(Gv.lights[Numlights]));
293  gsd_switchlight(Numlights + 1, 1);
294 
295  return ++Numlights;
296  }
297 
298  return -1;
299 }
300 
301 /*!
302  \brief Set light position
303 
304  \bug I think lights array doesnt match sgi_light array
305 
306  \param num light id (starts with 1)
307  \param xpos,ypos,zpos coordinates (model)
308  \param local local coordinate (for viewport)
309  */
310 void GS_setlight_position(int num, float xpos, float ypos, float zpos,
311  int local)
312 {
313  if (num) {
314  num -= 1;
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;
320 
321  gsd_deflight(num + 1, &(Gv.lights[num]));
322  }
323  }
324 
325  return;
326 }
327 
328 
329 /*!
330  \brief Get light position
331 
332  \param num light id (starts at 1)
333  \param[out] xpos,ypos,zpos coordinates
334  \param[out] local ?
335  */
336 void GS_getlight_position(int num, float *xpos, float *ypos, float *zpos,
337  int *local)
338 {
339  if (num) {
340  num -= 1;
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];
346 
347  }
348  }
349 
350  return;
351 }
352 
353 /*!
354  \brief Set light color
355 
356  \param num light id (starts at 1)
357  \param red,green,blue color values (from 0.0 to 1.0)
358  */
359 void GS_setlight_color(int num, float red, float green, float blue)
360 {
361  if (num) {
362  num -= 1;
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;
367 
368  gsd_deflight(num + 1, &(Gv.lights[num]));
369  }
370  }
371 
372  return;
373 }
374 
375 /*!
376  \brief Get light color
377 
378  \param num light id (starts at 1)
379  \param[out] red,green,blue color values
380  */
381 void GS_getlight_color(int num, float *red, float *green, float *blue)
382 {
383  if (num) {
384  num -= 1;
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];
389  }
390  }
391 
392  return;
393 }
394 
395 /*!
396  \brief Set light ambient
397 
398  Red, green, blue from 0.0 to 1.0
399 
400  \param num light id (starts at 1)
401  \param red,green,blue color values
402  */
403 void GS_setlight_ambient(int num, float red, float green, float blue)
404 {
405  if (num) {
406  num -= 1;
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;
411 
412  gsd_deflight(num + 1, &(Gv.lights[num]));
413  }
414  }
415 
416  return;
417 }
418 
419 /*!
420  \brief Get light ambient
421 
422  \param num light id (starts at 1)
423  \param[out] red,green,blue color values
424  */
425 void GS_getlight_ambient(int num, float *red, float *green, float *blue)
426 {
427  if (num) {
428  num -= 1;
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];
433  }
434  }
435 
436  return;
437 }
438 
439 
440 /*!
441  \brief Switch off all lights
442  */
443 void GS_lights_off(void)
444 {
445  int i;
446 
447  for (i = 0; i < Numlights; i++) {
448  gsd_switchlight(i + 1, 0);
449  }
450 
451  return;
452 }
453 
454 /*!
455  \brief Switch on all lights
456  */
457 void GS_lights_on(void)
458 {
459  int i;
460 
461  for (i = 0; i < Numlights; i++) {
462  gsd_switchlight(i + 1, 1);
463  }
464 
465  return;
466 }
467 
468 /*!
469  \brief Switch on/off light
470 
471  \param num light id (starts at 1)
472  \param on non-zero for 'on' otherwise 'off'
473  */
474 void GS_switchlight(int num, int on)
475 {
476  if (num) {
477  num -= 1;
478 
479  if (num < Numlights) {
480  gsd_switchlight(num + 1, on);
481  }
482  }
483 
484  return;
485 }
486 
487 /*!
488  \brief Check if transparency is set
489 
490  \return 0 transparency not set
491  \return 1 transparency is set
492  */
494 {
495  return (gs_att_is_set(NULL, ATT_TRANSP) || (FC_GREY == gsd_getfc()));
496 }
497 
498 /*!
499  \brief Retrieves coordinates for lighting model position, at center of view
500 
501  \param pos[out] coordinates
502  */
503 void GS_get_modelposition1(float pos[])
504 {
505  /* TODO: Still needs work to handle other cases */
506  /* this is a quick hack to get lighting adjustments debugged */
507  /*
508  GS_v3dir(Gv.from_to[FROM], Gv.from_to[TO], center);
509  GS_v3mult(center, 1000);
510  GS_v3add(center, Gv.from_to[FROM]);
511  */
512 
513  gs_get_datacenter(pos);
514  gs_get_data_avg_zmax(&(pos[Z]));
515 
516  G_debug(1, "GS_get_modelposition1(): model position: %f %f %f",
517  pos[X], pos[Y], pos[Z]);
518 
519  return;
520 }
521 
522 /*!
523  \brief Retrieves coordinates for lighting model position, at center of view
524 
525  Position at nearclip * 2: tried nearclip + siz, but since need to
526  know position to calculate size, have two dependent variables
527  (nearclip * 2) from eye.
528 
529  \param siz[out] size
530  \param pos[out] coordinates (X, Y, Z)
531  */
532 void GS_get_modelposition(float *siz, float *pos)
533 {
534  float dist, near_h, dir[3];
535 
536  dist = 2. * Gd.nearclip;
537 
538  near_h = 2.0 * tan(4.0 * atan(1.) * Gv.fov / 3600.) * dist;
539  *siz = near_h / 8.0;
540 
541  /* prevent clipping - would only happen if fov > ~127 degrees, at
542  fov = 2.0 * atan(2.0) */
543 
544  if (*siz > Gd.nearclip) {
545  *siz = Gd.nearclip;
546  }
547 
548  GS_v3dir(Gv.from_to[FROM], Gv.from_to[TO], dir);
549 
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;
553 
554  return;
555 }
556 
557 
558 /*!
559  \brief Set decoration, north arrow ??
560 
561  \todo scale used to calculate len of arrow still needs work
562  needs go function that returns center / eye distance
563  gsd_get_los function is not working correctly ??
564 
565  \param pt point value in true world coordinates (?)
566  \param id surface id
567  \param[out] pos2 output coordinates
568  */
569 void GS_set_Narrow(int *pt, int id, float *pos2)
570 {
571  geosurf *gs;
572  float x, y, z;
573  GLdouble modelMatrix[16], projMatrix[16];
574  GLint viewport[4];
575 
576  if (GS_get_selected_point_on_surface(pt[X], pt[Y], &id, &x, &y, &z)) {
577  gs = gs_get_surf(id);
578  if (gs) {
579  z = gs->zmax;
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;
583 
584  return;
585  }
586  }
587  else {
588  gs = gs_get_surf(id);
589 
590  /* Need to get model matrix, etc
591  * to run gluUnProject
592  */
593  gsd_pushmatrix();
594  gsd_do_scale(1);
595  glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
596  glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
597  glGetIntegerv(GL_VIEWPORT, viewport);
598 
599  if (gs) {
600  GLdouble out_near[3], out_far[3];
601  GLdouble factor;
602  GLdouble out[3];
603 
604  z = (float)gs->zmax + gs->z_trans;
605 
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]);
612 
613  glPopMatrix();
614 
615  factor = (out_near[Z] - z) / (out_near[Z] - out_far[Z]);
616 
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);
619  out[Z] = z;
620 
621  pos2[X] = (float)out[X];
622  pos2[Y] = (float)out[Y];
623  pos2[Z] = (float)out[Z];
624 
625  return;
626 
627  }
628  }
629  return;
630 }
631 
632 /*!
633  \brief Draw place marker
634 
635  Used to display query point for raster queries.
636 
637  \param id surface id
638  \param pt point, X, Y value in true world coordinates
639  */
640 void GS_draw_X(int id, float *pt)
641 {
642  geosurf *gs;
643  Point3 pos;
644  float siz;
645  gvstyle style;
646 
647  if ((gs = gs_get_surf(id))) {
648  GS_get_longdim(&siz);
649  style.size = siz / 200.;
650  pos[X] = pt[X] - gs->ox;
651  pos[Y] = pt[Y] - gs->oy;
652  _viewcell_tri_interp(gs, pos);
653 
654  gsd_pushmatrix();
655 
656  gsd_do_scale(1);
657  gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans);
658  gsd_linewidth(1);
659 
660  if (CONST_ATT == gs_get_att_src(gs, ATT_TOPO)) {
661  pos[Z] = gs->att[ATT_TOPO].constant;
662  gs = NULL; /* tells gpd_obj to use given Z val */
663  }
664  style.color = Gd.bgcol;
665  style.symbol = ST_GYRO;
666  gpd_obj(gs, &style, pos);
667  gsd_flush();
668 
669  gsd_popmatrix();
670  }
671 
672  return;
673 }
674 
675 /*!
676  \brief Draw line on surface
677 
678  \param id surface id
679  \param x1,y1,x2,y2 line nodes
680  */
681 void GS_draw_line_onsurf(int id, float x1, float y1, float x2, float y2)
682 {
683  float p1[2], p2[2];
684  geosurf *gs;
685 
686  if ((gs = gs_get_surf(id))) {
687  p1[X] = x1 - gs->ox;
688  p1[Y] = y1 - gs->oy;
689  p2[X] = x2 - gs->ox;
690  p2[Y] = y2 - gs->oy;
691 
692  gsd_pushmatrix();
693 
694  gsd_do_scale(1);
695  gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans);
696  gsd_linewidth(1);
697 
699  gsd_line_onsurf(gs, p1, p2);
700 
701  gsd_popmatrix();
702  gsd_flush();
703  }
704 
705  return;
706 }
707 
708 /*!
709  \brief Draw multiline on surface
710 
711  Like above but limits points in line to n or points found in segment,
712  whichever is smaller.
713 
714  \param id surface id
715  \param x1,y1,x2,y2 line nodes
716 
717  \return number of points used
718  */
719 int GS_draw_nline_onsurf(int id, float x1, float y1, float x2, float y2,
720  float *lasp, int n)
721 {
722  float p1[2], p2[2];
723  geosurf *gs;
724  int ret = 0;
725 
726  if ((gs = gs_get_surf(id))) {
727  p1[X] = x1 - gs->ox;
728  p1[Y] = y1 - gs->oy;
729  p2[X] = x2 - gs->ox;
730  p2[Y] = y2 - gs->oy;
731 
732  gsd_pushmatrix();
733 
734  gsd_do_scale(1);
735  gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans);
736  gsd_linewidth(1);
738  ret = gsd_nline_onsurf(gs, p1, p2, lasp, n);
739  gsd_surf2real(gs, lasp);
740 
741  gsd_popmatrix();
742  gsd_flush();
743  }
744 
745  return (ret);
746 }
747 
748 /*!
749  \brief Draw flow-line on surace
750 
751  This is slow - should be moved to gs_ but GS_ good for testing
752  and useful for app programmer
753 
754  \param id surface id
755  \param x,y coordinates of flow-line
756  */
757 void GS_draw_flowline_at_xy(int id, float x, float y)
758 {
759  geosurf *gs;
760  float nv[3], pdir[2], mult;
761  float p1[2], p2[2], next[2];
762  int i = 0;
763 
764  if ((gs = gs_get_surf(id))) {
765  p1[X] = x;
766  p1[Y] = y;
767  /* multiply by 1.5 resolutions to ensure a crossing ? */
768  mult = .1 * (VXRES(gs) > VYRES(gs) ? VXRES(gs) : VYRES(gs));
769 
770  GS_coordpair_repeats(p1, p1, 50);
771 
772  while (1 == GS_get_norm_at_xy(id, p1[X], p1[Y], nv)) {
773  if (nv[Z] == 1.0) {
774  if (pdir[X] == 0.0 && pdir[Y] == 0.0) {
775  break;
776  }
777 
778  p2[X] = p1[X] + (pdir[X] * mult);
779  p2[Y] = p1[Y] + (pdir[Y] * mult);
780  }
781  else {
782  /* use previous direction */
783  GS_v2norm(nv);
784  p2[X] = p1[X] + (nv[X] * mult);
785  p2[Y] = p1[Y] + (nv[Y] * mult);
786  pdir[X] = nv[X];
787  pdir[Y] = nv[Y];
788  }
789 
790  if (i > 2000) {
791  break;
792  }
793 
794  if (GS_coordpair_repeats(p1, p2, 0)) {
795  break;
796  }
797 
798  /* Think about this: */
799  /* degenerate line means edge or level edge ? */
800  /* next is filled with last point drawn */
801  if (2 > GS_draw_nline_onsurf(id, p1[X], p1[Y],
802  p2[X], p2[Y], next, 3)) {
803  break;
804  }
805 
806  p1[X] = next[X];
807  p1[Y] = next[Y];
808  }
809 
810  G_debug(3, "GS_draw_flowline_at_xy(): dir: %f %f", nv[X], nv[Y]);
811  }
812 
813  return;
814 }
815 
816 /*!
817  \brief Draw fringe around data (surface) at selected corners
818 
819  \param id surface id
820  \param clr color
821  \param elev elevation value
822  \param where nw/ne/sw/se edges - 0 (turn off) 1 (turn on)
823  */
824 void GS_draw_fringe(int id, unsigned long clr, float elev, int *where)
825 {
826  geosurf *gs;
827 
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]);
830  if ((gs = gs_get_surf(id)))
831  gsd_display_fringe(gs, clr, elev, where);
832 
833 }
834 
835 
836 /*!
837  \brief Draw legend
838 
839  \todo add legend from list option
840  make font loading more flexible
841 
842  \param name legend name
843  \param fontbase font-base
844  \param size ?
845  \param flags legend flags
846  \param range values range
847  \param pt ?
848  */
849 int GS_draw_legend(const char *name, GLuint fontbase, int size, int *flags,
850  float *range, int *pt)
851 {
852  int list_no;
853 
854  list_no = gsd_put_legend(name, fontbase, size, flags, range, pt);
855 
856  return (list_no);
857 }
858 
859 /*!
860  \brief Draw pre-defined list
861 
862  Uses glFlush() to ensure all drawing is complete
863  before returning
864 
865  \param list_id list id
866  */
867 void GS_draw_list(GLuint list_id)
868 {
869  gsd_calllist(list_id);
870  glFlush();
871  return;
872 }
873 
874 /*!
875  \brief Draw all glLists
876 
877  Uses glFlush() to ensure all drawing is complete
878  before returning
879  */
881 {
882  gsd_calllists(0); /* not sure if 0 is right - MN */
883  glFlush();
884  return;
885 }
886 
887 /*!
888  \brief Delete pre-defined list
889 
890  \param list_id list id
891  */
892 void GS_delete_list(GLuint list_id)
893 {
894  gsd_deletelist(list_id, 1);
895 
896  return;
897 }
898 
899 /*!
900  \brief Draw lighting model
901  */
903 {
904  static float center[3];
905  float tcenter[3];
906 
907  if (!Modelshowing) {
908  GS_get_modelposition1(center);
909  }
910 
911  GS_v3eq(tcenter, center);
912 
913  gsd_zwritemask(0x0);
914  gsd_backface(1);
915 
918  gsd_pushmatrix();
919  gsd_do_scale(1);
920 
921  if (Gv.vert_exag) {
922  tcenter[Z] *= Gv.vert_exag;
923  gsd_scale(1.0, 1.0, 1. / Gv.vert_exag);
924  }
925 
926  gsd_drawsphere(tcenter, 0xDDDDDD, (float)(Longdim / 10.));
927  gsd_popmatrix();
928  Modelshowing = 1;
929 
930  gsd_backface(0);
931  gsd_zwritemask(0xffffffff);
932 
933  return;
934 }
935 
936 /*!
937  \brief Draw lighting model
938 
939  Just turn off any cutting planes and draw it just outside near
940  clipping plane, since lighting is infinite now
941  */
943 {
944  static float center[3], size;
945  float tcenter[3], tsize;
946  int i, wason[MAX_CPLANES];
947 
948  gsd_get_cplanes_state(wason);
949 
950  for (i = 0; i < MAX_CPLANES; i++) {
951  if (wason[i]) {
952  gsd_cplane_off(i);
953  }
954  }
955 
956 
957  if (!Modelshowing) {
958  GS_get_modelposition(&size, center);
959  }
960 
961  GS_v3eq(tcenter, center);
962  tsize = size;
963 
964  gsd_zwritemask(0x0);
965  gsd_backface(1);
966 
969  gsd_pushmatrix();
970  gsd_drawsphere(tcenter, 0xDDDDDD, tsize);
971  gsd_popmatrix();
972  Modelshowing = 1;
973 
974  gsd_backface(0);
975  gsd_zwritemask(0xffffffff);
976 
977  for (i = 0; i < MAX_CPLANES; i++) {
978  if (wason[i]) {
979  gsd_cplane_on(i);
980  }
981  }
982 
983  gsd_flush();
984 
985  return;
986 }
987 
988 /*!
989  \brief Update current mask
990 
991  May be called to update total mask for a surface at convenient times
992  instead of waiting until ready to redraw surface
993 
994  \param id surface id
995 
996  \return ?
997  */
998 int GS_update_curmask(int id)
999 {
1000  geosurf *gs;
1001 
1002  gs = gs_get_surf(id);
1003  return (gs_update_curmask(gs));
1004 }
1005 
1006 /*!
1007  \brief Check if point is masked ?
1008 
1009  \param id surface id
1010  \param pt point
1011 
1012  \return 1 masked
1013  \return 0 not masked
1014  \return -1 on error, invalid surface id
1015  */
1016 int GS_is_masked(int id, float *pt)
1017 {
1018  geosurf *gs;
1019  Point3 tmp;
1020 
1021  if ((gs = gs_get_surf(id))) {
1022  tmp[X] = pt[X] - gs->ox;
1023  tmp[Y] = pt[Y] - gs->oy;
1024 
1025  return (gs_point_is_masked(gs, tmp));
1026  }
1027 
1028  return (-1);
1029 }
1030 
1031 /*!
1032  \brief Unset Scaled Difference surface
1033  */
1035 {
1037  SDref_surf = 0;
1038 
1039  return;
1040 }
1041 
1042 /*!
1043  \brief Set surface as Scaled Difference surface
1044 
1045  \param id surface id
1046 
1047  \return 1 on success
1048  \return 0 on error, invalid surface id
1049  */
1050 int GS_set_SDsurf(int id)
1051 {
1052  geosurf *gs;
1053 
1054  if ((gs = gs_get_surf(id))) {
1055  gsdiff_set_SDref(gs);
1056  SDref_surf = id;
1057 
1058  return (1);
1059  }
1060 
1061  return (0);
1062 }
1063 
1064 /*!
1065  \brief Set ?
1066 
1067  \param scale scale value
1068 
1069  \return 1
1070  */
1071 int GS_set_SDscale(float scale)
1072 {
1073  gsdiff_set_SDscale(scale);
1074 
1075  return (1);
1076 }
1077 
1078 /*!
1079  \brief Get ?
1080 
1081  \param[out] id ?
1082 
1083  \return 1 on success
1084  \return 0 on error
1085  */
1086 int GS_get_SDsurf(int *id)
1087 {
1088  geosurf *gs;
1089 
1090  if ((gs = gsdiff_get_SDref())) {
1091  *id = SDref_surf;
1092 
1093  return (1);
1094  }
1095 
1096  return (0);
1097 }
1098 
1099 /*!
1100  \brief Get ?
1101 
1102  \param[out] scale value
1103 
1104  \return 1
1105  */
1106 int GS_get_SDscale(float *scale)
1107 {
1108  *scale = gsdiff_get_SDscale();
1109 
1110  return (1);
1111 }
1112 
1113 /*!
1114  \brief Update normals
1115 
1116  \param id surface id
1117 
1118  \return ?
1119  */
1121 {
1122  geosurf *gs;
1123 
1124  gs = gs_get_surf(id);
1125 
1126  return (gs_calc_normals(gs));
1127 }
1128 
1129 /*!
1130  \brief Get attributes
1131 
1132  \param id surface id
1133  \param att
1134  \param[out] set
1135  \param[out] constant
1136  \param[out] mapname
1137 
1138  \return 1 on success
1139  \return -1 on error (invalid surface id)
1140  */
1141 int GS_get_att(int id, int att, int *set, float *constant, char *mapname)
1142 {
1143  int src;
1144  geosurf *gs;
1145 
1146  gs = gs_get_surf(id);
1147  if (gs) {
1148  if (-1 != (src = gs_get_att_src(gs, att))) {
1149  *set = src;
1150 
1151  if (src == CONST_ATT) {
1152  *constant = gs->att[att].constant;
1153  }
1154  else if (src == MAP_ATT) {
1155  strcpy(mapname, gsds_get_name(gs->att[att].hdata));
1156  }
1157 
1158  return (1);
1159  }
1160 
1161  return (-1);
1162  }
1163 
1164  return (-1);
1165 }
1166 
1167 /*!
1168  \brief Get surface category on given position
1169 
1170  Prints "no data" or a description (i.e., "coniferous forest") to
1171  <i>catstr</i>. Usually call after GS_get_selected_point_on_surface().
1172  Define <i>att</i> as MAP_ATT
1173 
1174  \todo Allocate catstr using G_store()
1175 
1176  \param id surface id
1177  \param att attribute id (MAP_ATT)
1178  \param catstr cat string (must be allocated, dim?)
1179  \param x,y real coordinates
1180 
1181  \return -1 if no category info or point outside of window
1182  \return 1 on success
1183 */
1184 int GS_get_cat_at_xy(int id, int att, char *catstr, float x, float y)
1185 {
1186  int offset, drow, dcol, vrow, vcol;
1187  float ftmp, pt[3];
1188  typbuff *buff;
1189  geosurf *gs;
1190 
1191  *catstr = '\0';
1192  gs = gs_get_surf(id);
1193 
1194  if (NULL == gs) {
1195  return -1;
1196  }
1197 
1198  pt[X] = x;
1199  pt[Y] = y;
1200 
1201  gsd_real2surf(gs, pt);
1202  if (gs_point_is_masked(gs, pt)) {
1203  return -1;
1204  }
1205 
1206  if (!in_vregion(gs, pt)) {
1207  return -1;
1208  }
1209 
1210  if (MAP_ATT != gs_get_att_src(gs, att)) {
1211  sprintf(catstr, _("no category info"));
1212  return -1;
1213  }
1214 
1215  buff = gs_get_att_typbuff(gs, att, 0);
1216 
1217  vrow = Y2VROW(gs, pt[Y]);
1218  vcol = X2VCOL(gs, pt[X]);
1219  drow = VROW2DROW(gs, vrow);
1220  dcol = VCOL2DCOL(gs, vcol);
1221 
1222  offset = DRC2OFF(gs, drow, dcol);
1223 
1224  if (GET_MAPATT(buff, offset, ftmp)) {
1225  return
1227  drow, dcol, catstr));
1228  }
1229 
1230  sprintf(catstr, _("no data"));
1231 
1232  return 1;
1233 }
1234 
1235 /*!
1236  \brief Get surface normal at x,y (real coordinates)
1237 
1238  Usually call after GS_get_selected_point_on_surface()
1239 
1240  \param id surface id
1241  \param x,y real coordinates
1242  \param[out] nv surface normal
1243 
1244  \return -1 if point outside of window or masked
1245  \return 1 on success
1246  */
1247 int GS_get_norm_at_xy(int id, float x, float y, float *nv)
1248 {
1249  int offset, drow, dcol, vrow, vcol;
1250  float pt[3];
1251  geosurf *gs;
1252 
1253  gs = gs_get_surf(id);
1254 
1255  if (NULL == gs) {
1256  return (-1);
1257  }
1258 
1259  if (gs->norm_needupdate) {
1260  gs_calc_normals(gs);
1261  }
1262 
1263  pt[X] = x;
1264  pt[Y] = y;
1265 
1266  gsd_real2surf(gs, pt);
1267  if (gs_point_is_masked(gs, pt)) {
1268  return (-1);
1269  }
1270 
1271  if (!in_vregion(gs, pt)) {
1272  return (-1);
1273  }
1274 
1275  vrow = Y2VROW(gs, pt[Y]);
1276  vcol = X2VCOL(gs, pt[X]);
1277  drow = VROW2DROW(gs, vrow);
1278  dcol = VCOL2DCOL(gs, vcol);
1279 
1280  offset = DRC2OFF(gs, drow, dcol);
1281 
1282  if (gs->norms) {
1283  FNORM(gs->norms[offset], nv);
1284  }
1285  else {
1286  /* otherwise must be a constant */
1287  nv[0] = 0.0;
1288  nv[1] = 0.0;
1289  nv[2] = 1.0;
1290  }
1291 
1292  return (1);
1293 }
1294 
1295 /*!
1296  \brief Get RGB color at given point
1297 
1298  Colors are translated to rgb and returned as Rxxx Gxxx Bxxx Usually
1299  call after GS_get_selected_point_on_surface().
1300 
1301  Prints NULL or the value (i.e., "921.5") to valstr
1302 
1303  \param id surface id
1304  \param att attribute id
1305  \param[out] valstr value string (allocated, dim?)
1306  \param x,y real coordinates
1307 
1308  \return -1 if point outside of window or masked
1309  \return 1 on success
1310  */
1311 int GS_get_val_at_xy(int id, int att, char *valstr, float x, float y)
1312 {
1313  int offset, drow, dcol, vrow, vcol;
1314  float ftmp, pt[3];
1315  typbuff *buff;
1316  geosurf *gs;
1317 
1318  *valstr = '\0';
1319  gs = gs_get_surf(id);
1320 
1321  if (NULL == gs) {
1322  return -1;
1323  }
1324 
1325  pt[X] = x;
1326  pt[Y] = y;
1327 
1328  gsd_real2surf(gs, pt);
1329 
1330  if (gs_point_is_masked(gs, pt)) {
1331  return -1;
1332  }
1333 
1334  if (!in_vregion(gs, pt)) {
1335  return (-1);
1336  }
1337 
1338  if (CONST_ATT == gs_get_att_src(gs, att)) {
1339  if (att == ATT_COLOR) {
1340  int r, g, b, i;
1341 
1342  i = gs->att[att].constant;
1343  sprintf(valstr, "R%d G%d B%d",
1344  INT_TO_RED(i, r), INT_TO_GRN(i, g), INT_TO_BLU(i, b));
1345  }
1346  else {
1347  sprintf(valstr, "%f", gs->att[att].constant);
1348  }
1349 
1350  return 1;
1351  }
1352  else if (MAP_ATT != gs_get_att_src(gs, att)) {
1353  return -1;
1354  }
1355 
1356  buff = gs_get_att_typbuff(gs, att, 0);
1357 
1358  vrow = Y2VROW(gs, pt[Y]);
1359  vcol = X2VCOL(gs, pt[X]);
1360  drow = VROW2DROW(gs, vrow);
1361  dcol = VCOL2DCOL(gs, vcol);
1362 
1363  offset = DRC2OFF(gs, drow, dcol);
1364 
1365  if (GET_MAPATT(buff, offset, ftmp)) {
1366  if (att == ATT_COLOR) {
1367  int r, g, b, i;
1368 
1370  &(gs->att[ATT_COLOR]), offset);
1371  sprintf(valstr, "R%d G%d B%d",
1372  INT_TO_RED(i, r), INT_TO_GRN(i, g), INT_TO_BLU(i, b));
1373  }
1374  else {
1375  sprintf(valstr, "%f", ftmp);
1376  }
1377 
1378  return (1);
1379  }
1380 
1381  sprintf(valstr, "NULL");
1382 
1383  return (1);
1384 }
1385 
1386 /*!
1387  \brief Unset attribute
1388 
1389  \param id surface id
1390  \param att attribute id
1391 
1392  \return ?
1393  */
1394 int GS_unset_att(int id, int att)
1395 {
1396  geosurf *gs;
1397 
1398  gs = gs_get_surf(id);
1399  gs->mask_needupdate = 1;
1400 
1401  return (gs_set_att_src(gs, att, NOTSET_ATT));
1402 }
1403 
1404 /*!
1405  \brief Set attribute constant
1406 
1407  \param id surface id
1408  \param att attribute id
1409  \param constant value
1410 
1411  \return ?
1412  */
1413 int GS_set_att_const(int id, int att, float constant)
1414 {
1415  geosurf *gs;
1416  int ret;
1417 
1418  gs = gs_get_surf(id);
1419  ret = (gs_set_att_const(gs, att, constant));
1420 
1421  Gs_update_attrange(gs, att);
1422 
1423  return (ret);
1424 }
1425 
1426 /*!
1427  \brief Set mask mode
1428 
1429  Mask attribute special: constant is set to indicate invert or no
1430 
1431  \param id surface id
1432  \param mode id
1433 
1434  \return mode id
1435  \return -1 on error (invalid surface id)
1436  */
1437 int GS_set_maskmode(int id, int mode)
1438 {
1439  geosurf *gs;
1440 
1441  gs = gs_get_surf(id);
1442 
1443  if (gs) {
1444  gs->att[ATT_MASK].constant = mode;
1445  gs->mask_needupdate = 1;
1446 
1447  return (mode);
1448  }
1449 
1450  return (-1);
1451 }
1452 
1453 /*!
1454  \brief Get mask mode
1455 
1456  \param id surface id
1457  \param[out] mode id
1458 
1459  \return 1 on success
1460  \return -1 on error (invalid surface id)
1461  */
1462 int GS_get_maskmode(int id, int *mode)
1463 {
1464  geosurf *gs;
1465 
1466  gs = gs_get_surf(id);
1467 
1468  if (gs) {
1469  *mode = gs->att[ATT_MASK].constant;
1470 
1471  return (1);
1472  }
1473 
1474  return (-1);
1475 }
1476 
1477 /*!
1478  \brief Set client data
1479 
1480  \param id surface id
1481  \param clientd pointer to client data struct
1482 
1483  \return 1 on success
1484  \return -1 on error (invalid surface id)
1485  */
1486 int GS_Set_ClientData(int id, void *clientd)
1487 {
1488  geosurf *gs;
1489 
1490  gs = gs_get_surf(id);
1491  if (gs) {
1492  gs->clientdata = clientd;
1493 
1494  return (1);
1495  }
1496 
1497  return (-1);
1498 }
1499 
1500 /*!
1501  \brief Get client data
1502 
1503  \param id surface id
1504 
1505  \return pointer to client data
1506  \return NULL on error
1507  */
1508 void *GS_Get_ClientData(int id)
1509 {
1510  geosurf *gs;
1511 
1512  gs = gs_get_surf(id);
1513  if (gs) {
1514  return (gs->clientdata);
1515  }
1516 
1517  return (NULL);
1518 }
1519 
1520 /*!
1521  \brief Get number of surfaces
1522 
1523  \return number of surfaces
1524  */
1525 int GS_num_surfs(void)
1526 {
1527  return (gs_num_surfaces());
1528 }
1529 
1530 /*!
1531  \brief Get surface list
1532 
1533  Must be freed when not neeed!
1534 
1535  \param[out] numsurf number of available surfaces
1536 
1537  \return pointer to surface array
1538  \return NULL on error
1539  */
1540 int *GS_get_surf_list(int *numsurfs)
1541 {
1542  int i, *ret;
1543 
1544  *numsurfs = Next_surf;
1545 
1546  if (Next_surf) {
1547  ret = (int *)G_malloc(Next_surf * sizeof(int));
1548 
1549  for (i = 0; i < Next_surf; i++) {
1550  ret[i] = Surf_ID[i];
1551  }
1552 
1553  return (ret);
1554  }
1555 
1556  return (NULL);
1557 }
1558 
1559 /*!
1560  \brief Delete surface
1561 
1562  \param id surface id
1563 
1564  \return 1 on success
1565  \return -1 on error
1566  */
1568 {
1569  int i, j, found;
1570 
1571  found = FALSE;
1572 
1573  G_debug(1, "GS_delete_surface(): id=%d", id);
1574 
1575  if (GS_surf_exists(id)) {
1576  gs_delete_surf(id);
1577  for (i = 0; i < Next_surf && !found; i++) {
1578  if (Surf_ID[i] == id) {
1579  found = TRUE;
1580 
1581  for (j = i; j < Next_surf; j++) {
1582  Surf_ID[j] = Surf_ID[j + 1];
1583  }
1584  }
1585  }
1586 
1588 
1589  if (found) {
1590  --Next_surf;
1591  return 1;
1592  }
1593  }
1594 
1595  return -1;
1596 }
1597 
1598 
1599 /*!
1600  \brief Load raster map as attribute
1601 
1602  \param id surface id
1603  \param filename filename
1604  \param att attribute descriptor
1605 
1606  \return -1 on error (invalid surface id)
1607  \return ?
1608  */
1609 int GS_load_att_map(int id, const char *filename, int att)
1610 {
1611  geosurf *gs;
1612  unsigned int changed;
1613  unsigned int atty;
1614  const char *mapset;
1615  struct Cell_head rast_head;
1616  int reuse, begin, hdata, ret, neg, has_null;
1617  typbuff *tbuff;
1618 
1619  G_debug(3, "GS_load_att_map(): map=%s", filename);
1620 
1621  reuse = ret = neg = has_null = 0;
1622  gs = gs_get_surf(id);
1623 
1624  if (NULL == gs) {
1625  return -1;
1626  }
1627 
1628  gs->mask_needupdate = (ATT_MASK == att || ATT_TOPO == att ||
1629  (gs->nz_topo && ATT_TOPO == att) ||
1630  (gs->nz_color && ATT_COLOR == att));
1631 
1632  gs_set_att_src(gs, att, MAP_ATT);
1633 
1634  /* Check against maps already loaded in memory */
1635  /* if to be color attribute:
1636  - if packed color for another surface, OK to reuse
1637  - if unchanged, ok to reuse IF it's of type char (will have lookup)
1638  */
1639  begin = hdata = 1;
1640 
1641  /* Get MAPSET to ensure names are fully qualified */
1642  mapset = G_find_raster2(filename, "");
1643  if (mapset == NULL) {
1644  /* Check for valid filename */
1645  G_warning("Raster map <%s> not found", filename);
1646  return -1;
1647  }
1648 
1649  /* Check to see if map is in Region */
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) {
1654 
1655  G_warning(_("Raster map <%s> is outside of current region. Load failed."),
1656  G_fully_qualified_name(filename, mapset));
1657  }
1658 
1659  while (!reuse && (0 < hdata)) {
1660  changed = CF_COLOR_PACKED;
1662 
1663  if (0 < (hdata = gsds_findh(filename, &changed, &atty, begin))) {
1664 
1665  G_debug(3, "GS_load_att_map(): %s already has data handle %d.CF=%x",
1666  filename, hdata, changed);
1667 
1668  /* handle found */
1669  if (ATT_COLOR == att) {
1670  if ((changed == CF_COLOR_PACKED) ||
1671  (!changed && atty == ATTY_CHAR)) {
1672  reuse = 1;
1673  }
1674  }
1675  else if (atty == ATTY_MASK && att != ATT_MASK) {
1676  reuse = 0;
1677  /* should also free mask data & share new - but need backward
1678  reference? */
1679  }
1680  else if (!changed) {
1681  reuse = 1;
1682  }
1683  }
1684 
1685  begin = 0;
1686  }
1687 
1688  if (reuse) {
1689  gs->att[att].hdata = hdata;
1690  gs_set_att_type(gs, att, atty); /* ?? */
1691 
1692  /* free lookup & set to NULL! */
1693  if (atty == ATTY_INT) {
1694  if (gs->att[att].lookup) {
1695  free(gs->att[att].lookup);
1696  gs->att[att].lookup = NULL;
1697  }
1698  }
1699  /* TODO: FIX THIS stuff with lookup sharing! */
1700 
1701  G_debug(3, "GS_load_att_map(): %s is being reused. hdata=%d",
1702  filename, hdata);
1703  }
1704  else {
1705  G_debug(3, "GS_load_att_map(): %s not loaded in correct form - loading now",
1706  filename);
1707 
1708  /* not loaded - need to get new dataset handle */
1709  gs->att[att].hdata = gsds_newh(filename);
1710 
1711  tbuff = gs_get_att_typbuff(gs, att, 1);
1712 
1713  /* TODO: Provide mechanism for loading certain attributes at
1714  specified sizes, allow scaling or capping, or scale non-zero */
1715  if (ATT_MASK == att) {
1716  atty = ATTY_MASK;
1717  }
1718  else {
1719  atty = Gs_numtype(filename, &neg);
1720  }
1721 
1722 #ifdef MAYBE_LATER
1723  if (att == ATT_COLOR && atty == ATTY_SHORT) {
1724  atty = (neg ? ATTY_INT : ATTY_SHORT);
1725  }
1726 #endif
1727 
1728  if (att == ATT_COLOR && atty == ATTY_SHORT) {
1729  atty = ATTY_INT;
1730  }
1731 
1732  if (0 == gs_malloc_att_buff(gs, att, ATTY_NULL)) {
1733  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1734  }
1735 
1736  switch (atty) {
1737  case ATTY_MASK:
1738  if (0 == gs_malloc_att_buff(gs, att, ATTY_MASK)) {
1739  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1740  }
1741 
1742  ret = Gs_loadmap_as_bitmap(&wind, filename, tbuff->bm);
1743 
1744  break;
1745  case ATTY_CHAR:
1746  if (0 == gs_malloc_att_buff(gs, att, ATTY_CHAR)) {
1747  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1748  }
1749 
1750  ret = Gs_loadmap_as_char(&wind, filename, tbuff->cb,
1751  tbuff->nm, &has_null);
1752 
1753  break;
1754  case ATTY_SHORT:
1755  if (0 == gs_malloc_att_buff(gs, att, ATTY_SHORT)) {
1756  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1757  }
1758 
1759  ret = Gs_loadmap_as_short(&wind, filename, tbuff->sb,
1760  tbuff->nm, &has_null);
1761  break;
1762  case ATTY_FLOAT:
1763  if (0 == gs_malloc_att_buff(gs, att, ATTY_FLOAT)) {
1764  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1765  }
1766 
1767  ret = Gs_loadmap_as_float(&wind, filename, tbuff->fb,
1768  tbuff->nm, &has_null);
1769 
1770  break;
1771  case ATTY_INT:
1772  default:
1773  if (0 == gs_malloc_att_buff(gs, att, ATTY_INT)) {
1774  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1775  }
1776 
1777  ret = Gs_loadmap_as_int(&wind, filename, tbuff->ib,
1778  tbuff->nm, &has_null);
1779  break;
1780 
1781  } /* Done with switch */
1782 
1783  if (ret == -1) {
1785  return -1;
1786  }
1787 
1788  G_debug(4, " has_null=%d", has_null);
1789 
1790  if (!has_null) {
1792  }
1793  else {
1794  gs_update_curmask(gs);
1795  }
1796 
1797  } /* end if not reuse */
1798 
1799  if (ATT_COLOR == att) {
1800 #ifdef MAYBE_LATER
1801  if (ATTY_INT == atty) {
1802  Gs_pack_colors(filename, tbuff->ib, gs->rows, gs->cols);
1804  gs->att[att].lookup = NULL;
1805  }
1806  else {
1807  gs_malloc_lookup(gs, att);
1808  Gs_build_lookup(filename, gs->att[att].lookup);
1809  }
1810 #else
1811 
1812  if (ATTY_CHAR == atty) {
1813  if (!gs->att[att].lookup) {
1814  /* might already exist if reusing */
1815  gs_malloc_lookup(gs, att);
1816  Gs_build_256lookup(filename, gs->att[att].lookup);
1817  }
1818  }
1819  else if (ATTY_FLOAT == atty) {
1820  if (!reuse) {
1821  if (0 == gs_malloc_att_buff(gs, att, ATTY_INT)) {
1822  G_fatal_error(_("GS_load_att_map(): Out of memory. Unable to load map"));
1823  }
1824 
1825  Gs_pack_colors_float(filename, tbuff->fb, tbuff->ib,
1826  gs->rows, gs->cols);
1829  gs->att[att].lookup = NULL;
1830  }
1831  }
1832  else {
1833  if (!reuse) {
1834  Gs_pack_colors(filename, tbuff->ib, gs->rows, gs->cols);
1836  gs->att[att].lookup = NULL;
1837  }
1838  }
1839 #endif
1840  }
1841 
1842  if (ATT_TOPO == att) {
1843  gs_init_normbuff(gs);
1844  /* S_DIFF: should also check here to see if this surface is a
1845  reference surface for scaled differences, if so update references
1846  to it */
1847  }
1848 
1849  if (ret < 0) {
1850  G_warning(_("Loading failed"));
1851  }
1852 
1853  if (-1 == Gs_update_attrange(gs, att)) {
1854  G_warning(_("Error finding range"));
1855  }
1856 
1857  return ret;
1858 }
1859 
1860 /*!
1861  \brief Draw surface
1862 
1863  \param id surface id
1864  */
1865 void GS_draw_surf(int id)
1866 {
1867  geosurf *gs;
1868 
1869  G_debug(3, "GS_draw_surf(): id=%d", id);
1870 
1871  gs = gs_get_surf(id);
1872  if (gs) {
1874 
1875  if (gs->draw_mode & DM_POLY) {
1876  gsd_surf(gs);
1877  }
1878 
1879  if (gs->draw_mode & DM_WIRE) {
1880  gsd_wire_surf(gs);
1881  }
1882 
1883  /* TODO: write wire/poly draw routines */
1884  if (gs->draw_mode & DM_WIRE_POLY) {
1885  gsd_surf(gs);
1886  gsd_wire_surf(gs);
1887  }
1888  }
1889 
1890  return;
1891 }
1892 
1893 /*!
1894  \brief Draw surface wire
1895 
1896  Overrides draw_mode for fast display
1897 
1898  \param id surface id
1899  */
1900 void GS_draw_wire(int id)
1901 {
1902  geosurf *gs;
1903 
1904  G_debug(3, "GS_draw_wire(): id=%d", id);
1905 
1906  gs = gs_get_surf(id);
1907 
1908  if (gs) {
1909  gsd_wire_surf(gs);
1910  }
1911 
1912  return;
1913 }
1914 
1915 /*!
1916  \brief Draw all wires
1917 
1918  Overrides draw_mode for fast display
1919  */
1921 {
1922  geosurf *gs;
1923  int i;
1924 
1925  for (i = 0; i < Next_surf; i++) {
1926  if ((gs = gs_get_surf(Surf_ID[i]))) {
1927  gsd_wire_surf(gs);
1928  }
1929  }
1930 
1931  return;
1932 }
1933 
1934 /*!
1935  \brief Draw all surfaces
1936  */
1938 {
1939  int i;
1940 
1941  for (i = 0; i < Next_surf; i++) {
1942  GS_draw_surf(Surf_ID[i]);
1943  }
1944 
1945  return;
1946 }
1947 
1948 /*!
1949  \brief Set Z exag for surface
1950 
1951  \param id surface id
1952  \param exag z-exag value
1953  */
1954 void GS_set_exag(int id, float exag)
1955 {
1956  geosurf *gs;
1957 
1958  G_debug(3, "GS_set_exag");
1959 
1960  gs = gs_get_surf(id);
1961 
1962  if (gs) {
1963  if (gs->z_exag != exag) {
1964  gs->norm_needupdate = 1;
1965  }
1966 
1967  gs->z_exag = exag;
1968  }
1969 
1970  return;
1971 }
1972 
1973 /*!
1974  \brief Set global z-exag value
1975 
1976  \param exag exag value to be set up
1977  */
1978 void GS_set_global_exag(float exag)
1979 {
1980 
1981  G_debug(3, "GS_set_global_exag");
1982 
1983  Gv.vert_exag = exag;
1984  /* GL_NORMALIZE */
1985  /* Only need to update norms gs_norms.c
1986  * if exag is used in norm equation which
1987  * it is not! If GL_NORMALIZE is disabled
1988  * will need to include.
1989  gs_setall_norm_needupdate();
1990  */
1991 
1992  return;
1993 }
1994 
1995 /*!
1996  \brief Get global z-exag value
1997 
1998  \return value
1999  */
2000 float GS_global_exag(void)
2001 {
2002  G_debug(3, "GS_global_exag(): %g", Gv.vert_exag);
2003 
2004  return (Gv.vert_exag);
2005 }
2006 
2007 /*!
2008  \brief Set wire color
2009 
2010  \todo error-handling
2011 
2012  \param id surface id
2013  \param colr color value
2014  */
2015 void GS_set_wire_color(int id, int colr)
2016 {
2017  geosurf *gs;
2018 
2019  G_debug(3, "GS_set_wire_color");
2020 
2021  gs = gs_get_surf(id);
2022 
2023  if (gs) {
2024  gs->wire_color = colr;
2025  }
2026 
2027  return;
2028 }
2029 
2030 /*!
2031  \brief Get wire color
2032 
2033  \param id surface id
2034  \param[out] colr color value
2035 
2036  \return 1 on success
2037  \return -1 on error
2038  */
2039 int GS_get_wire_color(int id, int *colr)
2040 {
2041  geosurf *gs;
2042 
2043  gs = gs_get_surf(id);
2044 
2045  if (gs) {
2046  *colr = gs->wire_color;
2047 
2048  return (1);
2049  }
2050 
2051  return (-1);
2052 }
2053 
2054 /*!
2055  \brief Set all draw-modes
2056 
2057  \param mode mode id
2058 
2059  \return 0 on success
2060  \return -1 on error
2061  */
2062 int GS_setall_drawmode(int mode)
2063 {
2064  int i;
2065 
2066  for (i = 0; i < Next_surf; i++) {
2067  if (0 != GS_set_drawmode(Surf_ID[i], mode)) {
2068  return (-1);
2069  }
2070  }
2071 
2072  return (0);
2073 }
2074 
2075 /*!
2076  \brief Set draw mode
2077 
2078  \param id surface id
2079  \param mode mode type(s)
2080 
2081  \return 0 on success
2082  \return -1 on error (invalid surface id)
2083  */
2084 int GS_set_drawmode(int id, int mode)
2085 {
2086  geosurf *gs;
2087 
2088  G_debug(3, "GS_set_drawmode(): id=%d mode=%d", id, mode);
2089 
2090  gs = gs_get_surf(id);
2091 
2092  if (gs) {
2093  gs->draw_mode = mode;
2094 
2095  return (0);
2096  }
2097 
2098  return (-1);
2099 }
2100 
2101 /*!
2102  \brief Get draw mode
2103 
2104  \param id surface id
2105  \param[out] mode mode id
2106 
2107  \return 1 on success
2108  \return -1 on error (invalid surface id)
2109  */
2110 int GS_get_drawmode(int id, int *mode)
2111 {
2112  geosurf *gs;
2113 
2114  gs = gs_get_surf(id);
2115 
2116  if (gs) {
2117  *mode = gs->draw_mode;
2118 
2119  return (1);
2120  }
2121 
2122  return (-1);
2123 }
2124 
2125 /*!
2126  \brief Set no-zero ?
2127 
2128  \param id surface id
2129  \param att attribute id
2130  \param mode mode id
2131  */
2132 void GS_set_nozero(int id, int att, int mode)
2133 {
2134  geosurf *gs;
2135 
2136  G_debug(3, "GS_set_nozero");
2137 
2138  gs = gs_get_surf(id);
2139 
2140  if (gs) {
2141  if (att == ATT_TOPO) {
2142  gs->nz_topo = mode;
2143  gs->mask_needupdate = 1;
2144  }
2145 
2146  if (att == ATT_COLOR) {
2147  gs->nz_color = mode;
2148  gs->mask_needupdate = 1;
2149  }
2150  }
2151 
2152  return;
2153 }
2154 
2155 /*!
2156  \brief Get no-zero ?
2157 
2158  \param id surface id
2159  \param att attribute id
2160  \param[out] mode mode id
2161 
2162  \return -1 on error (invalid surface id)
2163  \return 1 on success
2164  */
2165 int GS_get_nozero(int id, int att, int *mode)
2166 {
2167  geosurf *gs;
2168 
2169  G_debug(3, "GS_set_nozero");
2170 
2171  gs = gs_get_surf(id);
2172 
2173  if (gs) {
2174  if (att == ATT_TOPO) {
2175  *mode = gs->nz_topo;
2176  }
2177  else if (att == ATT_COLOR) {
2178  *mode = gs->nz_color;
2179  }
2180  else {
2181  return (-1);
2182  }
2183 
2184  return (1);
2185  }
2186 
2187  return (-1);
2188 }
2189 
2190 /*!
2191  \brief Set all draw resolutions
2192 
2193  \param xres,yres x/y resolution value
2194  \param xwire,ywire x/y wire value
2195 
2196  \return 0 on success
2197  \return -1 on error
2198  */
2199 int GS_setall_drawres(int xres, int yres, int xwire, int ywire)
2200 {
2201  int i;
2202 
2203  for (i = 0; i < Next_surf; i++) {
2204  if (0 != GS_set_drawres(Surf_ID[i], xres, yres, xwire, ywire)) {
2205  return (-1);
2206  }
2207  }
2208 
2209  return (0);
2210 }
2211 
2212 /*!
2213  \brief Set draw resolution for surface
2214 
2215  \param id surface id
2216  \param xres,yres x/y resolution value
2217  \param xwire,ywire x/y wire value
2218 
2219  \return -1 on error
2220  \return 0 on success
2221  */
2222 int GS_set_drawres(int id, int xres, int yres, int xwire, int ywire)
2223 {
2224  geosurf *gs;
2225 
2226  G_debug(3, "GS_set_drawres() id=%d xyres=%d/%d xywire=%d/%d",
2227  id, xres, yres, xwire, ywire);
2228 
2229  if (xres < 1 || yres < 1 || xwire < 1 || ywire < 1) {
2230  return (-1);
2231  }
2232 
2233  gs = gs_get_surf(id);
2234 
2235  if (gs) {
2236  if (gs->x_mod != xres || gs->y_mod != yres) {
2237  gs->norm_needupdate = 1;
2238  }
2239 
2240  gs->x_mod = xres;
2241  gs->y_mod = yres;
2242  gs->x_modw = xwire;
2243  gs->y_modw = ywire;
2244  }
2245 
2246  return (0);
2247 }
2248 
2249 /*!
2250  \brief Get draw resolution of surface
2251 
2252  \param id surface id
2253  \param[out] xres,yres x/y resolution value
2254  \param[out] xwire,ywire x/y wire value
2255  */
2256 void GS_get_drawres(int id, int *xres, int *yres, int *xwire, int *ywire)
2257 {
2258  geosurf *gs;
2259 
2260  G_debug(3, "GS_get_drawres");
2261 
2262  gs = gs_get_surf(id);
2263 
2264  if (gs) {
2265  *xres = gs->x_mod;
2266  *yres = gs->y_mod;
2267  *xwire = gs->x_modw;
2268  *ywire = gs->y_modw;
2269  }
2270 
2271  return;
2272 }
2273 
2274 /*!
2275  \brief Get dimension of surface
2276 
2277  \param id surface id
2278  \param[out] rows,cols number of rows/cols
2279  */
2280 void GS_get_dims(int id, int *rows, int *cols)
2281 {
2282  geosurf *gs;
2283 
2284  gs = gs_get_surf(id);
2285 
2286  if (gs) {
2287  *rows = gs->rows;
2288  *cols = gs->cols;
2289  }
2290 
2291  return;
2292 }
2293 
2294 /*!
2295  \brief Get exag-value guess
2296 
2297  Use no_zero range because if zero IS data, then range won't be that
2298  much off (it's just a GUESS, after all), but if zero is NO data, could
2299  drastically affect guess
2300 
2301  \param id surface id
2302  \param[out] exag exag value
2303 
2304  \return 1 on success
2305  \return -1 on error
2306  */
2307 int GS_get_exag_guess(int id, float *exag)
2308 {
2309  geosurf *gs;
2310  float guess;
2311 
2312  gs = gs_get_surf(id);
2313  guess = 1.0;
2314 
2315  /* if gs is type const return guess = 1.0 */
2316  if (CONST_ATT == gs_get_att_src(gs, ATT_TOPO)) {
2317  *exag = guess;
2318  return (1);
2319  }
2320 
2321  if (gs) {
2322  if (gs->zrange_nz == 0.0) {
2323  *exag = 0.0;
2324 
2325  return (1);
2326  }
2327 
2328  G_debug(3, "GS_get_exag_guess(): %f %f", gs->zrange_nz, Longdim);
2329 
2330  while (gs->zrange_nz * guess / Longdim >= .25) {
2331  guess *= .1;
2332 
2333  G_debug(3, "GS_get_exag_guess(): %f", guess);
2334  }
2335 
2336  while (gs->zrange_nz * guess / Longdim < .025) {
2337  guess *= 10.;
2338 
2339  G_debug(3, "GS_get_exag_guess(): %f", guess);
2340  }
2341 
2342  *exag = guess;
2343 
2344  return (1);
2345  }
2346 
2347  return (-1);
2348 }
2349 
2350 /*!
2351  \brief Get Z extents for all loaded surfaces
2352 
2353  Treating zeros as "no data"
2354 
2355  \param[out] min min value
2356  \param[out] max max value
2357  */
2358 void GS_get_zrange_nz(float *min, float *max)
2359 {
2360  int i, first = 1;
2361  geosurf *gs;
2362 
2363  for (i = 0; i < Next_surf; i++) {
2364  if ((gs = gs_get_surf(Surf_ID[i]))) {
2365  if (first) {
2366  first = 0;
2367  *min = gs->zmin_nz;
2368  *max = gs->zmax_nz;
2369  }
2370 
2371  if (gs->zmin_nz < *min) {
2372  *min = gs->zmin_nz;
2373  }
2374 
2375  if (gs->zmax_nz > *max) {
2376  *max = gs->zmax_nz;
2377  }
2378  }
2379  }
2380 
2381  G_debug(3, "GS_get_zrange_nz(): min=%g max=%g", *min, *max);
2382 
2383  return;
2384 }
2385 
2386 /*!
2387  \brief Set translation (surface position)
2388 
2389  \param id surface id
2390  \param xtrans,ytrans,ztrans translation values
2391  */
2392 void GS_set_trans(int id, float xtrans, float ytrans, float ztrans)
2393 {
2394  geosurf *gs;
2395 
2396  gs = gs_get_surf(id);
2397 
2398  if (gs) {
2399  gs->x_trans = xtrans;
2400  gs->y_trans = ytrans;
2401  gs->z_trans = ztrans;
2402  }
2403 
2404  G_debug(3, "GS_set_trans(): id=%d, x=%f, y=%f, z=%f",
2405  id, xtrans, ytrans, ztrans);
2406 
2407  return;
2408 }
2409 
2410 /*!
2411  \brief Get translation values (surface position)
2412 
2413  \param id surface id
2414  \param[out] xtrans,ytrans,ztrans trans values
2415  */
2416 void GS_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
2417 {
2418  geosurf *gs;
2419 
2420  gs = gs_get_surf(id);
2421 
2422  if (gs) {
2423  *xtrans = gs->x_trans;
2424  *ytrans = gs->y_trans;
2425  *ztrans = gs->z_trans;
2426  }
2427 
2428  G_debug(3, "GS_get_trans: id=%d, x=%f, y=%f, z=%f",
2429  id, *xtrans, *ytrans, *ztrans);
2430 
2431  return;
2432 }
2433 
2434 
2435 /*!
2436  \brief Get default draw color
2437 
2438  \return color value
2439  */
2440 unsigned int GS_default_draw_color(void)
2441 {
2442 
2443  G_debug(3, "GS_default_draw_color");
2444 
2445  return ((unsigned int)Gd.bgcol);
2446 }
2447 
2448 /*!
2449  \brief Get background color
2450 
2451  \return color value
2452  */
2453 unsigned int GS_background_color(void)
2454 {
2455  return ((unsigned int)Gd.bgcol);
2456 }
2457 
2458 /*!
2459  \brief Sets which buffer to draw to
2460 
2461  \param where GSD_BOTH, GSD_FRONT, GSD_BACK
2462  */
2463 void GS_set_draw(int where)
2464 {
2465  Buffermode = where;
2466 
2467  switch (where) {
2468  case GSD_BOTH:
2469  gsd_bothbuffers();
2470 
2471  break;
2472  case GSD_FRONT:
2473  gsd_frontbuffer();
2474 
2475  break;
2476  case GSD_BACK:
2477  default:
2478  gsd_backbuffer();
2479 
2480  break;
2481  }
2482 
2483  return;
2484 }
2485 
2486 /*
2487  \brief Ready to draw
2488  */
2489 void GS_ready_draw(void)
2490 {
2491 
2492  G_debug(3, "GS_ready_draw");
2493 
2494  gsd_set_view(&Gv, &Gd);
2495 
2496  return;
2497 }
2498 
2499 /*!
2500  \brief Draw done, swap buffers
2501  */
2502 void GS_done_draw(void)
2503 {
2504 
2505  G_debug(3, "GS_done_draw");
2506 
2507  if (GSD_BACK == Buffermode) {
2508  gsd_swapbuffers();
2509  }
2510 
2511  gsd_flush();
2512 
2513  return;
2514 }
2515 
2516 /*!
2517  \brief Set focus
2518 
2519  \param realto real coordinates to
2520  */
2521 void GS_set_focus(float *realto)
2522 {
2523 
2524  G_debug(3, "GS_set_focus(): %f,%f,%f", realto[0], realto[1], realto[2]);
2525 
2526  Gv.infocus = 1;
2527  GS_v3eq(Gv.real_to, realto);
2528 
2529  gsd_set_view(&Gv, &Gd);
2530 
2531  return;
2532 }
2533 
2534 /*!
2535  \brief Set real focus
2536 
2537  \param realto real coordinates to
2538  */
2539 void GS_set_focus_real(float *realto)
2540 {
2541 
2542  G_get_set_window(&wind);
2543  realto[X] = realto[X] - wind.west - (wind.ew_res / 2.);
2544  realto[Y] = realto[Y] - wind.south - (wind.ns_res / 2.);
2545 
2546  Gv.infocus = 1;
2547  GS_v3eq(Gv.real_to, realto);
2548 
2549  gsd_set_view(&Gv, &Gd);
2550 
2551  return;
2552 }
2553 
2554 
2555 /*!
2556  \brief Get focus
2557 
2558  OK to call with NULL argument if just want to check state
2559 
2560  \param realto real coordinates to
2561 
2562  \return ?
2563  */
2564 int GS_get_focus(float *realto)
2565 {
2566 
2567  G_debug(3, "GS_get_focus");
2568 
2569  if (Gv.infocus) {
2570  if (realto) {
2571  GS_v3eq(realto, Gv.real_to);
2572  }
2573  }
2574 
2575  return (Gv.infocus);
2576 }
2577 
2578 /*!
2579  \brief Set focus to map center
2580 
2581  \param id surface id
2582  */
2584 {
2585  float center[3];
2586  geosurf *gs;
2587 
2588  G_debug(3, "GS_set_focus_center_map");
2589 
2590  gs = gs_get_surf(id);
2591 
2592  if (gs) {
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.;
2596 
2597  /* not yet working
2598  buff = gs_get_att_typbuff(gs, ATT_TOPO, 0);
2599  offset = gs->rows*gs->cols/2 + gs->cols/2;
2600  if (buff)
2601  {
2602  if (GET_MAPATT(buff, offset, tmp))
2603  {
2604  center[Z] = tmp;
2605  }
2606  }
2607  */
2608 
2609  GS_set_focus(center);
2610  }
2611 }
2612 
2613 /*!
2614  \brief Move viewpoint
2615 
2616  \param pt 'from' model coordinates
2617  */
2618 void GS_moveto(float *pt)
2619 {
2620  float ft[3];
2621 
2622  G_debug(3, "GS_moveto(): %f,%f,%f", pt[0], pt[1], pt[2]);
2623 
2624  if (Gv.infocus) {
2625  GS_v3eq(Gv.from_to[FROM], pt);
2626  /*
2627  GS_v3eq(Gv.from_to[TO], Gv.real_to);
2628  */
2629  GS_v3normalize(Gv.from_to[FROM], Gv.from_to[TO]);
2630  /* update inclination, look_dir if we're keeping these */
2631  }
2632  else {
2633  GS_v3eq(ft, Gv.from_to[TO]);
2634  GS_v3sub(ft, Gv.from_to[FROM]);
2635  GS_v3eq(Gv.from_to[FROM], pt);
2636  GS_v3eq(Gv.from_to[TO], pt);
2637  GS_v3add(Gv.from_to[TO], ft);
2638  }
2639 
2640  return;
2641 }
2642 
2643 /*!
2644  \brief Move position to (real)
2645 
2646  \param pt point real coordinates
2647  */
2648 void GS_moveto_real(float *pt)
2649 {
2650  gsd_real2model(pt);
2651  GS_moveto(pt);
2652 
2653  return;
2654 }
2655 
2656 /*!
2657  \brief Get z-extent for a single surface
2658 
2659  \param id surface id
2660  \param[out] min min z-value
2661  \param[out] max max z-value
2662  \param[out] mid middle z-value
2663 
2664  \return -1 on error (invalid surface id)
2665  \return ?
2666  */
2667 int GS_get_zextents(int id, float *min, float *max, float *mid)
2668 {
2669  geosurf *gs;
2670 
2671  if (NULL == (gs = gs_get_surf(id))) {
2672  return (-1);
2673  }
2674 
2675  G_debug(3, "GS_get_zextents(): id=%d", id);
2676 
2677  return (gs_get_zextents(gs, min, max, mid));
2678 }
2679 
2680 /*!
2681  \brief Get z-extent for all loaded surfaces
2682 
2683  \param[out] min min z-value
2684  \param[out] max max z-value
2685  \param doexag use z-exaggeration
2686 
2687  \return 1 on success
2688  \return -1 on error
2689  */
2690 int GS_get_zrange(float *min, float *max, int doexag)
2691 {
2692  int ret_surf, ret_vol;
2693  float surf_min, surf_max;
2694  float vol_min, vol_max;
2695 
2696  ret_surf = gs_get_zrange(&surf_min, &surf_max);
2697  ret_vol = gvl_get_zrange(&vol_min, &vol_max);
2698 
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;
2702  }
2703  else if (ret_surf > 0) {
2704  *min = surf_min;
2705  *max = surf_max;
2706  }
2707  else if (ret_vol > 0) {
2708  *min = vol_min;
2709  *max = vol_max;
2710  }
2711 
2712  if (doexag) {
2713  *min *= Gv.vert_exag;
2714  *max *= Gv.vert_exag;
2715  }
2716 
2717  G_debug(3, "GS_get_zrange(): min=%g max=%g", *min, *max);
2718  return ((ret_surf > 0 || ret_vol > 0) ? (1) : (-1));
2719 }
2720 
2721 /*!
2722  \brief Get viewpoint 'from' position
2723 
2724  \param[out] fr from model coordinates
2725  */
2726 void GS_get_from(float *fr)
2727 {
2728  GS_v3eq(fr, Gv.from_to[FROM]);
2729 
2730  G_debug(3, "GS_get_from(): %f,%f,%f", fr[0], fr[1], fr[2]);
2731 
2732  return;
2733 }
2734 
2735 /*!
2736  \brief Get viewpoint 'from' real coordinates
2737 
2738  \param[out] fr 'from' real coordinates
2739  */
2740 void GS_get_from_real(float *fr)
2741 {
2742  GS_v3eq(fr, Gv.from_to[FROM]);
2743  gsd_model2real(fr);
2744 
2745  return;
2746 }
2747 
2748 /*!
2749  \brief Get 'to' real coordinates
2750 
2751  \param[out] to 'to' real coordinates
2752  */
2753 void GS_get_to_real(float *to)
2754 {
2755  float realto[3];
2756 
2757  G_get_set_window(&wind);
2758  GS_get_focus(realto);
2759  to[X] = realto[X] + wind.west + (wind.ew_res / 2.);
2760  to[Y] = realto[Y] + wind.south + (wind.ns_res / 2.);
2761  to[Z] = realto[Z];
2762 
2763  return;
2764 }
2765 
2766 
2767 /*!
2768  \brief Get zoom setup
2769 
2770  \param[out] a,b,c,d current viewport settings
2771  \param[out] maxx,maxy max viewport size
2772  */
2773 void GS_zoom_setup(int *a, int *b, int *c, int *d, int *maxx, int *maxy)
2774 {
2775  GLint tmp[4];
2776  GLint num[2];
2777 
2778  gsd_getViewport(tmp, num);
2779  *a = tmp[0];
2780  *b = tmp[1];
2781  *c = tmp[2];
2782  *d = tmp[3];
2783  *maxx = num[0];
2784  *maxy = num[1];
2785 
2786  return;
2787 }
2788 
2789 /*!
2790  \brief Get 'to' model coordinates
2791 
2792  \todo need set_to? - just use viewdir?
2793 
2794  \param[out] to 'to' model coordinates
2795  */
2796 void GS_get_to(float *to)
2797 {
2798  G_debug(3, "GS_get_to");
2799 
2800  GS_v3eq(to, Gv.from_to[TO]);
2801 
2802  return;
2803 }
2804 
2805 /*!
2806  \brief Get viewdir
2807 
2808  \param[out] dir viewdir value
2809  */
2810 void GS_get_viewdir(float *dir)
2811 {
2812  GS_v3dir(Gv.from_to[FROM], Gv.from_to[TO], dir);
2813 
2814  return;
2815 }
2816 
2817 /*!
2818  \brief Set viewdir
2819 
2820  Automatically turns off focus
2821 
2822  \param dir viewdir value
2823  */
2824 void GS_set_viewdir(float *dir)
2825 {
2826  float tmp[3];
2827 
2828  GS_v3eq(tmp, dir);
2829  GS_v3norm(tmp);
2830  GS_v3eq(Gv.from_to[TO], Gv.from_to[FROM]);
2831  GS_v3add(Gv.from_to[TO], tmp);
2832 
2833  GS_set_nofocus();
2834  gsd_set_view(&Gv, &Gd);
2835 
2836  return;
2837 }
2838 
2839 /*!
2840  \brief Set field of view
2841 
2842  \param fov fov value
2843  */
2844 void GS_set_fov(int fov)
2845 {
2846  Gv.fov = fov;
2847 
2848  return;
2849 }
2850 
2851 /*!
2852  \brief Get fied of view
2853 
2854  \return field of view, in 10ths of degrees
2855  */
2856 int GS_get_fov(void)
2857 {
2858  return (Gv.fov);
2859 }
2860 
2861 /*!
2862  \brief Get twist value
2863 
2864  10ths of degrees off twelve o'clock
2865  */
2866 int GS_get_twist(void)
2867 {
2868  return (Gv.twist);
2869 }
2870 
2871 /*!
2872  \brief Set viewpoint twist value
2873 
2874  10ths of degrees off twelve o'clock
2875 
2876  \param t tenths of degrees clockwise from 12:00.
2877  */
2878 void GS_set_twist(int t)
2879 {
2880  Gv.twist = t;
2881 
2882  return;
2883 }
2884 
2885 /*!
2886  \brief Set rotation params
2887  */
2888 void GS_set_rotation(double angle, double x, double y, double z)
2889 {
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;
2895 
2896  return;
2897 }
2898 
2899 /*!
2900  \brief Stop scene rotation
2901  */
2903 {
2904  Gv.rotate.do_rot = 0;
2905 }
2906 
2907 /*!
2908  \brief Reset scene rotation
2909  */
2911 {
2912  int i;
2913 
2914  for (i = 0; i < 16; i++) {
2915  if (i == 0 || i == 5 || i == 10 || i == 15)
2916  Gv.rotate.rotMatrix[i] = 1.0;
2917  else
2918  Gv.rotate.rotMatrix[i] = 0.0;
2919  }
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;
2925 
2926 }
2927 /*!
2928  * \brief Get rotation matrix
2929  */
2930 void GS_get_rotation_matrix(double *matrix)
2931 {
2932  int i;
2933 
2934  for (i = 0; i < 16; i++) {
2935  matrix[i] = Gv.rotate.rotMatrix[i];
2936  }
2937 }
2938 
2939 /*!
2940  * \brief Set rotation matrix
2941  */
2942 void GS_set_rotation_matrix(double *matrix)
2943 {
2944  int i;
2945 
2946  for (i = 0; i < 16; i++) {
2947  Gv.rotate.rotMatrix[i] = matrix[i];
2948  }
2949 }
2950 
2951 /*!
2952  \brief Unset focus
2953  */
2954 void GS_set_nofocus(void)
2955 {
2956  G_debug(3, "GS_set_nofocus");
2957 
2958  Gv.infocus = 0;
2959 
2960  return;
2961 }
2962 
2963 /*!
2964  \brief Set focus
2965 
2966  Make sure that the center of view is set
2967  */
2968 void GS_set_infocus(void)
2969 {
2970  G_debug(3, "GS_set_infocus");
2971 
2972  Gv.infocus = 1;
2973 
2974  return;
2975 }
2976 
2977 /*!
2978  \brief Set viewport
2979 
2980  \param left,right,bottom,top viewport extent values
2981  */
2982 void GS_set_viewport(int left, int right, int bottom, int top)
2983 {
2984  G_debug(3, "GS_set_viewport(): left=%d, right=%d, "
2985  "bottom=%d, top=%d", left, right, bottom, top);
2986 
2987  gsd_viewport(left, right, bottom, top);
2988 
2989  return;
2990 }
2991 
2992 /*!
2993  \brief Send screen coords sx and sy, lib traces through surfaces; sets
2994  new center to point of nearest intersection.
2995 
2996  If no intersection, uses line of sight with length of current view
2997  ray (eye to center) to set new center.
2998 
2999  Reset center of view to screen coordinates sx, sy.
3000 
3001  \param sx,sy screen coordinates
3002 
3003  \return 1 on success
3004  \return 0 on error (invalid surface id)
3005  */
3006 int GS_look_here(int sx, int sy)
3007 {
3008  float x, y, z, len, los[2][3];
3009  Point3 realto, dir;
3010  int id;
3011  geosurf *gs;
3012 
3013  if (GS_get_selected_point_on_surface(sx, sy, &id, &x, &y, &z)) {
3014  gs = gs_get_surf(id);
3015  if (gs) {
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;
3019  GS_set_focus(realto);
3020 
3021  return (1);
3022  }
3023  }
3024  else {
3025  if (gsd_get_los(los, (short)sx, (short)sy)) {
3026  len = GS_distance(Gv.from_to[FROM], Gv.real_to);
3027  GS_v3dir(los[FROM], los[TO], dir);
3028  GS_v3mult(dir, len);
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];
3032  GS_set_focus(realto);
3033 
3034  return (1);
3035  }
3036  }
3037 
3038  return (0);
3039 }
3040 
3041 /*!
3042  \brief Get selected point of surface
3043 
3044  Given screen coordinates sx and sy, find closest intersection of
3045  view ray with surfaces and return coordinates of intersection in x, y,
3046  z, and identifier of surface in id.
3047 
3048  \param sx,sy screen coordinates
3049  \param[out] id surface id
3050  \param[out] x,y,z point on surface (model coordinates?)
3051 
3052  \returns 0 if no intersections found
3053  \return number of intersections
3054  */
3055 int GS_get_selected_point_on_surface(int sx, int sy, int *id, float *x,
3056  float *y, float *z)
3057 {
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;
3061  geosurf *gs;
3062 
3063  /* returns surface-world coords */
3064  gsd_get_los(los, (short)sx, (short)sy);
3065 
3066  if (!gs_setlos_enterdata(los)) {
3067  G_debug(3, "gs_setlos_enterdata(los): returns false");
3068  return (0);
3069  }
3070 
3071  for (i = 0; i < Next_surf; i++) {
3072  G_debug(3, "id=%d", i);
3073 
3074  gs = gs_get_surf(Surf_ID[i]);
3075 
3076  /* los_intersect expects surf-world coords (xy transl, no scaling) */
3077 
3078 #if NVIZ_HACK
3079  if (gs_los_intersect1(Surf_ID[i], los, point)) {
3080 #else
3081  if (gs_los_intersect(Surf_ID[i], los, point)) {
3082 #endif
3083  if (!gs_point_is_masked(gs, point)) {
3084  GS_v3eq(tmp, point);
3085  tmp[X] += gs->x_trans;
3086  tmp[Y] += gs->y_trans;
3087  tmp[Z] += gs->z_trans;
3088  find_dist[numhits] = GS_distance(los[FROM], tmp);
3089  gsd_surf2real(gs, point);
3090  GS_v3eq(finds[numhits], point);
3091  surfs[numhits] = Surf_ID[i];
3092  numhits++;
3093  }
3094  }
3095  }
3096 
3097  for (i = iclose = 0; i < numhits; i++) {
3098  closest = find_dist[iclose];
3099 
3100  if (find_dist[i] < closest) {
3101  iclose = i;
3102  }
3103  }
3104 
3105  if (numhits) {
3106  *x = finds[iclose][X];
3107  *y = finds[iclose][Y];
3108  *z = finds[iclose][Z];
3109  *id = surfs[iclose];
3110  }
3111 
3112  G_debug(3, "NumHits %d, next %d", numhits, Next_surf);
3113 
3114  return (numhits);
3115 }
3116 
3117 /*!
3118  \brief Set cplace rotation
3119 
3120  \param num cplace id
3121  \param dx,dy,dz rotation values
3122  */
3123 void GS_set_cplane_rot(int num, float dx, float dy, float dz)
3124 {
3125  gsd_cplane_setrot(num, dx, dy, dz);
3126 
3127  return;
3128 }
3129 
3130 /*!
3131  \brief Set cplace trans
3132 
3133  \param num cplace id
3134  \param dx,dy,dz rotation values
3135  */
3136 void GS_set_cplane_trans(int num, float dx, float dy, float dz)
3137 {
3138  gsd_cplane_settrans(num, dx, dy, dz);
3139 
3140  return;
3141 }
3142 
3143 
3144 /*!
3145  \brief Draw cplace
3146 
3147  \param num cplace id
3148  */
3150 {
3151  geosurf *gsurfs[MAX_SURFS];
3152  int nsurfs;
3153 
3154  nsurfs = gs_num_surfaces();
3155  if (2 == nsurfs) {
3156  /* testing */
3157  gs_getall_surfaces(gsurfs);
3158  gsd_draw_cplane_fence(gsurfs[0], gsurfs[1], num);
3159  }
3160  else {
3161  gsd_draw_cplane(num);
3162  }
3163 
3164  return;
3165 }
3166 
3167 /*!
3168  \brief Draw cplace fence ?
3169 
3170  \param hs1,hs2
3171  \param num cplane id
3172 
3173  \return 0 on error
3174  \return 1 on success
3175  */
3176 int GS_draw_cplane_fence(int hs1, int hs2, int num)
3177 {
3178  geosurf *gs1, *gs2;
3179 
3180  if (NULL == (gs1 = gs_get_surf(hs1))) {
3181  return (0);
3182  }
3183 
3184  if (NULL == (gs2 = gs_get_surf(hs2))) {
3185  return (0);
3186  }
3187 
3188  gsd_draw_cplane_fence(gs1, gs2, num);
3189 
3190  return (1);
3191 }
3192 
3193 /*!
3194  \brief Draw all cplace fences ?
3195  */
3197 {
3198  int onstate[MAX_CPLANES], i;
3199 
3200  gsd_get_cplanes_state(onstate);
3201 
3202  for (i = 0; i < MAX_CPLANES; i++) {
3203  if (onstate[i]) {
3204  GS_draw_cplane_fence(Surf_ID[0], Surf_ID[1], i);
3205  }
3206  }
3207 
3208  return;
3209 }
3210 
3211 /*!
3212  \brief Set cplace
3213 
3214  \param num cplane id
3215  */
3217 {
3218  gsd_cplane_on(num);
3219 
3220  return;
3221 }
3222 
3223 /*!
3224  \brief Unset clip place (turn off)
3225 
3226  \param num cplane id
3227  */
3229 {
3230  gsd_cplane_off(num);
3231 
3232  return;
3233 }
3234 
3235 /*!
3236  \brief Get axis scale
3237 
3238  \param sx,sy,sz x/y/z scale values
3239  \param doexag use vertical exaggeration
3240  */
3241 void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
3242 {
3243  float zexag;
3244 
3245  zexag = doexag ? Gv.vert_exag : 1.;
3246  *sx = *sy = Gv.scale;
3247  *sz = Gv.scale * zexag;
3248 
3249  return;
3250 }
3251 
3252 /*!
3253  \brief Set fence color
3254 
3255  \param mode mode id
3256  */
3257 void GS_set_fencecolor(int mode)
3258 {
3259  gsd_setfc(mode);
3260 
3261  return;
3262 }
3263 
3264 /*!
3265  \brief Get fence color
3266 
3267  \return color value
3268  */
3270 {
3271  return gsd_getfc();
3272 }
3273 
3274 /*!
3275  \brief Measure distance "as the ball rolls" between two points on
3276  surface
3277 
3278  \param hs surface id
3279  \param x1,y1,x2,y2 two points on surface
3280  \param[out] dist measured distance
3281  \param use_exag use exag. surface
3282 
3283  \return 0 on error or if one or more points is not in region
3284  \return distance following terrain
3285  */
3286 int GS_get_distance_alongsurf(int hs, float x1, float y1, float x2, float y2,
3287  float *dist, int use_exag)
3288 {
3289  geosurf *gs;
3290  float p1[2], p2[2];
3291 
3292  gs = gs_get_surf(hs);
3293  if (gs == NULL) {
3294  return 0;
3295  }
3296 
3297  p1[X] = x1;
3298  p1[Y] = y1;
3299  p2[X] = x2;
3300  p2[Y] = y2;
3301  gsd_real2surf(gs, p1);
3302  gsd_real2surf(gs, p2);
3303 
3304  G_debug(3, "GS_get_distance_alongsurf(): hs=%d p1=%f,%f p2=%f,%f",
3305  hs, x1, y1, x2, y2);
3306  return gs_distance_onsurf(gs, p1, p2, dist, use_exag);
3307 }
3308 
3309 /*!
3310  \brief Save 3d view
3311 
3312  \param vname view file name
3313  \param surfid surface id
3314 
3315  \return ?
3316  */
3317 int GS_save_3dview(const char *vname, int surfid)
3318 {
3319  return (Gs_save_3dview(vname, &Gv, &Gd, &wind, gs_get_surf(surfid)));
3320 }
3321 
3322 /*!
3323  \brief Load 3d view
3324 
3325  \param vname view file name
3326  \param surfid surface id
3327 
3328  \return ?
3329  */
3330 int GS_load_3dview(const char *vname, int surfid)
3331 {
3332 
3333  return (Gs_load_3dview(vname, &Gv, &Gd, &wind, gs_get_surf(surfid)));
3334 
3335  /* what to do about lights - I guess, delete all &
3336  create any that exist in 3dview file */
3337 }
3338 
3339 /************************************************************************
3340 * Following routines use Graphics Library
3341 ************************************************************************/
3342 
3343 /*!
3344  \brief Init viewpoint
3345 
3346  \todo allow setting center?
3347  */
3348 void GS_init_view(void)
3349 {
3350  static int first = 1;
3351 
3352  G_debug(3, "GS_init_view");
3353 
3354  if (first) {
3355  first = 0;
3356  glMatrixMode(GL_MODELVIEW);
3357 
3358  /* OGLXXX doublebuffer: use GLX_DOUBLEBUFFER in attriblist */
3359  /* glxChooseVisual(*dpy, screen, *attriblist); */
3360  /* OGLXXX
3361  * ZMIN not needed -- always 0.
3362  * ZMAX not needed -- always 1.
3363  * getgdesc other posiblilties:
3364  * glxGetConfig();
3365  * glxGetCurrentContext();
3366  * glxGetCurrentDrawable();
3367  * GLint gdtmp;
3368  * getgdesc other posiblilties:
3369  * glxGetConfig();
3370  * glxGetCurrentContext();
3371  * glxGetCurrentDrawable();
3372  * GLint gdtmp;
3373  * glDepthRange params must be scaled to [0, 1]
3374  */
3375  glDepthRange(0.0, 1.0);
3376  glEnable(GL_DEPTH_TEST);
3377  glDepthFunc(GL_LEQUAL);
3378  /* } */
3379 
3380  /* replace these with something meaningful */
3381  Gv.fov = 450;
3382  Gv.twist = 0;
3383 
3384  GS_init_rotation();
3385 
3386  Gv.from_to[FROM][X] = Gv.from_to[FROM][Y] =
3387  Gv.from_to[FROM][Z] = GS_UNIT_SIZE / 2.;
3388 
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.;
3393 
3394  Gv.real_to[W] = 1.;
3395  Gv.vert_exag = 1.;
3396 
3397  GS_v3eq(Gv.real_to, Gv.from_to[TO]);
3398  GS_v3normalize(Gv.from_to[FROM], Gv.from_to[TO]);
3399 
3400  /*
3401  Gd.nearclip = 50;
3402  Gd.farclip = 10000.;
3403  */
3404  Gd.nearclip = 10.;
3405  Gd.farclip = 10000.;
3406  Gd.aspect = (float)GS_get_aspect();
3407 
3408  GS_set_focus(Gv.real_to);
3409  }
3410 
3411  return;
3412 }
3413 
3414 /*!
3415  \brief Clear view
3416 
3417  \param col color value
3418  */
3419 void GS_clear(int col)
3420 {
3421  G_debug(3, "GS_clear");
3422 
3423  col = col | 0xFF000000;
3424 
3425  /* OGLXXX
3426  * change glClearDepth parameter to be in [0, 1]
3427  * ZMAX not needed -- always 1.
3428  * getgdesc other posiblilties:
3429  * glxGetConfig();
3430  * glxGetCurrentContext();
3431  * glxGetCurrentDrawable();
3432  * GLint gdtmp;
3433  */
3434  glClearDepth(1.0);
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);
3440 
3441  Gd.bgcol = col;
3442  Modelshowing = 0;
3443  gsd_flush();
3444 
3445  return;
3446 }
3447 
3448 /*!
3449  \brief Get aspect value
3450 
3451  \return aspect value
3452  */
3453 double GS_get_aspect(void)
3454 {
3455  int left, right, bottom, top;
3456  GLint tmp[4];
3457 
3458  /* OGLXXX
3459  * get GL_VIEWPORT:
3460  * You can probably do better than this.
3461  */
3462  glGetIntegerv(GL_VIEWPORT, tmp);
3463  left = tmp[0];
3464  right = tmp[0] + tmp[2] - 1;
3465  bottom = tmp[1];
3466  top = tmp[1] + tmp[3] - 1;
3467 
3468  G_debug(3, "GS_get_aspect(): left=%d, right=%d, top=%d, bottom=%d",
3469  left, right, top, bottom);
3470 
3471  return ((double)(right - left) / (top - bottom));
3472 }
3473 
3474 /*!
3475  \brief Check for transparency
3476 
3477  Disabled.
3478 
3479  \return 1
3480  */
3482 {
3483  /* OGLXXX
3484  * getgdesc other posiblilties:
3485  * glxGetConfig();
3486  * glxGetCurrentContext();
3487  * glxGetCurrentDrawable();
3488  * GLint gdtmp;
3489  * blending is ALWAYS supported.
3490  * This function returns whether it is enabled.
3491  * return((glGetIntegerv(GL_BLEND, &gdtmp), gdtmp));
3492  */
3493 
3494  return (1);
3495 }
int GS_set_maskmode(int id, int mode)
Set mask mode.
Definition: gs2.c:1437
#define VXRES(gs)
Definition: rowcol.h:9
float scale
Definition: ogsf.h:487
void gsd_zwritemask(unsigned long n)
Write out z-mask.
Definition: gsd_prim.c:231
void gsdiff_set_SDscale(float scale)
Set scale.
Definition: gsdiff.c:42
int GS_Set_ClientData(int id, void *clientd)
Set client data.
Definition: gs2.c:1486
void GS_ready_draw(void)
Definition: gs2.c:2489
#define TRUE
Definition: gis.h:49
int GS_get_zextents(int id, float *min, float *max, float *mid)
Get z-extent for a single surface.
Definition: gs2.c:2667
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_los_intersect(int surfid, float **los, float *point)
Crude method of intersecting line of sight with closest part of surface.
Definition: gs_query.c:191
void GS_set_nozero(int id, int att, int mode)
Set no-zero ?
Definition: gs2.c:2132
#define ATTY_CHAR
Definition: ogsf.h:168
float aspect
Definition: ogsf.h:493
void gs_delete_surf(int id)
Remove geosurf struct from list.
Definition: gs.c:463
#define CM_DIFFUSE
Definition: ogsf.h:148
void gsd_calllist(int listno)
ADD.
Definition: gsd_prim.c:1154
long wire_color
Definition: ogsf.h:263
float ymin
Definition: ogsf.h:268
int bgcol
Definition: ogsf.h:495
float ambient[3]
Definition: ogsf.h:465
void GS_get_to(float *to)
Get &#39;to&#39; model coordinates.
Definition: gs2.c:2796
int GS_get_fov(void)
Get fied of view.
Definition: gs2.c:2856
#define MAX_CPLANES
Definition: ogsf.h:45
#define DM_WIRE_POLY
Definition: ogsf.h:62
#define ATT_SHINE
Definition: ogsf.h:77
#define DRC2OFF(gs, drow, dcol)
Definition: rowcol.h:17
void gsd_cplane_settrans(int num, float tx, float ty, float tz)
ADD.
Definition: gsd_cplane.c:229
int GS_load_3dview(const char *vname, int surfid)
Load 3d view.
Definition: gs2.c:3330
int gsd_wire_surf(geosurf *surf)
Draw surface wire.
Definition: gsd_wire.c:47
float nearclip
Definition: ogsf.h:493
int GS_set_SDscale(float scale)
Set ?
Definition: gs2.c:1071
void GS_get_from(float *fr)
Get viewpoint &#39;from&#39; position.
Definition: gs2.c:2726
void GS_get_rotation_matrix(double *matrix)
Get rotation matrix.
Definition: gs2.c:2930
void GS_get_modelposition(float *siz, float *pos)
Retrieves coordinates for lighting model position, at center of view.
Definition: gs2.c:532
short * sb
Definition: ogsf.h:208
void GS_alldraw_cplane_fences(void)
Draw all cplace fences ?
Definition: gs2.c:3196
float gsdiff_get_SDscale(void)
Get scale.
Definition: gsdiff.c:54
float zrange_nz
Definition: ogsf.h:270
int gsds_findh(const char *name, IFLAG *changes, IFLAG *types, int begin)
Get handle to gsds.
Definition: gsds.c:188
void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
Get axis scale.
Definition: gs2.c:3241
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:417
GLdouble rotMatrix[16]
Definition: ogsf.h:475
int gs_get_datacenter(float *cen)
Get data center point.
Definition: gs.c:1232
int GS_new_surface(void)
Add new surface.
Definition: gs2.c:225
int GS_v3normalize(float *v1, float *v2)
Change v2 so that v1v2 is a unit vector.
Definition: gs_util.c:322
float size
Definition: ogsf.h:290
int gs_get_data_avg_zmax(float *azmax)
Get average z-max value.
Definition: gs.c:1203
int in_vregion(geosurf *gs, float *pt)
ADD.
Definition: gsdrape.c:696
void GS_getlight_color(int num, float *red, float *green, float *blue)
Get light color.
Definition: gs2.c:381
double rot_angle
Definition: ogsf.h:473
unsigned int GS_default_draw_color(void)
Get default draw color.
Definition: gs2.c:2440
void GS_draw_list(GLuint list_id)
Draw pre-defined list.
Definition: gs2.c:867
double ox
Definition: ogsf.h:264
unsigned long * norms
Definition: ogsf.h:274
void(* Swap_func)()
Definition: gsx.c:22
2D/3D raster map header (used also for region)
Definition: gis.h:390
void GS_get_drawres(int id, int *xres, int *yres, int *xwire, int *ywire)
Get draw resolution of surface.
Definition: gs2.c:2256
void GS_moveto_real(float *pt)
Move position to (real)
Definition: gs2.c:2648
#define GS_UNIT_SIZE
Definition: ogsf.h:30
void GS_draw_wire(int id)
Draw surface wire.
Definition: gs2.c:1900
int GS_get_maskmode(int id, int *mode)
Get mask mode.
Definition: gs2.c:1462
int gs_point_is_masked(geosurf *gs, float *pt)
Check if point is masked.
Definition: gs.c:1317
void * GS_Get_ClientData(int id)
Get client data.
Definition: gs2.c:1508
#define MAX_LIGHTS
Definition: ogsf.h:44
#define NOTSET_ATT
Definition: ogsf.h:82
void GS_draw_flowline_at_xy(int id, float x, float y)
Draw flow-line on surace.
Definition: gs2.c:757
#define min(x, y)
Definition: draw2.c:31
void gsd_do_scale(int doexag)
Set current scale.
Definition: gsd_views.c:355
int GS_get_zrange(float *min, float *max, int doexag)
Get z-extent for all loaded surfaces.
Definition: gs2.c:2690
int Gs_update_attrange(geosurf *gs, int desc)
Update no_zero ranges for attribute (actually no_null now)
Definition: gs3.c:1087
int GS_draw_cplane_fence(int hs1, int hs2, int num)
Draw cplace fence ?
Definition: gs2.c:3176
double west
Extent coordinates (west)
Definition: gis.h:442
void gsd_cplane_off(int num)
Turn off clip plane.
Definition: gsd_cplane.c:126
void GS_set_rotation(double angle, double x, double y, double z)
Set rotation params.
Definition: gs2.c:2888
int GS_get_exag_guess(int id, float *exag)
Get exag-value guess.
Definition: gs2.c:2307
int rows
Definition: ogsf.h:260
float zmax_nz
Definition: ogsf.h:270
void GS_draw_lighting_model1(void)
Draw lighting model.
Definition: gs2.c:902
float xmax
Definition: ogsf.h:268
void GS_set_focus_real(float *realto)
Set real focus.
Definition: gs2.c:2539
void GS_setlight_position(int num, float xpos, float ypos, float zpos, int local)
Set light position.
Definition: gs2.c:310
void GS_v3sub(float *v1, float *v2)
Subtract vectors.
Definition: gs_util.c:212
#define ATT_TOPO
Definition: ogsf.h:73
int Gs_build_256lookup(const char *filename, int *buff)
Build color table (256)
Definition: gs3.c:576
void GS_set_fencecolor(int mode)
Set fence color.
Definition: gs2.c:3257
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_get_SDscale(float *scale)
Get ?
Definition: gs2.c:1106
void GS_draw_all_list(void)
Draw all glLists.
Definition: gs2.c:880
int * ib
Definition: ogsf.h:207
int color
Definition: ogsf.h:288
int GS_v3norm(float *v1)
Change v1 so that it is a unit vector (2D)
Definition: gs_util.c:246
int GS_get_wire_color(int id, int *colr)
Get wire color.
Definition: gs2.c:2039
size_t gs_malloc_att_buff(geosurf *gs, int desc, int type)
Allocate attribute buffer.
Definition: gs.c:717
void GS_set_Narrow(int *pt, int id, float *pos2)
Set decoration, north arrow ??
Definition: gs2.c:569
int GS_save_3dview(const char *vname, int surfid)
Save 3d view.
Definition: gs2.c:3317
void GS_set_trans(int id, float xtrans, float ytrans, float ztrans)
Set translation (surface position)
Definition: gs2.c:2392
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_zoom_setup(int *a, int *b, int *c, int *d, int *maxx, int *maxy)
Get zoom setup.
Definition: gs2.c:2773
void GS_getlight_position(int num, float *xpos, float *ypos, float *zpos, int *local)
Get light position.
Definition: gs2.c:336
int gvl_get_zrange(float *min, float *max)
Get volume z-range value.
Definition: gvl.c:476
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:3055
void GS_v3add(float *v1, float *v2)
Sum vectors.
Definition: gs_util.c:195
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
void GS_set_viewdir(float *dir)
Set viewdir.
Definition: gs2.c:2824
float Point3[3]
Definition: ogsf.h:201
void gsd_color_func(unsigned int col)
Set current color.
Definition: gsd_prim.c:689
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:3286
void GS_set_global_exag(float exag)
Set global z-exag value.
Definition: gs2.c:1978
void free(void *)
int GS_set_att_const(int id, int att, float constant)
Set attribute constant.
Definition: gs2.c:1413
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
#define NULL
Definition: ccmath.h:32
double GS_get_aspect(void)
Get aspect value.
Definition: gs2.c:3453
int GS_draw_legend(const char *name, GLuint fontbase, int size, int *flags, float *range, int *pt)
Draw legend.
Definition: gs2.c:849
#define GSD_BOTH
Definition: ogsf.h:103
int GS_update_curmask(int id)
Update current mask.
Definition: gs2.c:998
#define x
#define max(x, y)
Definition: draw2.c:32
void gs_set_defaults(geosurf *gs, float *defs, float *null_defs)
Set default attribute values.
Definition: gs.c:441
void GS_init_rotation(void)
Reset scene rotation.
Definition: gs2.c:2910
void gs_init(void)
Initialize library.
Definition: gs.c:47
void Gs_pack_colors(const char *filename, int *buff, int rows, int cols)
Pack color table.
Definition: gs3.c:636
void GS_moveto(float *pt)
Move viewpoint.
Definition: gs2.c:2618
#define MAX_SURFS
Definition: ogsf.h:38
int GS_surf_exists(int id)
Definition: gs2.c:195
void GS_set_focus(float *realto)
Set focus.
Definition: gs2.c:2521
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
void GS_get_from_real(float *fr)
Get viewpoint &#39;from&#39; real coordinates.
Definition: gs2.c:2740
void GS_get_dims(int id, int *rows, int *cols)
Get dimension of surface.
Definition: gs2.c:2280
int GS_setall_drawmode(int mode)
Set all draw-modes.
Definition: gs2.c:2062
int gs_set_att_type(geosurf *gs, int desc, int type)
Set attribute type.
Definition: gs.c:803
int GS_v2norm(float *v1)
Change v1 so that it is a unit vector (3D)
Definition: gs_util.c:271
int GS_get_twist(void)
Get twist value.
Definition: gs2.c:2866
float z_exag
Definition: ogsf.h:266
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
Definition: gis/error.c:159
#define VYRES(gs)
Definition: rowcol.h:10
#define W
Definition: ogsf.h:140
#define ATTY_SHORT
Definition: ogsf.h:167
void gsd_real2surf(geosurf *gs, Point3 point)
Convert real to surface coordinates.
Definition: gsd_views.c:480
int GS_get_focus(float *realto)
Get focus.
Definition: gs2.c:2564
double top
Extent coordinates (top) - 3D data.
Definition: gis.h:444
void gsd_real2model(Point3 point)
Convert real to model coordinates.
Definition: gsd_views.c:373
void GS_set_infocus(void)
Set focus.
Definition: gs2.c:2968
void GS_set_nofocus(void)
Unset focus.
Definition: gs2.c:2954
void GS_switchlight(int num, int on)
Switch on/off light.
Definition: gs2.c:474
geosurf * gsdiff_get_SDref(void)
ADD.
Definition: gsdiff.c:77
void gsd_pushmatrix(void)
Push the current matrix stack.
Definition: gsd_prim.c:498
#define INT_TO_GRN(i, g)
Definition: gsd_prim.c:44
#define FC_GREY
Definition: ogsf.h:110
int cols
Definition: ogsf.h:260
void GS_set_light_reset(int i)
Definition: gs2.c:253
void GS_unset_rotation(void)
Stop scene rotation.
Definition: gs2.c:2902
int * lookup
Definition: ogsf.h:252
double t
Definition: r_raster.c:39
void gsd_backface(int n)
ADD.
Definition: gsd_prim.c:244
IFLAG draw_mode
Definition: ogsf.h:262
int gsd_surf(geosurf *surf)
ADD.
Definition: gsd_surf.c:81
void Rast_get_cellhd(const char *name, const char *mapset, struct Cell_head *cellhd)
Read the raster header.
Definition: get_cellhd.c:44
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:1184
double north
Extent coordinates (north)
Definition: gis.h:436
int GS_set_SDsurf(int id)
Set surface as Scaled Difference surface.
Definition: gs2.c:1050
void GS_set_viewport(int left, int right, int bottom, int top)
Set viewport.
Definition: gs2.c:2982
char * gsds_get_name(int id)
Get name.
Definition: gsds.c:303
void * clientdata
Definition: ogsf.h:277
int GS_update_normals(int id)
Update normals.
Definition: gs2.c:1120
void gv_update_drapesurfs(void)
Update drape surfaces.
Definition: gv.c:154
#define ATTY_FLOAT
Definition: ogsf.h:165
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:1247
typbuff * gs_get_att_typbuff(geosurf *gs, int desc, int to_write)
Get attribute data buffer.
Definition: gs.c:681
struct georot rotate
Definition: ogsf.h:484
int x_mod
Definition: ogsf.h:271
void GS_draw_X(int id, float *pt)
Draw place marker.
Definition: gs2.c:640
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:517
void GS_set_twist(int t)
Set viewpoint twist value.
Definition: gs2.c:2878
double b
Definition: r_raster.c:39
int norm_needupdate
Definition: ogsf.h:273
#define ST_GYRO
Definition: ogsf.h:97
int gsds_free_data_buff(int id, int typ)
Free allocated buffer.
Definition: gsds.c:369
float x_trans
Definition: ogsf.h:267
#define ATTY_INT
Definition: ogsf.h:166
void GS_v3mult(float *v1, float k)
Multiple vectors.
Definition: gs_util.c:229
#define Y2VROW(gs, py)
Definition: rowcol.h:27
#define FALSE
Definition: gis.h:53
#define X2VCOL(gs, px)
Definition: rowcol.h:28
void GS_getlight_ambient(int num, float *red, float *green, float *blue)
Get light ambient.
Definition: gs2.c:425
int GS_setall_drawres(int xres, int yres, int xwire, int ywire)
Set all draw resolutions.
Definition: gs2.c:2199
double south
Extent coordinates (south)
Definition: gis.h:438
int gs_setlos_enterdata(Point3 *los)
Definition: gs_query.c:529
int fov
Definition: ogsf.h:485
int gs_num_surfaces(void)
Get number of surfaces.
Definition: gs.c:127
void gsd_switchlight(int num, int on)
Switch light on/off.
Definition: gsd_prim.c:868
#define DM_POLY
Definition: ogsf.h:61
Definition: ogsf.h:478
void GS_delete_list(GLuint list_id)
Delete pre-defined list.
Definition: gs2.c:892
int gs_los_intersect1(int surfid, float(*los)[3], float *point)
Crude method of intersecting line of sight with closest part of surface.
Definition: gs_query.c:52
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
float zmin_nz
Definition: ogsf.h:270
#define MAP_ATT
Definition: ogsf.h:83
int nz_topo
Definition: ogsf.h:272
int GS_new_light(void)
Add new model light.
Definition: gs2.c:269
int y_mod
Definition: ogsf.h:271
#define DM_GOURAUD
Definition: ogsf.h:54
int hdata
Definition: ogsf.h:249
#define INT_TO_BLU(i, b)
Definition: gsd_prim.c:45
void GS_set_cplane_trans(int num, float dx, float dy, float dz)
Set cplace trans.
Definition: gs2.c:3136
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
#define ATT_COLOR
Definition: ogsf.h:74
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_set_wire_color(int id, int colr)
Set wire color.
Definition: gs2.c:2015
int GS_get_region(float *n, float *s, float *w, float *e)
Get 2D region extent.
Definition: gs2.c:157
void GS_clear(int col)
Clear view.
Definition: gs2.c:3419
int GS_num_surfs(void)
Get number of surfaces.
Definition: gs2.c:1525
int gs_getall_surfaces(geosurf **gsurfs)
Get array of geosurf structs.
Definition: gs.c:108
double bottom
Extent coordinates (bottom) - 3D data.
Definition: gis.h:446
void gsd_swapbuffers(void)
Swap buffers.
Definition: gsd_prim.c:474
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:705
void GS_set_att_defaults(float *defs, float *null_defs)
Set default attributes for map objects.
Definition: gs2.c:173
int GS_get_longdim(float *dim)
Get largest dimension.
Definition: gs2.c:141
float vert_exag
Definition: ogsf.h:486
void gsd_draw_cplane_fence(geosurf *surf1, geosurf *surf2, int cpnum)
ADD.
Definition: gsd_cplane.c:247
int GS_set_drawmode(int id, int mode)
Set draw mode.
Definition: gs2.c:2084
#define FROM
Definition: ogsf.h:141
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:178
#define CM_AD
Definition: ogsf.h:150
int GS_get_drawmode(int id, int *mode)
Get draw mode.
Definition: gs2.c:2110
int gsd_nline_onsurf(geosurf *gs, float *v1, float *v2, float *pt, int n)
Multiline on surface, fix z-values.
Definition: gsd_objs.c:235
unsigned int GS_background_color(void)
Get background color.
Definition: gs2.c:2453
void gsd_backbuffer(void)
Specify which color buffers are to be drawn into.
Definition: gsd_prim.c:464
void GS_draw_fringe(int id, unsigned long clr, float elev, int *where)
Draw fringe around data (surface) at selected corners.
Definition: gs2.c:824
int do_rot
Definition: ogsf.h:472
#define Z
Definition: ogsf.h:139
void GS_get_viewdir(float *dir)
Get viewdir.
Definition: gs2.c:2810
void gsd_model2real(Point3 point)
Convert model to real coordinates.
Definition: gsd_views.c:393
int gs_get_zextents(geosurf *gs, float *min, float *max, float *mid)
Get z-extent values.
Definition: gs.c:998
double oy
Definition: ogsf.h:264
void GS_init_view(void)
Init viewpoint.
Definition: gs2.c:3348
int GS_is_masked(int id, float *pt)
Check if point is masked ?
Definition: gs2.c:1016
gsurf_att att[MAX_ATTS]
Definition: ogsf.h:261
void GS_set_cplane_rot(int num, float dx, float dy, float dz)
Set cplace rotation.
Definition: gs2.c:3123
int y_modw
Definition: ogsf.h:271
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
int mask_needupdate
Definition: ogsf.h:273
int GS_get_att(int id, int att, int *set, float *constant, char *mapname)
Get attributes.
Definition: gs2.c:1141
int _viewcell_tri_interp(geosurf *gs, Point3 pt)
ADD.
Definition: gsdrape.c:467
float shine
Definition: ogsf.h:467
int Gs_get_cat_label(const char *filename, int drow, int dcol, char *catstr)
Get categories/labels.
Definition: gs3.c:776
int GS_load_att_map(int id, const char *filename, int att)
Load raster map as attribute.
Definition: gs2.c:1609
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:189
void(* Cxl_func)()
Definition: gsx.c:21
#define DM_WIRE
Definition: ogsf.h:59
void gsd_setfc(int mode)
ADD.
Definition: gsd_surf.c:1208
#define GSD_BACK
Definition: ogsf.h:102
float y_trans
Definition: ogsf.h:267
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
void GS_set_focus_center_map(int id)
Set focus to map center.
Definition: gs2.c:2583
int gs_malloc_lookup(geosurf *gs, int desc)
Allocate attribute lookup.
Definition: gs.c:746
#define Y
Definition: ogsf.h:138
void GS_draw_cplane(int num)
Draw cplace.
Definition: gs2.c:3149
float xmin
Definition: ogsf.h:268
GLuint gsd_put_legend(const char *name, GLuint fontbase, int size, int *flags, float *rangef, int *pt)
Put legend.
Definition: gsd_legend.c:202
#define ATTY_MASK
Definition: ogsf.h:164
#define CF_COLOR_PACKED
Definition: ogsf.h:180
void gsd_init_lightmodel(void)
Initialize model light.
Definition: gsd_prim.c:710
float GS_global_exag(void)
Get global z-exag value.
Definition: gs2.c:2000
geosurf * gs_get_surf(int id)
Get geosurf struct.
Definition: gs.c:62
int cols
Number of columns for 2D data.
Definition: gis.h:409
void GS_unset_cplane(int num)
Unset clip place (turn off)
Definition: gs2.c:3228
void GS_set_draw(int where)
Sets which buffer to draw to.
Definition: gs2.c:2463
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:312
void GS_get_zrange_nz(float *min, float *max)
Get Z extents for all loaded surfaces.
Definition: gs2.c:2358
void GS_set_rotation_matrix(double *matrix)
Set rotation matrix.
Definition: gs2.c:2942
void GS_draw_surf(int id)
Draw surface.
Definition: gs2.c:1865
int infocus
Definition: ogsf.h:482
double ns_res
Resolution - north to south cell size for 2D data.
Definition: gis.h:430
#define ATT_TRANSP
Definition: ogsf.h:76
int gsurf_id
Definition: ogsf.h:259
void GS_draw_lighting_model(void)
Draw lighting model.
Definition: gs2.c:942
float ymax
Definition: ogsf.h:268
void G_get_set_window(struct Cell_head *window)
Get the current working window (region)
void GS_lights_off(void)
Switch off all lights.
Definition: gs2.c:443
void GS_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
Get translation values (surface position)
Definition: gs2.c:2416
Definition: ogsf.h:204
void GS_v3eq(float *v1, float *v2)
Copy vector values.
Definition: gs_util.c:178
int gs_get_att_src(geosurf *gs, int desc)
Get attribute source.
Definition: gs.c:656
void GS_alldraw_surf(void)
Draw all surfaces.
Definition: gs2.c:1937
float real_to[4]
Definition: ogsf.h:486
void gsd_linewidth(short n)
Set width of rasterized lines.
Definition: gsd_prim.c:257
void GS_set_exag(int id, float exag)
Set Z exag for surface.
Definition: gs2.c:1954
void GS_alldraw_wire(void)
Draw all wires.
Definition: gs2.c:1920
int Gs_load_3dview(const char *vname, geoview *gv, geodisplay *gd, struct Cell_head *w, geosurf *defsurf)
Load 3dview.
Definition: gs3.c:951
void GS_setlight_ambient(int num, float red, float green, float blue)
Set light ambient.
Definition: gs2.c:403
void GS_set_fov(int fov)
Set field of view.
Definition: gs2.c:2844
float color[3]
Definition: ogsf.h:464
#define GSD_FRONT
Definition: ogsf.h:101
#define VCOL2DCOL(gs, vcol)
Definition: rowcol.h:32
float farclip
Definition: ogsf.h:493
int GS_delete_surface(int id)
Delete surface.
Definition: gs2.c:1567
#define TO
Definition: ogsf.h:142
int GS_transp_is_set(void)
Check if transparency is set.
Definition: gs2.c:493
double east
Extent coordinates (east)
Definition: gis.h:440
void gsd_flush(void)
Mostly for flushing drawing commands accross a network.
Definition: gsd_prim.c:74
float position[4]
Definition: ogsf.h:463
#define ATTY_NULL
Definition: ogsf.h:163
void gpd_obj(geosurf *gs, gvstyle *style, Point3 pt)
Draw point representing object.
Definition: gpd.c:71
#define _(str)
Definition: glocale.h:13
int GS_set_drawres(int id, int xres, int yres, int xwire, int ywire)
Set draw resolution for surface.
Definition: gs2.c:2222
char * G_fully_qualified_name(const char *name, const char *mapset)
Get fully qualified element name.
Definition: nme_in_mps.c:101
const char * G_find_raster2(const char *name, const char *mapset)
Find a raster map (look but don&#39;t touch)
Definition: find_rast.c:76
#define X
Definition: ogsf.h:137
void gsd_popmatrix(void)
Pop the current matrix stack.
Definition: gsd_prim.c:488
void gsd_bothbuffers(void)
ADD.
Definition: gsd_prim.c:436
void GS_set_cplane(int num)
Set cplace.
Definition: gs2.c:3216
#define FNORM(i, nv)
Definition: gsget.h:50
int gs_init_normbuff(geosurf *gs)
Init geosurf normbuff.
Definition: gs.c:306
long num
Definition: raster3d/cats.c:85
float zmax
Definition: ogsf.h:268
int Gs_numtype(const char *filename, int *negflag)
Get map data type.
Definition: gs3.c:230
#define MAX_ATTS
Definition: ogsf.h:43
geosurf * gs_get_new_surface(void)
Allocate new geosurf struct.
Definition: gs.c:193
void GS_draw_line_onsurf(int id, float x1, float y1, float x2, float y2)
Draw line on surface.
Definition: gs2.c:681
int symbol
Definition: ogsf.h:289
char buff[1024]
Definition: raster3d/cats.c:81
int
Reads the categories file for map name in mapset and stores the categories in the pcats structure...
void gsd_display_fringe(geosurf *surf, unsigned long clr, float elev, int where[4])
Display fridge.
Definition: gsd_fringe.c:51
void GS_get_modelposition1(float pos[])
Retrieves coordinates for lighting model position, at center of view.
Definition: gs2.c:503
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
#define ATT_MASK
Definition: ogsf.h:75
void gsd_cplane_on(int num)
ADD.
Definition: gsd_cplane.c:104
const char * name
Definition: named_colr.c:7
int GS_get_fencecolor(void)
Get fence color.
Definition: gs2.c:3269
float GS_distance(float *from, float *to)
Calculate distance.
Definition: gs_util.c:141
void GS_get_to_real(float *to)
Get &#39;to&#39; real coordinates.
Definition: gs2.c:2753
int Gs_save_3dview(const char *vname, geoview *gv, geodisplay *gd, struct Cell_head *w, geosurf *defsurf)
Save 3dview.
Definition: gs3.c:853
double ew_res
Resolution - east to west cell size for 2D data.
Definition: gis.h:426
#define VROW2DROW(gs, vrow)
Definition: rowcol.h:31
int x_modw
Definition: ogsf.h:271
void gsd_frontbuffer(void)
Specify which color buffers are to be drawn into.
Definition: gsd_prim.c:450
int GS_coordpair_repeats(float *p1, float *p2, int nhist)
ADD.
Definition: gs_util.c:443
void gsd_deflight(int num, struct lightdefs *vals)
Define light.
Definition: gsd_prim.c:827
int GS_has_transparency(void)
Check for transparency.
Definition: gs2.c:3481
void GS_lights_on(void)
Switch on all lights.
Definition: gs2.c:457
float z_trans
Definition: ogsf.h:267
int gsds_newh(const char *name)
Get handle to gsds.
Definition: gsds.c:219
int GS_get_SDsurf(int *id)
Get ?
Definition: gs2.c:1086
void GS_setlight_color(int num, float red, float green, float blue)
Set light color.
Definition: gs2.c:359
struct BM * nm
Definition: ogsf.h:211
int GS_unset_att(int id, int att)
Unset attribute.
Definition: gs2.c:1394
int gsds_set_changed(int id, IFLAG reason)
ADD.
Definition: gsds.c:635
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
#define CONST_ATT
Definition: ogsf.h:84
int rows
Number of rows for 2D data.
Definition: gis.h:405
int GS_get_nozero(int id, int att, int *mode)
Get no-zero ?
Definition: gs2.c:2165
float * fb
Definition: ogsf.h:206
void void_func(void)
Definition: gs2.c:85
int GS_get_light_reset(void)
Definition: gs2.c:259
void GS_unset_SDsurf(void)
Unset Scaled Difference surface.
Definition: gs2.c:1034
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
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:1311
int twist
Definition: ogsf.h:485
Definition: ogsf.h:257
struct BM * bm
Definition: ogsf.h:210
int gsd_getViewport(GLint *, GLint *)
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition: gis/error.c:203
float constant
Definition: ogsf.h:251
double r
Definition: r_raster.c:39
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:719
int gs_update_curmask(geosurf *surf)
Update current maps.
Definition: gs_bm.c:232
unsigned char * cb
Definition: ogsf.h:209
void gsd_drawsphere(float *center, unsigned long colr, float siz)
Draw sphere.
Definition: gsd_objs.c:565
float from_to[2][4]
Definition: ogsf.h:483
int * GS_get_surf_list(int *numsurfs)
Get surface list.
Definition: gs2.c:1540
int nz_color
Definition: ogsf.h:272
void GS_done_draw(void)
Draw done, swap buffers.
Definition: gs2.c:2502
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:3006
double rot_axes[3]
Definition: ogsf.h:474
void gsd_draw_cplane(int num)
Draw cplane.
Definition: gsd_cplane.c:296
void GS_libinit(void)
Initialize OGSF library.
Definition: gs2.c:97
struct lightdefs lights[MAX_LIGHTS]
Definition: ogsf.h:488
#define GET_MAPATT(buff, offset, att)
Definition: gsget.h:27