[GRASS-SVN] r45400 - grass/trunk/display/d.grid

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 14 06:14:59 EST 2011


Author: hamish
Date: 2011-02-14 03:14:59 -0800 (Mon, 14 Feb 2011)
New Revision: 45400

Modified:
   grass/trunk/display/d.grid/local_proto.h
   grass/trunk/display/d.grid/main.c
   grass/trunk/display/d.grid/plot.c
Log:
+ grid line width option (sometimes 1px wide is hard to see) (merge from devbr6)

Modified: grass/trunk/display/d.grid/local_proto.h
===================================================================
--- grass/trunk/display/d.grid/local_proto.h	2011-02-14 11:02:11 UTC (rev 45399)
+++ grass/trunk/display/d.grid/local_proto.h	2011-02-14 11:14:59 UTC (rev 45400)
@@ -1,9 +1,9 @@
 #include <grass/gprojects.h>
 
 /* plot.c */
-int plot_grid(double, double, double, int, int, int, int, int);
+int plot_grid(double, double, double, int, int, int, int, int, double);
 int plot_geogrid(double, struct pj_info, struct pj_info, int, int, int, int,
-		 int);
+		 int, double);
 void init_proj(struct pj_info *, struct pj_info *, int);
 void get_ll_bounds(double *, double *, double *, double *, struct Cell_head,
 		   struct pj_info, struct pj_info);

Modified: grass/trunk/display/d.grid/main.c
===================================================================
--- grass/trunk/display/d.grid/main.c	2011-02-14 11:02:11 UTC (rev 45399)
+++ grass/trunk/display/d.grid/main.c	2011-02-14 11:14:59 UTC (rev 45400)
@@ -35,9 +35,9 @@
     int colort = 0;
     double size = 0., gsize = 0.;	/* initialize to zero */
     double east, north;
-    int do_text, fontsize, mark_type;
+    int do_text, fontsize, mark_type, line_width;
     struct GModule *module;
-    struct Option *opt1, *opt2, *opt3, *opt4, *fsize, *tcolor;
+    struct Option *opt1, *opt2, *opt3, *opt4, *fsize, *tcolor, *lwidth;
     struct Flag *noborder, *notext, *geogrid, *nogrid, *wgs84, *cross,
 	*fiducial, *align;
     struct pj_info info_in;	/* Proj structures */
@@ -71,6 +71,12 @@
     opt3->multiple = NO;
     opt3->description = _("Lines of the grid pass through this coordinate");
 
+    lwidth = G_define_option();
+    lwidth->key = "width";
+    lwidth->type = TYPE_DOUBLE;
+    lwidth->required = NO;
+    lwidth->description = _("Grid line width");
+
     opt1 = G_define_standard_option(G_OPT_C_FG);
     opt1->answer = "gray";
     opt1->label = _("Grid color");
@@ -152,6 +158,14 @@
     else
 	do_text = TRUE;
 
+    if (lwidth->answer) {
+	line_width = atoi(lwidth->answer);
+	if(line_width < 0 || line_width > 1e3)
+	    G_fatal_error("Invalid line width.");
+    }
+    else
+	line_width = 0;
+
     fontsize = atoi(fsize->answer);
 
     mark_type = MARK_GRID;
@@ -226,12 +240,12 @@
 	    /* initialzie proj stuff */
 	    init_proj(&info_in, &info_out, wgs84->answer);
 	    plot_geogrid(gsize, info_in, info_out, do_text, colorg, colort,
-			 fontsize, mark_type);
+			 fontsize, mark_type, line_width);
 	}
 	else {
 	    /* Do the grid plotting */
 	    plot_grid(size, east, north, do_text, colorg, colort, fontsize,
-		      mark_type);
+		      mark_type, line_width);
 	}
     }
 

Modified: grass/trunk/display/d.grid/plot.c
===================================================================
--- grass/trunk/display/d.grid/plot.c	2011-02-14 11:02:11 UTC (rev 45399)
+++ grass/trunk/display/d.grid/plot.c	2011-02-14 11:14:59 UTC (rev 45400)
@@ -10,7 +10,8 @@
 
 
 int plot_grid(double grid_size, double east, double north, int do_text,
-	      int gcolor, int tcolor, int fontsize, int mark_type)
+	      int gcolor, int tcolor, int fontsize, int mark_type,
+	      double line_width)
 {
     double x, y, y0;
     double e1, e2;
@@ -37,7 +38,10 @@
 
 	if (mark_type == MARK_GRID) {
 	    D_use_color(gcolor);
+	    if (line_width)
+		D_line_width(line_width);
 	    D_line_abs(x, window.north, x, window.south);
+	    D_line_width(0);	/* reset so text doesn't use it */
 	}
 
 	if (do_text) {
@@ -79,9 +83,12 @@
     while (y <= window.north) {
 	if (mark_type == MARK_GRID) {
 	    D_use_color(gcolor);
+	    if (line_width)
+		D_line_width(line_width);
 	    D_line_abs(window.east, y, e1, y);
 	    D_line_abs(e1, y, e2, y);
 	    D_line_abs(e2, y, window.west, y);
+	    D_line_width(0);	/* reset so text doesn't use it */
 	}
 
 	if (do_text) {
@@ -136,7 +143,7 @@
 
 int plot_geogrid(double size, struct pj_info info_in, struct pj_info info_out,
 		 int do_text, int gcolor, int tcolor, int fontsize,
-		 int mark_type)
+		 int mark_type, double line_width)
 {
     double g;
     double e1, e2, n1, n2;
@@ -199,7 +206,11 @@
 		start_coord = n1;
 		font_angle = get_heading((e1 - e2), (n1 - n2));
 	    }
+
+	    if (line_width)
+		D_line_width(line_width);
 	    D_line_abs(e1, n1, e2, n2);
+	    D_line_width(0);
 	}
 
 	if (do_text) {
@@ -252,7 +263,10 @@
 		start_coord = e1;
 	    }
 
+	    if (line_width)
+		D_line_width(line_width);
 	    D_line_abs(e1, n1, e2, n2);
+	    D_line_width(0);
 	}
 	if (do_text) {
 	    /* Set text color */



More information about the grass-commit mailing list