summaryrefslogtreecommitdiffstats
Unidiff
-rw-r--r--r/connect.R2
-rw-r--r--src/Makefile.am3
-rw-r--r--src/controller/exp004reshape.c11
-rw-r--r--src/model/density_legend_geometry.c81
-rw-r--r--src/model/density_legend_geometry.h9
-rw-r--r--src/model/display_list_index.h6
-rw-r--r--src/model/exp004state.h14
-rw-r--r--src/util/check_error.c6
-rw-r--r--src/view/exp004geometry.c7
-rw-r--r--src/view/exp004init.c8
-rw-r--r--src/view/exp004view.c4
11 files changed, 124 insertions, 27 deletions
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
9void
10density_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}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.