summaryrefslogtreecommitdiffstats
authorDon Pellegrino <don@drexel.edu>2009-07-07 01:29:54 (GMT)
committer Don Pellegrino <don@drexel.edu>2009-07-07 01:29:54 (GMT)
commit94b89e8fc1b0980dfe1f6856005d4ea8a5aa477e (patch) (unidiff)
tree86900af9901ce653c2667f0ffc84dc49d467a867
parent36e8103a5a09869ce64fd41253280446195c0a0e (diff)
downloadexp005-94b89e8fc1b0980dfe1f6856005d4ea8a5aa477e.zip
exp005-94b89e8fc1b0980dfe1f6856005d4ea8a5aa477e.tar.gz
exp005-94b89e8fc1b0980dfe1f6856005d4ea8a5aa477e.tar.bz2
Set the legend to appear as a constant height above the map. Set
updating of the map display list to be done only when the contents change.
-rw-r--r--src/controller/clear_selection.sqc9
-rw-r--r--src/controller/exp004processhits.c6
-rw-r--r--src/controller/keyboard.c10
-rw-r--r--src/controller/selection_from_db.sqc6
-rw-r--r--src/model/density_legend_geometry.c20
-rw-r--r--src/model/exp004state.h7
-rw-r--r--src/model/protein_geometry.c2
-rw-r--r--src/view/exp004geometry.c26
-rw-r--r--src/view/exp004init.c3
9 files changed, 59 insertions, 30 deletions
diff --git a/src/controller/clear_selection.sqc b/src/controller/clear_selection.sqc
index 01a5364..ec98b4c 100644
--- a/src/controller/clear_selection.sqc
+++ b/src/controller/clear_selection.sqc
@@ -1,8 +1,6 @@
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_PROTOTYPES1#define GL_GLEXT_PROTOTYPES
4
5#include "clear_selection.h"2#include "clear_selection.h"
3#include "../model/map_geometry.h"
6#include "../view/exp004state0.h"4#include "../view/exp004state0.h"
7#include <GL/glut.h>5#include <GL/glut.h>
8#include "sqlca.h"6#include "sqlca.h"
@@ -40,6 +38,11 @@ clear_selection (void)
40 sizeof (S.base_colors_data), S.base_colors_data,38 sizeof (S.base_colors_data), S.base_colors_data,
41 GL_STATIC_DRAW);39 GL_STATIC_DRAW);
4240
41 /*
42 * Rebuild the display list for the map.
43 */
44 map_geometry ();
45
43 glutPostRedisplay ();46 glutPostRedisplay ();
4447
45 return;48 return;
diff --git a/src/controller/exp004processhits.c b/src/controller/exp004processhits.c
index 264bd46..418f23a 100644
--- a/src/controller/exp004processhits.c
+++ b/src/controller/exp004processhits.c
@@ -1,5 +1,6 @@
1#define GL_GLEXT_PROTOTYPES1#define GL_GLEXT_PROTOTYPES
2#include "../view/exp004state0.h"2#include "../view/exp004state0.h"
3#include "../model/map_geometry.h"
3#include "exp004processhits.h"4#include "exp004processhits.h"
4#include "selsave.h"5#include "selsave.h"
5#include <stdio.h>6#include <stdio.h>
@@ -42,5 +43,10 @@ exp004processhits (GLint hits, GLuint buffer[])
42 sizeof (S.base_colors_data), S.base_colors_data,43 sizeof (S.base_colors_data), S.base_colors_data,
43 GL_STATIC_DRAW);44 GL_STATIC_DRAW);
4445
46 /*
47 * Rebuild the display list for the map.
48 */
49 map_geometry ();
50
45 return;51 return;
46}52}
diff --git a/src/controller/keyboard.c b/src/controller/keyboard.c
index d817d7c..99a20d0 100644
--- a/src/controller/keyboard.c
+++ b/src/controller/keyboard.c
@@ -17,6 +17,7 @@ keyboard (unsigned char key, int x, int y)
17 * ESC Pressed.17 * ESC Pressed.
18 */18 */
19 clear_selection ();19 clear_selection ();
20 glutPostRedisplay ();
20 break;21 break;
2122
22 case 'g':23 case 'g':
@@ -26,6 +27,15 @@ keyboard (unsigned char key, int x, int y)
26 * refreshing a buffer in Emacs.27 * refreshing a buffer in Emacs.
27 */28 */
28 selection_from_db ();29 selection_from_db ();
30 glutPostRedisplay ();
31 break;
32
33 case 'l':
34 /*
35 * Toggle display of the legend.
36 */
37 S.legend = !S.legend;
38 glutPostRedisplay ();
29 break;39 break;
3040
31 case 'r':41 case 'r':
diff --git a/src/controller/selection_from_db.sqc b/src/controller/selection_from_db.sqc
index 8c12c79..ccefa4a 100644
--- a/src/controller/selection_from_db.sqc
+++ b/src/controller/selection_from_db.sqc
@@ -1,5 +1,6 @@
1#define GL_GLEXT_PROTOTYPES1#define GL_GLEXT_PROTOTYPES
2#include "selection_from_db.h"2#include "selection_from_db.h"
3#include "../model/map_geometry.h"
3#include "../view/exp004state0.h"4#include "../view/exp004state0.h"
4#include "../util/check_error.h"5#include "../util/check_error.h"
5#include <GL/glut.h>6#include <GL/glut.h>
@@ -62,6 +63,11 @@ selection_from_db (void)
62 sizeof (S.base_colors_data), S.base_colors_data,63 sizeof (S.base_colors_data), S.base_colors_data,
63 GL_STATIC_DRAW);64 GL_STATIC_DRAW);
6465
66 /*
67 * Rebuild the display list.
68 */
69 map_geometry ();
70
65 glutPostRedisplay ();71 glutPostRedisplay ();
6672
67 return;73 return;
diff --git a/src/model/density_legend_geometry.c b/src/model/density_legend_geometry.c
index ab3e46c..7e30de8 100644
--- a/src/model/density_legend_geometry.c
+++ b/src/model/density_legend_geometry.c
@@ -2,7 +2,6 @@
2#include "../view/exp004state0.h"2#include "../view/exp004state0.h"
3#include "../controller/exp004reshape.h"3#include "../controller/exp004reshape.h"
4#include <GL/glut.h>4#include <GL/glut.h>
5#include <stdio.h>
65
7#define S exp004state06#define S exp004state0
87
@@ -15,13 +14,6 @@ density_legend_geometry (void)
15 DEFAULT_COLOR_A);14 DEFAULT_COLOR_A);
1615
17 /*16 /*
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.17 * Calculate the bounding box for the legend.
26 */18 */
2719
@@ -33,20 +25,30 @@ density_legend_geometry (void)
33 const double *left;25 const double *left;
34 const double *right;26 const double *right;
35 const double *top;27 const double *top;
28 const double *bottom;
3629
37 if (S.zoom.active)30 if (S.zoom.active)
38 {31 {
39 left = &S.zoom.coords[0];32 left = &S.zoom.coords[0];
40 right = &S.zoom.coords[1];33 right = &S.zoom.coords[1];
34 bottom = &S.zoom.coords[2];
41 top = &S.zoom.coords[3];35 top = &S.zoom.coords[3];
42 }36 }
43 else37 else
44 {38 {
45 left = &S.ortho.min_x;39 left = &S.ortho.min_x;
46 top = &S.ortho.max_y;
47 right = &S.ortho.max_x;40 right = &S.ortho.max_x;
41 bottom = &S.ortho.min_y;
42 top = &S.ortho.max_y;
48 }43 }
4944
45 /*
46 * This value should be a percentage of the world height so that it
47 * remains a fixed number of pixels tall when the window is resized
48 * or zoomed.
49 */
50 double legend_height = (*top - *bottom) / S.viewport.h * 10.0;
51
50 a[0] = *left;52 a[0] = *left;
51 a[1] = *top;53 a[1] = *top;
52 b[0] = *right;54 b[0] = *right;
diff --git a/src/model/exp004state.h b/src/model/exp004state.h
index 5a9761a..6473028 100644
--- a/src/model/exp004state.h
+++ b/src/model/exp004state.h
@@ -24,7 +24,7 @@
24#define SELECT_COLOR_A 0.7524#define SELECT_COLOR_A 0.75
2525
26typedef enum26typedef enum
27{ PROTEIN_GEOMETRY, DENSITY_LEGEND_GEOMETRY } LISTS;27 { PROTEIN_GEOMETRY, DENSITY_LEGEND_GEOMETRY, MAP_GEOMETRY } LISTS;
28#define NUM_LISTS 228#define NUM_LISTS 2
2929
30/*30/*
@@ -102,6 +102,11 @@ typedef struct
102102
103 ZOOM_INFO zoom;103 ZOOM_INFO zoom;
104104
105 /*
106 * Display a legend on the map.
107 */
108 bool legend;
109
105} EXP004STATE;110} EXP004STATE;
106111
107#endif // EXP004STATE_H112#endif // EXP004STATE_H
diff --git a/src/model/protein_geometry.c b/src/model/protein_geometry.c
index 001b578..dc71a4e 100644
--- a/src/model/protein_geometry.c
+++ b/src/model/protein_geometry.c
@@ -12,9 +12,11 @@ protein_geometry (void)
12 */12 */
13 GLUquadricObj *obj = gluNewQuadric ();13 GLUquadricObj *obj = gluNewQuadric ();
14 gluQuadricDrawStyle (obj, GLU_FILL);14 gluQuadricDrawStyle (obj, GLU_FILL);
15
15 glNewList (S.list_offset + PROTEIN_GEOMETRY, GL_COMPILE);16 glNewList (S.list_offset + PROTEIN_GEOMETRY, GL_COMPILE);
16 gluSphere (obj, 0.05, 20, 20);17 gluSphere (obj, 0.05, 20, 20);
17 glEndList ();18 glEndList ();
19
18 gluDeleteQuadric (obj);20 gluDeleteQuadric (obj);
1921
20 return;22 return;
diff --git a/src/view/exp004geometry.c b/src/view/exp004geometry.c
index 6f3bc17..76f39bb 100644
--- a/src/view/exp004geometry.c
+++ b/src/view/exp004geometry.c
@@ -1,7 +1,4 @@
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_PROTOTYPES1#define GL_GLEXT_PROTOTYPES
4
5#include "exp004geometry.h"2#include "exp004geometry.h"
6#include "exp004state0.h"3#include "exp004state0.h"
7#include <GL/glut.h>4#include <GL/glut.h>
@@ -14,21 +11,16 @@ exp004geometry (GLenum mode)
14 glMatrixMode (GL_MODELVIEW);11 glMatrixMode (GL_MODELVIEW);
15 glLoadIdentity ();12 glLoadIdentity ();
1613
17 glPointSize (0.1);14 /*
18 glColor3f (0.2, 0.2, 0.2);15 * Draw the map.
1916 */
20 for (int i = 0; i < ROWS; i++)17 glCallList (S.list_offset + MAP_GEOMETRY);
21 {
22 glLoadName (i);
23 glPushMatrix ();
24 glTranslatef (S.base_vertices_data[i][0],
25 S.base_vertices_data[i][1], 0.0);
26 glColor4fv (S.base_colors_data[i]);
27 glCallList (S.list_offset + PROTEIN_GEOMETRY);
28 glPopMatrix ();
29 }
3018
31 glCallList (S.list_offset + DENSITY_LEGEND_GEOMETRY);19 /*
20 * Draw the legend.
21 */
22 if (S.legend)
23 glCallList (S.list_offset + DENSITY_LEGEND_GEOMETRY);
3224
33 return;25 return;
34}26}
diff --git a/src/view/exp004init.c b/src/view/exp004init.c
index ab12d2a..78311e6 100644
--- a/src/view/exp004init.c
+++ b/src/view/exp004init.c
@@ -1,6 +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"3#include "../model/density_legend_geometry.h"
4#include "../model/map_geometry.h"
4#include "../model/protein_geometry.h"5#include "../model/protein_geometry.h"
5#include "../model/selection_info_init.h"6#include "../model/selection_info_init.h"
6#include "../model/zoom_info_init.h"7#include "../model/zoom_info_init.h"
@@ -13,10 +14,12 @@ exp004init (void)
13{14{
14 selection_info_init (&S.selection);15 selection_info_init (&S.selection);
15 zoom_info_init (&S.zoom);16 zoom_info_init (&S.zoom);
17 S.legend = true;
1618
17 S.list_offset = glGenLists (NUM_LISTS);19 S.list_offset = glGenLists (NUM_LISTS);
18 protein_geometry ();20 protein_geometry ();
19 density_legend_geometry ();21 density_legend_geometry ();
22 map_geometry ();
2023
21 return;24 return;
22}25}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.