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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 28 07:53:01 EST 2008


Author: hamish
Date: 2008-01-28 07:53:01 -0500 (Mon, 28 Jan 2008)
New Revision: 29878

Added:
   grass/trunk/display/d.grid/fiducial.c
Modified:
   grass/trunk/display/d.grid/Makefile
   grass/trunk/display/d.grid/local_proto.h
   grass/trunk/display/d.grid/main.c
Log:
first pass at adding support for cross marks instead of grid lines

Modified: grass/trunk/display/d.grid/Makefile
===================================================================
--- grass/trunk/display/d.grid/Makefile	2008-01-28 12:40:32 UTC (rev 29877)
+++ grass/trunk/display/d.grid/Makefile	2008-01-28 12:53:01 UTC (rev 29878)
@@ -2,8 +2,8 @@
 
 PGM = d.grid
 
-LIBES     = $(DISPLAYLIB) $(RASTERLIB) $(GPROJLIB) $(GISLIB)
-DEPENDENCIES= $(DISPLAYDEP) $(RASTERDEP) $(GPROJDEP) $(GISDEP)
+LIBES     = $(SYMBLIB) $(DISPLAYLIB) $(RASTERLIB) $(GPROJLIB) $(GISLIB)
+DEPENDENCIES= $(SYMBDEP) $(DISPLAYDEP) $(RASTERDEP) $(GPROJDEP) $(GISDEP)
 EXTRA_INC = $(PROJINC)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make

Added: grass/trunk/display/d.grid/fiducial.c
===================================================================
--- grass/trunk/display/d.grid/fiducial.c	                        (rev 0)
+++ grass/trunk/display/d.grid/fiducial.c	2008-01-28 12:53:01 UTC (rev 29878)
@@ -0,0 +1,54 @@
+#include <grass/gis.h>
+#include <grass/display.h>
+#include <grass/symbol.h>
+#include <grass/colors.h>
+#include <grass/glocale.h>
+#include "local_proto.h"
+
+
+void plot_cross(double easting, double northing, int color, double rotation)
+{
+    plot_symbol(easting, northing, color, rotation, "basic/cross1");
+}
+
+
+void plot_fiducial(double easting, double northing, int color, double rotation)
+{
+    plot_symbol(easting, northing, color, rotation + 45.0, "extra/fiducial");
+}
+
+
+void plot_symbol(double easting, double northing, int color, double rotation, char *symbol_name)
+{
+    SYMBOL *Symb;
+    RGBA_Color *line_color, *fill_color;
+    int R, G, B;
+    int x0, y0;
+    int size = 16;
+    int tolerance = 0;
+
+    x0 = (int)(D_u_to_d_col(easting)+0.5);
+    y0 = (int)(D_u_to_d_row(northing)+0.5);
+
+    line_color = G_malloc(sizeof(RGBA_Color));
+    fill_color = G_malloc(sizeof(RGBA_Color));
+
+    /* TODO: color->RGB values, for now just use DEFAULT_FG_COLOR */
+    G_str_to_color(DEFAULT_FG_COLOR, &R, &G, &B);
+    line_color->r = (unsigned char) R;
+    line_color->g = (unsigned char) G;
+    line_color->b = (unsigned char) B;
+    line_color->a = RGBA_COLOR_OPAQUE;
+
+    fill_color->a = RGBA_COLOR_NONE;
+
+
+    Symb = S_read( symbol_name );
+    if(!Symb) G_fatal_error(_("Reading symbol"));
+
+    S_stroke( Symb, size, rotation, tolerance );
+    D_symbol( Symb, x0, y0, line_color, fill_color );
+
+    G_free(line_color);
+    G_free(fill_color);
+}

Modified: grass/trunk/display/d.grid/local_proto.h
===================================================================
--- grass/trunk/display/d.grid/local_proto.h	2008-01-28 12:40:32 UTC (rev 29877)
+++ grass/trunk/display/d.grid/local_proto.h	2008-01-28 12:53:01 UTC (rev 29878)
@@ -1,3 +1,5 @@
+#include <grass/gprojects.h>
+
 /* plot.c */
 int plot_grid(double, double, double, int, int, int, int);
 int plot_geogrid(double, struct pj_info, struct pj_info, int, int, int, int);
@@ -8,3 +10,12 @@
 
 /* plotborder.c */
 int plot_border(double, double, double);
+
+#define MARK_GRID     0
+#define MARK_CROSS    1
+#define MARK_FIDUCIAL 2
+
+/* fiducial.c */
+void plot_cross(double, double, int, double);
+void plot_fiducial(double, double, int, double);
+void plot_symbol(double, double, int, double, char*);

Modified: grass/trunk/display/d.grid/main.c
===================================================================
--- grass/trunk/display/d.grid/main.c	2008-01-28 12:40:32 UTC (rev 29877)
+++ grass/trunk/display/d.grid/main.c	2008-01-28 12:53:01 UTC (rev 29878)
@@ -40,7 +40,7 @@
 	int do_text, fontsize;
 	struct GModule *module;
 	struct Option *opt1, *opt2, *opt3, *opt4, *fsize, *tcolor;
-	struct Flag *noborder, *notext, *geogrid, *nogrid, *wgs84;
+	struct Flag *noborder, *notext, *geogrid, *nogrid, *wgs84, *cross, *fiducial;
 	struct pj_info info_in;  /* Proj structures */
 	struct pj_info info_out; /* Proj structures */
 
@@ -101,6 +101,16 @@
 	wgs84->description =
 	    _("Draw geographic grid (referenced to WGS84 ellipsoid)");
 
+#ifdef NOTYET
+	cross = G_define_flag();
+	cross->key = 'c';
+	cross->description = _("Draw '+' marks instead of grid lines");
+
+	fiducial = G_define_flag();
+	fiducial->key = 'f';
+	fiducial->description = _("Draw fiducial marks instead of grid lines");
+#endif
+
 	nogrid = G_define_flag();
 	nogrid->key = 'n';
 	nogrid->description = _("Disable grid drawing");
@@ -132,6 +142,18 @@
 	if(notext->answer) do_text = FALSE;
 	else do_text = TRUE;
 
+#ifdef NOTYET
+	int mark_type = MARK_GRID;
+	if (cross->answer && fiducial->answer)
+		G_fatal_error(_("Chose a single mark style"));
+	if (cross->answer)
+		mark_type = MARK_CROSS;
+	if (fiducial->answer)
+		mark_type = MARK_FIDUCIAL;
+
+	/* then pass mark_type to plot_grid() and plot_geogrid() */
+#endif
+
 	fontsize = atoi(fsize->answer);
 
 	/* get grid size */



More information about the grass-commit mailing list