summaryrefslogtreecommitdiffstats
Unidiff
-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/actions/zoom.c b/src/controller/actions/zoom.c
index b8e54cc..7209e85 100644
--- a/src/controller/actions/zoom.c
+++ b/src/controller/actions/zoom.c
@@ -11,52 +11,40 @@
11#define S state011#define S state0
1212
13void13void
14zoom (int x1, int y1, int x2, int y2)14zoom (double x1, double y1, double x2, double y2)
15{15{
16 S.zoom.active = true;
17
18 S.zoom.coords[0] = x1;
19 S.zoom.coords[1] = x2;
20 S.zoom.coords[2] = y1;
21 S.zoom.coords[3] = y2;
22
16 /*23 /*
17 * Convert the selection boundary from window coordinates to24 * Preserve the aspect ratio. First convert the selection to the
18 * world coordinates.25 * aspect ratio of the original geometry. The world is a square so
26 * convert the zoom region to a square. The reshape callback
27 * performs step two of converting the squarified zoom region to the
28 * aspect ratio of the window. This is done in reshape as the window
29 * may change while the zoom region is held the same.
19 */30 */
20 glMatrixMode (GL_MODELVIEW);31 double width = S.zoom.coords[1] - S.zoom.coords[0];
21 glLoadIdentity ();32 double height = S.zoom.coords[3] - S.zoom.coords[2];
22 GLdouble model[16];33 double difference = fabs(width - height);
23 glGetDoublev (GL_MODELVIEW_MATRIX, model);34
24 GLdouble projection[16];35 if (width > height)
25 glGetDoublev (GL_PROJECTION_MATRIX, projection);36 {
37 S.zoom.coords[2] -= 0.5 * difference;
38 S.zoom.coords[3] += 0.5 * difference;
39 }
40 else
41 {
42 S.zoom.coords[0] -= 0.5 * difference;
43 S.zoom.coords[1] += 0.5 * difference;
44 }
45
26 GLint viewport[4];46 GLint viewport[4];
27 glGetIntegerv (GL_VIEWPORT, viewport);47 glGetIntegerv (GL_VIEWPORT, viewport);
28
29 check_error (__FILE__, __LINE__);
30
31 GLdouble start_position[3];
32 gluUnProject (x1,
33 y1,
34 0,
35 model,
36 projection,
37 viewport,
38 &start_position[0],
39 &start_position[1], &start_position[2]);
40
41 check_error (__FILE__, __LINE__);
42
43 GLdouble end_position[3];
44 gluUnProject (x2,
45 y2,
46 0,
47 model,
48 projection,
49 viewport,
50 &end_position[0], &end_position[1], &end_position[2]);
51
52 check_error (__FILE__, __LINE__);
53
54 S.zoom.active = true;
55 S.zoom.coords[0] = fmin (start_position[0], end_position[0]);
56 S.zoom.coords[1] = fmax (start_position[0], end_position[0]);
57 S.zoom.coords[2] = fmin (start_position[1], end_position[1]);
58 S.zoom.coords[3] = fmax (start_position[1], end_position[1]);
59
60 reshape (viewport[2], viewport[3]);48 reshape (viewport[2], viewport[3]);
61 49
62 glutPostRedisplay ();50 glutPostRedisplay ();

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.