path:
root/
src/
model/
geometry/
density_legend_geometry.c (
plain)
blob: ac3280cb43be58f1f4c180c319e722e766b68369
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#include "../../controller/callbacks/reshape.h"
#include "../../view/state0.h"
#include "density_legend_geometry.h"
#include <GL/glut.h>
#define S state0
void
density_legend_geometry (void)
{
glNewList (S.list_offset + DENSITY_LEGEND_GEOMETRY, GL_COMPILE);
glPolygonMode (GL_FRONT, GL_FILL);
glColor4f (DEFAULT_COLOR_R, DEFAULT_COLOR_G, DEFAULT_COLOR_B,
DEFAULT_COLOR_A);
/*
* Calculate the bounding box for the legend.
*/
double a[2];
double b[2];
double c[2];
double d[2];
const double *left;
const double *right;
const double *top;
const double *bottom;
left = &S.ortho.min_x;
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.
*/
GLint viewport[4];
glGetIntegerv (GL_VIEWPORT, viewport);
double legend_height = (*top - *bottom) / viewport[3] * 10.0;
a[0] = *left;
a[1] = *top;
b[0] = *right;
b[1] = *top;
c[0] = *right;
c[1] = *top - legend_height;
d[0] = *left;
d[1] = *top - legend_height;
/*
* Overlay a legend from default saturation / alpha to full saturation.
*/
for (int i = 1; i <= 1 / DEFAULT_COLOR_A; i++)
{
glBegin (GL_QUADS);
glVertex2dv (a);
glVertex2dv (b);
glVertex2dv (c);
glVertex2dv (d);
glEnd ();
/*
* Step left to right along the x-coordinate.
*/
a[0] = *left + (*right - *left) * (DEFAULT_COLOR_A * i);
d[0] = a[0];
}
glEndList ();
return;
}
|