author | Don Pellegrino <don@drexel.edu> | 2009-07-06 21:22:31 (GMT) |
---|---|---|
committer | Don Pellegrino <don@drexel.edu> | 2009-07-06 21:22:31 (GMT) |
commit | f0817d6a70052e49e45661529c7999f25baa528b (patch) (unidiff) | |
tree | 7780c1074ce167f0196715ecb506cdb6fa598e53 | |
parent | ae129719e6ff1cb0691638e9483b4e21a93aa7f5 (diff) | |
download | exp005-f0817d6a70052e49e45661529c7999f25baa528b.zip exp005-f0817d6a70052e49e45661529c7999f25baa528b.tar.gz exp005-f0817d6a70052e49e45661529c7999f25baa528b.tar.bz2 |
Added a density legend to the display. Disabled the depth test so
that the alpha blending and point overlays work as expected for an
orthographic projection.
-rw-r--r-- | r/connect.R | 2 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/controller/exp004reshape.c | 11 | ||||
-rw-r--r-- | src/model/density_legend_geometry.c | 81 | ||||
-rw-r--r-- | src/model/density_legend_geometry.h | 9 | ||||
-rw-r--r-- | src/model/display_list_index.h | 6 | ||||
-rw-r--r-- | src/model/exp004state.h | 14 | ||||
-rw-r--r-- | src/util/check_error.c | 6 | ||||
-rw-r--r-- | src/view/exp004geometry.c | 7 | ||||
-rw-r--r-- | src/view/exp004init.c | 8 | ||||
-rw-r--r-- | src/view/exp004view.c | 4 |
11 files changed, 124 insertions, 27 deletions
diff --git a/r/connect.R b/r/connect.R index b42b8bb..75e84df 100644 --- a/r/connect.R +++ b/r/connect.R | |||
@@ -9,6 +9,8 @@ dbGetQuery (conn, "SELECT COUNT(*) FROM vis_collect"); | |||
9 | 9 | ||
10 | d <- dbReadTable (conn, "vis_collect"); | 10 | d <- dbReadTable (conn, "vis_collect"); |
11 | 11 | ||
12 | summary (d); | ||
13 | |||
12 | hist (d$"N_CITES"); | 14 | hist (d$"N_CITES"); |
13 | 15 | ||
14 | dbDisconnect (conn); | 16 | dbDisconnect (conn); |
diff --git a/src/Makefile.am b/src/Makefile.am index abedab7..9fd441c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -12,6 +12,7 @@ exp004viz_SOURCES = \ | |||
12 | controller/set_ortho.c \ | 12 | controller/set_ortho.c \ |
13 | db/dbconnect.c \ | 13 | db/dbconnect.c \ |
14 | exp004viz.c \ | 14 | exp004viz.c \ |
15 | model/density_legend_geometry.c \ | ||
15 | model/exp004base.c \ | 16 | model/exp004base.c \ |
16 | model/protein_geometry.c \ | 17 | model/protein_geometry.c \ |
17 | model/selection_info_init.c \ | 18 | model/selection_info_init.c \ |
@@ -36,7 +37,7 @@ noinst_HEADERS = \ | |||
36 | controller/selsave.h \ | 37 | controller/selsave.h \ |
37 | controller/set_ortho.h \ | 38 | controller/set_ortho.h \ |
38 | db/dbconnect.h \ | 39 | db/dbconnect.h \ |
39 | model/display_list_index.h \ | 40 | model/density_legend_geometry.h \ |
40 | model/exp004base.h \ | 41 | model/exp004base.h \ |
41 | model/exp004state.h \ | 42 | model/exp004state.h \ |
42 | model/protein_geometry.h \ | 43 | model/protein_geometry.h \ |
diff --git a/src/controller/exp004reshape.c b/src/controller/exp004reshape.c index 82f134d..891de08 100644 --- a/src/controller/exp004reshape.c +++ b/src/controller/exp004reshape.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "exp004reshape.h" | 1 | #include "exp004reshape.h" |
2 | #include "set_ortho.h" | 2 | #include "set_ortho.h" |
3 | #include "../view/exp004state0.h" | 3 | #include "../view/exp004state0.h" |
4 | #include "../model/density_legend_geometry.h" | ||
4 | #include <GL/glut.h> | 5 | #include <GL/glut.h> |
5 | 6 | ||
6 | #define S exp004state0 | 7 | #define S exp004state0 |
@@ -22,13 +23,13 @@ exp004reshape (int w, int h) | |||
22 | { | 23 | { |
23 | S.ortho.min_x = S.ortho_min; | 24 | S.ortho.min_x = S.ortho_min; |
24 | S.ortho.max_x = S.ortho_max; | 25 | S.ortho.max_x = S.ortho_max; |
25 | S.ortho.min_y = S.ortho_min * (GLfloat) h / (GLfloat) w; | 26 | S.ortho.min_y = S.ortho_min * (double) h / (double) w; |
26 | S.ortho.max_y = S.ortho_max * (GLfloat) h / (GLfloat) w; | 27 | S.ortho.max_y = S.ortho_max * (double) h / (double) w; |
27 | } | 28 | } |
28 | else | 29 | else |
29 | { | 30 | { |
30 | S.ortho.min_x = S.ortho_min * (GLfloat) w / (GLfloat) h; | 31 | S.ortho.min_x = S.ortho_min * (double) w / (double) h; |
31 | S.ortho.max_x = S.ortho_max * (GLfloat) w / (GLfloat) h; | 32 | S.ortho.max_x = S.ortho_max * (double) w / (double) h; |
32 | S.ortho.min_y = S.ortho_min; | 33 | S.ortho.min_y = S.ortho_min; |
33 | S.ortho.max_y = S.ortho_max; | 34 | S.ortho.max_y = S.ortho_max; |
34 | } | 35 | } |
@@ -43,5 +44,7 @@ exp004reshape (int w, int h) | |||
43 | S.viewport.w = w; | 44 | S.viewport.w = w; |
44 | S.viewport.h = h; | 45 | S.viewport.h = h; |
45 | 46 | ||
47 | density_legend_geometry (); | ||
48 | |||
46 | return; | 49 | return; |
47 | } | 50 | } |
diff --git a/src/model/density_legend_geometry.c b/src/model/density_legend_geometry.c new file mode 100644 index 0000000..ab3e46c --- a/dev/null +++ b/src/model/density_legend_geometry.c | |||
@@ -0,0 +1,81 @@ | |||
1 | #include "density_legend_geometry.h" | ||
2 | #include "../view/exp004state0.h" | ||
3 | #include "../controller/exp004reshape.h" | ||
4 | #include <GL/glut.h> | ||
5 | #include <stdio.h> | ||
6 | |||
7 | #define S exp004state0 | ||
8 | |||
9 | void | ||
10 | density_legend_geometry (void) | ||
11 | { | ||
12 | glNewList (S.list_offset + DENSITY_LEGEND_GEOMETRY, GL_COMPILE); | ||
13 | glPolygonMode (GL_FRONT, GL_FILL); | ||
14 | glColor4f (DEFAULT_COLOR_R, DEFAULT_COLOR_G, DEFAULT_COLOR_B, | ||
15 | DEFAULT_COLOR_A); | ||
16 | |||
17 | /* | ||
18 | * This value should be a percentage of the world height so that it | ||
19 | * remains a fixed number of pixels tall when the window is resized | ||
20 | * or zoomed. | ||
21 | */ | ||
22 | double legend_height = 0.5; | ||
23 | |||
24 | /* | ||
25 | * Calculate the bounding box for the legend. | ||
26 | */ | ||
27 | |||
28 | double a[2]; | ||
29 | double b[2]; | ||
30 | double c[2]; | ||
31 | double d[2]; | ||
32 | |||
33 | const double *left; | ||
34 | const double *right; | ||
35 | const double *top; | ||
36 | |||
37 | if (S.zoom.active) | ||
38 | { | ||
39 | left = &S.zoom.coords[0]; | ||
40 | right = &S.zoom.coords[1]; | ||
41 | top = &S.zoom.coords[3]; | ||
42 | } | ||
43 | else | ||
44 | { | ||
45 | left = &S.ortho.min_x; | ||
46 | top = &S.ortho.max_y; | ||
47 | right = &S.ortho.max_x; | ||
48 | } | ||
49 | |||
50 | a[0] = *left; | ||
51 | a[1] = *top; | ||
52 | b[0] = *right; | ||
53 | b[1] = *top; | ||
54 | c[0] = *right; | ||
55 | c[1] = *top - legend_height; | ||
56 | d[0] = *left; | ||
57 | d[1] = *top - legend_height; | ||
58 | |||
59 | /* | ||
60 | * Overlay a legend from default saturation / alpha to full saturation. | ||
61 | */ | ||
62 | for (int i = 1; i <= 1 / DEFAULT_COLOR_A; i++) | ||
63 | { | ||
64 | glBegin (GL_QUADS); | ||
65 | glVertex2dv (a); | ||
66 | glVertex2dv (b); | ||
67 | glVertex2dv (c); | ||
68 | glVertex2dv (d); | ||
69 | glEnd (); | ||
70 | |||
71 | /* | ||
72 | * Step left to right along the x-coordinate. | ||
73 | */ | ||
74 | a[0] = *left + (*right - *left) * (DEFAULT_COLOR_A * i); | ||
75 | d[0] = a[0]; | ||
76 | } | ||
77 | |||
78 | glEndList (); | ||
79 | |||
80 | return; | ||
81 | } | ||
diff --git a/src/model/density_legend_geometry.h b/src/model/density_legend_geometry.h new file mode 100644 index 0000000..4745ac0 --- a/dev/null +++ b/src/model/density_legend_geometry.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef DENSITY_LEGEND_GEOMETRY_H | ||
2 | #define DENSITY_LEGEND_GEOMETRY_H | ||
3 | |||
4 | /* | ||
5 | * Define the geometry to redner the density legend. | ||
6 | */ | ||
7 | void density_legend_geometry (void); | ||
8 | |||
9 | #endif // DENSITY_LEGEND_GEOMETRY_H | ||
diff --git a/src/model/display_list_index.h b/src/model/display_list_index.h deleted file mode 100644 index a68f8a7..0000000 --- a/src/model/display_list_index.h +++ b/dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | #ifndef DISPLAY_LIST_INDEX | ||
2 | #define DISPLAY_LIST_INDEX | ||
3 | |||
4 | #define PROTEIN_GEOMETRY 0 | ||
5 | |||
6 | #endif // DISPLAY_LIST_INDEX | ||
diff --git a/src/model/exp004state.h b/src/model/exp004state.h index 1af8a5b..5a9761a 100644 --- a/src/model/exp004state.h +++ b/src/model/exp004state.h | |||
@@ -16,14 +16,16 @@ | |||
16 | #define DEFAULT_COLOR_R 0.00 | 16 | #define DEFAULT_COLOR_R 0.00 |
17 | #define DEFAULT_COLOR_G 0.00 | 17 | #define DEFAULT_COLOR_G 0.00 |
18 | #define DEFAULT_COLOR_B 0.01 | 18 | #define DEFAULT_COLOR_B 0.01 |
19 | #define DEFAULT_COLOR_A 0.25 | 19 | #define DEFAULT_COLOR_A (1.0 / 7.0) |
20 | 20 | ||
21 | #define SELECT_COLOR_R 0.00 | 21 | #define SELECT_COLOR_R 0.00 |
22 | #define SELECT_COLOR_G 0.00 | 22 | #define SELECT_COLOR_G 0.00 |
23 | #define SELECT_COLOR_B 0.00 | 23 | #define SELECT_COLOR_B 0.00 |
24 | #define SELECT_COLOR_A 0.75 | 24 | #define SELECT_COLOR_A 0.75 |
25 | 25 | ||
26 | typedef enum { PROTEIN_GEOMETRY } LISTS; | 26 | typedef enum |
27 | { PROTEIN_GEOMETRY, DENSITY_LEGEND_GEOMETRY } LISTS; | ||
28 | #define NUM_LISTS 2 | ||
27 | 29 | ||
28 | /* | 30 | /* |
29 | * Maintain state of the model. | 31 | * Maintain state of the model. |
@@ -61,10 +63,10 @@ typedef struct | |||
61 | */ | 63 | */ |
62 | struct | 64 | struct |
63 | { | 65 | { |
64 | float min_x; | 66 | double min_x; |
65 | float max_x; | 67 | double max_x; |
66 | float min_y; | 68 | double min_y; |
67 | float max_y; | 69 | double max_y; |
68 | } ortho; | 70 | } ortho; |
69 | 71 | ||
70 | /* | 72 | /* |
diff --git a/src/util/check_error.c b/src/util/check_error.c index cd00439..c47ca43 100644 --- a/src/util/check_error.c +++ b/src/util/check_error.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <GL/glut.h> | 1 | #include <GL/glut.h> |
2 | #include <error.h> | 2 | #include <error.h> |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <stdlib.h> | ||
4 | #include "sqlinfoprint.h" | 5 | #include "sqlinfoprint.h" |
5 | extern struct sqlca sqlca; | 6 | extern struct sqlca sqlca; |
6 | 7 | ||
@@ -15,14 +16,15 @@ check_error (const char *filename, const unsigned int linenum) | |||
15 | if (errCode != GL_NO_ERROR) | 16 | if (errCode != GL_NO_ERROR) |
16 | { | 17 | { |
17 | const GLubyte *errString = gluErrorString (errCode); | 18 | const GLubyte *errString = gluErrorString (errCode); |
18 | error_at_line (-1, errno, filename, linenum, | 19 | error_at_line (EXIT_FAILURE, errno, filename, linenum, |
19 | "OpenGL Error %s", errString); | 20 | "OpenGL Error %s", errString); |
20 | } | 21 | } |
21 | 22 | ||
22 | /* | 23 | /* |
23 | * Check for an error from the Database API. | 24 | * Check for an error from the Database API. |
24 | */ | 25 | */ |
25 | sqlinfoprint ("DB Error", &sqlca, filename, linenum); | 26 | if (sqlinfoprint ("DB Error", &sqlca, filename, linenum) == 1) |
27 | exit (EXIT_FAILURE); | ||
26 | 28 | ||
27 | return; | 29 | return; |
28 | } | 30 | } |
diff --git a/src/view/exp004geometry.c b/src/view/exp004geometry.c index e7193fd..6f3bc17 100644 --- a/src/view/exp004geometry.c +++ b/src/view/exp004geometry.c | |||
@@ -21,13 +21,14 @@ exp004geometry (GLenum mode) | |||
21 | { | 21 | { |
22 | glLoadName (i); | 22 | glLoadName (i); |
23 | glPushMatrix (); | 23 | glPushMatrix (); |
24 | glTranslatef (S.base_vertices_data[i][0], | 24 | glTranslatef (S.base_vertices_data[i][0], |
25 | S.base_vertices_data[i][1], | 25 | S.base_vertices_data[i][1], 0.0); |
26 | 0.0); | ||
27 | glColor4fv (S.base_colors_data[i]); | 26 | glColor4fv (S.base_colors_data[i]); |
28 | glCallList (S.list_offset + PROTEIN_GEOMETRY); | 27 | glCallList (S.list_offset + PROTEIN_GEOMETRY); |
29 | glPopMatrix (); | 28 | glPopMatrix (); |
30 | } | 29 | } |
31 | 30 | ||
31 | glCallList (S.list_offset + DENSITY_LEGEND_GEOMETRY); | ||
32 | |||
32 | return; | 33 | return; |
33 | } | 34 | } |
diff --git a/src/view/exp004init.c b/src/view/exp004init.c index e7da51d..ab12d2a 100644 --- a/src/view/exp004init.c +++ b/src/view/exp004init.c | |||
@@ -1,5 +1,7 @@ | |||
1 | #include "exp004init.h" | 1 | #include "exp004init.h" |
2 | #include "exp004state0.h" | 2 | #include "exp004state0.h" |
3 | #include "../model/density_legend_geometry.h" | ||
4 | #include "../model/protein_geometry.h" | ||
3 | #include "../model/selection_info_init.h" | 5 | #include "../model/selection_info_init.h" |
4 | #include "../model/zoom_info_init.h" | 6 | #include "../model/zoom_info_init.h" |
5 | #include <GL/glut.h> | 7 | #include <GL/glut.h> |
@@ -12,7 +14,9 @@ exp004init (void) | |||
12 | selection_info_init (&S.selection); | 14 | selection_info_init (&S.selection); |
13 | zoom_info_init (&S.zoom); | 15 | zoom_info_init (&S.zoom); |
14 | 16 | ||
15 | S.list_offset = glGenLists (1); | 17 | S.list_offset = glGenLists (NUM_LISTS); |
16 | 18 | protein_geometry (); | |
19 | density_legend_geometry (); | ||
20 | |||
17 | return; | 21 | return; |
18 | } | 22 | } |
diff --git a/src/view/exp004view.c b/src/view/exp004view.c index 68a4e79..33198ad 100644 --- a/src/view/exp004view.c +++ b/src/view/exp004view.c | |||
@@ -4,7 +4,6 @@ | |||
4 | #include "../controller/keyboard.h" | 4 | #include "../controller/keyboard.h" |
5 | #include "../db/dbconnect.h" | 5 | #include "../db/dbconnect.h" |
6 | #include "../model/exp004base.h" | 6 | #include "../model/exp004base.h" |
7 | #include "../model/protein_geometry.h" | ||
8 | #include "exp004init.h" | 7 | #include "exp004init.h" |
9 | #include "exp004state0.h" | 8 | #include "exp004state0.h" |
10 | #include "exp004view.h" | 9 | #include "exp004view.h" |
@@ -25,7 +24,7 @@ exp004view (void) | |||
25 | glClearColor (CLEAR_COLOR); | 24 | glClearColor (CLEAR_COLOR); |
26 | glColor3f (DRAW_COLOR); | 25 | glColor3f (DRAW_COLOR); |
27 | glEnable (GL_AUTO_NORMAL); | 26 | glEnable (GL_AUTO_NORMAL); |
28 | glEnable (GL_DEPTH_TEST); | 27 | glDisable (GL_DEPTH_TEST); |
29 | glEnable (GL_MAP1_VERTEX_3); | 28 | glEnable (GL_MAP1_VERTEX_3); |
30 | glShadeModel (GL_SMOOTH); | 29 | glShadeModel (GL_SMOOTH); |
31 | 30 | ||
@@ -43,7 +42,6 @@ exp004view (void) | |||
43 | // Initialize the model. | 42 | // Initialize the model. |
44 | exp004base (); | 43 | exp004base (); |
45 | exp004init (); | 44 | exp004init (); |
46 | protein_geometry (); | ||
47 | 45 | ||
48 | // Callbacks (Controllers) | 46 | // Callbacks (Controllers) |
49 | glutDisplayFunc (exp004display); | 47 | glutDisplayFunc (exp004display); |