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/callbacks/mouse_wheel.c b/src/controller/callbacks/mouse_wheel.c
index 52d3c8b..9ca73bc 100644
--- a/src/controller/callbacks/mouse_wheel.c
+++ b/src/controller/callbacks/mouse_wheel.c
@@ -1,44 +1,74 @@
1#include "mouse_wheel.h"1#include "mouse_wheel.h"
2#include "../actions/zoom.h"2#include "../actions/zoom.h"
3#include "../../view/state0.h"
3#include <GL/glut.h>4#include <GL/glut.h>
5#include <math.h>
6
7#define S state0
48
5void 9void
6mouse_wheel (int button, int dir, int x, int y)10mouse_wheel (int button, int dir, int x, int y)
7{11{
8 /*12 /*
9 * Get the current coordinates, substract some fixed amount and13 * Start at the origin of the window. An alternative would be to
10 * then perform the zoom.14 * start at the position of the mouse. Calculate a bounding box
15 * that will be the selection and zoom to it.
11 */16 */
12 GLint viewport[4];17 double width = fabs(S.ortho.max_x - S.ortho.min_x);
13 glGetIntegerv (GL_VIEWPORT, viewport);18 double height = fabs(S.ortho.max_y - S.ortho.min_y);
1419
15 /*20 /*
16 * The step size could be either a fixed number of pixels or a percentage.21 * Box the smaller of the two dimensions.
17 */22 */
18 // int step = 5;23 double box = 0.0;
19 int step = (viewport[3] - viewport[1]) * 0.10;24 if (width <= height)
25 box = width;
26 else
27 box = height;
2028
21 /*29 /*
22 * Not that the focus of the zoom is currently the center of the30 * The step size could be either a fixed number of pixels or a
23 * window but could alternatively be the mouse pointer's position.31 * percentage. Here we take 10% of the size of the box.
24 */32 */
33 double step = box * 0.10;
34
35 double x1 = 0.0;
36 double y1 = 0.0;
37 double x2 = 0.0;
38 double y2 = 0.0;
39
40 if (width < height)
41 {
42 x1 = S.ortho.min_x;
43 x2 = S.ortho.max_x;
44 y1 = ((S.ortho.max_y + S.ortho.min_y) / 2.0) - (0.5 * width);
45 y2 = ((S.ortho.max_y + S.ortho.min_y) / 2.0) + (0.5 * width);
46 }
47 else if (width > height)
48 {
49 x1 = ((S.ortho.max_x + S.ortho.min_x) / 2.0) - (0.5 * height);
50 x2 = ((S.ortho.max_x + S.ortho.min_x) / 2.0) + (0.5 * height);
51 y1 = S.ortho.min_y;
52 y2 = S.ortho.max_y;
53 }
54 else
55 {
56 x1 = S.ortho.min_x;
57 x2 = S.ortho.max_x;
58 y1 = S.ortho.min_y;
59 y2 = S.ortho.max_y;
60 }
2561
26 // Zoom in62 // Zoom in
27 if (dir > 0)63 if (dir > 0)
28 {64 {
29 zoom (step,65 zoom (x1 + step, y1 + step, x2 - step, y2 - step);
30 step,
31 viewport[3] - step,
32 viewport[3] - step);
33 }66 }
3467
35 // Zoom out68 // Zoom out
36 else69 else
37 {70 {
38 zoom (-step,71 zoom (x1 - step, y1 - step, x2 + step, y2 + step);
39 -step,
40 viewport[3] + step,
41 viewport[3] + step);
42 }72 }
4373
44 return;74 return;

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.