GRASS Programmer's Manual  6.5.svn(2014)-r66266
 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);
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 
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);
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 }
void gsd_end_legend_viewport(void)
ADD.
Definition: gsd_legend.c:90
int l
Definition: dataquad.c:292
float b
Definition: named_colr.c:8
void do_label_display(GLuint fontbase, float *lab_pos, const char *txt)
Display label.
Definition: gsd_fonts.c:99
GLuint label_base
Definition: gsd_label.c:28
float r
Definition: named_colr.c:8
#define Y(x)
Definition: display/draw.c:246
#define X(y)
Definition: display/draw.c:248
void gsd_color_func(unsigned int col)
Set current color.
Definition: gsd_prim.c:689
void gsd_remove_all(void)
Remove all labels from display list.
Definition: gsd_label.c:111
void gsd_call_label(void)
Call display list and draw defined labels – called from gsd_prim (gsd_call_lists) ...
Definition: gsd_label.c:122
tuple size
value.Bind(wx.EVT_TEXT, self.OnVolumeIsosurfMap)
Definition: tools.py:2334
tuple color
Definition: tools.py:1703
#define MAX_LIST
Definition: gsd_label.c:25
void gs_put_label(const char *text, GLuint fontbase, int size, unsigned long color, int *pt)
Put label.
Definition: gsd_label.c:41
int first
Definition: form/open.c:25
GLuint label_id
Definition: gsd_label.c:29
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
void gsd_bgn_legend_viewport(GLint wl, GLint wb, GLint wr, GLint wt)
ADD.
Definition: gsd_legend.c:60
void gsd_remove_curr(void)
Remove current label.
Definition: gsd_label.c:97
int gsd_get_txtwidth(const char *s, int size)
Get text width.
Definition: gsd_fonts.c:37