[GRASS-SVN] r32206 - in grass/trunk: gui/wxpython/gui_modules
gui/wxpython/nviz include lib/nviz visualization/nviz2/cmd
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 22 06:40:27 EDT 2008
Author: martinl
Date: 2008-07-22 06:40:15 -0400 (Tue, 22 Jul 2008)
New Revision: 32206
Modified:
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/nviz/init.cpp
grass/trunk/include/nviz.h
grass/trunk/lib/nviz/draw.c
grass/trunk/lib/nviz/map_obj.c
grass/trunk/lib/nviz/nvizlib.dox
grass/trunk/visualization/nviz2/cmd/args.c
grass/trunk/visualization/nviz2/cmd/local_proto.h
grass/trunk/visualization/nviz2/cmd/vector.c
Log:
nviz2: support for 2d vector points added (drawing points)
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-07-22 09:59:39 UTC (rev 32205)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-07-22 10:40:15 UTC (rev 32206)
@@ -106,8 +106,7 @@
if Debug.get_level() == 0:
# don't redirect when debugging is enabled
# sys.stderr = self.cmd_stderr
- pass
-
+
return True
return False
Modified: grass/trunk/gui/wxpython/nviz/init.cpp
===================================================================
--- grass/trunk/gui/wxpython/nviz/init.cpp 2008-07-22 09:59:39 UTC (rev 32205)
+++ grass/trunk/gui/wxpython/nviz/init.cpp 2008-07-22 10:40:15 UTC (rev 32206)
@@ -75,7 +75,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("white")); /* TODO */
Modified: grass/trunk/include/nviz.h
===================================================================
--- grass/trunk/include/nviz.h 2008-07-22 09:59:39 UTC (rev 32205)
+++ grass/trunk/include/nviz.h 2008-07-22 10:40:15 UTC (rev 32206)
@@ -148,6 +148,8 @@
/* draw.c */
int Nviz_draw_all_surf(nv_data *);
int Nviz_draw_all_vect(nv_data *);
+int Nviz_draw_all_site(nv_data *);
+int Nviz_draw_all_vol(nv_data *);
int Nviz_draw_all(nv_data *);
int Nviz_draw_quick(nv_data *);
@@ -172,6 +174,7 @@
int Nviz_set_attr(int, int, int, int, const char *, float,
nv_data *);
void Nviz_set_surface_attr_default();
+int Nviz_set_vpoint_attr_default();
int Nviz_unset_attr(int, int, int);
/* nviz.c */
Modified: grass/trunk/lib/nviz/draw.c
===================================================================
--- grass/trunk/lib/nviz/draw.c 2008-07-22 09:59:39 UTC (rev 32205)
+++ grass/trunk/lib/nviz/draw.c 2008-07-22 10:40:15 UTC (rev 32206)
@@ -113,7 +113,7 @@
}
/*!
- \brief Draw all loaded vector sets
+ \brief Draw all loaded vector sets (lines)
\param dc nviz data
@@ -140,6 +140,51 @@
}
/*!
+ \brief Draw all loaded vector point sets
+
+ \param dc nviz data
+
+ \return 1
+*/
+int Nviz_draw_all_site(nv_data *dc)
+{
+ int i;
+ int *site_list, nsites;
+
+ site_list = GP_get_site_list(&nsites);
+
+ /* in case transparency is set */
+ GS_set_draw(GSD_BOTH);
+
+ GS_ready_draw();
+
+ for (i = 0; i < nsites; i++) {
+ GP_draw_site(site_list[i]);
+ }
+ G_free (site_list);
+
+ GS_done_draw();
+
+ GS_set_draw(GSD_BACK);
+
+ return 1;
+}
+
+/*!
+ \brief Draw all loaded volume sets
+
+ \todo To be implement
+
+ \param dc nviz data
+
+ \return 1
+*/
+int Nviz_draw_all_vol(nv_data *dc)
+{
+ return 1;
+}
+
+/*!
\brief Draw all map objects (in full resolution) and decorations
\param data nviz data
@@ -149,12 +194,10 @@
int draw_surf, draw_vect, draw_site, draw_vol;
int draw_north_arrow, arrow_x, draw_label, draw_legend;
int draw_fringe, draw_scalebar, draw_bar_x;
- // const char* draw_is_drawing = Tcl_GetVar(interp, "is_drawing", TCL_GLOBAL_ONLY);
- // const char* EMPTYSTRING = "";
draw_surf = 1;
draw_vect = 1;
- draw_site = 0;
+ draw_site = 1;
draw_vol = 0;
draw_north_arrow = 0;
arrow_x = 0;
@@ -164,147 +207,27 @@
draw_scalebar = 0;
draw_bar_x = 0;
- /*
- if (buf_is_drawing && atoi(buf_is_drawing))
- return (TCL_OK);
- */
-
- // Tcl_SetVar(interp, "is_drawing", "1", TCL_GLOBAL_ONLY);
-
GS_set_draw(GSD_BACK); /* needs to be BACK to avoid flickering */
GS_ready_draw();
GS_clear(data->bgcolor);
-/*
- buf_surf = Tcl_GetVar(interp, "surface", TCL_GLOBAL_ONLY);
- buf_vect = Tcl_GetVar(interp, "vector", TCL_GLOBAL_ONLY);
- buf_site = Tcl_GetVar(interp, "sites", TCL_GLOBAL_ONLY);
- buf_vol = Tcl_GetVar(interp, "volume", TCL_GLOBAL_ONLY);
- buf_north_arrow = Tcl_GetVar(interp, "n_arrow", TCL_GLOBAL_ONLY);
- arrow_x = Tcl_GetVar(interp, "n_arrow_x", TCL_GLOBAL_ONLY);
- buf_label = Tcl_GetVar(interp, "labels", TCL_GLOBAL_ONLY);
- buf_legend = Tcl_GetVar(interp, "legend", TCL_GLOBAL_ONLY);
- buf_fringe = Tcl_GetVar(interp, "fringe", TCL_GLOBAL_ONLY);
- buf_scalebar = Tcl_GetVar(interp, "scalebar", TCL_GLOBAL_ONLY);
- bar_x = Tcl_GetVar(interp, "scalebar_x", TCL_GLOBAL_ONLY);
-*/
if (draw_surf)
Nviz_draw_all_surf(data);
if (draw_vect)
- Nviz_draw_all_vect (data);
+ Nviz_draw_all_vect(data);
- /*
if (draw_site)
- site_draw_all_together(data, interp);
+ Nviz_draw_all_site(data);
if (draw_vol)
- vol_draw_all_cmd(data, interp, argc, argv);
- */
+ Nviz_draw_all_vol(data);
+
GS_done_draw();
GS_set_draw(GSD_BACK);
- /*
- if (!draw_north_arrow)
- draw_north_arrow = EMPTYSTRING;
-
- if (!arrow_x)
- arrow_x = EMPTYSTRING;
-
- if (!draw_scalebar)
- draw_scalebar = EMPTYSTRING;
-
- if (!draw_bar_x)
- bar_x = EMPTYSTRING;
-
- if (!draw_fringe)
- draw_fringe = EMPTYSTRING;
-
- if (!draw_label)
- draw_label = EMPTYSTRING;
-
- if (!draw_legend)
- draw_legend = EMPTYSTRING;
- */
- /* Draw decorations */
-
- /* North Arrow
- if (atoi(draw_north_arrow) == 1 && atoi(arrow_x) != 999 ) {
- const char *arrow_y, *arrow_z, *arrow_len;
- float coords[3], len;
- int arrow_clr, text_clr;
-
- arrow_y = Tcl_GetVar(interp, "n_arrow_y", TCL_GLOBAL_ONLY);
- arrow_z = Tcl_GetVar(interp, "n_arrow_z", TCL_GLOBAL_ONLY);
- arrow_len = Tcl_GetVar(interp, "n_arrow_size", TCL_GLOBAL_ONLY);
- arrow_clr = (int) tcl_color_to_int(Tcl_GetVar(interp, "arw_clr", TCL_GLOBAL_ONLY));
- text_clr = (int) tcl_color_to_int(Tcl_GetVar(interp, "arw_text_clr", TCL_GLOBAL_ONLY));
- coords[0] = atoi(arrow_x);
- coords[1] = atoi(arrow_y);
- coords[2] = atoi(arrow_z);
- len = atof(arrow_len);
-
- FontBase = load_font(TOGL_BITMAP_HELVETICA_18);
- gsd_north_arrow(coords, len, FontBase, arrow_clr, text_clr);
- }
- */
-
- /* Scale Bar
- if (atoi(draw_scalebar) == 1 && atoi(bar_x) != 999 ) {
- const char *bar_y, *bar_z, *bar_len;
- float coords[3], len;
- int bar_clr, text_clr;
-
- bar_y = Tcl_GetVar(interp, "scalebar_y", TCL_GLOBAL_ONLY);
- bar_z = Tcl_GetVar(interp, "scalebar_z", TCL_GLOBAL_ONLY);
- bar_len = Tcl_GetVar(interp, "scalebar_size", TCL_GLOBAL_ONLY);
- bar_clr = (int) tcl_color_to_int(Tcl_GetVar(interp, "bar_clr", TCL_GLOBAL_ONLY));
- text_clr = (int) tcl_color_to_int(Tcl_GetVar(interp, "bar_text_clr", TCL_GLOBAL_ONLY));
- coords[0] = atoi(bar_x);
- coords[1] = atoi(bar_y);
- coords[2] = atoi(bar_z);
- len = atof(bar_len);
-
- FontBase = load_font(TOGL_BITMAP_HELVETICA_18);
- gsd_scalebar(coords, len, FontBase, bar_clr, bar_clr);
- }
- */
-
- /* fringe
- if (atoi(draw_fringe) == 1) {
- const char *fringe_ne, *fringe_nw, *fringe_se, *fringe_sw;
- const char *surf_id;
- int flags[4], id;
- int fringe_clr;
- float fringe_elev;
-
- fringe_clr = (int) tcl_color_to_int(Tcl_GetVar(interp, "fringe_color", TCL_GLOBAL_ONLY));
- fringe_elev = (float) atof(Tcl_GetVar(interp, "fringe_elev", TCL_GLOBAL_ONLY));
- fringe_ne = Tcl_GetVar(interp, "fringe_ne", TCL_GLOBAL_ONLY);
- fringe_nw = Tcl_GetVar(interp, "fringe_nw", TCL_GLOBAL_ONLY);
- fringe_se = Tcl_GetVar(interp, "fringe_se", TCL_GLOBAL_ONLY);
- fringe_sw = Tcl_GetVar(interp, "fringe_sw", TCL_GLOBAL_ONLY);
- flags[0] = atoi(fringe_nw);
- flags[1] = atoi(fringe_ne);
- flags[2] = atoi(fringe_sw);
- flags[3] = atoi(fringe_se);
- surf_id = Tcl_GetVar2(interp, "Nv_", "CurrSurf", TCL_GLOBAL_ONLY);
- id = atoi(surf_id);
-
- GS_draw_fringe(id, fringe_clr, fringe_elev, flags);
- }
- */
-
- /* Legend and/or labels
- if (atoi(draw_label) == 1 || atoi(draw_legend) == 1)
- GS_draw_all_list();
- */
-
- // Tcl_SetVar(interp, "is_drawing", "0", TCL_GLOBAL_ONLY);
- // flythrough_postdraw_cb();
-
return 1;
}
Modified: grass/trunk/lib/nviz/map_obj.c
===================================================================
--- grass/trunk/lib/nviz/map_obj.c 2008-07-22 09:59:39 UTC (rev 32205)
+++ grass/trunk/lib/nviz/map_obj.c 2008-07-22 10:40:15 UTC (rev 32206)
@@ -118,7 +118,6 @@
}
/* vector points overlay */
else if (type == MAP_OBJ_SITE) {
- geosite * gp;
if (GP_num_sites() >= MAX_SITES) {
G_warning (_("Maximum vector point maps loaded!"));
return -1;
@@ -127,13 +126,8 @@
new_id = GP_new_site();
/* initizalize site attributes */
- /* TODO: move to ogsflib */
- gp = gp_get_site(new_id);
+ Nviz_set_vpoint_attr_default(new_id);
- for (i = 0; i < GPT_MAX_ATTR; i++)
- gp->use_attr[i] = ST_ATT_NONE;
-
-
/* load vector points */
if (0 > GP_load_site(new_id, name)) {
GP_delete_site(new_id);
@@ -308,6 +302,30 @@
}
/*!
+ \brief Set default vector point attributes
+
+ \param id vector point set id
+
+ \return 1 on success
+ \return 0 on failure
+*/
+int Nviz_set_vpoint_attr_default(int id)
+{
+ int i;
+ geosite * gp;
+
+ gp = gp_get_site(id);
+
+ if (!gp)
+ return 0;
+
+ for (i = 0; i < GPT_MAX_ATTR; i++)
+ gp->use_attr[i] = ST_ATT_NONE;
+
+ return 1;
+}
+
+/*!
Unset map object attribute
\param id map object id
Modified: grass/trunk/lib/nviz/nvizlib.dox
===================================================================
--- grass/trunk/lib/nviz/nvizlib.dox 2008-07-22 09:59:39 UTC (rev 32205)
+++ grass/trunk/lib/nviz/nvizlib.dox 2008-07-22 10:40:15 UTC (rev 32206)
@@ -59,7 +59,7 @@
- Nviz_set_attr()
- - Nviz_set_attr_default()
+ - Nviz_set_surface_attr_default()
- Nviz_unset_attr()
Modified: grass/trunk/visualization/nviz2/cmd/args.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/args.c 2008-07-22 09:59:39 UTC (rev 32205)
+++ grass/trunk/visualization/nviz2/cmd/args.c 2008-07-22 10:40:15 UTC (rev 32206)
@@ -365,6 +365,18 @@
params->vpoint_size->options = "1-1000";
params->vpoint_size->answer = "100";
+ /* point width */
+ params->vpoint_width = G_define_option();
+ params->vpoint_width->key = "vpoint_width";
+ params->vpoint_width->key_desc = "value";
+ params->vpoint_width->type = TYPE_INTEGER;
+ params->vpoint_width->required = NO;
+ params->vpoint_width->multiple = YES;
+ params->vpoint_width->description = _("Icon width");
+ params->vpoint_width->guisection = _("Vector points");
+ params->vpoint_width->options = "1-1000";
+ params->vpoint_width->answer = "2";
+
/* point color */
params->vpoint_color = G_define_standard_option(G_OPT_C_FG);
params->vpoint_color->multiple = YES;
@@ -375,16 +387,16 @@
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");
+ params->vpoint_marker = G_define_option();
+ params->vpoint_marker->key = "vpoint_marker";
+ params->vpoint_marker->key_desc = "string";
+ params->vpoint_marker->type = TYPE_STRING;
+ params->vpoint_marker->required = YES;
+ params->vpoint_marker->multiple = YES;
+ params->vpoint_marker->description = _("Icon marker");
+ params->vpoint_marker->options = "x,sphere,diamond,cube,box,gyro,aster,histogram";
+ params->vpoint_marker->answer = "sphere";
+ params->vpoint_marker->guisection = _("Vector points");
return;
}
Modified: grass/trunk/visualization/nviz2/cmd/local_proto.h
===================================================================
--- grass/trunk/visualization/nviz2/cmd/local_proto.h 2008-07-22 09:59:39 UTC (rev 32205)
+++ grass/trunk/visualization/nviz2/cmd/local_proto.h 2008-07-22 10:40:15 UTC (rev 32206)
@@ -15,7 +15,7 @@
/* vector lines */
*vlines, *vline_width, *vline_color, *vline_mode, *vline_height,
/* vector points */
- *vpoints, *vpoint_size, *vpoint_symbol, *vpoint_color,
+ *vpoints, *vpoint_size, *vpoint_marker, *vpoint_color, *vpoint_width,
/* misc */
*exag, *bgcolor,
/* viewpoint */
Modified: grass/trunk/visualization/nviz2/cmd/vector.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/vector.c 2008-07-22 09:59:39 UTC (rev 32205)
+++ grass/trunk/visualization/nviz2/cmd/vector.c 2008-07-22 10:40:15 UTC (rev 32206)
@@ -135,5 +135,42 @@
*/
int vpoints_set_attrb(const struct GParams *params)
{
+ int i;
+ int *site_list, nsites;
+ int marker, color, width;
+ float size;
+ char *marker_str;
+
+ site_list = GP_get_site_list(&nsites);
+
+ for(i = 0; i < nsites; i++) {
+ color = Nviz_color_from_str(params->vpoint_color->answers[i]);
+ size = atof(params->vpoint_size->answers[i]);
+ width = atoi(params->vpoint_width->answers[i]);
+ marker_str = params->vpoint_marker->answers[i];
+
+ if (strcmp(marker_str, "x") == 0)
+ marker = ST_X;
+ else if (strcmp(marker_str, "sphere") == 0)
+ marker = ST_SPHERE;
+ else if (strcmp(marker_str, "diamond") == 0)
+ marker = ST_DIAMOND;
+ else if (strcmp(marker_str, "cube") == 0)
+ marker = ST_CUBE;
+ else if (strcmp(marker_str, "box") == 0)
+ marker = ST_BOX;
+ else if (strcmp(marker_str, "gyro") == 0)
+ marker = ST_GYRO;
+ else if (strcmp(marker_str, "aster") == 0)
+ marker = ST_ASTER;
+ else if (strcmp(marker_str, "histogram") == 0)
+ marker = ST_HISTOGRAM;
+ else
+ G_fatal_error(_("Unknow icon marker"));
+
+ GP_set_sitemode(site_list[i], ST_ATT_NONE,
+ color, width, size, marker);
+ }
+
return 1;
}
More information about the grass-commit
mailing list