16#include <grass/colors.h>
17#include <grass/raster.h>
18#include <grass/glocale.h>
19#include <grass/nviz.h>
35 data->num_cplanes = 0;
37 for (i = 0; i < MAX_CPLANES; i++) {
45 for (i = 0; i < MAX_LIGHTS - 1; i++) {
50 data->num_fringes = 0;
58 data->num_scalebars = 0;
59 data->scalebar =
NULL;
72 for (i = 0; i < data->num_fringes; i++) {
74 data->fringe[i] =
NULL;
76 data->num_fringes = 0;
85 for (i = 0; i < data->num_scalebars; i++) {
87 data->scalebar[i] =
NULL;
89 data->num_scalebars = 0;
90 data->scalebar =
NULL;
101 data->bgcolor = color;
115 return data->bgcolor;
130 G_warning(_(
"Invalid color (%s), using \"white\" as default"),
132 red = grn = blu = 255;
151 double elev,
int nw,
int ne,
int sw,
int se)
155 struct fringe_data *f;
166 f = (
struct fringe_data *)G_malloc(
sizeof(
struct fringe_data));
175 data->fringe = (
struct fringe_data **)G_realloc(
176 data->fringe, data->num_fringes + 1 *
sizeof(
struct fringe_data *));
177 data->fringe[data->num_fringes++] = f;
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++) {
236 for (i = 0; i < data->num_fringes; i++) {
237 struct fringe_data *f = data->fringe[i];
255 int *surf_list, num_surfs;
257 struct arrow_data *arw;
270 data->arrow->color = color;
271 data->arrow->size = size;
272 data->arrow->where[0] = coords[0];
273 data->arrow->where[1] = coords[1];
274 data->arrow->where[2] = coords[2];
277 arw = (
struct arrow_data *)G_malloc(
sizeof(
struct arrow_data));
280 arw->where[0] = coords[0];
281 arw->where[1] = coords[1];
282 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 float *coords,
float size,
336 struct scalebar_data *s;
338 s = (
struct scalebar_data *)G_malloc(
sizeof(
struct scalebar_data));
342 s->where[0] = coords[0];
343 s->where[1] = coords[1];
344 s->where[2] = coords[2];
346 data->scalebar = (
struct scalebar_data **)G_realloc(
348 (data->num_scalebars + 1) *
sizeof(
struct scalebar_data *));
349 data->scalebar[data->num_scalebars++] = s;
367 int sy,
float size,
unsigned int color)
370 int *surf_list, num_surfs;
372 struct scalebar_data *s;
384 for (i = 0; i < data->num_scalebars; i++) {
385 if (data->scalebar[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];
417 for (i = 0; i < data->num_scalebars; i++) {
418 if (data->scalebar[i]) {
419 struct scalebar_data *s = data->scalebar[i];
436 if (bar_id < data->num_scalebars && data->scalebar[bar_id] !=
NULL) {
437 G_free(data->scalebar[bar_id]);
438 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 UNUSED, unsigned long bar_clr, unsigned long text_clr UNUSED)
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.
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.
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.
void Nviz_draw_scalebar(nv_data *data)
Draws the Scale bar.
struct fringe_data * Nviz_new_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.
struct fringe_data * Nviz_set_fringe(nv_data *data, int id, unsigned long color, double elev, int nw, int ne, int sw, int se)
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.
struct scalebar_data * Nviz_new_scalebar(nv_data *data, int bar_id, float *coords, float size, unsigned int color)
void Nviz_draw_fringe(nv_data *data)