summaryrefslogtreecommitdiffstats
Side-by-side diff
-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 @@
-/* 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 "clear_selection.h"
+#include "../model/map_geometry.h"
#include "../view/exp004state0.h"
#include <GL/glut.h>
#include "sqlca.h"
@@ -40,6 +38,11 @@ clear_selection (void)
sizeof (S.base_colors_data), S.base_colors_data,
GL_STATIC_DRAW);
+ /*
+ * Rebuild the display list for the map.
+ */
+ map_geometry ();
+
glutPostRedisplay ();
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 @@
#define GL_GLEXT_PROTOTYPES
#include "../view/exp004state0.h"
+#include "../model/map_geometry.h"
#include "exp004processhits.h"
#include "selsave.h"
#include <stdio.h>
@@ -42,5 +43,10 @@ exp004processhits (GLint hits, GLuint buffer[])
sizeof (S.base_colors_data), S.base_colors_data,
GL_STATIC_DRAW);
+ /*
+ * Rebuild the display list for the map.
+ */
+ map_geometry ();
+
return;
}
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)
* ESC Pressed.
*/
clear_selection ();
+ glutPostRedisplay ();
break;
case 'g':
@@ -26,6 +27,15 @@ keyboard (unsigned char key, int x, int y)
* refreshing a buffer in Emacs.
*/
selection_from_db ();
+ glutPostRedisplay ();
+ break;
+
+ case 'l':
+ /*
+ * Toggle display of the legend.
+ */
+ S.legend = !S.legend;
+ glutPostRedisplay ();
break;
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 @@
#define GL_GLEXT_PROTOTYPES
#include "selection_from_db.h"
+#include "../model/map_geometry.h"
#include "../view/exp004state0.h"
#include "../util/check_error.h"
#include <GL/glut.h>
@@ -62,6 +63,11 @@ selection_from_db (void)
sizeof (S.base_colors_data), S.base_colors_data,
GL_STATIC_DRAW);
+ /*
+ * Rebuild the display list.
+ */
+ map_geometry ();
+
glutPostRedisplay ();
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 @@
#include "../view/exp004state0.h"
#include "../controller/exp004reshape.h"
#include <GL/glut.h>
-#include <stdio.h>
#define S exp004state0
@@ -15,13 +14,6 @@ density_legend_geometry (void)
DEFAULT_COLOR_A);
/*
- * This value should be a percentage of the world height so that it
- * remains a fixed number of pixels tall when the window is resized
- * or zoomed.
- */
- double legend_height = 0.5;
-
- /*
* Calculate the bounding box for the legend.
*/
@@ -33,20 +25,30 @@ density_legend_geometry (void)
const double *left;
const double *right;
const double *top;
+ const double *bottom;
if (S.zoom.active)
{
left = &S.zoom.coords[0];
right = &S.zoom.coords[1];
+ bottom = &S.zoom.coords[2];
top = &S.zoom.coords[3];
}
else
{
left = &S.ortho.min_x;
- top = &S.ortho.max_y;
right = &S.ortho.max_x;
+ bottom = &S.ortho.min_y;
+ top = &S.ortho.max_y;
}
+ /*
+ * This value should be a percentage of the world height so that it
+ * remains a fixed number of pixels tall when the window is resized
+ * or zoomed.
+ */
+ double legend_height = (*top - *bottom) / S.viewport.h * 10.0;
+
a[0] = *left;
a[1] = *top;
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 @@
#define SELECT_COLOR_A 0.75
typedef enum
-{ PROTEIN_GEOMETRY, DENSITY_LEGEND_GEOMETRY } LISTS;
+ { PROTEIN_GEOMETRY, DENSITY_LEGEND_GEOMETRY, MAP_GEOMETRY } LISTS;
#define NUM_LISTS 2
/*
@@ -102,6 +102,11 @@ typedef struct
ZOOM_INFO zoom;
+ /*
+ * Display a legend on the map.
+ */
+ bool legend;
+
} EXP004STATE;
#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)
*/
GLUquadricObj *obj = gluNewQuadric ();
gluQuadricDrawStyle (obj, GLU_FILL);
+
glNewList (S.list_offset + PROTEIN_GEOMETRY, GL_COMPILE);
gluSphere (obj, 0.05, 20, 20);
glEndList ();
+
gluDeleteQuadric (obj);
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 @@
-/* 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 "exp004geometry.h"
#include "exp004state0.h"
#include <GL/glut.h>
@@ -14,21 +11,16 @@ exp004geometry (GLenum mode)
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
- glPointSize (0.1);
- glColor3f (0.2, 0.2, 0.2);
-
- for (int i = 0; i < ROWS; i++)
- {
- glLoadName (i);
- glPushMatrix ();
- glTranslatef (S.base_vertices_data[i][0],
- S.base_vertices_data[i][1], 0.0);
- glColor4fv (S.base_colors_data[i]);
- glCallList (S.list_offset + PROTEIN_GEOMETRY);
- glPopMatrix ();
- }
+ /*
+ * Draw the map.
+ */
+ glCallList (S.list_offset + MAP_GEOMETRY);
- glCallList (S.list_offset + DENSITY_LEGEND_GEOMETRY);
+ /*
+ * Draw the legend.
+ */
+ if (S.legend)
+ glCallList (S.list_offset + DENSITY_LEGEND_GEOMETRY);
return;
}
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 @@
#include "exp004init.h"
#include "exp004state0.h"
#include "../model/density_legend_geometry.h"
+#include "../model/map_geometry.h"
#include "../model/protein_geometry.h"
#include "../model/selection_info_init.h"
#include "../model/zoom_info_init.h"
@@ -13,10 +14,12 @@ exp004init (void)
{
selection_info_init (&S.selection);
zoom_info_init (&S.zoom);
+ S.legend = true;
S.list_offset = glGenLists (NUM_LISTS);
protein_geometry ();
density_legend_geometry ();
+ map_geometry ();
return;
}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.