summaryrefslogtreecommitdiffstats
Side-by-side diff
-rw-r--r--src/controller/actions/set_ortho.c13
-rw-r--r--src/controller/actions/zoom.c70
-rw-r--r--src/controller/actions/zoom.h4
-rw-r--r--src/controller/callbacks/display.c6
-rw-r--r--src/controller/callbacks/keyboard.c7
-rw-r--r--src/controller/callbacks/mouse.c49
-rw-r--r--src/controller/callbacks/mouse_wheel.c66
-rw-r--r--src/controller/callbacks/reshape.c68
-rw-r--r--src/model/geometry/density_legend_geometry.c18
-rw-r--r--src/model/state/zoom_info.h1
-rw-r--r--src/model/state/zoom_info_init.c6
11 files changed, 197 insertions, 111 deletions
diff --git a/src/controller/callbacks/mouse.c b/src/controller/callbacks/mouse.c
index f901476..34ff290 100644
--- a/src/controller/callbacks/mouse.c
+++ b/src/controller/callbacks/mouse.c
@@ -25,7 +25,7 @@ mouse (int button, int state, int x, int y)
{
// Deactive a panning event if one was happening.
S.pan.active = false;
-
+
if (S.selection.active &&
S.selection.purpose == ZOOM &&
glutGetModifiers () == GLUT_ACTIVE_CTRL)
@@ -35,14 +35,49 @@ mouse (int button, int state, int x, int y)
*/
if (x == S.selection.x || y == S.selection.y)
return;
-
+
+ /*
+ * Convert the selection boundary from window coordinates to
+ * world coordinates.
+ */
+ glMatrixMode (GL_MODELVIEW);
+ glLoadIdentity ();
+ GLdouble model[16];
+ glGetDoublev (GL_MODELVIEW_MATRIX, model);
+ GLdouble projection[16];
+ glGetDoublev (GL_PROJECTION_MATRIX, projection);
GLint viewport[4];
glGetIntegerv (GL_VIEWPORT, viewport);
-
- zoom (S.selection.x,
- viewport[3] - S.selection.y,
- x,
- viewport[3] - y);
+
+ check_error (__FILE__, __LINE__);
+
+ GLdouble start_position[3];
+ gluUnProject (x,
+ viewport[3] -y,
+ 0,
+ model,
+ projection,
+ viewport,
+ &start_position[0],
+ &start_position[1], &start_position[2]);
+
+ check_error (__FILE__, __LINE__);
+
+ GLdouble end_position[3];
+ gluUnProject (S.selection.x,
+ viewport[3] - S.selection.y,
+ 0,
+ model,
+ projection,
+ viewport,
+ &end_position[0], &end_position[1], &end_position[2]);
+
+ check_error (__FILE__, __LINE__);
+
+ zoom (fmin (start_position[0], end_position[0]),
+ fmin (start_position[1], end_position[1]),
+ fmax (start_position[0], end_position[0]),
+ fmax (start_position[1], end_position[1]));
}
/*

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.