[GRASS-SVN] r43692 - grass/branches/releasebranch_6_4/gui/tcltk/gis.m

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 26 08:01:03 EDT 2010


Author: marisn
Date: 2010-09-26 12:01:03 +0000 (Sun, 26 Sep 2010)
New Revision: 43692

Modified:
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gm.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmlib.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmtree.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/legend.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapcanvas.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapprint.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/maptool.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/profile.tcl
   grass/branches/releasebranch_6_4/gui/tcltk/gis.m/thematic.tcl
Log:
gis.m: prevent crash on exit; close gis.m on CLI exit; remember last used directory for file open/save dialogs; prevent legend duplication failure; list new modules in menu. (Synced to develbranch_6 43689)

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gm.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gm.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gm.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -146,7 +146,7 @@
 	variable selectedfont
 	variable encoding
 	global array filename ;# mon
-
+        variable last_directory ;# last save/load dir for reuse
 }
 
 
@@ -271,8 +271,12 @@
 			Gm::cleanup}
 	}
 
+        if { [info exists env(HOME)] } {
+                set Gm::last_directory $env(HOME)
+        } else {
+                set Gm::last_directory [pwd]
+        }
 
-
 }
 
 
@@ -513,6 +517,21 @@
 
 };
 
+# Provides remote exit call. Used by GRASS exit to close all session's gis.m instances.
+# Argument session_id is exit caller's GIS_LOCK variable.
+proc Gm::remoteExit { session_id } {
+	global env
+	if {$env(GIS_LOCK) == $session_id} Gm::quit
+}
+
+# Provides exit from gis.m. May also do some clean-up, save-settings et.al.
+proc Gm::quit { } {
+	global env
+	
+	# It's unsafe to call exit during Destroy event
+	after idle [list destroy .]
+}
+
 ###############################################################################
 
 proc main {argc argv} {
@@ -538,7 +557,7 @@
 		Gm::SaveFileBox
     }
     bind . <$keycontrol-Key-q> {
-		exit
+		Gm::quit
 	}
     bind . <$keycontrol-Key-w> {
 		GmTree::FileClose {}
@@ -562,6 +581,9 @@
     }
 }
 
+wm protocol . WM_DELETE_WINDOW {
+	Gm::quit
+}
 
 main $argc $argv
 wm geom . [wm geom .]

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmlib.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmlib.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmlib.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -86,7 +86,7 @@
 		[list [G_msg "All Files"] "*"] \
 	]
 
-	set filename_new [tk_getOpenFile -parent $Gm::mainwindow -filetypes $types \
+	set filename_new [tk_getOpenFile -initialdir $Gm::last_directory -parent $Gm::mainwindow -filetypes $types \
 		-title [G_msg "Open File"] ]
 	if { $filename_new == "" } { return}
 	set filename($mon) $filename_new
@@ -115,7 +115,7 @@
 		    [list [G_msg "DM Resource File"] [list {.dm} {.dmrc}]] \
 		    [list [G_msg "All Files"] "*"] \
 		]
-		set filename($mon) [tk_getSaveFile -parent $Gm::mainwindow -filetypes $types \
+		set filename($mon) [tk_getSaveFile -initialdir $Gm::last_directory -parent $Gm::mainwindow -filetypes $types \
 		    -title [G_msg "Save File"] -defaultextension .grc]
 		    if { $filename($mon) == "" } { return}
 		    GmTree::save $filename($mon)

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmmenu.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -201,7 +201,7 @@
 	}}
 	{command {[G_msg "PostScript plot"]} {} "ps.map: Create cartographic PostScript plot" {} -command { execute ps.map }}
 	{separator}
-	{command {[G_msg "E&xit"]} {} "Exit GIS Manager" {} -accelerator $keyctrl-Q -command { exit } }
+	{command {[G_msg "&Quit GIS Manager"]} {} "Exit GIS Manager" {} -accelerator $keyctrl-Q -command { Gm::quit } }
  }
  {[G_msg "&Config"]} all options $tmenu {
 	{cascad {[G_msg "Region"]} {} "" $tmenu {
@@ -259,6 +259,8 @@
 		{command {[G_msg "Blend"]} {} "r.blend: Blend 2 color maps to produce 3 RGB files" {} -command {execute r.blend }}
 		{command {[G_msg "Create RGB"]} {} "r.composite: Create color image from RGB files" {} -command {execute r.composite }}
 		{command {[G_msg "HIS to RGB"]} {} "r.his: Create 3 RGB (red, green, blue) maps from 3 HIS (hue, intensity, saturation) maps" {} -command {execute r.his }}
+		{separator}
+		{command {[G_msg "Query raster color"]} {} "r.what.color: Queries colors for a raster map layer" {} -command {execute r.what.color }}
 	}}
 	{separator}
 	{command {[G_msg "Query by coordinate(s)"]} {} "r.what: Query by coordinate(s)" {} -command { execute r.what }}
@@ -441,6 +443,7 @@
 		{separator}
 		{command {[G_msg "Build polylines"]} {} "v.build.polylines: Build polylines from adjacent segments" {} -command {execute v.build.polylines }}
 		{command {[G_msg "Split polylines"]} {} "v.segment: Split polylines into points and segments" {} -command {execute v.segment }}
+		{command {[G_msg "Split lines to segments"]} {} "v.split: Split vector lines into shorter segments using a maximal distance between nodes" {} -command {execute v.split }}
 		{command {[G_msg "Parallel lines"]} {} "v.parallel: Create lines parallel to existing lines" {} -command {execute v.parallel }}
 		{separator}
 		{command {[G_msg "Dissolve boundaries"]} {} "v.dissolve: Dissolve common boundaries of areas" {} -command {execute v.dissolve }}
@@ -451,6 +454,7 @@
 		{command {[G_msg "Link to OGR"]} {} "v.external: Create new vector as link to external OGR layer" {} -command {execute v.external }}
 		{separator}
 		{command {[G_msg "Create labels"]} {} "v.label: Create text label file for vector objects" {} -command {execute v.label }}
+		{command {[G_msg "Create optimally placed labels"]} {} "v.label.sa: Create optimally placed labels for vector map" {} -command {execute v.label.sa }}
 		{command {[G_msg "Assign colors"]} {} "v.colors: Set color rules using a numeric attribute column" {} -command {execute v.colors }}
 		{separator}
 		{command {[G_msg "Reposition vector"]} {} "v.transform: Reposition (shift, rotate, skew) vector file in coordinate space" {} -command {execute v.transform }}
@@ -533,6 +537,7 @@
 		{command {[G_msg "Upload or report topology"]} {} "v.to.db: Update database fields or create reports from vector topology" {} -command {execute v.to.db }}
  		{separator}
 		{command {[G_msg "Univariate attribute statistics"]} {} "v.univar: Calculate univariate statistics for vector attributes" {} -command {execute v.univar }}
+		{command {[G_msg "Attribute classification"]} {} "v.class: Classifies attribute data" {} -command {execute v.class }}
  		{separator}
 		{command {[G_msg "Quadrat indices"]} {} "v.qcount: Indices of point counts in quadrats" {} -command {execute v.qcount }}
 		{command {[G_msg "Test normality"]} {} "v.normal: Test normality of point distribution" {} -command {execute v.normal }}
@@ -602,6 +607,8 @@
 	{command {[G_msg "Interpolate volume from vector points"]} {} "v.vol.rst: Interpolate volume from vector points using splines" {} -command {execute v.vol.rst }}
 	{cascad {[G_msg "Report and Statistics"]} {} "" $tmenu {			
 		{command {[G_msg "Basic information"]} {} "r3.info: Display information about grid3D volume" {} -command {execute r3.info }}
+		{command {[G_msg "General statistics"]} {} "r3.stats: Generates volume statistics for raster3d maps" {} -command {execute r3.stats }}
+		{command {[G_msg "Univariate statistics"]} {} "r3.univar: Calculates univariate statistics of a raster3d map" {} -command {execute r3.univar }}
 	}}
  } 
  {[G_msg "&Databases"]} all options $tmenu {
@@ -637,6 +644,10 @@
 		{command {[G_msg "Reconnect vector to database"]} {} "v.db.reconnect.all: Reconnect vector map to attribute database" {} -command {execute v.db.reconnect.all }}
 		{command {[G_msg "Set vector - database connection"]} {} "v.db.connect: Set database connection for vector attributes" {} -command {execute v.db.connect }}
 	}}
+	{separator}
+	{cascad {[G_msg "Report and Statistics"]} {} "" $tmenu {
+                {command {[G_msg "Univariate statistics"]} {} "v.db.univar: Calculates univariate statistics on selected table column" {} -command {execute v.db.univar }}
+        }}
  } 
 {[G_msg "&Help"]} all options $tmenu {
 	{command {[G_msg "GRASS help"]} {} "g.manual" {} -command { exec g.manual -i > $devnull & } }

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmtree.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmtree.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/gmtree.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -730,7 +730,9 @@
 	if {[catch {close $rcfile} error]} {
         GmLib::errmsg $error
 	}
-
+    if { $fpath != "" } {
+        set Gm::last_directory [file dirname $fpath]
+    }
 }
 
 

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/legend.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/legend.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/legend.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -33,7 +33,6 @@
     
 
     set node "legend:$count"
-	set dup($count) 1
 
     set frm [ frame .legendicon$count]
     set check [checkbutton $frm.check \
@@ -455,6 +454,7 @@
 	variable dup
 
     set node "legend:$count"
+    set dup($count) 1
 
     set frm [ frame .legendicon$count]
     set check [checkbutton $frm.check \
@@ -490,9 +490,6 @@
 
 	set opt($count,1,opacity) $opt($id,1,opacity)
 
-	set optlist { _check map opacity color lines thin labelnum at height width \
-             mouseset use range nolbl noval skip smooth flip}
-             
     foreach key $optlist {
     	set opt($count,1,$key) $opt($id,1,$key)
 		set opt($count,0,$key) $opt($count,1,$key)

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapcanvas.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapcanvas.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapcanvas.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -478,22 +478,21 @@
 	    while {[gets $input line] >= 0} {
 	    	if { [string equal "XY location (unprojected)" "$line"] } {
 	    	    set mapunits "map units"
-                set prj(proj) "xy"
 	    	    break
 	    	}
 	    	regexp -nocase {^(.*):(.*)$} $line trash key value
 	    	set key [string trim $key]
 	    	set value [string trim $value]
-	    	set prj($key) $value	
+	    	set prj($key) $value
 	    }
 
         # Set for latlon locations
         if { [ info exist prj ] && $prj(proj) == "ll"} {set proj_is_ll 1}
         
         if {[catch {close $input} error]} {
-			GmLib::errmsg $error [G_msg "g.proj or projection error"]
-			return
-	    } 
+		GmLib::errmsg $error [G_msg "g.proj or projection error"]
+		return
+	    }
 	}
 	# Length is calculated from the map canvas arrows
 	#  and so is measured & plotted in map units.
@@ -710,10 +709,10 @@
 		cd $currdir
 	}
 
-	GmTree::cvdisplay "root"
-	set drawprog 100
-
+	# cvdisplay might need new canvas coordinates. Coordconv has to be run first!
 	MapCanvas::coordconv $mon
+	GmTree::cvdisplay "root"
+	
 	set drawprog 0
 	$mapframe($mon) showstatusbar status
 	return

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapprint.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapprint.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/mapprint.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -337,7 +337,7 @@
 		-state $psprint::gsstate 
 	Entry $row.c -width 30 -textvariable psprint::pdffile  -state $gsstate
 	Button $row.d -text [G_msg "Browse"]  -command { set psprint::pdffile \
-		[tk_getSaveFile -title "Output PDF file" -defaultextension ".pdf"]} \
+		[tk_getSaveFile -initialdir $Gm::last_directory -title "Output PDF file" -defaultextension ".pdf"]} \
 		-state $psprint::gsstate
 	pack $row.a $row.b $row.c $row.d -side left;
 	pack $row -side top -fill x -expand no -anchor n
@@ -349,7 +349,7 @@
 	Label $row.b -anchor w -text [G_msg "Save to EPS file               "] 
 	Entry $row.c -width 30 -textvariable psprint::epsfile 
 	Button $row.d -text [G_msg "Browse"] -command { set psprint::epsfile \
-	       [ tk_getSaveFile -title "Output EPS file" -defaultextension ".eps"] }
+	       [ tk_getSaveFile -initialdir $Gm::last_directory -title "Output EPS file" -defaultextension ".eps"] }
 	pack $row.a $row.b $row.c $row.d -side left;
 	pack $row -side top -fill x -expand no -anchor n
 	
@@ -448,7 +448,7 @@
 		if {[catch {exec $cmd  $format -sDEVICE#pdfwrite -r$res -sNOPAUSE -sOutputFile#$pdffile -dBATCH -- $tmppsfile} error]} {
 			GmLib::errmsg $error
 		}
-		 
+		set Gm::last_directory [file dirname $pdffile]
 	}
 
 	# output to eps file
@@ -458,6 +458,7 @@
 		} else {
 			$cv postscript -file "$epsfile" -rotate 1
 		}
+		set Gm::last_directory [file dirname $epsfile]
 	}
 	
 	psprint::clean

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/maptool.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/maptool.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/maptool.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -374,14 +374,8 @@
 
 	set outfile($mon) $MapCanvas::outfile($mon)
 
-	if { [info exists env(HOME)] } {
-		set dir $env(HOME)
-		set path [tk_getSaveFile -initialdir $dir \
-			-title "Save Mapcanvas contents to file"]
-	} else {
-		set path [tk_getSaveFile \
-			-title "Save Mapcanvas contents to file"]
-	}
+	set path [tk_getSaveFile -initialdir $Gm::last_directory \
+		-title "Save Mapcanvas contents to file" ]
 	set currdir [pwd]
 	cd $tmpdir
 
@@ -451,6 +445,7 @@
 				catch {file delete $path.ppm}
 			}
 		}
+                set Gm::last_directory [file dirname $path] ;# update last path only when user saves something
 	}
 	return
 }

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/profile.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/profile.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/profile.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -195,16 +195,13 @@
 	set types {
     {{EPS} {.eps}}
 	}
-
-	if { [info exists HOME] } {
-		set dir $env(HOME)
-		set path [tk_getSaveFile -filetypes $types -initialdir $dir \
+	set path [tk_getSaveFile -initialdir $Gm::last_directory -filetypes $types \
 			-defaultextension ".eps" -parent .profile]
-	} else {
-		set path [tk_getSaveFile -filetypes $types -defaultextension ".eps" -parent .profile]
-	}
 	
 	$pcan postscript -file "$path"
+	if { $path != "" } {
+                 set Gm::last_directory [file dirname $path]
+        }
 
 	return
 }

Modified: grass/branches/releasebranch_6_4/gui/tcltk/gis.m/thematic.tcl
===================================================================
--- grass/branches/releasebranch_6_4/gui/tcltk/gis.m/thematic.tcl	2010-09-26 11:36:21 UTC (rev 43691)
+++ grass/branches/releasebranch_6_4/gui/tcltk/gis.m/thematic.tcl	2010-09-26 12:01:03 UTC (rev 43692)
@@ -837,15 +837,13 @@
     {{EPS} {.eps}}
 	}
 
-	if { [info exists HOME] } {
-		set dir $env(HOME)
-		set path [tk_getSaveFile -filetypes $types -initialdir $dir \
+	set path [tk_getSaveFile -initialdir $Gm::last_directory -filetypes $types \
 			-defaultextension ".eps"]
-	} else {
-		set path [tk_getSaveFile -filetypes $types -defaultextension ".eps"]
-	}
 	
 	$tlegcan($mon,$id) postscript -file "$path"
+	if { $path != "" } {
+                set Gm::last_directory [file dirname $path]
+        }
 
 	return
 }



More information about the grass-commit mailing list