-rw-r--r-- | src/controller/actions/set_ortho.c | 13 | ||||
-rw-r--r-- | src/controller/actions/zoom.c | 70 | ||||
-rw-r--r-- | src/controller/actions/zoom.h | 4 | ||||
-rw-r--r-- | src/controller/callbacks/display.c | 6 | ||||
-rw-r--r-- | src/controller/callbacks/keyboard.c | 7 | ||||
-rw-r--r-- | src/controller/callbacks/mouse.c | 49 | ||||
-rw-r--r-- | src/controller/callbacks/mouse_wheel.c | 66 | ||||
-rw-r--r-- | src/controller/callbacks/reshape.c | 68 | ||||
-rw-r--r-- | src/model/geometry/density_legend_geometry.c | 18 | ||||
-rw-r--r-- | src/model/state/zoom_info.h | 1 | ||||
-rw-r--r-- | src/model/state/zoom_info_init.c | 6 |
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 state0 | 11 | #define S state0 |
12 | 12 | ||
13 | void | 13 | void |
14 | zoom (int x1, int y1, int x2, int y2) | 14 | zoom (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 to | 24 | * 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 (); |