21#include <grass/ogsf.h>
22#include <grass/glocale.h>
26static int Site_ID[MAX_SITES];
27static int Next_site = 0;
41 G_debug(4,
"GP_site_exists(%d)",
id);
47 for (i = 0; i < Next_site && !found; i++) {
48 if (Site_ID[i] ==
id) {
53 G_debug(3,
"GP_site_exists(): found=%d", found);
68 if (Next_site < MAX_SITES) {
71 Site_ID[Next_site] = np->gsite_id;
74 G_debug(3,
"GP_new_site() id=%d", np->gsite_id);
106 *numsites = Next_site;
109 ret = (
int *)G_malloc(Next_site *
sizeof(
int));
114 for (i = 0; i < Next_site; i++) {
136 G_debug(4,
"GP_delete_site(%d)",
id);
141 for (i = 0; i < Next_site && !found; i++) {
142 if (Site_ID[i] ==
id) {
144 for (j = i; j < Next_site; j++) {
145 Site_ID[j] = Site_ID[j + 1];
177 G_debug(3,
"GP_load_site(id=%d, name=%s)",
id, filename);
187 gp->filename =
G_store(filename);
189 gp->points =
Gp_load_sites(filename, &(gp->n_sites), &(gp->has_z));
213 G_debug(4,
"GP_get_sitename(%d)",
id);
219 *filename =
G_store(gp->filename);
232int GP_get_style(
int id,
int *color,
int *width,
float *size,
int *symbol)
236 G_debug(4,
"GP_get_style(%d)",
id);
242 *color = gp->style->color;
243 *width = gp->style->width;
244 *symbol = gp->style->symbol;
245 *size = gp->style->size;
278 G_debug(4,
"GP_set_style(id=%d, color=%d, width=%d, size=%f, symbol=%d)",
279 id, color, width, size, symbol);
285 gp->style->color = color;
286 gp->style->symbol = symbol;
287 gp->style->size = size;
288 gp->style->width = width;
310 const char *width,
const char *size,
311 const char *symbol,
struct Colors *color_rules)
316 "GP_set_style_thematic(id=%d, layer=%d, color=%s, width=%s, "
317 "size=%s, symbol=%s)",
318 id, layer, color, width, size, symbol);
325 gp->tstyle = (gvstyle_thematic *)G_malloc(
sizeof(gvstyle_thematic));
326 G_zero(gp->tstyle,
sizeof(gvstyle_thematic));
328 gp->tstyle->active = 1;
329 gp->tstyle->layer = layer;
331 gp->tstyle->color_column =
G_store(color);
333 gp->tstyle->symbol_column =
G_store(symbol);
335 gp->tstyle->size_column =
G_store(size);
337 gp->tstyle->width_column =
G_store(width);
356 G_debug(4,
"GP_unset_style_thematic(): id=%d",
id);
363 gp->tstyle->active = 0;
384 G_debug(3,
"GP_set_zmode(%d,%d)",
id, use_z);
418 G_debug(4,
"GP_get_zmode(%d)",
id);
438 G_debug(3,
"GP_set_trans(): id=%d trans=%f,%f,%f",
id, xtrans, ytrans,
443 gp->x_trans = xtrans;
444 gp->y_trans = ytrans;
445 gp->z_trans = ztrans;
464 *xtrans = gp->x_trans;
465 *ytrans = gp->y_trans;
466 *ztrans = gp->z_trans;
469 G_debug(3,
"GP_get_trans(): id=%d, trans=%f,%f,%f",
id, *xtrans, *ytrans,
488 G_debug(3,
"GP_select_surf(%d,%d)", hp, hs);
497 gp->drape_surf_id[gp->n_surfs] = hs;
519 G_debug(3,
"GP_unselect_surf(%d,%d)", hp, hs);
528 for (i = 0; i < gp->n_surfs; i++) {
529 if (gp->drape_surf_id[i] == hs) {
530 for (j = i; j < gp->n_surfs - 1; j++) {
531 gp->drape_surf_id[j] = gp->drape_surf_id[j + 1];
557 G_debug(3,
"GP_surf_is_selected(%d,%d)", hp, hs);
562 for (i = 0; i < gp->n_surfs; i++) {
563 if (hs == gp->drape_surf_id[i]) {
589 if (gp->use_z && gp->has_z) {
593 for (i = 0; i < gp->n_surfs; i++) {
598 G_debug(5,
"Drawing site %d on Surf %d",
id,
599 gp->drape_surf_id[i]);
615 for (
id = 0;
id < Next_site;
id++) {
638 gp->clientdata = clientd;
659 return (gp->clientdata);
688 if (strcmp(str,
"x") == 0)
690 else if (strcmp(str,
"box") == 0)
692 else if (strcmp(str,
"sphere") == 0)
694 else if (strcmp(str,
"cube") == 0)
696 else if (strcmp(str,
"diamond") == 0)
698 else if (strcmp(str,
"dec_tree") == 0)
699 marker = ST_DEC_TREE;
700 else if (strcmp(str,
"con_tree") == 0)
701 marker = ST_CON_TREE;
702 else if (strcmp(str,
"aster") == 0)
704 else if (strcmp(str,
"gyro") == 0)
706 else if (strcmp(str,
"histogram") == 0)
707 marker = ST_HISTOGRAM;
709 G_warning(_(
"Unknown icon marker, using \"sphere\""));
int G_debug(int level, const char *msg,...)
Print debugging message.
void G_warning(const char *msg,...)
Print a warning message to stderr.
int GP_select_surf(int hp, int hs)
Select surface for given point set.
int GP_delete_site(int id)
Delete registrated point set.
int GP_new_site(void)
Create new point set.
void GP_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
Get transformation params.
int GP_get_zmode(int id, int *use_z)
Get z-mode.
int GP_get_sitename(int id, char **filename)
Get point set filename.
int GP_set_zmode(int id, int use_z)
Set z mode for point set.
int GP_load_site(int id, const char *filename)
Load point set from file.
void GP_set_trans(int id, float xtrans, float ytrans, float ztrans)
Set transformation params.
int GP_Set_ClientData(int id, void *clientd)
Set client data.
int GP_site_exists(int id)
Check if point set exists.
int GP_str_to_marker(const char *str)
Determine point marker symbol for string.
int GP_get_style(int id, int *color, int *width, float *size, int *symbol)
Get point set style.
int GP_surf_is_selected(int hp, int hs)
Check if surface is selected.
int * GP_get_site_list(int *numsites)
Get list of point sets.
int GP_num_sites(void)
Get number of loaded point sets.
void GP_draw_site(int id)
Draw point set.
void * GP_Get_ClientData(int id)
Get client data.
void GP_alldraw_site(void)
Draw all available point sets.
int GP_unselect_surf(int hp, int hs)
Unselect surface.
int GP_set_style_thematic(int id, int layer, const char *color, const char *width, const char *size, const char *symbol, struct Colors *color_rules)
Set point set style for thematic mapping.
int GP_set_style(int id, int color, int width, float size, int symbol)
Set point style.
int GP_unset_style_thematic(int id)
Make style for thematic mapping inactive.
geopoint * Gp_load_sites(const char *name, int *nsites, int *has_z)
Load to points to memory.
int Gp_load_sites_thematic(geosite *gp, struct Colors *colors)
Load styles for geopoints based on thematic mapping.
void gp_delete_site(int id)
Delete point set and remove from list.
geosite * gp_get_site(int id)
Get geosite struct.
void gp_free_sitemem(geosite *fp)
Free geosite (lower level)
geosite * gp_get_new_site(void)
Create new geosite instance and add it to list.
int gp_set_defaults(geosite *gp)
Set default value for geosite struct.
int gp_num_sites(void)
Get number of loaded point sets.
int gpd_2dsite(geosite *gp, geosurf *gs, int do_fast UNUSED)
Draw 2D point set.
int gpd_3dsite(geosite *gp, float xo, float yo, int do_fast UNUSED)
Draw 3D point set.
int GS_get_region(float *n, float *s, float *w, float *e)
Get 2D region extent.
int GS_surf_exists(int id)
geosurf * gs_get_surf(int id)
Get geosurf struct.
char * G_store(const char *s)
Copy string to allocated memory.
void G_zero(void *buf, int i)
Zero out a buffer, buf, of length i.