[GRASS-SVN] r32200 - in grass/trunk: include lib/nviz lib/ogsf
visualization/nviz2/cmd
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 21 18:52:43 EDT 2008
Author: martinl
Date: 2008-07-21 18:52:43 -0400 (Mon, 21 Jul 2008)
New Revision: 32200
Modified:
grass/trunk/include/nviz.h
grass/trunk/lib/nviz/map_obj.c
grass/trunk/lib/ogsf/GP2.c
grass/trunk/visualization/nviz2/cmd/args.c
grass/trunk/visualization/nviz2/cmd/local_proto.h
grass/trunk/visualization/nviz2/cmd/main.c
grass/trunk/visualization/nviz2/cmd/surface.c
grass/trunk/visualization/nviz2/cmd/vector.c
Log:
nviz2/cmd: module/nvizlib updated to support 2d points (in progress)
Modified: grass/trunk/include/nviz.h
===================================================================
--- grass/trunk/include/nviz.h 2008-07-21 22:29:53 UTC (rev 32199)
+++ grass/trunk/include/nviz.h 2008-07-21 22:52:43 UTC (rev 32200)
@@ -171,7 +171,7 @@
nv_data *);
int Nviz_set_attr(int, int, int, int, const char *, float,
nv_data *);
-void Nviz_set_attr_default();
+void Nviz_set_surface_attr_default();
int Nviz_unset_attr(int, int, int);
/* nviz.c */
Modified: grass/trunk/lib/nviz/map_obj.c
===================================================================
--- grass/trunk/lib/nviz/map_obj.c 2008-07-21 22:29:53 UTC (rev 32199)
+++ grass/trunk/lib/nviz/map_obj.c 2008-07-21 22:52:43 UTC (rev 32200)
@@ -91,7 +91,7 @@
/* vector overlay */
else if (type == MAP_OBJ_VECT) {
if (GV_num_vects() >= MAX_VECTS) {
- G_warning (_("Maximum vectors loaded!"));
+ G_warning (_("Maximum vector line maps loaded!"));
return -1;
}
@@ -120,7 +120,7 @@
else if (type == MAP_OBJ_SITE) {
geosite * gp;
if (GP_num_sites() >= MAX_SITES) {
- G_warning (_("Maximum point vectors loaded!"));
+ G_warning (_("Maximum vector point maps loaded!"));
return -1;
}
@@ -137,17 +137,15 @@
/* load vector points */
if (0 > GP_load_site(new_id, name)) {
GP_delete_site(new_id);
- G_warning (_("Error loading point vector map <%s>"), name);
+ G_warning (_("Error loading vector map <%s>"), name);
return -1;
}
/* initialize display parameters */
GP_set_sitemode(new_id, ST_ATT_NONE, 0xFF0000, 2, 100, ST_X);
surf_list = GS_get_surf_list(&num_surfs);
- if (num_surfs) {
- for (i = 0; i < num_surfs; i++) {
- GP_select_surf(new_id, surf_list[i]);
- }
+ for (i = 0; i < num_surfs; i++) {
+ GP_select_surf(new_id, surf_list[i]);
}
G_free (surf_list);
}
@@ -291,9 +289,9 @@
}
/*!
- \brief Set default map object attributes
+ \brief Set default surface attributes
*/
-void Nviz_set_attr_default()
+void Nviz_set_surface_attr_default()
{
float defs[MAX_ATTS];
Modified: grass/trunk/lib/ogsf/GP2.c
===================================================================
--- grass/trunk/lib/ogsf/GP2.c 2008-07-21 22:29:53 UTC (rev 32199)
+++ grass/trunk/lib/ogsf/GP2.c 2008-07-21 22:52:43 UTC (rev 32200)
@@ -245,7 +245,7 @@
\param id point set id
\param atmod
\param color icon color
- \param width
+ \param width icon line width
\param size icon size
\param marker icon symbol
Modified: grass/trunk/visualization/nviz2/cmd/args.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/args.c 2008-07-21 22:29:53 UTC (rev 32199)
+++ grass/trunk/visualization/nviz2/cmd/args.c 2008-07-21 22:52:43 UTC (rev 32200)
@@ -9,7 +9,7 @@
License (>=v2). Read the file COPYING that comes with GRASS
for details.
- \author Martin Landa <landa.martin gmail.com>
+ \author Martin Landa <landa.martin gmail.com> (Google SoC 2008)
\date 2008
*/
@@ -26,6 +26,11 @@
const char *, const char *,
const char *, const char *);
+static void args_surface(struct GParams *);
+static void args_vline(struct GParams *);
+static void args_vpoint(struct GParams *);
+static void args_viewpoint(struct GParams *);
+
/*!
\brief Parse command
@@ -44,6 +49,65 @@
/*
surface attributes
*/
+ args_surface(params);
+
+ /*
+ vector lines
+ */
+ args_vline(params);
+
+ /*
+ vector points
+ */
+ args_vpoint(params);
+
+ /*
+ misc
+ */
+ /* background color */
+ params->bgcolor = G_define_standard_option(G_OPT_C_BG);
+
+ /*
+ viewpoint
+ */
+ args_viewpoint(params);
+
+ /*
+ image
+ */
+ /* output */
+ params->output = G_define_standard_option(G_OPT_F_OUTPUT);
+ params->output->description = _("Name for output file (do not add extension)");
+ params->output->guisection = _("Image");
+
+ /* format */
+ params->format = G_define_option();
+ params->format->key = "format";
+ params->format->type = TYPE_STRING;
+ params->format->options = "ppm,tif"; /* TODO: png */
+ params->format->answer = "ppm";
+ params->format->description = _("Graphics file format");
+ params->format->required = YES;
+ params->format->guisection = _("Image");
+
+ /* size */
+ params->size = G_define_option();
+ params->size->key = "size";
+ params->size->type = TYPE_INTEGER;
+ params->size->key_desc = "width,height";
+ params->size->answer = "640,480";
+ params->size->description = _("Width and height of output image");
+ params->size->required = YES;
+ params->size->guisection = _("Image");
+
+ if (G_parser(argc, argv))
+ exit(EXIT_FAILURE);
+
+ return;
+}
+
+void args_surface(struct GParams *params)
+{
/* topography */
params->elev_map = G_define_standard_option(G_OPT_R_ELEV);
params->elev_map->key = "elevation_map";
@@ -220,70 +284,113 @@
params->shade->answer = "gouraud";
params->shade->guisection = _("Draw");
- /*
- vector
- */
- params->vector = G_define_standard_option(G_OPT_V_MAP);
- params->vector->multiple = YES;
- params->vector->required = NO;
- params->vector->description = _("Name of vector overlay map(s)");
- params->vector->guisection = _("Vector");
- params->vector->key = "vector";
+ return;
+}
+void args_vline(struct GParams *params)
+{
+ params->vlines = G_define_standard_option(G_OPT_V_MAP);
+ params->vlines->multiple = YES;
+ params->vlines->required = NO;
+ params->vlines->description = _("Name of line vector overlay map(s)");
+ params->vlines->guisection = _("Vector lines");
+ params->vlines->key = "vlines";
+
/* line width */
- params->line_width = G_define_option();
- params->line_width->key = "line_width";
- params->line_width->key_desc = "value";
- params->line_width->type = TYPE_INTEGER;
- params->line_width->required = NO;
- params->line_width->multiple = YES;
- params->line_width->description = _("Vector line width");
- params->line_width->guisection = _("Vector");
- params->line_width->options = "1-100";
- params->line_width->answer = "2";
+ params->vline_width = G_define_option();
+ params->vline_width->key = "vline_width";
+ params->vline_width->key_desc = "value";
+ params->vline_width->type = TYPE_INTEGER;
+ params->vline_width->required = NO;
+ params->vline_width->multiple = YES;
+ params->vline_width->description = _("Vector line width");
+ params->vline_width->guisection = _("Vector lines");
+ params->vline_width->options = "1-100";
+ params->vline_width->answer = "2";
/* line color */
- params->line_color = G_define_standard_option(G_OPT_C_FG);
- params->line_color->multiple = YES;
- params->line_color->required = NO;
- params->line_color->label = _("Vector line color");
- params->line_color->key = "line_color";
- params->line_color->answer = "blue";
- params->line_color->guisection = _("Vector");
+ params->vline_color = G_define_standard_option(G_OPT_C_FG);
+ params->vline_color->multiple = YES;
+ params->vline_color->required = NO;
+ params->vline_color->label = _("Vector line color");
+ params->vline_color->key = "vline_color";
+ params->vline_color->answer = "blue";
+ params->vline_color->guisection = _("Vector lines");
/* line mode */
- params->line_mode = G_define_option();
- params->line_mode->key = "line_mode";
- params->line_mode->key_desc = "string";
- params->line_mode->type = TYPE_STRING;
- params->line_mode->required = YES;
- params->line_mode->multiple = YES;
- params->line_mode->description = _("Vector line display mode");
- params->line_mode->options = "surface,flat";
- params->line_mode->answer = "surface";
- params->line_mode->guisection = _("Vector");
+ params->vline_mode = G_define_option();
+ params->vline_mode->key = "vline_mode";
+ params->vline_mode->key_desc = "string";
+ params->vline_mode->type = TYPE_STRING;
+ params->vline_mode->required = YES;
+ params->vline_mode->multiple = YES;
+ params->vline_mode->description = _("Vector line display mode");
+ params->vline_mode->options = "surface,flat";
+ params->vline_mode->answer = "surface";
+ params->vline_mode->guisection = _("Vector lines");
/* line height */
- params->line_height = G_define_option();
- params->line_height->key = "line_height";
- params->line_height->key_desc = "value";
- params->line_height->type = TYPE_INTEGER;
- params->line_height->required = NO;
- params->line_height->multiple = YES;
- params->line_height->description = _("Vector line height");
- params->line_height->guisection = _("Vector");
- params->line_height->options = "0-1000";
- params->line_height->answer = "0";
+ params->vline_height = G_define_option();
+ params->vline_height->key = "vline_height";
+ params->vline_height->key_desc = "value";
+ params->vline_height->type = TYPE_INTEGER;
+ params->vline_height->required = NO;
+ params->vline_height->multiple = YES;
+ params->vline_height->description = _("Vector line height");
+ params->vline_height->guisection = _("Vector lines");
+ params->vline_height->options = "0-1000";
+ params->vline_height->answer = "0";
- /*
- misc
- */
- /* background color */
- params->bgcolor = G_define_standard_option(G_OPT_C_BG);
+ return;
+}
- /*
- viewpoint
- */
+void args_vpoint(struct GParams *params)
+{
+ params->vpoints = G_define_standard_option(G_OPT_V_MAP);
+ params->vpoints->multiple = YES;
+ params->vpoints->required = NO;
+ params->vpoints->description = _("Name of point vector overlay map(s)");
+ params->vpoints->guisection = _("Vector points");
+ params->vpoints->key = "vpoints";
+
+ /* point width */
+ params->vpoint_size = G_define_option();
+ params->vpoint_size->key = "vpoint_size";
+ params->vpoint_size->key_desc = "value";
+ params->vpoint_size->type = TYPE_INTEGER;
+ params->vpoint_size->required = NO;
+ params->vpoint_size->multiple = YES;
+ params->vpoint_size->description = _("Icon size");
+ params->vpoint_size->guisection = _("Vector points");
+ params->vpoint_size->options = "1-1000";
+ params->vpoint_size->answer = "100";
+
+ /* point color */
+ params->vpoint_color = G_define_standard_option(G_OPT_C_FG);
+ params->vpoint_color->multiple = YES;
+ params->vpoint_color->required = NO;
+ params->vpoint_color->label = _("Icon color");
+ params->vpoint_color->key = "vpoint_color";
+ params->vpoint_color->answer = "blue";
+ params->vpoint_color->guisection = _("Vector points");
+
+ /* point mode */
+ params->vpoint_symbol = G_define_option();
+ params->vpoint_symbol->key = "vpoint_symbol";
+ params->vpoint_symbol->key_desc = "string";
+ params->vpoint_symbol->type = TYPE_STRING;
+ params->vpoint_symbol->required = YES;
+ params->vpoint_symbol->multiple = YES;
+ params->vpoint_symbol->description = _("Icon symbol");
+ params->vpoint_symbol->options = "x,sphere,diamond,cube,box,gyro,aster,histogram";
+ params->vpoint_symbol->answer = "sphere";
+ params->vpoint_symbol->guisection = _("Vector points");
+
+ return;
+}
+
+void args_viewpoint(struct GParams *params)
+{
/* position */
params->pos = G_define_option();
params->pos->key = "position";
@@ -338,38 +445,6 @@
params->exag->multiple = NO;
params->exag->description = _("Vertical exaggeration");
-
- /*
- image
- */
- /* output */
- params->output = G_define_standard_option(G_OPT_F_OUTPUT);
- params->output->description = _("Name for output file (do not add extension)");
- params->output->guisection = _("Image");
-
- /* format */
- params->format = G_define_option();
- params->format->key = "format";
- params->format->type = TYPE_STRING;
- params->format->options = "ppm,tif"; /* TODO: png */
- params->format->answer = "ppm";
- params->format->description = _("Graphics file format");
- params->format->required = YES;
- params->format->guisection = _("Image");
-
- /* size */
- params->size = G_define_option();
- params->size->key = "size";
- params->size->type = TYPE_INTEGER;
- params->size->key_desc = "width,height";
- params->size->answer = "640,480";
- params->size->description = _("Width and height of output image");
- params->size->required = YES;
- params->size->guisection = _("Image");
-
- if (G_parser(argc, argv))
- exit(EXIT_FAILURE);
-
return;
}
@@ -377,34 +452,22 @@
\brief Get number of answers of given option
\param pointer to option
- \param[out] number of non-zero length items (or NULL)
- \param[out] number of all items (or NULL)
+
+ \return number of arguments
*/
-void opt_get_num_answers(const struct Option *opt, int *non_zero, int *all)
+int opt_get_num_answers(const struct Option *opt)
{
int i;
i = 0;
- if(non_zero)
- *non_zero = 0;
-
- if(all)
- *all = 0;
-
if (opt->answer) {
while (opt->answers[i]) {
- if (all)
- (*all)++;
- if (strcmp(opt->answers[i], "")) {
- if (non_zero)
- (*non_zero)++; /* skip empty values */
- }
i++;
}
}
- return;
+ return i;
}
/*!
@@ -414,138 +477,128 @@
*/
void check_parameters(const struct GParams * params)
{
- int nelev_map, nelev_const, nelev_map0, nelev_const0, nelevs0;
- int nmaps0, nconsts0;
+ int nelev_map, nelev_const, nelevs;
+ int nmaps, nconsts;
int nvects;
/* topography */
- opt_get_num_answers(params->elev_map, &nelev_map, &nelev_map0);
- opt_get_num_answers(params->elev_const, &nelev_const, &nelev_const0);
-
- if (nelev_map + nelev_const < 1)
+ nelev_map = opt_get_num_answers(params->elev_map);
+ nelev_const = opt_get_num_answers(params->elev_const);
+ nelevs = nelev_map + nelev_const;
+
+ if (nelevs < 1)
G_fatal_error(_("At least one <%s> or <%s> required"),
params->elev_map->key, params->elev_const->key);
- if ((nelev_map > 0 && nelev_const > 0) &&
- (nelev_map0 != nelev_const0))
- G_fatal_error (_("Inconsistent number of attributes (<%s> %d, <%s> %d)"),
- params->elev_map->key, nelev_map0,
- params->elev_const->key, nelev_const0);
-
- if (nelev_map0 > 0)
- nelevs0 = nelev_map0;
- else
- nelevs0 = nelev_const0;
-
/* color */
- opt_get_num_answers(params->color_map, NULL, &nmaps0);
- opt_get_num_answers(params->color_const, NULL, &nconsts0);
+ nmaps = opt_get_num_answers(params->color_map);
+ nconsts = opt_get_num_answers(params->color_const);
- print_error(nmaps0, nconsts0, nelevs0,
+ print_error(nmaps, nconsts, nelevs,
params->elev_map->key, params->elev_const->key,
params->color_map->key, params->color_const->key);
/* mask */
- opt_get_num_answers(params->mask_map, NULL, &nmaps0);
- if (nmaps0 > 0 && nelevs0 != nmaps0)
+ nmaps = opt_get_num_answers(params->mask_map);
+ if (nmaps > 0 && nelevs != nmaps)
G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d)"),
- params->elev_map->key, params->elev_const->key, nelevs0,
- params->mask_map->key, nmaps0);
+ params->elev_map->key, params->elev_const->key, nelevs,
+ params->mask_map->key, nmaps);
/* transparency */
- opt_get_num_answers(params->transp_map, NULL, &nmaps0);
- opt_get_num_answers(params->transp_const, NULL, &nconsts0);
- print_error(nmaps0, nconsts0, nelevs0,
+ nmaps = opt_get_num_answers(params->transp_map);
+ nconsts = opt_get_num_answers(params->transp_const);
+ print_error(nmaps, nconsts, nelevs,
params->elev_map->key, params->elev_const->key,
params->transp_map->key, params->transp_const->key);
/* shininess */
- opt_get_num_answers(params->shine_map, NULL, &nmaps0);
- opt_get_num_answers(params->shine_const, NULL, &nconsts0);
- print_error(nmaps0, nconsts0, nelevs0,
+ nmaps = opt_get_num_answers(params->shine_map);
+ nconsts = opt_get_num_answers(params->shine_const);
+ print_error(nmaps, nconsts, nelevs,
params->elev_map->key, params->elev_const->key,
params->shine_map->key, params->shine_const->key);
/* emit */
- opt_get_num_answers(params->emit_map, NULL, &nmaps0);
- opt_get_num_answers(params->emit_const, NULL, &nconsts0);
- print_error(nmaps0, nconsts0, nelevs0,
+ nmaps = opt_get_num_answers(params->emit_map);
+ nconsts = opt_get_num_answers(params->emit_const);
+ print_error(nmaps, nconsts, nelevs,
params->elev_map->key, params->elev_const->key,
params->emit_map->key, params->emit_const->key);
/* draw mode */
if (!params->mode_all->answer) { /* use one mode for all surfaces */
- opt_get_num_answers(params->mode, NULL, &nconsts0);
- if (nconsts0 > 0 && nconsts0 != nelevs0)
+ nconsts = opt_get_num_answers(params->mode);
+ if (nconsts > 0 && nconsts != nelevs)
G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d)"),
- params->elev_map->key, params->elev_const->key, nelevs0,
- params->mode->key, nconsts0);
+ params->elev_map->key, params->elev_const->key, nelevs,
+ params->mode->key, nconsts);
- opt_get_num_answers(params->res_fine, NULL, &nconsts0);
- if (nconsts0 > 0 && nconsts0 != nelevs0)
+ nconsts = opt_get_num_answers(params->res_fine);
+ if (nconsts > 0 && nconsts != nelevs)
G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d"),
- params->elev_map->key, params->elev_const->key, nelevs0,
- params->res_fine->key, nconsts0);
+ params->elev_map->key, params->elev_const->key, nelevs,
+ params->res_fine->key, nconsts);
- opt_get_num_answers(params->res_coarse, NULL, &nconsts0);
- if (nconsts0 > 0 && nconsts0 != nelevs0)
+ nconsts = opt_get_num_answers(params->res_coarse);
+ if (nconsts > 0 && nconsts != nelevs)
G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d)"),
- params->elev_map->key, params->elev_const->key, nelevs0,
- params->res_coarse->key, nconsts0);
+ params->elev_map->key, params->elev_const->key, nelevs,
+ params->res_coarse->key, nconsts);
- opt_get_num_answers(params->style, NULL, &nconsts0);
- if (nconsts0 > 0 && nconsts0 != nelevs0)
+ nconsts = opt_get_num_answers(params->style);
+ if (nconsts > 0 && nconsts != nelevs)
G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d)"),
- params->elev_map->key, params->elev_const->key, nelevs0,
- params->style->key, nconsts0);
+ params->elev_map->key, params->elev_const->key, nelevs,
+ params->style->key, nconsts);
- opt_get_num_answers(params->shade, NULL, &nconsts0);
- if (nconsts0 > 0 && nconsts0 != nelevs0)
+ nconsts = opt_get_num_answers(params->shade);
+ if (nconsts > 0 && nconsts != nelevs)
G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d)"),
- params->elev_map->key, params->elev_const->key, nelevs0,
- params->shade->key, nconsts0);
+ params->elev_map->key, params->elev_const->key, nelevs,
+ params->shade->key, nconsts);
- opt_get_num_answers(params->wire_color, NULL, &nconsts0);
- if (nconsts0 > 0 && nconsts0 != nelevs0)
+ nconsts = opt_get_num_answers(params->wire_color);
+ if (nconsts > 0 && nconsts != nelevs)
G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d)"),
- params->elev_map->key, params->elev_const->key, nelevs0,
- params->wire_color->key, nconsts0);
+ params->elev_map->key, params->elev_const->key, nelevs,
+ params->wire_color->key, nconsts);
}
/*
* vector
*/
- opt_get_num_answers(params->vector, &nvects, NULL);
+ nvects = opt_get_num_answers(params->vlines);
/* width */
- opt_get_num_answers(params->line_width, NULL, &nconsts0);
- if (nvects > 0 && nconsts0 != nvects)
+ nconsts = opt_get_num_answers(params->vline_width);
+ if (nvects > 0 && nconsts != nvects)
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
- params->vector->key, nvects,
- params->line_width->key, nconsts0);
+ params->vlines->key, nvects,
+ params->vline_width->key, nconsts);
/* color */
- opt_get_num_answers(params->line_color, NULL, &nconsts0);
- if (nvects > 0 && nconsts0 != nvects)
+ nconsts = opt_get_num_answers(params->vline_color);
+ if (nvects > 0 && nconsts != nvects)
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d"),
- params->vector->key, nvects,
- params->line_color->key, nconsts0);
+ params->vlines->key, nvects,
+ params->vline_color->key, nconsts);
/* mode */
- opt_get_num_answers(params->line_mode, NULL, &nconsts0);
- if (nvects > 0 && nconsts0 != nvects)
+ nconsts = opt_get_num_answers(params->vline_mode);
+ if (nvects > 0 && nconsts != nvects)
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
- params->vector->key, nvects,
- params->line_mode->key, nconsts0);
+ params->vlines->key, nvects,
+ params->vline_mode->key, nconsts);
/* height */
- opt_get_num_answers(params->line_height, NULL, &nconsts0);
- if (nvects > 0 && nconsts0 != nvects)
+ nconsts = opt_get_num_answers(params->vline_height);
+ if (nvects > 0 && nconsts != nvects)
G_fatal_error(_("Inconsistent number of attributes (<%s> %d: <%s> %d)"),
- params->vector->key, nvects,
- params->line_height->key, nconsts0);
+ params->vlines->key, nvects,
+ params->vline_height->key, nconsts);
return;
}
Modified: grass/trunk/visualization/nviz2/cmd/local_proto.h
===================================================================
--- grass/trunk/visualization/nviz2/cmd/local_proto.h 2008-07-21 22:29:53 UTC (rev 32199)
+++ grass/trunk/visualization/nviz2/cmd/local_proto.h 2008-07-21 22:52:43 UTC (rev 32200)
@@ -12,8 +12,10 @@
*emit_map, *emit_const,
/* draw */
*mode, *res_fine, *res_coarse, *style, *shade, *wire_color,
- /* vector */
- *vector, *line_width, *line_color, *line_mode, *line_height,
+ /* vector lines */
+ *vlines, *vline_width, *vline_color, *vline_mode, *vline_height,
+ /* vector points */
+ *vpoints, *vpoint_size, *vpoint_symbol, *vpoint_color,
/* misc */
*exag, *bgcolor,
/* viewpoint */
@@ -25,18 +27,21 @@
/* args.c */
void parse_command(int, char**, struct GParams *);
int color_from_cmd(const char *);
-void opt_get_num_answers(const struct Option *, int *, int *);
+int opt_get_num_answers(const struct Option *);
void check_parameters(const struct GParams *);
/* surface.c */
int load_rasters(const struct GParams *,
nv_data *);
-void set_draw_mode(const struct GParams *);
+void surface_set_draw_mode(const struct GParams *);
/* vector.c */
-int load_vectors(const struct GParams *,
- nv_data *);
-int set_lines_attrb(const struct GParams *);
+int load_vector_lines(const struct GParams *,
+ nv_data *);
+int load_vector_points(const struct GParams *,
+ nv_data *);
+int vlines_set_attrb(const struct GParams *);
+int vpoints_set_attrb(const struct GParams *);
/* write_img.c */
int write_img(const char *, int);
Modified: grass/trunk/visualization/nviz2/cmd/main.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/main.c 2008-07-21 22:29:53 UTC (rev 32199)
+++ grass/trunk/visualization/nviz2/cmd/main.c 2008-07-21 22:52:43 UTC (rev 32200)
@@ -2,10 +2,9 @@
*
* MODULE: nviz_cmd
*
- * AUTHOR(S): Martin Landa <landa.martin gmail.com>
+ * AUTHOR(S): Martin Landa <landa.martin gmail.com> (Google SoC 2008)
*
* PURPOSE: Experimental NVIZ CLI prototype
- * Google SoC 2008
*
* COPYRIGHT: (C) 2008 by the GRASS Development Team
*
@@ -73,7 +72,7 @@
Nviz_init_data(&data);
/* define default attributes for map objects */
- Nviz_set_attr_default();
+ Nviz_set_surface_attr_default();
/* set background color */
Nviz_set_bgcolor(&data, Nviz_color_from_str(params->bgcolor->answer));
@@ -102,13 +101,20 @@
/* load raster maps (surface topography) & set attributes (map/constant) */
load_rasters(params, &data);
/* set draw mode of loaded surfaces */
- set_draw_mode(params);
+ surface_set_draw_mode(params);
- /* load vector maps & set line mode */
- if (params->vector->answer) {
- load_vectors(params, &data);
+ /* load line vector maps */
+ if (params->vlines->answer) {
+ load_vector_lines(params, &data);
+ /* set attributes of 2d lines */
+ vlines_set_attrb(params);
+ }
+
+ /* load point vector maps */
+ if (params->vpoints->answer) {
+ load_vector_points(params, &data);
/* set attributes for 2d lines */
- set_lines_attrb(params);
+ vpoints_set_attrb(params);
}
/* focus on loaded data */
Modified: grass/trunk/visualization/nviz2/cmd/surface.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/surface.c 2008-07-21 22:29:53 UTC (rev 32199)
+++ grass/trunk/visualization/nviz2/cmd/surface.c 2008-07-21 22:52:43 UTC (rev 32200)
@@ -32,24 +32,24 @@
{
char *mapset;
int i;
- int nelevs, nelev_map0, nelev_const0, ncolor_map0, ncolor_const0, nmask_map0;
- int ntransp_map0, ntransp_const0, nshine_map0, nshine_const0;
- int nemit_map0, nemit_const0;
+ int nelevs, nelev_map, nelev_const, ncolor_map, ncolor_const, nmask_map;
+ int ntransp_map, ntransp_const, nshine_map, nshine_const;
+ int nemit_map, nemit_const;
int *surf_list, nsurfs;
int id;
- opt_get_num_answers(params->elev_map, NULL, &nelev_map0);
- opt_get_num_answers(params->elev_const, NULL, &nelev_const0);
+ nelev_map = opt_get_num_answers(params->elev_map);
+ nelev_const = opt_get_num_answers(params->elev_const);
- if (nelev_map0 > 0)
- nelevs = nelev_map0;
+ if (nelev_map > 0)
+ nelevs = nelev_map;
else
- nelevs = nelev_const0;
+ nelevs = nelev_const;
/* topography (required) */
for (i = 0; i < nelevs; i++) {
/* check maps */
- if (i < nelev_map0 && strcmp(params->elev_map->answers[i], "")) {
+ if (i < nelev_map && strcmp(params->elev_map->answers[i], "")) {
mapset = G_find_cell2 (params->elev_map->answers[i], "");
if (mapset == NULL) {
G_fatal_error(_("Raster map <%s> not found"),
@@ -61,7 +61,7 @@
data);
}
else {
- if (i < nelev_const0 && strcmp(params->elev_const->answers[i], "")) {
+ if (i < nelev_const && strcmp(params->elev_const->answers[i], "")) {
id = Nviz_new_map_obj(MAP_OBJ_SURF,
NULL, atof(params->elev_const->answers[i]),
data);
@@ -76,21 +76,21 @@
/* set surface attributes */
surf_list = GS_get_surf_list(&nsurfs);
- opt_get_num_answers(params->color_map, NULL, &ncolor_map0);
- opt_get_num_answers(params->color_const, NULL, &ncolor_const0);
- opt_get_num_answers(params->mask_map, NULL, &nmask_map0);
- opt_get_num_answers(params->transp_map, NULL, &ntransp_map0);
- opt_get_num_answers(params->transp_const, NULL, &ntransp_const0);
- opt_get_num_answers(params->shine_map, NULL, &nshine_map0);
- opt_get_num_answers(params->shine_const, NULL, &nshine_const0);
- opt_get_num_answers(params->emit_map, NULL, &nemit_map0);
- opt_get_num_answers(params->emit_const, NULL, &nemit_const0);
+ ncolor_map = opt_get_num_answers(params->color_map);
+ ncolor_const =opt_get_num_answers(params->color_const);
+ nmask_map = opt_get_num_answers(params->mask_map);
+ ntransp_map = opt_get_num_answers(params->transp_map);
+ ntransp_const = opt_get_num_answers(params->transp_const);
+ nshine_map = opt_get_num_answers(params->shine_map);
+ nshine_const = opt_get_num_answers(params->shine_const);
+ nemit_map = opt_get_num_answers(params->emit_map);
+ nemit_const = opt_get_num_answers(params->emit_const);
for (i = 0; i < nsurfs; i++) {
id = surf_list[i];
/* color */
/* check for color map */
- if (i < ncolor_map0 && strcmp(params->color_map->answers[i], "")) {
+ if (i < ncolor_map && strcmp(params->color_map->answers[i], "")) {
mapset = G_find_cell2 (params->color_map->answers[i], "");
if (mapset == NULL) {
G_fatal_error(_("Raster map <%s> not found"),
@@ -102,7 +102,7 @@
data);
}
/* check for color value */
- else if (i < ncolor_const0 && strcmp(params->color_const->answers[i], "")) {
+ else if (i < ncolor_const && strcmp(params->color_const->answers[i], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_COLOR, CONST_ATT,
NULL, Nviz_color_from_str(params->color_const->answers[i]),
data);
@@ -115,43 +115,43 @@
G_fully_qualified_name(params->elev_map->answers[i], mapset));
}
/* mask */
- if (i < nmask_map0 && strcmp(params->mask_map->answers[i], "")) {
+ if (i < nmask_map && strcmp(params->mask_map->answers[i], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_MASK, MAP_ATT,
G_fully_qualified_name(params->mask_map->answers[i], mapset), -1.0,
data);
}
/* transparency */
- if (i < ntransp_map0 && strcmp(params->transp_map->answers[i], "")) {
+ 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);
}
- else if (i < ntransp_const0 && strcmp(params->transp_const->answers[i], "")) {
+ else if (i < ntransp_const && strcmp(params->transp_const->answers[i], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_TRANSP, CONST_ATT,
NULL, atof(params->transp_const->answers[i]),
data);
}
/* shininess */
- if (i < nshine_map0 && strcmp(params->shine_map->answers[i], "")) {
+ 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);
}
- else if (i < nshine_const0 && strcmp(params->shine_const->answers[i], "")) {
+ else if (i < nshine_const && strcmp(params->shine_const->answers[i], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_SHINE, CONST_ATT,
NULL, atof(params->shine_const->answers[i]),
data);
}
/* emission */
- if (i < nemit_map0 && strcmp(params->emit_map->answers[i], "")) {
+ if (i < nemit_map && strcmp(params->emit_map->answers[i], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_EMIT, MAP_ATT,
G_fully_qualified_name(params->emit_map->answers[i], mapset), -1.0,
data);
}
- else if (i < nemit_const0 && strcmp(params->emit_const->answers[i], "")) {
+ else if (i < nemit_const && strcmp(params->emit_const->answers[i], "")) {
Nviz_set_attr(id, MAP_OBJ_SURF, ATT_EMIT, CONST_ATT,
NULL, atof(params->emit_const->answers[i]),
data);
@@ -171,7 +171,7 @@
\param params module parameters
*/
-void set_draw_mode(const struct GParams *params)
+void surface_set_draw_mode(const struct GParams *params)
{
int *surf_list, nsurfs;
int i, id, draw_mode;
Modified: grass/trunk/visualization/nviz2/cmd/vector.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/vector.c 2008-07-21 22:29:53 UTC (rev 32199)
+++ grass/trunk/visualization/nviz2/cmd/vector.c 2008-07-21 22:52:43 UTC (rev 32200)
@@ -21,23 +21,49 @@
#include "local_proto.h"
+static int load_vectors(const struct Option *, const struct Option *,
+ const struct Option *, int, nv_data *);
+
/*!
- \brief Load vector maps and set attributes
+ \brief Load vector maps (lines)
\param params module parameters
\param data nviz data
\return number of loaded vectors
*/
-int load_vectors(const struct GParams *params,
- nv_data *data)
+int load_vector_lines(const struct GParams *params,
+ nv_data *data)
{
+ return load_vectors(params->elev_map, params->elev_const,
+ params->vlines, MAP_OBJ_VECT, data);
+}
+
+/*!
+ \brief Load vector maps (points)
+
+ \param params module parameters
+ \param data nviz data
+
+ \return number of loaded vectors
+*/
+int load_vector_points(const struct GParams *params,
+ nv_data *data)
+{
+ return load_vectors(params->elev_map, params->elev_const,
+ params->vpoints, MAP_OBJ_SITE, data);
+}
+
+int load_vectors(const struct Option *elev_map, const struct Option *elev_const,
+ const struct Option *vect, int map_obj_type, nv_data *data)
+{
int i;
int nvects;
char *mapset;
- if (!params->elev_map->answer && GS_num_surfs() == 0) { /* load base surface if no loaded */
+ 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);
@@ -48,14 +74,14 @@
nvects = 0;
- for (i = 0; params->vector->answers[i]; i++) {
- mapset = G_find_vector2 (params->vector->answers[i], "");
+ 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"),
- params->vector->answers[i]);
+ G_fatal_error(_("Vector map <%s> not found"),
+ vect->answers[i]);
}
- Nviz_new_map_obj(MAP_OBJ_VECT,
- G_fully_qualified_name(params->vector->answers[i], mapset), 0.0,
+ Nviz_new_map_obj(map_obj_type,
+ G_fully_qualified_name(vect->answers[i], mapset), 0.0,
data);
nvects++;
@@ -65,14 +91,14 @@
}
/*!
- \brief Set vector mode
+ \brief Set vector lines mode
\param params parameters
\return 1 on success
\return 0 on failure
*/
-int set_lines_attrb(const struct GParams *params)
+int vlines_set_attrb(const struct GParams *params)
{
int i, color, width, flat, height;
int *vect_list, nvects;
@@ -81,9 +107,9 @@
for(i = 0; i < nvects; i++) {
/* mode -- use memory by default */
- color = Nviz_color_from_str(params->line_color->answers[i]);
- width = atoi(params->line_width->answers[i]);
- if (strcmp(params->line_mode->answers[i], "flat") == 0)
+ 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;
@@ -91,10 +117,23 @@
return 0;
/* height */
- height = atoi(params->line_height->answers[i]);
+ height = atoi(params->vline_height->answers[i]);
if (height > 0)
GV_set_trans(vect_list[i], 0.0, 0.0, height);
}
return 1;
}
+
+/*!
+ \brief Set vector points mode
+
+ \param params parameters
+
+ \return 1 on success
+ \return 0 on failure
+*/
+int vpoints_set_attrb(const struct GParams *params)
+{
+ return 1;
+}
More information about the grass-commit
mailing list