[GRASS-SVN] r39323 - in grass/trunk: gui/wxpython/nviz include
lib/nviz lib/ogsf visualization/nviz2/cmd
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 29 04:37:07 EDT 2009
Author: marisn
Date: 2009-09-29 04:37:06 -0400 (Tue, 29 Sep 2009)
New Revision: 39323
Modified:
grass/trunk/gui/wxpython/nviz/vector.cpp
grass/trunk/include/gstypes.h
grass/trunk/include/gsurf.h
grass/trunk/include/ogsf_proto.h
grass/trunk/lib/nviz/map_obj.c
grass/trunk/lib/ogsf/GP2.c
grass/trunk/lib/ogsf/GS2.c
grass/trunk/lib/ogsf/GV2.c
grass/trunk/lib/ogsf/GVL2.c
grass/trunk/lib/ogsf/Gp3.c
grass/trunk/lib/ogsf/Gv3.c
grass/trunk/lib/ogsf/gp.c
grass/trunk/lib/ogsf/gpd.c
grass/trunk/lib/ogsf/gsd_objs.c
grass/trunk/lib/ogsf/gv.c
grass/trunk/lib/ogsf/gvd.c
grass/trunk/lib/ogsf/gvl.c
grass/trunk/lib/ogsf/gvl_calc.c
grass/trunk/visualization/nviz2/cmd/vector.c
Log:
Move OGSF to new vector feature styling approach
Modified: grass/trunk/gui/wxpython/nviz/vector.cpp
===================================================================
--- grass/trunk/gui/wxpython/nviz/vector.cpp 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/gui/wxpython/nviz/vector.cpp 2009-09-29 08:37:06 UTC (rev 39323)
@@ -119,8 +119,7 @@
color = Nviz_color_from_str(color_str);
- if (GP_set_sitemode(id, ST_ATT_NONE,
- color, width, size, marker) < 0)
+ if (GP_set_style(id, color, width, size, marker) < 0)
return -2;
return 1;
Modified: grass/trunk/include/gstypes.h
===================================================================
--- grass/trunk/include/gstypes.h 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/include/gstypes.h 2009-09-29 08:37:06 UTC (rev 39323)
@@ -162,6 +162,22 @@
vector file to have multiple attributes ? Cached lines should
usually be stored as 2d, since they may be draped on multiple
surfaces & Z will vary depending upon surface. */
+
+/* Struct for vector feature displaying attributes */
+typedef struct g_vect_style
+{
+ int color; /* Line color */
+ int symbol; /* Point symbol/line type */
+ float size; /* Symbol size. Unset for lines. */
+ int width; /* Line width. Also used for lines forming symbols i.e. X */
+ /*TODO:fill; Area fill pattern */
+ /*TODO:falpha; Area fill transparency */
+ /*TODO:lalpha; Line/boundary/point transparency */
+ /*TODO:struct *orientation; Symbol orientation */
+ struct g_vect_style *next; /* Point to next gvstyle struct if single point has multiple styles. In such case feature with next style should be shifted. */
+} gvstyle;
+
+/* Line instance */
typedef struct g_line
{
int type;
@@ -169,9 +185,15 @@
int dims, npts;
Point3 *p3;
Point2 *p2;
+
+ struct line_cats *cats; /* Store information about all layers/cats for thematic display */
+ gvstyle *style; /* Line instance look&feel */
+ signed char highlighted; /* >0 Feature is highlighted */
+
struct g_line *next;
} geoline;
+/* Vector line layer */
typedef struct g_vect
{
int gvect_id;
@@ -179,7 +201,6 @@
int drape_surf_id[MAX_SURFS]; /* if you want 'em flat, define the surface */
int flat_val;
int n_surfs;
- int color, width;
char *filename;
float x_trans, y_trans, z_trans;
/* also maybe center & rotate? */
@@ -188,59 +209,47 @@
int (*bgn_read) (), (*end_read) (), (*nxt_line) ();
struct g_vect *next;
void *clientdata;
+
+ int thematic_layer; /* Layer number to use for thematic mapping. <0 == no thematic mapping;
+ 0 == thematic mapping is unset but initialized;
+ >0 use specified layer */
+ gvstyle *style; /* Vector default look&feel */
+ gvstyle *hstyle; /* IMHO highlight should be per layer basis. */
} geovect;
-/* ACS_MODIFY one line site_attr ********************************************** */
-#define GPT_MAX_ATTR 8
-
+/* Point instance */
typedef struct g_point
{
int dims;
Point3 p3;
- float fattr; /* may want to make these pointers or arrays for mult atts */
- int iattr;
- char *cattr;
+
+ struct line_cats *cats; /* Store information about all layers/cats for thematic display */
+ gvstyle *style;
+ signed char highlighted; /* >0 Feature is highlighted */
- /* ACS_MODIFY_BEGIN site_attr ************************************************* */
- int cat;
- int color[GPT_MAX_ATTR];
- float size[GPT_MAX_ATTR];
- int marker[GPT_MAX_ATTR];
- /* ACS_MODIFY_END site_attr *************************************************** */
-
- /* ACS_MODIFY_BEGIN highlight ************************************************* */
- int highlight_color;
- int highlight_size;
- int highlight_marker;
-
- int highlight_color_value;
- float highlight_size_value;
- int highlight_marker_value;
- /* ACS_MODIFY_END highlight *************************************************** */
-
struct g_point *next;
} geopoint;
+/* Point layer */
typedef struct g_site
{
int gsite_id;
int drape_surf_id[MAX_SURFS]; /* ditto */
int n_surfs, n_sites;
- int color, width, marker, use_z, use_mem;
- int has_z, has_att; /* set when file loaded */
- int attr_mode; /* ST_ATT_COLOR, ST_ATT_MARKER, ST_ATT_SIZE, ST_ATT_NONE */
+ int use_z, use_mem;
+ int has_z; /* set when file loaded */
- /* ACS_MODIFY OneLine site_attr *********************************************** */
- int use_attr[GPT_MAX_ATTR]; /* ST_ATT_COLOR, ST_ATT_MARKER, ST_ATT_SIZE, ST_ATT_NONE, for multiple attr's */
-
char *filename;
transform attr_trans;
- float size;
float x_trans, y_trans, z_trans;
geopoint *points;
int (*bgn_read) (), (*end_read) (), (*nxt_site) ();
struct g_site *next;
void *clientdata;
+
+ int thematic_layer; /* Layer number to use for thematic mapping. */
+ gvstyle *style; /* Vector default look&feel */
+ gvstyle *hstyle; /* IMHO highlight should be per layer basis. */
} geosite;
typedef struct
Modified: grass/trunk/include/gsurf.h
===================================================================
--- grass/trunk/include/gsurf.h 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/include/gsurf.h 2009-09-29 08:37:06 UTC (rev 39323)
@@ -86,16 +86,8 @@
#define ST_CON_TREE 7
#define ST_ASTER 8
#define ST_GYRO 9
-/* ACS_MODIFY_One Line site_attr management ************************************** */
#define ST_HISTOGRAM 10
-/* site attribute modes (what attribute of marker category is used for) */
-/* TODO: may want to make these OR'able */
-#define ST_ATT_NONE 0x00000000
-#define ST_ATT_COLOR 0x00000001
-#define ST_ATT_SIZE 0x00000002
-#define ST_ATT_MARKER 0x00000004
-
/* Buffer modes */
#define GSD_FRONT 1
#define GSD_BACK 2
Modified: grass/trunk/include/ogsf_proto.h
===================================================================
--- grass/trunk/include/ogsf_proto.h 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/include/ogsf_proto.h 2009-09-29 08:37:06 UTC (rev 39323)
@@ -61,8 +61,8 @@
int GP_delete_site(int);
int GP_load_site(int, const char *);
int GP_get_sitename(int, char **);
-int GP_get_sitemode(int, int *, int *, int *, float *, int *);
-int GP_set_sitemode(int, int, int, int, float, int);
+int GP_get_style(int, int *, int *, float *, int *);
+int GP_set_style(int, int, int, float, int);
int GP_attmode_color(int, const char *);
int GP_attmode_none(int);
int GP_set_zmode(int, int);
@@ -306,7 +306,7 @@
/* From Gp3.c */
int Gp_set_color(const char *, geopoint *);
-geopoint *Gp_load_sites(const char *, int *, int *, int *);
+geopoint *Gp_load_sites(const char *, int *, int *);
/* From Gs3.c */
double Gs_distance(double *, double *);
@@ -369,7 +369,7 @@
/* From gpd.c */
int gs_point_in_region(geosurf *, float *, float *);
-void gpd_obj(geosurf *, int, float, int, Point3);
+void gpd_obj(geosurf *, gvstyle *, Point3);
int gpd_2dsite(geosite *, geosurf *, int);
int gpd_3dsite(geosite *, float, float, int);
Modified: grass/trunk/lib/nviz/map_obj.c
===================================================================
--- grass/trunk/lib/nviz/map_obj.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/nviz/map_obj.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -136,7 +136,7 @@
}
/* initialize display parameters */
- GP_set_sitemode(new_id, ST_ATT_NONE, 0xFF0000, 2, 100, ST_X);
+ GP_set_style(new_id, 0xFF0000, 2, 100, ST_X);
surf_list = GS_get_surf_list(&num_surfs);
for (i = 0; i < num_surfs; i++) {
GP_select_surf(new_id, surf_list[i]);
@@ -340,9 +340,6 @@
if (!gp)
return 0;
- for (i = 0; i < GPT_MAX_ATTR; i++)
- gp->use_attr[i] = ST_ATT_NONE;
-
return 1;
}
Modified: grass/trunk/lib/ogsf/GP2.c
===================================================================
--- grass/trunk/lib/ogsf/GP2.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/GP2.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -39,6 +39,8 @@
{
int i, found = 0;
+ G_debug(4, "GP_site_exists(%d)", id);
+
if (NULL == gp_get_site(id)) {
return (0);
}
@@ -132,7 +134,7 @@
{
int i, j, found = 0;
- G_debug(3, "GP_delete_site(): id=%d", id);
+ G_debug(4, "GP_delete_site(%d)", id);
if (GP_site_exists(id)) {
gp_delete_site(id);
@@ -174,6 +176,8 @@
{
geosite *gp;
+ G_debug(3, "GP_load_site(%d, %s)", id, filename);
+
if (NULL == (gp = gp_get_site(id))) {
return (-1);
}
@@ -184,8 +188,7 @@
gp->filename = G_store(filename);
- gp->points = Gp_load_sites(filename, &(gp->n_sites),
- &(gp->has_z), &(gp->has_att));
+ gp->points = Gp_load_sites(filename, &(gp->n_sites), &(gp->has_z));
if (gp->points) {
return (1);
@@ -209,6 +212,8 @@
{
geosite *gp;
+ G_debug(4, "GP_get_sitename(%d)", id);
+
if (NULL == (gp = gp_get_site(id))) {
return (-1);
}
@@ -219,106 +224,57 @@
}
/*!
- \brief Get point set mode
+ \brief Get point set style
+
+ \param id point set id
+
+ \return -1 on error (point set not found)
*/
-int GP_get_sitemode(int id, int *atmod, int *color, int *width, float *size,
- int *marker)
+int GP_get_style(int id, int *color, int *width, float *size, int *symbol)
{
geosite *gp;
+ G_debug(4, "GP_get_style(%d)", id);
+
if (NULL == (gp = gp_get_site(id))) {
return (-1);
}
- *atmod = gp->attr_mode;
- *color = gp->color;
- *width = gp->width;
- *marker = gp->marker;
- *size = gp->size;
+ *color = gp->style->color;
+ *width = gp->style->width;
+ *symbol = gp->style->symbol;
+ *size = gp->style->size;
return (1);
}
/*!
- \brief Set point set mode
+ \brief Set point set style
\param id point set id
- \param atmod
\param color icon color
\param width icon line width
\param size icon size
- \param marker icon symbol
+ \param symbol icon symbol
\return -1 on error (point set not found)
*/
-int GP_set_sitemode(int id, int atmod, int color, int width, float size,
- int marker)
+int GP_set_style(int id, int color, int width, float size, int symbol)
{
geosite *gp;
- if (NULL == (gp = gp_get_site(id))) {
- return (-1);
- }
+ G_debug(4, "GP_set_style(%d, %d, %d, %f, %d)", id, color, width, size,
+ symbol);
- gp->attr_mode = atmod; /* FIX this - probably should be seperate */
- gp->color = color;
- gp->width = width;
- gp->marker = marker;
- gp->size = size;
-
- return (1);
-}
-
-/*!
- \brief Set attribute mode color
-
- \todo make similar routines for attmode_size, attmode_marker (use transform)
-
- \param id surface id
- \param filename filename
-
- \return 1 for success
- \return 0 for no attribute info
- \return -1 for bad parameter
- */
-int GP_attmode_color(int id, const char *filename)
-{
- geosite *gp;
-
if (NULL == (gp = gp_get_site(id))) {
return (-1);
}
- if (!gp->has_att) {
- return (0);
- }
+ gp->style->color = color;
+ gp->style->symbol = symbol;
+ gp->style->size = size;
+ gp->style->width = width;
- if (Gp_set_color(filename, gp->points)) {
- gp->attr_mode = ST_ATT_COLOR;
- return (1);
- }
-
- return (-1);
-}
-
-/*!
- \brief Set attribute mode to none
-
- \param id point set id
-
- \return -1 on error (invalid point set id)
- \return 1 on success
- */
-int GP_attmode_none(int id)
-{
- geosite *gp;
-
- if (NULL == (gp = gp_get_site(id))) {
- return (-1);
- }
-
- gp->attr_mode = ST_ATT_NONE;
-
return (1);
}
@@ -332,10 +288,13 @@
\return 0 no z
\return -1 on error (invalid point set id)
*/
+/* I don't see who is using it? Why it's required? */
int GP_set_zmode(int id, int use_z)
{
geosite *gp;
+ G_debug(3, "GP_set_zmode(%d,%d)", id, use_z);
+
if (NULL == (gp = gp_get_site(id))) {
return (-1);
}
@@ -362,10 +321,13 @@
\return -1 on error (invalid point set id)
\return 1 on success
*/
+/* Who's using this? */
int GP_get_zmode(int id, int *use_z)
{
geosite *gp;
+ G_debug(4, "GP_get_zmode(%d)", id);
+
if (NULL == (gp = gp_get_site(id))) {
return (-1);
}
@@ -434,6 +396,8 @@
{
geosite *gp;
+ G_debug(3, "GP_select_surf(%d,%d)", hp, hs);
+
if (GP_surf_is_selected(hp, hs)) {
return (1);
}
@@ -463,6 +427,8 @@
geosite *gp;
int i, j;
+ G_debug(3, "GP_unselect_surf(%d,%d)", hp, hs);
+
if (!GP_surf_is_selected(hp, hs)) {
return (1);
}
@@ -499,6 +465,8 @@
int i;
geosite *gp;
+ G_debug(3, "GP_surf_is_selected(%d,%d)", hp, hs);
+
gp = gp_get_site(hp);
if (gp) {
@@ -538,11 +506,8 @@
if (gs) {
gpd_2dsite(gp, gs, 0);
-#ifdef TRACE_GP_FUNCS
- G_debug(3, "Drawing site %d on Surf %d", id,
+ G_debug(5, "Drawing site %d on Surf %d", id,
gp->drape_surf_id[i]);
- print_site_fields(gp);
-#endif
}
}
}
Modified: grass/trunk/lib/ogsf/GS2.c
===================================================================
--- grass/trunk/lib/ogsf/GS2.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/GS2.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -616,8 +616,10 @@
}
/*!
- \brief ADD
+ \brief Draw place marker
+ Used to display query point for raster queries.
+
\param id surface id
\param pt point, X, Y value in true world coordinates
*/
@@ -626,10 +628,11 @@
geosurf *gs;
Point3 pos;
float siz;
+ gvstyle style;
if ((gs = gs_get_surf(id))) {
GS_get_longdim(&siz);
- siz /= 200.;
+ style.size = siz / 200.;
pos[X] = pt[X] - gs->ox;
pos[Y] = pt[Y] - gs->oy;
_viewcell_tri_interp(gs, pos);
@@ -644,8 +647,9 @@
pos[Z] = gs->att[ATT_TOPO].constant;
gs = NULL; /* tells gpd_obj to use given Z val */
}
-
- gpd_obj(gs, Gd.bgcol, siz, ST_GYRO, pos);
+ style.color = Gd.bgcol;
+ style.symbol = ST_GYRO;
+ gpd_obj(gs, &style, pos);
gsd_flush();
gsd_popmatrix();
@@ -1646,7 +1650,8 @@
if (0 < (hdata = gsds_findh(filename, &changed, &atty, begin))) {
- G_debug(3, "GS_load_att_map(): %s already has data handle %d.CF=%x",
+ G_debug(3,
+ "GS_load_att_map(): %s already has data handle %d.CF=%x",
filename, hdata, changed);
/* handle found */
@@ -1686,7 +1691,8 @@
filename, hdata);
}
else {
- G_debug(3, "GS_load_att_map(): %s not loaded in correct form - loading now",
+ G_debug(3,
+ "GS_load_att_map(): %s not loaded in correct form - loading now",
filename);
/* not loaded - need to get new dataset handle */
Modified: grass/trunk/lib/ogsf/GV2.c
===================================================================
--- grass/trunk/lib/ogsf/GV2.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/GV2.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -237,9 +237,9 @@
}
gv->use_mem = mem;
- gv->color = color;
- gv->width = width;
gv->flat_val = flat;
+ gv->style->color = color;
+ gv->style->width = width;
return (1);
}
@@ -265,8 +265,8 @@
}
*mem = gv->use_mem;
- *color = gv->color;
- *width = gv->width;
+ *color = gv->style->color;
+ *width = gv->style->width;
*flat = gv->flat_val;
return (1);
Modified: grass/trunk/lib/ogsf/GVL2.c
===================================================================
--- grass/trunk/lib/ogsf/GVL2.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/GVL2.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -239,8 +239,7 @@
geovol *gvl;
int handle;
- G_debug(3, "GVL_load_vol(): id=%d, name=%s",
- id, filename);
+ G_debug(3, "GVL_load_vol(): id=%d, name=%s", id, filename);
if (NULL == (gvl = gvl_get_vol(id))) {
return (-1);
Modified: grass/trunk/lib/ogsf/Gp3.c
===================================================================
--- grass/trunk/lib/ogsf/Gp3.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/Gp3.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -26,56 +26,6 @@
#include <grass/gstypes.h>
/*!
- \brief Set color for point set
-
- used when site attribute mode is ST_ATT_COLOR
-
- Gets color structure for grass file, goes through points and
- uses fattr as CAT, putting rgb color in iattr.
-
- \param grassname raster map name
- \param gp pointer to geopoint struct
-
- \return 1 on success
- \return 0 on failure
- */
-int Gp_set_color(const char *grassname, geopoint * gp)
-{
- const char *col_map;
- struct Colors sc;
- CELL cat;
- geopoint *tp;
- int r, g, b, color;
-
- /* TODO: handle error messages */
-
- if (grassname) {
- col_map = G_find_raster2(grassname, "");
- if (!col_map) {
- G_warning(_("Raster map <%s> not found"), grassname);
- return 0;
- }
-
- Rast_read_colors(grassname, col_map, &sc);
-
- for (tp = gp; tp; tp = tp->next) {
- cat = (int)tp->fattr;
- color = NULL_COLOR;
-
- if (Rast_get_c_color(&cat, &r, &g, &b, &sc)) {
- color = (r & 0xff) | ((g & 0xff) << 8) | ((b & 0xff) << 16);
- }
-
- tp->iattr = color;
- }
-
- return (1);
- }
-
- return (0);
-}
-
-/*!
\brief Load to points to memory
The other alternative may be to load to a tmp file.
@@ -83,17 +33,15 @@
\param grassname vector point map
\param nsites
\param has_z 2D or 3D points?
- \param has_att attributes included
\return pointer to geopoint struct
\return NULL on failure
*/
-geopoint *Gp_load_sites(const char *grassname, int *nsites, int *has_z,
- int *has_att)
+geopoint *Gp_load_sites(const char *grassname, int *nsites, int *has_z)
{
struct Map_info map;
static struct line_pnts *Points = NULL;
- static struct line_cats *Cats = NULL;
+ struct line_cats *Cats = NULL;
geopoint *top, *gpt, *prev;
int np, ltype, eof;
struct Cell_head wind;
@@ -103,7 +51,7 @@
np = 0;
eof = 0;
- *has_z = *has_att = 0;
+ *has_z = 0;
mapset = G_find_vector2(grassname, "");
if (!mapset) {
@@ -166,20 +114,17 @@
*has_z = 0;
}
+ /* Store category info for thematic display */
if (Cats->n_cats > 0) {
- *has_att = 1;
- gpt->fattr = Cats->field[0]; /* Is this correct? */
- /* gpt->cat = ; ??** */
- gpt->highlight_color = gpt->highlight_size =
- gpt->highlight_marker = FALSE;
+ gpt->cats = Cats;
+ Cats = Vect_new_cats_struct();
}
else {
- gpt->fattr = 0;
- *has_att = 0;
+ gpt->cats = NULL;
+ Vect_reset_cats(Cats);
}
+ gpt->highlighted = 0;
- gpt->iattr = gpt->fattr;
- gpt->cattr = NULL;
G_debug(3, "loading vector point %d %f %f -- %d",
np, Points->x[0], Points->y[0], Cats->n_cats);
Modified: grass/trunk/lib/ogsf/Gv3.c
===================================================================
--- grass/trunk/lib/ogsf/Gv3.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/Gv3.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -46,6 +46,7 @@
{
struct Map_info map;
struct line_pnts *points;
+ struct line_cats *Cats = NULL;
geoline *top, *gln, *prev;
int np, i, n, nareas, nl = 0, area, type, is3d;
struct Cell_head wind;
@@ -77,6 +78,7 @@
#endif
points = Vect_new_line_struct();
+ Cats = Vect_new_cats_struct();
G_get_set_window(&wind);
Vect_set_constraint_region(&map, wind.north, wind.south, wind.east,
@@ -90,7 +92,6 @@
G_debug(3, "Reading vector areas (nareas = %d)", n);
for (area = 1; area <= n; area++) {
G_debug(3, " area %d", area);
-
Vect_get_area_points(&map, area, points);
if (points->n_points < 3)
continue;
@@ -159,9 +160,8 @@
/* Read all lines */
G_debug(3, "Reading vector lines ...");
- while (-1 < (type = Vect_read_next_line(&map, points, NULL))) {
+ while (-1 < (type = Vect_read_next_line(&map, points, Cats))) {
G_debug(3, "line type = %d", type);
-
if (type & (GV_LINES | GV_FACE)) {
if (type & (GV_LINES)) {
gln->type = OGSF_LINE;
@@ -219,6 +219,16 @@
gln->norm[2]);
}
+ /* Store category info for thematic display */
+ if (Cats->n_cats > 0) {
+ gln->cats = Cats;
+ Cats = Vect_new_cats_struct();
+ }
+ else {
+ gln->cats = NULL;
+ Vect_reset_cats(Cats);
+ }
+
gln->next = (geoline *) G_malloc(sizeof(geoline)); /* G_fatal_error */
if (!gln->next) {
return (NULL);
Modified: grass/trunk/lib/ogsf/gp.c
===================================================================
--- grass/trunk/lib/ogsf/gp.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/gp.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -37,7 +37,7 @@
{
geosite *gp;
- G_debug(5, "gp_get_site");
+ G_debug(5, "gp_get_site(%d)", id);
for (gp = Site_top; gp; gp = gp->next) {
if (gp->gsite_id == id) {
@@ -60,7 +60,7 @@
{
geosite *pp;
- G_debug(5, "gp_get_prev_site");
+ G_debug(5, "gp_get_prev_site(%d)", id);
for (pp = Site_top; pp; pp = pp->next) {
if (pp->gsite_id == id - 1) {
@@ -139,6 +139,12 @@
}
np->next = NULL;
+ np->style = (gvstyle *) G_malloc(sizeof(gvstyle));
+ if (!np->style)
+ return NULL;
+ np->hstyle = (gvstyle *) G_malloc(sizeof(gvstyle));
+ if (!np->hstyle)
+ return NULL;
return (np);
}
@@ -196,13 +202,18 @@
gp->filename = NULL;
gp->n_sites = gp->use_z = gp->n_surfs = gp->use_mem = 0;
gp->x_trans = gp->y_trans = gp->z_trans = 0.0;
- gp->size = dim / 100.;
gp->points = NULL;
- gp->width = 1;
- gp->color = 0xFFFFFF;
- gp->marker = ST_X;
- gp->has_z = gp->has_att = 0;
- gp->attr_mode = ST_ATT_NONE;
+ gp->has_z = 0;
+ gp->thematic_layer = -1;
+ gp->style->color = 0xF0F0F0;
+ gp->style->size = dim / 100.;
+ gp->style->width = 1;
+ gp->style->symbol = ST_X;
+ gp->style->next = NULL;
+ gp->hstyle->color = 0xFF0000;
+ gp->hstyle->size = dim / 150.;
+ gp->hstyle->symbol = ST_X;
+ gp->hstyle->next = NULL;
gp->next = NULL;
for (i = 0; i < MAX_SURFS; i++) {
gp->drape_surf_id[i] = 0;
@@ -212,34 +223,6 @@
}
/*!
- \brief Print point set fields, debugging
-
- \param gp pointer to geosite struct
- */
-void print_site_fields(geosite * gp)
-{
- int i;
-
- fprintf(stderr, "n_sites=%d use_z=%d n_surfs=%d use_mem=%d\n",
- gp->n_sites, gp->use_z, gp->n_surfs, gp->use_mem);
- fprintf(stderr, "x_trans=%.2f x_trans=%.2f x_trans=%.2f\n",
- gp->x_trans, gp->y_trans, gp->z_trans);
- fprintf(stderr, "size = %.2f\n", gp->size);
- fprintf(stderr, "points = %lx\n", (unsigned long)gp->points);
- fprintf(stderr, "width = %d\n", gp->width);
- fprintf(stderr, "color = %x\n", gp->color);
- fprintf(stderr, "marker = %d\n", gp->marker);
- fprintf(stderr, "has_z = %d, has_att = %d\n", gp->has_z, gp->has_att);
- fprintf(stderr, "attr_mode = %d\n", gp->attr_mode);
-
- for (i = 0; i < MAX_SURFS; i++) {
- fprintf(stderr, "drape_surf_id[%d] = %d\n", i, gp->drape_surf_id[i]);
- }
-
- return;
-}
-
-/*!
\brief Initialize geosite struct
\param gp pointer to geosite struct
@@ -338,14 +321,24 @@
void gp_free_sitemem(geosite * fp)
{
geopoint *gpt, *tmp;
+ gvstyle *gvs, *tmpstyle;
G_free((void *)fp->filename);
fp->filename = NULL;
+ if (fp->style)
+ G_free(fp->style);
+ if (fp->hstyle)
+ G_free(fp->hstyle);
if (fp->points) {
for (gpt = fp->points; gpt;) {
- if (gpt->cattr) {
- G_free(gpt->cattr);
+ G_free(gpt->cats);
+ if (fp->thematic_layer > -1) { /* Style also exists for features */
+ for (gvs = fp->style; gvs;) {
+ tmpstyle = gvs;
+ gvs = gvs->next;
+ G_free(tmpstyle);
}
+ }
tmp = gpt;
gpt = gpt->next;
Modified: grass/trunk/lib/ogsf/gpd.c
===================================================================
--- grass/trunk/lib/ogsf/gpd.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/gpd.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -28,131 +28,7 @@
/* BOB -- border allowed outside of viewport */
#define v_border 50
-/* ACS_MODIFY_BEGIN site_attr management ************************************** */
-static float _cur_size_;
-
/*!
- \brief Substitutes gpd_obj()
-
- \param gs surface (geosurf)
- \param gp site (geosite)
- \param gpt point (point)
- \param site point
-
- \return 0
- */
-int gpd_obj_site_attr(geosurf * gs, geosite * gp, geopoint * gpt, Point3 site)
-{
- float size, z, y, x, z_scale, z_offset;
- int marker, color, i, ii, iii;
- int use_attr, has_drawn;
- int _put_aside_;
-
- _put_aside_ = 0;
- _cur_size_ = gp->size;
-
- z_scale = GS_global_exag();
- z_offset = 0.0;
-
- has_drawn = 0;
-
- for (i = 0; i < GPT_MAX_ATTR; i++) {
- color = gp->color;
- marker = gp->marker;
- size = gp->size;
- use_attr = 0;
-
- if (gp->use_attr[i] & ST_ATT_COLOR) {
- use_attr = 1;
- color = gpt->color[i];
- }
-
- if (gp->use_attr[i] & ST_ATT_MARKER) {
- use_attr = 1;
- marker = gpt->marker[i];
- }
-
- if (gp->use_attr[i] & ST_ATT_SIZE) {
- use_attr = 1;
- size = gpt->size[i] * gp->size;
- if (gp->marker == ST_HISTOGRAM)
- _put_aside_ = 1;
- }
-
- /* ACS_MODIFY_BEGIN site_highlight management ********************************* */
- if (gpt->highlight_color)
- color = gpt->highlight_color_value;
- if (gpt->highlight_marker)
- marker = gpt->highlight_marker_value;
- if (gpt->highlight_size)
- size *= gpt->highlight_size_value;
- /* ACS_MODIFY_END site_highlight management *********************************** */
-
- if (_put_aside_) {
- if (use_attr == 1) {
- has_drawn = 1;
-
-/*******************************************************************************
- fixed size = gp->size
- this is mailny intended for "histograms" that grow in z, but not in xy
-
- square filling to right and then up
-
- 15 14 13 12
- 8 7 6 11
- 3 2 5 10
- 0 1 4 9
-
-*******************************************************************************/
- x = site[X];
- y = site[Y];
-
- ii = (int)(sqrt(i));
- iii = ii * ii + ii;
-
- if (i <= iii) {
- site[X] += ii * 2.2 * gp->size;
- site[Y] += (i - ii) * 2.2 * gp->size;
- }
- else {
- site[X] += (ii - (i - iii)) * 2.2 * gp->size;
- site[Y] += ii * 2.2 * gp->size;
-
- }
-
- gpd_obj(gs, color, size, marker, site);
-
- site[X] = x;
- site[Y] = y;
- }
- }
- else {
- if (i > 0)
- z_offset += size;
- if (use_attr == 1) {
- has_drawn = 1;
-
- z = site[Z];
- site[Z] += z_offset / z_scale;
-
- gpd_obj(gs, color, size, marker, site);
-
- site[Z] = z;
- }
-
- z_offset += size;
- }
- }
-
- if (has_drawn == 0)
- gpd_obj(gs, color, size, marker, site);
-
- return (0);
-}
-
-/* ACS_MODIFY_END site_attr management **************************************** */
-
-/*!
\brief Check if point is in region
Check for cancel every CHK_FREQ points
@@ -186,30 +62,26 @@
}
/*!
- \brief ADD
+ \brief Draw point representing object
Do normal transforms before calling
Note gs: NULL if 3d obj or const elev surface
- \todo add size1, size2 & dir1, dir2 (eg azimuth, elevation) variables
-
\param gs surface (geosurf)
- \param size
- \param marker
+ \param style object displaying style (highlighted or not)
\param pt 3d point (Point3)
*/
-void gpd_obj(geosurf * gs, int color, float size, int marker, Point3 pt)
+void gpd_obj(geosurf * gs, gvstyle * style, Point3 pt)
{
float sz, lpt[3];
float siz[3];
- gsd_color_func(color);
+ gsd_color_func(style->color);
sz = GS_global_exag();
GS_v3eq(lpt, pt); /* CHANGING Z OF POINT PASSED, so use copy */
- switch (marker) {
- /* ACS_MODIFY_BEGIN site_attr management ************************************** */
+ switch (style->symbol) {
case ST_HISTOGRAM:
gsd_colormode(CM_DIFFUSE);
gsd_pushmatrix();
@@ -219,17 +91,16 @@
gsd_scale(1.0, 1.0, 1. / sz);
}
- siz[0] = _cur_size_;
- siz[1] = _cur_size_;
- siz[2] = size;
+ siz[0] = style->size; /*TODO: Fix historgam drawing */
+ siz[1] = style->size;
+ siz[2] = style->size;
- gsd_box(lpt, color, siz);
+ gsd_box(lpt, style->color, siz);
gsd_popmatrix();
gsd_colormode(CM_COLOR);
break;
- /* ACS_MODIFY_END site_attr management ************************************** */
case ST_DIAMOND:
/*
gsd_colormode(CM_AD);
@@ -242,7 +113,7 @@
gsd_scale(1.0, 1.0, 1. / sz);
}
- gsd_diamond(lpt, color, size);
+ gsd_diamond(lpt, style->color, style->size);
gsd_popmatrix();
gsd_colormode(CM_COLOR);
@@ -256,7 +127,7 @@
gsd_scale(1.0, 1.0, 1. / sz);
}
- gsd_draw_box(lpt, color, size);
+ gsd_draw_box(lpt, style->color, style->size);
gsd_popmatrix();
break;
@@ -272,7 +143,7 @@
gsd_scale(1.0, 1.0, 1. / sz);
}
- gsd_sphere(lpt, size);
+ gsd_sphere(lpt, style->size);
gsd_popmatrix();
gsd_colormode(CM_COLOR);
@@ -286,7 +157,7 @@
gsd_scale(1.0, 1.0, 1. / sz);
}
- gsd_draw_gyro(lpt, color, size);
+ gsd_draw_gyro(lpt, style->color, style->size);
gsd_popmatrix();
break;
@@ -299,7 +170,7 @@
gsd_scale(1.0, 1.0, 1. / sz);
}
- gsd_draw_asterisk(lpt, color, size);
+ gsd_draw_asterisk(lpt, style->color, style->size);
gsd_popmatrix();
break;
@@ -312,7 +183,7 @@
gsd_scale(1.0, 1.0, 1. / sz);
}
- gsd_cube(lpt, color, size);
+ gsd_cube(lpt, style->color, style->size);
gsd_popmatrix();
gsd_colormode(CM_COLOR);
@@ -320,7 +191,7 @@
default:
case ST_X:
gsd_colormode(CM_COLOR);
- gsd_x(gs, lpt, color, size);
+ gsd_x(gs, lpt, style->color, style->size);
break;
}
@@ -349,8 +220,7 @@
int gpd_2dsite(geosite * gp, geosurf * gs, int do_fast)
{
float site[3], konst;
- float size;
- int src, check, marker, color;
+ int src, check;
geopoint *gpt;
typbuff *buf;
GLdouble modelMatrix[16], projMatrix[16];
@@ -384,12 +254,8 @@
gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans);
- gsd_linewidth(gp->width);
-
+ gsd_linewidth(gp->style->width);
check = 0;
- color = gp->color;
- marker = gp->marker;
- size = gp->size;
for (gpt = gp->points; gpt; gpt = gpt->next) {
if (!(++check % CHK_FREQ)) {
@@ -408,11 +274,6 @@
continue;
}
- /* TODO: set other dynamic attributes */
- if (gp->attr_mode & ST_ATT_COLOR) {
- color = gpt->iattr;
- }
-
if (src == MAP_ATT) {
if (viewcell_tri_interp(gs, buf, site, 1)) {
/* returns 0 if outside or masked */
@@ -421,23 +282,33 @@
if (gsd_checkpoint
(site, window, viewport, modelMatrix, projMatrix))
continue;
+ else {
+ if (gpt->highlighted > 0)
+ gpd_obj(gs, gp->hstyle, site);
+ else if (gp->thematic_layer > 0)
+ gpd_obj(gs, gpt->style, site);
else
- /* ACS_MODIFY_OneLine site_attr management - was: gpd_obj(gs, color, size, marker, site); */
- gpd_obj_site_attr(gs, gp, gpt, site);
+ gpd_obj(gs, gp->style, site);
}
}
+ }
else if (src == CONST_ATT) {
if (gs_point_in_region(gs, site, NULL)) {
site[Z] += gp->z_trans;
if (gsd_checkpoint
(site, window, viewport, modelMatrix, projMatrix))
continue;
+ else {
+ if (gpt->highlighted > 0)
+ gpd_obj(gs, gp->hstyle, site);
+ else if (gp->thematic_layer > 0)
+ gpd_obj(gs, gpt->style, site);
else
- /* ACS_MODIFY_OneLine site_attr management - was: gpd_obj(NULL, color, size, marker, site); */
- gpd_obj_site_attr(NULL, gp, gpt, site);
+ gpd_obj(gs, gp->style, site);
}
}
}
+ }
gsd_linewidth(1);
gsd_popmatrix();
@@ -459,8 +330,7 @@
int gpd_3dsite(geosite * gp, float xo, float yo, int do_fast)
{
float site[3], tz;
- float size;
- int check, color, marker;
+ int check;
geopoint *gpt;
GLdouble modelMatrix[16], projMatrix[16];
GLint viewport[4];
@@ -480,11 +350,8 @@
site[Z] = 0.0;
check = 0;
- color = gp->color;
- marker = gp->marker;
- size = gp->size;
- gsd_linewidth(gp->width);
+ gsd_linewidth(gp->style->width);
for (gpt = gp->points; gpt; gpt = gpt->next) {
if (!(++check % CHK_FREQ)) {
@@ -503,18 +370,19 @@
site[Z] = gpt->p3[Z] + gp->z_trans;
}
- /* TODO: set other dynamic attributes */
- if (gp->attr_mode & ST_ATT_COLOR) {
- color = gpt->iattr;
- }
-
if (gsd_checkpoint(site, window, viewport, modelMatrix, projMatrix))
continue;
else
/* clip points outside default region? */
- /* ACS_MODIFY_OneLine site_attr management - was: gpd_obj(NULL, color, size, marker, site); */
- gpd_obj_site_attr(NULL, gp, gpt, site);
+ {
+ if (gpt->highlighted > 0)
+ gpd_obj(NULL, gp->hstyle, site);
+ else if (gp->thematic_layer > 0)
+ gpd_obj(NULL, gpt->style, site);
+ else
+ gpd_obj(NULL, gp->style, site);
}
+ }
gsd_linewidth(1);
gsd_popmatrix();
Modified: grass/trunk/lib/ogsf/gsd_objs.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_objs.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/gsd_objs.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -267,7 +267,7 @@
}
/*!
- \brief ADD
+ \brief Draw X symbol
Note gs: NULL if flat
@@ -823,6 +823,8 @@
\return 1
*/
+/*TODO: Store arrow somewhere to enable it's removal/change.
+ Add option to specify north text and font. */
int gsd_north_arrow(float *pos2, float len, GLuint fontbase,
unsigned long arw_clr, unsigned long text_clr)
{
Modified: grass/trunk/lib/ogsf/gv.c
===================================================================
--- grass/trunk/lib/ogsf/gv.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/gv.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -137,6 +137,13 @@
nv->next = NULL;
+ nv->style = (gvstyle *) G_malloc(sizeof(gvstyle));
+ if (NULL == nv->style)
+ return NULL;
+ nv->hstyle = (gvstyle *) G_malloc(sizeof(gvstyle));
+ if (NULL == nv->hstyle)
+ return NULL;
+
G_debug(5, "gv_get_new_vect() id=%d", nv->gvect_id);
return (nv);
@@ -192,9 +199,15 @@
gv->x_trans = gv->y_trans = gv->z_trans = 0.0;
gv->lines = NULL;
gv->fastlines = NULL;
- gv->width = 1;
- gv->color = 0xFFFFFF;
gv->flat_val = 0;
+ gv->thematic_layer = -1;
+ gv->style->color = 0xF0F0F0;
+ gv->style->width = 1;
+ gv->style->next = NULL;
+ gv->hstyle->color = 0xFF0000;
+ gv->hstyle->width = 2;
+ gv->hstyle->next = NULL;
+ gv->next = NULL;
for (i = 0; i < MAX_SURFS; i++) {
gv->drape_surf_id[i] = 0;
@@ -301,9 +314,14 @@
void gv_free_vectmem(geovect * fv)
{
geoline *gln, *tmpln;
+ gvstyle *gvs, *tmpstyle;
G_free((void *)fv->filename);
fv->filename = NULL;
+ if (fv->style)
+ G_free(fv->style);
+ if (fv->hstyle)
+ G_free(fv->hstyle);
if (fv->lines) {
for (gln = fv->lines; gln;) {
@@ -316,6 +334,15 @@
G_free(gln->p3);
}
+ G_free(gln->cats);
+ if (fv->thematic_layer > -1) { /* Style also exists for features */
+ for (gvs = gln->style; gvs;) {
+ tmpstyle = gvs;
+ gvs = gvs->next;
+ G_free(tmpstyle);
+ }
+ }
+
tmpln = gln;
gln = gln->next;
sub_Vectmem(sizeof(geoline));
Modified: grass/trunk/lib/ogsf/gvd.c
===================================================================
--- grass/trunk/lib/ogsf/gvd.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/gvd.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -123,8 +123,8 @@
gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans + fudge);
gsd_colormode(CM_COLOR);
- gsd_color_func(gv->color);
- gsd_linewidth(gv->width);
+ gsd_color_func(gv->style->color);
+ gsd_linewidth(gv->style->width);
check = 0;
if (do_fast) {
@@ -205,7 +205,7 @@
G_debug(5, "gvd_vect(): 3D vector line");
points = (Point3 *) malloc(sizeof(Point3));
- gsd_color_func(gv->color);
+ gsd_color_func(gv->style->color);
gsd_bgnline();
for (k = 0; k < gln->npts; k++) {
points[0][X] =
@@ -241,7 +241,7 @@
glBegin(GL_POLYGON);
glColor3f(1.0, 0, 0);
- gsd_color_func(gv->color);
+ gsd_color_func(gv->style->color);
glNormal3fv(gln->norm);
for (k = 0; k < gln->npts; k++) {
Modified: grass/trunk/lib/ogsf/gvl.c
===================================================================
--- grass/trunk/lib/ogsf/gvl.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/gvl.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -578,8 +578,7 @@
{
geovol *gvl;
- G_debug(5, "gvl_isosurf_get_isosurf(): id=%d isosurf=%d",
- id, isosurf_id);
+ G_debug(5, "gvl_isosurf_get_isosurf(): id=%d isosurf=%d", id, isosurf_id);
gvl = gvl_get_vol(id);
Modified: grass/trunk/lib/ogsf/gvl_calc.c
===================================================================
--- grass/trunk/lib/ogsf/gvl_calc.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/lib/ogsf/gvl_calc.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -392,7 +392,8 @@
iso_get_cube_values(isosurf, ATT_EMIT, x, y, z, val[ATT_EMIT]);
}
- FOR_0_TO_N(3, d_sum[FOR_VAR] = 0.; n_sum[FOR_VAR] = 0.);
+ FOR_0_TO_N(3, d_sum[FOR_VAR] = 0.;
+ n_sum[FOR_VAR] = 0.);
/* loop in edges */
for (i = 0; i < cell_table[c_ndx].nedges; i++) {
Modified: grass/trunk/visualization/nviz2/cmd/vector.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/vector.c 2009-09-29 07:31:55 UTC (rev 39322)
+++ grass/trunk/visualization/nviz2/cmd/vector.c 2009-09-29 08:37:06 UTC (rev 39323)
@@ -180,8 +180,7 @@
else
G_fatal_error(_("Unknown icon marker"));
- GP_set_sitemode(site_list[i], ST_ATT_NONE,
- color, width, size, marker);
+ GP_set_style(site_list[i], color, width, size, marker);
}
return 1;
More information about the grass-commit
mailing list