-rw-r--r-- | src/controller/clear_selection.h | 6 | ||||
-rw-r--r-- | src/controller/clear_selection.sqc | 45 | ||||
-rw-r--r-- | src/controller/keyboard.c | 28 | ||||
-rw-r--r-- | src/controller/keyboard.h | 6 | ||||
-rw-r--r-- | src/controller/selection_from_db.h | 9 | ||||
-rw-r--r-- | src/controller/selection_from_db.sqc | 21 | ||||
-rw-r--r-- | src/controller/selection_to_db.h | 9 | ||||
-rw-r--r-- | src/controller/selection_to_db.sqc | 38 | ||||
-rw-r--r-- | src/model/exp004base.sqc | 144 | ||||
-rw-r--r-- | src/util/pick_convert.c | 50 | ||||
-rw-r--r-- | src/util/pick_convert.h | 29 |
11 files changed, 385 insertions, 0 deletions
diff --git a/src/model/exp004base.sqc b/src/model/exp004base.sqc new file mode 100644 index 0000000..6189b72 --- a/dev/null +++ b/src/model/exp004base.sqc | |||
@@ -0,0 +1,144 @@ | |||
1 | /* I seem to need this for glGenBuffers as per | ||
2 | http://www.gamedev.net/community/forums/topic.asp?topic_id=422358 */ | ||
3 | #define GL_GLEXT_PROTOTYPES | ||
4 | |||
5 | #include "exp004base.h" | ||
6 | #include "../view/exp004state0.h" | ||
7 | #include <GL/glut.h> | ||
8 | #include <stdio.h> | ||
9 | #include <string.h> | ||
10 | |||
11 | EXEC SQL INCLUDE sqlca; | ||
12 | |||
13 | /* | ||
14 | * A simple alias to make the code more readable. | ||
15 | */ | ||
16 | #define S exp004state0 | ||
17 | |||
18 | void | ||
19 | exp004base (void) | ||
20 | { | ||
21 | EXEC SQL CONNECT TO exp004; | ||
22 | |||
23 | /* | ||
24 | * This implementation can be improved by mapping the video memory | ||
25 | * directly rather than loading into system memory and then copying | ||
26 | * into video memory. | ||
27 | */ | ||
28 | |||
29 | /* | ||
30 | * db2dclgn -d exp004 -t coordinates | ||
31 | */ | ||
32 | EXEC SQL BEGIN DECLARE SECTION; | ||
33 | EXEC SQL INCLUDE 'model/coordinates.h'; | ||
34 | EXEC SQL END DECLARE SECTION; | ||
35 | |||
36 | EXEC SQL DECLARE c2 CURSOR FOR | ||
37 | SELECT * FROM coordinates; | ||
38 | |||
39 | EXEC SQL OPEN c2; | ||
40 | |||
41 | /* | ||
42 | FILE* coords = | ||
43 | fopen ("/home/don/exp004/test/run20090514/run20090514.coords", "r"); | ||
44 | int i = 0; | ||
45 | */ | ||
46 | |||
47 | /* | ||
48 | * Initialize the bounding box of the points. | ||
49 | */ | ||
50 | S.bb.min_x = 0.0; | ||
51 | S.bb.max_x = 0.0; | ||
52 | S.bb.min_y = 0.0; | ||
53 | S.bb.max_y = 0.0; | ||
54 | |||
55 | // for (i = 0; i < ROWS; i++) | ||
56 | |||
57 | EXEC SQL FETCH c2 INTO :coordinates; | ||
58 | while (sqlca.sqlcode != 100) | ||
59 | { | ||
60 | /* | ||
61 | fscanf (coords, "%s %f %f\n", | ||
62 | S.gi_data[i], | ||
63 | &S.base_vertices_data[i][0], | ||
64 | &S.base_vertices_data[i][1]); | ||
65 | */ | ||
66 | |||
67 | int i = coordinates.coord_id; | ||
68 | |||
69 | strncpy(S.gi_data[i], | ||
70 | coordinates.gi.data, | ||
71 | sizeof (S.gi_data[i])); | ||
72 | |||
73 | S.base_vertices_data[i][0] = coordinates.x; | ||
74 | S.base_vertices_data[i][1] = coordinates.y; | ||
75 | |||
76 | if (S.base_vertices_data[i][0] < S.bb.min_x) | ||
77 | S.bb.min_x = S.base_vertices_data[i][0]; | ||
78 | if (S.base_vertices_data[i][0] > S.bb.max_x) | ||
79 | S.bb.max_x = S.base_vertices_data[i][0]; | ||
80 | if (S.base_vertices_data[i][1] < S.bb.min_y) | ||
81 | S.bb.min_y = S.base_vertices_data[i][1]; | ||
82 | if (S.base_vertices_data[i][1] > S.bb.max_y) | ||
83 | S.bb.max_y = S.base_vertices_data[i][1]; | ||
84 | |||
85 | /* | ||
86 | * Deselected by default. | ||
87 | */ | ||
88 | S.selection[i] = false; | ||
89 | |||
90 | S.base_colors_data[i][0] = DEFAULT_COLOR_R; | ||
91 | S.base_colors_data[i][1] = DEFAULT_COLOR_G; | ||
92 | S.base_colors_data[i][2] = DEFAULT_COLOR_B; | ||
93 | |||
94 | EXEC SQL FETCH c2 INTO :coordinates; | ||
95 | } | ||
96 | |||
97 | EXEC SQL CLOSE c2; | ||
98 | |||
99 | /* | ||
100 | fclose (coords); | ||
101 | */ | ||
102 | |||
103 | /* | ||
104 | * Find the largest axis and use it to setup the projection. This | ||
105 | * is done to preserve the aspect ratio. The aspect ratio should be | ||
106 | * preserved since relative distance is a meaningful indicator in | ||
107 | * the map. | ||
108 | */ | ||
109 | |||
110 | // Min of min x or min y. | ||
111 | if (S.bb.min_x <= S.bb.min_y) | ||
112 | S.ortho_min = S.bb.min_x; | ||
113 | else | ||
114 | S.ortho_min = S.bb.min_y; | ||
115 | S.ortho_min--; | ||
116 | |||
117 | // Max of max x or max y. | ||
118 | if (S.bb.max_x >= S.bb.max_y) | ||
119 | S.ortho_max = S.bb.max_x; | ||
120 | else | ||
121 | S.ortho_max = S.bb.max_y; | ||
122 | S.ortho_max++; | ||
123 | |||
124 | // Invert the y coordinate to match up with the LGL Java viewer. | ||
125 | for (int i = 0; i < ROWS; i++) | ||
126 | S.base_vertices_data[i][1] = | ||
127 | S.ortho_max - S.base_vertices_data[i][1]; | ||
128 | |||
129 | glGenBuffers (2, S.buffers); | ||
130 | |||
131 | glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_VERTICES]); | ||
132 | glVertexPointer (2, GL_FLOAT, 0, 0); | ||
133 | glBufferData (GL_ARRAY_BUFFER, | ||
134 | sizeof (S.base_vertices_data), S.base_vertices_data, | ||
135 | GL_STATIC_DRAW); | ||
136 | |||
137 | glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]); | ||
138 | glColorPointer (3, GL_FLOAT, 0, 0); | ||
139 | glBufferData (GL_ARRAY_BUFFER, | ||
140 | sizeof (S.base_colors_data), S.base_colors_data, | ||
141 | GL_STATIC_DRAW); | ||
142 | |||
143 | return; | ||
144 | } | ||