[GRASS-SVN] r58789 - grass/trunk/misc/m.nviz.image
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 27 17:57:55 PST 2014
Author: hamish
Date: 2014-01-27 17:57:55 -0800 (Mon, 27 Jan 2014)
New Revision: 58789
Modified:
grass/trunk/misc/m.nviz.image/args.c
grass/trunk/misc/m.nviz.image/local_proto.h
grass/trunk/misc/m.nviz.image/main.c
grass/trunk/misc/m.nviz.image/surface.c
grass/trunk/misc/m.nviz.image/vector.c
grass/trunk/misc/m.nviz.image/volume.c
grass/trunk/misc/m.nviz.image/write_img.c
Log:
run grass_indent.sh
Modified: grass/trunk/misc/m.nviz.image/args.c
===================================================================
--- grass/trunk/misc/m.nviz.image/args.c 2014-01-27 19:06:00 UTC (rev 58788)
+++ grass/trunk/misc/m.nviz.image/args.c 2014-01-28 01:57:55 UTC (rev 58789)
@@ -1,17 +1,17 @@
/*!
- \file args.c
-
- \brief Parse command
-
- (C) 2008, 2010-2011 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
-*/
+ \file args.c
+ \brief Parse command
+
+ (C) 2008, 2010-2011 by the GRASS Development Team
+
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
+ */
+
#include <stdlib.h>
#include <string.h>
@@ -35,14 +35,14 @@
static void args_arrow(struct GParams *);
/*!
- \brief Parse command
-
- \param argc number of arguments
- \param argv arguments array
- \param params GRASS parameters
-
- \return 1
-*/
+ \brief Parse command
+
+ \param argc number of arguments
+ \param argv arguments array
+ \param params GRASS parameters
+
+ \return 1
+ */
void parse_command(int argc, char *argv[], struct GParams *params)
{
params->mode_all = G_define_flag();
@@ -50,7 +50,7 @@
params->mode_all->description =
_("Use draw mode for all loaded surfaces");
params->mode_all->guisection = _("Surfaces");
-
+
/*** surface attributes ***/
args_surface(params);
@@ -81,7 +81,7 @@
/*** north arrow ***/
args_arrow(params);
-
+
/*** output image ***/
/* output */
params->output = G_define_standard_option(G_OPT_F_OUTPUT);
@@ -152,7 +152,7 @@
params->color_const->label = _("Color value(s)");
params->color_const->guisection = _("Surfaces");
params->color_const->answer = NULL;
-
+
/* mask */
params->mask_map = G_define_standard_option(G_OPT_R_MAP);
params->mask_map->multiple = YES;
@@ -216,9 +216,7 @@
params->emit_const->guisection = _("Surfaces");
params->emit_const->options = "0-255";
- /*
- draw
- */
+ /* draw */
/* mode */
params->mode = G_define_option();
params->mode->key = "mode";
@@ -296,7 +294,7 @@
params->surface_pos->description = _("Surface position");
params->surface_pos->guisection = _("Draw");
params->surface_pos->answer = "0,0,0";
-
+
return;
}
@@ -312,7 +310,8 @@
params->vline_layer = G_define_standard_option(G_OPT_V_FIELD);
params->vline_layer->multiple = YES;
params->vline_layer->required = NO;
- params->vline_layer->description = _("Layer number or name for thematic mapping");
+ params->vline_layer->description =
+ _("Layer number or name for thematic mapping");
params->vline_layer->guisection = _("Vector lines");
params->vline_layer->key = "vline_layer";
params->vline_layer->answer = "1";
@@ -404,7 +403,8 @@
params->vpoint_layer = G_define_standard_option(G_OPT_V_FIELD);
params->vpoint_layer->multiple = YES;
params->vpoint_layer->required = NO;
- params->vpoint_layer->description = _("Layer number or name for thematic mapping");
+ params->vpoint_layer->description =
+ _("Layer number or name for thematic mapping");
params->vpoint_layer->guisection = _("Vector points");
params->vpoint_layer->key = "vpoint_layer";
params->vpoint_layer->answer = "1";
@@ -479,7 +479,8 @@
params->vpoint_marker_column = G_define_standard_option(G_OPT_DB_COLUMN);
params->vpoint_marker_column->multiple = YES;
params->vpoint_marker_column->required = NO;
- params->vpoint_marker_column->label = _("Name of marker definition column");
+ params->vpoint_marker_column->label =
+ _("Name of marker definition column");
params->vpoint_marker_column->key = "vpoint_marker_column";
params->vpoint_marker_column->guisection = _("Vector points");
@@ -494,7 +495,7 @@
params->vpoint_mode->options = "surface,3D";
params->vpoint_mode->descriptions = _("surface;drape on raster surface;"
"3D;place at 3D point's z-elevation");
- /* TODO: "flat", place at a constant elevation */
+ /* TODO: "flat", place at a constant elevation */
params->vpoint_mode->answer = "3D";
params->vpoint_mode->guisection = _("Vector points");
@@ -508,7 +509,7 @@
params->vpoint_pos->description = _("Vector points position");
params->vpoint_pos->guisection = _("Vector points");
params->vpoint_pos->answer = "0,0,0";
-
+
return;
}
@@ -577,9 +578,10 @@
params->focus->type = TYPE_DOUBLE;
params->focus->required = NO;
params->focus->multiple = NO;
- params->focus->description = _("Focus to point on surface (from SW corner in map units)");
+ params->focus->description =
+ _("Focus to point on surface (from SW corner in map units)");
params->focus->guisection = _("Viewpoint");
-
+
return;
}
@@ -624,7 +626,7 @@
params->volume_pos->description = _("Volume position");
params->volume_pos->guisection = _("Volumes");
params->volume_pos->answer = "0,0,0";
-
+
/* resolution */
params->volume_res = G_define_option();
params->volume_res->key = "volume_resolution";
@@ -645,13 +647,14 @@
params->isosurf_level->multiple = YES;
params->isosurf_level->description = _("Isosurface level");
params->isosurf_level->guisection = _("Volumes");
-
+
/* isosurface color map */
params->isosurf_color_map = G_define_standard_option(G_OPT_R3_MAPS);
params->isosurf_color_map->key = "isosurf_color_map";
params->isosurf_color_map->required = NO;
params->isosurf_color_map->multiple = YES;
- params->isosurf_color_map->description = _("Name of volume for isosurface color");
+ params->isosurf_color_map->description =
+ _("Name of volume for isosurface color");
params->isosurf_color_map->guisection = _("Volumes");
/* isosurface color value */
@@ -678,15 +681,17 @@
params->isosurf_transp_const->type = TYPE_INTEGER;
params->isosurf_transp_const->required = NO;
params->isosurf_transp_const->multiple = YES;
- params->isosurf_transp_const->description = _("Transparency value(s)for isosurfaces");
+ params->isosurf_transp_const->description =
+ _("Transparency value(s)for isosurfaces");
params->isosurf_transp_const->guisection = _("Volumes");
params->isosurf_transp_const->options = "0-255";
-
+
/* isosurface shininess */
params->isosurf_shine_map = G_define_standard_option(G_OPT_R3_MAP);
params->isosurf_shine_map->multiple = YES;
params->isosurf_shine_map->required = NO;
- params->isosurf_shine_map->description = _("Name of 3D raster map(s) for shininess");
+ params->isosurf_shine_map->description =
+ _("Name of 3D raster map(s) for shininess");
params->isosurf_shine_map->guisection = _("Volumes");
params->isosurf_shine_map->key = "isosurf_shininess_map";
@@ -696,7 +701,8 @@
params->isosurf_shine_const->type = TYPE_INTEGER;
params->isosurf_shine_const->required = NO;
params->isosurf_shine_const->multiple = YES;
- params->isosurf_shine_const->description = _("Shininess value(s) for isosurfaces");
+ params->isosurf_shine_const->description =
+ _("Shininess value(s) for isosurfaces");
params->isosurf_shine_const->guisection = _("Volumes");
params->isosurf_shine_const->options = "0-255";
@@ -720,7 +726,8 @@
params->slice->type = TYPE_STRING;
params->slice->required = NO;
params->slice->multiple = YES;
- params->slice->description = _("Volume slice parallel to given axis (x, y, z)");
+ params->slice->description =
+ _("Volume slice parallel to given axis (x, y, z)");
params->slice->guisection = _("Volumes");
/* slice position */
@@ -733,7 +740,7 @@
params->slice_pos->description = _("Volume slice position");
params->slice_pos->guisection = _("Volumes");
params->slice_pos->answer = "0,1,0,1,0,1";
-
+
/* slice transparency */
params->slice_transp = G_define_option();
params->slice_transp->key = "slice_transparency";
@@ -767,16 +774,16 @@
params->light_color->label = _("Light color");
params->light_color->guisection = _("Lighting");
params->light_color->answer = "white";
-
+
params->light_bright = G_define_option();
params->light_bright->key = "light_brightness";
params->light_bright->type = TYPE_INTEGER;
params->light_bright->required = NO;
params->light_bright->multiple = NO;
- params->light_bright->description = _("Light brightness");
+ params->light_bright->description = _("Light brightness");
params->light_bright->guisection = _("Lighting");
params->light_bright->answer = "80";
- params->light_bright->options="0-100";
+ params->light_bright->options = "0-100";
params->light_ambient = G_define_option();
params->light_ambient->key = "light_ambient";
@@ -786,7 +793,7 @@
params->light_ambient->description = _("Light ambient");
params->light_ambient->guisection = _("Lighting");
params->light_ambient->answer = "20";
- params->light_ambient->options="0-100";
+ params->light_ambient->options = "0-100";
}
void args_cplane(struct GParams *params)
@@ -799,7 +806,7 @@
params->cplane->multiple = YES;
params->cplane->description = _("Cutting plane index (0-5)");
params->cplane->guisection = _("Cutting planes");
-
+
params->cplane_pos = G_define_option();
params->cplane_pos->key = "cplane_position";
params->cplane_pos->key_desc = "x,y,z";
@@ -809,7 +816,7 @@
params->cplane_pos->description = _("Cutting plane x,y,z coordinates");
params->cplane_pos->guisection = _("Cutting planes");
params->cplane_pos->answer = "0,0,0";
-
+
params->cplane_rot = G_define_option();
params->cplane_rot->key = "cplane_rotation";
params->cplane_rot->key_desc = "value";
@@ -817,10 +824,11 @@
params->cplane_rot->multiple = YES;
params->cplane_rot->required = NO;
params->cplane_rot->guisection = _("Cutting planes");
- params->cplane_rot->description = _("Cutting plane rotation along the vertical axis");
+ params->cplane_rot->description =
+ _("Cutting plane rotation along the vertical axis");
params->cplane_rot->answer = "0";
- params->cplane_rot->options="0-360";
-
+ params->cplane_rot->options = "0-360";
+
params->cplane_tilt = G_define_option();
params->cplane_tilt->key = "cplane_tilt";
params->cplane_tilt->key_desc = "value";
@@ -830,8 +838,8 @@
params->cplane_tilt->guisection = _("Cutting planes");
params->cplane_tilt->description = _("Cutting plane tilt");
params->cplane_tilt->answer = "0";
- params->cplane_tilt->options="0-360";
-
+ params->cplane_tilt->options = "0-360";
+
params->cplane_shading = G_define_option();
params->cplane_shading->key = "cplane_shading";
params->cplane_shading->key_desc = "string";
@@ -839,37 +847,37 @@
params->cplane_shading->multiple = NO;
params->cplane_shading->required = NO;
params->cplane_shading->guisection = _("Cutting planes");
- params->cplane_shading->description = _("Cutting plane color (between two surfaces)");
+ params->cplane_shading->description =
+ _("Cutting plane color (between two surfaces)");
params->cplane_shading->answer = "clear";
- params->cplane_shading->options= "clear,top,bottom,blend,shaded";
+ params->cplane_shading->options = "clear,top,bottom,blend,shaded";
}
void args_fringe(struct GParams *params)
{
char *desc;
-
+
params->fringe = G_define_option();
params->fringe->key = "fringe";
params->fringe->type = TYPE_STRING;
params->fringe->options = "nw,ne,sw,se";
desc = NULL;
G_asprintf(&desc,
- "nw;%s;ne;%s;sw;%s;se;%s",
- _("North-West edge"),
- _("North-East edge"),
- _("South-West edge"),
- _("South-East edge"));
+ "nw;%s;ne;%s;sw;%s;se;%s",
+ _("North-West edge"),
+ _("North-East edge"),
+ _("South-West edge"), _("South-East edge"));
params->fringe->descriptions = desc;
params->fringe->description = _("Fringe edges");
params->fringe->guisection = _("Fringe");
params->fringe->multiple = YES;
-
+
params->fringe_color = G_define_standard_option(G_OPT_C_FG);
params->fringe_color->key = "fringe_color";
params->fringe_color->label = _("Fringe color");
params->fringe_color->guisection = _("Fringe");
params->fringe_color->answer = "grey";
-
+
params->fringe_elev = G_define_option();
params->fringe_elev->key = "fringe_elevation";
params->fringe_elev->type = TYPE_INTEGER;
@@ -888,19 +896,21 @@
params->north_arrow->type = TYPE_INTEGER;
params->north_arrow->required = NO;
params->north_arrow->multiple = NO;
- params->north_arrow->description = _("Place north arrow at given position \
+ params->north_arrow->description =
+ _("Place north arrow at given position \
(in screen coordinates from bottom left corner)");
params->north_arrow->guisection = _("Decoration");
-
+
params->north_arrow_size = G_define_option();
params->north_arrow_size->key = "arrow_size";
params->north_arrow_size->key_desc = "value";
params->north_arrow_size->type = TYPE_DOUBLE;
params->north_arrow_size->required = NO;
params->north_arrow_size->multiple = NO;
- params->north_arrow_size->description = _("North arrow size (in map units)");
+ params->north_arrow_size->description =
+ _("North arrow size (in map units)");
params->north_arrow_size->guisection = _("Decoration");
-
+
params->north_arrow_color = G_define_standard_option(G_OPT_C_FG);
params->north_arrow_color->key = "arrow_color";
params->north_arrow_color->required = NO;
@@ -930,14 +940,14 @@
}
G_debug(3, "opt_get_num_answers(): opt=%s num=%d", opt->key, i);
-
+
return i;
}
/*!
- \brief Check parameters consistency
-
- \param params module parameters
+ \brief Check parameters consistency
+
+ \param params module parameters
*/
void check_parameters(const struct GParams *params)
{
@@ -947,7 +957,7 @@
int nvlines;
int nvpoints, nvpoints_pos, nvpoints_layer;
-
+
int nvolumes, nisosurf, nslices;
/* topography */
@@ -1035,25 +1045,28 @@
params->elev_map->key, params->elev_const->key,
nelevs, params->wire_color->key, nconsts);
}
-
+
/*
* Cutting planes
*/
ncplanes = opt_get_num_answers(params->cplane);
ncoords = opt_get_num_answers(params->cplane_pos);
- if (ncplanes > 0 && ncplanes * 3 != ncoords)
- G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d x 3)"),
- params->cplane->key, ncplanes, params->cplane_pos->key, ncoords/3);
-
+ if (ncplanes > 0 && ncplanes * 3 != ncoords)
+ G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d x 3)"),
+ params->cplane->key, ncplanes, params->cplane_pos->key,
+ ncoords / 3);
+
nconsts = opt_get_num_answers(params->cplane_rot);
if (ncplanes > 0 && ncplanes != nconsts)
- G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
- params->cplane->key, ncplanes, params->cplane_rot->key, nconsts);
-
+ G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
+ params->cplane->key, ncplanes, params->cplane_rot->key,
+ nconsts);
+
nconsts = opt_get_num_answers(params->cplane_tilt);
if (ncplanes > 0 && ncplanes != nconsts)
- G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
- params->cplane->key, ncplanes, params->cplane_tilt->key, nconsts);
+ G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
+ params->cplane->key, ncplanes, params->cplane_tilt->key,
+ nconsts);
/*
* vector lines
@@ -1087,7 +1100,7 @@
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
params->vlines->key, nvlines, params->vline_height->key,
nconsts);
-
+
/* position */
nconsts = opt_get_num_answers(params->vline_pos);
if (nvlines > 0 && nconsts != 3 * nvlines)
@@ -1104,15 +1117,17 @@
if (nvpoints && (nvpoints * 3 != nvpoints_pos))
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
- params->vpoints->key, nvpoints, params->vpoint_pos->key, nvpoints_pos);
+ params->vpoints->key, nvpoints, params->vpoint_pos->key,
+ nvpoints_pos);
if (nvpoints && (nvpoints != nvpoints_layer))
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
- params->vpoints->key, nvpoints, params->vpoint_layer->key, nvpoints_layer);
+ params->vpoints->key, nvpoints,
+ params->vpoint_layer->key, nvpoints_layer);
/* TODO */
-
+
/*
* volumes
*/
@@ -1126,7 +1141,8 @@
if ((nmaps + nconsts > 0) && (nisosurf != nmaps + nconsts))
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d, <%s> %d)"),
- params->isosurf_level->key, nisosurf, params->isosurf_transp_map->key, nmaps,
+ params->isosurf_level->key, nisosurf,
+ params->isosurf_transp_map->key, nmaps,
params->isosurf_transp_const->key, nconsts);
/* isosurface shininess */
@@ -1135,20 +1151,23 @@
if ((nmaps + nconsts > 0) && (nisosurf != nmaps + nconsts))
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d, <%s> %d)"),
- params->isosurf_level->key, nisosurf, params->isosurf_shine_map->key, nmaps,
- params->isosurf_shine_const->key, nconsts);
+ params->isosurf_level->key, nisosurf,
+ params->isosurf_shine_map->key, nmaps,
+ params->isosurf_shine_const->key, nconsts);
/* slice transparency */
nconsts = opt_get_num_answers(params->slice_transp);
if (nslices > 0 && nslices != nconsts)
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
- params->slice->key, nslices, params->slice_transp->key, nconsts);
+ params->slice->key, nslices, params->slice_transp->key,
+ nconsts);
/* slice position */
ncoords = opt_get_num_answers(params->slice_pos);
if (nslices > 0 && ncoords != 6 * nslices)
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d x 6)"),
- params->slice->key, nslices, params->slice_pos->key, ncoords/6);
+ params->slice->key, nslices, params->slice_pos->key,
+ ncoords / 6);
return;
}
Modified: grass/trunk/misc/m.nviz.image/local_proto.h
===================================================================
--- grass/trunk/misc/m.nviz.image/local_proto.h 2014-01-27 19:06:00 UTC (rev 58788)
+++ grass/trunk/misc/m.nviz.image/local_proto.h 2014-01-28 01:57:55 UTC (rev 58789)
@@ -10,38 +10,39 @@
struct Flag *isosurf_toggle_norm_dir;
struct Flag *draw_volume_box;
- struct Option
- /* surface */
- *elev_map, *elev_const, *color_map, *color_const,
+ struct Option
+ /* surface */
+ *elev_map, *elev_const, *color_map, *color_const,
*mask_map, *transp_map, *transp_const, *shine_map, *shine_const,
*emit_map, *emit_const,
- /* surface draw mode */
- *mode, *res_fine, *res_coarse, *style, *shade, *wire_color, *surface_pos,
- /* vector lines */
- *vlines, *vline_width, *vline_color, *vline_mode, *vline_height, *vline_pos,
- *vline_layer, *vline_color_column, *vline_width_column,
- /* vector points */
- *vpoints, *vpoint_size, *vpoint_mode, *vpoint_marker, *vpoint_color,
+ /* surface draw mode */
+ *mode, *res_fine, *res_coarse, *style, *shade, *wire_color, *surface_pos,
+ /* vector lines */
+ *vlines, *vline_width, *vline_color, *vline_mode, *vline_height,
+ *vline_pos, *vline_layer, *vline_color_column, *vline_width_column,
+ /* vector points */
+ *vpoints, *vpoint_size, *vpoint_mode, *vpoint_marker, *vpoint_color,
*vpoint_width, *vpoint_pos, *vpoint_layer, *vpoint_size_column,
*vpoint_marker_column, *vpoint_color_column, *vpoint_width_column,
- /* volumes */
- *volume, *volume_mode, *volume_shade, *volume_pos, *volume_res, *isosurf_level,
- *isosurf_color_map, *isosurf_color_const, *isosurf_transp_map, *isosurf_transp_const,
- *isosurf_shine_map, *isosurf_shine_const, *slice_pos, *slice, *slice_transp,
- /* misc */
- *exag, *bgcolor,
- /* cutting planes */
- *cplane, *cplane_pos, *cplane_rot, *cplane_tilt, *cplane_shading,
- /* viewpoint */
- *pos, *height, *persp, *twist, *focus,
- /* output */
- *output, *format, *size,
- /* lighting */
- *light_pos, *light_color, *light_bright, *light_ambient,
- /* fringe */
- *fringe, *fringe_color, *fringe_elev,
- /* north arrow */
- *north_arrow, *north_arrow_size, *north_arrow_color;
+ /* volumes */
+ *volume, *volume_mode, *volume_shade, *volume_pos, *volume_res,
+ *isosurf_level, *isosurf_color_map, *isosurf_color_const,
+ *isosurf_transp_map, *isosurf_transp_const, *isosurf_shine_map,
+ *isosurf_shine_const, *slice_pos, *slice, *slice_transp,
+ /* misc */
+ *exag, *bgcolor,
+ /* cutting planes */
+ *cplane, *cplane_pos, *cplane_rot, *cplane_tilt, *cplane_shading,
+ /* viewpoint */
+ *pos, *height, *persp, *twist, *focus,
+ /* output */
+ *output, *format, *size,
+ /* lighting */
+ *light_pos, *light_color, *light_bright, *light_ambient,
+ /* fringe */
+ *fringe, *fringe_color, *fringe_elev,
+ /* north arrow */
+ *north_arrow, *north_arrow_size, *north_arrow_color;
};
/* args.c */
Modified: grass/trunk/misc/m.nviz.image/main.c
===================================================================
--- grass/trunk/misc/m.nviz.image/main.c 2014-01-27 19:06:00 UTC (rev 58788)
+++ grass/trunk/misc/m.nviz.image/main.c 2014-01-28 01:57:55 UTC (rev 58789)
@@ -6,9 +6,9 @@
* AUTHOR(S): Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
* Anna Kratochvilova (Google SoC 2011)
*
- * PURPOSE: Renders GIS data in 3D space.
+ * PURPOSE: Renders GIS data in 3D space from the command line.
*
- * COPYRIGHT: (C) 2008, 2010-2011 by the GRASS Development Team
+ * COPYRIGHT: (C) 2008-2014 by the GRASS Development Team
*
* This program is free software under the GNU General
* Public License (>=v2). Read the file COPYING that
@@ -39,7 +39,7 @@
double vp_height, z_exag; /* calculated viewpoint height, z-exag */
int width, height; /* output image size */
char *output_name;
-
+
nv_data data;
struct render_window *offscreen;
@@ -79,7 +79,7 @@
offscreen = Nviz_new_render_window();
Nviz_init_render_window(offscreen);
if (Nviz_create_render_window(offscreen, NULL, width, height) == -1)
- G_fatal_error(_("Unable to render data"));
+ G_fatal_error(_("Unable to render data"));
Nviz_make_current_render_window(offscreen);
/* initialize nviz data */
@@ -96,6 +96,7 @@
/* load raster maps (surface topography) & set attributes (map/constant) */
load_rasters(params, &data);
+
/* set draw mode of loaded surfaces */
surface_set_draw_mode(params);
@@ -138,8 +139,7 @@
else {
z_exag = Nviz_get_exag();
G_verbose_message(_("Vertical exaggeration not given, using calculated "
- "value %.0f"),
- z_exag);
+ "value %.0f"), z_exag);
}
Nviz_change_exag(&data, z_exag);
@@ -148,10 +148,10 @@
}
else {
double min, max;
+
Nviz_get_exag_height(&vp_height, &min, &max);
G_verbose_message(_("Viewpoint height not given, using calculated "
- "value %.0f"),
- vp_height);
+ "value %.0f"), vp_height);
}
Nviz_set_viewpoint_height(vp_height);
@@ -159,21 +159,21 @@
atof(params->pos->answers[1]));
Nviz_set_viewpoint_twist(atoi(params->twist->answer));
Nviz_set_viewpoint_persp(atoi(params->persp->answer));
+
if (params->focus->answer) {
- Nviz_set_focus(&data, atof(params->focus->answers[0]),
- atof(params->focus->answers[1]),
- atof(params->focus->answers[2]));
+ Nviz_set_focus(&data, atof(params->focus->answers[0]),
+ atof(params->focus->answers[1]),
+ atof(params->focus->answers[2]));
}
/* set lights */
Nviz_set_light_position(&data, 1,
atof(params->light_pos->answers[0]),
atof(params->light_pos->answers[1]),
- atof(params->light_pos->answers[2]),
- 0.0);
+ atof(params->light_pos->answers[2]), 0.0);
Nviz_set_light_bright(&data, 1,
atoi(params->light_bright->answer) / 100.0);
- if(G_str_to_color(params->light_color->answer, &red, &grn, &blu) != 1) {
+ if (G_str_to_color(params->light_color->answer, &red, &grn, &blu) != 1) {
red = grn = blu = 255;
}
Nviz_set_light_color(&data, 1, red, grn, blu);
@@ -183,11 +183,12 @@
/* define fringes */
if (params->fringe->answer) {
int nw, ne, sw, se;
-
+
i = 0;
nw = ne = sw = se = 0;
- while(params->fringe->answers[i]) {
+ while (params->fringe->answers[i]) {
const char *edge = params->fringe->answers[i++];
+
if (strcmp(edge, "nw") == 0)
nw = 1;
else if (strcmp(edge, "ne") == 0)
@@ -197,29 +198,33 @@
else if (strcmp(edge, "se") == 0)
se = 1;
}
- Nviz_new_fringe(&data, -1, Nviz_color_from_str(params->fringe_color->answer),
+ Nviz_new_fringe(&data, -1,
+ Nviz_color_from_str(params->fringe_color->answer),
atof(params->fringe_elev->answer), nw, ne, sw, se);
}
/* draw north arrow */
if (params->north_arrow->answer) {
-
+
if (!params->north_arrow_size->answer)
size = Nviz_get_longdim(&data) / 8.;
else
size = atof(params->north_arrow_size->answer);
Nviz_set_arrow(&data, atoi(params->north_arrow->answers[0]),
- atoi(params->north_arrow->answers[1]),
- size, Nviz_color_from_str(params->north_arrow_color->answer));
+ atoi(params->north_arrow->answers[1]),
+ size,
+ Nviz_color_from_str(params->north_arrow_color->
+ answer));
Nviz_draw_arrow(&data);
}
GS_clear(data.bgcolor);
/* cutting planes */
- if(params->cplane->answer)
- draw_cplane(params, &data);
+ if (params->cplane->answer)
+ draw_cplane(params, &data);
+
/* draw */
Nviz_draw_all(&data);
Modified: grass/trunk/misc/m.nviz.image/surface.c
===================================================================
--- grass/trunk/misc/m.nviz.image/surface.c 2014-01-27 19:06:00 UTC (rev 58788)
+++ grass/trunk/misc/m.nviz.image/surface.c 2014-01-28 01:57:55 UTC (rev 58789)
@@ -1,17 +1,17 @@
/*!
- \file surface.c
-
- \brief Surface subroutines
-
- (C) 2008, 2010 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
-*/
+ \file surface.c
+ \brief Surface subroutines
+
+ (C) 2008, 2010 by the GRASS Development Team
+
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
+ */
+
#include <stdlib.h>
#include <string.h>
@@ -20,11 +20,11 @@
#include "local_proto.h"
/*!
- \brief Load raster maps/constants and set surface attributes
-
- \param params module parameters
- \param data nviz data
-*/
+ \brief Load raster maps/constants and set surface attributes
+
+ \param params module parameters
+ \param data nviz data
+ */
int load_rasters(const struct GParams *params, nv_data * data)
{
const char *mapset;
@@ -52,16 +52,16 @@
}
id = Nviz_new_map_obj(MAP_OBJ_SURF,
- G_fully_qualified_name(params->elev_map->
- answers[i], mapset),
- 0.0, data);
+ G_fully_qualified_name(params->
+ elev_map->answers[i],
+ mapset), 0.0, data);
}
else {
- if (i-nelev_map < nelev_const && strcmp(params->elev_const->answers[i-nelev_map], "")) {
- id = Nviz_new_map_obj(MAP_OBJ_SURF,
- NULL,
- atof(params->elev_const->answers[i-nelev_map]),
- data);
+ if (i - nelev_map < nelev_const &&
+ strcmp(params->elev_const->answers[i - nelev_map], "")) {
+ id = Nviz_new_map_obj(MAP_OBJ_SURF, NULL,
+ atof(params->elev_const->
+ answers[i - nelev_map]), data);
}
else {
G_fatal_error(_("Missing topography attribute for surface %d"),
@@ -70,16 +70,16 @@
}
/* set position */
- if (opt_get_num_answers(params->surface_pos) != 3 * nelevs){
- x = atof(params->surface_pos->answers[0]);
- y = atof(params->surface_pos->answers[1]);
- z = atof(params->surface_pos->answers[2]);
- }
- else{
- x = atof(params->surface_pos->answers[i*3+0]);
- y = atof(params->surface_pos->answers[i*3+1]);
- z = atof(params->surface_pos->answers[i*3+2]);
- }
+ if (opt_get_num_answers(params->surface_pos) != 3 * nelevs) {
+ x = atof(params->surface_pos->answers[0]);
+ y = atof(params->surface_pos->answers[1]);
+ z = atof(params->surface_pos->answers[2]);
+ }
+ else {
+ x = atof(params->surface_pos->answers[i * 3 + 0]);
+ y = atof(params->surface_pos->answers[i * 3 + 1]);
+ z = atof(params->surface_pos->answers[i * 3 + 2]);
+ }
GS_set_trans(id, x, y, z);
}
@@ -109,30 +109,34 @@
}
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, MAP_ATT,
- G_fully_qualified_name(params->color_map->
- answers[i], mapset), -1.0,
- data);
+ G_fully_qualified_name(params->
+ color_map->answers[i],
+ mapset), -1.0, data);
}
/* check for color value */
- else if (i-ncolor_map < ncolor_const &&
- strcmp(params->color_const->answers[i-ncolor_map], "")) {
+ else if (i - ncolor_map < ncolor_const &&
+ strcmp(params->color_const->answers[i - ncolor_map], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, CONST_ATT, NULL,
- Nviz_color_from_str(params->color_const->
- answers[i-ncolor_map]), data);
+ Nviz_color_from_str(params->
+ color_const->answers[i -
+ ncolor_map]),
+ data);
}
else { /* use by default elevation map for coloring */
- if (nelev_map > 0){
- Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, MAP_ATT,
- G_fully_qualified_name(params->elev_map->answers[i],
- mapset), -1.0, data);
- G_verbose_message(_("Color attribute not defined, using default <%s>"),
- G_fully_qualified_name(params->elev_map->
- answers[i], mapset));
- }
- else{
- G_fatal_error(_("Missing color attribute for surface %d"),
+ if (nelev_map > 0) {
+ Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, MAP_ATT,
+ G_fully_qualified_name(params->elev_map->
+ answers[i], mapset),
+ -1.0, data);
+ G_verbose_message(_("Color attribute not defined, using default <%s>"),
+ G_fully_qualified_name(params->
+ elev_map->answers[i],
+ mapset));
+ }
+ else {
+ G_fatal_error(_("Missing color attribute for surface %d"),
i + 1);
- }
+ }
}
/* mask */
if (i < nmask_map && strcmp(params->mask_map->answers[i], "")) {
@@ -144,27 +148,29 @@
/* transparency */
if (i < ntransp_map && strcmp(params->transp_map->answers[i], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_TRANSP, MAP_ATT,
- G_fully_qualified_name(params->transp_map->
- answers[i], mapset), -1.0,
- data);
+ G_fully_qualified_name(params->
+ transp_map->answers[i],
+ mapset), -1.0, data);
}
- else if (i-ntransp_map < ntransp_const &&
- strcmp(params->transp_const->answers[i-ntransp_map], "")) {
+ else if (i - ntransp_map < ntransp_const &&
+ strcmp(params->transp_const->answers[i - ntransp_map], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_TRANSP, CONST_ATT, NULL,
- atof(params->transp_const->answers[i-ntransp_map]), data);
+ atof(params->transp_const->
+ answers[i - ntransp_map]), data);
}
/* shininess */
if (i < nshine_map && strcmp(params->shine_map->answers[i], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_SHINE, MAP_ATT,
- G_fully_qualified_name(params->shine_map->
- answers[i], mapset), -1.0,
- data);
+ G_fully_qualified_name(params->
+ shine_map->answers[i],
+ mapset), -1.0, data);
}
- else if (i-nshine_map < nshine_const &&
- strcmp(params->shine_const->answers[i-nshine_map], "")) {
+ else if (i - nshine_map < nshine_const &&
+ strcmp(params->shine_const->answers[i - nshine_map], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_SHINE, CONST_ATT, NULL,
- atof(params->shine_const->answers[i-nshine_map]), data);
+ atof(params->shine_const->answers[i - nshine_map]),
+ data);
}
/* emission */
@@ -173,10 +179,11 @@
G_fully_qualified_name(params->emit_map->answers[i],
mapset), -1.0, data);
}
- else if (i-nemit_map < nemit_const &&
- strcmp(params->emit_const->answers[i-nemit_map], "")) {
+ else if (i - nemit_map < nemit_const &&
+ strcmp(params->emit_const->answers[i - nemit_map], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_EMIT, CONST_ATT, NULL,
- atof(params->emit_const->answers[i-nemit_map]), data);
+ atof(params->emit_const->answers[i - nemit_map]),
+ data);
}
/*
@@ -189,10 +196,10 @@
}
/*!
- \brief Set draw mode for loaded surfaces
-
- \param params module parameters
-*/
+ \brief Set draw mode for loaded surfaces
+
+ \param params module parameters
+ */
void surface_set_draw_mode(const struct GParams *params)
{
int *surf_list, nsurfs;
Modified: grass/trunk/misc/m.nviz.image/vector.c
===================================================================
--- grass/trunk/misc/m.nviz.image/vector.c 2014-01-27 19:06:00 UTC (rev 58788)
+++ grass/trunk/misc/m.nviz.image/vector.c 2014-01-28 01:57:55 UTC (rev 58789)
@@ -1,17 +1,17 @@
/*!
- \file vector.c
-
- \brief Vector subroutines
-
- (C) 2008-2013 by the GRASS Development Team
+ \file vector.c
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
-*/
+ \brief Vector subroutines
+ (C) 2008-2013 by the GRASS Development Team
+
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
+ */
+
#include <stdlib.h>
#include <string.h>
@@ -22,18 +22,19 @@
#include "local_proto.h"
static int load_vectors(const struct Option *, const struct Option *,
- const struct Option *, const struct Option *, int, nv_data *);
+ const struct Option *, const struct Option *, int,
+ nv_data *);
static void error_handler_vector(void *);
static void error_handler_db(void *);
/*!
- \brief Load vector maps (lines)
-
- \param params module parameters
- \param data nviz data
-
- \return number of loaded vectors
-*/
+ \brief Load vector maps (lines)
+
+ \param params module parameters
+ \param data nviz data
+
+ \return number of loaded vectors
+ */
int load_vlines(const struct GParams *params, nv_data * data)
{
return load_vectors(params->elev_map, params->elev_const,
@@ -42,13 +43,13 @@
}
/*!
- \brief Load vector maps (points)
-
- \param params module parameters
- \param data nviz data
-
- \return number of loaded vectors
-*/
+ \brief Load vector maps (points)
+
+ \param params module parameters
+ \param data nviz data
+
+ \return number of loaded vectors
+ */
int load_vpoints(const struct GParams *params, nv_data * data)
{
return load_vectors(params->elev_map, params->elev_const,
@@ -67,7 +68,7 @@
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;
@@ -85,13 +86,13 @@
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);
+ 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]);
+ 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);
@@ -105,13 +106,13 @@
}
/*!
- \brief Set vector lines mode
-
- \param params parameters
-
- \return 1 on success
- \return 0 on failure
-*/
+ \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;
@@ -120,35 +121,36 @@
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)
+ width_column,
+ have_colors ? &colors : NULL) < 0)
return 0;
/* height */
@@ -161,27 +163,28 @@
}
/*!
- \brief Set vector points style
-
- \param params parameters
-
- \return 1 on success
- \return 0 on failure
-*/
+ \brief Set vector points style
+
+ \param params parameters
+
+ \return 1 on success
+ \return 0 on failure
+ */
int vpoints_set_attrb(const struct GParams *params)
{
int i, layer, have_colors, with_z;
int *site_list, nsites;
int marker, color, width;
float size;
- char *marker_str, *color_column, *size_column, *width_column, *marker_column;
+ char *marker_str, *color_column, *size_column, *width_column,
+ *marker_column;
struct Colors colors;
-
+
site_list = GP_get_site_list(&nsites);
for (i = 0; i < nsites; i++) {
- check_map(params, i, FALSE, &layer, &with_z);
+ check_map(params, i, FALSE, &layer, &with_z);
color = Nviz_color_from_str(params->vpoint_color->answers[i]);
color_column = params->vpoint_color_column->answers ?
@@ -197,7 +200,7 @@
params->vpoint_marker_column->answers[i] : NULL;
marker = GP_str_to_marker(marker_str);
- if (with_z) {
+ if (with_z) {
if (strcmp(params->vpoint_mode->answers[i], "surface") == 0)
GP_set_zmode(site_list[i], FALSE);
else
@@ -210,11 +213,12 @@
/* check for vector color table */
have_colors = Vect_read_colors(params->vpoints->answers[i], "",
&colors);
-
+
if (have_colors || color_column || width_column ||
size_column || marker_column) {
if (GP_set_style_thematic(site_list[i], layer, color_column,
- width_column, size_column, marker_column,
+ width_column, size_column,
+ marker_column,
have_colors ? &colors : NULL) < 0)
return 0;
}
@@ -224,18 +228,18 @@
}
/*!
- \brief Check vector map
+ \brief Check vector map
- \param params parameters
- \param index answers array index
- \param vlines TRUE for lines otherwise points
- \param[out] field number
- \param[out] WITH_Z for 3D maps
+ \param params parameters
+ \param index answers array index
+ \param vlines TRUE for lines otherwise points
+ \param[out] field number
+ \param[out] WITH_Z for 3D maps
- \return 0 on success otherwise 1
-*/
+ \return 0 on success otherwise 1
+ */
int check_map(const struct GParams *params, int index, int vlines,
- int *field, int *with_z)
+ int *field, int *with_z)
{
int type;
struct Map_info Map;
@@ -244,98 +248,99 @@
dbDriver *driver;
dbColumn *column;
-
+
Fi = NULL;
driver = NULL;
if (vlines) {
- map = params->vlines->answers[index];
- layer = params->vline_layer->answers[index];
- color = params->vline_color_column->answers ?
- params->vline_color_column->answers[index] : NULL;
- size = NULL;
- width = params->vline_width_column->answers ?
- params->vline_width_column->answers[index] : NULL;
+ map = params->vlines->answers[index];
+ layer = params->vline_layer->answers[index];
+ color = params->vline_color_column->answers ?
+ params->vline_color_column->answers[index] : NULL;
+ size = NULL;
+ width = params->vline_width_column->answers ?
+ params->vline_width_column->answers[index] : NULL;
marker = NULL;
}
else {
- map = params->vpoints->answers[index];
- layer = params->vpoint_layer->answers[index];
- color = params->vpoint_color_column->answers ?
- params->vpoint_color_column->answers[index] : NULL;
- size = params->vpoint_size_column->answers ?
- params->vpoint_size_column->answers[index] : NULL;
- width = params->vpoint_width_column->answers ?
- params->vpoint_width_column->answers[index] : NULL;
+ map = params->vpoints->answers[index];
+ layer = params->vpoint_layer->answers[index];
+ color = params->vpoint_color_column->answers ?
+ params->vpoint_color_column->answers[index] : NULL;
+ size = params->vpoint_size_column->answers ?
+ params->vpoint_size_column->answers[index] : NULL;
+ width = params->vpoint_width_column->answers ?
+ params->vpoint_width_column->answers[index] : NULL;
marker = params->vpoint_marker_column->answers ?
- params->vpoint_marker_column->answers[index] : NULL;
+ params->vpoint_marker_column->answers[index] : NULL;
}
if (!map)
- return 1;
-
+ return 1;
+
if (1 > Vect_open_old(&Map, map, ""))
- G_fatal_error(_("Unable to open vector map <%s>"), map);
+ G_fatal_error(_("Unable to open vector map <%s>"), map);
G_add_error_handler(error_handler_vector, &Map);
if (with_z)
- *with_z = Vect_is_3d(&Map);
+ *with_z = Vect_is_3d(&Map);
- *field = -1;
+ *field = -1;
Fi = Vect_get_field2(&Map, layer);
if (Fi) {
- *field = Fi->number;
-
- driver = db_start_driver_open_database(Fi->driver, Fi->database);
- if (!driver)
- G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
- Fi->database, Fi->driver);
- G_add_error_handler(error_handler_db, driver);
-
- if (color) {
- db_get_column(driver, Fi->table, color, &column);
- if (!column)
- G_fatal_error(_("Column <%s> in table <%s> not found"),
- color, Fi->table);
-
- if (db_column_Ctype(driver, Fi->table, color) != DB_C_TYPE_STRING)
- G_fatal_error(_("Data type of color column must be character"));
- }
- if (size) {
- db_get_column(driver, Fi->table, size, &column);
- if (!column)
- G_fatal_error(_("Column <%s> in table <%s> not found"),
- size, Fi->table);
-
- type = db_column_Ctype(driver, Fi->table, size);
- if (type != DB_C_TYPE_INT && type != DB_C_TYPE_DOUBLE)
- G_fatal_error(_("Data type of size column must be numeric"));
- }
- if (width) {
- db_get_column(driver, Fi->table, width, &column);
- if (!column)
- G_fatal_error(_("Column <%s> in table <%s> not found"),
- width, Fi->table);
-
- type = db_column_Ctype(driver, Fi->table, width);
- if (type != DB_C_TYPE_INT && type != DB_C_TYPE_DOUBLE)
- G_fatal_error(_("Data type of width column must be numeric"));
- }
- if (marker) {
- db_get_column(driver, Fi->table, marker, &column);
- if (!column)
- G_fatal_error(_("Column <%s> in table <%s> not found"),
- marker, Fi->table);
-
- type = db_column_Ctype(driver, Fi->table, marker);
- if (db_column_Ctype(driver, Fi->table, marker) != DB_C_TYPE_STRING)
- G_fatal_error(_("Data type of marker column must be character"));
- }
-
- G_remove_error_handler(error_handler_db, driver);
- db_close_database_shutdown_driver(driver);
+ *field = Fi->number;
+
+ driver = db_start_driver_open_database(Fi->driver, Fi->database);
+ if (!driver)
+ G_fatal_error(_("Unable to open database <%s> by driver <%s>"),
+ Fi->database, Fi->driver);
+ G_add_error_handler(error_handler_db, driver);
+
+ if (color) {
+ db_get_column(driver, Fi->table, color, &column);
+ if (!column)
+ G_fatal_error(_("Column <%s> in table <%s> not found"),
+ color, Fi->table);
+
+ if (db_column_Ctype(driver, Fi->table, color) != DB_C_TYPE_STRING)
+ G_fatal_error(_("Data type of color column must be character"));
+ }
+ if (size) {
+ db_get_column(driver, Fi->table, size, &column);
+ if (!column)
+ G_fatal_error(_("Column <%s> in table <%s> not found"),
+ size, Fi->table);
+
+ type = db_column_Ctype(driver, Fi->table, size);
+ if (type != DB_C_TYPE_INT && type != DB_C_TYPE_DOUBLE)
+ G_fatal_error(_("Data type of size column must be numeric"));
+ }
+ if (width) {
+ db_get_column(driver, Fi->table, width, &column);
+ if (!column)
+ G_fatal_error(_("Column <%s> in table <%s> not found"),
+ width, Fi->table);
+
+ type = db_column_Ctype(driver, Fi->table, width);
+ if (type != DB_C_TYPE_INT && type != DB_C_TYPE_DOUBLE)
+ G_fatal_error(_("Data type of width column must be numeric"));
+ }
+ if (marker) {
+ db_get_column(driver, Fi->table, marker, &column);
+ if (!column)
+ G_fatal_error(_("Column <%s> in table <%s> not found"),
+ marker, Fi->table);
+
+ type = db_column_Ctype(driver, Fi->table, marker);
+ if (db_column_Ctype(driver, Fi->table, marker) !=
+ DB_C_TYPE_STRING)
+ G_fatal_error(_("Data type of marker column must be character"));
+ }
+
+ G_remove_error_handler(error_handler_db, driver);
+ db_close_database_shutdown_driver(driver);
}
-
+
G_remove_error_handler(error_handler_vector, &Map);
Vect_close(&Map);
@@ -355,7 +360,7 @@
{
dbDriver *driver;
- driver = (dbDriver *)p;
- if (driver)
- db_close_database_shutdown_driver(driver);
+ driver = (dbDriver *) p;
+ if (driver)
+ db_close_database_shutdown_driver(driver);
}
Modified: grass/trunk/misc/m.nviz.image/volume.c
===================================================================
--- grass/trunk/misc/m.nviz.image/volume.c 2014-01-27 19:06:00 UTC (rev 58788)
+++ grass/trunk/misc/m.nviz.image/volume.c 2014-01-28 01:57:55 UTC (rev 58789)
@@ -1,17 +1,17 @@
/*!
- \file volume.c
-
- \brief Volume subroutines
-
- (C) 2008, 2010 by the GRASS Development Team
+ \file volume.c
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
-*/
+ \brief Volume subroutines
+ (C) 2008, 2010 by the GRASS Development Team
+
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ \author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
+ */
+
#include <stdlib.h>
#include <string.h>
@@ -21,19 +21,19 @@
#include "local_proto.h"
/*!
- \brief Load 3d raster map layers -> volume
-
- \param params module parameters
- \param data nviz data
+ \brief Load 3d raster map layers -> volume
- \return number of loaded volumes
-*/
-int load_rasters3d(const struct GParams *params, nv_data *data)
+ \param params module parameters
+ \param data nviz data
+
+ \return number of loaded volumes
+ */
+int load_rasters3d(const struct GParams *params, nv_data * data)
{
int i, nvol, id;
float x, y, z;
char *mapset;
-
+
nvol = opt_get_num_answers(params->volume);
for (i = 0; i < nvol; i++) {
@@ -44,9 +44,9 @@
}
id = Nviz_new_map_obj(MAP_OBJ_VOL,
- G_fully_qualified_name(params->volume->answers[i],
- mapset),
- 0.0, data);
+ G_fully_qualified_name(params->volume->
+ answers[i], mapset), 0.0,
+ data);
/* set position */
if (opt_get_num_answers(params->volume_pos) != 3 * nvol) {
@@ -55,11 +55,11 @@
z = atof(params->volume_pos->answers[2]);
}
else {
- x = atof(params->volume_pos->answers[i*3+0]);
- y = atof(params->volume_pos->answers[i*3+1]);
- z = atof(params->volume_pos->answers[i*3+2]);
+ x = atof(params->volume_pos->answers[i * 3 + 0]);
+ y = atof(params->volume_pos->answers[i * 3 + 1]);
+ z = atof(params->volume_pos->answers[i * 3 + 2]);
}
-
+
GVL_set_trans(id, x, y, z);
if (params->draw_volume_box->answer) {
GVL_set_draw_wire(id, 1);
@@ -70,126 +70,144 @@
}
/*!
- \brief Add isosurfaces and set their attributes
-
- \param params module parameters
- \param data nviz data
-
- \return number of defined isosurfaces
-*/
-int add_isosurfs(const struct GParams *params, nv_data *data)
+ \brief Add isosurfaces and set their attributes
+
+ \param params module parameters
+ \param data nviz data
+
+ \return number of defined isosurfaces
+ */
+int add_isosurfs(const struct GParams *params, nv_data * data)
{
int i;
float level;
int num, nvols, *vol_list, id, nisosurfs;
- int ncolor_map, ncolor_const, ntransp_map, ntransp_const, nshine_map, nshine_const;
+ int ncolor_map, ncolor_const, ntransp_map, ntransp_const, nshine_map,
+ nshine_const;
int res, draw_mode;
char **tokens;
const char *mapset, *style;
-
+
vol_list = GVL_get_vol_list(&nvols);
for (i = 0; params->isosurf_level->answers[i]; i++) {
tokens = G_tokenize(params->isosurf_level->answers[i], ":");
- if (G_number_of_tokens(tokens) != 2)
- G_fatal_error(_("Error tokenize '%s'"),
+ if (G_number_of_tokens(tokens) != 2)
+ G_fatal_error(_("Error tokenize '%s'"),
params->isosurf_level->answers[i]);
num = atoi(tokens[0]);
level = atof(tokens[1]);
G_free_tokens(tokens);
if (num > nvols) {
- G_fatal_error(_("Volume set number %d is not available"),
- num);
+ G_fatal_error(_("Volume set number %d is not available"), num);
}
- id = vol_list[num-1];
+ id = vol_list[num - 1];
if (GVL_isosurf_add(id) < 0) {
- G_fatal_error(_("Unable to add isosurface (volume set %d)"),
- id);
+ G_fatal_error(_("Unable to add isosurface (volume set %d)"), id);
}
nisosurfs = GVL_isosurf_num_isosurfs(id);
if (params->isosurf_toggle_norm_dir->answer) {
- GVL_isosurf_set_flags(id, nisosurfs-1, 1);
+ GVL_isosurf_set_flags(id, nisosurfs - 1, 1);
}
/* topography (level) */
- if (GVL_isosurf_set_att_const(id, nisosurfs-1, ATT_TOPO, level) < 0) {
+ if (GVL_isosurf_set_att_const(id, nisosurfs - 1, ATT_TOPO, level) < 0) {
G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
- nisosurfs-1, ATT_TOPO, id);
+ nisosurfs - 1, ATT_TOPO, id);
}
/* color */
ncolor_map = opt_get_num_answers(params->isosurf_color_map);
ncolor_const = opt_get_num_answers(params->isosurf_color_const);
- if (i < ncolor_map && strcmp(params->isosurf_color_map->answers[i], "")) {
- mapset = G_find_raster3d(params->isosurf_color_map->answers[i], "");
+ if (i < ncolor_map &&
+ strcmp(params->isosurf_color_map->answers[i], "")) {
+ mapset =
+ G_find_raster3d(params->isosurf_color_map->answers[i], "");
if (mapset == NULL) {
G_fatal_error(_("3d raster map <%s> not found"),
params->isosurf_color_map->answers[i]);
}
- if (GVL_isosurf_set_att_map(id, nisosurfs-1, ATT_COLOR,
- params->isosurf_color_map->answers[i]) < 0)
+ if (GVL_isosurf_set_att_map(id, nisosurfs - 1, ATT_COLOR,
+ params->isosurf_color_map->
+ answers[i]) < 0)
G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
- nisosurfs-1, ATT_COLOR, id);
+ nisosurfs - 1, ATT_COLOR, id);
}
- else if (i-ncolor_map < ncolor_const &&
- strcmp(params->isosurf_color_const->answers[i-ncolor_map], "")) {
+ else if (i - ncolor_map < ncolor_const &&
+ strcmp(params->isosurf_color_const->answers[i - ncolor_map],
+ "")) {
- if (GVL_isosurf_set_att_const(id, nisosurfs-1, ATT_COLOR,
- Nviz_color_from_str(params->isosurf_color_const->answers[i-ncolor_map])) < 0)
+ if (GVL_isosurf_set_att_const(id, nisosurfs - 1, ATT_COLOR,
+ Nviz_color_from_str(params->
+ isosurf_color_const->
+ answers[i -
+ ncolor_map]))
+ < 0)
G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
- nisosurfs-1, ATT_COLOR, id);
+ nisosurfs - 1, ATT_COLOR, id);
}
else { /* use by default 3d raster map for coloring */
- GVL_isosurf_set_att_map(id, nisosurfs-1, ATT_COLOR, params->volume->answers[num-1]);
+ GVL_isosurf_set_att_map(id, nisosurfs - 1, ATT_COLOR,
+ params->volume->answers[num - 1]);
G_verbose_message(_("Color attribute not defined, using default <%s>"),
- params->volume->answers[num-1]);
+ params->volume->answers[num - 1]);
}
/* transparency */
ntransp_map = opt_get_num_answers(params->isosurf_transp_map);
ntransp_const = opt_get_num_answers(params->isosurf_transp_const);
- if (i < ntransp_map && strcmp(params->isosurf_transp_map->answers[i], "")) {
- if (GVL_isosurf_set_att_map(id, nisosurfs-1, ATT_TRANSP,
- params->isosurf_transp_map->answers[i]) < 0)
+ if (i < ntransp_map &&
+ strcmp(params->isosurf_transp_map->answers[i], "")) {
+ if (GVL_isosurf_set_att_map
+ (id, nisosurfs - 1, ATT_TRANSP,
+ params->isosurf_transp_map->answers[i]) < 0)
G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
- nisosurfs-1, ATT_TRANSP, id);
+ nisosurfs - 1, ATT_TRANSP, id);
}
- else if (i-ntransp_map < ntransp_const &&
- strcmp(params->isosurf_transp_const->answers[i-ntransp_map], "")) {
- if (GVL_isosurf_set_att_const(id, nisosurfs-1, ATT_TRANSP,
- atof(params->isosurf_transp_const->answers[i-ntransp_map])) < 0)
+ else if (i - ntransp_map < ntransp_const &&
+ strcmp(params->isosurf_transp_const->
+ answers[i - ntransp_map], "")) {
+ if (GVL_isosurf_set_att_const
+ (id, nisosurfs - 1, ATT_TRANSP,
+ atof(params->isosurf_transp_const->
+ answers[i - ntransp_map])) < 0)
G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
- nisosurfs-1, ATT_TRANSP, id);
+ nisosurfs - 1, ATT_TRANSP, id);
}
/* shine */
nshine_map = opt_get_num_answers(params->isosurf_shine_map);
nshine_const = opt_get_num_answers(params->isosurf_shine_const);
- if (i < nshine_map && strcmp(params->isosurf_shine_map->answers[i], "")) {
- if (GVL_isosurf_set_att_map(id, nisosurfs-1, ATT_SHINE,
- params->isosurf_shine_map->answers[i]) < 0)
+ if (i < nshine_map &&
+ strcmp(params->isosurf_shine_map->answers[i], "")) {
+ if (GVL_isosurf_set_att_map
+ (id, nisosurfs - 1, ATT_SHINE,
+ params->isosurf_shine_map->answers[i]) < 0)
G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
- nisosurfs-1, ATT_SHINE, id);
+ nisosurfs - 1, ATT_SHINE, id);
}
- else if (i-nshine_map < nshine_const &&
- strcmp(params->isosurf_shine_const->answers[i-nshine_map], "")) {
- if (GVL_isosurf_set_att_const(id, nisosurfs-1, ATT_SHINE,
- atof(params->isosurf_shine_const->answers[i-nshine_map])) < 0)
+ else if (i - nshine_map < nshine_const &&
+ strcmp(params->isosurf_shine_const->answers[i - nshine_map],
+ "")) {
+ if (GVL_isosurf_set_att_const
+ (id, nisosurfs - 1, ATT_SHINE,
+ atof(params->isosurf_shine_const->answers[i - nshine_map])) <
+ 0)
G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
- nisosurfs-1, ATT_SHINE, id);
+ nisosurfs - 1, ATT_SHINE, id);
}
}
- /* set draw resolution and shading after isosurfaces are added*/
+ /* set draw resolution and shading after isosurfaces are added */
for (i = 0; i < nvols; i++) {
id = vol_list[i];
@@ -215,71 +233,69 @@
else {
draw_mode |= DM_GOURAUD;
}
-
+
GVL_isosurf_set_drawmode(id, draw_mode);
}
return 1;
}
-int add_slices(const struct GParams *params, nv_data *data)
+int add_slices(const struct GParams *params, nv_data * data)
{
int i;
int num, nvols, *vol_list, id, nslices, axis;
int res, draw_mode;
char **tokens;
- const char* style;
+ const char *style;
vol_list = GVL_get_vol_list(&nvols);
for (i = 0; params->slice->answers[i]; i++) {
tokens = G_tokenize(params->slice->answers[i], ":");
- if (G_number_of_tokens(tokens) != 2)
- G_fatal_error(_("Error tokenize '%s'"),
+ if (G_number_of_tokens(tokens) != 2)
+ G_fatal_error(_("Error tokenize '%s'"),
params->slice->answers[i]);
num = atoi(tokens[0]);
- if (!strcmp(tokens[1],"x") || !strcmp(tokens[1],"X"))
+ if (!strcmp(tokens[1], "x") || !strcmp(tokens[1], "X"))
axis = 0;
- else if (!strcmp(tokens[1],"y") || !strcmp(tokens[1],"Y"))
+ else if (!strcmp(tokens[1], "y") || !strcmp(tokens[1], "Y"))
axis = 1;
- else if (!strcmp(tokens[1],"z") || !strcmp(tokens[1],"Z"))
+ else if (!strcmp(tokens[1], "z") || !strcmp(tokens[1], "Z"))
axis = 2;
else
- G_fatal_error(_("Wrong name for axis: %s"),
- tokens[1]);
+ G_fatal_error(_("Wrong name for axis: %s"), tokens[1]);
G_free_tokens(tokens);
if (num > nvols) {
- G_fatal_error(_("Volume set number %d is not available"),
- num);
+ G_fatal_error(_("Volume set number %d is not available"), num);
}
- id = vol_list[num-1];
+ id = vol_list[num - 1];
if (GVL_slice_add(id) < 0) {
- G_fatal_error(_("Unable to add slice (volume set %d)"),
- id);
+ G_fatal_error(_("Unable to add slice (volume set %d)"), id);
}
nslices = GVL_slice_num_slices(id);
- if (GVL_slice_set_pos(id, nslices-1, atof(params->slice_pos->answers[i*6+0]),
- atof(params->slice_pos->answers[i*6+1]),
- atof(params->slice_pos->answers[i*6+2]),
- atof(params->slice_pos->answers[i*6+3]),
- atof(params->slice_pos->answers[i*6+4]),
- atof(params->slice_pos->answers[i*6+5]),
- axis) < 0)
+ if (GVL_slice_set_pos
+ (id, nslices - 1, atof(params->slice_pos->answers[i * 6 + 0]),
+ atof(params->slice_pos->answers[i * 6 + 1]),
+ atof(params->slice_pos->answers[i * 6 + 2]),
+ atof(params->slice_pos->answers[i * 6 + 3]),
+ atof(params->slice_pos->answers[i * 6 + 4]),
+ atof(params->slice_pos->answers[i * 6 + 5]), axis) < 0)
G_fatal_error(_("Unable to set slice (%d) position of volume %d"),
- nslices-1, id);
+ nslices - 1, id);
/* set transparency */
- if (GVL_slice_set_transp(id, nslices-1, atoi(params->slice_transp->answers[i])) < 0)
+ if (GVL_slice_set_transp
+ (id, nslices - 1, atoi(params->slice_transp->answers[i])) < 0)
G_fatal_error(_("Unable to set slice (%d) transparency of volume %d"),
- nslices-1, id);
+ nslices - 1, id);
}
- /* set draw resolution and shading after slices are added*/
+ /* set draw resolution and shading after slices are added */
for (i = 0; i < nvols; i++) {
id = vol_list[i];
Modified: grass/trunk/misc/m.nviz.image/write_img.c
===================================================================
--- grass/trunk/misc/m.nviz.image/write_img.c 2014-01-27 19:06:00 UTC (rev 58788)
+++ grass/trunk/misc/m.nviz.image/write_img.c 2014-01-28 01:57:55 UTC (rev 58789)
@@ -1,31 +1,31 @@
/*!
- \file write_img.c
-
- \brief Save current GL screen to image file.
-
- (C) 2008, 2010 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- Based on visualization/nviz/src/anim_support.c
-
- \author Updated/modified by Martin Landa <landa.martin gmail.com>
-*/
+ \file write_img.c
+ \brief Save current GL screen to image file.
+
+ (C) 2008, 2010 by the GRASS Development Team
+
+ This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+
+ Based on visualization/nviz/src/anim_support.c
+
+ \author Updated/modified by Martin Landa <landa.martin gmail.com>
+ */
+
#include "local_proto.h"
#include <grass/ogsf.h>
/*!
- \brief Save current GL screen to an ppm file.
-
- \param name filename
-
- \return 1 on success
- \return 0 on failure (unsupported format)
-*/
+ \brief Save current GL screen to an ppm file.
+
+ \param name filename
+
+ \return 1 on success
+ \return 0 on failure (unsupported format)
+ */
int write_img(const char *name, int format)
{
if (format == FORMAT_PPM)
More information about the grass-commit
mailing list