GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 }
int Nviz_get_focus(nv_data *data, float *x, float *y, float *z)
Get focus.
Definition: position.c:119
void Nviz_init_view(nv_data *data)
Definition: position.c:23
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
int Nviz_set_focus_state(int state_flag)
Set focus state.
Definition: position.c:49
#define min(x, y)
Definition: draw2.c:68
void GS_set_focus(float *realto)
Set focus.
Definition: GS2.c:2518
int GVL_num_vols(void)
Get number of loaded volume sets.
Definition: GVL2.c:146
int y
Definition: plot.c:34
#define max(x, y)
Definition: draw2.c:69
int Nviz_set_focus_map(int type, int id)
Set focus based on loaded map.
Definition: position.c:75
int Nviz_set_light_color(nv_data *data, int num, int red, int green, int blue)
Set light color.
Definition: lights.c:87
float Nviz_get_xyrange(nv_data *data)
Get xy range.
Definition: position.c:176
void GS_init_view(void)
Init viewpoint.
Definition: GS2.c:3345
int Nviz_set_light_bright(nv_data *data, int num, double value)
Set light brightness.
Definition: lights.c:63
int Nviz_set_light_ambient(nv_data *data, int num, double value)
Set light ambient.
Definition: lights.c:114
void GS_set_focus_center_map(int id)
Set focus to map center.
Definition: GS2.c:2580
tuple data
float Nviz_get_longdim(nv_data *data)
Get largest dimension.
Definition: position.c:198
tuple id
self.OnVectorSurface(event)
Definition: tools.py:3426
void GS_set_infocus(void)
Set focus.
Definition: GS2.c:2965
void GS_set_nofocus(void)
Unset focus.
Definition: GS2.c:2951
int Nviz_get_zrange(nv_data *data, float *min, float *max)
Get z range.
Definition: position.c:187
void GS_get_zrange_nz(float *min, float *max)
Get Z extents for all loaded surfaces.
Definition: GS2.c:2354
void GVL_set_focus_center_map(int id)
Set focus on map center.
Definition: GVL2.c:473
int GS_get_focus(float *realto)
Get focus.
Definition: GS2.c:2561
int GS_num_surfs(void)
Get number of surfaces.
Definition: GS2.c:1521
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int Nviz_set_light_position(nv_data *data, int num, double x, double y, double z, double w)
Set light position.
Definition: lights.c:27
int Nviz_set_focus(nv_data *data, float x, float y, float z)
Set focus.
Definition: position.c:141
int * GVL_get_vol_list(int *numvols)
Get list of loaded volume sets.
Definition: GVL2.c:161
int GS_get_longdim(float *dim)
Get largest dimension.
Definition: GS2.c:140
int * GS_get_surf_list(int *numsurfs)
Get surface list.
Definition: GS2.c:1536
int Nviz_has_focus(nv_data *data)
Test focus.
Definition: position.c:161