[GRASS-SVN] r33487 - grass/branches/develbranch_6/ps/ps.map

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 18 22:22:19 EDT 2008


Author: hamish
Date: 2008-09-18 22:22:18 -0400 (Thu, 18 Sep 2008)
New Revision: 33487

Modified:
   grass/branches/develbranch_6/ps/ps.map/description.html
   grass/branches/develbranch_6/ps/ps.map/do_vectors.c
   grass/branches/develbranch_6/ps/ps.map/r_vlines.c
   grass/branches/develbranch_6/ps/ps.map/vector.h
Log:
add line sytle by name and linecap (trac #250)

Modified: grass/branches/develbranch_6/ps/ps.map/description.html
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/description.html	2008-09-17 15:59:51 UTC (rev 33486)
+++ grass/branches/develbranch_6/ps/ps.map/description.html	2008-09-19 02:22:18 UTC (rev 33487)
@@ -1324,6 +1324,7 @@
 	<B>coffset</B> #
 	<B>ref</B> left|right
 	<B>style</B> 00001111
+	<B>linecap</B> style
 	<B>label</B> label
 	<B>lpos</B> #
 	<B>end</B>
@@ -1334,7 +1335,8 @@
 <P>
 <B>color</B> - color of the vector lines or area boundaries;
 <P>
-<B>rgbcolumn</B> - name of color definition column used for the vector lines or area boundaries;
+<B>rgbcolumn</B> - name of color definition column used for the vector lines
+or area boundaries;
 <P>
 <B>width</B> - width of the vectors lines or area boundaries in pixels
 (accepts decimal points [floating points] as well as integers);
@@ -1347,13 +1349,13 @@
 <P>
 <B>hwidth</B> - the width of the highlight color in pixels;
 <P>
-<B>offset</B> (experimental) - offset for the vectors lines in pixels for plotting
-parallel lines in distance equal to offset (accepts positive or 
+<B>offset</B> (experimental) - offset for the vectors lines in pixels for
+plotting parallel lines in distance equal to offset (accepts positive or 
 negative decimal points). Useful to print streets with several parallel lanes;
 <P>
-<B>coffset</B> (experimental) - offset for the vectors lines. If coffset is used then 
-offset of line is equal to coffset * category value and offset is 
-used in legend;
+<B>coffset</B> (experimental) - offset for the vectors lines. If coffset
+is used then  offset of line is equal to coffset * category value and offset
+is used in legend;
 <P>
 <B>ref</B> (experimental) - line justification. 
 <P>
@@ -1362,15 +1364,22 @@
 (see manual entry <EM><A HREF="r.mask.html">r.mask</A></EM>
 for more information on the mask);
 <P>
-<B>style</B> - the line style allows the vectors
-to be dashed in different patterns.  This is done by typing a
-series of numbers (0's and 1's) in a desired sequence or pattern.
+<B>style</B> - the line style allows the vectors to be dashed in different
+patterns.  This is done by either typing "solid", "dashed", "dotted", or
+"dashdotted", or as a series of 0's and 1's in a desired sequence or pattern.
 The first block of repeated zeros or ones represents "draw", the second
 block represents "blank".
 An even number of blocks will repeat the pattern, an odd number of blocks
 will alternate the pattern.
 The default is "solid";
 <P>
+<B>linecap</B> - the linecap specifies the look of the ends of the line,
+or the end of the dashes in a dashed line. The parameters are:
+'butt' for butt caps (default), 'round' for round caps and 'extended_butt'
+for extended butt caps. The shape of the round and the extended butt caps
+is related to the line thickness: for round butts the radius is hald the
+linewidth, while for extended butt the line will extend for half the linewidth.  
+<P>
 <B>cats</B> - which categories should be plotted (default is all);
 <P>
 <B>label</B> - for description in <a href="#vlegend">vlegend</a>.

Modified: grass/branches/develbranch_6/ps/ps.map/do_vectors.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/do_vectors.c	2008-09-17 15:59:51 UTC (rev 33486)
+++ grass/branches/develbranch_6/ps/ps.map/do_vectors.c	2008-09-19 02:22:18 UTC (rev 33487)
@@ -63,6 +63,12 @@
 
 	    fprintf(PS.fp, "%.8f W\n", vector.layer[n].width);
 	    set_ps_color(&(vector.layer[n].color));
+
+	    if (vector.layer[n].linecap >= 0) {
+		G_debug(1, "Line cap: '%d'", vector.layer[n].linecap);
+		fprintf(PS.fp, "%d setlinecap\n",vector.layer[n].linecap);		 
+	    }
+
 	    dashes[0] = '[';
 	    dashes[1] = 0;
 	    lz = 0;

Modified: grass/branches/develbranch_6/ps/ps.map/r_vlines.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_vlines.c	2008-09-17 15:59:51 UTC (rev 33486)
+++ grass/branches/develbranch_6/ps/ps.map/r_vlines.c	2008-09-19 02:22:18 UTC (rev 33487)
@@ -8,8 +8,8 @@
  */
 #include <stdlib.h>
 #include <string.h>
+#include <grass/Vect.h>
 #include "vector.h"
-#include <grass/Vect.h>
 #include "ps_info.h"
 #include "local_proto.h"
 
@@ -24,7 +24,8 @@
     "offset      #",
     "coffset     #",
     "masked      [y|n]",
-    "style       solid|[0|1]...",
+    "style       solid|dashed|dotted|dashdotted|[0|1]...",
+    "linecap     butt|round|extended_butt"
     "line_cat    #",
     "acolor      r g b",
     "label       label",
@@ -38,7 +39,7 @@
 
 int read_vlines(char *name, char *mapset)
 {
-    char fullname[100];
+    char fullname[GNAME_MAX];
     char buf[1024];
     char *key, *data, *dp;
     double width;
@@ -79,6 +80,7 @@
     set_color(&(vector.layer[vec].color), 0, 0, 0);
     vector.layer[vec].rgbcol = NULL;
     vector.layer[vec].linestyle = NULL;
+    vector.layer[vec].linecap = LINECAP_BUTT;
     vector.layer[vec].ref = LINE_REF_CENTER;
     vector.layer[vec].hwidth = 0.;
     unset_color(&(vector.layer[vec].hcolor));
@@ -132,10 +134,21 @@
 	if (KEY("style")) {
 	    G_strip(data);
 	    if (strcmp(data, "solid") == 0) {
-/* TODO: add "dotted" and "dashed" preset line patterns */
 		vector.layer[vec].linestyle = NULL;
 		continue;
 	    }
+	    else if (strcmp(data, "dashed") == 0) {
+		vector.layer[vec].linestyle = G_store("000000111");
+		continue;
+	    }
+	    else if (strcmp(data, "dotted") == 0) {
+		vector.layer[vec].linestyle = G_store("100000");
+		continue;
+	    }
+	    else if (strcmp(data, "dashdotted") == 0) {
+		vector.layer[vec].linestyle = G_store("000000111011111");
+		continue;
+	    }
 	    for (dp = data; *dp; dp++)
 		if (*dp < '0' || *dp > '9')
 		    break;
@@ -147,6 +160,25 @@
 	    continue;
 	}
 
+	if (KEY("linecap")) {
+	    G_strip(data);
+	    if (strcmp(data, "butt") == 0) {
+		vector.layer[vec].linecap = LINECAP_BUTT;
+		continue;
+	    }
+	    else if (strcmp(data, "round") == 0) {
+		vector.layer[vec].linecap = LINECAP_ROUND;
+		continue;
+	    }
+	    else if (strcmp(data, "extended_butt") == 0) {
+		vector.layer[vec].linecap = LINECAP_EXTBUTT;
+		continue;
+	    }
+	    else
+		error(key, data, "illegal line cap (vlines)");		
+	    continue;
+	}
+
 	if (KEY("width")) {
 	    width = -1.;
 	    *mapset = 0;

Modified: grass/branches/develbranch_6/ps/ps.map/vector.h
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/vector.h	2008-09-17 15:59:51 UTC (rev 33486)
+++ grass/branches/develbranch_6/ps/ps.map/vector.h	2008-09-19 02:22:18 UTC (rev 33487)
@@ -30,6 +30,12 @@
 #define CLOSE_PATH  2
 #define WHOLE_PATH  3
 
+/* line end style */
+#define LINECAP_BUTT 0
+#define LINECAP_ROUND 1
+#define LINECAP_EXTBUTT 2
+
+
 typedef struct
 {
     /* All types */
@@ -54,7 +60,8 @@
     double coffset;		/* category offset */
     int ref;			/* justification */
     char *linestyle;		/* line or boundary style */
-    char *setdash;		/* ? */
+    char *setdash;		/* line style converted to PS setdash format */
+    int linecap;		/* line end style */
     double hwidth;		/* line or boundary highlight line width */
     PSCOLOR hcolor;
 



More information about the grass-commit mailing list