Ignore:
Timestamp:
Jan 27, 2010, 8:41:20 PM (15 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/gui/scripts/xyresult.tcl

    r1643 r1644  
    166166            -rightmargin 10
    167167    } {
    168         keep -background -foreground -cursor -font
     168        keep -foreground -cursor -font
    169169    }
    170170    pack $itk_component(plot) -expand yes -fill both
     
    252252    after idle [subst {
    253253        update idletasks
    254         #$itk_component(legend) reset
     254        $itk_component(legend) reset
    255255    }]
    256256
     
    601601    eval $g element delete [$g element names]
    602602    foreach axis [$g axis names] {
    603         $g axis configure $axis -hide yes -checklimits no
     603        $g axis configure $axis -hide yes -checklimits no \
     604            -activeforeground blue
    604605    }
    605606    # Presumably you want at least an X-axis and Y-axis displayed.
     
    667668        $g axis bind $axis <Leave> \
    668669            [itcl::code $this _axis hilite $axis off]
    669         $g axis bind $axis <ButtonPress> \
     670        $g axis bind $axis <ButtonPress-1> \
    670671            [itcl::code $this _axis click $axis %x %y]
    671672        $g axis bind $axis <B1-Motion> \
    672673            [itcl::code $this _axis drag $axis %x %y]
    673         $g axis bind $axis <ButtonRelease> \
     674        $g axis bind $axis <ButtonRelease-1> \
    674675            [itcl::code $this _axis release $axis %x %y]
    675676        $g axis bind $axis <KeyPress> \
     
    907908    set tip ""
    908909    if {$state == "at"} {
    909         if {[$g element closest $x $y info -interpolate yes]} {
     910        set results [$g element closest $x $y -interpolate yes]
     911        if { $results != "" } {
     912            array set info $results
    910913            # for dealing with xy line plots
    911914            set elem $info(name)
     
    922925            set tip ""
    923926            array unset info
    924             if {[$g element closest $x $y info -interpolate no]
    925                   && $info(name) == $elem} {
     927            set results [$g element closest $x $y -interpolate no]
     928            array set info $results
     929            if { [info exists info(name)] && $info(name) == $elem } {
    926930
    927931                set x [$g axis transform $mapx $info(x)]
     
    944948            }
    945949            set state 1
    946         } elseif {[$g element closest $x $y info -interpolate no]} {
    947             # for dealing with xy scatter plot
    948             set elem $info(name)
    949 
    950             # Some elements are generated dynamically and therefore will
    951             # not have a curve object associated with them.
    952             set mapx [$g element cget $elem -mapx]
    953             set mapy [$g element cget $elem -mapy]
    954             if {[info exists _elem2curve($elem)]} {
    955                 foreach {mapx mapy} [_getAxes $_elem2curve($elem)] break
    956             }
    957 
    958             set tip ""
    959             set x [$g axis transform $mapx $info(x)]
    960             set y [$g axis transform $mapy $info(y)]
     950        } else {
     951            set results [$g element closest $x $y -interpolate no]
     952            if { $results != ""  } {
     953                array unset info
     954                array set info $results
     955                # for dealing with xy scatter plot
     956                set elem $info(name)
     957               
     958                # Some elements are generated dynamically and therefore will
     959                # not have a curve object associated with them.
     960                set mapx [$g element cget $elem -mapx]
     961                set mapy [$g element cget $elem -mapy]
     962                if {[info exists _elem2curve($elem)]} {
     963                    foreach {mapx mapy} [_getAxes $_elem2curve($elem)] break
     964                }
     965               
     966                set tip ""
     967                set x [$g axis transform $mapx $info(x)]
     968                set y [$g axis transform $mapy $info(y)]
    961969               
    962             if {[info exists _elem2curve($elem)]} {
    963                 set curve $_elem2curve($elem)
    964                 set yunits [$curve hints yunits]
    965                 set xunits [$curve hints xunits]
    966             } else {
    967                 set xunits ""
    968                 set yunits ""
    969             }
    970             set tip [$g element cget $elem -label]
    971             set yval [_axis format y dummy $info(y)]
    972             append tip "\n$yval$yunits"
    973             set xval [_axis format x dummy $info(x)]
    974             append tip " @ $xval$xunits"
    975             set tip [string trim $tip]
    976             set state 1
    977         } else {
    978             set state 0
    979         }
     970                if {[info exists _elem2curve($elem)]} {
     971                    set curve $_elem2curve($elem)
     972                    set yunits [$curve hints yunits]
     973                    set xunits [$curve hints xunits]
     974                } else {
     975                    set xunits ""
     976                    set yunits ""
     977                }
     978                set tip [$g element cget $elem -label]
     979                set yval [_axis format y dummy $info(y)]
     980                append tip "\n$yval$yunits"
     981                set xval [_axis format x dummy $info(x)]
     982                append tip " @ $xval$xunits"
     983                set tip [string trim $tip]
     984                set state 1
     985            } else {
     986                set state 0
     987            }
     988        }
    980989    }
    981990
     
    11181127itcl::body Rappture::XyResult::_axis {option args} {
    11191128    set inner [$itk_component(hull).axes component inner]
    1120 
    11211129    switch -- $option {
    11221130        hilite {
     
    11291137
    11301138            if {$state} {
    1131                 $g axis configure $axis \
    1132                     -color $itk_option(-activecolor) \
    1133                     -titlecolor $itk_option(-activecolor)
    1134 
     1139                $g axis activate $axis
     1140                update
    11351141                set x [expr {[winfo pointerx $g]+4}]
    11361142                set y [expr {[winfo pointery $g]+4}]
    11371143                Rappture::Tooltip::tooltip pending $g-$axis @$x,$y
    11381144            } else {
    1139                 $g axis configure $axis \
    1140                     -color $itk_option(-foreground) \
    1141                     -titlecolor $itk_option(-foreground)
     1145                $g axis deactivate $axis
     1146                update
    11421147                Rappture::Tooltip::tooltip cancel
    11431148            }
     
    15531558# ----------------------------------------------------------------------
    15541559itcl::configbody Rappture::XyResult::gridcolor {
    1555     if {"" == $itk_option(-gridcolor)} {
     1560    if { "" == $itk_option(-gridcolor) } {
    15561561        foreach axis [$itk_component(plot) axis names] {
    1557             $itk_component(plot) axis configure -grid off
     1562            $itk_component(plot) axis configure $axis -grid off
    15581563        }
    15591564    } else {
    15601565        foreach axis [$itk_component(plot) axis names] {
    1561             $itk_component(plot) axis configure \
     1566            $itk_component(plot) axis configure $axis \
    15621567                -gridcolor $itk_option(-gridcolor) -grid on
    15631568        }
Note: See TracChangeset for help on using the changeset viewer.