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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 8 10:18:26 EDT 2010


Author: marisn
Date: 2010-09-08 14:18:26 +0000 (Wed, 08 Sep 2010)
New Revision: 43426

Modified:
   grass/branches/develbranch_6/gui/tcltk/gis.m/mapcanvas.tcl
   grass/branches/develbranch_6/gui/tcltk/gis.m/maplabels.tcl
Log:
gis.m Fix PS Label placement problems on zoom-in/out

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/mapcanvas.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/mapcanvas.tcl	2010-09-07 22:29:20 UTC (rev 43425)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/mapcanvas.tcl	2010-09-08 14:18:26 UTC (rev 43426)
@@ -709,10 +709,10 @@
 		cd $currdir
 	}
 
+	# cvdisplay might need new canvas coordinates. Coordconv has to be run first!
+	MapCanvas::coordconv $mon
 	GmTree::cvdisplay "root"
-	set drawprog 100
-
-	MapCanvas::coordconv $mon
+	
 	set drawprog 0
 	$mapframe($mon) showstatusbar status
 	return

Modified: grass/branches/develbranch_6/gui/tcltk/gis.m/maplabels.tcl
===================================================================
--- grass/branches/develbranch_6/gui/tcltk/gis.m/maplabels.tcl	2010-09-07 22:29:20 UTC (rev 43425)
+++ grass/branches/develbranch_6/gui/tcltk/gis.m/maplabels.tcl	2010-09-08 14:18:26 UTC (rev 43426)
@@ -28,6 +28,7 @@
     variable array tree ;# mon    
     variable optlist
     variable array dup ;# layer
+    variable canvasId  ;# List of canvas item ID's for deletion on update
 }
 
 
@@ -36,6 +37,7 @@
     variable count
     variable optlist
 	variable dup
+    variable canvasId
     global mon
     global iconpath
 
@@ -104,7 +106,9 @@
 
     foreach key $optlist {
 		set opt($count,0,$key) $opt($count,1,$key)
-    } 
+    }
+    
+    set canvasId [ list ] ;# CanvasId is an empty list
         
     incr count
     return $node
@@ -298,10 +302,13 @@
     variable tree
     variable dup
     variable count
+    variable canvasId
     
     set tree($mon) $GmTree::tree($mon)
     set id [GmTree::node_id $node]
     
+    # No need to do anything, if we are invisible/unset.
+    if { ! ( $opt($id,1,_check) ) } { return } 
     if {$opt($id,1,labels) == "" } {return}
     
     set can($mon) $MapCanvas::can($mon)
@@ -312,8 +319,6 @@
     } else {
 		set labelpath "$env(GISDBASE)/$env(LOCATION_NAME)/$env(MAPSET)/paint/labels/$opt($id,1,labels)"
     }
-
-    if { ! ( $opt($id,1,_check) ) } { return } 
     
     # open the v.label file for reading
 	if { [catch {set labelfile [open $labelpath r]} err ] } {
@@ -321,6 +326,10 @@
 		return
 	}
 	
+	# Delete current labels on Canvas and empty ID list
+	$can($mon) delete canvasId
+	set canvasId [ list ] ;# CanvasId is an empty list
+	
 	#loop through coordinates and options for each label
     while { [gets $labelfile in] > -1 } {
 		set key ""
@@ -484,68 +493,69 @@
 				} else { set wdth $ropt($id,1,lbwidth) }
 
 				# create box around text
-				
-				switch $ropt($id,1,anchor) {
-					"ne" { 
-						set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}] 
-						set boxcenter_y [expr {$ropt($id,1,ycoord) + ($lineh+4) / 2}]
-						}
-					"n" { 
-						set boxcenter_x $ropt($id,1,xcoord)
-						set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
-						}
-					"nw" { 
-						set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
-						set boxcenter_y [expr {$ropt($id,1,ycoord) + ($lineh+4) / 2}]
-						}
-					"e" { 
-						set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
-						set boxcenter_y $ropt($id,1,ycoord)
-						}
-					"center" { 
-						set boxcenter_x $ropt($id,1,xcoord)
-						set boxcenter_y $ropt($id,1,ycoord)
-						}
-					"w" { 
-						set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
-						set boxcenter_y $ropt($id,1,ycoord)
-						}
-					"se" { 
-						set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
-						set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
-						}
-					"s" { 
-						set boxcenter_x $ropt($id,1,xcoord)
-						set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
-						}
-					"sw" { 
-						set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
-						set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
-						}
-					default { 
-						set boxcenter_x $ropt($id,1,xcoord)
-						set boxcenter_y $ropt($id,1,ycoord)
-						}
+				if {$opt($id,1,lboxenable)} { 
+				  switch $ropt($id,1,anchor) {
+					  "ne" { 
+						  set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}] 
+						  set boxcenter_y [expr {$ropt($id,1,ycoord) + ($lineh+4) / 2}]
+						  }
+					  "n" { 
+						  set boxcenter_x $ropt($id,1,xcoord)
+						  set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
+						  }
+					  "nw" { 
+						  set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
+						  set boxcenter_y [expr {$ropt($id,1,ycoord) + ($lineh+4) / 2}]
+						  }
+					  "e" { 
+						  set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
+						  set boxcenter_y $ropt($id,1,ycoord)
+						  }
+					  "center" { 
+						  set boxcenter_x $ropt($id,1,xcoord)
+						  set boxcenter_y $ropt($id,1,ycoord)
+						  }
+					  "w" { 
+						  set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
+						  set boxcenter_y $ropt($id,1,ycoord)
+						  }
+					  "se" { 
+						  set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
+						  set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
+						  }
+					  "s" { 
+						  set boxcenter_x $ropt($id,1,xcoord)
+						  set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
+						  }
+					  "sw" { 
+						  set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
+						  set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
+						  }
+					  default { 
+						  set boxcenter_x $ropt($id,1,xcoord)
+						  set boxcenter_y $ropt($id,1,ycoord)
+						  }
+				  }
 				}
 
 				if {$opt($id,1,lboxenable)} { 
 					# draw recangle around label
-					$can($mon) create rectangle \
+					lappend canvasId [$can($mon) create rectangle \
 						[expr {$boxcenter_x - $opt($id,1,lhoffset) - $wid / 2}] \
 						[expr {$boxcenter_y -2- $opt($id,1,lvoffset) - $lineh / 2}]\
 						[expr {$boxcenter_x + $opt($id,1,lhoffset) + $wid / 2}] \
 						[expr {$boxcenter_y + $opt($id,1,lvoffset) + $lineh / 2}]\
 						-width  $wdth \
 						-outline $ropt($id,1,lborder) \
-						-fill $lbackground
+						-fill $lbackground]
 				}
-				$can($mon) create text $ropt($id,1,xcoord) $ropt($id,1,ycoord) \
+				lappend canvasId [$can($mon) create text $ropt($id,1,xcoord) $ropt($id,1,ycoord) \
 					-anchor $ropt($id,1,anchor) \
 					-justify $opt($id,1,ljust) \
 					-width $wid \
 					-fill $ropt($id,1,lfill) \
 					-font $ropt($id,1,lfont) \
-					-text $ropt($id,1,ltxt)
+					-text $ropt($id,1,ltxt)]
 			} 
 			default {
 				#for anything else, just move on



More information about the grass-commit mailing list