Changeset 43426


Ignore:
Timestamp:
Sep 8, 2010, 7:18:26 AM (14 years ago)
Author:
marisn
Message:

gis.m Fix PS Label placement problems on zoom-in/out

Location:
grass/branches/develbranch_6/gui/tcltk/gis.m
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • grass/branches/develbranch_6/gui/tcltk/gis.m/mapcanvas.tcl

    r39856 r43426  
    710710        }
    711711
     712        # cvdisplay might need new canvas coordinates. Coordconv has to be run first!
     713        MapCanvas::coordconv $mon
    712714        GmTree::cvdisplay "root"
    713         set drawprog 100
    714 
    715         MapCanvas::coordconv $mon
     715       
    716716        set drawprog 0
    717717        $mapframe($mon) showstatusbar status
  • grass/branches/develbranch_6/gui/tcltk/gis.m/maplabels.tcl

    r40450 r43426  
    2929    variable optlist
    3030    variable array dup ;# layer
     31    variable canvasId  ;# List of canvas item ID's for deletion on update
    3132}
    3233
     
    3738    variable optlist
    3839        variable dup
     40    variable canvasId
    3941    global mon
    4042    global iconpath
     
    105107    foreach key $optlist {
    106108                set opt($count,0,$key) $opt($count,1,$key)
    107     }
     109    }
     110   
     111    set canvasId [ list ] ;# CanvasId is an empty list
    108112       
    109113    incr count
     
    299303    variable dup
    300304    variable count
     305    variable canvasId
    301306   
    302307    set tree($mon) $GmTree::tree($mon)
    303308    set id [GmTree::node_id $node]
    304309   
     310    # No need to do anything, if we are invisible/unset.
     311    if { ! ( $opt($id,1,_check) ) } { return }
    305312    if {$opt($id,1,labels) == "" } {return}
    306313   
     
    313320                set labelpath "$env(GISDBASE)/$env(LOCATION_NAME)/$env(MAPSET)/paint/labels/$opt($id,1,labels)"
    314321    }
    315 
    316     if { ! ( $opt($id,1,_check) ) } { return }
    317322   
    318323    # open the v.label file for reading
     
    321326                return
    322327        }
     328       
     329        # Delete current labels on Canvas and empty ID list
     330        $can($mon) delete canvasId
     331        set canvasId [ list ] ;# CanvasId is an empty list
    323332       
    324333        #loop through coordinates and options for each label
     
    485494
    486495                                # create box around text
    487                                
    488                                 switch $ropt($id,1,anchor) {
    489                                         "ne" {
    490                                                 set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
    491                                                 set boxcenter_y [expr {$ropt($id,1,ycoord) + ($lineh+4) / 2}]
    492                                                 }
    493                                         "n" {
    494                                                 set boxcenter_x $ropt($id,1,xcoord)
    495                                                 set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
    496                                                 }
    497                                         "nw" {
    498                                                 set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
    499                                                 set boxcenter_y [expr {$ropt($id,1,ycoord) + ($lineh+4) / 2}]
    500                                                 }
    501                                         "e" {
    502                                                 set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
    503                                                 set boxcenter_y $ropt($id,1,ycoord)
    504                                                 }
    505                                         "center" {
    506                                                 set boxcenter_x $ropt($id,1,xcoord)
    507                                                 set boxcenter_y $ropt($id,1,ycoord)
    508                                                 }
    509                                         "w" {
    510                                                 set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
    511                                                 set boxcenter_y $ropt($id,1,ycoord)
    512                                                 }
    513                                         "se" {
    514                                                 set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
    515                                                 set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
    516                                                 }
    517                                         "s" {
    518                                                 set boxcenter_x $ropt($id,1,xcoord)
    519                                                 set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
    520                                                 }
    521                                         "sw" {
    522                                                 set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
    523                                                 set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
    524                                                 }
    525                                         default {
    526                                                 set boxcenter_x $ropt($id,1,xcoord)
    527                                                 set boxcenter_y $ropt($id,1,ycoord)
    528                                                 }
     496                                if {$opt($id,1,lboxenable)} {
     497                                  switch $ropt($id,1,anchor) {
     498                                          "ne" {
     499                                                  set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
     500                                                  set boxcenter_y [expr {$ropt($id,1,ycoord) + ($lineh+4) / 2}]
     501                                                  }
     502                                          "n" {
     503                                                  set boxcenter_x $ropt($id,1,xcoord)
     504                                                  set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
     505                                                  }
     506                                          "nw" {
     507                                                  set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
     508                                                  set boxcenter_y [expr {$ropt($id,1,ycoord) + ($lineh+4) / 2}]
     509                                                  }
     510                                          "e" {
     511                                                  set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
     512                                                  set boxcenter_y $ropt($id,1,ycoord)
     513                                                  }
     514                                          "center" {
     515                                                  set boxcenter_x $ropt($id,1,xcoord)
     516                                                  set boxcenter_y $ropt($id,1,ycoord)
     517                                                  }
     518                                          "w" {
     519                                                  set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
     520                                                  set boxcenter_y $ropt($id,1,ycoord)
     521                                                  }
     522                                          "se" {
     523                                                  set boxcenter_x [expr {$ropt($id,1,xcoord) - ($wid-4) / 2}]
     524                                                  set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
     525                                                  }
     526                                          "s" {
     527                                                  set boxcenter_x $ropt($id,1,xcoord)
     528                                                  set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
     529                                                  }
     530                                          "sw" {
     531                                                  set boxcenter_x [expr {$ropt($id,1,xcoord) + ($wid-4) / 2}]
     532                                                  set boxcenter_y [expr {$ropt($id,1,ycoord) - ($lineh+4) / 2}]
     533                                                  }
     534                                          default {
     535                                                  set boxcenter_x $ropt($id,1,xcoord)
     536                                                  set boxcenter_y $ropt($id,1,ycoord)
     537                                                  }
     538                                  }
    529539                                }
    530540
    531541                                if {$opt($id,1,lboxenable)} {
    532542                                        # draw recangle around label
    533                                         $can($mon) create rectangle \
     543                                        lappend canvasId [$can($mon) create rectangle \
    534544                                                [expr {$boxcenter_x - $opt($id,1,lhoffset) - $wid / 2}] \
    535545                                                [expr {$boxcenter_y -2- $opt($id,1,lvoffset) - $lineh / 2}]\
     
    538548                                                -width  $wdth \
    539549                                                -outline $ropt($id,1,lborder) \
    540                                                 -fill $lbackground
    541                                 }
    542                                 $can($mon) create text $ropt($id,1,xcoord) $ropt($id,1,ycoord) \
     550                                                -fill $lbackground]
     551                                }
     552                                lappend canvasId [$can($mon) create text $ropt($id,1,xcoord) $ropt($id,1,ycoord) \
    543553                                        -anchor $ropt($id,1,anchor) \
    544554                                        -justify $opt($id,1,ljust) \
     
    546556                                        -fill $ropt($id,1,lfill) \
    547557                                        -font $ropt($id,1,lfont) \
    548                                         -text $ropt($id,1,ltxt)
     558                                        -text $ropt($id,1,ltxt)]
    549559                        }
    550560                        default {
Note: See TracChangeset for help on using the changeset viewer.