예제 #1
0
파일: nviz.c 프로젝트: rashadkm/grass_cmake
/*! Add new fringe

  \param data nviz data
  \param id surface id
  \param color color
  \param elev fringe elevation
  \param nw,ne,sw,se 1 (turn on) 0 (turn off)

  \return pointer to allocated fringe_data structure
  \return NULL on error
*/
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 num;
    int *surf;
    struct fringe_data *f;

    if (!GS_surf_exists(id)) {
	/* select first surface from the list */
	surf = GS_get_surf_list(&num);
	if (num < 1)
	    return NULL;
	id = surf[0];
	G_free(surf);
    }
     

    f = (struct fringe_data *) G_malloc(sizeof(struct fringe_data));
    f->id = id;
    f->color = color;
    f->elev = elev;
    f->where[0] = nw;
    f->where[1] = ne;
    f->where[2] = sw;
    f->where[3] = se;

    data->fringe = (struct fringe_data **) G_realloc(data->fringe, data->num_fringes + 1 * sizeof(struct fringe_data *));
    data->fringe[data->num_fringes++] = f;
    
    return f;
}
예제 #2
0
파일: gv2.c 프로젝트: rashadkm/grass_cmake
/*!
   \brief Select surface identified by hs to have vector identified
   by hv draped over it

   \param hv vector set id
   \param hs surface id

   \return 1 on success
   \return -1 on error
 */
int GV_select_surf(int hv, int hs)
{
    geovect *gv;

    if (GV_surf_is_selected(hv, hs)) {
	return (1);
    }

    gv = gv_get_vect(hv);

    if (gv && GS_surf_exists(hs)) {
	gv->drape_surf_id[gv->n_surfs] = hs;
	gv->n_surfs += 1;

	return (1);
    }

    return (-1);
}
예제 #3
0
파일: GP2.c 프로젝트: AsherBond/MondocosmOS
/*!
   \brief Select surface for given point set

   \param hp point set id
   \param hs surface id

   \return 1 surface selected
   \return -1 on error
 */
int GP_select_surf(int hp, int hs)
{
    geosite *gp;

    G_debug(3, "GP_select_surf(%d,%d)", hp, hs);

    if (GP_surf_is_selected(hp, hs)) {
	return 1;
    }

    gp = gp_get_site(hp);

    if (gp && GS_surf_exists(hs)) {
	gp->drape_surf_id[gp->n_surfs] = hs;
	gp->n_surfs += 1;
	return 1;
    }

    return -1;
}
예제 #4
0
파일: nviz.c 프로젝트: rashadkm/grass_cmake
/*! Set fringe

  \param data nviz data
  \param id surface id
  \param color color
  \param elev fringe elevation
  \param nw,ne,sw,se 1 (turn on) 0 (turn off)

  \return pointer to allocated fringe_data structure
  \return NULL on error
*/
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 i, num;
    int *surf;
    struct fringe_data *f;

    if (!GS_surf_exists(id)) {
	/* select first surface from the list */
	surf = GS_get_surf_list(&num);
	if (num < 1)
	    return NULL;
	id = surf[0];
	G_free(surf);
    }
    
    for (i = 0; i < data->num_fringes; i++) {
	f = data->fringe[i];
	if (f->id == id) {
	    f->color = color;
	    f->elev  = elev;
	    f->where[0] = nw;
	    f->where[1] = ne;
	    f->where[2] = sw;
	    f->where[3] = se;
	    
	    return f;
	}
    }

    f = Nviz_new_fringe(data,
			id, color,
			elev, nw, ne, sw, se);
    
    return f;
}
예제 #5
0
/*!
  \brief Set draw mode for loaded surfaces
  
  \param params module parameters
*/
void surface_set_draw_mode(const struct GParams *params)
{
    int *surf_list, nsurfs;
    int i, id, draw_mode;
    int resol_fine, resol_coarse;

    char *mode, *style, *shade, *res_fine, *res_coarse, *wire_color;

    surf_list = GS_get_surf_list(&nsurfs);

    for (i = 0; i < nsurfs; i++) {
	draw_mode = 0;
	id = surf_list[i];
	if (!GS_surf_exists(id))
	    G_fatal_error(_("Surface id %d doesn't exist"), id);

	if (params->mode_all->answer) {	/* use one mode for all surfaces */
	    mode = params->mode->answers[0];
	    style = params->style->answers[0];
	    shade = params->shade->answers[0];
	    res_fine = params->res_fine->answers[0];
	    res_coarse = params->res_coarse->answers[0];
	    wire_color = params->wire_color->answers[0];
	}
	else {
	    mode = params->mode->answers[i];
	    style = params->style->answers[i];
	    shade = params->shade->answers[i];
	    res_fine = params->res_fine->answers[i];
	    res_coarse = params->res_coarse->answers[i];
	    wire_color = params->wire_color->answers[i];
	}

	/* mode */
	if (strcmp(mode, "coarse") == 0) {
	    draw_mode |= DM_WIRE;
	}
	else if (strcmp(mode, "fine") == 0) {
	    draw_mode |= DM_POLY;
	}
	else {			/* both */
	    draw_mode |= DM_WIRE_POLY;
	}

	/* style */
	if (strcmp(style, "wire") == 0) {
	    draw_mode |= DM_GRID_WIRE;
	}
	else {			/* surface */
	    draw_mode |= DM_GRID_SURF;
	}

	/* shading */
	if (strcmp(shade, "flat") == 0) {
	    draw_mode |= DM_FLAT;
	}
	else {			/* gouraud */
	    draw_mode |= DM_GOURAUD;
	}

	if (GS_set_drawmode(id, draw_mode) < 0)
	    G_fatal_error(_("Unable to set draw mode for surface id %d"), id);

	/* resolution */
	resol_fine = atoi(res_fine);
	resol_coarse = atoi(res_coarse);
	if (GS_set_drawres(id, resol_fine, resol_fine,
			   resol_coarse, resol_coarse) < 0)
	    G_fatal_error(_("Unable to set draw mode for surface id %d"), id);

	/* wire color */
	GS_set_wire_color(id, Nviz_color_from_str(wire_color));
    }

    return;
}