summaryrefslogtreecommitdiffstats
Unidiff
-rw-r--r--README21
-rw-r--r--TODO3
-rw-r--r--src/Makefile.am27
-rw-r--r--src/controller/actions/pan.c57
-rw-r--r--src/controller/actions/pan.h2
-rw-r--r--src/controller/actions/sel_save.c2
-rw-r--r--src/controller/callbacks/keyboard.c2
-rw-r--r--src/controller/callbacks/mouse.c30
-rw-r--r--src/controller/callbacks/mouse_motion.c19
-rw-r--r--src/controller/callbacks/mouse_motion.h9
-rw-r--r--src/model/base.c417
-rw-r--r--src/model/base.h9
-rw-r--r--src/model/coordinates.h11
-rw-r--r--src/model/data/base.sqc (renamed from src/model/base.sqc)6
-rw-r--r--src/model/selection_info.h37
-rw-r--r--src/model/selection_info_init.c14
-rw-r--r--src/model/selection_info_init.h8
-rw-r--r--src/model/selection_purposes.h17
-rw-r--r--src/model/state/pan_info_init.h8
-rw-r--r--src/model/state/state.h (renamed from src/model/state.h)3
-rw-r--r--src/model/state/zoom_info.h (renamed from src/model/zoom_info.h)0
-rw-r--r--src/model/state/zoom_info_init.c (renamed from src/model/zoom_info_init.c)0
-rw-r--r--src/model/state/zoom_info_init.h (renamed from src/model/zoom_info_init.h)0
-rw-r--r--src/view/geometry.c8
-rw-r--r--src/view/init.c12
-rw-r--r--src/view/state0.h2
-rw-r--r--src/view/view.c4
27 files changed, 179 insertions, 549 deletions
diff --git a/README b/README
index d369028..737b89f 100644
--- a/README
+++ b/README
@@ -1,17 +1,24 @@
1Visualization system to explore the data from exp004.1Visualization system to explore influenza sequence data.
22
3Light gray is used to display unselected points. White is used to3Light gray is used to display unselected points. A yellow outline is
4highlight the selection.4used to highlight the selection.
5
6Use
75
8 ESC: Clear selection.6 ESC: Clear selection.
9 Left-click, drag and release: Add box to selection.7
10 Left-click: Add points under mouse pointer to selection.8 Left-click, drag: Pan.
9
10 CTRL + Left-click, drag and release: Add box to selection.
11
11 s: Selection will be used to define a set.12 s: Selection will be used to define a set.
13
12 z: Selection will be used to define a zoom region.14 z: Selection will be used to define a zoom region.
15
13 r: Reset the display (unzoom).16 r: Reset the display (unzoom).
17
14 l: Toggle display of the legend (on by default).18 l: Toggle display of the legend (on by default).
19
20 Mouse-wheel: scroll to zoom in or out by 10% of the window size with
21 the focus at the center of the window.
1522
16======23======
17COFFEE24COFFEE
diff --git a/TODO b/TODO
index dad8316..a188804 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,7 @@
1This is the todo list for the project.1This is the todo list for the project.
22
3* Features to add:3* Features to add:
4 - Pan the display.4 - Preserve the aspect ratio when zooming.
5 - Zoom out.
6 - Handle multiple selections defined by the user.5 - Handle multiple selections defined by the user.
7 . Save a selection.6 . Save a selection.
8 . Load a selection.7 . Load a selection.
diff --git a/src/Makefile.am b/src/Makefile.am
index e2a3b72..c7f33a0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,17 +11,19 @@ flumap_SOURCES = \
11 controller/callbacks/display.c \11 controller/callbacks/display.c \
12 controller/callbacks/keyboard.c \12 controller/callbacks/keyboard.c \
13 controller/callbacks/mouse.c \13 controller/callbacks/mouse.c \
14 controller/callbacks/mouse_motion.c \
14 controller/callbacks/mouse_wheel.c \15 controller/callbacks/mouse_wheel.c \
15 controller/callbacks/reshape.c \16 controller/callbacks/reshape.c \
16 db/dbconnect.c \17 db/dbconnect.c \
17 flumap.c \18 flumap.c \
18 model/base.c \19 model/data/base.c \
19 model/geometry/density_legend_geometry.c \20 model/geometry/density_legend_geometry.c \
20 model/geometry/map_geometry.c \21 model/geometry/map_geometry.c \
21 model/geometry/protein_geometry.c \22 model/geometry/protein_geometry.c \
22 model/geometry/protein_selected_geometry.c \23 model/geometry/protein_selected_geometry.c \
23 model/selection_info_init.c \24 model/state/pan_info_init.c \
24 model/zoom_info_init.c \25 model/state/selection_info_init.c \
26 model/state/zoom_info_init.c \
25 util/ati_meminfo.c \27 util/ati_meminfo.c \
26 util/check_error.c \28 util/check_error.c \
27 util/pick_convert.c \29 util/pick_convert.c \
@@ -44,20 +46,23 @@ noinst_HEADERS = \
44 controller/callbacks/display.h \46 controller/callbacks/display.h \
45 controller/callbacks/keyboard.h \47 controller/callbacks/keyboard.h \
46 controller/callbacks/mouse.h \48 controller/callbacks/mouse.h \
49 controller/callbacks/mouse_motion.h \
47 controller/callbacks/mouse_wheel.h \50 controller/callbacks/mouse_wheel.h \
48 controller/callbacks/reshape.h \51 controller/callbacks/reshape.h \
49 db/dbconnect.h \52 db/dbconnect.h \
50 model/base.h \53 model/data/base.h \
51 model/state.h \54 model/data/coordinates.h \
52 model/geometry/density_legend_geometry.h \55 model/geometry/density_legend_geometry.h \
53 model/geometry/map_geometry.h \56 model/geometry/map_geometry.h \
54 model/geometry/protein_geometry.h \57 model/geometry/protein_geometry.h \
55 model/geometry/protein_selected_geometry.h \58 model/geometry/protein_selected_geometry.h \
56 model/selection_info.h \59 model/state/pan_info.h \
57 model/selection_info_init.h \60 model/state/selection_info.h \
58 model/selection_purposes.h \61 model/state/selection_info_init.h \
59 model/zoom_info.h \62 model/state/selection_purposes.h \
60 model/zoom_info_init.h \63 model/state/state.h \
64 model/state/zoom_info.h \
65 model/state/zoom_info_init.h \
61 util/ati_meminfo.h \66 util/ati_meminfo.h \
62 util/check_error.h \67 util/check_error.h \
63 util/pick_convert.h \68 util/pick_convert.h \
@@ -86,4 +91,4 @@ CLEANFILES = \
86 controller/actions/selection_from_db.c \91 controller/actions/selection_from_db.c \
87 controller/actions/sel_save.c \92 controller/actions/sel_save.c \
88 db/dbconnect.c \93 db/dbconnect.c \
89 model/base.c94 model/data/base.c
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
27
3void8void
4pan ()9pan (int x1, int y1, int x2, int y2)
5{10{
611 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}
diff --git a/src/controller/actions/pan.h b/src/controller/actions/pan.h
index 18ac876..1af615e 100644
--- a/src/controller/actions/pan.h
+++ b/src/controller/actions/pan.h
@@ -4,6 +4,6 @@
4/*4/*
5 * Pan around the geometry.5 * Pan around the geometry.
6 */6 */
7void pan ();7void pan (int x1, int y1, int x2, int y2);
88
9#endif // PAN_H9#endif // PAN_H
diff --git a/src/controller/actions/sel_save.c b/src/controller/actions/sel_save.c
index 9690459..48dabc2 100644
--- a/src/controller/actions/sel_save.c
+++ b/src/controller/actions/sel_save.c
@@ -1,6 +1,6 @@
1static char sqla_program_id[292] = 1static char sqla_program_id[292] =
2{2{
3 172,0,65,69,65,78,65,73,79,66,73,55,78,82,73,90,48,49,49,49,3 172,0,65,69,65,78,65,73,114,65,76,72,80,82,73,90,48,49,49,49,
4 49,32,50,32,32,32,32,32,32,32,32,32,8,0,68,79,78,32,32,32,4 49,32,50,32,32,32,32,32,32,32,32,32,8,0,68,79,78,32,32,32,
5 32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5 32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
6 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
diff --git a/src/controller/callbacks/keyboard.c b/src/controller/callbacks/keyboard.c
index 28bea81..cc917e7 100644
--- a/src/controller/callbacks/keyboard.c
+++ b/src/controller/callbacks/keyboard.c
@@ -3,6 +3,7 @@
3#include "../actions/selection_from_db.h"3#include "../actions/selection_from_db.h"
4#include "reshape.h"4#include "reshape.h"
5#include "../../view/state0.h"5#include "../../view/state0.h"
6#include "../../model/state/pan_info_init.h"
6#include <GL/glut.h>7#include <GL/glut.h>
78
8#define S state09#define S state0
@@ -42,6 +43,7 @@ keyboard (unsigned char key, int x, int y)
42 /*43 /*
43 * Reset the view (unzoom).44 * Reset the view (unzoom).
44 */45 */
46 pan_info_init (&S.pan);
45 S.zoom.active = false;47 S.zoom.active = false;
46 reshape (S.viewport.w, S.viewport.h);48 reshape (S.viewport.w, S.viewport.h);
47 glutPostRedisplay ();49 glutPostRedisplay ();
diff --git a/src/controller/callbacks/mouse.c b/src/controller/callbacks/mouse.c
index 16e8b8b..f594c23 100644
--- a/src/controller/callbacks/mouse.c
+++ b/src/controller/callbacks/mouse.c
@@ -9,6 +9,7 @@
9#include "reshape.h"9#include "reshape.h"
10#include <GL/glut.h>10#include <GL/glut.h>
11#include <math.h>11#include <math.h>
12#include <stdio.h>
12#include <stdlib.h>13#include <stdlib.h>
1314
14/*15/*
@@ -19,8 +20,12 @@
19void20void
20mouse (int button, int state, int x, int y)21mouse (int button, int state, int x, int y)
21{22{
23 // Release left button.
22 if (button == GLUT_LEFT_BUTTON && state == GLUT_UP)24 if (button == GLUT_LEFT_BUTTON && state == GLUT_UP)
23 {25 {
26 // Deactive a panning event if one was happening.
27 S.pan.active = false;
28
24 if (S.selection.active && S.selection.purpose == ZOOM)29 if (S.selection.active && S.selection.purpose == ZOOM)
25 {30 {
26 /*31 /*
@@ -41,7 +46,9 @@ mouse (int button, int state, int x, int y)
41 /*46 /*
42 * Complete a selection if one was started and not cancelled.47 * Complete a selection if one was started and not cancelled.
43 */48 */
44 if (S.selection.active && S.selection.purpose == SET)49 if (S.selection.active &&
50 S.selection.purpose == SET &&
51 glutGetModifiers () == GLUT_ACTIVE_CTRL)
45 {52 {
4653
47 /*54 /*
@@ -116,12 +123,31 @@ mouse (int button, int state, int x, int y)
116123
117 }124 }
118125
119 if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)126 // Begin selection.
127 if (button == GLUT_LEFT_BUTTON &&
128 state == GLUT_DOWN &&
129 glutGetModifiers () == GLUT_ACTIVE_CTRL)
120 {130 {
121 S.selection.active = true;131 S.selection.active = true;
122 S.selection.x = x;132 S.selection.x = x;
123 S.selection.y = y;133 S.selection.y = y;
124 }134 }
125135
136 // Pan.
137 if (button == GLUT_LEFT_BUTTON &&
138 state == GLUT_DOWN &&
139 glutGetModifiers () != GLUT_ACTIVE_CTRL)
140 {
141 /*
142 * Detection of the first point in a panning event.
143 */
144 if (S.pan.active == false)
145 {
146 S.pan.active = true;
147 S.pan.begin[0] = x;
148 S.pan.begin[1] = y;
149 }
150 }
151
126 return;152 return;
127}153}
diff --git a/src/controller/callbacks/mouse_motion.c b/src/controller/callbacks/mouse_motion.c
new file mode 100644
index 0000000..3279773
--- a/dev/null
+++ b/src/controller/callbacks/mouse_motion.c
@@ -0,0 +1,19 @@
1#include "mouse_motion.h"
2#include "../../view/state0.h"
3#include "../actions/pan.h"
4#include <GL/glut.h>
5
6#define S state0
7
8void
9mouse_motion (int x, int y)
10{
11 if (S.pan.active)
12 {
13 pan (S.pan.begin[0], S.pan.begin[1], x, y);
14 S.pan.begin[0] = x;
15 S.pan.begin[1] = y;
16 }
17
18 return;
19}
diff --git a/src/controller/callbacks/mouse_motion.h b/src/controller/callbacks/mouse_motion.h
new file mode 100644
index 0000000..2d8e7f2
--- a/dev/null
+++ b/src/controller/callbacks/mouse_motion.h
@@ -0,0 +1,9 @@
1#ifndef MOUSE_MOTION_H
2#define MOUSE_MOTION_H
3
4/*
5 * GLUT callback for mouse motion.
6 */
7void mouse_motion (int x, int y);
8
9#endif // MOUSE_MOTION_H
diff --git a/src/model/base.c b/src/model/base.c
deleted file mode 100644
index 649fec3..0000000
--- a/src/model/base.c
+++ b/dev/null
@@ -1,417 +0,0 @@
1static char sqla_program_id[292] =
2{
3 172,0,65,69,65,78,65,73,86,65,78,55,78,82,73,90,48,49,49,49,
4 49,32,50,32,32,32,32,32,32,32,32,32,8,0,68,79,78,32,32,32,
5 32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
6 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
7 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
8 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
9 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
10 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
11 0,0,8,0,66,65,83,69,32,32,32,32,0,0,0,0,0,0,0,0,
12 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
13 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
14 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
15 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
17 0,0,0,0,0,0,0,0,0,0,0,0
18};
19
20#include "sqladef.h"
21
22static struct sqla_runtime_info sqla_rtinfo =
23{{'S','Q','L','A','R','T','I','N'}, sizeof(wchar_t), 0, {' ',' ',' ',' '}};
24
25
26static const short sqlIsLiteral = SQL_IS_LITERAL;
27static const short sqlIsInputHvar = SQL_IS_INPUT_HVAR;
28
29
30#line 1 "base.sqc"
31/* I seem to need this for glGenBuffers as per
32 http://www.gamedev.net/community/forums/topic.asp?topic_id=422358 */
33#define GL_GLEXT_PROTOTYPES
34
35#include "base.h"
36#include "../view/state0.h"
37#include "../util/check_error.h"
38#include <GL/glut.h>
39#include <string.h>
40#include <stdlib.h>
41#include "sqlca.h"
42extern struct sqlca sqlca;
43
44/*
45 * A simple alias to make the code more readable.
46 */
47#define S state0
48
49void
50base (void)
51{
52 /*
53 * This implementation can be improved by mapping the video memory
54 * directly rather than loading into system memory and then copying
55 * into video memory.
56 */
57
58 /*
59 * db2dclgn -d exp004 -t coordinates
60 */
61
62/*
63EXEC SQL BEGIN DECLARE SECTION;
64*/
65
66#line 31 "base.sqc"
67
68
69/*
70EXEC SQL INCLUDE 'model/coordinates.h';
71*/
72
73#line 1 "/home/don/projects/Research/Experiments/exp005/src/model/coordinates.h"
74struct
75{
76 sqlint32 coord_id;
77 struct
78 {
79 short length;
80 char data[50];
81 } gi;
82 double x;
83 double y;
84} coordinates;
85
86#line 32 "base.sqc"
87
88 sqlint32 rows;
89
90/*
91EXEC SQL END DECLARE SECTION;
92*/
93
94#line 34 "base.sqc"
95
96
97 /* Determine how many nodes have coordinates assigned to them. */
98
99/*
100EXEC SQL SELECT COUNT (*) INTO:rows FROM coordinates;
101*/
102
103{
104#line 37 "base.sqc"
105 sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
106#line 37 "base.sqc"
107 sqlaaloc(3,1,1,0L);
108 {
109 struct sqla_setdata_list sql_setdlist[1];
110#line 37 "base.sqc"
111 sql_setdlist[0].sqltype = 496; sql_setdlist[0].sqllen = 4;
112#line 37 "base.sqc"
113 sql_setdlist[0].sqldata = (void*)&rows;
114#line 37 "base.sqc"
115 sql_setdlist[0].sqlind = 0L;
116#line 37 "base.sqc"
117 sqlasetdata(3,0,1,sql_setdlist,0L,0L);
118 }
119#line 37 "base.sqc"
120 sqlacall((unsigned short)24,1,0,3,0L);
121#line 37 "base.sqc"
122 sqlastop(0L);
123}
124
125#line 37 "base.sqc"
126
127
128 /* Free any existing coordinates and allocate memory to store the
129 new values. */
130 S.rows = rows;
131
132 free (S.selection.set);
133 S.selection.set = calloc (rows, sizeof (bool));
134
135 free (S.gi_data);
136 S.gi_data = calloc (rows, sizeof (char) * 20);
137
138 free (S.base_vertices_data);
139 S.base_vertices_data = calloc (rows, sizeof (float) * 2);
140
141 free (S.base_colors_data);
142 S.base_colors_data = calloc (rows, sizeof (float) * 4);
143
144
145/*
146EXEC SQL DECLARE c2 CURSOR FOR SELECT *FROM coordinates;
147*/
148
149#line 55 "base.sqc"
150
151
152
153/*
154EXEC SQL OPEN c2;
155*/
156
157{
158#line 57 "base.sqc"
159 sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
160#line 57 "base.sqc"
161 sqlacall((unsigned short)26,2,0,0,0L);
162#line 57 "base.sqc"
163 sqlastop(0L);
164}
165
166#line 57 "base.sqc"
167
168
169 /*
170 * Initialize the bounding box of the points.
171 */
172 S.bb.min_x = 0.0;
173 S.bb.max_x = 0.0;
174 S.bb.min_y = 0.0;
175 S.bb.max_y = 0.0;
176
177
178/*
179EXEC SQL FETCH c2 INTO:coordinates;
180*/
181
182{
183#line 67 "base.sqc"
184 sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
185#line 67 "base.sqc"
186 sqlaaloc(3,4,2,0L);
187 {
188 struct sqla_setdata_list sql_setdlist[4];
189#line 67 "base.sqc"
190 sql_setdlist[0].sqltype = 496; sql_setdlist[0].sqllen = 4;
191#line 67 "base.sqc"
192 sql_setdlist[0].sqldata = (void*)&coordinates.coord_id;
193#line 67 "base.sqc"
194 sql_setdlist[0].sqlind = 0L;
195#line 67 "base.sqc"
196 sql_setdlist[1].sqltype = 448; sql_setdlist[1].sqllen = 50;
197#line 67 "base.sqc"
198 sql_setdlist[1].sqldata = (void*)&coordinates.gi;
199#line 67 "base.sqc"
200 sql_setdlist[1].sqlind = 0L;
201#line 67 "base.sqc"
202 sql_setdlist[2].sqltype = 480; sql_setdlist[2].sqllen = 8;
203#line 67 "base.sqc"
204 sql_setdlist[2].sqldata = (void*)&coordinates.x;
205#line 67 "base.sqc"
206 sql_setdlist[2].sqlind = 0L;
207#line 67 "base.sqc"
208 sql_setdlist[3].sqltype = 480; sql_setdlist[3].sqllen = 8;
209#line 67 "base.sqc"
210 sql_setdlist[3].sqldata = (void*)&coordinates.y;
211#line 67 "base.sqc"
212 sql_setdlist[3].sqlind = 0L;
213#line 67 "base.sqc"
214 sqlasetdata(3,0,4,sql_setdlist,0L,0L);
215 }
216#line 67 "base.sqc"
217 sqlacall((unsigned short)25,2,0,3,0L);
218#line 67 "base.sqc"
219 sqlastop(0L);
220}
221
222#line 67 "base.sqc"
223
224 while (sqlca.sqlcode != 100)
225 {
226 int i = coordinates.coord_id - 1;
227
228 strncpy (S.gi_data + i, coordinates.gi.data, sizeof (S.gi_data[i]));
229
230 float *v = S.base_vertices_data + (i * 2);
231 *v = coordinates.x;
232 v++;
233 *v = coordinates.y;
234
235 v = S.base_vertices_data + (i * 2);
236 if (*v < S.bb.min_x)
237 S.bb.min_x = *v;
238 if (*v > S.bb.max_x)
239 S.bb.max_x = *v;
240
241 v++;
242 if (*v < S.bb.min_y)
243 S.bb.min_y = *v;
244 if (*v > S.bb.max_y)
245 S.bb.max_y = *v;
246
247 /*
248 * Deselected by default.
249 */
250 S.selection.set[i] = false;
251
252 float *c = S.base_colors_data + (i * 4);
253 *c = DEFAULT_COLOR_R;
254 c++;
255 *c = DEFAULT_COLOR_G;
256 c++;
257 *c = DEFAULT_COLOR_B;
258 c++;
259 *c = DEFAULT_COLOR_A;
260
261
262/*
263EXEC SQL FETCH c2 INTO:coordinates;
264*/
265
266{
267#line 105 "base.sqc"
268 sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
269#line 105 "base.sqc"
270 sqlaaloc(3,4,3,0L);
271 {
272 struct sqla_setdata_list sql_setdlist[4];
273#line 105 "base.sqc"
274 sql_setdlist[0].sqltype = 496; sql_setdlist[0].sqllen = 4;
275#line 105 "base.sqc"
276 sql_setdlist[0].sqldata = (void*)&coordinates.coord_id;
277#line 105 "base.sqc"
278 sql_setdlist[0].sqlind = 0L;
279#line 105 "base.sqc"
280 sql_setdlist[1].sqltype = 448; sql_setdlist[1].sqllen = 50;
281#line 105 "base.sqc"
282 sql_setdlist[1].sqldata = (void*)&coordinates.gi;
283#line 105 "base.sqc"
284 sql_setdlist[1].sqlind = 0L;
285#line 105 "base.sqc"
286 sql_setdlist[2].sqltype = 480; sql_setdlist[2].sqllen = 8;
287#line 105 "base.sqc"
288 sql_setdlist[2].sqldata = (void*)&coordinates.x;
289#line 105 "base.sqc"
290 sql_setdlist[2].sqlind = 0L;
291#line 105 "base.sqc"
292 sql_setdlist[3].sqltype = 480; sql_setdlist[3].sqllen = 8;
293#line 105 "base.sqc"
294 sql_setdlist[3].sqldata = (void*)&coordinates.y;
295#line 105 "base.sqc"
296 sql_setdlist[3].sqlind = 0L;
297#line 105 "base.sqc"
298 sqlasetdata(3,0,4,sql_setdlist,0L,0L);
299 }
300#line 105 "base.sqc"
301 sqlacall((unsigned short)25,2,0,3,0L);
302#line 105 "base.sqc"
303 sqlastop(0L);
304}
305
306#line 105 "base.sqc"
307
308 }
309
310
311/*
312EXEC SQL CLOSE c2;
313*/
314
315{
316#line 108 "base.sqc"
317 sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
318#line 108 "base.sqc"
319 sqlacall((unsigned short)20,2,0,0,0L);
320#line 108 "base.sqc"
321 sqlastop(0L);
322}
323
324#line 108 "base.sqc"
325
326
327
328/*
329EXEC SQL COMMIT;
330*/
331
332{
333#line 110 "base.sqc"
334 sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
335#line 110 "base.sqc"
336 sqlacall((unsigned short)21,0,0,0,0L);
337#line 110 "base.sqc"
338 sqlastop(0L);
339}
340
341#line 110 "base.sqc"
342
343
344 /*
345 * Find the largest axis and use it to setup the projection. This
346 * is done to preserve the aspect ratio. The aspect ratio should be
347 * preserved since relative distance is a meaningful indicator in
348 * the map.
349 */
350
351 // Min of min x or min y.
352 if (S.bb.min_x <= S.bb.min_y)
353 S.ortho_min = S.bb.min_x;
354 else
355 S.ortho_min = S.bb.min_y;
356 S.ortho_min--;
357
358 // Max of max x or max y.
359 if (S.bb.max_x >= S.bb.max_y)
360 S.ortho_max = S.bb.max_x;
361 else
362 S.ortho_max = S.bb.max_y;
363 S.ortho_max++;
364
365 // Invert the y coordinate to match up with the LGL Java viewer.
366 float *v = S.base_vertices_data;
367 for (int i = 0; i < S.rows; i++)
368 {
369 v++;
370 *v = S.ortho_max - *v;
371 v++;
372 }
373
374 // Move the origin (0,0) to the center of the data.
375 S.ortho_min = 0.0;
376 S.ortho_max = 0.0;
377
378 v = S.base_vertices_data;
379 for (int i = 0; i < S.rows; i++)
380 {
381 *v = *v - (0.5 * (S.bb.max_x - S.bb.min_x));
382
383 if (S.ortho_min > *v)
384 S.ortho_min = *v;
385
386 if (S.ortho_max < *v)
387 S.ortho_max = *v;
388
389 v++;
390
391 *v = *v - (0.5 * (S.bb.max_y - S.bb.min_y));
392
393 if (S.ortho_min > *v)
394 S.ortho_min = *v;
395
396 if (S.ortho_max < *v)
397 S.ortho_max = *v;
398
399 v++;
400 }
401
402 glGenBuffers (2, S.buffers);
403
404 glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_VERTICES]);
405 glVertexPointer (2, GL_FLOAT, 0, 0);
406 glBufferData (GL_ARRAY_BUFFER,
407 sizeof (S.base_vertices_data), S.base_vertices_data,
408 GL_STATIC_DRAW);
409
410 glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]);
411 glColorPointer (4, GL_FLOAT, 0, 0);
412 glBufferData (GL_ARRAY_BUFFER,
413 sizeof (S.base_colors_data), S.base_colors_data,
414 GL_STATIC_DRAW);
415
416 return;
417}
diff --git a/src/model/base.h b/src/model/base.h
deleted file mode 100644
index 5b7bd0b..0000000
--- a/src/model/base.h
+++ b/dev/null
@@ -1,9 +0,0 @@
1#ifndef BASE_H
2#define BASE_H
3
4/*
5 * Build the base layer of the map.
6 */
7void base (void);
8
9#endif // BASE_H
diff --git a/src/model/coordinates.h b/src/model/coordinates.h
deleted file mode 100644
index 7620904..0000000
--- a/src/model/coordinates.h
+++ b/dev/null
@@ -1,11 +0,0 @@
1struct
2{
3 sqlint32 coord_id;
4 struct
5 {
6 short length;
7 char data[50];
8 } gi;
9 double x;
10 double y;
11} coordinates;
diff --git a/src/model/base.sqc b/src/model/data/base.sqc
index 901ccd7..ad1c395 100644
--- a/src/model/base.sqc
+++ b/src/model/data/base.sqc
@@ -3,8 +3,8 @@
3#define GL_GLEXT_PROTOTYPES3#define GL_GLEXT_PROTOTYPES
44
5#include "base.h"5#include "base.h"
6#include "../view/state0.h"6#include "../../view/state0.h"
7#include "../util/check_error.h"7#include "../../util/check_error.h"
8#include <GL/glut.h>8#include <GL/glut.h>
9#include <string.h>9#include <string.h>
10#include <stdlib.h>10#include <stdlib.h>
@@ -29,7 +29,7 @@ base (void)
29 * db2dclgn -d exp004 -t coordinates29 * db2dclgn -d exp004 -t coordinates
30 */30 */
31 EXEC SQL BEGIN DECLARE SECTION;31 EXEC SQL BEGIN DECLARE SECTION;
32 EXEC SQL INCLUDE 'model/coordinates.h';32 EXEC SQL INCLUDE 'model/data/coordinates.h';
33 sqlint32 rows;33 sqlint32 rows;
34 EXEC SQL END DECLARE SECTION;34 EXEC SQL END DECLARE SECTION;
3535
diff --git a/src/model/selection_info.h b/src/model/selection_info.h
deleted file mode 100644
index 73a1c34..0000000
--- a/src/model/selection_info.h
+++ b/dev/null
@@ -1,37 +0,0 @@
1#ifndef SELECTION_INFO_H
2#define SELECTION_INFO_H
3
4#include "selection_purposes.h"
5#include <stdbool.h>
6
7typedef struct
8{
9
10 /*
11 * Selection list.
12 */
13 bool *set;
14
15 /*
16 * A selection is being performed.
17 */
18 bool active;
19
20 /*
21 * Indicate if the user is currently defining a selection.
22 */
23 SELECTION_PURPOSES purpose;
24
25 /*
26 * X coordinate of mouse when selection mode initiated.
27 */
28 int x;
29
30 /*
31 * Y coordinate of mouse when selection mode initiated.
32 */
33 int y;
34
35} SELECTION_INFO;
36
37#endif // SELECTION_INFO_H
diff --git a/src/model/selection_info_init.c b/src/model/selection_info_init.c
deleted file mode 100644
index 40d00aa..0000000
--- a/src/model/selection_info_init.c
+++ b/dev/null
@@ -1,14 +0,0 @@
1#include "selection_info_init.h"
2#include <string.h>
3
4void
5selection_info_init (SELECTION_INFO * s)
6{
7 s->set = NULL;
8 s->active = false;
9 s->purpose = SET;
10 s->x = 0;
11 s->y = 0;
12
13 return;
14}
diff --git a/src/model/selection_info_init.h b/src/model/selection_info_init.h
deleted file mode 100644
index d38b851..0000000
--- a/src/model/selection_info_init.h
+++ b/dev/null
@@ -1,8 +0,0 @@
1#ifndef SELECTION_INFO_INIT_H
2#define SELECTION_INFO_INIT_H
3
4#include "selection_info.h"
5
6void selection_info_init (SELECTION_INFO * s);
7
8#endif // SELECTION_INFO_INIT_H
diff --git a/src/model/selection_purposes.h b/src/model/selection_purposes.h
deleted file mode 100644
index 6c2e651..0000000
--- a/src/model/selection_purposes.h
+++ b/dev/null
@@ -1,17 +0,0 @@
1#ifndef SELECTION_PURPOSES_H
2#define SELECTION_PURPOSES_H
3
4typedef enum
5{
6 /*
7 * The selection will define a new set.
8 */
9 SET,
10
11 /*
12 * The selection will define a zoom region.
13 */
14 ZOOM
15} SELECTION_PURPOSES;
16
17#endif // SELECTION_PURPOSES_H
diff --git a/src/model/state/pan_info_init.h b/src/model/state/pan_info_init.h
new file mode 100644
index 0000000..f47b790
--- a/dev/null
+++ b/src/model/state/pan_info_init.h
@@ -0,0 +1,8 @@
1#ifndef PAN_INFO_INIT_H
2#define PAN_INFO_INIT_H
3
4#include "pan_info.h"
5
6void pan_info_init (PAN_INFO* p);
7
8#endif // PAN_INFO_INIT_H
diff --git a/src/model/state.h b/src/model/state/state.h
index 71185c8..ac1e035 100644
--- a/src/model/state.h
+++ b/src/model/state/state.h
@@ -3,6 +3,7 @@
33
4#include "selection_info.h"4#include "selection_info.h"
5#include "zoom_info.h"5#include "zoom_info.h"
6#include "pan_info.h"
67
7/*8/*
8 * Buffer object identifiers.9 * Buffer object identifiers.
@@ -109,6 +110,8 @@ typedef struct
109110
110 ZOOM_INFO zoom;111 ZOOM_INFO zoom;
111112
113 PAN_INFO pan;
114
112 /*115 /*
113 * Display a legend on the map.116 * Display a legend on the map.
114 */117 */
diff --git a/src/model/zoom_info.h b/src/model/state/zoom_info.h
index 5916b3c..5916b3c 100644
--- a/src/model/zoom_info.h
+++ b/src/model/state/zoom_info.h
diff --git a/src/model/zoom_info_init.c b/src/model/state/zoom_info_init.c
index f49dd59..f49dd59 100644
--- a/src/model/zoom_info_init.c
+++ b/src/model/state/zoom_info_init.c
diff --git a/src/model/zoom_info_init.h b/src/model/state/zoom_info_init.h
index 2cf2ac2..2cf2ac2 100644
--- a/src/model/zoom_info_init.h
+++ b/src/model/state/zoom_info_init.h
diff --git a/src/view/geometry.c b/src/view/geometry.c
index 7a3ed36..f8bd8e6 100644
--- a/src/view/geometry.c
+++ b/src/view/geometry.c
@@ -10,12 +10,20 @@ geometry (GLenum mode)
10{10{
11 glMatrixMode (GL_MODELVIEW);11 glMatrixMode (GL_MODELVIEW);
12 glLoadIdentity ();12 glLoadIdentity ();
13 glPushMatrix ();
14
15 /*
16 * Apply the results of any panning operations.
17 */
18 glTranslatef (S.pan.trans[0], S.pan.trans[1], 0.0);
1319
14 /*20 /*
15 * Draw the map.21 * Draw the map.
16 */22 */
17 glCallList (S.list_offset + MAP_GEOMETRY);23 glCallList (S.list_offset + MAP_GEOMETRY);
1824
25 glPopMatrix ();
26
19 /*27 /*
20 * Draw the legend.28 * Draw the legend.
21 */29 */
diff --git a/src/view/init.c b/src/view/init.c
index e32a75e..1c06c7e 100644
--- a/src/view/init.c
+++ b/src/view/init.c
@@ -1,12 +1,13 @@
1#include "init.h"1#include "../model/data/base.h"
2#include "state0.h"
3#include "../model/geometry/density_legend_geometry.h"2#include "../model/geometry/density_legend_geometry.h"
4#include "../model/geometry/map_geometry.h"3#include "../model/geometry/map_geometry.h"
5#include "../model/geometry/protein_geometry.h"4#include "../model/geometry/protein_geometry.h"
6#include "../model/geometry/protein_selected_geometry.h"5#include "../model/geometry/protein_selected_geometry.h"
7#include "../model/selection_info_init.h"6#include "../model/state/pan_info_init.h"
8#include "../model/zoom_info_init.h"7#include "../model/state/selection_info_init.h"
9#include "../model/base.h"8#include "../model/state/zoom_info_init.h"
9#include "init.h"
10#include "state0.h"
10#include <GL/glut.h>11#include <GL/glut.h>
1112
12#define S state013#define S state0
@@ -23,6 +24,7 @@ init (void)
23 S.base_colors_data = NULL;24 S.base_colors_data = NULL;
24 selection_info_init (&S.selection);25 selection_info_init (&S.selection);
25 zoom_info_init (&S.zoom);26 zoom_info_init (&S.zoom);
27 pan_info_init (&S.pan);
26 S.legend = true;28 S.legend = true;
2729
28 /*30 /*
diff --git a/src/view/state0.h b/src/view/state0.h
index 071e3ff..6be5b48 100644
--- a/src/view/state0.h
+++ b/src/view/state0.h
@@ -1,7 +1,7 @@
1#ifndef STATE0_H1#ifndef STATE0_H
2#define STATE0_H2#define STATE0_H
33
4#include "../model/state.h"4#include "../model/state/state.h"
55
6STATE state0;6STATE state0;
77
diff --git a/src/view/view.c b/src/view/view.c
index db3be6d..02fd833 100644
--- a/src/view/view.c
+++ b/src/view/view.c
@@ -1,6 +1,7 @@
1#include "../controller/callbacks/display.h"1#include "../controller/callbacks/display.h"
2#include "../controller/callbacks/keyboard.h"2#include "../controller/callbacks/keyboard.h"
3#include "../controller/callbacks/mouse.h"3#include "../controller/callbacks/mouse.h"
4#include "../controller/callbacks/mouse_motion.h"
4#include "../controller/callbacks/mouse_wheel.h"5#include "../controller/callbacks/mouse_wheel.h"
5#include "../controller/callbacks/reshape.h"6#include "../controller/callbacks/reshape.h"
6#include "../db/dbconnect.h"7#include "../db/dbconnect.h"
@@ -20,7 +21,7 @@ view (void)
20 // GLUT Initialization21 // GLUT Initialization
21 glutInitWindowSize (500, 500);22 glutInitWindowSize (500, 500);
22 glutInitWindowPosition (100, 100);23 glutInitWindowPosition (100, 100);
23 glutCreateWindow ("Exp004");24 glutCreateWindow ("Protein Sequence Map - Flu");
2425
25 // GL Initialization26 // GL Initialization
26 glClearColor (CLEAR_COLOR);27 glClearColor (CLEAR_COLOR);
@@ -49,6 +50,7 @@ view (void)
49 glutKeyboardFunc (keyboard);50 glutKeyboardFunc (keyboard);
50 glutMouseFunc (mouse);51 glutMouseFunc (mouse);
51 glutMouseWheelFunc (mouse_wheel);52 glutMouseWheelFunc (mouse_wheel);
53 glutMotionFunc (mouse_motion);
52 glutReshapeFunc (reshape);54 glutReshapeFunc (reshape);
5355
54 return;56 return;

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.