Ignore:
Timestamp:
Mar 4, 2013 6:37:47 AM (11 years ago)
Author:
gah
Message:

improvements to legend: button-click to activate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/vtkheightmapviewer.tcl

    r3435 r3439  
    139139    private variable _start 0
    140140    private variable _title ""
     141    private variable _isolines
    141142
    142143    common _downloadPopup;              # download options from popup
     
    22482249            -anchor ne \
    22492250            -image $_image(legend) -tags "colormap legend"
     2251        $c create rectangle $x $y 1 1 \
     2252            -fill "" -outline "" -tags "sensor legend"
    22502253        $c create text $x [expr {$h-2}] \
    22512254            -anchor se \
    22522255            -fill $itk_option(-plotforeground) -tags "vmin legend" \
    22532256            -font $font
    2254         #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y]
    2255         $c bind colormap <Leave> [itcl::code $this LeaveLegend]
    2256         $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
     2257        $c bind sensor <B1-Enter> [itcl::code $this EnterLegend %x %y]
     2258        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2259        $c bind sensor <B1-Motion> [itcl::code $this MotionLegend %x %y]
    22572260    }
    22582261    $c delete isoline
     
    22822285        $values seq $vmin $vmax $_settings(numIsolines)
    22832286        set tags "isoline legend"
     2287        array unset _isolines
    22842288        foreach pos [$pixels range 0 end] value [$values range end 0] {
    22852289            set y1 [expr int($pos)]
     2290            for { set off 0 } { $off < 3 } { incr off } {
     2291                set _isolines([expr $y1 + $off]) $value
     2292                set _isolines([expr $y1 - $off]) $value
     2293            }
    22862294            set id [$c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags]
    2287             $c bind $id <Enter> [itcl::code $this EnterIsoline %x %y $value]
    2288             $c bind $id <Leave> [itcl::code $this LeaveIsoline]
     2295            #$c bind $id <B1-Enter> [itcl::code $this EnterIsoline %x %y $value]
     2296            #$c bind $id <Leave> [itcl::code $this LeaveIsoline]
    22892297        }
    22902298        blt::vector destroy $pixels $values
     
    23102318    incr y $lineht
    23112319    $c coords colormap $x $y
     2320    set ix [image width $_image(legend)]
     2321    set ih [image height $_image(legend)]
     2322    $c coords sensor [expr $x - $iw] $y $x [expr $y + $ih]
     2323    $c raise sensor
    23122324    $c coords vmin $x [expr {$h - 2}]
    23132325}
     
    23562368    Rappture::Tooltip::tooltip cancel
    23572369    set c $itk_component(view)
    2358     SetLegendTip $x $y
     2370    set cw [winfo width $c]
     2371    set ch [winfo height $c]
     2372    if { $x >= 0 && $x < $cw && $y >= 0 && $y < $ch } {
     2373        SetLegendTip $x $y
     2374    }
    23592375}
    23602376
     
    23902406    # If there's a legend title, increase the offset by the line height.
    23912407    if { $title != "" } {
    2392         incr iy $lineht
     2408        incr iy -$lineht
    23932409    }
    23942410
     
    24042420    $_image(swatch) put black  -to 0 0 23 23
    24052421    $_image(swatch) put $color -to 1 1 22 22
    2406     .rappturetooltip configure -icon $_image(swatch)
    24072422
    24082423    # Compute the value of the point
     
    24162431    set tipx [expr $x + 15]
    24172432    set tipy [expr $y - 5]
    2418     Rappture::Tooltip::text $c "$title $value"
     2433    .rappturetooltip configure -icon $_image(swatch)
     2434    if { [info exists _isolines($iy)] } {
     2435        Rappture::Tooltip::text $c [format "$title (isoline) %g" $_isolines($iy)]
     2436    } else {
     2437        Rappture::Tooltip::text $c [format "$title %g" $value]
     2438    }
    24192439    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
    24202440}
Note: See TracChangeset for help on using the changeset viewer.