[GRASS-SVN] r40109 - grass/branches/develbranch_6/gui/tcltk/gis.m

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 22 05:22:07 EST 2009


Author: marisn
Date: 2009-12-22 05:22:06 -0500 (Tue, 22 Dec 2009)
New Revision: 40109

Modified:
   grass/branches/develbranch_6/gui/tcltk/gis.m/labels.tcl
   grass/branches/develbranch_6/gui/tcltk/gis.m/maplabels.tcl
Log:
gis.m: better PS label position calculation

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/labels.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/labels.tcl	2009-12-22 09:41:10 UTC (rev 40108)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/labels.tcl	2009-12-22 10:22:06 UTC (rev 40109)
@@ -10,13 +10,13 @@
 ##########################################################################
 
 namespace eval GmLabels {
-    variable array opt # labels current options
+    variable array opt ;# labels current options
     variable count 1
-    variable array tree # mon    
-    variable array lfile # labels
-    variable array lfilemask # labels
+    variable array tree ;# mon    
+    variable array lfile ;# labels
+    variable array lfilemask ;# labels
     variable optlist
-    variable array dup # layer
+    variable array dup ;# layer
 }
 
 

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/maplabels.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/maplabels.tcl	2009-12-22 09:41:10 UTC (rev 40108)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/maplabels.tcl	2009-12-22 10:22:06 UTC (rev 40109)
@@ -449,7 +449,7 @@
 				set opt($id,1,ltxt) [subst -nocommands -novariables $val]
 				
 				# check to see if there are line breaks in the text
-				set newlines [expr [llength [split $opt($id,1,ltxt) "\n"]] - 1]
+				set newlines [llength [split $opt($id,1,ltxt) "\n"]]
 				
 				# create each label when loop gets to a text line in the labels file
 				# Here should be set all font related options, that come from labelfile
@@ -460,14 +460,14 @@
 				# set the label width and height
 				set linelen [font measure $opt($id,1,lfont) $opt($id,1,ltxt)]
 				if {$linelen < $opt($id,1,lwidth)} {
-					set wid [expr $linelen + 8]
-					set lineh [expr $newlines * [font metrics $opt($id,1,lfont) -linespace] + 8]
+					set wid [expr $linelen + 2]
+					set lineh [expr $newlines * [font metrics $opt($id,1,lfont) -linespace]]
 				} else {
-					set wid $opt($id,1,lwidth)
-					set lineh [expr $newlines * (ceil($linelen/$opt($id,1,lwidth))+1)\
-					 * [font metrics $opt($id,1,lfont) -linespace] + 8]
+					set wid $opt($id,1,lwidth); # This is too wide as wrapped text lines might be shorter.
+					set lineh [expr $newlines * (ceil($linelen/($opt($id,1,lwidth)-15.0)))\
+					 * [font metrics $opt($id,1,lfont) -linespace]]; # Somtimes font measure gives wrong length. -15.0 is a hack.
 				}
-				if {$opt($id,1,lopaque) != "yes"} {
+				if {!$opt($id,1,lopaque)} {
 					set lbackground ""
 				} else { set lbackground $opt($id,1,lbackground) }
 				if {!$opt($id,1,lboxbenable)} {



More information about the grass-commit mailing list