GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
gsd_label.c
Go to the documentation of this file.
1
19
#include <grass/gis.h>
20
#include <grass/glocale.h>
21
#include <grass/gstypes.h>
22
23
#include "
rgbpack.h
"
24
25
#define MAX_LIST 20
26
27
static
int
first
= 0;
28
GLuint
label_base
;
29
GLuint
label_id
;
30
41
void
gs_put_label
(
const
char
*text, GLuint fontbase,
int
size,
42
unsigned
long
color,
int
*pt)
43
{
44
int
txt_width;
45
GLint tmp[4];
46
float
labpt[2];
47
int
t, l,
b
,
r
;
48
49
if
(!
first
) {
50
/* initialize display list */
51
label_base
= glGenLists(
MAX_LIST
);
52
glListBase(
label_base
);
53
label_id
=
label_base
;
54
first
= 1;
55
}
56
57
if
(
label_id
> (
label_base
+
MAX_LIST
)) {
58
G_warning
(_(
"Max. number of labels reached!"
));
59
return
;
60
}
61
62
glNewList(
label_id
, GL_COMPILE_AND_EXECUTE);
63
txt_width =
gsd_get_txtwidth
(text, size);
64
65
/* adjust to center text string */
66
labpt[
X
] = (float)(pt[
X
] - txt_width / 2.);
67
labpt[
Y
] = (float)pt[
Y
];
68
69
glGetIntegerv(GL_VIEWPORT, tmp);
70
l = tmp[0];
71
r = tmp[0] + tmp[2];
72
b = tmp[1];
73
t = tmp[1] + tmp[3];
74
75
gsd_bgn_legend_viewport
(l, b, r, t);
76
77
78
/* Set text color */
79
gsd_color_func
(color);
80
81
do_label_display
(fontbase, labpt, text);
82
83
84
gsd_end_legend_viewport
();
85
86
glEndList();
87
88
label_id
++;
89
90
return
;
91
}
92
93
97
void
gsd_remove_curr
(
void
)
98
{
99
if
(
label_id
) {
100
glDeleteLists(
label_id
- 1, 1);
101
label_id
--;
102
}
103
104
return
;
105
}
106
107
111
void
gsd_remove_all
(
void
)
112
{
113
glDeleteLists(
label_base
,
MAX_LIST
);
114
label_id
=
label_base
;
115
116
return
;
117
}
118
122
void
gsd_call_label
(
void
)
123
{
124
int
i;
125
126
for
(i = 0; i <
MAX_LIST
; i++) {
127
glCallList(i +
label_base
);
128
glFlush();
129
}
130
return
;
131
}
lib
ogsf
gsd_label.c
Generated on Sun Sep 9 2012 18:55:32 for GRASS Programmer's Manual by
1.8.1.2