17 #include <grass/glocale.h>
18 #include <grass/nviz.h>
35 if (width < 1 || height < 1) {
41 G_debug(1,
"Nviz_resize_window(): width = %d height = %d", width, height);
62 float zmin, zmax, exag;
71 dc->zrange = dc->xyrange / exag;
79 zmax = zmin + (3. * dc->xyrange / exag);
80 zmin = zmin - (2. * dc->xyrange / exag);
82 if ((zmax - zmin) > dc->zrange)
83 dc->zrange = zmax - zmin;
98 float xpos, ypos, from[3];
102 xpos = (xpos < 0) ? 0 : (xpos > 1.0) ? 1.0 : xpos;
104 ypos = (ypos < 0) ? 0 : (ypos > 1.0) ? 1.0 : ypos;
106 if (x_pos < 0.0 || x_pos > 1.0 || y_pos < 0.0 || y_pos > 1.0) {
107 G_debug(3,
"Invalid view position coordinates, using %f,%f",
111 G_debug(1,
"Nviz_set_viewpoint_position(): x = %f y = %f", x_pos, y_pos);
114 tempx = xpos * RANGE - RANGE_OFFSET;
115 tempy = ypos * RANGE - RANGE_OFFSET;
117 if ((from[
X] != tempx) || (from[
Y] != tempy)) {
136 xpos = (from[
X] + RANGE_OFFSET) / RANGE;
137 ypos = (from[
Y] + RANGE_OFFSET) / RANGE;
139 *x_pos = (*x_pos < 0) ? 0 : (*x_pos > 1.0) ? 1.0 : *x_pos;
141 *y_pos = (*y_pos < 0) ? 0 : (*y_pos > 1.0) ? 1.0 : *y_pos;
143 if (xpos < 0.0 || xpos > 1.0 || ypos < 0.0 || ypos > 1.0) {
144 G_debug(3,
"Invalid view position coordinates, using %f,%f",
145 *x_pos, 1.0 - *y_pos);
161 G_debug(1,
"Nviz_set_viewpoint_height(): value = %f", height);
165 if (height != from[Z]) {
185 G_debug(1,
"Nviz_get_viewpoint_height():");
203 G_debug(1,
"Nviz_set_viewpoint_persp(): value = %d", persp);
205 fov = (
int)(10 * persp);
223 G_debug(1,
"Nviz_set_viewpoint_twist(): value = %d", twist);
243 G_debug(1,
"Nviz_change_exag(): value = %f", exag);
264 G_debug(1,
"Nviz_look_here(): screen coordinates = %f %f", sx, sy);
274 glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
290 G_debug(3,
"Nviz_set_rotation(): angle = %f, x = %f, y = %f, z = %f", angle, x, y, z);
324 float dir[3], from[4], cur_from[4], cur_dir[4];
325 float speed,
h, p, sh, ch, sp, cp;
326 float diff_x, diff_y, diff_z;
334 p = asin(cur_dir[Z]);
335 h = atan2(- cur_dir[
X], - cur_dir[
Y]);
337 speed = scale[0] * fly_info[0];
339 h += scale[1] * fly_info[1];
341 p -= scale[1] * fly_info[2];
343 h = fmod(h + M_PI, 2 * M_PI) - M_PI;
355 from[
X] = cur_from[
X] + speed * dir[
Y];
356 from[
Y] = cur_from[
Y] - speed * dir[
X];
357 from[Z] = cur_from[Z] + scale[0] * fly_info[2];
360 from[
X] = cur_from[
X] + speed * dir[
X];
361 from[
Y] = cur_from[
Y] + speed * dir[
Y];
363 from[Z] = cur_from[Z];
366 diff_x = fabs(cur_dir[X] - dir[X]);
367 diff_y = fabs(cur_dir[Y] - dir[Y]);
368 diff_z = fabs(cur_dir[Z] - dir[Z]);
371 (diff_x > quasi_zero) || (diff_y > quasi_zero) ||
372 (diff_z > quasi_zero) || (cur_from[X] != from[X]) ||
373 (cur_from[Y] != from[Y]) || (cur_from[Z] != from[Z])
void GS_set_fov(int fov)
Set field of view.
void GS_set_global_exag(float exag)
Set global z-exag value.
int Nviz_set_viewpoint_height(double height)
Change viewpoint height.
void GS_init_rotation(void)
Reset scene rotation.
void GS_get_from_real(float *fr)
Get viewpoint 'from' real coordinates.
void Nviz_get_viewpoint_position(double *x_pos, double *y_pos)
void GS_done_draw(void)
Draw done, swap buffers.
void GS_get_from(float *fr)
Get viewpoint 'from' position.
int Nviz_resize_window(int width, int height)
GL canvas resized.
int Nviz_update_ranges(nv_data *dc)
Update ranges.
void Nviz_init_rotation(void)
Stop scene rotation.
void GS_set_rotation(double angle, double x, double y, double z)
Set rotation params.
int Nviz_set_viewpoint_persp(int persp)
Change viewpoint perspective (field of view)
void GS_set_viewport(int left, int right, int bottom, int top)
Set viewport.
void Nviz_flythrough(nv_data *data, float *fly_info, int *scale, int lateral)
Fly through the scene.
int Nviz_change_exag(nv_data *data, double exag)
Change z-exag value.
void Nviz_set_rotation(double angle, double x, double y, double z)
Set rotation parameters.
void Nviz_get_modelview(double *modelMatrix)
Get current modelview matrix.
void GS_set_viewdir(float *dir)
Set viewdir.
void GS_moveto(float *pt)
Move viewpoint.
void Nviz_get_viewpoint_height(double *height)
void GS_get_zrange_nz(float *min, float *max)
Get Z extents for all loaded surfaces.
int Nviz_set_viewpoint_twist(int twist)
Change viewpoint twist.
void GS_alldraw_wire(void)
Draw all wires.
void GS_unset_rotation(void)
Stop scene rotation.
int Nviz_look_here(double sx, double sy)
Change focused point.
int Nviz_set_viewpoint_position(double x_pos, double y_pos)
Change position of view.
void GS_set_twist(int t)
Set viewpoint twist value.
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...
int G_debug(int level, const char *msg,...)
Print debugging message.
void GS_get_viewdir(float *dir)
Get viewdir.
int GS_get_longdim(float *dim)
Get largest dimension.
void Nviz_unset_rotation(void)
Stop scene rotation.
void GS_moveto_real(float *pt)
Move position to (real)
float GS_global_exag(void)
Get global z-exag value.
void GS_set_draw(int where)
Sets which buffer to draw to.
tuple h
panel.defaultSize = wx.CheckBox(panel, id = wx.ID_ANY, label = _("Use default size")) panel...