[GRASS-SVN] r31000 - grass/trunk/gui/tcltk/gis.m

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 15 04:59:26 EDT 2008


Author: marisn
Date: 2008-04-15 04:59:26 -0400 (Tue, 15 Apr 2008)
New Revision: 31000

Modified:
   grass/trunk/gui/tcltk/gis.m/gm.tcl
   grass/trunk/gui/tcltk/gis.m/legend.tcl
   grass/trunk/gui/tcltk/gis.m/mapcanvas.tcl
Log:
gis.m enchance raster legend default height calculation for CELL maps

Modified: grass/trunk/gui/tcltk/gis.m/gm.tcl
===================================================================
--- grass/trunk/gui/tcltk/gis.m/gm.tcl	2008-04-15 07:45:43 UTC (rev 30999)
+++ grass/trunk/gui/tcltk/gis.m/gm.tcl	2008-04-15 08:59:26 UTC (rev 31000)
@@ -121,7 +121,7 @@
 namespace eval Gm {
 	variable gm_mainframe
 	variable status
-	variable array tree # mon
+	variable array tree ;# mon
 	variable rcfile
 	variable moncount
 	variable prgtext
@@ -129,7 +129,7 @@
 	variable dfont 
 	variable selectedfont
 	variable encoding
-	global array filename # mon
+	global array filename ;# mon
 
 }
 
@@ -482,7 +482,7 @@
 		catch {file delete $file}
 	}
 
-	if {[file exists $legfile]} {catch {file delete -force $legfile}}
+	if {[info exists legfile] && [file exists $legfile]} {catch {file delete -force $legfile}}
 
 	unset mon
 

Modified: grass/trunk/gui/tcltk/gis.m/legend.tcl
===================================================================
--- grass/trunk/gui/tcltk/gis.m/legend.tcl	2008-04-15 07:45:43 UTC (rev 30999)
+++ grass/trunk/gui/tcltk/gis.m/legend.tcl	2008-04-15 08:59:26 UTC (rev 31000)
@@ -10,12 +10,12 @@
 ##########################################################################
 
 namespace eval GmLegend {
-    variable array opt # legend current options
+    variable array opt ;# legend current options
     variable count 1
-    variable array lfile # raster
-    variable array lfilemask # raster
+    variable array lfile ;# raster
+    variable array lfilemask ;# raster
     variable optlist
-    variable array dup # vector
+    variable array dup ;# vector
     variable llcorner
 }
 
@@ -153,6 +153,34 @@
     }
 }
 
+# Calculate optimal legend height for CELL maps
+proc GmLegend::getoptimalvsize { varname key op } {
+	upvar #0 $varname var
+	set numclass 0
+	
+	if {[string length $var($key)] > 0} {
+		if {![catch {open "|r.info -t map=$var($key)" r} iinput]} {
+			while {[gets $iinput iline] >= 0} {
+				if {[string equal "datatype=CELL" "$iline"]} {
+					if {![catch {open "|r.describe -1 -n --q map=$var($key)" r} dinput]} {
+						while {[gets $dinput dline] >= 0} {
+							incr numclass
+						}
+					}
+				}
+			}
+		}
+		if {$numclass > 0} {
+			set hg [expr {$numclass * 7}]
+			if {$hg > 80} {
+				set GmLegend::opt([string index $key 0],1,height) 80
+			} else {
+				set GmLegend::opt([string index $key 0],1,height) $hg
+			}
+		}
+	}
+}
+
 ###############################################################################
 # legend options
 proc GmLegend::options { id frm } {
@@ -176,7 +204,7 @@
 	Label $row.c -text [G_msg " Transparent"]
     pack $row.a $row.b $row.c -side left
     pack $row -side top -fill both -expand yes	
-	
+    
     # raster name
     set row [ frame $frm.map ]
     Label $row.a -text [G_msg "Raster map: "]
@@ -185,6 +213,8 @@
 	icon_configure $row.b element cell
     Entry $row.c -width 35 -text " $opt($id,1,map)" \
           -textvariable GmLegend::opt($id,1,map) 
+	trace add variable GmLegend::opt($id,1,map) write GmLegend::getoptimalvsize
+    
     Label $row.d -text "   "
     Button $row.e -text [G_msg "Help"] \
             -command "spawn g.manual --q d.legend" \

Modified: grass/trunk/gui/tcltk/gis.m/mapcanvas.tcl
===================================================================
--- grass/trunk/gui/tcltk/gis.m/mapcanvas.tcl	2008-04-15 07:45:43 UTC (rev 30999)
+++ grass/trunk/gui/tcltk/gis.m/mapcanvas.tcl	2008-04-15 08:59:26 UTC (rev 31000)
@@ -25,23 +25,23 @@
 # source $gmpath/maptool.tcl
 
 namespace eval MapCanvas {
-	variable array displayrequest # Indexed by mon, true if it wants to get displayed.
+	variable array displayrequest ;# Indexed by mon, true if it wants to get displayed.
 
 	# Something's modified the canvas or view, indexed by mon.
 	# Degree of modification 0 - none, 1 - zoom, 2 - canvas
 	variable array canmodified
 
-	variable array can # The canvas widgets of the monitors, indexed by mon
-	variable array mapframe # Frame widgets, indexed by mon
-	variable array canvas_w # Width and height of canvas. Indexed by mon
-	variable array canvas_h # mon
-	variable array driver_w # Actual width and height used while drawing / compositing. Indexed by mon
-	variable array driver_h # Actual width and height used while drawing / compositing. Indexed by mon
-	variable array exploremode # Whether or not to change regions to match monitor, indexed by mon
-	variable array map_ind # Indicator widgets, indexed by mon
-	variable array msg # status message, indexed by mon
-	variable b1north # capture north coordinate on clicking mouse
-	variable b1east # capture east coordinate on clicking mouse
+	variable array can ;# The canvas widgets of the monitors, indexed by mon
+	variable array mapframe ;# Frame widgets, indexed by mon
+	variable array canvas_w ;# Width and height of canvas. Indexed by mon
+	variable array canvas_h ;# mon
+	variable array driver_w ;# Actual width and height used while drawing / compositing. Indexed by mon
+	variable array driver_h ;# Actual width and height used while drawing / compositing. Indexed by mon
+	variable array exploremode ;# Whether or not to change regions to match monitor, indexed by mon
+	variable array map_ind ;# Indicator widgets, indexed by mon
+	variable array msg ;# status message, indexed by mon
+	variable b1north ;# capture north coordinate on clicking mouse
+	variable b1east ;# capture east coordinate on clicking mouse
 
 	
 	# zoom box corners indexed by mon
@@ -83,7 +83,7 @@
 	# Their masks
 	variable array masklist 
 
-	global geoentry "" # variable holds path of entry widgets that use coordinates from canvas
+	global geoentry "" ;# variable holds path of entry widgets that use coordinates from canvas
 
 	# Current region and region historys
 	# Indexed by mon, history (1 (current) - zoomhistories), part (n, s, e, w, nsres, ewres, rows, cols).



More information about the grass-commit mailing list