Ejemplo n.º 1
0
/*!
  \brief Set vector lines mode
  
  \param params parameters
  
  \return 1 on success
  \return 0 on failure
*/
int vlines_set_attrb(const struct GParams *params)
{
    int i, color, width, flat, height;
    int *vect_list, nvects;

    vect_list = GV_get_vect_list(&nvects);

    for (i = 0; i < nvects; i++) {
	/* mode -- use memory by default */
	color = Nviz_color_from_str(params->vline_color->answers[i]);
	width = atoi(params->vline_width->answers[i]);
	if (strcmp(params->vline_mode->answers[i], "flat") == 0)
	    flat = 1;
	else
	    flat = 0;
	if (GV_set_vectmode(vect_list[i], 1, color, width, flat) < 0)
	    return 0;

	/* height */
	height = atoi(params->vline_height->answers[i]);
	if (height > 0)
	    GV_set_trans(vect_list[i], 0.0, 0.0, height);
    }

    return 1;
}
Ejemplo n.º 2
0
/*!
   \brief Set vector lines mode

   \param params parameters

   \return 1 on success
   \return 0 on failure
 */
int vlines_set_attrb(const struct GParams *params)
{
    int i, layer, color, width, flat, height;
    int *vect_list, nvects;
    int have_colors;

    char *color_column, *width_column;
    struct Colors colors;

    vect_list = GV_get_vect_list(&nvects);

    for (i = 0; i < nvects; i++) {
	check_map(params, i, TRUE, &layer, NULL);

	color = Nviz_color_from_str(params->vline_color->answers[i]);
	color_column = params->vline_color_column->answers ?
	    params->vline_color_column->answers[i] : NULL;
	width = atoi(params->vline_width->answers[i]);
	width_column = params->vline_width_column->answers ?
	    params->vline_width_column->answers[i] : NULL;

	if (strcmp(params->vline_mode->answers[i], "flat") == 0)
	    flat = 1;
	else
	    flat = 0;

	/* style (mode -- use memory by default) */
	if (GV_set_style(vect_list[i], TRUE, color, width, flat) < 0)
	    return 0;

	/* check for vector color table */
	have_colors = Vect_read_colors(params->vlines->answers[i], "",
				       &colors);

	if (have_colors || color_column || width_column)
	    if (GV_set_style_thematic(vect_list[i], layer, color_column,
				      width_column,
				      have_colors ? &colors : NULL) < 0)
		return 0;

	/* height */
	height = atoi(params->vline_height->answers[i]);
	if (height > 0)
	    GV_set_trans(vect_list[i], 0.0, 0.0, height);
    }

    return 1;
}
Ejemplo n.º 3
0
int load_vectors(const struct Option *elev_map,
		 const struct Option *elev_const, const struct Option *vect,
		 const struct Option *position,
		 int map_obj_type, nv_data * data)
{
    int i, id;
    int nvects;

    const char *mapset;

    double x, y, z;
    
    if ((!elev_map->answer || elev_const->answer) && GS_num_surfs() == 0) {	/* load base surface if no loaded */
	int *surf_list, nsurf;

	Nviz_new_map_obj(MAP_OBJ_SURF, NULL, 0.0, data);

	surf_list = GS_get_surf_list(&nsurf);
	GS_set_att_const(surf_list[0], ATT_TRANSP, 255);
    }

    nvects = 0;

    for (i = 0; vect->answers[i]; i++) {
	mapset = G_find_vector2(vect->answers[i], "");
	if (mapset == NULL) {
	    G_fatal_error(_("Vector map <%s> not found"), vect->answers[i]);
	}
	id = Nviz_new_map_obj(map_obj_type,
			      G_fully_qualified_name(vect->answers[i], mapset),
			      0.0, data);

	/* set position */
	x = atof(position->answers[i*3+0]);
	y = atof(position->answers[i*3+1]);
	z = atof(position->answers[i*3+2]);

	if (map_obj_type == MAP_OBJ_VECT)
	    GV_set_trans(id, x, y, z);
	else
	    GP_set_trans(id, x, y, z);

	nvects++;
    }

    return nvects;
}