[GRASS-SVN] r33261 - in grass/trunk: display/d.barscale display/d.colortable display/d.geodesic display/d.graph display/d.histogram display/d.legend display/d.linegraph display/d.profile display/d.rast.arrow display/d.rast.num display/d.rhumbline include lib/display

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 4 14:00:54 EDT 2008


Author: glynn
Date: 2008-09-04 14:00:54 -0400 (Thu, 04 Sep 2008)
New Revision: 33261

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.histogram/bar.c
   grass/trunk/display/d.histogram/pie.c
   grass/trunk/display/d.legend/main.c
   grass/trunk/display/d.linegraph/linegraph.h
   grass/trunk/display/d.linegraph/main.c
   grass/trunk/display/d.profile/main.c
   grass/trunk/display/d.rast.arrow/main.c
   grass/trunk/display/d.rast.num/main.c
   grass/trunk/display/d.rhumbline/plot.c
   grass/trunk/include/display.h
   grass/trunk/lib/display/draw2.c
Log:
Add, use D_begin, D_end, D_close, D_stroke, D_fill
Simplify handling of D_*_rel() functions
Fix bug in d.barscale


Modified: grass/trunk/display/d.barscale/draw_scale.c
===================================================================
--- grass/trunk/display/d.barscale/draw_scale.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.barscale/draw_scale.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -21,42 +21,41 @@
 } all_scales[2][NUMSCALES] = {
     {
 	/* meters */
-	{
-	"", 0., 2., 10}, {
-	"1 meter", 1., 7., 10}, {
-	"5 meters", 5., 20., 5}, {
-	"10 meters", 10., 70., 10}, {
-	"50 meters", 50., 200., 5}, {
-	"100 meters", 100., 700., 10}, {
-	"500 meters", 500., 2000., 5}, {
-	"1 km", 1000., 7000., 10}, {
-	"5 km", 5000., 20000., 5}, {
-	"10 km", 10000., 70000., 10}, {
-	"50 km", 50000., 200000., 5}, {
-	"100 km", 100000., 700000., 10}, {
-	"500 km", 500000., 2000000., 5}, {
-	"1000 km", 1000000., 7000000., 10}, {
-	"5000 km", 5000000., 20000000., 5}, {
-	"10000 km", 10000000., 70000000., 10}
-    }, {
-	/* feet/miles */
-	{
-	"", 0.000, 1., 10}, {
-	"1 foot", 0.305, 2., 10}, {
-	"5 feet", 1.524, 10., 5}, {
-	"10 feet", 3.048, 20., 10}, {
-	"50 feet", 15.240, 100., 5}, {
-	"100 feet", 30.480, 200., 10}, {
-	"500 feet", 152.400, 1000., 5}, {
-	"1000 feet", 304.800, 2000., 10}, {
-	"1 mile", 1609.344, 10000., 5}, {
-	"5 miles", 8046.720, 20000., 5}, {
-	"10 miles", 16093.440, 100000., 10}, {
-	"50 miles", 80467.200, 200000., 5}, {
-	"100 miles", 160934.400, 1000000., 10}, {
-	"500 miles", 804672.000, 2000000., 5}, {
-	"1000 miles", 1609344.000, 10000000., 10}, {
-    "5000 miles", 8046720.000, 20000000., 5},}
+	{"", 0., 2., 10},
+	{"1 meter", 1., 7., 10},
+	{"5 meters", 5., 20., 5},
+	{"10 meters", 10., 70., 10},
+	{"50 meters", 50., 200., 5},
+	{"100 meters", 100., 700., 10},
+	{"500 meters", 500., 2000., 5},
+	{"1 km", 1000., 7000., 10},
+	{"5 km", 5000., 20000., 5},
+	{"10 km", 10000., 70000., 10},
+	{"50 km", 50000., 200000., 5},
+	{"100 km", 100000., 700000., 10},
+	{"500 km", 500000., 2000000., 5},
+	{"1000 km", 1000000., 7000000., 10},
+	{"5000 km", 5000000., 20000000., 5},
+	{"10000 km", 10000000., 70000000., 10}
+    },
+    {/* feet/miles */
+	{"", 0.000, 1., 10},
+	{"1 foot", 0.305, 2., 10},
+	{"5 feet", 1.524, 10., 5},
+	{"10 feet", 3.048, 20., 10},
+	{"50 feet", 15.240, 100., 5},
+	{"100 feet", 30.480, 200., 10},
+	{"500 feet", 152.400, 1000., 5},
+	{"1000 feet", 304.800, 2000., 10},
+	{"1 mile", 1609.344, 10000., 5},
+	{"5 miles", 8046.720, 20000., 5},
+	{"10 miles", 16093.440, 100000., 10},
+	{"50 miles", 80467.200, 200000., 5},
+	{"100 miles", 160934.400, 1000000., 10},
+	{"500 miles", 804672.000, 2000000., 5},
+	{"1000 miles", 1609344.000, 10000000., 10},
+	{"5000 miles", 8046720.000, 20000000., 5},
+    }
 };
 
 int draw_scale(int toptext)
@@ -101,16 +100,21 @@
 	/* Draw legend */
 	D_use_color(color2);
 
+	D_begin();
+
 	D_move_abs(pl + w / 2 + 1, pt + 17 + 1);
 	D_cont_rel(-0.5 * w,  2.0 * w);
 	D_cont_rel( 0.5 * w, -0.5 * w);
-	D_cont_rel( 0      , -1.5 * w);
+	D_close();
 
 	D_move_abs(pl + w / 2 + 1, pt + 17 + 1);
 	D_cont_rel( 0.5 * w,  2.0 * w);
 	D_cont_rel(-0.5 * w, -0.5 * w);
-	D_cont_rel( 0      , -1.5 * w);
+	D_close();
 
+	D_end();
+	D_stroke();
+
 	/* actual text width is 81% of size? from d.legend */
 	D_move_abs(pl + w / 2 - 7 * .81, pt + 14);
 	R_text("N");
@@ -118,6 +122,8 @@
 	return 0;
     }
 
+    D_setup(0);
+
     meters = D_get_u_east() - D_get_u_west();
     meters *= G_database_units_to_meters_factor();
 
@@ -136,6 +142,8 @@
     /* work around round off */
     line_len = ((int)seg_len) * scales[incr].seg;
 
+    D_setup_unity(0);
+
     /* Blank out area with background color */
     if (toptext) {
 	pr = x_pos + 35 + (int)line_len;
@@ -168,6 +176,7 @@
     D_use_color(color2);
 
     if (draw != 2) {
+	D_begin();
 	D_move_abs(x_pos + 5, y_pos + 20);
 	D_cont_rel(0, -10);
 	D_cont_rel(10, 10);
@@ -178,15 +187,21 @@
 	D_cont_rel(2, -2);
 	D_cont_rel(2, 2);
 	D_cont_rel(-2, -0);
+	D_end();
+	D_stroke();
     }
 
     if (draw == 2) {
+	D_begin();
 	D_move_abs(x_pos + 25 - draw * 10, y_pos + 17);
 	/* actual width is line_len-1+1=line_len and height is 7+1=8 */
 	D_cont_rel(line_len - 1, 0);
 	D_cont_rel(0, -7);
 	D_cont_rel(line_len * -1 + 1, 0);
 	D_cont_rel(0, 7);
+	D_end();
+	D_stroke();
+
 	D_move_rel(0, 1 - 4);
 	for (i = 1; i <= scales[incr].seg; i++) {
 	    xarr[0] = 0;	    yarr[0] = 0;
@@ -200,12 +215,16 @@
 	}
     }
     else if (do_bar) {
+	D_begin();
 	D_move_abs(x_pos + 25, y_pos + 17);
 	/* actual width is line_len-1+1=line_len and height is 4+1=5 */
 	D_cont_rel((int)line_len - 1, 0);
 	D_cont_rel(0, -4);
 	D_cont_rel((int)(line_len * -1 + 1), 0);
 	D_cont_rel(0, 4);
+	D_end();
+	D_stroke();
+
 	D_move_rel(0, 1);
 	for (i = 1; i <= scales[incr].seg; i += 2) {
 	    /* width is seg_len and height is 5 */
@@ -214,12 +233,15 @@
 	}
     }
     else {			/* draw simple line scale */
+	D_begin();
 	D_move_abs(x_pos + 25, y_pos + 5);
 	D_cont_abs(x_pos + 25, y_pos + 25);
 	D_move_abs(x_pos + 25, y_pos + 15);
 	D_cont_abs(x_pos + 25 + line_len, y_pos + 15);
 	D_move_abs(x_pos + 25 + line_len, y_pos + 5);
 	D_cont_abs(x_pos + 25 + line_len, y_pos + 25);
+	D_end();
+	D_stroke();
     }
 
     if (toptext) {

Modified: grass/trunk/display/d.colortable/main.c
===================================================================
--- grass/trunk/display/d.colortable/main.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.colortable/main.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -183,18 +183,24 @@
 		cur_dot_row += dots_per_line;
 		/* Draw white box */
 		D_use_color(color);
+		D_begin();
 		D_move_abs(cur_dot_col + 2, (cur_dot_row - 1));
 		D_cont_rel(0, (2 - dots_per_line));
 		D_cont_rel((dots_per_col - 2), 0);
 		D_cont_rel(0, (dots_per_line - 2));
 		D_cont_rel((2 - dots_per_col), 0);
+		D_end();
+		D_stroke();
 		/* Draw black box */
 		D_use_color(black);
+		D_begin();
 		D_move_abs(cur_dot_col + 3, (cur_dot_row - 2));
 		D_cont_rel(0, (4 - dots_per_line));
 		D_cont_rel((dots_per_col - 4), 0);
 		D_cont_rel(0, (dots_per_line - 4));
 		D_cont_rel((4 - dots_per_col), 0);
+		D_end();
+		D_stroke();
 		/* Color box */
 		D_color((CELL) atcat, &colors);
 		D_move_abs(cur_dot_col + 4, (cur_dot_row - 3));
@@ -217,18 +223,24 @@
 	cur_dot_col = l;
 	/* Draw white box */
 	D_use_color(color);
+	D_begin();
 	D_move_abs(cur_dot_col + 2, (cur_dot_row - 1));
 	D_cont_rel(0, (2 - dots_per_line));
 	D_cont_rel((dots_per_col - 2), 0);
 	D_cont_rel(0, (dots_per_line - 2));
 	D_cont_rel((2 - dots_per_col), 0);
+	D_end();
+	D_stroke();
 	/* Draw black box */
 	D_use_color(black);
+	D_begin();
 	D_move_abs(cur_dot_col + 3, (cur_dot_row - 2));
 	D_cont_rel(0, (4 - dots_per_line));
 	D_cont_rel((dots_per_col - 4), 0);
 	D_cont_rel(0, (dots_per_line - 4));
 	D_cont_rel((4 - dots_per_col), 0);
+	D_end();
+	D_stroke();
 	/* Color ramp box */
 
 	/* get separate color for each pixel */

Modified: grass/trunk/display/d.geodesic/plot.c
===================================================================
--- grass/trunk/display/d.geodesic/plot.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.geodesic/plot.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -29,6 +29,8 @@
     if (lon1 != lon2) {
 	G_begin_geodesic_equation(lon1, lat1, lon2, lat2);
 
+	D_begin();
+
 	for (i = 0; i <= nsteps; i++) {
 	    double lon = lon1 + (lon2 - lon1) * i / nsteps;
 	    double lat = G_geodesic_lat_from_lon(lon);
@@ -38,6 +40,9 @@
 		D_cont_abs(lon, lat);
 	}
 
+	D_end();
+	D_stroke();
+
 	text_x = (lon1 + lon2) / 2;
 	text_y = G_geodesic_lat_from_lon(text_x);
     }

Modified: grass/trunk/display/d.graph/do_graph.c
===================================================================
--- grass/trunk/display/d.graph/do_graph.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.graph/do_graph.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -264,7 +264,9 @@
     iy = yper;
     size *= yincr;
 
-    switch (type & 0177) {
+    D_begin();
+
+    switch (type & 0x7F) {
     case 'o':
 	D_move_abs(ix - size, iy - size);
 	D_cont_abs(ix - size, iy + size);
@@ -286,6 +288,10 @@
 	D_cont_abs(ix + size, iy);
 	break;
     }
+
+    D_end();
+    D_stroke();
+
     return (0);
 }
 

Modified: grass/trunk/display/d.histogram/bar.c
===================================================================
--- grass/trunk/display/d.histogram/bar.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.histogram/bar.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -217,10 +217,8 @@
 			G_get_ith_d_raster_cat(&cats, bar_color,
 					       &dmin, &dmax);
 		    else {
-			dmin = range_dmin + (double)i *
-			    (range_dmax - range_dmin) / (double)nsteps;
-			dmax = range_dmin + (double)(i + 1) *
-			    (range_dmax - range_dmin) / (double)nsteps;
+			dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
+			dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
 		    }
 		    if (dmin != dmax) {
 			for (j = 0; j < xscale; j++) {
@@ -272,10 +270,8 @@
 			G_get_ith_d_raster_cat(&cats, bar_color,
 					       &dmin, &dmax);
 		    else {
-			dmin = range_dmin + (double)i *
-			    (range_dmax - range_dmin) / (double)nsteps;
-			dmax = range_dmin + (double)(i + 1) *
-			    (range_dmax - range_dmin) / (double)nsteps;
+			dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
+			dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
 		    }
 		    D_d_color(dmin, colors);
 		}
@@ -285,8 +281,7 @@
 		    xoffset + (i - dist_stats->mincat) * xscale;
 		y_box[0] = yoffset;
 		y_box[1] = bar_height;
-		D_move_abs(x_box[0], y_box[0]);
-		D_cont_abs(x_box[1], y_box[1]);
+		D_line_abs(x_box[0], y_box[0], x_box[1], y_box[1]);
 	    }
 	}
 
@@ -297,11 +292,16 @@
 	if (((rem((long int)i, tic_every) == 0L) ||
 	     ((i == dist_stats->mincat) && nodata))
 	    && !(nodata && i == dist_stats->mincat + 1)) {
+
 	    /* draw a numbered tic-mark */
 	    D_use_color(color);
+	    D_begin();
 	    D_move_abs(xoffset + (i - dist_stats->mincat) * xscale - 0.5 * xscale,
 		       b - ORIGIN_Y * (b - t));
 	    D_cont_rel(0, BIG_TIC * (b - t));
+	    D_end();
+	    D_stroke();
+
 	    if (nodata && i == dist_stats->mincat)
 		sprintf(txt, "null");
 	    else if (is_fp) {
@@ -326,12 +326,15 @@
 		       b - XNUMS_Y * (b - t));
 	    R_text(txt);
 	}
-	else if (rem(i, tic_unit) == (float)0) {
+	else if (rem(i, tic_unit) == 0.0) {
 	    /* draw a tic-mark */
 	    D_use_color(color);
+	    D_begin();
 	    D_move_abs(xoffset + (i - dist_stats->mincat) * xscale - 0.5 * xscale,
 		       b - ORIGIN_Y * (b - t));
 	    D_cont_rel(0, SMALL_TIC * (b - t));
+	    D_end();
+	    D_stroke();
 	}
     }
 
@@ -377,8 +380,11 @@
     for (i = stat_start; i <= stat_finis; i += tic_unit) {
 	if (rem(i, tic_every) == (float)0) {
 	    /* draw a tic-mark */
+	    D_begin();
 	    D_move_abs(x_line[0], yoffset - yscale * i);
 	    D_cont_rel((-(r - l) * BIG_TIC), 0);
+	    D_end();
+	    D_stroke();
 
 	    /* draw a tic-mark number */
 	    sprintf(txt, "%d", (int)(i / tic_unit));
@@ -396,10 +402,13 @@
 		       yoffset - (yscale * i + 0.5 * (tt - tb)));
 	    R_text(txt);
 	}
-	else if (rem(i, tic_unit) == (float)0) {
+	else if (rem(i, tic_unit) == 0.0) {
 	    /* draw a tic-mark */
+	    D_begin();
 	    D_move_abs(x_line[0], yoffset - yscale * i);
 	    D_cont_rel(-(r - l) * SMALL_TIC, 0);
+	    D_end();
+	    D_stroke();
 	}
     }
 

Modified: grass/trunk/display/d.histogram/pie.c
===================================================================
--- grass/trunk/display/d.histogram/pie.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.histogram/pie.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -76,10 +76,10 @@
     /* create legend box border, to be drawn later */
     height = b - t;
     width = r - l;
-    x_line[4] = x_line[0] = x_line[1] = l + (int)(BAR_X1 * width);
-    y_line[4] = y_line[0] = y_line[3] = b - (int)(BAR_Y1 * height);
-    x_line[2] = x_line[3] = l + (int)(BAR_X2 * width);
-    bar_height = y_line[1] = y_line[2] = b - (int)(BAR_Y2 * height);
+    x_line[4] = x_line[0] = x_line[1] = l + (BAR_X1 * width);
+    y_line[4] = y_line[0] = y_line[3] = b - (BAR_Y1 * height);
+    x_line[2] = x_line[3] = l + (BAR_X2 * width);
+    bar_height = y_line[1] = y_line[2] = b - (BAR_Y2 * height);
 
     /* figure scaling factors and offsets */
     num_cats = dist_stats->maxcat - dist_stats->mincat + 1;
@@ -145,8 +145,8 @@
     ptr = dist_stats->ptr;
     arc_counter = 0;
     for (i = dist_stats->mincat; i <= dist_stats->maxcat; i++) {
-	text_height = (height) * 0.7 * TEXT_HEIGHT;
-	text_width = (width) * 0.7 * TEXT_WIDTH;
+	text_height = height * 0.7 * TEXT_HEIGHT;
+	text_width = width * 0.7 * TEXT_WIDTH;
 	R_text_size(text_width, text_height);
 	draw = NO;
 	/* figure color and height of the slice of pie 
@@ -166,14 +166,14 @@
 	    else {
 		draw = YES;
 		G_set_d_null_value(&dval, 1);
-		arc = (double)360 *((double)dist_stats->null_stat
+		arc = 360.0 *((double)dist_stats->null_stat
 				    / (double)dist_stats->sumstat);
-		draw_slice_filled(colors, dval, (int)color, (double)ORIGIN_X,
-				  (double)ORIGIN_Y, (double)RADIUS,
+		draw_slice_filled(colors, dval, color, ORIGIN_X,
+				  ORIGIN_Y, RADIUS,
 				  arc_counter, arc);
 		/*OUTLINE THE SLICE
-		   draw_slice_unfilled(colors, (int)color,(double)ORIGIN_X,(double)ORIGIN_Y,
-		   (double)RADIUS,arc_counter,arc); */
+		   draw_slice_unfilled(colors, color,ORIGIN_X,ORIGIN_Y,
+		   RADIUS,arc_counter,arc); */
 		arc_counter += arc;
 		D_d_color(dval, colors);
 	    }
@@ -187,36 +187,25 @@
 		    if (cat_ranges)
 			G_get_ith_d_raster_cat(&cats, (CELL) i, &dmin, &dmax);
 		    else {
-			dmin =
-			    range_dmin + (double)i *(range_dmax -
-						     range_dmin) /
-			    (double)nsteps;
-			dmax =
-			    range_dmin + (double)(i + 1) * (range_dmax -
-							    range_dmin) /
-			    (double)nsteps;
+			dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
+			dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
 		    }
-		    arc =
-			(double)360 *((double)ptr->stat /
-				      (double)dist_stats->sumstat);
-		    draw_slice(colors, 1, dmin, dmax, (int)color,
-			       (double)ORIGIN_X, (double)ORIGIN_Y,
-			       (double)RADIUS, arc_counter, arc);
+		    arc = 360.0 * ptr->stat / dist_stats->sumstat;
+		    draw_slice(colors, 1, dmin, dmax, color, ORIGIN_X, ORIGIN_Y,
+			       RADIUS, arc_counter, arc);
 		    arc_counter += arc;
 		    D_d_color(dmin, colors);
 		    /*OUTLINE THE SLICE */
-		    draw_slice_unfilled(colors, (int)color, (double)ORIGIN_X,
-					(double)ORIGIN_Y, (double)RADIUS,
+		    draw_slice_unfilled(colors, color, ORIGIN_X,
+					ORIGIN_Y, RADIUS,
 					arc_counter, arc);
 		}
 		else {
 		    bar_color = ptr->cat;
-		    arc =
-			(double)360 *((double)ptr->stat /
-				      (double)dist_stats->sumstat);
-		    draw_slice_filled(colors, (DCELL) bar_color, (int)color,
-				      (double)ORIGIN_X, (double)ORIGIN_Y,
-				      (double)RADIUS, arc_counter, arc);
+		    arc = 360.0 * ptr->stat / dist_stats->sumstat;
+		    draw_slice_filled(colors, (DCELL) bar_color, color,
+				      ORIGIN_X, ORIGIN_Y,
+				      RADIUS, arc_counter, arc);
 		    D_color((CELL) bar_color, colors);
 		    arc_counter += arc;
 		}
@@ -236,40 +225,29 @@
 		    draw = YES;
 		    if (is_fp) {
 			if (cat_ranges)
-			    G_get_ith_d_raster_cat(&cats, (CELL) i, &dmin,
-						   &dmax);
+			    G_get_ith_d_raster_cat(&cats, (CELL) i, &dmin, &dmax);
 			else {
-			    dmin =
-				range_dmin + (double)i *(range_dmax -
-							 range_dmin) /
-				(double)nsteps;
-			    dmax =
-				range_dmin + (double)(i + 1) * (range_dmax -
-								range_dmin) /
-				(double)nsteps;
+			    dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
+			    dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
 			}
-			arc =
-			    (double)360 *((double)ptr->stat /
-					  (double)dist_stats->sumstat);
-			draw_slice(colors, 1, dmin, dmax, (int)color,
-				   (double)ORIGIN_X, (double)ORIGIN_Y,
-				   (double)RADIUS, arc_counter, arc);
+			arc = 360.0 * ptr->stat / dist_stats->sumstat;
+			draw_slice(colors, 1, dmin, dmax, color,
+				   ORIGIN_X, ORIGIN_Y,
+				   RADIUS, arc_counter, arc);
 			arc_counter += arc;
 			/*OUTLINE THE SLICE */
-			draw_slice_unfilled(colors, (int)color,
-					    (double)ORIGIN_X,
-					    (double)ORIGIN_Y, (double)RADIUS,
+			draw_slice_unfilled(colors, color,
+					    ORIGIN_X,
+					    ORIGIN_Y, RADIUS,
 					    arc_counter, arc);
 			D_d_color(dmin, colors);
 		    }
 		    else {
 			bar_color = ptr->cat;
-			arc =
-			    (double)360 *((double)ptr->stat /
-					  (double)dist_stats->sumstat);
+			arc = 360.0 * ptr->stat / dist_stats->sumstat;
 			draw_slice_filled(colors, (DCELL) bar_color,
-					  (int)color, (double)ORIGIN_X,
-					  (double)ORIGIN_Y, (double)RADIUS,
+					  color, ORIGIN_X,
+					  ORIGIN_Y, RADIUS,
 					  arc_counter, arc);
 			D_color((CELL) bar_color, colors);
 			arc_counter += arc;
@@ -334,8 +312,7 @@
 		    xoffset + (i - dist_stats->mincat) * xscale;
 		y_box[0] = yoffset;
 		y_box[1] = bar_height;
-		D_move_abs((int)x_box[0], (int)y_box[0]);
-		D_cont_abs((int)x_box[1], (int)y_box[1]);
+		D_line_abs(x_box[0], y_box[0], x_box[1], y_box[1]);
 	    }
 	}
 
@@ -346,20 +323,26 @@
 	if ((rem((long int)i, tic_every) == 0L ||
 	     ((i == dist_stats->mincat) && nodata))
 	    && !(nodata && i == dist_stats->mincat + 1)) {
+
 	    /* draw a numbered tic-mark */
 	    D_use_color(color);
-	    D_move_abs((int)
-		       (xoffset + (i - dist_stats->mincat) * xscale -
-			0.5 * xscale), (int)(b - BAR_Y1 * (height)));
-	    D_cont_rel((int)0, (int)(BIG_TIC * (height)));
+	    D_begin();
+	    D_move_abs(xoffset
+		       + (i - dist_stats->mincat) * xscale
+		       - 0.5 * xscale,
+		       b - BAR_Y1 * height);
+	    D_cont_rel(0, BIG_TIC * height);
+	    D_end();
+	    D_stroke();
+
 	    if (nodata && i == dist_stats->mincat)
 		sprintf(txt, "null");
 	    else if (is_fp)
 		sprintf(txt, "%d", (int)(dmin / (double)tic_unit));
 	    else
 		sprintf(txt, "%d", (int)(i / tic_unit));
-	    text_height = (height) * TEXT_HEIGHT;
-	    text_width = (width) * TEXT_WIDTH;
+	    text_height = height * TEXT_HEIGHT;
+	    text_width = width * TEXT_WIDTH;
 	    R_text_size(text_width, text_height);
 	    D_get_text_box(txt, &tt, &tb, &tl, &tr);
 	    while ((tr - tl) > XTIC_DIST) {
@@ -368,30 +351,33 @@
 		R_text_size(text_width, text_height);
 		D_get_text_box(txt, &tt, &tb, &tl, &tr);
 	    }
-	    D_move_abs((int)
-		       (xoffset + (i - dist_stats->mincat) * xscale -
-			0.5 * xscale - (tr - tl) / 2),
-		       (int)(b - XNUMS_Y * (height)));
+	    D_move_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) == (float)0) {
+	else if (rem(i, tic_unit) == 0.0) {
 	    /* draw a tic-mark */
-	    D_use_color((int)color);
-	    D_move_abs((int)
-		       (xoffset + (i - dist_stats->mincat) * xscale -
-			0.5 * xscale), (int)(b - BAR_Y1 * (height)));
-	    D_cont_rel((int)0, (int)(SMALL_TIC * (height)));
+	    D_use_color(color);
+	    D_begin();
+	    D_move_abs(xoffset
+		       + (i - dist_stats->mincat) * xscale
+		       - 0.5 * xscale,
+		       b - BAR_Y1 * height);
+	    D_cont_rel(0, SMALL_TIC * height);
+	    D_end();
+	    D_stroke();
 	}
     }
 
     /* draw border around pie */
-    D_use_color((int)color);
-    draw_slice_unfilled(colors, (int)color, (double)ORIGIN_X,
-			(double)ORIGIN_Y, (double)RADIUS, (double)0,
-			(double)360);
+    D_use_color(color);
+    draw_slice_unfilled(colors, color, ORIGIN_X, ORIGIN_Y, RADIUS, 0.0, 360.0);
 
     /* draw border around legend bar */
-    D_use_color((int)color);
+    D_use_color(color);
     D_polyline_abs(x_line, y_line, 5);
 
     /* draw the x-axis label */
@@ -399,13 +385,13 @@
 	sprintf(xlabel, "Cell Values %s", tic_name);
     else
 	sprintf(xlabel, "Cell Values");
-    text_height = (height) * TEXT_HEIGHT;
-    text_width = (width) * TEXT_WIDTH;
+    text_height = height * TEXT_HEIGHT;
+    text_width = width * TEXT_WIDTH;
     R_text_size(text_width, text_height);
     D_get_text_box(xlabel, &tt, &tb, &tl, &tr);
-    D_move_abs((int)(l + (width) / 2 - (tr - tl) / 2),
-	       (int)(b - LABEL * (height)));
-    D_use_color((int)color);
+    D_move_abs(l + width / 2 - (tr - tl) / 2,
+	       b - LABEL * height);
+    D_use_color(color);
     R_text(xlabel);
 
     return 0;

Modified: grass/trunk/display/d.legend/main.c
===================================================================
--- grass/trunk/display/d.legend/main.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.legend/main.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -692,19 +692,25 @@
 
 	/* Black box */
 	D_use_color(black);
+	D_begin();
 	D_move_abs(x0 + 1, y0 + 1);
 	D_cont_rel(0, lleg - 2);
 	D_cont_rel(wleg - 2, 0);
 	D_cont_rel(0, 2 - lleg);
-	D_cont_rel(2 - wleg, 0);
+	D_close();
+	D_end();
+	D_stroke();
 
 	/* White box */
 	D_use_color(white);
+	D_begin();
 	D_move_abs(x0, y0);
 	D_cont_rel(0, lleg);
 	D_cont_rel(wleg, 0);
 	D_cont_rel(0, -lleg);
-	D_cont_rel(-wleg, 0);
+	D_close();
+	D_end();
+	D_stroke();
 
     }
     else {			/* non FP, no smoothing */
@@ -789,21 +795,27 @@
 	    k++;		/* count of actual boxes drawn (hide_nodata option invaidates using j-1) */
 
 	    /* White box */
+	    cur_dot_row += dots_per_line;
 	    D_use_color(white);
-	    cur_dot_row += dots_per_line;
+	    D_begin();
 	    D_move_abs(l + 2, (cur_dot_row - 1));
 	    D_cont_rel(0, (2 - dots_per_line));
 	    D_cont_rel((dots_per_line - 2), 0);
 	    D_cont_rel(0, (dots_per_line - 2));
-	    D_cont_rel((2 - dots_per_line), 0);
+	    D_close();
+	    D_end();
+	    D_stroke();
 
 	    /* Black box */
 	    D_use_color(black);
+	    D_begin();
 	    D_move_abs(l + 3, (cur_dot_row - 2));
 	    D_cont_rel(0, (4 - dots_per_line));
 	    D_cont_rel((dots_per_line - 4), 0);
 	    D_cont_rel(0, (dots_per_line - 4));
-	    D_cont_rel((4 - dots_per_line), 0);
+	    D_close();
+	    D_end();
+	    D_stroke();
 
 	    /* Color solid box */
 	    if (!fp) {

Modified: grass/trunk/display/d.linegraph/linegraph.h
===================================================================
--- grass/trunk/display/d.linegraph/linegraph.h	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.linegraph/linegraph.h	2008-09-04 18:00:54 UTC (rev 33261)
@@ -86,6 +86,3 @@
     {"in billions", 1000000000, 1000000000}
 };
 
-
-float rem(long int, long int);
-int death(char *);

Modified: grass/trunk/display/d.linegraph/main.c
===================================================================
--- grass/trunk/display/d.linegraph/main.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.linegraph/main.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -49,6 +49,13 @@
     GRAY, BROWN, MAGENTA, WHITE, INDIGO
 };
 
+static double rem(long int x, long int y)
+{
+    long int d = x / y;
+
+    return ((double)(x - y * d));
+}
+
 int main(int argc, char **argv)
 {
     double xoffset;		/* offset for x-axis */
@@ -399,8 +406,7 @@
 		    prev_x = xoffset;
 		    prev_y[i] = yoffset;
 		}
-		D_move_abs(prev_x, prev_y[i]);
-		D_cont_abs(new_x, new_y[i]);
+		D_line_abs(prev_x, prev_y[i], new_x, new_y[i]);
 		prev_y[i] = new_y[i];
 	    }
 	}
@@ -408,14 +414,17 @@
 
 	/* draw x-axis tic-marks and numbers */
 
-	if (rem((long int)in[0].value, tic_every) == (float)0) {
+	if (rem((long int)in[0].value, tic_every) == 0.0) {
 
 	    /* draw a numbered tic-mark */
 
 	    D_use_color(title_color);
-	    D_move_abs((xoffset + line * xscale),
-		       (b - ORIGIN_Y * (b - t)));
-	    D_cont_rel(0, (BIG_TIC * (b - t)));
+	    D_begin();
+	    D_move_abs(xoffset + line * xscale, b - ORIGIN_Y * (b - t));
+	    D_cont_rel(0, BIG_TIC * (b - t));
+	    D_end();
+	    D_stroke();
+
 	    if ((in[0].value >= 1) || (in[0].value <= -1) ||
 		(in[0].value == 0))
 		sprintf(txt, "%.0f", (in[0].value / tic_unit));
@@ -435,14 +444,17 @@
 		       (b - XNUMS_Y * (b - t)));
 	    R_text(txt);
 	}
-	else if (rem(line, tic_unit) == (float)0) {
+	else if (rem(line, tic_unit) == 0.0) {
 
 	    /* draw a tic-mark */
 
 	    D_use_color(title_color);
-	    D_move_abs((xoffset + line * xscale),
-		       (b - ORIGIN_Y * (b - t)));
-	    D_cont_rel(0, (SMALL_TIC * (b - t)));
+	    D_begin();
+	    D_move_abs(xoffset + line * xscale,
+		       b - ORIGIN_Y * (b - t));
+	    D_cont_rel(0, SMALL_TIC * (b - t));
+	    D_end();
+	    D_stroke();
 	}
     }
 
@@ -488,11 +500,14 @@
     /* Y-AXIS LOOP */
 
     for (i = (int)min_y; i <= (int)max_y; i += tic_unit) {
-	if (rem(i, tic_every) == (float)0) {
+	if (rem(i, tic_every) == 0.0) {
 	    /* draw a tic-mark */
 
-	    D_move_abs(x_line[0], (yoffset - yscale * (i - min_y)));
-	    D_cont_rel((-(r - l) * BIG_TIC), 0);
+	    D_begin();
+	    D_move_abs(x_line[0], yoffset - yscale * (i - min_y));
+	    D_cont_rel(-(r - l) * BIG_TIC, 0);
+	    D_end();
+	    D_stroke();
 
 	    /* draw a tic-mark number */
 
@@ -512,11 +527,13 @@
 			     (yscale * (i - min_y) + 0.5 * (tt - tb))));
 	    R_text(txt);
 	}
-	else if (rem(i, tic_unit) == (float)0) {
+	else if (rem(i, tic_unit) == 0.0) {
 	    /* draw a tic-mark */
-
+	    D_begin();
 	    D_move_abs(x_line[0], (yoffset - yscale * (i - min_y)));
-	    D_cont_rel((-(r - l) * SMALL_TIC), 0);
+	    D_cont_rel(-(r - l) * SMALL_TIC, 0);
+	    D_end();
+	    D_stroke();
 	}
     }
 
@@ -529,8 +546,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_2 * (b - t)));
+    D_move_abs(l + (r - l) / 2 - (tr - tl) / 2,
+	       b - LABEL_2 * (b - t));
     D_use_color(title_color);
     R_text(xlabel);
 
@@ -544,8 +561,8 @@
        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_move_abs(l + (r - l) / 2 - (tr - tl) / 2,
+	       t + (b - t) * .07);
     D_use_color(title_color);
     R_text(xlabel);
 
@@ -557,10 +574,3 @@
     exit(EXIT_SUCCESS);
 }
 
-float rem(long int x, long int y)
-{
-    long int d = x / y;
-
-    return ((float)(x - y * d));
-}
-

Modified: grass/trunk/display/d.profile/main.c
===================================================================
--- grass/trunk/display/d.profile/main.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.profile/main.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -89,9 +89,12 @@
 
     D_use_color(D_translate_color("red"));
 
+    D_begin();
     D_move_abs(0, 1);
     D_cont_abs(0, 0);
     D_cont_abs(1, 0);
+    D_end();
+    D_stroke();
 
     D_use_color(D_translate_color(DEFAULT_FG_COLOR));
 
@@ -270,6 +273,8 @@
     l += 0.1 * (r - l);
     r -= 0.1 * (r - l);
 
+    D_begin();
+
     i = 0;
     last = 0;
     for (sx = 0; sx < 1; sx += D_get_d_to_u_xconv()) {
@@ -305,6 +310,9 @@
 	last = 1;
     }
 
+    D_end();
+    D_stroke();
+
     R_close_driver();
 
     exit(EXIT_SUCCESS);

Modified: grass/trunk/display/d.rast.arrow/main.c
===================================================================
--- grass/trunk/display/d.rast.arrow/main.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.rast.arrow/main.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -243,16 +243,12 @@
 	D_use_color(grid_color);
 
 	/* Draw vertical grids */
-	for (col = 0; col < ncols; col++) {
-	    D_move_abs(col, 0);
-	    D_cont_abs(col, nrows);
-	}
+	for (col = 0; col < ncols; col++)
+	    D_line_abs(col, 0, col, nrows);
 
 	/* Draw horizontal grids */
-	for (row = 0; row < nrows; row++) {
-	    D_move_abs(0,     row);
-	    D_cont_abs(ncols, row);
-	}
+	for (row = 0; row < nrows; row++)
+	    D_line_abs(0, row, ncols, row);
     }
 
     /* open the raster map */
@@ -492,6 +488,8 @@
     mid_x = col + (.5);
     mid_y = row + (.5);
 
+    D_begin();
+
     /* tail */
     D_move_abs(mid_x, mid_y);
 
@@ -512,6 +510,9 @@
     dx = mid_x + (0.6 * length * cos(D2R(theta_offset)));
     dy = mid_y + (0.6 * length * sin(D2R(theta_offset)));
     D_cont_abs(dx, dy);
+
+    D_end();
+    D_stroke();
 }
 
 
@@ -527,6 +528,8 @@
     mid_x = col + (0.5);
     mid_y = row + (0.5);
 
+    D_begin();
+
     /* head */
     x = mid_x + (max_radius * cos(D2R(theta)));
     y = mid_y + (max_radius * sin(D2R(theta)));
@@ -551,122 +554,150 @@
     dy = mid_y + (0.5 * max_radius * sin(D2R(theta_offset)));
     D_cont_abs(dx, dy);
 
+    D_end();
+    D_stroke();
 }
 
 static void arrow_se(void)
 {
     double x = col + (.8);
     double y = row + (.8);
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(((-.6)), (((-.6))));
     D_move_abs(x, y);
     D_cont_rel(0, ((-.4)));
     D_move_abs(x, y);
     D_cont_rel(((-.4)), 0);
-
+    D_end();
+    D_stroke();
 }
 
 static void arrow_ne(void)
 {
     double x = col + (.8);
     double y = row + (.2);
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(((-.6)), (((.6))));
     D_move_abs(x, y);
     D_cont_rel(0, ((.4)));
     D_move_abs(x, y);
     D_cont_rel(((-.4)), 0);
-
+    D_end();
+    D_stroke();
 }
 
 static void arrow_nw(void)
 {
     double x = col + (.2);
     double y = row + (.2);
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(((.6)), (((.6))));
     D_move_abs(x, y);
     D_cont_rel(0, ((.4)));
     D_move_abs(x, y);
     D_cont_rel(((.4)), 0);
-
+    D_end();
+    D_stroke();
 }
 
 static void arrow_sw(void)
 {
     double x = col + (.2);
     double y = row + (.8);
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(((.6)), (((-.6))));
     D_move_abs(x, y);
     D_cont_rel(0, ((-.4)));
     D_move_abs(x, y);
     D_cont_rel(((.4)), 0);
+    D_end();
+    D_stroke();
+}
 
-}
 static void arrow_e(void)
 {
     double x = col + (.9);
     double y = row + (.5);
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(((-.8)), 0);
     D_move_abs(x, y);
     D_cont_rel(((-.3)), ((-.3)));
     D_move_abs(x, y);
     D_cont_rel(((-.3)), ((.3)));
+    D_end();
+    D_stroke();
+}
 
-}
 static void arrow_w(void)
 {
     double x = col + (.1);
     double y = row + (.5);
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(((.8)), 0);
     D_move_abs(x, y);
     D_cont_rel(((.3)), ((-.3)));
     D_move_abs(x, y);
     D_cont_rel(((.3)), ((.3)));
+    D_end();
+    D_stroke();
+}
 
-}
 static void arrow_s(void)
 {
     double x = col + (.5);
     double y = row + (.9);
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(0, ((-.8)));
     D_move_abs(x, y);
     D_cont_rel(((.3)), ((-.3)));
     D_move_abs(x, y);
     D_cont_rel(((-.3)), ((-.3)));
+    D_end();
+    D_stroke();
+}
 
-}
 static void arrow_n(void)
 {
     double x = col + (.5);
     double y = row + (.1);
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(0, ((.8)));
     D_move_abs(x, y);
     D_cont_rel(((.3)), ((.3)));
     D_move_abs(x, y);
     D_cont_rel(((-.3)), ((.3)));
+    D_end();
+    D_stroke();
+}
 
-}
 static void draw_x(void)
 {
     double x = col;
     double y = row;
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(1, 1);
     y = row + 1;
     D_move_abs(x, y);
     D_cont_rel(1, (-1));
+    D_end();
+    D_stroke();
 }
+
 static void unknown_(void)
 {
     double x = col + (.3);
     double y = row + (.4);
 
+    D_begin();
     D_move_abs(x, y);
     D_cont_rel(0, ((-.15)));
     D_cont_rel(((.1)), ((-.1)));
@@ -678,4 +709,6 @@
     D_cont_rel(0, ((.25)));
     D_move_rel(0, ((.1)));
     D_cont_rel(0, ((.1)));
+    D_end();
+    D_stroke();
 }

Modified: grass/trunk/display/d.rast.num/main.c
===================================================================
--- grass/trunk/display/d.rast.num/main.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.rast.num/main.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -171,16 +171,12 @@
 	D_use_color(grid_color);
 
 	/* Draw vertical grids */
-	for (col = 0; col <= ncols; col++) {
-	    D_move_abs(col, 0);
-	    D_cont_abs(col, nrows);
-	}
+	for (col = 0; col <= ncols; col++)
+	    D_line_abs(col, 0, col, nrows);
 
 	/* Draw horizontal grids */
-	for (row = 0; row <= nrows; row++) {
-	    D_move_abs(0,     row);
-	    D_cont_abs(ncols, row);
-	}
+	for (row = 0; row <= nrows; row++)
+	    D_line_abs(0, row, ncols, row);
     }
 
     /* allocate the cell array */

Modified: grass/trunk/display/d.rhumbline/plot.c
===================================================================
--- grass/trunk/display/d.rhumbline/plot.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/display/d.rhumbline/plot.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -30,6 +30,8 @@
 
     G_begin_rhumbline_equation(lon1, lat1, lon2, lat2);
 
+    D_begin();
+
     for (i = 0; i <= nsteps; i++) {
 	double lon = lon1 + (lon2 - lon1) * i / nsteps;
 	double lat = G_rhumbline_lat_from_lon(lon);
@@ -38,4 +40,7 @@
 	else
 	    D_cont_abs(lon, lat);
     }
+
+    D_end();
+    D_stroke();
 }

Modified: grass/trunk/include/display.h
===================================================================
--- grass/trunk/include/display.h	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/include/display.h	2008-09-04 18:00:54 UTC (rev 33261)
@@ -68,6 +68,13 @@
 double D_u_to_a_col(double);
 
 /* draw2.c */
+enum clip_mode {
+    D_MODE_NONE,
+    D_MODE_CULL,
+    D_MODE_CLIP,
+};
+
+void D_set_clip_mode(int);
 void D_set_clip(double, double, double, double);
 void D_clip_to_map(void);
 
@@ -89,14 +96,12 @@
 void D_box_abs(double, double, double, double);
 void D_box_rel(double, double);
 
-enum clip_mode {
-    D_MODE_NONE,
-    D_MODE_CULL,
-    D_MODE_CLIP,
-};
+void D_begin(void);
+void D_end(void);
+void D_close(void);
+void D_stroke(void);
+void D_fill(void);
 
-void D_set_clip_mode(int);
-
 /* icon.c */
 void D_plot_icon(double, double, int, double, double);
 

Modified: grass/trunk/lib/display/draw2.c
===================================================================
--- grass/trunk/lib/display/draw2.c	2008-09-04 17:57:33 UTC (rev 33260)
+++ grass/trunk/lib/display/draw2.c	2008-09-04 18:00:54 UTC (rev 33261)
@@ -5,6 +5,7 @@
 #include <grass/gis.h>
 #include <grass/raster.h>
 #include <grass/display.h>
+#include <grass/glocale.h>
 
 struct rectangle
 {
@@ -45,20 +46,11 @@
 static int nalloc_f;
 
 struct functions {
-    void (*move_abs)(double x, double y);
-    void (*move_rel)(double x, double y);
-    void (*cont_abs)(double x, double y);
-    void (*cont_rel)(double x, double y);
-    void (*line_abs)(double x1, double y1, double x2, double y2);
-    void (*line_rel)(double x1, double y1, double x2, double y2);
-    void (*polydots_abs)(const double *x, const double *y, int n);
-    void (*polydots_rel)(const double *x, const double *y, int n);
-    void (*polyline_abs)(const double *x, const double *y, int n);
-    void (*polyline_rel)(const double *x, const double *y, int n);
-    void (*polygon_abs)(const double *x, const double *y, int n);
-    void (*polygon_rel)(const double *x, const double *y, int n);
-    void (*box_abs)(double x1, double y1, double x2, double y2);
-    void (*box_rel)(double x2, double y2);
+    void (*line)(double x1, double y1, double x2, double y2);
+    void (*polydots)(const double *x, const double *y, int n);
+    void (*polyline)(const double *x, const double *y, int n);
+    void (*polygon)(const double *x, const double *y, int n);
+    void (*box)(double x1, double y1, double x2, double y2);
 };
 
 static struct functions raw_functions, cull_functions, clip_functions;
@@ -718,91 +710,39 @@
 
 /******************************************************************************/
 
-static void D_move_abs_raw(double x, double y)
+static void D_line_raw(double x1, double y1, double x2, double y2)
 {
-    cur.x = x;
-    cur.y = y;
+    x1 = D_u_to_d_col(x1);
+    y1 = D_u_to_d_row(y1);
 
-    x = D_u_to_d_col(x);
-    y = D_u_to_d_row(y);
+    R_move_abs(x1, y1);
 
-    R_move_abs(x, y);
-}
+    x2 = D_u_to_d_col(x2);
+    y2 = D_u_to_d_row(y2);
 
-static void D_move_rel_raw(double x, double y)
-{
-    D_move_abs_raw(cur.x + x, cur.y + y);
+    R_cont_abs(x2, y2);
 }
 
-static void D_cont_abs_raw(double x, double y)
+static void D_polydots_raw(const double *x, const double *y, int n)
 {
-    cur.x = x;
-    cur.y = y;
-
-    x = D_u_to_d_col(x);
-    y = D_u_to_d_row(y);
-
-    R_cont_abs(x, y);
-}
-
-static void D_cont_rel_raw(double x, double y)
-{
-    D_cont_abs_raw(cur.x + x, cur.y + y);
-}
-
-static void D_line_abs_raw(double x1, double y1, double x2, double y2)
-{
-    D_move_abs_raw(x1, y1);
-    D_cont_abs_raw(x2, y2);
-}
-
-static void D_line_rel_raw(double x1, double y1, double x2, double y2)
-{
-    D_move_rel_raw(x1, y1);
-    D_cont_rel_raw(x2, y2);
-}
-
-static void D_polydots_abs_raw(const double *x, const double *y, int n)
-{
     n = do_convert(x, y, n);
     R_polydots_abs(xi, yi, n);
 }
 
-static void D_polydots_rel_raw(const double *x, const double *y, int n)
+static void D_polyline_raw(const double *x, const double *y, int n)
 {
-    rel_to_abs(&x, &y, n);
-    D_polydots_abs_raw(x, y, n);
-    dealloc_src(&x, &y, 1);
-}
-
-static void D_polyline_abs_raw(const double *x, const double *y, int n)
-{
     n = do_convert(x, y, n);
     R_polyline_abs(xi, yi, n);
 }
 
-static void D_polyline_rel_raw(const double *x, const double *y, int n)
+static void D_polygon_raw(const double *x, const double *y, int n)
 {
-    rel_to_abs(&x, &y, n);
-    D_polyline_abs_raw(x, y, n);
-    dealloc_src(&x, &y, 1);
-}
-
-static void D_polygon_abs_raw(const double *x, const double *y, int n)
-{
     n = do_convert(x, y, n);
     R_polygon_abs(xi, yi, n);
 }
 
-static void D_polygon_rel_raw(const double *x, const double *y, int n)
+static void D_box_raw(double x1, double y1, double x2, double y2)
 {
-    rel_to_abs(&x, &y, n);
-    D_polygon_abs_raw(x, y, n);
-    dealloc_src(&x, &y, 1);
-}
-
-static void D_box_abs_raw(double x1, double y1, double x2, double y2)
-{
     x1 = D_u_to_d_col(x1);
     x2 = D_u_to_d_col(x2);
     y1 = D_u_to_d_row(y1);
@@ -811,80 +751,37 @@
     R_box_abs(x1, y1, x2, y2);
 }
 
-static void D_box_rel_raw(double x2, double y2)
-{
-    D_box_abs_raw(cur.x, cur.y, x2, y2);
-}
-
 static struct functions raw_functions = {
-    D_move_abs_raw,
-    D_move_rel_raw,
-    D_cont_abs_raw,
-    D_cont_rel_raw,
-    D_line_abs_raw,
-    D_line_rel_raw,
-    D_polydots_abs_raw,
-    D_polydots_rel_raw,
-    D_polyline_abs_raw,
-    D_polyline_rel_raw,
-    D_polygon_abs_raw,
-    D_polygon_rel_raw,
-    D_box_abs_raw,
-    D_box_rel_raw,
+    D_line_raw,
+    D_polydots_raw,
+    D_polyline_raw,
+    D_polygon_raw,
+    D_box_raw,
 };
 
 /******************************************************************************/
 
-static void D_cont_abs_cull(double x, double y)
+static void D_line_cull(double x1, double y1, double x2, double y2)
 {
-    int ret;
-
     if (!window_set)
 	D_clip_to_map();
 
     if (D_is_lat_lon())
-	ret = line_cull_ll(cur.x, cur.y, x, y);
+	line_cull_ll(x1, y1, x2, y2);
     else
-	ret = line_cull(cur.x, cur.y, x, y);
-
-    cur.x = x;
-    cur.y = y;
+	line_cull(x1, y1, x2, y2);
 }
 
-static void D_cont_rel_cull(double x, double y)
+static void D_polydots_cull(const double *x, const double *y, int n)
 {
-    D_cont_abs_cull(cur.x + x, cur.y + y);
-}
-
-static void D_line_abs_cull(double x1, double y1, double x2, double y2)
-{
-    D_move_rel(x1, y1);
-    D_cont_rel_cull(x2, y2);
-}
-
-static void D_line_rel_cull(double x1, double y1, double x2, double y2)
-{
-    D_move_abs(x1, y1);
-    D_cont_abs_cull(x2, y2);
-}
-
-static void D_polydots_abs_cull(const double *x, const double *y, int n)
-{
     if (!window_set)
 	D_clip_to_map();
 
     polydots_clip(x, y, n);
 }
 
-static void D_polydots_rel_cull(const double *x, const double *y, int n)
+static void D_polyline_cull(const double *x, const double *y, int n)
 {
-    rel_to_abs(&x, &y, n);
-    D_polydots_abs_cull(x, y, n);
-    dealloc_src(&x, &y, 1);
-}
-
-static void D_polyline_abs_cull(const double *x, const double *y, int n)
-{
     if (n < 2)
 	return;
 
@@ -897,15 +794,8 @@
 	polyline_cull(x, y, n);
 }
 
-static void D_polyline_rel_cull(const double *x, const double *y, int n)
+static void D_polygon_cull(const double *x, const double *y, int n)
 {
-    rel_to_abs(&x, &y, n);
-    D_polyline_abs_cull(x, y, n);
-    dealloc_src(&x, &y, 1);
-}
-
-static void D_polygon_abs_cull(const double *x, const double *y, int n)
-{
     if (!window_set)
 	D_clip_to_map();
 
@@ -915,15 +805,8 @@
 	polygon_cull(x, y, n);
 }
 
-static void D_polygon_rel_cull(const double *x, const double *y, int n)
+static void D_box_cull(double x1, double y1, double x2, double y2)
 {
-    rel_to_abs(&x, &y, n);
-    D_polygon_abs_cull(x, y, n);
-    dealloc_src(&x, &y, 1);
-}
-
-static void D_box_abs_cull(double x1, double y1, double x2, double y2)
-{
     if (!window_set)
 	D_clip_to_map();
 
@@ -933,80 +816,37 @@
 	box_cull(x1, y1, x2, y2);
 }
 
-static void D_box_rel_cull(double x2, double y2)
-{
-    D_box_abs_cull(cur.x, cur.y, x2, y2);
-}
-
 static struct functions cull_functions = {
-    D_move_abs_raw,
-    D_move_rel_raw,
-    D_cont_abs_cull,
-    D_cont_rel_cull,
-    D_line_abs_cull,
-    D_line_rel_cull,
-    D_polydots_abs_cull,
-    D_polydots_rel_cull,
-    D_polyline_abs_cull,
-    D_polyline_rel_cull,
-    D_polygon_abs_cull,
-    D_polygon_rel_cull,
-    D_box_abs_cull,
-    D_box_rel_cull,
+    D_line_cull,
+    D_polydots_cull,
+    D_polyline_cull,
+    D_polygon_cull,
+    D_box_cull,
 };
 
 /******************************************************************************/
 
-static void D_cont_abs_clip(double x, double y)
+static void D_line_clip(double x1, double y1, double x2, double y2)
 {
-    int ret;
-
     if (!window_set)
 	D_clip_to_map();
 
     if (D_is_lat_lon())
-	ret = line_clip_ll(cur.x, cur.y, x, y);
+	line_clip_ll(x1, y1, x2, y2);
     else
-	ret = line_clip(cur.x, cur.y, x, y);
-
-    cur.x = x;
-    cur.y = y;
+	line_clip(x1, y1, x2, y2);
 }
 
-static void D_cont_rel_clip(double x, double y)
+static void D_polydots_clip(const double *x, const double *y, int n)
 {
-    D_cont_abs_clip(cur.x + x, cur.y + y);
-}
-
-static void D_line_abs_clip(double x1, double y1, double x2, double y2)
-{
-    D_move_abs(x1, y1);
-    D_cont_abs_clip(x2, y2);
-}
-
-static void D_line_rel_clip(double x1, double y1, double x2, double y2)
-{
-    D_move_rel(x1, y1);
-    D_cont_rel_clip(x2, y2);
-}
-
-static void D_polydots_abs_clip(const double *x, const double *y, int n)
-{
     if (!window_set)
 	D_clip_to_map();
 
     polydots_clip(x, y, n);
 }
 
-static void D_polydots_rel_clip(const double *x, const double *y, int n)
+static void D_polyline_clip(const double *x, const double *y, int n)
 {
-    rel_to_abs(&x, &y, n);
-    D_polydots_abs_clip(x, y, n);
-    dealloc_src(&x, &y, 1);
-}
-
-static void D_polyline_abs_clip(const double *x, const double *y, int n)
-{
     if (!window_set)
 	D_clip_to_map();
 
@@ -1019,15 +859,8 @@
 	polyline_clip(x, y, n);
 }
 
-static void D_polyline_rel_clip(const double *x, const double *y, int n)
+static void D_polygon_clip(const double *x, const double *y, int n)
 {
-    rel_to_abs(&x, &y, n);
-    D_polyline_abs_clip(x, y, n);
-    dealloc_src(&x, &y, 1);
-}
-
-static void D_polygon_abs_clip(const double *x, const double *y, int n)
-{
     if (!window_set)
 	D_clip_to_map();
 
@@ -1037,15 +870,8 @@
 	polygon_clip(x, y, n);
 }
 
-static void D_polygon_rel_clip(const double *x, const double *y, int n)
+static void D_box_clip(double x1, double y1, double x2, double y2)
 {
-    rel_to_abs(&x, &y, n);
-    D_polygon_abs_clip(x, y, n);
-    dealloc_src(&x, &y, 1);
-}
-
-static void D_box_abs_clip(double x1, double y1, double x2, double y2)
-{
     if (!window_set)
 	D_clip_to_map();
 
@@ -1055,26 +881,12 @@
 	box_clip(x1, y1, x2, y2);
 }
 
-static void D_box_rel_clip(double x2, double y2)
-{
-    D_box_abs_clip(cur.x, cur.y, x2, y2);
-}
-
 static struct functions clip_functions = {
-    D_move_abs_raw,
-    D_move_rel_raw,
-    D_cont_abs_clip,
-    D_cont_rel_clip,
-    D_line_abs_clip,
-    D_line_rel_clip,
-    D_polydots_abs_clip,
-    D_polydots_rel_clip,
-    D_polyline_abs_clip,
-    D_polyline_rel_clip,
-    D_polygon_abs_clip,
-    D_polygon_rel_clip,
-    D_box_abs_clip,
-    D_box_rel_clip,
+    D_line_clip,
+    D_polydots_clip,
+    D_polyline_clip,
+    D_polygon_clip,
+    D_box_clip,
 };
 
 /******************************************************************************/
@@ -1150,86 +962,225 @@
 
 /******************************************************************************/
 
-void D_move_abs(double x, double y)
+void D_line_abs(double x1, double y1, double x2, double y2)
 {
-	(*fns->move_abs)(x, y);
+    (*fns->line)(x1, y1, x2, y2);
 }
 
-void D_move_rel(double x, double y)
+void D_polydots_abs(const double *x, const double *y, int n)
 {
-	(*fns->move_rel)(x, y);
+    (*fns->polydots)(x, y, n);
 }
 
-void D_cont_abs(double x, double y)
+void D_polyline_abs(const double *x, const double *y, int n)
 {
-	(*fns->cont_abs)(x, y);
+    (*fns->polyline)(x, y, n);
 }
 
-void D_cont_rel(double x, double y)
+void D_polygon_abs(const double *x, const double *y, int n)
 {
-	(*fns->cont_rel)(x, y);
+    (*fns->polygon)(x, y, n);
 }
 
-void D_line_abs(double x1, double y1, double x2, double y2)
+void D_box_abs(double x1, double y1, double x2, double y2)
 {
-	(*fns->line_abs)(x1, y1, x2, y2);
+    (*fns->box)(x1, y1, x2, y2);
 }
 
+/******************************************************************************/
+
 void D_line_rel(double x1, double y1, double x2, double y2)
 {
-	(*fns->line_rel)(x1, y1, x2, y2);
+    cur.x += x1;
+    cur.y += y1;
+
+    x1 = cur.x;
+    y1 = cur.y;
+
+    cur.x += x2;
+    cur.y += y2;
+
+    x2 = cur.x;
+    y2 = cur.y;
+
+    D_line_abs(x1, y1, x2, y2);
 }
 
-void D_polydots_abs(const double *x, const double *y, int n)
+void D_polydots_rel(const double *x, const double *y, int n)
 {
-	(*fns->polydots_abs)(x, y, n);
+    rel_to_abs(&x, &y, n);
+    D_polydots_abs(x, y, n);
+    dealloc_src(&x, &y, 1);
 }
 
-void D_polydots_rel(const double *x, const double *y, int n)
+void D_polyline_rel(const double *x, const double *y, int n)
 {
-	(*fns->polydots_rel)(x, y, n);
+    rel_to_abs(&x, &y, n);
+    D_polyline_abs(x, y, n);
+    dealloc_src(&x, &y, 1);
 }
 
-void D_polyline_abs(const double *x, const double *y, int n)
+void D_polygon_rel(const double *x, const double *y, int n)
 {
-	(*fns->polyline_abs)(x, y, n);
+    rel_to_abs(&x, &y, n);
+    D_polygon_abs(x, y, n);
+    dealloc_src(&x, &y, 1);
 }
 
-void D_polyline_rel(const double *x, const double *y, int n)
+void D_box_rel(double x2, double y2)
 {
-	(*fns->polyline_rel)(x, y, n);
+    D_box_abs(cur.x, cur.y, cur.x + x2, cur.y + y2);
 }
 
-void D_polygon_abs(const double *x, const double *y, int n)
+/******************************************************************************/
+
+void D_set_clip_mode(int mode)
 {
-	(*fns->polygon_abs)(x, y, n);
+    switch (mode) {
+    case D_MODE_NONE: fns = &raw_functions;	break;
+    case D_MODE_CULL: fns = &cull_functions;	break;
+    case D_MODE_CLIP: fns = &clip_functions;	break;
+    }
 }
 
-void D_polygon_rel(const double *x, const double *y, int n)
+/******************************************************************************/
+
+static int path_point_max;
+static int path_point_num;
+static double *path_x, *path_y;
+
+static int path_segment_max;
+static int path_segment_num;
+static int *path_segments;
+
+static int in_path;
+static int cur_seg;
+
+static void path_alloc_segment(void)
 {
-	(*fns->polygon_rel)(x, y, n);
+    if (path_segment_num >= path_segment_max) {
+	path_segment_max = path_segment_num + 10;
+	path_segments = G_realloc(path_segments, path_segment_max * sizeof(int));
+    }
 }
 
-void D_box_abs(double x1, double y1, double x2, double y2)
+static void path_alloc_point(void)
 {
-	(*fns->box_abs)(x1, y1, x2, y2);
+    if (path_point_num >= path_point_max) {
+	path_point_max = path_point_num + 100;
+	path_x = G_realloc(path_x, path_point_max * sizeof(double));
+	path_y = G_realloc(path_y, path_point_max * sizeof(double));
+    }
 }
 
-void D_box_rel(double x2, double y2)
+static void new_point(double x, double y)
 {
-	(*fns->box_rel)(x2, y2);
+    path_alloc_point();
+    path_x[path_point_num] = x;
+    path_y[path_point_num] = y;
+    path_point_num++;
 }
 
+static void new_segment(void)
+{
+    cur_seg = path_segment_num;
+    path_alloc_segment();
+    path_segments[path_segment_num] = path_point_num;
+    path_segment_num++;
+}
+
 /******************************************************************************/
 
-void D_set_clip_mode(int mode)
+void D_move_abs(double x, double y)
 {
-    switch (mode) {
-    case D_MODE_NONE: fns = &raw_functions;	break;
-    case D_MODE_CULL: fns = &cull_functions;	break;
-    case D_MODE_CLIP: fns = &clip_functions;	break;
+    cur.x = x;
+    cur.y = y;
+
+    if (in_path) {
+	new_segment();
+	new_point(x, y);
     }
+    else {
+	x = D_u_to_d_col(x);
+	y = D_u_to_d_row(y);
+	R_move_abs(x, y);
+    }
 }
 
+void D_move_rel(double x, double y)
+{
+    D_move_abs(cur.x + x, cur.y + y);
+}
+
+void D_cont_abs(double x, double y)
+{
+    if (in_path)
+	new_point(x, y);
+    else
+	(*fns->line)(cur.x, cur.y, x, y);
+
+    cur.x = x;
+    cur.y = y;
+}
+
+void D_cont_rel(double x, double y)
+{
+    D_cont_abs(cur.x + x, cur.y + y);
+}
+
 /******************************************************************************/
 
+void D_begin(void)
+{
+    if (in_path)
+	G_warning(_("D_begin() called while path active"));
+    path_segment_num = 0;
+    path_point_num = 0;
+    in_path = 1;
+}
+
+void D_end(void)
+{
+    if (!in_path)
+	G_warning(_("D_end() called while path not active"));
+    new_segment();
+    in_path = 0;
+}
+
+void D_close(void)
+{
+    int i;
+
+    if (!in_path) {
+	G_warning(_("D_close() called while path not active"));
+	return;
+    }
+
+    i = path_segments[cur_seg];
+    new_point(path_x[i], path_y[i]);
+}
+
+void D_stroke(void)
+{
+    int i;
+
+    for (i = 0; i < path_segment_num - 1; i++) {
+	int i0 = path_segments[i];
+	int i1 = path_segments[i+1];
+	D_polyline_abs(&path_x[i0], &path_y[i0], i1 - i0);
+    }
+}
+
+void D_fill(void)
+{
+    int i;
+
+    for (i = 0; i < path_segment_num - 1; i++) {
+	int i0 = path_segments[i];
+	int i1 = path_segments[i+1];
+	D_polygon_abs(&path_x[i0], &path_y[i0], i1 - i0);
+    }
+}
+
+/******************************************************************************/
+



More information about the grass-commit mailing list