summaryrefslogtreecommitdiffstats
authorDon Pellegrino <don@coffee.donpellegrino.com>2009-08-17 20:55:20 (GMT)
committer Don Pellegrino <don@coffee.donpellegrino.com>2009-08-17 20:55:20 (GMT)
commit468e3205a35410f05943ccb01643576ab8036f94 (patch) (side-by-side diff)
tree27cbd450ff9edd345625484bf96a310660971718
parentac9ed9af7856daf7333248dd046ffea3479351f7 (diff)
downloadexp005-468e3205a35410f05943ccb01643576ab8036f94.zip
exp005-468e3205a35410f05943ccb01643576ab8036f94.tar.gz
exp005-468e3205a35410f05943ccb01643576ab8036f94.tar.bz2
Refactored the model package into data, state and geometry
subdirectories. Added implementation for panning the map.
-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 @@
-Visualization system to explore the data from exp004.
+Visualization system to explore influenza sequence data.
-Light gray is used to display unselected points. White is used to
-highlight the selection.
-
-Use
+Light gray is used to display unselected points. A yellow outline is
+used to highlight the selection.
ESC: Clear selection.
- Left-click, drag and release: Add box to selection.
- Left-click: Add points under mouse pointer to selection.
+
+ Left-click, drag: Pan.
+
+ CTRL + Left-click, drag and release: Add box to selection.
+
s: Selection will be used to define a set.
+
z: Selection will be used to define a zoom region.
+
r: Reset the display (unzoom).
+
l: Toggle display of the legend (on by default).
+
+ Mouse-wheel: scroll to zoom in or out by 10% of the window size with
+ the focus at the center of the window.
======
COFFEE
diff --git a/TODO b/TODO
index dad8316..a188804 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,7 @@
This is the todo list for the project.
* Features to add:
- - Pan the display.
- - Zoom out.
+ - Preserve the aspect ratio when zooming.
- Handle multiple selections defined by the user.
. Save a selection.
. 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 = \
controller/callbacks/display.c \
controller/callbacks/keyboard.c \
controller/callbacks/mouse.c \
+ controller/callbacks/mouse_motion.c \
controller/callbacks/mouse_wheel.c \
controller/callbacks/reshape.c \
db/dbconnect.c \
flumap.c \
- model/base.c \
+ model/data/base.c \
model/geometry/density_legend_geometry.c \
model/geometry/map_geometry.c \
model/geometry/protein_geometry.c \
model/geometry/protein_selected_geometry.c \
- model/selection_info_init.c \
- model/zoom_info_init.c \
+ model/state/pan_info_init.c \
+ model/state/selection_info_init.c \
+ model/state/zoom_info_init.c \
util/ati_meminfo.c \
util/check_error.c \
util/pick_convert.c \
@@ -44,20 +46,23 @@ noinst_HEADERS = \
controller/callbacks/display.h \
controller/callbacks/keyboard.h \
controller/callbacks/mouse.h \
+ controller/callbacks/mouse_motion.h \
controller/callbacks/mouse_wheel.h \
controller/callbacks/reshape.h \
db/dbconnect.h \
- model/base.h \
- model/state.h \
+ model/data/base.h \
+ model/data/coordinates.h \
model/geometry/density_legend_geometry.h \
model/geometry/map_geometry.h \
model/geometry/protein_geometry.h \
model/geometry/protein_selected_geometry.h \
- model/selection_info.h \
- model/selection_info_init.h \
- model/selection_purposes.h \
- model/zoom_info.h \
- model/zoom_info_init.h \
+ model/state/pan_info.h \
+ model/state/selection_info.h \
+ model/state/selection_info_init.h \
+ model/state/selection_purposes.h \
+ model/state/state.h \
+ model/state/zoom_info.h \
+ model/state/zoom_info_init.h \
util/ati_meminfo.h \
util/check_error.h \
util/pick_convert.h \
@@ -86,4 +91,4 @@ CLEANFILES = \
controller/actions/selection_from_db.c \
controller/actions/sel_save.c \
db/dbconnect.c \
- model/base.c
+ 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 @@
#include "pan.h"
+#include "../../util/check_error.h"
+#include "../../view/state0.h"
+#include <GL/glut.h>
+
+#define S state0
void
-pan ()
+pan (int x1, int y1, int x2, int y2)
{
-
+ int dx = x1 - x2;
+ int dy = y1 - x2;
+
+ if (dx == 0 && dy == 0)
+ return;
+
+ /*
+ * Convert the selection boundary from window coordinates to
+ * world coordinates.
+ */
+ glMatrixMode (GL_MODELVIEW);
+ glLoadIdentity ();
+ GLdouble model[16];
+ glGetDoublev (GL_MODELVIEW_MATRIX, model);
+ GLdouble projection[16];
+ glGetDoublev (GL_PROJECTION_MATRIX, projection);
+ GLint viewport[4];
+ glGetIntegerv (GL_VIEWPORT, viewport);
+
+ check_error (__FILE__, __LINE__);
+
+ GLdouble start_position[3];
+ gluUnProject (x1,
+ y1,
+ 0,
+ model,
+ projection,
+ viewport,
+ &start_position[0],
+ &start_position[1], &start_position[2]);
+
+ check_error (__FILE__, __LINE__);
+
+ GLdouble end_position[3];
+ gluUnProject (x2,
+ y2,
+ 0,
+ model,
+ projection,
+ viewport,
+ &end_position[0], &end_position[1], &end_position[2]);
+
+ check_error (__FILE__, __LINE__);
+
+ S.pan.trans[0] += end_position[0] - start_position[0];
+ S.pan.trans[1] -= end_position[1] - start_position[1];
+
+ glutPostRedisplay ();
+
return;
}
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 @@
/*
* Pan around the geometry.
*/
-void pan ();
+void pan (int x1, int y1, int x2, int y2);
#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 @@
static char sqla_program_id[292] =
{
- 172,0,65,69,65,78,65,73,79,66,73,55,78,82,73,90,48,49,49,49,
+ 172,0,65,69,65,78,65,73,114,65,76,72,80,82,73,90,48,49,49,49,
49,32,50,32,32,32,32,32,32,32,32,32,8,0,68,79,78,32,32,32,
32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
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 @@
#include "../actions/selection_from_db.h"
#include "reshape.h"
#include "../../view/state0.h"
+#include "../../model/state/pan_info_init.h"
#include <GL/glut.h>
#define S state0
@@ -42,6 +43,7 @@ keyboard (unsigned char key, int x, int y)
/*
* Reset the view (unzoom).
*/
+ pan_info_init (&S.pan);
S.zoom.active = false;
reshape (S.viewport.w, S.viewport.h);
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 @@
#include "reshape.h"
#include <GL/glut.h>
#include <math.h>
+#include <stdio.h>
#include <stdlib.h>
/*
@@ -19,8 +20,12 @@
void
mouse (int button, int state, int x, int y)
{
+ // Release left button.
if (button == GLUT_LEFT_BUTTON && state == GLUT_UP)
{
+ // Deactive a panning event if one was happening.
+ S.pan.active = false;
+
if (S.selection.active && S.selection.purpose == ZOOM)
{
/*
@@ -41,7 +46,9 @@ mouse (int button, int state, int x, int y)
/*
* Complete a selection if one was started and not cancelled.
*/
- if (S.selection.active && S.selection.purpose == SET)
+ if (S.selection.active &&
+ S.selection.purpose == SET &&
+ glutGetModifiers () == GLUT_ACTIVE_CTRL)
{
/*
@@ -116,12 +123,31 @@ mouse (int button, int state, int x, int y)
}
- if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
+ // Begin selection.
+ if (button == GLUT_LEFT_BUTTON &&
+ state == GLUT_DOWN &&
+ glutGetModifiers () == GLUT_ACTIVE_CTRL)
{
S.selection.active = true;
S.selection.x = x;
S.selection.y = y;
}
+ // Pan.
+ if (button == GLUT_LEFT_BUTTON &&
+ state == GLUT_DOWN &&
+ glutGetModifiers () != GLUT_ACTIVE_CTRL)
+ {
+ /*
+ * Detection of the first point in a panning event.
+ */
+ if (S.pan.active == false)
+ {
+ S.pan.active = true;
+ S.pan.begin[0] = x;
+ S.pan.begin[1] = y;
+ }
+ }
+
return;
}
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 @@
+#include "mouse_motion.h"
+#include "../../view/state0.h"
+#include "../actions/pan.h"
+#include <GL/glut.h>
+
+#define S state0
+
+void
+mouse_motion (int x, int y)
+{
+ if (S.pan.active)
+ {
+ pan (S.pan.begin[0], S.pan.begin[1], x, y);
+ S.pan.begin[0] = x;
+ S.pan.begin[1] = y;
+ }
+
+ return;
+}
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 @@
+#ifndef MOUSE_MOTION_H
+#define MOUSE_MOTION_H
+
+/*
+ * GLUT callback for mouse motion.
+ */
+void mouse_motion (int x, int y);
+
+#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 @@
-static char sqla_program_id[292] =
-{
- 172,0,65,69,65,78,65,73,86,65,78,55,78,82,73,90,48,49,49,49,
- 49,32,50,32,32,32,32,32,32,32,32,32,8,0,68,79,78,32,32,32,
- 32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,8,0,66,65,83,69,32,32,32,32,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0
-};
-
-#include "sqladef.h"
-
-static struct sqla_runtime_info sqla_rtinfo =
-{{'S','Q','L','A','R','T','I','N'}, sizeof(wchar_t), 0, {' ',' ',' ',' '}};
-
-
-static const short sqlIsLiteral = SQL_IS_LITERAL;
-static const short sqlIsInputHvar = SQL_IS_INPUT_HVAR;
-
-
-#line 1 "base.sqc"
-/* I seem to need this for glGenBuffers as per
- http://www.gamedev.net/community/forums/topic.asp?topic_id=422358 */
-#define GL_GLEXT_PROTOTYPES
-
-#include "base.h"
-#include "../view/state0.h"
-#include "../util/check_error.h"
-#include <GL/glut.h>
-#include <string.h>
-#include <stdlib.h>
-#include "sqlca.h"
-extern struct sqlca sqlca;
-
-/*
- * A simple alias to make the code more readable.
- */
-#define S state0
-
-void
-base (void)
-{
- /*
- * This implementation can be improved by mapping the video memory
- * directly rather than loading into system memory and then copying
- * into video memory.
- */
-
- /*
- * db2dclgn -d exp004 -t coordinates
- */
-
-/*
-EXEC SQL BEGIN DECLARE SECTION;
-*/
-
-#line 31 "base.sqc"
-
-
-/*
-EXEC SQL INCLUDE 'model/coordinates.h';
-*/
-
-#line 1 "/home/don/projects/Research/Experiments/exp005/src/model/coordinates.h"
-struct
-{
- sqlint32 coord_id;
- struct
- {
- short length;
- char data[50];
- } gi;
- double x;
- double y;
-} coordinates;
-
-#line 32 "base.sqc"
-
- sqlint32 rows;
-
-/*
-EXEC SQL END DECLARE SECTION;
-*/
-
-#line 34 "base.sqc"
-
-
- /* Determine how many nodes have coordinates assigned to them. */
-
-/*
-EXEC SQL SELECT COUNT (*) INTO:rows FROM coordinates;
-*/
-
-{
-#line 37 "base.sqc"
- sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
-#line 37 "base.sqc"
- sqlaaloc(3,1,1,0L);
- {
- struct sqla_setdata_list sql_setdlist[1];
-#line 37 "base.sqc"
- sql_setdlist[0].sqltype = 496; sql_setdlist[0].sqllen = 4;
-#line 37 "base.sqc"
- sql_setdlist[0].sqldata = (void*)&rows;
-#line 37 "base.sqc"
- sql_setdlist[0].sqlind = 0L;
-#line 37 "base.sqc"
- sqlasetdata(3,0,1,sql_setdlist,0L,0L);
- }
-#line 37 "base.sqc"
- sqlacall((unsigned short)24,1,0,3,0L);
-#line 37 "base.sqc"
- sqlastop(0L);
-}
-
-#line 37 "base.sqc"
-
-
- /* Free any existing coordinates and allocate memory to store the
- new values. */
- S.rows = rows;
-
- free (S.selection.set);
- S.selection.set = calloc (rows, sizeof (bool));
-
- free (S.gi_data);
- S.gi_data = calloc (rows, sizeof (char) * 20);
-
- free (S.base_vertices_data);
- S.base_vertices_data = calloc (rows, sizeof (float) * 2);
-
- free (S.base_colors_data);
- S.base_colors_data = calloc (rows, sizeof (float) * 4);
-
-
-/*
-EXEC SQL DECLARE c2 CURSOR FOR SELECT *FROM coordinates;
-*/
-
-#line 55 "base.sqc"
-
-
-
-/*
-EXEC SQL OPEN c2;
-*/
-
-{
-#line 57 "base.sqc"
- sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
-#line 57 "base.sqc"
- sqlacall((unsigned short)26,2,0,0,0L);
-#line 57 "base.sqc"
- sqlastop(0L);
-}
-
-#line 57 "base.sqc"
-
-
- /*
- * Initialize the bounding box of the points.
- */
- S.bb.min_x = 0.0;
- S.bb.max_x = 0.0;
- S.bb.min_y = 0.0;
- S.bb.max_y = 0.0;
-
-
-/*
-EXEC SQL FETCH c2 INTO:coordinates;
-*/
-
-{
-#line 67 "base.sqc"
- sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
-#line 67 "base.sqc"
- sqlaaloc(3,4,2,0L);
- {
- struct sqla_setdata_list sql_setdlist[4];
-#line 67 "base.sqc"
- sql_setdlist[0].sqltype = 496; sql_setdlist[0].sqllen = 4;
-#line 67 "base.sqc"
- sql_setdlist[0].sqldata = (void*)&coordinates.coord_id;
-#line 67 "base.sqc"
- sql_setdlist[0].sqlind = 0L;
-#line 67 "base.sqc"
- sql_setdlist[1].sqltype = 448; sql_setdlist[1].sqllen = 50;
-#line 67 "base.sqc"
- sql_setdlist[1].sqldata = (void*)&coordinates.gi;
-#line 67 "base.sqc"
- sql_setdlist[1].sqlind = 0L;
-#line 67 "base.sqc"
- sql_setdlist[2].sqltype = 480; sql_setdlist[2].sqllen = 8;
-#line 67 "base.sqc"
- sql_setdlist[2].sqldata = (void*)&coordinates.x;
-#line 67 "base.sqc"
- sql_setdlist[2].sqlind = 0L;
-#line 67 "base.sqc"
- sql_setdlist[3].sqltype = 480; sql_setdlist[3].sqllen = 8;
-#line 67 "base.sqc"
- sql_setdlist[3].sqldata = (void*)&coordinates.y;
-#line 67 "base.sqc"
- sql_setdlist[3].sqlind = 0L;
-#line 67 "base.sqc"
- sqlasetdata(3,0,4,sql_setdlist,0L,0L);
- }
-#line 67 "base.sqc"
- sqlacall((unsigned short)25,2,0,3,0L);
-#line 67 "base.sqc"
- sqlastop(0L);
-}
-
-#line 67 "base.sqc"
-
- while (sqlca.sqlcode != 100)
- {
- int i = coordinates.coord_id - 1;
-
- strncpy (S.gi_data + i, coordinates.gi.data, sizeof (S.gi_data[i]));
-
- float *v = S.base_vertices_data + (i * 2);
- *v = coordinates.x;
- v++;
- *v = coordinates.y;
-
- v = S.base_vertices_data + (i * 2);
- if (*v < S.bb.min_x)
- S.bb.min_x = *v;
- if (*v > S.bb.max_x)
- S.bb.max_x = *v;
-
- v++;
- if (*v < S.bb.min_y)
- S.bb.min_y = *v;
- if (*v > S.bb.max_y)
- S.bb.max_y = *v;
-
- /*
- * Deselected by default.
- */
- S.selection.set[i] = false;
-
- float *c = S.base_colors_data + (i * 4);
- *c = DEFAULT_COLOR_R;
- c++;
- *c = DEFAULT_COLOR_G;
- c++;
- *c = DEFAULT_COLOR_B;
- c++;
- *c = DEFAULT_COLOR_A;
-
-
-/*
-EXEC SQL FETCH c2 INTO:coordinates;
-*/
-
-{
-#line 105 "base.sqc"
- sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
-#line 105 "base.sqc"
- sqlaaloc(3,4,3,0L);
- {
- struct sqla_setdata_list sql_setdlist[4];
-#line 105 "base.sqc"
- sql_setdlist[0].sqltype = 496; sql_setdlist[0].sqllen = 4;
-#line 105 "base.sqc"
- sql_setdlist[0].sqldata = (void*)&coordinates.coord_id;
-#line 105 "base.sqc"
- sql_setdlist[0].sqlind = 0L;
-#line 105 "base.sqc"
- sql_setdlist[1].sqltype = 448; sql_setdlist[1].sqllen = 50;
-#line 105 "base.sqc"
- sql_setdlist[1].sqldata = (void*)&coordinates.gi;
-#line 105 "base.sqc"
- sql_setdlist[1].sqlind = 0L;
-#line 105 "base.sqc"
- sql_setdlist[2].sqltype = 480; sql_setdlist[2].sqllen = 8;
-#line 105 "base.sqc"
- sql_setdlist[2].sqldata = (void*)&coordinates.x;
-#line 105 "base.sqc"
- sql_setdlist[2].sqlind = 0L;
-#line 105 "base.sqc"
- sql_setdlist[3].sqltype = 480; sql_setdlist[3].sqllen = 8;
-#line 105 "base.sqc"
- sql_setdlist[3].sqldata = (void*)&coordinates.y;
-#line 105 "base.sqc"
- sql_setdlist[3].sqlind = 0L;
-#line 105 "base.sqc"
- sqlasetdata(3,0,4,sql_setdlist,0L,0L);
- }
-#line 105 "base.sqc"
- sqlacall((unsigned short)25,2,0,3,0L);
-#line 105 "base.sqc"
- sqlastop(0L);
-}
-
-#line 105 "base.sqc"
-
- }
-
-
-/*
-EXEC SQL CLOSE c2;
-*/
-
-{
-#line 108 "base.sqc"
- sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
-#line 108 "base.sqc"
- sqlacall((unsigned short)20,2,0,0,0L);
-#line 108 "base.sqc"
- sqlastop(0L);
-}
-
-#line 108 "base.sqc"
-
-
-
-/*
-EXEC SQL COMMIT;
-*/
-
-{
-#line 110 "base.sqc"
- sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
-#line 110 "base.sqc"
- sqlacall((unsigned short)21,0,0,0,0L);
-#line 110 "base.sqc"
- sqlastop(0L);
-}
-
-#line 110 "base.sqc"
-
-
- /*
- * Find the largest axis and use it to setup the projection. This
- * is done to preserve the aspect ratio. The aspect ratio should be
- * preserved since relative distance is a meaningful indicator in
- * the map.
- */
-
- // Min of min x or min y.
- if (S.bb.min_x <= S.bb.min_y)
- S.ortho_min = S.bb.min_x;
- else
- S.ortho_min = S.bb.min_y;
- S.ortho_min--;
-
- // Max of max x or max y.
- if (S.bb.max_x >= S.bb.max_y)
- S.ortho_max = S.bb.max_x;
- else
- S.ortho_max = S.bb.max_y;
- S.ortho_max++;
-
- // Invert the y coordinate to match up with the LGL Java viewer.
- float *v = S.base_vertices_data;
- for (int i = 0; i < S.rows; i++)
- {
- v++;
- *v = S.ortho_max - *v;
- v++;
- }
-
- // Move the origin (0,0) to the center of the data.
- S.ortho_min = 0.0;
- S.ortho_max = 0.0;
-
- v = S.base_vertices_data;
- for (int i = 0; i < S.rows; i++)
- {
- *v = *v - (0.5 * (S.bb.max_x - S.bb.min_x));
-
- if (S.ortho_min > *v)
- S.ortho_min = *v;
-
- if (S.ortho_max < *v)
- S.ortho_max = *v;
-
- v++;
-
- *v = *v - (0.5 * (S.bb.max_y - S.bb.min_y));
-
- if (S.ortho_min > *v)
- S.ortho_min = *v;
-
- if (S.ortho_max < *v)
- S.ortho_max = *v;
-
- v++;
- }
-
- glGenBuffers (2, S.buffers);
-
- glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_VERTICES]);
- glVertexPointer (2, GL_FLOAT, 0, 0);
- glBufferData (GL_ARRAY_BUFFER,
- sizeof (S.base_vertices_data), S.base_vertices_data,
- GL_STATIC_DRAW);
-
- glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]);
- glColorPointer (4, GL_FLOAT, 0, 0);
- glBufferData (GL_ARRAY_BUFFER,
- sizeof (S.base_colors_data), S.base_colors_data,
- GL_STATIC_DRAW);
-
- return;
-}
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 @@
-#ifndef BASE_H
-#define BASE_H
-
-/*
- * Build the base layer of the map.
- */
-void base (void);
-
-#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 @@
-struct
-{
- sqlint32 coord_id;
- struct
- {
- short length;
- char data[50];
- } gi;
- double x;
- double y;
-} 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 @@
#define GL_GLEXT_PROTOTYPES
#include "base.h"
-#include "../view/state0.h"
-#include "../util/check_error.h"
+#include "../../view/state0.h"
+#include "../../util/check_error.h"
#include <GL/glut.h>
#include <string.h>
#include <stdlib.h>
@@ -29,7 +29,7 @@ base (void)
* db2dclgn -d exp004 -t coordinates
*/
EXEC SQL BEGIN DECLARE SECTION;
- EXEC SQL INCLUDE 'model/coordinates.h';
+ EXEC SQL INCLUDE 'model/data/coordinates.h';
sqlint32 rows;
EXEC SQL END DECLARE SECTION;
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 @@
-#ifndef SELECTION_INFO_H
-#define SELECTION_INFO_H
-
-#include "selection_purposes.h"
-#include <stdbool.h>
-
-typedef struct
-{
-
- /*
- * Selection list.
- */
- bool *set;
-
- /*
- * A selection is being performed.
- */
- bool active;
-
- /*
- * Indicate if the user is currently defining a selection.
- */
- SELECTION_PURPOSES purpose;
-
- /*
- * X coordinate of mouse when selection mode initiated.
- */
- int x;
-
- /*
- * Y coordinate of mouse when selection mode initiated.
- */
- int y;
-
-} SELECTION_INFO;
-
-#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 @@
-#include "selection_info_init.h"
-#include <string.h>
-
-void
-selection_info_init (SELECTION_INFO * s)
-{
- s->set = NULL;
- s->active = false;
- s->purpose = SET;
- s->x = 0;
- s->y = 0;
-
- return;
-}
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 @@
-#ifndef SELECTION_INFO_INIT_H
-#define SELECTION_INFO_INIT_H
-
-#include "selection_info.h"
-
-void selection_info_init (SELECTION_INFO * s);
-
-#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 @@
-#ifndef SELECTION_PURPOSES_H
-#define SELECTION_PURPOSES_H
-
-typedef enum
-{
- /*
- * The selection will define a new set.
- */
- SET,
-
- /*
- * The selection will define a zoom region.
- */
- ZOOM
-} SELECTION_PURPOSES;
-
-#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 @@
+#ifndef PAN_INFO_INIT_H
+#define PAN_INFO_INIT_H
+
+#include "pan_info.h"
+
+void pan_info_init (PAN_INFO* p);
+
+#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 @@
#include "selection_info.h"
#include "zoom_info.h"
+#include "pan_info.h"
/*
* Buffer object identifiers.
@@ -109,6 +110,8 @@ typedef struct
ZOOM_INFO zoom;
+ PAN_INFO pan;
+
/*
* Display a legend on the map.
*/
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)
{
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
+ glPushMatrix ();
+
+ /*
+ * Apply the results of any panning operations.
+ */
+ glTranslatef (S.pan.trans[0], S.pan.trans[1], 0.0);
/*
* Draw the map.
*/
glCallList (S.list_offset + MAP_GEOMETRY);
+ glPopMatrix ();
+
/*
* Draw the legend.
*/
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 @@
-#include "init.h"
-#include "state0.h"
+#include "../model/data/base.h"
#include "../model/geometry/density_legend_geometry.h"
#include "../model/geometry/map_geometry.h"
#include "../model/geometry/protein_geometry.h"
#include "../model/geometry/protein_selected_geometry.h"
-#include "../model/selection_info_init.h"
-#include "../model/zoom_info_init.h"
-#include "../model/base.h"
+#include "../model/state/pan_info_init.h"
+#include "../model/state/selection_info_init.h"
+#include "../model/state/zoom_info_init.h"
+#include "init.h"
+#include "state0.h"
#include <GL/glut.h>
#define S state0
@@ -23,6 +24,7 @@ init (void)
S.base_colors_data = NULL;
selection_info_init (&S.selection);
zoom_info_init (&S.zoom);
+ pan_info_init (&S.pan);
S.legend = true;
/*
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 @@
#ifndef STATE0_H
#define STATE0_H
-#include "../model/state.h"
+#include "../model/state/state.h"
STATE state0;
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 @@
#include "../controller/callbacks/display.h"
#include "../controller/callbacks/keyboard.h"
#include "../controller/callbacks/mouse.h"
+#include "../controller/callbacks/mouse_motion.h"
#include "../controller/callbacks/mouse_wheel.h"
#include "../controller/callbacks/reshape.h"
#include "../db/dbconnect.h"
@@ -20,7 +21,7 @@ view (void)
// GLUT Initialization
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
- glutCreateWindow ("Exp004");
+ glutCreateWindow ("Protein Sequence Map - Flu");
// GL Initialization
glClearColor (CLEAR_COLOR);
@@ -49,6 +50,7 @@ view (void)
glutKeyboardFunc (keyboard);
glutMouseFunc (mouse);
glutMouseWheelFunc (mouse_wheel);
+ glutMotionFunc (mouse_motion);
glutReshapeFunc (reshape);
return;

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.