[GRASS-SVN] r33270 - in grass/trunk: display/d.barscale
display/d.colortable display/d.geodesic display/d.graph
display/d.grid display/d.histogram display/d.labels
display/d.legend display/d.linegraph display/d.profile
display/d.rast.num display/d.text display/d.vect include
lib/display lib/driver lib/raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Sep 5 03:54:53 EDT 2008
Author: glynn
Date: 2008-09-05 03:54:52 -0400 (Fri, 05 Sep 2008)
New Revision: 33270
Modified:
grass/trunk/display/d.barscale/draw_scale.c
grass/trunk/display/d.colortable/main.c
grass/trunk/display/d.geodesic/plot.c
grass/trunk/display/d.graph/do_graph.c
grass/trunk/display/d.graph/local_proto.h
grass/trunk/display/d.grid/plot.c
grass/trunk/display/d.histogram/bar.c
grass/trunk/display/d.histogram/draw_slice.c
grass/trunk/display/d.histogram/main.c
grass/trunk/display/d.histogram/pie.c
grass/trunk/display/d.labels/do_labels.c
grass/trunk/display/d.legend/main.c
grass/trunk/display/d.linegraph/main.c
grass/trunk/display/d.profile/main.c
grass/trunk/display/d.rast.num/main.c
grass/trunk/display/d.text/main.c
grass/trunk/display/d.vect/plot1.c
grass/trunk/display/d.vect/utils.c
grass/trunk/include/display.h
grass/trunk/include/raster.h
grass/trunk/lib/display/draw2.c
grass/trunk/lib/display/symbol.c
grass/trunk/lib/driver/Box.c
grass/trunk/lib/driver/Cont.c
grass/trunk/lib/driver/Move.c
grass/trunk/lib/driver/Polydots.c
grass/trunk/lib/driver/Polygon.c
grass/trunk/lib/driver/Polyline.c
grass/trunk/lib/driver/driver.h
grass/trunk/lib/driver/driverlib.h
grass/trunk/lib/driver/text2.c
grass/trunk/lib/driver/text3.c
grass/trunk/lib/raster/raster.c
Log:
Remove COM_*_rel, R_*_rel functions; no longer used
Replace R_move_abs -> R_pos_abs
Replace R_move_abs + R_cont_abs -> R_line_abs
Add D_pos_abs, D_pos_rel
Eliminate dual-use of D_{move,cont}_{abs,rel}
Update d.graph to use D_pos_abs for move and D_line_abs for move/draw
Merge D_symbol and D_symbol2
Replace R_* -> D_* in D_symbol
Update d.vect to handle D_symbol changes
Eliminate integer coordinates in soft_text functions
Modified: grass/trunk/display/d.barscale/draw_scale.c
===================================================================
--- grass/trunk/display/d.barscale/draw_scale.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.barscale/draw_scale.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -116,7 +116,7 @@
D_stroke();
/* actual text width is 81% of size? from d.legend */
- D_move_abs(pl + w / 2 - 7 * .81, pt + 14);
+ D_pos_abs(pl + w / 2 - 7 * .81, pt + 14);
R_text("N");
return 0;
@@ -202,7 +202,7 @@
D_end();
D_stroke();
- D_move_rel(0, 1 - 4);
+ D_pos_rel(0, 1 - 4);
for (i = 1; i <= scales[incr].seg; i++) {
xarr[0] = 0; yarr[0] = 0;
xarr[1] = seg_len; yarr[1] = 0;
@@ -211,7 +211,7 @@
xarr[4] = 0; yarr[4] = (i % 2 ? 4 : -4);
/* width is seg_len and height is 4 */
D_polygon_rel(xarr, yarr, 4);
- D_move_rel(seg_len, 0);
+ D_pos_rel(seg_len, 0);
}
}
else if (do_bar) {
@@ -225,11 +225,11 @@
D_end();
D_stroke();
- D_move_rel(0, 1);
+ D_pos_rel(0, 1);
for (i = 1; i <= scales[incr].seg; i += 2) {
/* width is seg_len and height is 5 */
D_box_rel(seg_len, -5);
- D_move_rel(seg_len * 2, 0);
+ D_pos_rel(seg_len * 2, 0);
}
}
else { /* draw simple line scale */
@@ -245,13 +245,13 @@
}
if (toptext) {
- D_move_abs(x_pos + 25 - draw * 10 + line_len / 2.
- - strlen(scales[incr].name) * size * 0.81 / 2,
- y_pos);
+ D_pos_abs(x_pos + 25 - draw * 10 + line_len / 2.
+ - strlen(scales[incr].name) * size * 0.81 / 2,
+ y_pos);
R_text(scales[incr].name);
}
else {
- D_move_abs(x_pos + 35 - draw * 10 + line_len, y_pos + 20);
+ D_pos_abs(x_pos + 35 - draw * 10 + line_len, y_pos + 20);
R_text(scales[incr].name);
}
Modified: grass/trunk/display/d.colortable/main.c
===================================================================
--- grass/trunk/display/d.colortable/main.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.colortable/main.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -203,7 +203,7 @@
D_stroke();
/* Color box */
D_color((CELL) atcat, &colors);
- D_move_abs(cur_dot_col + 4, (cur_dot_row - 3));
+ D_pos_abs(cur_dot_col + 4, (cur_dot_row - 3));
D_polygon_rel(x_box, y_box, 5);
count++;
@@ -255,7 +255,7 @@
dval =
dmin + (r - 1) * (dmax - dmin) / (dots_per_line - 6 - 5);
D_d_color(dval, &colors);
- D_move_abs(cur_dot_col + 4, (cur_dot_row - 3) - r);
+ D_pos_abs(cur_dot_col + 4, (cur_dot_row - 3) - r);
D_polygon_rel(x_box, y_box, 5);
}
}
Modified: grass/trunk/display/d.geodesic/plot.c
===================================================================
--- grass/trunk/display/d.geodesic/plot.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.geodesic/plot.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -61,7 +61,7 @@
distance = G_geodesic_distance(lon1, lat1, lon2, lat2);
sprintf(buf, "%.0f miles", METERS_TO_MILES(distance));
- D_move_abs(text_x, text_y);
+ D_pos_abs(text_x, text_y);
D_get_text_box(buf, &t, &b, &l, &r);
if (t - D_get_u_north() > 0)
@@ -75,7 +75,7 @@
D_use_color(text_color);
- D_move_abs(text_x, text_y);
+ D_pos_abs(text_x, text_y);
R_text(buf);
}
}
Modified: grass/trunk/display/d.graph/do_graph.c
===================================================================
--- grass/trunk/display/d.graph/do_graph.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.graph/do_graph.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -24,6 +24,8 @@
static double t, b, l, r;
+static double cur_x, cur_y;
+
int set_graph_stuff(void)
{
D_get_dst(&t, &b, &l, &r);
@@ -54,40 +56,44 @@
return (0);
}
-int do_draw(char *buff)
+int do_draw(const char *str)
{
float xper, yper;
- if (2 != sscanf(buff, "%*s %f %f", &xper, &yper)) {
- G_warning(_("Problem parsing coordinates [%s]"), buff);
+ if (2 != sscanf(str, "%*s %f %f", &xper, &yper)) {
+ G_warning(_("Problem parsing coordinates [%s]"), str);
return (-1);
}
- D_cont_abs(xper, yper);
+ D_line_abs(cur_x, cur_y, xper, yper);
+ cur_x = xper;
+ cur_y = yper;
return (0);
}
-int do_move(char *buff)
+int do_move(const char *str)
{
float xper, yper;
- if (2 != sscanf(buff, "%*s %f %f", &xper, &yper)) {
- G_warning(_("Problem parsing coordinates [%s]"), buff);
+ if (2 != sscanf(str, "%*s %f %f", &xper, &yper)) {
+ G_warning(_("Problem parsing coordinates [%s]"), str);
return (-1);
}
- D_move_abs(xper, yper);
+ D_pos_abs(xper, yper);
+ cur_x = xper;
+ cur_y = yper;
return (0);
}
-int do_color(char *buff)
+int do_color(const char *str)
{
char in_color[64];
int R, G, B, color = 0;
- if (1 != sscanf(buff, "%*s %s", in_color)) {
+ if (1 != sscanf(str, "%*s %s", in_color)) {
G_warning(_("Unable to read color"));
return (-1);
}
@@ -114,12 +120,12 @@
return (0);
}
-int do_linewidth(char *buff)
+int do_linewidth(const char *str)
{
double width;
- if (1 != sscanf(buff, "%*s %lf", &width)) {
- G_warning(_("Problem parsing command [%s]"), buff);
+ if (1 != sscanf(str, "%*s %lf", &width)) {
+ G_warning(_("Problem parsing command [%s]"), str);
return (-1);
}
@@ -130,30 +136,32 @@
}
-int do_poly(char *buff, FILE * infile)
+int do_poly(const char *str, FILE * infile)
{
int num;
char origcmd[64];
float xper, yper;
int to_return;
- sscanf(buff, "%s", origcmd);
+ sscanf(str, "%s", origcmd);
num = 0;
for (;;) {
- if ((to_return = G_getl2(buff, 128, infile)) != 1)
+ char buf[128];
+
+ if ((to_return = G_getl2(buf, sizeof(buf), infile)) != 1)
break;
- if (2 != sscanf(buff, "%f %f", &xper, &yper)) {
+ if (2 != sscanf(buf, "%f %f", &xper, &yper)) {
- if ('#' == buff[0]) {
- G_debug(3, " skipping comment line [%s]", buff);
+ if ('#' == buf[0]) {
+ G_debug(3, " skipping comment line [%s]", buf);
continue;
}
G_debug(3, "coordinate pair not found. ending polygon. [%s]",
- buff);
+ buf);
break;
}
@@ -177,15 +185,15 @@
return (to_return);
}
-int do_size(char *buff)
+int do_size(const char *str)
{
float xper, yper;
int ret;
- ret = sscanf(buff, "%*s %f %f", &xper, &yper);
+ ret = sscanf(str, "%*s %f %f", &xper, &yper);
if (ret != 2 && ret != 1) {
- G_warning(_("Problem parsing command [%s]"), buff);
+ G_warning(_("Problem parsing command [%s]"), str);
return (-1);
}
@@ -203,10 +211,10 @@
return (0);
}
-int do_rotate(char *buff)
+int do_rotate(const char *str)
{
- if (1 != sscanf(buff, "%*s %lf", &rotation)) {
- G_warning(_("Problem parsing command [%s]"), buff);
+ if (1 != sscanf(str, "%*s %lf", &rotation)) {
+ G_warning(_("Problem parsing command [%s]"), str);
return (-1);
}
@@ -216,14 +224,15 @@
return (0);
}
-int do_text(char *buff)
+int do_text(const char *str)
{
- char *ptr;
+ const char *ptr = str;
- ptr = buff;
/* skip to beginning of actual text */
- for (; *ptr != ' '; ptr++) ;
- for (; *ptr == ' '; ptr++) ;
+ for (; *ptr != ' '; ptr++)
+ ;
+ for (; *ptr == ' '; ptr++)
+ ;
R_text(ptr);
return 0;
@@ -248,15 +257,15 @@
return 0;
}
-int do_icon(char *buff)
+int do_icon(const char *str)
{
double xper, yper;
char type;
double size;
double ix, iy;
- if (4 != sscanf(buff, "%*s %c %lf %lf %lf", &type, &size, &xper, &yper)) {
- G_warning(_("Problem parsing command [%s]"), buff);
+ if (4 != sscanf(str, "%*s %c %lf %lf %lf", &type, &size, &xper, &yper)) {
+ G_warning(_("Problem parsing command [%s]"), str);
return (-1);
}
@@ -295,7 +304,7 @@
return (0);
}
-int do_symbol(char *buff)
+int do_symbol(const char *str)
{
double xper, yper;
double size;
@@ -310,20 +319,20 @@
line_color = G_malloc(sizeof(RGBA_Color));
fill_color = G_malloc(sizeof(RGBA_Color));
- symb_name = G_malloc(sizeof(char) * strlen(buff) + 1); /* well, it won't be any bigger than this */
- line_color_str = G_malloc(sizeof(char) * strlen(buff) + 1);
- fill_color_str = G_malloc(sizeof(char) * strlen(buff) + 1);
+ symb_name = G_malloc(strlen(str) + 1); /* well, it won't be any bigger than this */
+ line_color_str = G_malloc(strlen(str) + 1);
+ fill_color_str = G_malloc(strlen(str) + 1);
- G_debug(3, "do_symbol() [%s]", buff);
+ G_debug(3, "do_symbol() [%s]", str);
/* set default colors so colors are optional */
strcpy(line_color_str, DEFAULT_FG_COLOR);
strcpy(fill_color_str, "grey");
if (sscanf
- (buff, "%*s %s %lf %lf %lf %s %s", symb_name, &size, &xper, &yper,
+ (str, "%*s %s %lf %lf %lf %s %s", symb_name, &size, &xper, &yper,
line_color_str, fill_color_str) < 4) {
- G_warning(_("Problem parsing command [%s]"), buff);
+ G_warning(_("Problem parsing command [%s]"), str);
return (-1);
}
Modified: grass/trunk/display/d.graph/local_proto.h
===================================================================
--- grass/trunk/display/d.graph/local_proto.h 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.graph/local_proto.h 2008-09-05 07:54:52 UTC (rev 33270)
@@ -5,17 +5,17 @@
/* do_graph.c */
int set_graph_stuff(void);
int set_text_size(void);
-int do_draw(char *);
-int do_move(char *);
-int do_linewidth(char *);
-int do_color(char *);
-int do_poly(char *, FILE *);
-int do_size(char *);
-int do_rotate(char *);
-int do_text(char *);
+int do_draw(const char *);
+int do_move(const char *);
+int do_linewidth(const char *);
+int do_color(const char *);
+int do_poly(const char *, FILE *);
+int do_size(const char *);
+int do_rotate(const char *);
+int do_text(const char *);
int check_alloc(int);
-int do_icon(char *);
-int do_symbol(char *);
+int do_icon(const char *);
+int do_symbol(const char *);
void set_last_color(int, int, int, int);
/* graphics.c */
Modified: grass/trunk/display/d.grid/plot.c
===================================================================
--- grass/trunk/display/d.grid/plot.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.grid/plot.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -52,7 +52,7 @@
y: End of text is 7 pixels up from bottom of screen, +.5 rounding.
fontsize*.81 = actual text width FOR DEFAULT FONT (NOT FreeType)
*/
- D_move_abs(x + 4.5 * D_get_d_to_u_xconv(),
+ D_pos_abs(x + 4.5 * D_get_d_to_u_xconv(),
D_get_u_south()
- D_get_d_to_u_yconv() * (strlen(text) * fontsize * 0.81) - 7.5);
@@ -95,7 +95,7 @@
fontsize*.81 = actual text width FOR DEFAULT FONT (NOT FreeType)
y: 4 pixels above each grid line, +.5 rounding.
*/
- D_move_abs(
+ D_pos_abs(
D_get_u_east()
- D_get_d_to_u_xconv() * (strlen(text) * fontsize * 0.81 - 7.5),
y + D_get_d_to_u_yconv() * 4.5);
@@ -210,8 +210,8 @@
G_format_northing(g, text, PROJECTION_LL);
R_text_rotation(font_angle);
R_text_size(fontsize, fontsize);
- D_move_abs(D_get_u_west() + D_get_d_to_u_xconv() * border_off,
- start_coord - D_get_d_to_u_yconv() * grid_off);
+ D_pos_abs(D_get_u_west() + D_get_d_to_u_xconv() * border_off,
+ start_coord - D_get_d_to_u_yconv() * grid_off);
R_text(text);
}
}
@@ -262,8 +262,8 @@
G_format_easting(g, text, PROJECTION_LL);
R_text_rotation(font_angle);
R_text_size(fontsize, fontsize);
- D_move_abs(start_coord + D_get_d_to_u_xconv() * (grid_off + 1.5),
- D_get_u_north() + D_get_d_to_u_yconv() * border_off);
+ D_pos_abs(start_coord + D_get_d_to_u_xconv() * (grid_off + 1.5),
+ D_get_u_north() + D_get_d_to_u_yconv() * border_off);
R_text(text);
}
}
Modified: grass/trunk/display/d.histogram/bar.c
===================================================================
--- grass/trunk/display/d.histogram/bar.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.histogram/bar.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -322,8 +322,8 @@
R_text_size(text_width, text_height);
D_get_text_box(txt, &tt, &tb, &tl, &tr);
}
- D_move_abs(xoffset + (i - dist_stats->mincat) * xscale - 0.5 * xscale - (tr - tl) / 2,
- b - XNUMS_Y * (b - t));
+ D_pos_abs(xoffset + (i - dist_stats->mincat) * xscale - 0.5 * xscale - (tr - tl) / 2,
+ b - XNUMS_Y * (b - t));
R_text(txt);
}
else if (rem(i, tic_unit) == 0.0) {
@@ -347,7 +347,7 @@
text_width = (r - l) * TEXT_WIDTH;
R_text_size(text_width, text_height);
D_get_text_box(xlabel, &tt, &tb, &tl, &tr);
- D_move_abs(l + (r - l) / 2 - (tr - tl) / 2,
+ D_pos_abs(l + (r - l) / 2 - (tr - tl) / 2,
b - LABEL_1 * (b - t));
D_use_color(color);
R_text(xlabel);
@@ -398,8 +398,8 @@
R_text_size(text_width, text_height);
D_get_text_box(txt, &tt, &tb, &tl, &tr);
}
- D_move_abs(l + (r - l) * YNUMS_X - (tr - tl) / 2,
- yoffset - (yscale * i + 0.5 * (tt - tb)));
+ D_pos_abs(l + (r - l) * YNUMS_X - (tr - tl) / 2,
+ yoffset - (yscale * i + 0.5 * (tt - tb)));
R_text(txt);
}
else if (rem(i, tic_unit) == 0.0) {
@@ -430,8 +430,8 @@
text_width = (r - l) * TEXT_WIDTH;
R_text_size(text_width, text_height);
D_get_text_box(ylabel, &tt, &tb, &tl, &tr);
- D_move_abs(l + (r - l) / 2 - (tr - tl) / 2,
- b - LABEL_2 * (b - t));
+ D_pos_abs(l + (r - l) / 2 - (tr - tl) / 2,
+ b - LABEL_2 * (b - t));
D_use_color(color);
R_text(ylabel);
Modified: grass/trunk/display/d.histogram/draw_slice.c
===================================================================
--- grass/trunk/display/d.histogram/draw_slice.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.histogram/draw_slice.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -77,7 +77,7 @@
D_get_text_box(txt, &tt, &tb, &tl, &tr);
lx = x[0] + (r + 0.03) * (width) * cos(arc / 57.296) - (tr - tl) / 2;
ly = y[0] - (r + 0.03) * (height) * sin(arc / 57.296) + (tb - tt) / 2;
- D_move_abs(lx, ly);
+ D_pos_abs(lx, ly);
D_use_color(txt_color);
R_text(txt);
}
Modified: grass/trunk/display/d.histogram/main.c
===================================================================
--- grass/trunk/display/d.histogram/main.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.histogram/main.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -200,8 +200,8 @@
text_width = (r - l) * 0.05 * 0.50;
R_text_size(text_width, text_height);
D_get_text_box(title, &tt, &tb, &tl, &tr);
- D_move_abs(l + (r - l) / 2 - (tr - tl) / 2,
- t + (b - t) * 0.07);
+ D_pos_abs(l + (r - l) / 2 - (tr - tl) / 2,
+ t + (b - t) * 0.07);
D_use_color(color);
R_text(title);
Modified: grass/trunk/display/d.histogram/pie.c
===================================================================
--- grass/trunk/display/d.histogram/pie.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.histogram/pie.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -351,11 +351,11 @@
R_text_size(text_width, text_height);
D_get_text_box(txt, &tt, &tb, &tl, &tr);
}
- D_move_abs(xoffset
- + (i - dist_stats->mincat) * xscale
- - 0.5 * xscale
- - (tr - tl) / 2,
- b - XNUMS_Y * height);
+ D_pos_abs(xoffset
+ + (i - dist_stats->mincat) * xscale
+ - 0.5 * xscale
+ - (tr - tl) / 2,
+ b - XNUMS_Y * height);
R_text(txt);
}
else if (rem(i, tic_unit) == 0.0) {
@@ -389,8 +389,8 @@
text_width = width * TEXT_WIDTH;
R_text_size(text_width, text_height);
D_get_text_box(xlabel, &tt, &tb, &tl, &tr);
- D_move_abs(l + width / 2 - (tr - tl) / 2,
- b - LABEL * height);
+ D_pos_abs(l + width / 2 - (tr - tl) / 2,
+ b - LABEL * height);
D_use_color(color);
R_text(xlabel);
Modified: grass/trunk/display/d.labels/do_labels.c
===================================================================
--- grass/trunk/display/d.labels/do_labels.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.labels/do_labels.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -236,7 +236,7 @@
G_debug(3, "line %d ='%s'", n_lines, line);
Y = north - (line_size * 1.2) - ((n_lines - 1) * line_size);
- D_move_abs(X, Y);
+ D_pos_abs(X, Y);
R_text_rotation(0.0); /* reset */
D_get_text_box(line, &t, &b, &l, &r);
@@ -371,22 +371,22 @@
for (j = 1; j <= highlight_width; j++) {
/* smear it around. probably a better way (knight's move? rand?) */
- D_move_abs(text_x + Xoffset, text_y + Yoffset + j);
+ D_pos_abs(text_x + Xoffset, text_y + Yoffset + j);
R_text(line);
- D_move_abs(text_x + Xoffset, text_y + Yoffset - j);
+ D_pos_abs(text_x + Xoffset, text_y + Yoffset - j);
R_text(line);
- D_move_abs(text_x + Xoffset + j, text_y + Yoffset);
+ D_pos_abs(text_x + Xoffset + j, text_y + Yoffset);
R_text(line);
- D_move_abs(text_x + Xoffset - j, text_y + Yoffset);
+ D_pos_abs(text_x + Xoffset - j, text_y + Yoffset);
R_text(line);
- D_move_abs(text_x + Xoffset + j, text_y + Yoffset + j);
+ D_pos_abs(text_x + Xoffset + j, text_y + Yoffset + j);
R_text(line);
- D_move_abs(text_x + Xoffset - j, text_y + Yoffset - j);
+ D_pos_abs(text_x + Xoffset - j, text_y + Yoffset - j);
R_text(line);
- D_move_abs(text_x + Xoffset + j, text_y + Yoffset - j);
+ D_pos_abs(text_x + Xoffset + j, text_y + Yoffset - j);
R_text(line);
- D_move_abs(text_x + Xoffset - j, text_y + Yoffset + j);
+ D_pos_abs(text_x + Xoffset - j, text_y + Yoffset + j);
R_text(line);
}
@@ -425,7 +425,7 @@
text_y = Y + Y_just_offset;
G_rotate_around_point(X, Y0, &text_x, &text_y, -1 * rotation);
- D_move_abs(text_x + Xoffset, text_y + Yoffset);
+ D_pos_abs(text_x + Xoffset, text_y + Yoffset);
R_text(line);
if ((*tptr == '\0') || (*tptr == NL))
Modified: grass/trunk/display/d.legend/main.c
===================================================================
--- grass/trunk/display/d.legend/main.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.legend/main.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -662,23 +662,23 @@
if (!horiz) {
if (!k) /* first */
- D_move_abs(x1 + 4, y0 + txsiz);
+ D_pos_abs(x1 + 4, y0 + txsiz);
else if (k == steps - 1) /* last */
- D_move_abs(x1 + 4, y1);
+ D_pos_abs(x1 + 4, y1);
else
- D_move_abs(x1 + 4, y0 + ppl * k + txsiz / 2);
+ D_pos_abs(x1 + 4, y0 + ppl * k + txsiz / 2);
}
else {
/* text width is 0.81 of text height? so even though we set width
to txsiz with R_text_size(), we still have to reduce.. hmmm */
if (!k) /* first */
- D_move_abs(x0 - (strlen(buff) * txsiz * .81 / 2),
+ D_pos_abs(x0 - (strlen(buff) * txsiz * .81 / 2),
y1 + 4 + txsiz);
else if (k == steps - 1) /* last */
- D_move_abs(x1 - (strlen(buff) * txsiz * .81 / 2),
+ D_pos_abs(x1 - (strlen(buff) * txsiz * .81 / 2),
y1 + 4 + txsiz);
else
- D_move_abs(x0 + ppl * k -
+ D_pos_abs(x0 + ppl * k -
(strlen(buff) * txsiz * .81 / 2),
y1 + 4 + txsiz);
}
@@ -726,7 +726,7 @@
r = x1;
b = y1;
- D_move_abs(x0, y0);
+ D_pos_abs(x0, y0);
/* figure out box height */
if (do_cats == cats_num)
@@ -832,7 +832,7 @@
D_d_color(catlist[catlistCount - i - 1], &colors);
}
- D_move_abs(l + 4, (cur_dot_row - 2));
+ D_pos_abs(l + 4, (cur_dot_row - 2));
D_polygon_rel(x_box, y_box, 5);
/* Draw text */
@@ -861,7 +861,7 @@
sprintf(buff, DispFormat, catlist[catlistCount - i - 1]);
}
- D_move_abs((l + 3 + dots_per_line), (cur_dot_row) - 3);
+ D_pos_abs((l + 3 + dots_per_line), (cur_dot_row) - 3);
R_text(buff);
}
@@ -883,7 +883,7 @@
R_text_size(txsiz, txsiz);
}
D_use_color(white);
- D_move_abs((l + 3 + dots_per_line), (cur_dot_row));
+ D_pos_abs((l + 3 + dots_per_line), (cur_dot_row));
R_text(buff);
}
}
Modified: grass/trunk/display/d.linegraph/main.c
===================================================================
--- grass/trunk/display/d.linegraph/main.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.linegraph/main.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -440,7 +440,7 @@
R_text_size(text_width, text_height);
D_get_text_box(txt, &tt, &tb, &tl, &tr);
}
- D_move_abs((xoffset + (line * xscale - (tr - tl) / 2)),
+ D_pos_abs((xoffset + (line * xscale - (tr - tl) / 2)),
(b - XNUMS_Y * (b - t)));
R_text(txt);
}
@@ -472,8 +472,8 @@
text_width = (r - l) * TEXT_WIDTH * 1.5;
R_text_size(text_width, text_height);
D_get_text_box(xlabel, &tt, &tb, &tl, &tr);
- D_move_abs((l + (r - l) / 2 - (tr - tl) / 2),
- (b - LABEL_1 * (b - t)));
+ D_pos_abs((l + (r - l) / 2 - (tr - tl) / 2),
+ (b - LABEL_1 * (b - t)));
D_use_color(title_color);
R_text(xlabel);
@@ -522,9 +522,8 @@
R_text_size(text_width, text_height);
D_get_text_box(txt, &tt, &tb, &tl, &tr);
}
- D_move_abs((l + (r - l) * YNUMS_X - (tr - tl) / 2),
- (yoffset -
- (yscale * (i - min_y) + 0.5 * (tt - tb))));
+ D_pos_abs(l + (r - l) * YNUMS_X - (tr - tl) / 2,
+ yoffset - (yscale * (i - min_y) + 0.5 * (tt - tb)));
R_text(txt);
}
else if (rem(i, tic_unit) == 0.0) {
@@ -546,8 +545,7 @@
text_width = (r - l) * TEXT_WIDTH * 1.5;
R_text_size(text_width, text_height);
D_get_text_box(xlabel, &tt, &tb, &tl, &tr);
- D_move_abs(l + (r - l) / 2 - (tr - tl) / 2,
- b - LABEL_2 * (b - t));
+ D_pos_abs(l + (r - l) / 2 - (tr - tl) / 2, b - LABEL_2 * (b - t));
D_use_color(title_color);
R_text(xlabel);
@@ -561,8 +559,7 @@
R_move_abs((int)(((r-l)/2)-(tr-tl)/2),
(int) (t+ (b-t)*.07) );
*/
- D_move_abs(l + (r - l) / 2 - (tr - tl) / 2,
- t + (b - t) * .07);
+ D_pos_abs(l + (r - l) / 2 - (tr - tl) / 2, t + (b - t) * .07);
D_use_color(title_color);
R_text(xlabel);
Modified: grass/trunk/display/d.profile/main.c
===================================================================
--- grass/trunk/display/d.profile/main.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.profile/main.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -105,13 +105,13 @@
/* plot y-axis label (bottom) */
sprintf(str, "%.1f", min);
D_get_text_box(str, &t, &b, &l, &r);
- D_move_abs(-0.02 - (r - l), 0 - (t - b) / 2);
+ D_pos_abs(-0.02 - (r - l), 0 - (t - b) / 2);
R_text(str);
/* plot y-axis label (top) */
sprintf(str, "%.1f", max);
D_get_text_box(str, &t, &b, &l, &r);
- D_move_abs(-0.02 - (r - l), 1 - (t - b) / 2);
+ D_pos_abs(-0.02 - (r - l), 1 - (t - b) / 2);
R_text(str);
}
Modified: grass/trunk/display/d.rast.num/main.c
===================================================================
--- grass/trunk/display/d.rast.num/main.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.rast.num/main.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -253,11 +253,11 @@
R_text_size(text_size, text_size);
- D_move_abs(col, row + 0.7);
+ D_pos_abs(col, row + 0.7);
D_get_text_box(no, &tt, &tb, &tl, &tr);
dx = (tr + tl) / 2 - (col + 0.5);
- D_move_abs(col - dx, row + 0.7);
+ D_pos_abs(col - dx, row + 0.7);
R_text(no);
return 0;
Modified: grass/trunk/display/d.text/main.c
===================================================================
--- grass/trunk/display/d.text/main.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.text/main.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -648,13 +648,13 @@
}
}
- D_move_abs(*x, *y);
+ D_pos_abs(*x, *y);
R_text(text);
if (bold) {
- D_move_abs(*x, *y + 1);
+ D_pos_abs(*x, *y + 1);
R_text(text);
- D_move_abs(*x + 1, *y);
+ D_pos_abs(*x + 1, *y);
R_text(text);
}
Modified: grass/trunk/display/d.vect/plot1.c
===================================================================
--- grass/trunk/display/d.vect/plot1.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.vect/plot1.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -388,14 +388,13 @@
if (!(color || fcolor || custom_rgb))
continue;
- x0 = D_u_to_d_col(x[0]);
- y0 = D_u_to_d_row(y[0]);
+ x0 = x[0];
+ y0 = y[0];
/* skip if the point is outside of the display window */
/* xy<0 tests make it go ever-so-slightly faster */
- if (x0 < 0 || y0 < 0 ||
- x0 > D_get_d_east() || x0 < D_get_d_west() ||
- y0 > D_get_d_south() || y0 < D_get_d_north())
+ if (x0 > D_get_u_east() || x0 < D_get_u_west() ||
+ y0 < D_get_u_south() || y0 > D_get_u_north())
continue;
/* use random or RGB column color if given, otherwise reset */
Modified: grass/trunk/display/d.vect/utils.c
===================================================================
--- grass/trunk/display/d.vect/utils.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/display/d.vect/utils.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -16,7 +16,7 @@
X = X + D_get_d_to_u_xconv() * 0.5 * lattr->size;
Y = Y + D_get_d_to_u_yconv() * 1.5 * lattr->size;
- D_move_abs(X, Y);
+ D_pos_abs(X, Y);
D_get_text_box(text, &T, &B, &L, &R);
/* Expand border 1/2 of text size */
@@ -56,7 +56,7 @@
D_RGB_color(lattr->color.R, lattr->color.G, lattr->color.B);
}
- D_move_abs(X + Xoffset, Y + Yoffset);
+ D_pos_abs(X + Xoffset, Y + Yoffset);
R_text(text);
}
Modified: grass/trunk/include/display.h
===================================================================
--- grass/trunk/include/display.h 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/include/display.h 2008-09-05 07:54:52 UTC (rev 33270)
@@ -81,6 +81,8 @@
void D_line_width(double);
void D_get_text_box(const char *, double *, double *, double *, double *);
+void D_pos_abs(double, double);
+void D_pos_rel(double, double);
void D_move_abs(double, double);
void D_move_rel(double, double);
void D_cont_abs(double, double);
Modified: grass/trunk/include/raster.h
===================================================================
--- grass/trunk/include/raster.h 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/include/raster.h 2008-09-05 07:54:52 UTC (rev 33270)
@@ -13,18 +13,12 @@
void R_line_width(double);
void R_erase(void);
-void R_move_abs(double, double);
-void R_move_rel(double, double);
-void R_cont_abs(double, double);
-void R_cont_rel(double, double);
+void R_pos_abs(double, double);
+void R_line_abs(double, double, double, double);
void R_polydots_abs(const double *, const double *, int);
-void R_polydots_rel(const double *, const double *, int);
void R_polyline_abs(const double *, const double *, int);
-void R_polyline_rel(const double *, const double *, int);
void R_polygon_abs(const double *, const double *, int);
-void R_polygon_rel(const double *, const double *, int);
void R_box_abs(double, double, double, double);
-void R_box_rel(double, double);
void R_text_size(double, double);
void R_text_rotation(double);
Modified: grass/trunk/lib/display/draw2.c
===================================================================
--- grass/trunk/lib/display/draw2.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/display/draw2.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -311,8 +311,7 @@
double x2 = D_u_to_d_col(b.x);
double y2 = D_u_to_d_row(b.y);
- R_move_abs(x1, y1);
- R_cont_abs(x2, y2);
+ R_line_abs(x1, y1, x2, y2);
}
return clipped;
@@ -678,8 +677,7 @@
x2 = D_u_to_d_col(x2);
y2 = D_u_to_d_row(y2);
- R_move_abs(x1, y1);
- R_cont_abs(x2, y2);
+ R_line_abs(x1, y1, x2, y2);
return 0;
}
@@ -715,12 +713,10 @@
x1 = D_u_to_d_col(x1);
y1 = D_u_to_d_row(y1);
- R_move_abs(x1, y1);
-
x2 = D_u_to_d_col(x2);
y2 = D_u_to_d_row(y2);
- R_cont_abs(x2, y2);
+ R_line_abs(x1, y1, x2, y2);
}
static void D_polydots_raw(const double *x, const double *y, int n)
@@ -1091,20 +1087,34 @@
/******************************************************************************/
-void D_move_abs(double x, double y)
+void D_pos_abs(double x, double y)
{
cur.x = x;
cur.y = y;
- if (in_path) {
- new_segment();
- new_point(x, y);
+ x = D_u_to_d_col(x);
+ y = D_u_to_d_row(y);
+
+ R_pos_abs(x, y);
+}
+
+void D_pos_rel(double x, double y)
+{
+ D_pos_abs(cur.x + x, cur.y + y);
+}
+
+void D_move_abs(double x, double y)
+{
+ if (!in_path) {
+ G_warning(_("D_move_abs() called while path not active"));
+ return;
}
- else {
- x = D_u_to_d_col(x);
- y = D_u_to_d_row(y);
- R_move_abs(x, y);
- }
+
+ new_segment();
+ new_point(x, y);
+
+ cur.x = x;
+ cur.y = y;
}
void D_move_rel(double x, double y)
@@ -1114,11 +1124,13 @@
void D_cont_abs(double x, double y)
{
- if (in_path)
- new_point(x, y);
- else
- (*fns->line)(cur.x, cur.y, x, y);
+ if (!in_path) {
+ G_warning(_("D_cont_abs() called while path not active"));
+ return;
+ }
+ new_point(x, y);
+
cur.x = x;
cur.y = y;
}
Modified: grass/trunk/lib/display/symbol.c
===================================================================
--- grass/trunk/lib/display/symbol.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/display/symbol.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -16,44 +16,23 @@
*****************************************************************************/
#include <grass/gis.h>
-#include <grass/raster.h>
+#include <grass/display.h>
#include <grass/symbol.h>
#include <grass/glocale.h>
-/*!
- * \brief draw a symbol at pixel coordinates
- *
- * Draws a symbol (one of $GISBASE/etc/symbols/) to the active display.
- * The starting x0,y0 coordinate corresponds to the center of the icon.
- * The symbol must be pre-processed with S_stroke() before being sent
- * to this function.
- *
- * example:
- * #include <grass/display.h>
- * #include <grass/symbol.h>
- * SYMBOL *Symb;
- * Symb = S_read( symbol_name );
- * S_stroke( Symb, size, rotation, tolerance );
- * D_symbol( Symb, x0, y0, line_color, fill_color );
- *
- * \param Symb The symbol name (e.g. basic/circle)
- * \param x0 The starting x display coordinate (pixel)
- * \param y0 The starting y display coordinate (pixel)
- * \param line_color Outline color
- * \param fill_color Fill color
- * \return void
- */
-
-void D_symbol(const SYMBOL * Symb, double x0, double y0,
- const RGBA_Color * line_color, const RGBA_Color * fill_color)
+static void symbol(const SYMBOL *Symb, double x0, double y0,
+ const RGBA_Color *fill_color,
+ const RGBA_Color *line_color,
+ const RGBA_Color *string_color)
{
int i, j, k;
const SYMBPART *part;
const SYMBCHAIN *chain;
double xp, yp;
double *x, *y;
+ double sx = D_get_d_to_u_xconv();
+ double sy = D_get_d_to_u_yconv();
-
G_debug(2, "D_symbol(): %d parts", Symb->count);
for (i = 0; i < Symb->count; i++) {
@@ -67,9 +46,9 @@
fill_color->a != RGBA_COLOR_NONE) ||
part->fcolor.color == S_COL_DEFINED) {
if (part->fcolor.color == S_COL_DEFAULT)
- R_RGB_color(fill_color->r, fill_color->g, fill_color->b);
+ D_RGB_color(fill_color->r, fill_color->g, fill_color->b);
else
- R_RGB_color(part->fcolor.r, part->fcolor.g,
+ D_RGB_color(part->fcolor.r, part->fcolor.g,
part->fcolor.b);
for (j = 0; j < part->count; j++) { /* for each component polygon */
@@ -79,10 +58,10 @@
y = G_malloc(sizeof(double) * chain->scount);
for (k = 0; k < chain->scount; k++) {
- x[k] = x0 + chain->sx[k];
- y[k] = y0 - chain->sy[k];
+ x[k] = x0 + sx * chain->sx[k];
+ y[k] = y0 - sy * chain->sy[k];
}
- R_polygon_abs(x, y, chain->scount);
+ D_polygon_abs(x, y, chain->scount);
G_free(x);
G_free(y);
@@ -93,23 +72,25 @@
if ((part->color.color == S_COL_DEFAULT &&
line_color->a != RGBA_COLOR_NONE) ||
part->color.color == S_COL_DEFINED) {
- if (part->color.color == S_COL_DEFAULT) {
- R_RGB_color(line_color->r, line_color->g, line_color->b);
- }
+ if (part->color.color == S_COL_DEFAULT)
+ D_RGB_color(line_color->r, line_color->g, line_color->b);
else
- R_RGB_color(part->color.r, part->color.g, part->color.b);
+ D_RGB_color(part->color.r, part->color.g, part->color.b);
for (j = 0; j < part->count; j++) {
chain = part->chain[j];
+ D_begin();
for (k = 0; k < chain->scount; k++) {
- xp = x0 + chain->sx[k];
- yp = y0 - chain->sy[k];
+ xp = x0 + sx * chain->sx[k];
+ yp = y0 - sy * chain->sy[k];
if (k == 0)
- R_move_abs(xp, yp);
+ D_move_abs(xp, yp);
else
- R_cont_abs(xp, yp);
+ D_cont_abs(xp, yp);
}
+ D_end();
+ D_stroke();
}
}
break;
@@ -118,28 +99,62 @@
if (part->color.color == S_COL_NONE)
break;
else if (part->color.color == S_COL_DEFAULT &&
- line_color->a != RGBA_COLOR_NONE)
- R_RGB_color(line_color->r, line_color->g, line_color->b);
+ string_color->a != RGBA_COLOR_NONE)
+ D_RGB_color(string_color->r, string_color->g, string_color->b);
else
- R_RGB_color(part->color.r, part->color.g, part->color.b);
+ D_RGB_color(part->color.r, part->color.g, part->color.b);
chain = part->chain[0];
+ D_begin();
for (j = 0; j < chain->scount; j++) {
- xp = x0 + chain->sx[j];
- yp = y0 - chain->sy[j];
+ xp = x0 + sx * chain->sx[j];
+ yp = y0 - sy * chain->sy[j];
if (j == 0)
- R_move_abs(xp, yp);
+ D_move_abs(xp, yp);
else
- R_cont_abs(xp, yp);
+ D_cont_abs(xp, yp);
}
+ D_end();
+ D_stroke();
break;
} /* switch */
} /* for loop */
}
+/*!
+ * \brief draw a symbol at pixel coordinates
+ *
+ * Draws a symbol (one of $GISBASE/etc/symbols/) to the active display.
+ * The starting x0,y0 coordinate corresponds to the center of the icon.
+ * The symbol must be pre-processed with S_stroke() before being sent
+ * to this function.
+ *
+ * example:
+ * #include <grass/display.h>
+ * #include <grass/symbol.h>
+ * SYMBOL *Symb;
+ * Symb = S_read( symbol_name );
+ * S_stroke( Symb, size, rotation, tolerance );
+ * D_symbol( Symb, x0, y0, line_color, fill_color );
+ *
+ * \param Symb The symbol name (e.g. basic/circle)
+ * \param x0 The starting x display coordinate (pixel)
+ * \param y0 The starting y display coordinate (pixel)
+ * \param line_color Outline color
+ * \param fill_color Fill color
+ * \return void
+ */
+void D_symbol(const SYMBOL *Symb, double x0, double y0,
+ const RGBA_Color *line_color,
+ const RGBA_Color *fill_color)
+{
+ symbol(Symb, x0, y0, fill_color, line_color, line_color);
+}
+
+
/*!
* \brief draw a symbol at pixel coordinates (alternate)
*
@@ -156,102 +171,9 @@
* \param secondary_color Secondary draw color
* \return void
*/
-void D_symbol2(const SYMBOL * Symb, double x0, double y0,
- const RGBA_Color * primary_color,
- const RGBA_Color * secondary_color)
+void D_symbol2(const SYMBOL *Symb, double x0, double y0,
+ const RGBA_Color *primary_color,
+ const RGBA_Color *secondary_color)
{
- /* TODO: merge duplicate D_symbol() code into common lib fns */
- int i, j, k;
- const SYMBPART *part;
- const SYMBCHAIN *chain;
- double xp, yp;
- double *x, *y;
-
-
- G_debug(2, "D_symbol(): %d parts", Symb->count);
-
- for (i = 0; i < Symb->count; i++) {
- part = Symb->part[i];
-
- switch (part->type) {
-
- case S_POLYGON:
- /* draw background fills */
- if ((part->fcolor.color == S_COL_DEFAULT &&
- primary_color->a != RGBA_COLOR_NONE) ||
- part->fcolor.color == S_COL_DEFINED) {
- if (part->fcolor.color == S_COL_DEFAULT)
- R_RGB_color(primary_color->r, primary_color->g,
- primary_color->b);
- else
- R_RGB_color(part->fcolor.r, part->fcolor.g,
- part->fcolor.b);
-
- for (j = 0; j < part->count; j++) { /* for each component polygon */
- chain = part->chain[j];
-
- x = G_malloc(sizeof(double) * chain->scount);
- y = G_malloc(sizeof(double) * chain->scount);
-
- for (k = 0; k < chain->scount; k++) {
- x[k] = x0 + chain->sx[k];
- y[k] = y0 - chain->sy[k];
- }
- R_polygon_abs(x, y, chain->scount);
-
- G_free(x);
- G_free(y);
- }
-
- }
- /* again, to draw the lines */
- if ((part->color.color == S_COL_DEFAULT &&
- secondary_color->a != RGBA_COLOR_NONE) ||
- part->color.color == S_COL_DEFINED) {
- if (part->color.color == S_COL_DEFAULT) {
- R_RGB_color(secondary_color->r, secondary_color->g,
- secondary_color->b);
- }
- else
- R_RGB_color(part->color.r, part->color.g, part->color.b);
-
- for (j = 0; j < part->count; j++) {
- chain = part->chain[j];
-
- for (k = 0; k < chain->scount; k++) {
- xp = x0 + chain->sx[k];
- yp = y0 - chain->sy[k];
- if (k == 0)
- R_move_abs(xp, yp);
- else
- R_cont_abs(xp, yp);
- }
- }
- }
- break;
-
- case S_STRING:
- if (part->color.color == S_COL_NONE)
- break;
- else if (part->color.color == S_COL_DEFAULT &&
- primary_color->a != RGBA_COLOR_NONE)
- R_RGB_color(primary_color->r, primary_color->g,
- primary_color->b);
- else
- R_RGB_color(part->color.r, part->color.g, part->color.b);
-
- chain = part->chain[0];
-
- for (j = 0; j < chain->scount; j++) {
- xp = x0 + chain->sx[j];
- yp = y0 - chain->sy[j];
- if (j == 0)
- R_move_abs(xp, yp);
- else
- R_cont_abs(xp, yp);
- }
- break;
-
- } /* switch */
- } /* for loop */
+ symbol(Symb, x0, y0, primary_color, secondary_color, primary_color);
}
Modified: grass/trunk/lib/driver/Box.c
===================================================================
--- grass/trunk/lib/driver/Box.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/Box.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -7,7 +7,3 @@
(*driver->Box)(x1, y1, x2, y2);
}
-void COM_Box_rel(double x, double y)
-{
- COM_Box_abs(cur_x, cur_y, cur_x + x, cur_y + y);
-}
Modified: grass/trunk/lib/driver/Cont.c
===================================================================
--- grass/trunk/lib/driver/Cont.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/Cont.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -1,14 +1,8 @@
#include "driver.h"
#include "driverlib.h"
-void COM_Cont_abs(double x, double y)
+void COM_Line_abs(double x1, double y1, double x2, double y2)
{
- DRV_draw_line(cur_x, cur_y, x, y);
- cur_x = x;
- cur_y = y;
+ DRV_draw_line(x1, y1, x2, y2);
}
-void COM_Cont_rel(double x, double y)
-{
- COM_Cont_abs(cur_x + x, cur_y + y);
-}
Modified: grass/trunk/lib/driver/Move.c
===================================================================
--- grass/trunk/lib/driver/Move.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/Move.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -1,14 +1,9 @@
#include "driver.h"
#include "driverlib.h"
-void COM_Move_abs(double x, double y)
+void COM_Pos_abs(double x, double y)
{
cur_x = x;
cur_y = y;
}
-void COM_Move_rel(double x, double y)
-{
- cur_x += x;
- cur_y += y;
-}
Modified: grass/trunk/lib/driver/Polydots.c
===================================================================
--- grass/trunk/lib/driver/Polydots.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/Polydots.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -10,18 +10,7 @@
return;
}
- for (i = 0; i < number; i++) {
- COM_Move_abs(xarray[i], yarray[i]);
- COM_Cont_rel(0, 0);
- }
+ for (i = 0; i < number; i++)
+ COM_Line_abs(xarray[i], yarray[i], xarray[i], yarray[i]);
}
-void COM_Polydots_rel(const double *xarray, const double *yarray, int number)
-{
- int i;
-
- for (i = 0; i < number; i++) {
- COM_Move_rel(xarray[i], yarray[i]);
- COM_Cont_rel(0, 0);
- }
-}
Modified: grass/trunk/lib/driver/Polygon.c
===================================================================
--- grass/trunk/lib/driver/Polygon.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/Polygon.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -9,25 +9,3 @@
(*driver->Polygon) (xarray, yarray, number);
}
-void COM_Polygon_rel(const double *xarray, const double *yarray, int number)
-{
- static double *xa, *ya;
- static int nalloc;
- int i;
-
- if (number > nalloc) {
- nalloc = number;
- xa = G_realloc(xa, (size_t) nalloc * sizeof(double));
- ya = G_realloc(ya, (size_t) nalloc * sizeof(double));
- }
-
- xa[0] = xarray[0] + cur_x;
- ya[0] = yarray[0] + cur_y;
-
- for (i = 1; i < number; i++) {
- xa[i] = xa[i - 1] + xarray[i];
- ya[i] = ya[i - 1] + yarray[i];
- }
-
- COM_Polygon_abs(xa, ya, number);
-}
Modified: grass/trunk/lib/driver/Polyline.c
===================================================================
--- grass/trunk/lib/driver/Polyline.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/Polyline.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -10,18 +10,7 @@
return;
}
- COM_Move_abs(xarray[0], yarray[0]);
-
for (i = 1; i < number; i++)
- COM_Cont_abs(xarray[i], yarray[i]);
+ COM_Line_abs(xarray[i-1], yarray[i-1], xarray[i], yarray[i]);
}
-void COM_Polyline_rel(const double *xarray, const double *yarray, int number)
-{
- int i;
-
- COM_Move_rel(xarray[0], yarray[0]);
-
- for (i = 1; i < number; i++)
- COM_Cont_rel(xarray[i], yarray[i]);
-}
Modified: grass/trunk/lib/driver/driver.h
===================================================================
--- grass/trunk/lib/driver/driver.h 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/driver.h 2008-09-05 07:54:52 UTC (rev 33270)
@@ -59,15 +59,13 @@
/* Box.c */
extern void COM_Box_abs(double, double, double, double);
-extern void COM_Box_rel(double, double);
/* Color.c */
extern void COM_Color_RGB(unsigned char, unsigned char, unsigned char);
extern void COM_Standard_color(int);
/* Cont.c */
-extern void COM_Cont_abs(double, double);
-extern void COM_Cont_rel(double, double);
+extern void COM_Line_abs(double, double, double, double);
/* Erase.c */
extern void COM_Erase(void);
@@ -89,20 +87,16 @@
extern void COM_Line_width(double);
/* Move.c */
-extern void COM_Move_abs(double, double);
-extern void COM_Move_rel(double, double);
+extern void COM_Pos_abs(double, double);
/* Polydots.c */
extern void COM_Polydots_abs(const double *, const double *, int);
-extern void COM_Polydots_rel(const double *, const double *, int);
/* Polygon.c */
extern void COM_Polygon_abs(const double *, const double *, int);
-extern void COM_Polygon_rel(const double *, const double *, int);
/* Polyline.c */
extern void COM_Polyline_abs(const double *, const double *, int);
-extern void COM_Polyline_rel(const double *, const double *, int);
/* Raster.c */
extern void COM_begin_scaled_raster(int, int[2][2], double[2][2]);
Modified: grass/trunk/lib/driver/driverlib.h
===================================================================
--- grass/trunk/lib/driver/driverlib.h 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/driverlib.h 2008-09-05 07:54:52 UTC (rev 33270)
@@ -14,14 +14,14 @@
/* Text2.c */
void drawchar(double, double, double, double, unsigned char);
-void soft_text_ext(int, int, double, double, double, const char *);
+void soft_text_ext(double, double, double, double, double, const char *);
void get_text_ext(double *, double *, double *, double *);
-void soft_text(int, int, double, double, double, const char *);
-void onechar(int, int, double, double, double, unsigned char);
+void soft_text(double, double, double, double, double, const char *);
+void onechar(double, double, double, double, double, unsigned char);
/* Text3.c */
-void soft_text_freetype(int, int, double, double, double, const char *);
-void soft_text_ext_freetype(int, int, double, double, double, const char *);
+void soft_text_freetype(double, double, double, double, double, const char *);
+void soft_text_ext_freetype(double, double, double, double, double, const char *);
void get_text_ext_freetype(double *, double *, double *, double *);
/* font2.c */
Modified: grass/trunk/lib/driver/text2.c
===================================================================
--- grass/trunk/lib/driver/text2.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/text2.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -4,22 +4,21 @@
#include "driver.h"
#include "driverlib.h"
-static int am_inside;
static int dont_draw;
-static int t, b, l, r;
+static double t, b, l, r;
static double basex, basey;
static double curx, cury;
static void remember(double x, double y)
{
- if ((int)x > r)
- r = (int)x;
- if ((int)x < l)
- l = (int)x;
- if ((int)y > b)
- b = (int)y;
- if ((int)y < t)
- t = (int)y;
+ if (x > r)
+ r = x;
+ if (x < l)
+ l = x;
+ if (y > b)
+ b = y;
+ if (y < t)
+ t = y;
curx = x;
cury = y;
@@ -27,32 +26,14 @@
static void text_draw(double x, double y)
{
- int X1 = (int)x;
- int Y1 = (int)y;
- int X2 = (int)curx;
- int Y2 = (int)cury;
+ COM_Line_abs(curx, cury, x, y);
- if (am_inside) {
- COM_Cont_abs(X1, Y1);
- }
- else {
- COM_Move_abs(X2, Y2);
- COM_Cont_abs(X1, Y1);
- am_inside = 1;
- }
-
curx = x;
cury = y;
}
static void text_move(double x, double y)
{
- int X1 = (int)x;
- int Y1 = (int)y;
-
- if (am_inside)
- COM_Move_abs(X1, Y1);
-
curx = x;
cury = y;
}
@@ -64,7 +45,7 @@
unsigned char *Y;
int n_vects;
int i;
- int ax, ay;
+ double ax, ay;
double x, y;
void (*Do) (double, double);
int ix, iy;
@@ -84,8 +65,8 @@
ix = 10 + X[i] - 'R';
iy = 10 - Y[i] + 'R';
- ax = (int)(text_size_x * (double)ix);
- ay = (int)(text_size_y * (double)iy);
+ ax = text_size_x * ix;
+ ay = text_size_y * iy;
if (dont_draw) {
remember(x + (ax * cosrot - ay * sinrot),
@@ -102,8 +83,9 @@
*/
ix = 20;
iy = 0;
- ax = (int)(text_size_x * (double)ix);
- ay = (int)(text_size_y * (double)iy);
+ ax = text_size_x * ix;
+ ay = text_size_y * iy;
+
if (!dont_draw)
text_move(basex + (ax * cosrot - ay * sinrot),
basey - (ax * sinrot + ay * cosrot));
@@ -112,7 +94,7 @@
basey - (ax * sinrot + ay * cosrot));
}
-void soft_text_ext(int x, int y,
+void soft_text_ext(double x, double y,
double text_size_x, double text_size_y,
double text_rotation, const char *string)
{
@@ -136,16 +118,15 @@
# define RpD ((2 * M_PI) / 360.) /* radians/degree */
# define D2R(d) (double)(d * RpD) /* degrees->radians */
-void soft_text(int x, int y,
+void soft_text(double x, double y,
double text_size_x, double text_size_y, double text_rotation,
const char *string)
{
double sinrot = sin(D2R(text_rotation));
double cosrot = cos(D2R(text_rotation));
- am_inside = 0;
- curx = basex = (double)x;
- cury = basey = (double)y;
+ curx = basex = x;
+ cury = basey = y;
while (*string) {
drawchar(text_size_x, text_size_y, sinrot, cosrot, *string++);
basex = curx;
@@ -153,15 +134,14 @@
}
}
-void onechar(int x, int y,
+void onechar(double x, double y,
double text_size_x, double text_size_y, double text_rotation,
unsigned char achar)
{
double sinrot = sin(D2R(text_rotation));
double cosrot = cos(D2R(text_rotation));
- am_inside = 0;
- curx = basex = (double)x;
- cury = basey = (double)y;
+ curx = basex = x;
+ cury = basey = y;
drawchar(text_size_x, text_size_y, sinrot, cosrot, achar);
}
Modified: grass/trunk/lib/driver/text3.c
===================================================================
--- grass/trunk/lib/driver/text3.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/driver/text3.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -38,7 +38,7 @@
#endif
static int fdont_draw = 0;
-static int ft, fb, fl, fr;
+static double ft, fb, fl, fr;
static const char *font_get_encoding(void)
{
@@ -47,7 +47,7 @@
return encoding;
}
-static void draw_main(int x, int y,
+static void draw_main(double x, double y,
double text_size_x, double text_size_y,
double text_rotation, const char *string)
{
@@ -246,10 +246,10 @@
int offset, i, j;
double x1, y1, x2, y2;
- x1 = (double)x;
- y1 = (double)y;
- x2 = x1 + (double)bw;
- y2 = y1 + (double)bh;
+ x1 = x;
+ y1 = y;
+ x2 = x1 + bw;
+ y2 = y1 + bh;
w = x2 - x1;
h = y2 - y1;
@@ -267,12 +267,12 @@
for (i = 0; i < w; i++)
buf[j * w + i] = sbuf[offset + j * bw + i];
- COM_Move_abs(x1, y1);
+ COM_Pos_abs(x1, y1);
DRV_draw_bitmap(w, h, 128, buf);
}
#endif
-void soft_text_freetype(int x, int y,
+void soft_text_freetype(double x, double y,
double text_size_x, double text_size_y,
double text_rotation, const char *string)
{
@@ -281,7 +281,7 @@
draw_main(x, y, text_size_x, text_size_y, text_rotation, string);
}
-void soft_text_ext_freetype(int x, int y,
+void soft_text_ext_freetype(double x, double y,
double text_size_x, double text_size_y,
double text_rotation, const char *string)
{
Modified: grass/trunk/lib/raster/raster.c
===================================================================
--- grass/trunk/lib/raster/raster.c 2008-09-05 07:43:35 UTC (rev 33269)
+++ grass/trunk/lib/raster/raster.c 2008-09-05 07:54:52 UTC (rev 33270)
@@ -156,32 +156,12 @@
* \return void
*/
-void R_move_abs(double x, double y)
+void R_pos_abs(double x, double y)
{
- COM_Move_abs(x, y);
+ COM_Pos_abs(x, y);
}
/*!
- * \brief move current location
- *
- * Shift the current screen location by the values in <b>dx</b> and <b>dy</b>:
- \code
- Newx = Oldx + dx;
- Newy = Oldy + dy;
- \endcode
- * Nothing is drawn on the screen.
- *
- * \param x dx
- * \param y dy
- * \return void
- */
-
-void R_move_rel(double x, double y)
-{
- COM_Move_rel(x, y);
-}
-
-/*!
* \brief draw line
*
* Draw a line using the current color, selected via <i>R_color</i>, from the
@@ -193,34 +173,12 @@
* \return void
*/
-void R_cont_abs(double x, double y)
+void R_line_abs(double x1, double y1, double x2, double y2)
{
- COM_Cont_abs(x, y);
+ COM_Line_abs(x1, y1, x2, y2);
}
/*!
- * \brief draw line
- *
- * Draw a line using the
- * current color, selected via <i>R_color</i>, from the current location to
- * the relative location specified by <b>x</b> and <b>y.</b> The current
- * location is updated:
- \code
- Newx = Oldx + x;
- Newy = Oldy + y;
- \endcode
- *
- * \param x
- * \param y
- * \return void
- */
-
-void R_cont_rel(double x, double y)
-{
- COM_Cont_rel(x, y);
-}
-
-/*!
* \brief draw a series of dots
*
* Pixels at the <b>num</b> absolute positions in the <b>x</b> and
@@ -239,26 +197,6 @@
}
/*!
- * \brief draw a series of dots
- *
- * Pixels at the <b>number</b> relative positions in the <b>x</b> and
- * <b>y</b> arrays are turned to the current color. The first position is
- * relative to the starting current location; the succeeding positions are then
- * relative to the previous position. The current location is updated to the
- * position of the last dot.
- *
- * \param xarray x
- * \param yarray y
- * \param number
- * \return void
- */
-
-void R_polydots_rel(const double *xarray, const double *yarray, int number)
-{
- COM_Polydots_rel(xarray, yarray, number);
-}
-
-/*!
* \brief draw an open polygon
*
* The <b>number</b> absolute positions in the <b>x</b> and <b>y</b>
@@ -280,28 +218,6 @@
}
/*!
- * \brief draw an open polygon
- *
- * The <b>number</b> relative positions in the <b>x</b> and <b>y</b>
- * arrays are used to generate a multisegment line (often curved). The first
- * position is relative to the starting current location; the succeeding
- * positions are then relative to the previous position. The current location is
- * updated to the position of the last point. This line is drawn with the current
- * color.
- * <b>Note.</b> No line is drawn between the last point and the first point.
- *
- * \param xarray x
- * \param yarray y
- * \param number
- * \return void
- */
-
-void R_polyline_rel(const double *xarray, const double *yarray, int number)
-{
- COM_Polyline_rel(xarray, yarray, number);
-}
-
-/*!
* \brief draw a closed polygon
*
* The <b>number</b> absolute positions in the <b>x</b> and <b>y</b> arrays
@@ -320,26 +236,6 @@
}
/*!
- * \brief draw a closed polygon
- *
- * The <b>number</b> relative positions in the <b>x</b> and <b>y</b>
- * arrays outline a closed polygon which is filled with the current color. The
- * first position is relative to the starting current location; the succeeding
- * positions are then relative to the previous position. The current location is
- * undefined afterwards.
- *
- * \param xarray x
- * \param yarray y
- * \param number
- * \return void
- */
-
-void R_polygon_rel(const double *xarray, const double *yarray, int number)
-{
- COM_Polygon_rel(xarray, yarray, number);
-}
-
-/*!
* \brief fill a box
*
* A box is drawn in the current color using the coordinates <b>x1,y1</b> and
@@ -358,25 +254,7 @@
COM_Box_abs(x1, y1, x2, y2);
}
-
/*!
- * \brief fill a box
- *
- * A box is drawn in the current color using the current location as one corner
- * and the current location plus <b>x</b> and <b>y</b> as the opposite corner
- * of the box. The current location is undefined afterwards.
- *
- * \param x
- * \param y
- * \return void
- */
-
-void R_box_rel(double x, double y)
-{
- COM_Box_rel(x, y);
-}
-
-/*!
* \brief set text size
*
* Sets text pixel width and height to <b>width</b> and <b>height.</b>
More information about the grass-commit
mailing list