-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/callbacks/reshape.c b/src/controller/callbacks/reshape.c index 2455ea3..fec5443 100644 --- a/src/controller/callbacks/reshape.c +++ b/src/controller/callbacks/reshape.c | |||
@@ -3,6 +3,8 @@ | |||
3 | #include "../actions/set_ortho.h" | 3 | #include "../actions/set_ortho.h" |
4 | #include "reshape.h" | 4 | #include "reshape.h" |
5 | #include <GL/glut.h> | 5 | #include <GL/glut.h> |
6 | #include <math.h> | ||
7 | #include <stdio.h> | ||
6 | 8 | ||
7 | #define S state0 | 9 | #define S state0 |
8 | 10 | ||
@@ -13,26 +15,60 @@ reshape (int w, int h) | |||
13 | glLoadIdentity (); | 15 | glLoadIdentity (); |
14 | 16 | ||
15 | /* | 17 | /* |
16 | * This scaling produces an odd effect when the coordinates are not | 18 | * Scale the zoom region to the aspect ratio of the window. |
17 | * centered at 0,0. When 0,0 is the lower left rather than the | ||
18 | * center this reshape is a bit unnatural since the image is not | ||
19 | * centered in the middle of the window. | ||
20 | */ | 19 | */ |
21 | 20 | if (S.zoom.active) | |
22 | if (w <= h) | ||
23 | { | 21 | { |
24 | S.ortho.min_x = S.ortho_min; | 22 | if (w >= h) |
25 | S.ortho.max_x = S.ortho_max; | 23 | { |
26 | S.ortho.min_y = S.ortho_min * (double) h / (double) w; | 24 | double scale |
27 | S.ortho.max_y = S.ortho_max * (double) h / (double) w; | 25 | = ( ( (S.zoom.coords[1] - S.zoom.coords[0]) * ((double) w / (double) h) ) |
26 | - (S.zoom.coords[1] - S.zoom.coords[0]) ) | ||
27 | * 0.5; | ||
28 | |||
29 | S.ortho.min_x = S.zoom.coords[0] - scale; | ||
30 | S.ortho.max_x = S.zoom.coords[1] + scale; | ||
31 | S.ortho.min_y = S.zoom.coords[2]; | ||
32 | S.ortho.max_y = S.zoom.coords[3]; | ||
33 | } | ||
34 | else | ||
35 | { | ||
36 | double scale | ||
37 | = ( ( (S.zoom.coords[3] - S.zoom.coords[2]) * ((double) h / (double) w) ) | ||
38 | - (S.zoom.coords[3] - S.zoom.coords[2]) ) | ||
39 | * 0.5; | ||
40 | |||
41 | S.ortho.min_x = S.zoom.coords[0]; | ||
42 | S.ortho.max_x = S.zoom.coords[1]; | ||
43 | S.ortho.min_y = S.zoom.coords[2] - scale; | ||
44 | S.ortho.max_y = S.zoom.coords[3] + scale; | ||
45 | } | ||
28 | } | 46 | } |
29 | else | 47 | |
48 | else | ||
30 | { | 49 | { |
31 | S.ortho.min_x = S.ortho_min * (double) w / (double) h; | 50 | /* |
32 | S.ortho.max_x = S.ortho_max * (double) w / (double) h; | 51 | * This scaling produces an odd effect when the coordinates are |
33 | S.ortho.min_y = S.ortho_min; | 52 | * not centered at 0,0. When 0,0 is the lower left rather than |
34 | S.ortho.max_y = S.ortho_max; | 53 | * the center this reshape is a bit unnatural since the image is |
35 | } | 54 | * not centered in the middle of the window. Try chaning this |
55 | * to use the method used above for the zoom region scaling. | ||
56 | */ | ||
57 | if (w <= h) | ||
58 | { | ||
59 | S.ortho.min_x = S.ortho_min; | ||
60 | S.ortho.max_x = S.ortho_max; | ||
61 | S.ortho.min_y = S.ortho_min * (double) h / (double) w; | ||
62 | S.ortho.max_y = S.ortho_max * (double) h / (double) w; | ||
63 | } | ||
64 | else | ||
65 | { | ||
66 | S.ortho.min_x = S.ortho_min * (double) w / (double) h; | ||
67 | S.ortho.max_x = S.ortho_max * (double) w / (double) h; | ||
68 | S.ortho.min_y = S.ortho_min; | ||
69 | S.ortho.max_y = S.ortho_max; | ||
70 | } | ||
71 | } | ||
36 | 72 | ||
37 | set_ortho (); | 73 | set_ortho (); |
38 | 74 | ||