Ignore:
Timestamp:
Oct 22, 2010 4:06:10 PM (14 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

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

    r1342 r1929  
    3030    # create a spectrum to use for all temperature widgets
    3131    private common _spectrum [Rappture::Spectrum [namespace current]::#auto {
    32         0.0    blue
    33         300.0  red
    34         500.0  yellow
     32        0.0    blue
     33        300.0  red
     34        500.0  yellow
    3535    } -units K]
    3636}
     
    5959
    6060    if {"" == [$c find all]} {
    61         # first time around, create the items
    62         $c create oval 0 0 1 1 -outline "" -tags bulbfill
    63         $c create oval 0 0 1 1 -outline black -tags bulboutline
    64         $c create oval 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags {bulbscreen screen}
    65         $c create rect 0 0 1 1 -outline black -fill white -tags stickoutline
    66         $c create rect 0 0 1 1 -outline "" -tags stickfill
    67         $c create rect 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags {stickscreen screen}
    68         $c create image 0 0 -anchor w -image "" -tags bimage
     61        # first time around, create the items
     62        $c create oval 0 0 1 1 -outline "" -tags bulbfill
     63        $c create oval 0 0 1 1 -outline black -tags bulboutline
     64        $c create oval 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags {bulbscreen screen}
     65        $c create rect 0 0 1 1 -outline black -fill white -tags stickoutline
     66        $c create rect 0 0 1 1 -outline "" -tags stickfill
     67        $c create rect 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags {stickscreen screen}
     68        $c create image 0 0 -anchor w -image "" -tags bimage
    6969    }
    7070
    7171    if {"" != $itk_option(-spectrum)} {
    72         set color [$itk_option(-spectrum) get [value]]
    73         set frac [$itk_option(-spectrum) get -fraction [value]]
     72        set color [$itk_option(-spectrum) get [value]]
     73        set frac [$itk_option(-spectrum) get -fraction [value]]
    7474    } else {
    75         set color ""
    76         set frac 0
     75        set color ""
     76        set frac 0
    7777    }
    7878
     
    8282    $c coords bimage 0 $y
    8383    if {$itk_option(-image) != ""} {
    84         set x [expr {$x + [image width $itk_option(-image)] + 2}]
     84        set x [expr {$x + [image width $itk_option(-image)] + 2}]
    8585    }
    8686
    8787    set avail [expr {$w-$x}]
    8888    if {$avail > 0} {
    89         #
    90         # If we have any space left over, draw the thermometer
    91         # as a mercury bulb on the left and a stick to the right.
    92         #
    93         set bsize [expr {0.2*$avail}]
    94         if {$bsize > 0.5*$h-2} {set bsize [expr {0.5*$h-2}]}
    95         set ssize [expr {0.5*$bsize}]
     89        #
     90        # If we have any space left over, draw the thermometer
     91        # as a mercury bulb on the left and a stick to the right.
     92        #
     93        set bsize [expr {0.2*$avail}]
     94        if {$bsize > 0.5*$h-2} {set bsize [expr {0.5*$h-2}]}
     95        set ssize [expr {0.5*$bsize}]
    9696
    97         $c coords bulboutline $x [expr {$y-$bsize}] \
    98             [expr {$x+2*$bsize}] [expr {$y+$bsize}]
    99         $c coords bulbscreen [expr {$x-1}] [expr {$y-$bsize-1}] \
    100             [expr {$x+2*$bsize+1}] [expr {$y+$bsize+1}]
    101         $c coords bulbfill $x [expr {$y-$bsize}] \
    102             [expr {$x+2*$bsize}] [expr {$y+$bsize}]
     97        $c coords bulboutline $x [expr {$y-$bsize}] \
     98            [expr {$x+2*$bsize}] [expr {$y+$bsize}]
     99        $c coords bulbscreen [expr {$x-1}] [expr {$y-$bsize-1}] \
     100            [expr {$x+2*$bsize+1}] [expr {$y+$bsize+1}]
     101        $c coords bulbfill $x [expr {$y-$bsize}] \
     102            [expr {$x+2*$bsize}] [expr {$y+$bsize}]
    103103
    104         set x0 [expr {$x+2*$bsize+1}]
    105         set x1 [expr {$w-2}]
    106         set xr [expr {($x1-$x0)*$frac + $x0}]
    107         $c coords stickoutline [expr {$x0-2}] [expr {$y-$ssize}] \
    108             $x1 [expr {$y+$ssize}]
    109         $c coords stickscreen [expr {$x0-2}] [expr {$y-$ssize}] \
    110             [expr {$x1+1}] [expr {$y+$ssize+1}]
    111         $c coords stickfill [expr {$x0-2}] [expr {$y-$ssize+1}] \
    112             $xr [expr {$y+$ssize}]
     104        set x0 [expr {$x+2*$bsize+1}]
     105        set x1 [expr {$w-2}]
     106        set xr [expr {($x1-$x0)*$frac + $x0}]
     107        $c coords stickoutline [expr {$x0-2}] [expr {$y-$ssize}] \
     108            $x1 [expr {$y+$ssize}]
     109        $c coords stickscreen [expr {$x0-2}] [expr {$y-$ssize}] \
     110            [expr {$x1+1}] [expr {$y+$ssize+1}]
     111        $c coords stickfill [expr {$x0-2}] [expr {$y-$ssize+1}] \
     112            $xr [expr {$y+$ssize}]
    113113
    114         $c itemconfigure bulbfill -fill $color
    115         $c itemconfigure stickfill -fill $color
     114        $c itemconfigure bulbfill -fill $color
     115        $c itemconfigure stickfill -fill $color
    116116    }
    117117
    118118    if {$itk_option(-state) == "disabled"} {
    119         $c itemconfigure screen -fill white
     119        $c itemconfigure screen -fill white
    120120    } else {
    121         $c itemconfigure screen -fill ""
     121        $c itemconfigure screen -fill ""
    122122    }
    123123}
     
    131131itcl::body Rappture::TemperatureGauge::_resize {} {
    132132    if {$itk_option(-samplewidth) > 0} {
    133         set w $itk_option(-samplewidth)
     133        set w $itk_option(-samplewidth)
    134134    } else {
    135         set w [winfo reqheight $itk_component(value)]
     135        set w [winfo reqheight $itk_component(value)]
    136136    }
    137137    if {$itk_option(-image) != ""} {
    138         set w [expr {$w+[image width $itk_option(-image)]+4}]
     138        set w [expr {$w+[image width $itk_option(-image)]+4}]
    139139    }
    140140
    141141    if {$itk_option(-sampleheight) > 0} {
    142         set h $itk_option(-sampleheight)
     142        set h $itk_option(-sampleheight)
    143143    } else {
    144         if {$itk_option(-image) != ""} {
    145             set h [expr {[image height $itk_option(-image)]+4}]
    146         } else {
    147             set h [winfo reqheight $itk_component(value)]
    148         }
     144        if {$itk_option(-image) != ""} {
     145            set h [expr {[image height $itk_option(-image)]+4}]
     146        } else {
     147            set h [winfo reqheight $itk_component(value)]
     148        }
    149149    }
    150150
Note: See TracChangeset for help on using the changeset viewer.