GRASS Programmer's Manual  6.4.3(2013)-r
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
position.c
Go to the documentation of this file.
1 
15 #include <grass/glocale.h>
16 #include <grass/nviz.h>
17 
23 void Nviz_init_view(nv_data * data)
24 {
25  GS_init_view();
26  Nviz_set_focus_state(1); /* center of view */
27 
28  /* set default lights (1 & 2) */
29  Nviz_set_light_position(data, 1, 0.68, -0.68, 0.80, 0.0);
30  Nviz_set_light_bright(data, 1, 0.8);
31  Nviz_set_light_color(data, 1, 255, 255, 255);
32  Nviz_set_light_ambient(data, 1, 0.2);
33  Nviz_set_light_position(data, 2, 0.0, 0.0, 1.0, 0.0);
34  Nviz_set_light_bright(data, 2, 0.5);
35  Nviz_set_light_color(data, 2, 255, 255, 255);
36  Nviz_set_light_ambient(data, 2, 0.3);
37 
38  return;
39 }
40 
49 int Nviz_set_focus_state(int state_flag)
50 {
51  if (state_flag == 1)
52  GS_set_infocus(); /* return center of view */
53  else if (state_flag == 0)
54  GS_set_nofocus(); /* no center of view -- use viewdir */
55  else {
56  G_warning(_("Unable to set focus"));
57  return 0;
58  }
59 
60  return 1;
61 }
62 
75 int Nviz_set_focus_map(int type, int id)
76 {
77  if (GS_num_surfs() < 0 && GVL_num_vols() < 0) {
79  return 0;
80  }
81 
82  if (type == MAP_OBJ_UNDEFINED) {
83  int *surf_list, num_surfs, *vol_list;
84 
85  if (GS_num_surfs() > 0) {
86  surf_list = GS_get_surf_list(&num_surfs);
87  id = surf_list[0];
88  G_free(surf_list);
89 
91  }
92 
93  if (GVL_num_vols() > 0) {
94  vol_list = GVL_get_vol_list(&num_surfs);
95  id = vol_list[0];
96  G_free(vol_list);
97 
99  }
100  return id;
101  }
102 
103  if (type == MAP_OBJ_SURF) {
105  }
106  else if (type == MAP_OBJ_VOL) {
108  }
109 
110  return id;
111 }
112 
119 int Nviz_get_focus(nv_data * data, float *x, float *y, float *z)
120 {
121  float realto[3];
122 
123  /* Get current center */
124  GS_get_focus(realto);
125  *x = realto[0];
126  *y = realto[1];
127  *z = realto[2];
128  /* old nviz code is more complicated and it doesn't work properly, */
129  /* no idea why */
130 
131  return 1;
132 
133 }
134 
141 int Nviz_set_focus(nv_data * data, float x, float y, float z)
142 {
143  float realto[3];
144 
145  realto[0] = x;
146  realto[1] = y;
147  realto[2] = z;
148  GS_set_focus(realto);
149  /* old nviz code is more complicated and it doesn't work properly, */
150  /* no idea why */
151 
152  return 1;
153 
154 }
155 
161 int Nviz_has_focus(nv_data * data)
162 {
163  float realto[3];
164 
165  if (GS_get_focus(realto))
166  return 1;
167  else
168  return 0;
169 }
170 
176 float Nviz_get_xyrange(nv_data * data)
177 {
178  return data->xyrange;
179 }
180 
187 int Nviz_get_zrange(nv_data * data, float *min, float *max)
188 {
189  GS_get_zrange_nz(min, max);
190  return 1;
191 }
192 
198 float Nviz_get_longdim(nv_data * data)
199 {
200  float dim;
201 
202  GS_get_longdim(&dim);
203 
204  return dim;
205 }