27 files changed, 179 insertions, 549 deletions
diff --git a/src/controller/actions/pan.c b/src/controller/actions/pan.c index cdc5cad..2f856b0 100644 --- a/src/controller/actions/pan.c +++ b/src/controller/actions/pan.c | |||
@@ -1,8 +1,61 @@ | |||
1 | #include "pan.h" | 1 | #include "pan.h" |
2 | #include "../../util/check_error.h" | ||
3 | #include "../../view/state0.h" | ||
4 | #include <GL/glut.h> | ||
5 | |||
6 | #define S state0 | ||
2 | 7 | ||
3 | void | 8 | void |
4 | pan () | 9 | pan (int x1, int y1, int x2, int y2) |
5 | { | 10 | { |
6 | 11 | int dx = x1 - x2; | |
12 | int dy = y1 - x2; | ||
13 | |||
14 | if (dx == 0 && dy == 0) | ||
15 | return; | ||
16 | |||
17 | /* | ||
18 | * Convert the selection boundary from window coordinates to | ||
19 | * world coordinates. | ||
20 | */ | ||
21 | glMatrixMode (GL_MODELVIEW); | ||
22 | glLoadIdentity (); | ||
23 | GLdouble model[16]; | ||
24 | glGetDoublev (GL_MODELVIEW_MATRIX, model); | ||
25 | GLdouble projection[16]; | ||
26 | glGetDoublev (GL_PROJECTION_MATRIX, projection); | ||
27 | GLint viewport[4]; | ||
28 | glGetIntegerv (GL_VIEWPORT, viewport); | ||
29 | |||
30 | check_error (__FILE__, __LINE__); | ||
31 | |||
32 | GLdouble start_position[3]; | ||
33 | gluUnProject (x1, | ||
34 | y1, | ||
35 | 0, | ||
36 | model, | ||
37 | projection, | ||
38 | viewport, | ||
39 | &start_position[0], | ||
40 | &start_position[1], &start_position[2]); | ||
41 | |||
42 | check_error (__FILE__, __LINE__); | ||
43 | |||
44 | GLdouble end_position[3]; | ||
45 | gluUnProject (x2, | ||
46 | y2, | ||
47 | 0, | ||
48 | model, | ||
49 | projection, | ||
50 | viewport, | ||
51 | &end_position[0], &end_position[1], &end_position[2]); | ||
52 | |||
53 | check_error (__FILE__, __LINE__); | ||
54 | |||
55 | S.pan.trans[0] += end_position[0] - start_position[0]; | ||
56 | S.pan.trans[1] -= end_position[1] - start_position[1]; | ||
57 | |||
58 | glutPostRedisplay (); | ||
59 | |||
7 | return; | 60 | return; |
8 | } | 61 | } |