15 #include <grass/colors.h>
16 #include <grass/raster.h>
17 #include <grass/glocale.h>
18 #include <grass/nviz.h>
34 data->num_cplanes = 0;
36 for (i = 0; i < MAX_CPLANES; i++) {
44 for (i = 0; i < MAX_LIGHTS - 1; i++) {
49 data->num_fringes = 0;
57 data->num_scalebars = 0;
58 data->scalebar =
NULL;
70 for (i = 0; i < data->num_fringes; i++) {
72 data->fringe[i] =
NULL;
74 data->num_fringes = 0;
83 for (i = 0; i < data->num_scalebars; i++) {
85 data->scalebar[i] =
NULL;
87 data->num_scalebars = 0;
88 data->scalebar =
NULL;
99 data->bgcolor = color;
113 return data->bgcolor;
128 G_warning(_(
"Invalid color (%s), using \"white\" as default"),
130 red = grn = blu = 255;
149 int id,
unsigned long color,
150 double elev,
int nw,
int ne,
int sw,
int se)
154 struct fringe_data *f;
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;
193 int id,
unsigned long color,
194 double elev,
int nw,
int ne,
int sw,
int se)
198 struct fringe_data *f;
209 for (i = 0; i < data->num_fringes; i++) {
225 elev, nw, ne, sw, se);
237 for (i = 0; i < data->num_fringes; i++) {
238 struct fringe_data *f = data->fringe[i];
252 int sx,
int sy,
float size,
256 int *surf_list, num_surfs;
258 struct arrow_data *arw;
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];
301 struct arrow_data *arw = data->arrow;
304 data->draw_arrow = 1;
305 gsd_north_arrow(arw->where, arw->size, FontBase, arw->color, arw->color);
317 data->draw_arrow = 0;
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;
369 int sx,
int sy,
float size,
373 int *surf_list, num_surfs;
375 struct scalebar_data *s;
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];
419 for (i = 0; i < data->num_scalebars; i++) {
420 if (data->scalebar[i]) {
421 struct scalebar_data *s = data->scalebar[i];
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;
void G_free(void *buf)
Free allocated memory.
int G_str_to_color(const char *str, int *red, int *grn, int *blu)
Parse color string and set red,green,blue.
int Nviz_off_cplane(nv_data *data, int id)
Turn off (make inactive) the given clip plane.
int Nviz_new_cplane(nv_data *data, int id)
Creates a clip plane object.
void G_warning(const char *msg,...)
Print a warning message to stderr.
int * GS_get_surf_list(int *numsurfs)
Get surface list.
void GS_set_Narrow(int *pt, int id, float *pos2)
Set decoration, north arrow ??
int GS_num_surfs(void)
Get number of surfaces.
void GS_draw_fringe(int id, unsigned long clr, float elev, int *where)
Draw fringe around data (surface) at selected corners.
void GS_set_light_reset(int i)
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.
int gsd_scalebar_v2(float *pos, float len, GLuint fontbase, unsigned long bar_clr, unsigned long text_clr)
Draw Scalebar (as lines)
int Nviz_new_light(nv_data *data)
Define new light.
int Nviz_get_bgcolor(nv_data *data)
Get background color.
void Nviz_delete_arrow(nv_data *data)
Deletes the North Arrow.
struct fringe_data * Nviz_new_fringe(nv_data *data, int id, unsigned long color, double elev, int nw, int ne, int sw, int se)
void Nviz_init_data(nv_data *data)
Initialize Nviz data.
int Nviz_draw_arrow(nv_data *data)
Draws the North Arrow.
void Nviz_delete_scalebar(nv_data *data, int bar_id)
Deletes scale bar.
void Nviz_draw_scalebar(nv_data *data)
Draws the Scale bar.
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.
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 Nviz_set_arrow(nv_data *data, int sx, int sy, float size, unsigned int color)
Sets the North Arrow position and return world coords.
void Nviz_set_bgcolor(nv_data *data, int color)
Set background color.
int Nviz_color_from_str(const char *color_str)
Get color value from color string (name or RGB triplet)
void Nviz_destroy_data(nv_data *data)
Free allocated space by nv_data struct.
void Nviz_draw_fringe(nv_data *data)
struct scalebar_data * Nviz_new_scalebar(nv_data *data, int bar_id, float *coords, float size, unsigned int color)