81
133
return (red & RED_MASK) + ((int)((grn) << 8) & GRN_MASK) +
82
134
((int)((blu) << 16) & BLU_MASK);
139
\param data nviz data
142
\param elev fringe elevation
143
\param nw,ne,sw,se 1 (turn on) 0 (turn off)
145
\return pointer to allocated fringe_data structure
146
\return NULL on error
148
struct fringe_data *Nviz_new_fringe(nv_data *data,
149
int id, unsigned long color,
150
double elev, int nw, int ne, int sw, int se)
154
struct fringe_data *f;
156
if (!GS_surf_exists(id)) {
157
/* select first surface from the list */
158
surf = GS_get_surf_list(&num);
166
f = (struct fringe_data *) G_malloc(sizeof(struct fringe_data));
175
data->fringe = (struct fringe_data **) G_realloc(data->fringe, data->num_fringes + 1 * sizeof(struct fringe_data *));
176
data->fringe[data->num_fringes++] = f;
183
\param data nviz data
186
\param elev fringe elevation
187
\param nw,ne,sw,se 1 (turn on) 0 (turn off)
189
\return pointer to allocated fringe_data structure
190
\return NULL on error
192
struct fringe_data *Nviz_set_fringe(nv_data *data,
193
int id, unsigned long color,
194
double elev, int nw, int ne, int sw, int se)
198
struct fringe_data *f;
200
if (!GS_surf_exists(id)) {
201
/* select first surface from the list */
202
surf = GS_get_surf_list(&num);
209
for (i = 0; i < data->num_fringes; i++) {
223
f = Nviz_new_fringe(data,
225
elev, nw, ne, sw, se);
231
\param data nviz data
233
void Nviz_draw_fringe(nv_data *data)
237
for (i = 0; i < data->num_fringes; i++) {
238
struct fringe_data *f = data->fringe[i];
240
GS_draw_fringe(f->id, f->color, f->elev, f->where);
244
\brief Sets the North Arrow position and return world coords
246
\param data nviz data
247
\param sx,sy screen coordinates
248
\param size arrow length
249
\param color arrow/text color
251
int Nviz_set_arrow(nv_data *data,
252
int sx, int sy, float size,
256
int *surf_list, num_surfs;
258
struct arrow_data *arw;
260
if (GS_num_surfs() > 0) {
261
surf_list = GS_get_surf_list(&num_surfs);
268
GS_set_Narrow(pt, id, coords);
271
data->arrow->color = color;
272
data->arrow->size = size;
273
data->arrow->where[0] = coords[0];
274
data->arrow->where[1] = coords[1];
275
data->arrow->where[2] = coords[2];
278
arw = (struct arrow_data *) G_malloc(sizeof(struct arrow_data));
281
arw->where[0] = coords[0];
282
arw->where[1] = coords[1];
283
arw->where[2] = coords[2];
294
\brief Draws the North Arrow
296
\param data nviz data
298
int Nviz_draw_arrow(nv_data *data)
301
struct arrow_data *arw = data->arrow;
302
GLuint FontBase = 0; /* don't know how to get fontbase*/
304
data->draw_arrow = 1;
305
gsd_north_arrow(arw->where, arw->size, FontBase, arw->color, arw->color);
311
\brief Deletes the North Arrow
313
\param data nviz data
315
void Nviz_delete_arrow(nv_data *data)
317
data->draw_arrow = 0;
324
\param data nviz data
325
\param bar_id scale bar id
326
\param coords real(?) coordinates
327
\param size scale bar length
328
\param color scalebar/text color
330
\return pointer to allocated scalebar_data structure
331
\return NULL on error
334
struct scalebar_data *Nviz_new_scalebar(nv_data *data,
335
int bar_id, float *coords, float size,
338
struct scalebar_data *s;
341
s = (struct scalebar_data *) G_malloc(sizeof(struct scalebar_data));
345
s->where[0] = coords[0];
346
s->where[1] = coords[1];
347
s->where[2] = coords[2];
349
data->scalebar = (struct scalebar_data **) G_realloc(data->scalebar,
350
(data->num_scalebars + 1) * sizeof(struct scalebar_data *));
351
data->scalebar[data->num_scalebars++] = s;
357
\brief Sets the scale bar position and return world coords
359
\param data nviz data
360
\param bar_id scale bar id
361
\param sx,sy screen coordinates
362
\param size scale bar length
363
\param color scalebar/text color
365
\return pointer to allocated scalebar_data structure
366
\return NULL when there's no surface
368
struct scalebar_data *Nviz_set_scalebar(nv_data *data, int bar_id,
369
int sx, int sy, float size,
373
int *surf_list, num_surfs;
375
struct scalebar_data *s;
377
if (GS_num_surfs() > 0) {
378
surf_list = GS_get_surf_list(&num_surfs);
385
GS_set_Narrow(pt, id, coords); /* the same like arrow */
387
for (i = 0; i < data->num_scalebars; i++) {
388
if (data->scalebar[i]) {
389
s = data->scalebar[i];
390
if (s->id == bar_id) {
393
s->where[0] = coords[0];
394
s->where[1] = coords[1];
395
s->where[2] = coords[2];
402
s = Nviz_new_scalebar(data, bar_id, coords, size, color);
409
\brief Draws the Scale bar
411
\param data nviz data
413
void Nviz_draw_scalebar(nv_data *data)
417
GLuint FontBase = 0; /* don't know how to get fontbase*/
419
for (i = 0; i < data->num_scalebars; i++) {
420
if (data->scalebar[i]) {
421
struct scalebar_data *s = data->scalebar[i];
423
gsd_scalebar_v2(s->where, s->size, FontBase, s->color, s->color);
429
\brief Deletes scale bar
431
When scalebar is freed, array then contains NULL,
432
which must be tested during drawing.
434
\param data nviz data
436
void Nviz_delete_scalebar(nv_data *data, int bar_id)
438
if (bar_id < data->num_scalebars && data->scalebar[bar_id] != NULL) {
439
G_free(data->scalebar[bar_id]);
440
data->scalebar[bar_id] = NULL;