[GRASS-SVN] r55730 - grass/branches/releasebranch_6_4/display/d.grid

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 13 03:07:51 PDT 2013


Author: hamish
Date: 2013-04-13 03:07:51 -0700 (Sat, 13 Apr 2013)
New Revision: 55730

Modified:
   grass/branches/releasebranch_6_4/display/d.grid/fiducial.c
   grass/branches/releasebranch_6_4/display/d.grid/local_proto.h
   grass/branches/releasebranch_6_4/display/d.grid/main.c
   grass/branches/releasebranch_6_4/display/d.grid/plot.c
Log:
backport dot flag and line width option from devbr6 (r45399, r45808)

Modified: grass/branches/releasebranch_6_4/display/d.grid/fiducial.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.grid/fiducial.c	2013-04-13 10:04:53 UTC (rev 55729)
+++ grass/branches/releasebranch_6_4/display/d.grid/fiducial.c	2013-04-13 10:07:51 UTC (rev 55730)
@@ -8,19 +8,24 @@
 
 void plot_cross(double easting, double northing, int color, double rotation)
 {
-    plot_symbol(easting, northing, color, rotation, "basic/cross1");
+    plot_symbol(easting, northing, color, rotation, "basic/cross1",
+		MARK_CROSS);
 }
 
-
 void plot_fiducial(double easting, double northing, int color,
 		   double rotation)
 {
-    plot_symbol(easting, northing, color, rotation + 45.0, "extra/fiducial");
+    plot_symbol(easting, northing, color, rotation + 45.0, "extra/fiducial",
+		MARK_FIDUCIAL);
 }
 
+void plot_dot(double easting, double northing, int color)
+{
+    plot_symbol(easting, northing, color, 0.0, "basic/point", MARK_DOT);
+}
 
 void plot_symbol(double easting, double northing, int color, double rotation,
-		 char *symbol_name)
+		 char *symbol_name, int mark_type)
 {
     SYMBOL *Symb;
     RGBA_Color *line_color, *fill_color;
@@ -46,6 +51,13 @@
 
     fill_color->a = RGBA_COLOR_NONE;
 
+    if(mark_type == MARK_DOT) {
+	size = 5;
+	fill_color->r = (unsigned char)R;
+	fill_color->g = (unsigned char)G;
+	fill_color->b = (unsigned char)B;
+	fill_color->a = RGBA_COLOR_OPAQUE;
+    }
 
     Symb = S_read(symbol_name);
     if (!Symb)

Modified: grass/branches/releasebranch_6_4/display/d.grid/local_proto.h
===================================================================
--- grass/branches/releasebranch_6_4/display/d.grid/local_proto.h	2013-04-13 10:04:53 UTC (rev 55729)
+++ grass/branches/releasebranch_6_4/display/d.grid/local_proto.h	2013-04-13 10:07:51 UTC (rev 55730)
@@ -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);
@@ -17,8 +17,10 @@
 #define MARK_GRID     0
 #define MARK_CROSS    1
 #define MARK_FIDUCIAL 2
+#define MARK_DOT      3
 
 /* fiducial.c */
 void plot_cross(double, double, int, double);
 void plot_fiducial(double, double, int, double);
-void plot_symbol(double, double, int, double, char *);
+void plot_symbol(double, double, int, double, char *, int);
+void plot_dot(double, double, int);

Modified: grass/branches/releasebranch_6_4/display/d.grid/main.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.grid/main.c	2013-04-13 10:04:53 UTC (rev 55729)
+++ grass/branches/releasebranch_6_4/display/d.grid/main.c	2013-04-13 10:07:51 UTC (rev 55730)
@@ -36,11 +36,11 @@
     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;
+	*fiducial, *dot;
     struct pj_info info_in;	/* Proj structures */
     struct pj_info info_out;	/* Proj structures */
 
@@ -70,6 +70,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");
@@ -108,6 +114,10 @@
     cross->key = 'c';
     cross->description = _("Draw '+' marks instead of grid lines");
 
+    dot = G_define_flag();
+    dot->key = 'd';
+    dot->description = _("Draw '.' marks instead of grid lines");
+
     fiducial = G_define_flag();
     fiducial->key = 'f';
     fiducial->description = _("Draw fiducial marks instead of grid lines");
@@ -147,15 +157,25 @@
     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;
-    if (cross->answer && fiducial->answer)
+    if (cross->answer + fiducial->answer + dot->answer > 1)
 	G_fatal_error(_("Choose a single mark style"));
     if (cross->answer)
 	mark_type = MARK_CROSS;
     if (fiducial->answer)
 	mark_type = MARK_FIDUCIAL;
+    if (dot->answer)
+	mark_type = MARK_DOT;
 
     /* get grid size */
     if (geogrid->answer) {
@@ -202,12 +222,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/branches/releasebranch_6_4/display/d.grid/plot.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.grid/plot.c	2013-04-13 10:04:53 UTC (rev 55729)
+++ grass/branches/releasebranch_6_4/display/d.grid/plot.c	2013-04-13 10:07:51 UTC (rev 55730)
@@ -11,7 +11,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;
@@ -41,7 +42,10 @@
 
 	if (mark_type == MARK_GRID) {
 	    D_raster_use_color(gcolor);
+	    if (line_width)
+		D_line_width(line_width);
 	    G_plot_line(x, window.north, x, window.south);
+	    D_line_width(0);	/* reset so text doesn't use it */
 	}
 
 	if (do_text) {
@@ -83,9 +87,12 @@
     while (y <= window.north) {
 	if (mark_type == MARK_GRID) {
 	    D_raster_use_color(gcolor);
+	    if (line_width)
+		D_line_width(line_width);
 	    G_plot_line(window.east, y, e1, y);
 	    G_plot_line(e1, y, e2, y);
 	    G_plot_line(e2, y, window.west, y);
+	    D_line_width(0);	/* reset so text doesn't use it */
 	}
 
 	if (do_text) {
@@ -125,8 +132,10 @@
 	    while (y <= window.north) {
 		if (mark_type == MARK_CROSS)
 		    plot_cross(x, y, gcolor, 0.0);
-		if (mark_type == MARK_FIDUCIAL)
+		else if (mark_type == MARK_FIDUCIAL)
 		    plot_fiducial(x, y, gcolor, 0.0);
+		else if (mark_type == MARK_DOT)
+		    plot_dot(x, y, gcolor);
 		y += grid_size;
 	    }
 	    x += grid_size;
@@ -139,7 +148,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;
@@ -205,7 +214,11 @@
 		start_coord = n1;
 		font_angle = get_heading((e1 - e2), (n1 - n2));
 	    }
+
+	    if (line_width)
+		D_line_width(line_width);
 	    G_plot_line(e1, n1, e2, n2);
+	    D_line_width(0);
 	}
 
 	if (do_text) {
@@ -258,7 +271,10 @@
 		start_coord = e1;
 	    }
 
+	    if (line_width)
+		D_line_width(line_width);
 	    G_plot_line(e1, n1, e2, n2);
+	    D_line_width(0);
 	}
 	if (do_text) {
 	    /* Set text color */



More information about the grass-commit mailing list