[GRASS-SVN] r49668 - grass/branches/develbranch_6/vector/v.digit

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 12 03:11:29 EST 2011


Author: hamish
Date: 2011-12-12 00:11:29 -0800 (Mon, 12 Dec 2011)
New Revision: 49668

Modified:
   grass/branches/develbranch_6/vector/v.digit/centre.c
   grass/branches/develbranch_6/vector/v.digit/driver.c
   grass/branches/develbranch_6/vector/v.digit/global.h
   grass/branches/develbranch_6/vector/v.digit/main.c
Log:
don't mess with the current WIND file, use WIND_OVERRIDE instead

Modified: grass/branches/develbranch_6/vector/v.digit/centre.c
===================================================================
--- grass/branches/develbranch_6/vector/v.digit/centre.c	2011-12-12 07:33:33 UTC (rev 49667)
+++ grass/branches/develbranch_6/vector/v.digit/centre.c	2011-12-12 08:11:29 UTC (rev 49668)
@@ -1,19 +1,16 @@
-/* ***************************************************************
- * *
- * * MODULE:       v.digit
- * * 
- * * AUTHOR(S):    Radim Blazek
- * *               
- * * PURPOSE:      Edit vector
- * *              
- * * COPYRIGHT:    (C) 2001 by the GRASS Development Team
- * *
- * *               This program is free software under the 
- * *               GNU General Public License (>=v2). 
- * *               Read the file COPYING that comes with GRASS
- * *               for details.
- * *
- * **************************************************************/
+/***************************************************************
+ *
+ * MODULE:	 v.digit
+ * AUTHOR(S):	 Radim Blazek
+ * PURPOSE:	 Edit vector
+ *		
+ * COPYRIGHT:	 (C) 2001 by the GRASS Development Team
+ *		 This program is free software under the 
+ *		 GNU General Public License (>=v2). 
+ *		 Read the file COPYING that comes with GRASS
+ *		 for details.
+ *
+ **************************************************************/
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -24,7 +21,8 @@
 #include "global.h"
 #include "proto.h"
 
-/* This function is started from the GUI, it regularly updates GUI and checks GUI requirements. 
+/* This function is started from the GUI, it regularly updates GUI and
+ *  checks GUI requirements.
  *  If Tool_next is set by GUI, the tool is started by the tool_centre()
  */
 void tool_centre(void)
@@ -174,8 +172,10 @@
     Vect_build(&Map);
     Vect_close(&Map);
 
-    if (1 == G_put_window(&GRegion))
-	G_message("%s", _("Region restored to original extent."));
+    /* abandon temporary region, back to the real one */
+    /* is unsetenv() portable? */
+    putenv("WIND_OVERRIDE=");
+    G_remove("windows", temp_wind_file);
 
     /* clear the screen */
     Tcl_Eval(Toolbox, ".screen.canvas delete all");

Modified: grass/branches/develbranch_6/vector/v.digit/driver.c
===================================================================
--- grass/branches/develbranch_6/vector/v.digit/driver.c	2011-12-12 07:33:33 UTC (rev 49667)
+++ grass/branches/develbranch_6/vector/v.digit/driver.c	2011-12-12 08:11:29 UTC (rev 49668)
@@ -2,6 +2,7 @@
 #include <grass/raster.h>
 #include <grass/display.h>
 #include <grass/colors.h>
+#include <grass/glocale.h>
 #include "global.h"
 #include "proto.h"
 
@@ -78,7 +79,7 @@
     /* Set the map region associated with graphics frame */
     G_get_set_window(&region);
     if (G_set_window(&region) < 0)
-	G_fatal_error("Invalid graphics coordinates");
+	G_fatal_error(_("Can't set window"));
 
     /* Determine conversion factors */
     if (D_do_conversions(&region, t, b, l, r))

Modified: grass/branches/develbranch_6/vector/v.digit/global.h
===================================================================
--- grass/branches/develbranch_6/vector/v.digit/global.h	2011-12-12 07:33:33 UTC (rev 49667)
+++ grass/branches/develbranch_6/vector/v.digit/global.h	2011-12-12 08:11:29 UTC (rev 49668)
@@ -155,7 +155,7 @@
 Global SYMB Symb[SYMB_COUNT];
 
 Global struct Map_info Map;
-Global struct Cell_head GRegion;	/* Current region (synchronized with GRASS WIND) */
+Global char temp_wind_file[24];
 Global Tcl_Interp *Toolbox;
 Global int Tool_next;		/* Next tool to be run */
 Global double Xscale, Yscale;	/* Scale factors = size_in_map / size_on_screen */

Modified: grass/branches/develbranch_6/vector/v.digit/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.digit/main.c	2011-12-12 07:33:33 UTC (rev 49667)
+++ grass/branches/develbranch_6/vector/v.digit/main.c	2011-12-12 08:11:29 UTC (rev 49668)
@@ -12,6 +12,8 @@
 #define MAIN
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include <tcl.h>
 #include <tk.h>
 #include <grass/gis.h>
@@ -97,6 +99,7 @@
     char **tokens;
     char *fake_argv[4];
     char toolbox[GPATH_MAX];
+    struct Cell_head GRegion;
 
     G_gisinit(argv[0]);
 
@@ -139,9 +142,14 @@
 	G_debug(2, "cmd %d : %s", i, Bgcmd[i].cmd);
 
     Tool_next = TOOL_NOTHING;
+
     G_get_window(&GRegion);
     G_debug(1, "Region: N = %f S = %f E = %f W = %f", GRegion.north,
 	    GRegion.south, GRegion.east, GRegion.west);
+    /* set up temporary region */
+    sprintf(temp_wind_file, "tmp_vdigit_%d", getpid());
+    G__put_window(&GRegion, "windows", temp_wind_file);
+    G_putenv("WIND_OVERRIDE", temp_wind_file);
 
     /* Open map */
     mapset = G_find_vector2(map_opt->answer, G_mapset());



More information about the grass-commit mailing list