15 #include <grass/glocale.h>
16 #include <grass/nviz.h>
32 data->num_cplanes = 0;
34 for (i = 0; i < MAX_CPLANES; i++) {
42 for (i = 0; i < MAX_LIGHTS - 1; i++) {
47 data->num_fringes = 0;
55 data->num_scalebars = 0;
56 data->scalebar =
NULL;
68 for (i = 0; data->num_fringes; i++) {
70 data->fringe[i] =
NULL;
72 data->num_fringes = 0;
81 for (i = 0; data->num_scalebars; i++) {
83 data->scalebar[i] =
NULL;
85 data->num_scalebars = 0;
86 data->scalebar =
NULL;
97 data->bgcolor =
color;
111 return data->bgcolor;
126 G_warning(_(
"Invalid color (%s), using \"white\" as default"),
128 red = grn = blu = 255;
147 int id,
unsigned long color,
148 double elev,
int nw,
int ne,
int sw,
int se)
152 struct fringe_data *f;
164 f = (
struct fringe_data *) G_malloc(
sizeof(
struct fringe_data));
173 data->fringe = (
struct fringe_data **) G_realloc(data->fringe, data->num_fringes + 1 *
sizeof(
struct fringe_data *));
174 data->fringe[data->num_fringes++] = f;
191 int id,
unsigned long color,
192 double elev,
int nw,
int ne,
int sw,
int se)
196 struct fringe_data *f;
207 for (i = 0; i < data->num_fringes; i++) {
223 elev, nw, ne, sw, se);
235 for (i = 0; i < data->num_fringes; i++) {
236 struct fringe_data *f = data->fringe[i];
250 int sx,
int sy,
float size,
254 int *surf_list, num_surfs;
256 struct arrow_data *arw;
269 data->arrow->color =
color;
270 data->arrow->size =
size;
271 data->arrow->where[0] = coords[0];
272 data->arrow->where[1] = coords[1];
273 data->arrow->where[2] = coords[2];
276 arw = (
struct arrow_data *) G_malloc(
sizeof(
struct arrow_data));
279 arw->where[0] = coords[0];
280 arw->where[1] = coords[1];
281 arw->where[2] = coords[2];
299 struct arrow_data *arw = data->arrow;
302 data->draw_arrow = 1;
303 gsd_north_arrow(arw->where, arw->size, FontBase, arw->color, arw->color);
315 data->draw_arrow = 0;
333 int bar_id,
float *coords,
float size,
336 struct scalebar_data *
s;
339 s = (
struct scalebar_data *) G_malloc(
sizeof(
struct scalebar_data));
343 s->where[0] = coords[0];
344 s->where[1] = coords[1];
345 s->where[2] = coords[2];
347 data->scalebar = (
struct scalebar_data **) G_realloc(data->scalebar,
348 data->num_scalebars + 1 *
sizeof(
struct scalebar_data *));
349 data->scalebar[data->num_scalebars++] =
s;
367 int sx,
int sy,
float size,
371 int *surf_list, num_surfs;
373 struct scalebar_data *
s;
385 for (i = 0; i < data->num_scalebars; i++) {
386 s = data->scalebar[i];
387 if (s->id == bar_id) {
390 s->where[0] = coords[0];
391 s->where[1] = coords[1];
392 s->where[2] = coords[2];
415 for (i = 0; i < data->num_scalebars; i++) {
416 struct scalebar_data *
s = data->scalebar[i];
429 if (bar_id < data->num_scalebars) {
430 G_free(data->scalebar[bar_id]);
431 data->scalebar[bar_id] =
NULL;
432 data->num_scalebars--;
void G_free(void *buf)
Free allocated memory.
int Nviz_color_from_str(const char *color_str)
Get color value from color string (name or RGB triplet)
void Nviz_delete_arrow(nv_data *data)
Deletes the North Arrow.
int GS_surf_exists(int id)
int gsd_north_arrow(float *pos2, float len, GLuint fontbase, unsigned long arw_clr, unsigned long text_clr)
Draw North Arrow takes OpenGL coords and size.
void Nviz_init_data(nv_data *data)
Initialize Nviz data.
void GS_draw_fringe(int id, unsigned long clr, float elev, int *where)
Draw fringe around data (surface) at selected corners.
int Nviz_get_bgcolor(nv_data *data)
Get background color.
void GS_set_Narrow(int *pt, int id, float *pos2)
Set decoration, north arrow ??
int Nviz_off_cplane(nv_data *data, int id)
Turn off (make inactive) the given clip plane.
void Nviz_draw_scalebar(nv_data *data)
Draws the Scale bar.
void GS_set_light_reset(int i)
struct fringe_data * Nviz_new_fringe(nv_data *data, int id, unsigned long color, double elev, int nw, int ne, int sw, int se)
struct scalebar_data * Nviz_new_scalebar(nv_data *data, int bar_id, float *coords, float size, unsigned int color)
int GS_num_surfs(void)
Get number of surfaces.
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
void Nviz_destroy_data(nv_data *data)
Free allocated space by nv_data struct.
int Nviz_draw_arrow(nv_data *data)
Draws the North Arrow.
int Nviz_new_cplane(nv_data *data, int id)
Creates a clip plane object.
struct fringe_data * Nviz_set_fringe(nv_data *data, int id, unsigned long color, double elev, int nw, int ne, int sw, int se)
int * GS_get_surf_list(int *numsurfs)
Get surface list.
void Nviz_set_bgcolor(nv_data *data, int color)
Set background color.
int G_str_to_color(const char *str, int *red, int *grn, int *blu)
Parse color string and set red,green,blue.
int gsd_scalebar_v2(float *pos, float len, GLuint fontbase, unsigned long bar_clr, unsigned long text_clr)
Draw Scalebar (as lines)
void Nviz_draw_fringe(nv_data *data)
void Nviz_delete_scalebar(nv_data *data, int bar_id)
Deletes scale bar.
int Nviz_new_light(nv_data *data)
Define new light.
struct scalebar_data * Nviz_set_scalebar(nv_data *data, int bar_id, int sx, int sy, float size, unsigned int color)
Sets the scale bar position and return world coords.
int Nviz_set_arrow(nv_data *data, int sx, int sy, float size, unsigned int color)
Sets the North Arrow position and return world coords.