[GRASS-SVN] r48618 - in grass/trunk: include lib/nviz lib/ogsf
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Oct 4 17:19:23 EDT 2011
Author: annakrat
Date: 2011-10-04 14:19:23 -0700 (Tue, 04 Oct 2011)
New Revision: 48618
Modified:
grass/trunk/include/ogsf_proto.h
grass/trunk/lib/nviz/draw.c
grass/trunk/lib/nviz/nviz.c
grass/trunk/lib/ogsf/gsd_objs.c
Log:
nviz: change scalebar appearance
Modified: grass/trunk/include/ogsf_proto.h
===================================================================
--- grass/trunk/include/ogsf_proto.h 2011-10-04 15:43:34 UTC (rev 48617)
+++ grass/trunk/include/ogsf_proto.h 2011-10-04 21:19:23 UTC (rev 48618)
@@ -514,6 +514,7 @@
int gsd_arrow_onsurf(float *, float *, unsigned long, int, geosurf *);
void gsd_3darrow(float *, unsigned long, float, float, float *, float);
int gsd_scalebar(float *, float, GLuint, unsigned long, unsigned long);
+int gsd_scalebar_v2(float *, float, GLuint, unsigned long, unsigned long);
void primitive_cone(unsigned long);
void primitive_cylinder(unsigned long, int);
Modified: grass/trunk/lib/nviz/draw.c
===================================================================
--- grass/trunk/lib/nviz/draw.c 2011-10-04 15:43:34 UTC (rev 48617)
+++ grass/trunk/lib/nviz/draw.c 2011-10-04 21:19:23 UTC (rev 48618)
@@ -248,7 +248,7 @@
/* scale bar */
for (i = 0; i < data->num_scalebars; i++) {
struct scalebar_data *s = data->scalebar[i];
- gsd_scalebar(s->where, s->size, 0, s->color, s->color);
+ gsd_scalebar_v2(s->where, s->size, 0, s->color, s->color);
}
GS_done_draw();
Modified: grass/trunk/lib/nviz/nviz.c
===================================================================
--- grass/trunk/lib/nviz/nviz.c 2011-10-04 15:43:34 UTC (rev 48617)
+++ grass/trunk/lib/nviz/nviz.c 2011-10-04 21:19:23 UTC (rev 48618)
@@ -417,7 +417,7 @@
for (i = 0; i < data->num_scalebars; i++) {
struct scalebar_data *s = data->scalebar[i];
- gsd_scalebar(s->where, s->size, FontBase, s->color, s->color);
+ gsd_scalebar_v2(s->where, s->size, FontBase, s->color, s->color);
}
}
Modified: grass/trunk/lib/ogsf/gsd_objs.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_objs.c 2011-10-04 15:43:34 UTC (rev 48617)
+++ grass/trunk/lib/ogsf/gsd_objs.c 2011-10-04 21:19:23 UTC (rev 48618)
@@ -1236,6 +1236,74 @@
}
/*!
+ \brief Draw Scalebar (as lines)
+
+ Adapted from gsd_scalebar A.Kratochvilova 2011
+
+ \param pos2 scalebar position
+ \param fontbase font-base (unused)
+ \param bar_clr barscale color
+ \param text_clr text color (unused)
+
+ \return 1
+ */
+int gsd_scalebar_v2(float *pos, float len, GLuint fontbase,
+ unsigned long bar_clr, unsigned long text_clr)
+{
+ float base[6][3];
+ float Ntop[] = { 0.0, 0.0, 1.0 };
+
+ base[0][Z] = base[1][Z] = base[2][Z] = pos[Z];
+ base[3][Z] = base[4][Z] = base[5][Z] = pos[Z];
+
+ /* simple scalebar: |------| */
+ base[0][X] = base[2][X] = base[3][X] = pos[X] - len / 2.;
+ base[1][X] = base[4][X] = base[5][X] = pos[X] + len / 2.;
+ base[0][Y] = base[1][Y] = pos[Y];
+ base[2][Y] = base[4][Y] = pos[Y] - len / 12;
+ base[3][Y] = base[5][Y] = pos[Y] + len / 12;
+
+ /* make sure we are drawing in front buffer */
+ GS_set_draw(GSD_FRONT);
+
+ gsd_pushmatrix();
+ gsd_do_scale(1); /* get map scale factor */
+
+ glNormal3fv(Ntop);
+
+ gsd_color_func(bar_clr);
+
+ gsd_linewidth(3); /* could be optional */
+
+ /* ------- */
+ gsd_bgnline();
+ gsd_vert_func(base[0]);
+ gsd_vert_func(base[1]);
+ gsd_endline();
+
+ /* |------- */
+ gsd_bgnline();
+ gsd_vert_func(base[2]);
+ gsd_vert_func(base[3]);
+ gsd_endline();
+
+ /* |-------| */
+ gsd_bgnline();
+ gsd_vert_func(base[4]);
+ gsd_vert_func(base[5]);
+ gsd_endline();
+
+ /* TODO -- draw units */
+
+ GS_done_draw();
+
+ gsd_popmatrix();
+ gsd_flush();
+
+ return 1;
+}
+
+/*!
\brief Primitives only called after transforms
Center is actually center at base of 8 sided cone
More information about the grass-commit
mailing list