Ignore:
Timestamp:
Apr 13, 2010 12:36:52 PM (14 years ago)
Author:
dkearney
Message:

spacing, tabs, blahh

File:
1 edited

Legend:

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

    r1638 r1694  
    1616package require BLT
    1717package require Img
    18                                        
     18                                       
    1919#
    2020# FIXME:
    21 #       Need to Add DX readers this client to examine the data before
    22 #       it's sent to the server.  This will eliminate 90% of the insanity in
    23 #       computing the limits of all the volumes.  I can rip out all the
    24 #       "receive data" "send transfer function" event crap.
     21#        Need to Add DX readers this client to examine the data before
     22#        it's sent to the server.  This will eliminate 90% of the insanity in
     23#        computing the limits of all the volumes.  I can rip out all the
     24#        "receive data" "send transfer function" event crap.
    2525#
    2626#       This means we can compute the transfer function (relative values) and
    27 #       draw the legend min/max values without waiting for the information to
    28 #       come from the server.  This will also prevent the flashing that occurs
    29 #       when a new volume is drawn (using the default transfer function) and
    30 #       then when the correct transfer function has been sent and linked to
    31 #       the volume. 
     27#        draw the legend min/max values without waiting for the information to
     28#        come from the server.  This will also prevent the flashing that occurs
     29#        when a new volume is drawn (using the default transfer function) and
     30#        then when the correct transfer function has been sent and linked to
     31#        the volume. 
    3232#
    3333option add *NanovisViewer.width 4i widgetDefault
     
    4646proc NanovisViewer_init_resources {} {
    4747    Rappture::resources::register \
    48         nanovis_server Rappture::NanovisViewer::SetServerList
     48        nanovis_server Rappture::NanovisViewer::SetServerList
    4949}
    5050
     
    5757
    5858    constructor { hostlist args } {
    59         Rappture::VisViewer::constructor $hostlist
     59        Rappture::VisViewer::constructor $hostlist
    6060    } {
    61         # defined below
     61        # defined below
    6262    }
    6363    destructor {
    64         # defined below
     64        # defined below
    6565    }
    6666    public proc SetServerList { namelist } {
    67         Rappture::VisViewer::SetServerList "nanovis" $namelist
     67        Rappture::VisViewer::SetServerList "nanovis" $namelist
    6868    }
    6969    public method add {dataobj {settings ""}}
     
    7878    public method sendto { string }
    7979    public method parameters {title args} {
    80         # do nothing
     80        # do nothing
    8181    }
    8282    public method rmdupmarker { m x }
     
    124124    private variable _obj2ovride   ;# maps dataobj => style override
    125125    private variable _serverVols   ;# contains all the dataobj-component
    126                                    ;# to volumes in the server
     126                                   ;# to volumes in the server
    127127    private variable _serverTfs    ;# contains all the transfer functions
    128                                    ;# in the server.
     128                                   ;# in the server.
    129129    private variable _recvdVols    ;# list of data objs to send to server
    130130    private variable _vol2style    ;# maps dataobj-component to transfunc
    131131    private variable _style2vols   ;# maps tf back to list of
    132                                     # dataobj-components using the tf.
     132                                    # dataobj-components using the tf.
    133133
    134134    private variable _click        ;# info used for rotate operations
     
    173173    $_dispatcher register !send_transfunc
    174174    $_dispatcher dispatch $this !send_transfunc \
    175         "[itcl::code $this SendTransferFuncs]; list"
     175        "[itcl::code $this SendTransferFuncs]; list"
    176176
    177177    # Rebuild event
     
    194194    # Initialize the view to some default parameters.
    195195    array set _view {
    196         theta   45
    197         phi     45
    198         psi     0
    199         zoom    1.0
    200         pan-x   0
    201         pan-y   0
     196        theta   45
     197        phi     45
     198        psi     0
     199        zoom    1.0
     200        pan-x        0
     201        pan-y        0
    202202    }
    203203    set _limits(vmin) 0.0
     
    205205
    206206    array set _settings [subst {
    207         $this-pan-x             $_view(pan-x)
    208         $this-pan-y             $_view(pan-y)
    209         $this-phi               $_view(phi)
    210         $this-psi               $_view(psi)
    211         $this-theta             $_view(theta)
    212         $this-volume            1
    213         $this-xcutplane         0
    214         $this-xcutposition      0
    215         $this-ycutplane         0
    216         $this-ycutposition      0
    217         $this-zcutplane         0
    218         $this-zcutposition      0
    219         $this-zoom              $_view(zoom)
     207        $this-pan-x                $_view(pan-x)
     208        $this-pan-y                $_view(pan-y)
     209        $this-phi                $_view(phi)
     210        $this-psi                $_view(psi)
     211        $this-theta                $_view(theta)
     212        $this-volume                1
     213        $this-xcutplane                0
     214        $this-xcutposition        0
     215        $this-ycutplane                0
     216        $this-ycutposition        0
     217        $this-zcutplane                0
     218        $this-zcutposition        0
     219        $this-zoom                $_view(zoom)
    220220    }]
    221221
    222222    itk_component add 3dview {
    223         label $itk_component(plotarea).vol -image $_image(plot) \
    224             -highlightthickness 0 -borderwidth 0
     223        label $itk_component(plotarea).vol -image $_image(plot) \
     224            -highlightthickness 0 -borderwidth 0
    225225    } {
    226         usual
    227         ignore -highlightthickness -borderwidth  -background
     226        usual
     227        ignore -highlightthickness -borderwidth  -background
    228228    }
    229229
     
    267267    itk_component add volume {
    268268        Rappture::PushButton $f.volume \
    269             -onimage [Rappture::icon volume-on] \
    270             -offimage [Rappture::icon volume-off] \
    271             -command [itcl::code $this FixSettings volume] \
    272             -variable [itcl::scope _settings($this-volume)]
     269            -onimage [Rappture::icon volume-on] \
     270            -offimage [Rappture::icon volume-off] \
     271            -command [itcl::code $this FixSettings volume] \
     272            -variable [itcl::scope _settings($this-volume)]
    273273    }
    274274    $itk_component(volume) select
     
    286286    set _image(legend) [image create photo]
    287287    itk_component add legend {
    288         canvas $itk_component(plotarea).legend -height 50 -highlightthickness 0
     288        canvas $itk_component(plotarea).legend -height 50 -highlightthickness 0
    289289    } {
    290         usual
    291         ignore -highlightthickness
    292         rename -background -plotbackground plotBackground Background
     290        usual
     291        ignore -highlightthickness
     292        rename -background -plotbackground plotBackground Background
    293293    }
    294294    bind $itk_component(legend) <Configure> \
    295         [itcl::code $this EventuallyResizeLegend]
     295        [itcl::code $this EventuallyResizeLegend]
    296296
    297297    # Hack around the Tk panewindow.  The problem is that the requested
     
    301301    pack forget $itk_component(3dview)
    302302    blt::table $itk_component(plotarea) \
    303         0,0 $itk_component(3dview) -fill both -reqwidth $w \
    304         1,0 $itk_component(legend) -fill x
     303        0,0 $itk_component(3dview) -fill both -reqwidth $w \
     304        1,0 $itk_component(legend) -fill x
    305305    blt::table configure $itk_component(plotarea) r1 -resize none
    306306
    307307    # Bindings for rotation via mouse
    308308    bind $itk_component(3dview) <ButtonPress-1> \
    309         [itcl::code $this Rotate click %x %y]
     309        [itcl::code $this Rotate click %x %y]
    310310    bind $itk_component(3dview) <B1-Motion> \
    311         [itcl::code $this Rotate drag %x %y]
     311        [itcl::code $this Rotate drag %x %y]
    312312    bind $itk_component(3dview) <ButtonRelease-1> \
    313         [itcl::code $this Rotate release %x %y]
     313        [itcl::code $this Rotate release %x %y]
    314314    bind $itk_component(3dview) <Configure> \
    315         [itcl::code $this EventuallyResize %w %h]
     315        [itcl::code $this EventuallyResize %w %h]
    316316
    317317    # Bindings for panning via mouse
    318318    bind $itk_component(3dview) <ButtonPress-2> \
    319         [itcl::code $this Pan click %x %y]
     319        [itcl::code $this Pan click %x %y]
    320320    bind $itk_component(3dview) <B2-Motion> \
    321         [itcl::code $this Pan drag %x %y]
     321        [itcl::code $this Pan drag %x %y]
    322322    bind $itk_component(3dview) <ButtonRelease-2> \
    323         [itcl::code $this Pan release %x %y]
     323        [itcl::code $this Pan release %x %y]
    324324
    325325    # Bindings for panning via keyboard
    326326    bind $itk_component(3dview) <KeyPress-Left> \
    327         [itcl::code $this Pan set -10 0]
     327        [itcl::code $this Pan set -10 0]
    328328    bind $itk_component(3dview) <KeyPress-Right> \
    329         [itcl::code $this Pan set 10 0]
     329        [itcl::code $this Pan set 10 0]
    330330    bind $itk_component(3dview) <KeyPress-Up> \
    331         [itcl::code $this Pan set 0 -10]
     331        [itcl::code $this Pan set 0 -10]
    332332    bind $itk_component(3dview) <KeyPress-Down> \
    333         [itcl::code $this Pan set 0 10]
     333        [itcl::code $this Pan set 0 10]
    334334    bind $itk_component(3dview) <Shift-KeyPress-Left> \
    335         [itcl::code $this Pan set -2 0]
     335        [itcl::code $this Pan set -2 0]
    336336    bind $itk_component(3dview) <Shift-KeyPress-Right> \
    337         [itcl::code $this Pan set 2 0]
     337        [itcl::code $this Pan set 2 0]
    338338    bind $itk_component(3dview) <Shift-KeyPress-Up> \
    339         [itcl::code $this Pan set 0 -2]
     339        [itcl::code $this Pan set 0 -2]
    340340    bind $itk_component(3dview) <Shift-KeyPress-Down> \
    341         [itcl::code $this Pan set 0 2]
     341        [itcl::code $this Pan set 0 2]
    342342
    343343    # Bindings for zoom via keyboard
    344344    bind $itk_component(3dview) <KeyPress-Prior> \
    345         [itcl::code $this Zoom out]
     345        [itcl::code $this Zoom out]
    346346    bind $itk_component(3dview) <KeyPress-Next> \
    347         [itcl::code $this Zoom in]
     347        [itcl::code $this Zoom in]
    348348
    349349    bind $itk_component(3dview) <Enter> "focus $itk_component(3dview)"
    350350
    351351    if {[string equal "x11" [tk windowingsystem]]} {
    352         # Bindings for zoom via mouse
    353         bind $itk_component(3dview) <4> [itcl::code $this Zoom out]
    354         bind $itk_component(3dview) <5> [itcl::code $this Zoom in]
     352        # Bindings for zoom via mouse
     353        bind $itk_component(3dview) <4> [itcl::code $this Zoom out]
     354        bind $itk_component(3dview) <5> [itcl::code $this Zoom in]
    355355    }
    356356
     
    384384itcl::body Rappture::NanovisViewer::add {dataobj {settings ""}} {
    385385    array set params {
    386         -color auto
    387         -width 1
    388         -linestyle solid
    389         -brightness 0
    390         -raise 0
    391         -description ""
    392         -param ""
     386        -color auto
     387        -width 1
     388        -linestyle solid
     389        -brightness 0
     390        -raise 0
     391        -description ""
     392        -param ""
    393393    }
    394394    foreach {opt val} $settings {
    395         if {![info exists params($opt)]} {
    396             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    397         }
    398         set params($opt) $val
     395        if {![info exists params($opt)]} {
     396            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
     397        }
     398        set params($opt) $val
    399399    }
    400400    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    401         # can't handle -autocolors yet
    402         set params(-color) black
     401        # can't handle -autocolors yet
     402        set params(-color) black
    403403    }
    404404    set pos [lsearch -exact $dataobj $_dlist]
    405405    if {$pos < 0} {
    406         lappend _dlist $dataobj
    407         set _allDataObjs($dataobj) 1
    408         set _obj2ovride($dataobj-color) $params(-color)
    409         set _obj2ovride($dataobj-width) $params(-width)
    410         set _obj2ovride($dataobj-raise) $params(-raise)
    411         $_dispatcher event -idle !rebuild
     406        lappend _dlist $dataobj
     407        set _allDataObjs($dataobj) 1
     408        set _obj2ovride($dataobj-color) $params(-color)
     409        set _obj2ovride($dataobj-width) $params(-width)
     410        set _obj2ovride($dataobj-raise) $params(-raise)
     411        $_dispatcher event -idle !rebuild
    412412    }
    413413}
     
    423423itcl::body Rappture::NanovisViewer::get {args} {
    424424    if {[llength $args] == 0} {
    425         set args "-objects"
     425        set args "-objects"
    426426    }
    427427
     
    429429    switch -- $op {
    430430      -objects {
    431         # put the dataobj list in order according to -raise options
    432         set dlist $_dlist
    433         foreach obj $dlist {
    434             if {[info exists _obj2ovride($obj-raise)] && $_obj2ovride($obj-raise)} {
    435                 set i [lsearch -exact $dlist $obj]
    436                 if {$i >= 0} {
    437                     set dlist [lreplace $dlist $i $i]
    438                     lappend dlist $obj
    439                 }
    440             }
    441         }
    442         return $dlist
     431        # put the dataobj list in order according to -raise options
     432        set dlist $_dlist
     433        foreach obj $dlist {
     434            if {[info exists _obj2ovride($obj-raise)] && $_obj2ovride($obj-raise)} {
     435                set i [lsearch -exact $dlist $obj]
     436                if {$i >= 0} {
     437                    set dlist [lreplace $dlist $i $i]
     438                    lappend dlist $obj
     439                }
     440            }
     441        }
     442        return $dlist
    443443      }
    444444      -image {
    445         if {[llength $args] != 2} {
    446             error "wrong # args: should be \"get -image 3dview|legend\""
    447         }
    448         switch -- [lindex $args end] {
    449             3dview {
    450                 return $_image(plot)
    451             }
    452             legend {
    453                 return $_image(legend)
    454             }
    455             default {
    456                 error "bad image name \"[lindex $args end]\": should be 3dview or legend"
    457             }
    458         }
     445        if {[llength $args] != 2} {
     446            error "wrong # args: should be \"get -image 3dview|legend\""
     447        }
     448        switch -- [lindex $args end] {
     449            3dview {
     450                return $_image(plot)
     451            }
     452            legend {
     453                return $_image(legend)
     454            }
     455            default {
     456                error "bad image name \"[lindex $args end]\": should be 3dview or legend"
     457            }
     458        }
    459459      }
    460460      default {
    461         error "bad option \"$op\": should be -objects or -image"
     461        error "bad option \"$op\": should be -objects or -image"
    462462      }
    463463    }
     
    474474itcl::body Rappture::NanovisViewer::delete {args} {
    475475    if {[llength $args] == 0} {
    476         set args $_dlist
     476        set args $_dlist
    477477    }
    478478    # Delete all specified dataobjs
    479479    set changed 0
    480480    foreach dataobj $args {
    481         set pos [lsearch -exact $_dlist $dataobj]
    482         if { $pos >= 0 } {
    483             set _dlist [lreplace $_dlist $pos $pos]
    484             array unset _limits $dataobj*
    485             array unset _obj2ovride $dataobj-*
    486             array unset _vol2style $dataobj-*
    487             set changed 1
    488         }
     481        set pos [lsearch -exact $_dlist $dataobj]
     482        if { $pos >= 0 } {
     483            set _dlist [lreplace $_dlist $pos $pos]
     484            array unset _limits $dataobj*
     485            array unset _obj2ovride $dataobj-*
     486            array unset _vol2style $dataobj-*
     487            set changed 1
     488        }
    489489    }
    490490    # If anything changed, then rebuild the plot
    491491    if {$changed} {
    492         $_dispatcher event -idle !rebuild
     492        $_dispatcher event -idle !rebuild
    493493    }
    494494}
     
    505505itcl::body Rappture::NanovisViewer::scale {args} {
    506506    foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} {
    507         set _limits($val) ""
     507        set _limits($val) ""
    508508    }
    509509    foreach obj $args {
    510         foreach axis {x y z v} {
    511 
    512             foreach { min max } [$obj limits $axis] break
    513 
    514             if {"" != $min && "" != $max} {
    515                 if {"" == $_limits(${axis}min)} {
    516                     set _limits(${axis}min) $min
    517                     set _limits(${axis}max) $max
    518                 } else {
    519                     if {$min < $_limits(${axis}min)} {
    520                         set _limits(${axis}min) $min
    521                     }
    522                     if {$max > $_limits(${axis}max)} {
    523                         set _limits(${axis}max) $max
    524                     }
    525                 }
    526             }
    527         }
     510        foreach axis {x y z v} {
     511
     512            foreach { min max } [$obj limits $axis] break
     513
     514            if {"" != $min && "" != $max} {
     515                if {"" == $_limits(${axis}min)} {
     516                    set _limits(${axis}min) $min
     517                    set _limits(${axis}max) $max
     518                } else {
     519                    if {$min < $_limits(${axis}min)} {
     520                        set _limits(${axis}min) $min
     521                    }
     522                    if {$max > $_limits(${axis}max)} {
     523                        set _limits(${axis}max) $max
     524                    }
     525                }
     526            }
     527        }
    528528    }
    529529}
     
    541541itcl::body Rappture::NanovisViewer::download {option args} {
    542542    switch $option {
    543         coming {
    544             if {[catch {
    545                 blt::winop snap $itk_component(plotarea) $_image(download)
    546             }]} {
    547                 $_image(download) configure -width 1 -height 1
    548                 $_image(download) put #000000
    549             }
    550         }
    551         controls {
    552             # no controls for this download yet
    553             return ""
    554         }
    555         now {
    556             # Get the image data (as base64) and decode it back to binary.
    557             # This is better than writing to temporary files.  When we switch
    558             # to the BLT picture image it won't be necessary to decode the
    559             # image data.
    560             if { [image width $_image(plot)] > 0 &&
    561                 [image height $_image(plot)] > 0 } {
    562                 set bytes [$_image(plot) data -format "jpeg -quality 100"]
    563                 set bytes [Rappture::encoding::decode -as b64 $bytes]
    564                 return [list .jpg $bytes]
    565             }
    566             return ""
    567         }
    568         default {
    569             error "bad option \"$option\": should be coming, controls, now"
    570         }
     543        coming {
     544            if {[catch {
     545                blt::winop snap $itk_component(plotarea) $_image(download)
     546            }]} {
     547                $_image(download) configure -width 1 -height 1
     548                $_image(download) put #000000
     549            }
     550        }
     551        controls {
     552            # no controls for this download yet
     553            return ""
     554        }
     555        now {
     556            # Get the image data (as base64) and decode it back to binary.
     557            # This is better than writing to temporary files.  When we switch
     558            # to the BLT picture image it won't be necessary to decode the
     559            # image data.
     560            if { [image width $_image(plot)] > 0 &&
     561                [image height $_image(plot)] > 0 } {
     562                set bytes [$_image(plot) data -format "jpeg -quality 100"]
     563                set bytes [Rappture::encoding::decode -as b64 $bytes]
     564                return [list .jpg $bytes]
     565            }
     566            return ""
     567        }
     568        default {
     569            error "bad option \"$option\": should be coming, controls, now"
     570        }
    571571    }
    572572}
     
    582582    set _hosts [GetServerList "nanovis"]
    583583    if { "" == $_hosts } {
    584         return 0
     584        return 0
    585585    }
    586586    set result [VisViewer::Connect $_hosts]
    587587    if { $result } {
    588         set w [winfo width $itk_component(3dview)]
    589         set h [winfo height $itk_component(3dview)]
    590         EventuallyResize $w $h
     588        set w [winfo width $itk_component(3dview)]
     589        set h [winfo height $itk_component(3dview)]
     590        EventuallyResize $w $h
    591591    }
    592592    return $result
     
    639639itcl::body Rappture::NanovisViewer::SendCmd {string} {
    640640    if { $_buffering } {
    641         append _outbuf $string "\n"
     641        append _outbuf $string "\n"
    642642    } else {
    643         foreach line [split $string \n] {
    644             SendEcho >>line $line
    645         }
    646         SendBytes "$string\n"
     643        foreach line [split $string \n] {
     644            SendEcho >>line $line
     645        }
     646        SendBytes "$string\n"
    647647    }
    648648}
     
    654654itcl::body Rappture::NanovisViewer::SendTransferFuncs {} {
    655655    if { $_first == "" } {
    656         puts stderr "first not set"
    657         return
     656        puts stderr "first not set"
     657        return
    658658    }
    659659    # Insure that the global opacity and thickness settings (in the slider
     
    665665
    666666    foreach vol [CurrentVolumes] {
    667         if { ![info exists _serverVols($vol)] || !$_serverVols($vol) } {
    668             # The volume hasn't reached the server yet.  How did we get
    669             # here?
    670             continue
    671         }
    672         if { ![info exists _vol2style($vol)] } {
    673             puts stderr "unknown volume $vol"
    674             continue;                   # How does this happen?
    675         }
    676         set tf $_vol2style($vol)
    677         set _settings($this-$tf-opacity) $opacity
    678         set _settings($this-$tf-thickness) $thickness
    679         ComputeTransferFunc $tf
    680         # FIXME: Need to the send information as to what transfer functions
    681         #        to update so that we only update the transfer function
    682         #        as necessary.  Right now, all transfer functions are
    683         #        updated. This makes moving the isomarker slider chunky.
    684         if { ![info exists _activeTfs($tf)] || !$_activeTfs($tf) } {
    685             set _activeTfs($tf) 1
    686         }
    687         SendCmd "volume shading transfunc $tf $vol"
     667        if { ![info exists _serverVols($vol)] || !$_serverVols($vol) } {
     668            # The volume hasn't reached the server yet.  How did we get
     669            # here?
     670            continue
     671        }
     672        if { ![info exists _vol2style($vol)] } {
     673            puts stderr "unknown volume $vol"
     674            continue;                        # How does this happen?
     675        }
     676        set tf $_vol2style($vol)
     677        set _settings($this-$tf-opacity) $opacity
     678        set _settings($this-$tf-thickness) $thickness
     679        ComputeTransferFunc $tf
     680        # FIXME: Need to the send information as to what transfer functions
     681        #        to update so that we only update the transfer function
     682        #        as necessary.  Right now, all transfer functions are
     683        #        updated. This makes moving the isomarker slider chunky.
     684        if { ![info exists _activeTfs($tf)] || !$_activeTfs($tf) } {
     685            set _activeTfs($tf) 1
     686        }
     687        SendCmd "volume shading transfunc $tf $vol"
    688688    }
    689689    FixLegend
     
    699699itcl::body Rappture::NanovisViewer::ReceiveImage { args } {
    700700    array set info {
    701         -token "???"
    702         -bytes 0
    703         -type image
     701        -token "???"
     702        -bytes 0
     703        -type image
    704704    }
    705705    array set info $args
     
    707707    ReceiveEcho <<line "<read $info(-bytes) bytes"
    708708    if { $info(-type) == "image" } {
    709         ReceiveEcho "for [image width $_image(plot)]x[image height $_image(plot)] image>"       
    710         $_image(plot) configure -data $bytes
     709        ReceiveEcho "for [image width $_image(plot)]x[image height $_image(plot)] image>"       
     710        $_image(plot) configure -data $bytes
    711711    } elseif { $info(type) == "print" } {
    712         set tag $this-print-$info(-token)
    713         set _hardcopy($tag) $bytes
     712        set tag $this-print-$info(-token)
     713        set _hardcopy($tag) $bytes
    714714    }
    715715}
     
    730730itcl::body Rappture::NanovisViewer::ReceiveLegend { tf vmin vmax size } {
    731731    if { ![isconnected] } {
    732         return
     732        return
    733733    }
    734734    set bytes [ReceiveBytes $size]
     
    742742    set ly [expr {$h - 1}]
    743743    if {"" == [$c find withtag transfunc]} {
    744         $c create image 10 10 -anchor nw \
    745             -image $_image(legend) -tags transfunc
    746         $c create text $lx $ly -anchor sw \
    747             -fill $itk_option(-plotforeground) -tags "limits vmin"
    748         $c create text [expr {$w-$lx}] $ly -anchor se \
    749             -fill $itk_option(-plotforeground) -tags "limits vmax"
    750         $c lower transfunc
    751         $c bind transfunc <ButtonRelease-1> \
    752             [itcl::code $this AddIsoMarker %x %y]
     744        $c create image 10 10 -anchor nw \
     745            -image $_image(legend) -tags transfunc
     746        $c create text $lx $ly -anchor sw \
     747            -fill $itk_option(-plotforeground) -tags "limits vmin"
     748        $c create text [expr {$w-$lx}] $ly -anchor se \
     749            -fill $itk_option(-plotforeground) -tags "limits vmax"
     750        $c lower transfunc
     751        $c bind transfunc <ButtonRelease-1> \
     752            [itcl::code $this AddIsoMarker %x %y]
    753753    }
    754754    # Display the markers used by the active transfer function.
     
    762762
    763763    if { [info exists _isomarkers($tf)] } {
    764         foreach m $_isomarkers($tf) {
    765             $m visible yes
    766         }
     764        foreach m $_isomarkers($tf) {
     765            $m visible yes
     766        }
    767767    }
    768768}
     
    791791itcl::body Rappture::NanovisViewer::ReceiveData { args } {
    792792    if { ![isconnected] } {
    793         return
     793        return
    794794    }
    795795    # Arguments from server are name value pairs. Stuff them in an array.
     
    805805    set _serverVols($tag) 1
    806806    if { $_settings($this-volume) && $dataobj == $_first } {
    807         SendCmd "volume state 1 $tag"
     807        SendCmd "volume state 1 $tag"
    808808    }
    809809    set _limits($tag-min) $info(min);  # Minimum value of the volume.
     
    814814    unset _recvdVols($tag)
    815815    if { [array size _recvdVols] == 0 } {
    816         # The active transfer function is by default the first component of
    817         # the first data object.  This assumes that the data is always
    818         # successfully transferred.
    819         updatetransferfuncs
     816        # The active transfer function is by default the first component of
     817        # the first data object.  This assumes that the data is always
     818        # successfully transferred.
     819        updatetransferfuncs
    820820    }
    821821}
     
    839839
    840840    foreach tf [array names _isomarkers] {
    841         foreach m $_isomarkers($tf) {
    842             $m visible no
    843         }
     841        foreach m $_isomarkers($tf) {
     842            $m visible no
     843        }
    844844    }
    845845
     
    849849
    850850    foreach dataobj [get] {
    851         foreach comp [$dataobj components] {
    852             set vol $dataobj-$comp
    853             if { ![info exists _serverVols($vol)] } {
    854                 # Send the data as one huge base64-encoded mess -- yuck!
    855                 set data [$dataobj values $comp]
    856                 set nbytes [string length $data]
    857                 append _outbuf "volume data follows $nbytes $vol\n"
    858                 append _outbuf $data
    859                 set _recvdVols($vol) 1
    860                 set _serverVols($vol) 0
    861             }
    862             NameTransferFunc $dataobj $comp
    863         }
     851        foreach comp [$dataobj components] {
     852            set vol $dataobj-$comp
     853            if { ![info exists _serverVols($vol)] } {
     854                # Send the data as one huge base64-encoded mess -- yuck!
     855                set data [$dataobj values $comp]
     856                set nbytes [string length $data]
     857                append _outbuf "volume data follows $nbytes $vol\n"
     858                append _outbuf $data
     859                set _recvdVols($vol) 1
     860                set _serverVols($vol) 0
     861            }
     862            NameTransferFunc $dataobj $comp
     863        }
    864864    }
    865865    #
     
    889889    set _first [lindex [get] 0]
    890890    if {"" != $_first} {
    891         set axis [$_first hints updir]
    892         if { "" != $axis } {
    893             SendCmd "up $axis"
    894         }
    895         set location [$_first hints camera]
    896         if { $location != "" } {
    897             array set _view $location
    898         }
    899         set vols [array names _serverVols $_first-*]
    900         if { $vols != "" } {
    901             SendCmd "volume state 1 $vols"
    902         }
     891        set axis [$_first hints updir]
     892        if { "" != $axis } {
     893            SendCmd "up $axis"
     894        }
     895        set location [$_first hints camera]
     896        if { $location != "" } {
     897            array set _view $location
     898        }
     899        set vols [array names _serverVols $_first-*]
     900        if { $vols != "" } {
     901            SendCmd "volume state 1 $vols"
     902        }
    903903    }
    904904    # If the first volume already exists on the server, then make sure we
     
    906906    set comp [lindex [$_first components] 0]
    907907    if { [info exists _serverVols($_first-$comp)] } {
    908         updatetransferfuncs
     908        updatetransferfuncs
    909909    }
    910910
     
    912912    set vols [CurrentVolumes -cutplanes]
    913913    foreach axis {x y z} {
    914         SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols"
    915         set pos [expr {0.01*$_settings($this-${axis}cutposition)}]
    916         SendCmd "cutplane position $pos $axis $vols"
     914        SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols"
     915        set pos [expr {0.01*$_settings($this-${axis}cutposition)}]
     916        SendCmd "cutplane position $pos $axis $vols"
    917917    }
    918918    SendCmd "volume data state $_settings($this-volume) $vols"
    919     set _buffering 0;                   # Turn off buffering.
     919    set _buffering 0;                        # Turn off buffering.
    920920    # Actually write the commands to the server socket.  If it fails, we don't
    921921    # care.  We're finished here.
    922922    blt::busy hold $itk_component(hull)
    923     SendBytes $_outbuf;                 
     923    SendBytes $_outbuf;                       
    924924    blt::busy release $itk_component(hull)
    925     set _outbuf "";                     # Clear the buffer.             
     925    set _outbuf "";                        # Clear the buffer.               
    926926}
    927927
     
    936936    set rlist ""
    937937    if { $_first == "" } {
    938         return
     938        return
    939939    }
    940940    foreach comp [$_first components] {
    941         set vol $_first-$comp
    942         if { [info exists _serverVols($vol)] && $_serverVols($vol) } {
    943             array set style {
    944                 -cutplanes 1
    945             }
    946             array set style [lindex [$_first components -style $comp] 0]
    947             if {$what != "-cutplanes" || $style(-cutplanes)} {
    948                 lappend rlist $vol
    949             }
    950         }
     941        set vol $_first-$comp
     942        if { [info exists _serverVols($vol)] && $_serverVols($vol) } {
     943            array set style {
     944                -cutplanes 1
     945            }
     946            array set style [lindex [$_first components -style $comp] 0]
     947            if {$what != "-cutplanes" || $style(-cutplanes)} {
     948                lappend rlist $vol
     949            }
     950        }
    951951    }
    952952    return $rlist
     
    963963itcl::body Rappture::NanovisViewer::Zoom {option} {
    964964    switch -- $option {
    965         "in" {
    966             set _view(zoom) [expr {$_view(zoom)*1.25}]
    967             set _settings($this-zoom) $_view(zoom)
    968         }
    969         "out" {
    970             set _view(zoom) [expr {$_view(zoom)*0.8}]
    971             set _settings($this-zoom) $_view(zoom)
    972         }
     965        "in" {
     966            set _view(zoom) [expr {$_view(zoom)*1.25}]
     967            set _settings($this-zoom) $_view(zoom)
     968        }
     969        "out" {
     970            set _view(zoom) [expr {$_view(zoom)*0.8}]
     971            set _settings($this-zoom) $_view(zoom)
     972        }
    973973        "reset" {
    974             array set _view {
    975                 theta   45
    976                 phi     45
    977                 psi     0
    978                 zoom    1.0
    979                 pan-x   0
    980                 pan-y   0
    981             }
    982             if { $_first != "" } {
    983                 set location [$_first hints camera]
    984                 if { $location != "" } {
    985                     array set _view $location
    986                 }
    987             }
     974            array set _view {
     975                theta   45
     976                phi     45
     977                psi     0
     978                zoom        1.0
     979                pan-x        0
     980                pan-y        0
     981            }
     982            if { $_first != "" } {
     983                set location [$_first hints camera]
     984                if { $location != "" } {
     985                    array set _view $location
     986                }
     987            }
    988988            set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    989989            SendCmd "camera angle $xyz"
    990             PanCamera
    991             set _settings($this-theta) $_view(theta)
    992             set _settings($this-phi)   $_view(phi)
    993             set _settings($this-psi)   $_view(psi)
    994             set _settings($this-pan-x) $_view(pan-x)
    995             set _settings($this-pan-y) $_view(pan-y)
    996             set _settings($this-zoom)  $_view(zoom)
     990            PanCamera
     991            set _settings($this-theta) $_view(theta)
     992            set _settings($this-phi)   $_view(phi)
     993            set _settings($this-psi)   $_view(psi)
     994            set _settings($this-pan-x) $_view(pan-x)
     995            set _settings($this-pan-y) $_view(pan-y)
     996            set _settings($this-zoom)  $_view(zoom)
    997997        }
    998998    }
     
    10671067                }
    10681068
    1069                 set _view(theta)        $theta
    1070                 set _view(phi)          $phi
    1071                 set _view(psi)          $psi
     1069                set _view(theta)        $theta
     1070                set _view(phi)          $phi
     1071                set _view(psi)          $psi
    10721072                set xyz [Euler2XYZ $theta $phi $psi]
    1073                 set _settings($this-theta) $_view(theta)
    1074                 set _settings($this-phi)   $_view(phi)
    1075                 set _settings($this-psi)   $_view(psi)
     1073                set _settings($this-theta) $_view(theta)
     1074                set _settings($this-phi)   $_view(phi)
     1075                set _settings($this-psi)   $_view(psi)
    10761076                SendCmd "camera angle $xyz"
    10771077                set _click(x) $x
     
    11081108        set _view(pan-y) [expr $_view(pan-y) + $y]
    11091109        PanCamera
    1110         set _settings($this-pan-x) $_view(pan-x)
    1111         set _settings($this-pan-y) $_view(pan-y)
     1110        set _settings($this-pan-x) $_view(pan-x)
     1111        set _settings($this-pan-y) $_view(pan-y)
    11121112        return
    11131113    }
     
    11251125        set _view(pan-y) [expr $_view(pan-y) - $dy]
    11261126        PanCamera
    1127         set _settings($this-pan-x) $_view(pan-x)
    1128         set _settings($this-pan-y) $_view(pan-y)
     1127        set _settings($this-pan-x) $_view(pan-x)
     1128        set _settings($this-pan-y) $_view(pan-y)
    11291129    }
    11301130    if { $option == "release" } {
     
    11621162                set val $_settings($this-opacity)
    11631163                set sval [expr { 0.01 * double($val) }]
    1164                 foreach tf [array names _activeTfs] {
    1165                     set _settings($this-$tf-opacity) $sval
    1166                     set _activeTfs($tf) 0
    1167                 }
     1164                foreach tf [array names _activeTfs] {
     1165                    set _settings($this-$tf-opacity) $sval
     1166                    set _activeTfs($tf) 0
     1167                }
    11681168                updatetransferfuncs
    11691169            }
     
    11751175                # Scale values between 0.00001 and 0.01000
    11761176                set sval [expr {0.0001*double($val)}]
    1177                 foreach tf [array names _activeTfs] {
    1178                     set _settings($this-$tf-thickness) $sval
    1179                     set _activeTfs($tf) 0
    1180                 }
     1177                foreach tf [array names _activeTfs] {
     1178                    set _settings($this-$tf-thickness) $sval
     1179                    set _activeTfs($tf) 0
     1180                }
    11811181                updatetransferfuncs
    11821182            }
     
    12021202            }
    12031203        }
    1204         "legend" {
    1205             if { $_settings($this-legend) } {
    1206                 blt::table $itk_component(plotarea) \
    1207                     0,0 $itk_component(3dview) -fill both \
    1208                     1,0 $itk_component(legend) -fill x
    1209                 blt::table configure $itk_component(plotarea) r1 -resize none
    1210             } else {
    1211                 blt::table forget $itk_component(legend)
    1212             }
    1213         }
     1204        "legend" {
     1205            if { $_settings($this-legend) } {
     1206                blt::table $itk_component(plotarea) \
     1207                    0,0 $itk_component(3dview) -fill both \
     1208                    1,0 $itk_component(legend) -fill x
     1209                blt::table configure $itk_component(plotarea) r1 -resize none
     1210            } else {
     1211                blt::table forget $itk_component(legend)
     1212            }
     1213        }
    12141214        "volume" {
    12151215            if { [isconnected] } {
    1216                 set vols [CurrentVolumes -cutplanes]
     1216                set vols [CurrentVolumes -cutplanes]
    12171217                SendCmd "volume data state $_settings($this-volume) $vols"
    1218             }
     1218            }
    12191219        }
    12201220        "xcutplane" - "ycutplane" - "zcutplane" {
    1221             set axis [string range $what 0 0]
    1222             set bool $_settings($this-$what)
     1221            set axis [string range $what 0 0]
     1222            set bool $_settings($this-$what)
    12231223            if { [isconnected] } {
    1224                 set vols [CurrentVolumes -cutplanes]
    1225                 SendCmd "cutplane state $bool $axis $vols"
    1226             }
    1227             if { $bool } {
    1228                 $itk_component(${axis}CutScale) configure -state normal \
    1229                     -troughcolor white
     1224                set vols [CurrentVolumes -cutplanes]
     1225                SendCmd "cutplane state $bool $axis $vols"
     1226            }
     1227            if { $bool } {
     1228                $itk_component(${axis}CutScale) configure -state normal \
     1229                    -troughcolor white
    12301230            } else {
    1231                 $itk_component(${axis}CutScale) configure -state disabled \
    1232                     -troughcolor grey82
     1231                $itk_component(${axis}CutScale) configure -state disabled \
     1232                    -troughcolor grey82
    12331233            }
    12341234        }
     
    12521252    set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
    12531253    if {$w > 0 && $h > 0 && [array names _activeTfs] > 0 && $_first != "" } {
    1254         set vol [lindex [CurrentVolumes] 0]
    1255         if { [info exists _vol2style($vol)] } {
    1256             SendCmd "legend $_vol2style($vol) $w $h"
    1257         }
     1254        set vol [lindex [CurrentVolumes] 0]
     1255        if { [info exists _vol2style($vol)] } {
     1256            SendCmd "legend $_vol2style($vol) $w $h"
     1257        }
    12581258    } else {
    1259         # Can't do this as this will remove the items associated with the
    1260         # isomarkers.
    1261        
    1262         #$itk_component(legend) delete all
     1259        # Can't do this as this will remove the items associated with the
     1260        # isomarkers.
     1261       
     1262        #$itk_component(legend) delete all
    12631263    }
    12641264}
     
    12811281itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj comp } {
    12821282    array set style {
    1283         -color rainbow
    1284         -levels 6
    1285         -opacity 1.0
     1283        -color rainbow
     1284        -levels 6
     1285        -opacity 1.0
    12861286    }
    12871287    array set style [lindex [$dataobj components -style $comp] 0]
     
    13031303itcl::body Rappture::NanovisViewer::ComputeTransferFunc { tf } {
    13041304    array set style {
    1305         -color rainbow
    1306         -levels 6
    1307         -opacity 1.0
     1305        -color rainbow
     1306        -levels 6
     1307        -opacity 1.0
    13081308    }
    13091309    foreach {dataobj comp} [split $_style2vols($tf) -] break
     
    13251325
    13261326    if { ![info exists _isomarkers($tf)] } {
    1327         # Have to defer creation of isomarkers until we have data limits
    1328         if { [info exists style(-markers)] } {
    1329             ParseMarkersOption $tf $style(-markers)
    1330         } else {
    1331             ParseLevelsOption $tf $style(-levels)
    1332         }
     1327        # Have to defer creation of isomarkers until we have data limits
     1328        if { [info exists style(-markers)] } {
     1329            ParseMarkersOption $tf $style(-markers)
     1330        } else {
     1331            ParseLevelsOption $tf $style(-levels)
     1332        }
    13331333    }
    13341334    if {$style(-color) == "rainbow"} {
    1335         set style(-color) "white:yellow:green:cyan:blue:magenta"
     1335        set style(-color) "white:yellow:green:cyan:blue:magenta"
    13361336    }
    13371337    set clist [split $style(-color) :]
    13381338    set cmap "0.0 [Color2RGB white] "
    13391339    for {set i 0} {$i < [llength $clist]} {incr i} {
    1340         set x [expr {double($i+1)/([llength $clist]+1)}]
    1341         set color [lindex $clist $i]
    1342         append cmap "$x [Color2RGB $color] "
     1340        set x [expr {double($i+1)/([llength $clist]+1)}]
     1341        set color [lindex $clist $i]
     1342        append cmap "$x [Color2RGB $color] "
    13431343    }
    13441344    append cmap "1.0 [Color2RGB $color]"
     
    13461346    set tag $this-$tf
    13471347    if { ![info exists _settings($tag-opacity)] } {
    1348         set _settings($tag-opacity) $style(-opacity)
     1348        set _settings($tag-opacity) $style(-opacity)
    13491349    }
    13501350    set max $_settings($tag-opacity)
     
    13521352    set isovalues {}
    13531353    foreach m $_isomarkers($tf) {
    1354         lappend isovalues [$m relval]
     1354        lappend isovalues [$m relval]
    13551355    }
    13561356    # Sort the isovalues
     
    13581358
    13591359    if { ![info exists _settings($tag-thickness)]} {
    1360         set _settings($tag-thickness) 0.05
     1360        set _settings($tag-thickness) 0.05
    13611361    }
    13621362    set delta $_settings($tag-thickness)
     
    13661366    set wmap ""
    13671367    if { $first == "" || $first != 0.0 } {
    1368         lappend wmap 0.0 0.0
     1368        lappend wmap 0.0 0.0
    13691369    }
    13701370    foreach x $isovalues {
    1371         set x1 [expr {$x-$delta-0.00001}]
    1372         set x2 [expr {$x-$delta}]
    1373         set x3 [expr {$x+$delta}]
    1374         set x4 [expr {$x+$delta+0.00001}]
    1375         if { $x1 < 0.0 } {
    1376             set x1 0.0
    1377         } elseif { $x1 > 1.0 } {
    1378             set x1 1.0
    1379         }
    1380         if { $x2 < 0.0 } {
    1381             set x2 0.0
    1382         } elseif { $x2 > 1.0 } {
    1383             set x2 1.0
    1384         }
    1385         if { $x3 < 0.0 } {
    1386             set x3 0.0
    1387         } elseif { $x3 > 1.0 } {
    1388             set x3 1.0
    1389         }
    1390         if { $x4 < 0.0 } {
    1391             set x4 0.0
    1392         } elseif { $x4 > 1.0 } {
    1393             set x4 1.0
    1394         }
    1395         # add spikes in the middle
    1396         lappend wmap $x1 0.0
    1397         lappend wmap $x2 $max
    1398         lappend wmap $x3 $max
    1399         lappend wmap $x4 0.0
     1371        set x1 [expr {$x-$delta-0.00001}]
     1372        set x2 [expr {$x-$delta}]
     1373        set x3 [expr {$x+$delta}]
     1374        set x4 [expr {$x+$delta+0.00001}]
     1375        if { $x1 < 0.0 } {
     1376            set x1 0.0
     1377        } elseif { $x1 > 1.0 } {
     1378            set x1 1.0
     1379        }
     1380        if { $x2 < 0.0 } {
     1381            set x2 0.0
     1382        } elseif { $x2 > 1.0 } {
     1383            set x2 1.0
     1384        }
     1385        if { $x3 < 0.0 } {
     1386            set x3 0.0
     1387        } elseif { $x3 > 1.0 } {
     1388            set x3 1.0
     1389        }
     1390        if { $x4 < 0.0 } {
     1391            set x4 0.0
     1392        } elseif { $x4 > 1.0 } {
     1393            set x4 1.0
     1394        }
     1395        # add spikes in the middle
     1396        lappend wmap $x1 0.0
     1397        lappend wmap $x2 $max
     1398        lappend wmap $x3 $max
     1399        lappend wmap $x4 0.0
    14001400    }
    14011401    if { $last == "" || $last != 1.0 } {
    1402         lappend wmap 1.0 0.0
     1402        lappend wmap 1.0 0.0
    14031403    }
    14041404    SendCmd "transfunc define $tf { $cmap } { $wmap }"
     
    14101410itcl::configbody Rappture::NanovisViewer::plotbackground {
    14111411    if { [isconnected] } {
    1412         foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
    1413         #fix this!
    1414         #SendCmd "color background $r $g $b"
     1412        foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
     1413        #fix this!
     1414        #SendCmd "color background $r $g $b"
    14151415    }
    14161416}
     
    14211421itcl::configbody Rappture::NanovisViewer::plotforeground {
    14221422    if { [isconnected] } {
    1423         foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
    1424         #fix this!
    1425         #SendCmd "color background $r $g $b"
     1423        foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
     1424        #fix this!
     1425        #SendCmd "color background $r $g $b"
    14261426    }
    14271427}
     
    14361436    # start sending commands to visualization server.
    14371437    if { [isconnected] } {
    1438         if {"" == $itk_option(-plotoutline)} {
    1439             SendCmd "volume outline state off"
    1440         } else {
    1441             SendCmd "volume outline state on"
    1442             SendCmd "volume outline color [Color2RGB $itk_option(-plotoutline)]"
    1443         }
     1438        if {"" == $itk_option(-plotoutline)} {
     1439            SendCmd "volume outline state off"
     1440        } else {
     1441            SendCmd "volume outline state on"
     1442            SendCmd "volume outline color [Color2RGB $itk_option(-plotoutline)]"
     1443        }
    14441444    }
    14451445}
     
    14541454    regsub -all "," $levels " " levels
    14551455    if {[string is int $levels]} {
    1456         for {set i 1} { $i <= $levels } {incr i} {
    1457             set x [expr {double($i)/($levels+1)}]
    1458             set m [Rappture::IsoMarker \#auto $c $this $tf]
    1459             $m relval $x
    1460             lappend _isomarkers($tf) $m
    1461         }
     1456        for {set i 1} { $i <= $levels } {incr i} {
     1457            set x [expr {double($i)/($levels+1)}]
     1458            set m [Rappture::IsoMarker \#auto $c $this $tf]
     1459            $m relval $x
     1460            lappend _isomarkers($tf) $m
     1461        }
    14621462    } else {
    1463         foreach x $levels {
    1464             set m [Rappture::IsoMarker \#auto $c $this $tf]
    1465             $m relval $x
    1466             lappend _isomarkers($tf) $m
    1467         }
     1463        foreach x $levels {
     1464            set m [Rappture::IsoMarker \#auto $c $this $tf]
     1465            $m relval $x
     1466            lappend _isomarkers($tf) $m
     1467        }
    14681468    }
    14691469}
     
    14851485    regsub -all "," $markers " " markers
    14861486    foreach marker $markers {
    1487         set n [scan $marker "%g%s" value suffix]
    1488         if { $n == 2 && $suffix == "%" } {
    1489             # ${n}% : Set relative value.
    1490             set value [expr {$value * 0.01}]
    1491             set m [Rappture::IsoMarker \#auto $c $this $tf]
    1492             $m relval $value
    1493             lappend _isomarkers($tf) $m
    1494         } else {
    1495             # ${n} : Set absolute value.
    1496             set m [Rappture::IsoMarker \#auto $c $this $tf]
    1497             $m absval $value
    1498             lappend _isomarkers($tf) $m
    1499         }
     1487        set n [scan $marker "%g%s" value suffix]
     1488        if { $n == 2 && $suffix == "%" } {
     1489            # ${n}% : Set relative value.
     1490            set value [expr {$value * 0.01}]
     1491            set m [Rappture::IsoMarker \#auto $c $this $tf]
     1492            $m relval $value
     1493            lappend _isomarkers($tf) $m
     1494        } else {
     1495            # ${n} : Set absolute value.
     1496            set m [Rappture::IsoMarker \#auto $c $this $tf]
     1497            $m absval $value
     1498            lappend _isomarkers($tf) $m
     1499        }
    15001500    }
    15011501}
     
    15101510itcl::body Rappture::NanovisViewer::AddIsoMarker { x y } {
    15111511    if { $_first == "" } {
    1512         error "active transfer function isn't set"
     1512        error "active transfer function isn't set"
    15131513    }
    15141514    set vol [lindex [CurrentVolumes] 0]
     
    15271527    set bool 0
    15281528    if { [info exists _isomarkers($tf)] } {
    1529         set list {}
    1530         set marker [namespace tail $marker]
    1531         foreach m $_isomarkers($tf) {
    1532             set sx [$m screenpos]
    1533             if { $m != $marker } {
    1534                 if { $x >= ($sx-3) && $x <= ($sx+3) } {
    1535                     $marker relval [$m relval]
    1536                     itcl::delete object $m
    1537                     bell
    1538                     set bool 1
    1539                     continue
    1540                 }
    1541             }
    1542             lappend list $m
    1543         }
    1544         set _isomarkers($tf) $list
    1545         updatetransferfuncs
     1529        set list {}
     1530        set marker [namespace tail $marker]
     1531        foreach m $_isomarkers($tf) {
     1532            set sx [$m screenpos]
     1533            if { $m != $marker } {
     1534                if { $x >= ($sx-3) && $x <= ($sx+3) } {
     1535                    $marker relval [$m relval]
     1536                    itcl::delete object $m
     1537                    bell
     1538                    set bool 1
     1539                    continue
     1540                }
     1541            }
     1542            lappend list $m
     1543        }
     1544        set _isomarkers($tf) $list
     1545        updatetransferfuncs
    15461546    }
    15471547    return $bool
     
    15511551    set tf [$marker transferfunc]
    15521552    if { [info exists _isomarkers($tf)] } {
    1553         set marker [namespace tail $marker]
    1554         foreach m $_isomarkers($tf) {
    1555             set sx [$m screenpos]
    1556             if { $m != $marker } {
    1557                 set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }]
    1558                 $m activate $bool
    1559             }
    1560         }
     1553        set marker [namespace tail $marker]
     1554        foreach m $_isomarkers($tf) {
     1555            set sx [$m screenpos]
     1556            if { $m != $marker } {
     1557                set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }]
     1558                $m activate $bool
     1559            }
     1560        }
    15611561    }
    15621562    return ""
     
    15671567    set _limits(max) 1.0
    15681568    if { ![info exists _style2vols($tf)] } {
    1569         return [array get _limits]
     1569        return [array get _limits]
    15701570    }
    15711571    set min ""; set max ""
    15721572    foreach vol $_style2vols($tf) {
    1573         if { ![info exists _serverVols($vol)] } {
    1574             continue
    1575         }
    1576         if { ![info exists _limits($vol-min)] } {
    1577             continue
    1578         }
    1579         if { $min == "" || $min > $_limits($vol-min) } {
    1580             set min $_limits($vol-min)
    1581         }
    1582         if { $max == "" || $max < $_limits($vol-max) } {
    1583             set max $_limits($vol-max)
    1584         }
     1573        if { ![info exists _serverVols($vol)] } {
     1574            continue
     1575        }
     1576        if { ![info exists _limits($vol-min)] } {
     1577            continue
     1578        }
     1579        if { $min == "" || $min > $_limits($vol-min) } {
     1580            set min $_limits($vol-min)
     1581        }
     1582        if { $max == "" || $max < $_limits($vol-max) } {
     1583            set max $_limits($vol-max)
     1584        }
    15851585    }
    15861586    if { $min != "" } {
    1587         set _limits(min) $min
     1587        set _limits(min) $min
    15881588    }
    15891589    if { $max != "" } {
    1590         set _limits(max) $max
     1590        set _limits(max) $max
    15911591    }
    15921592    return [array get _limits]
     
    15961596itcl::body Rappture::NanovisViewer::BuildViewTab {} {
    15971597    foreach { key value } {
    1598         grid            0
    1599         axes            1
    1600         outline         1
    1601         volume          1
    1602         legend          1
    1603         particles       1
    1604         lic             1
     1598        grid                0
     1599        axes                1
     1600        outline                1
     1601        volume                1
     1602        legend                1
     1603        particles        1
     1604        lic                1
    16051605    } {
    1606         set _settings($this-$key) $value
     1606        set _settings($this-$key) $value
    16071607    }
    16081608
     
    16201620        -variable [itcl::scope _settings($this-isosurface)] \
    16211621        -command [itcl::code $this FixSettings isosurface] \
    1622         -font "Arial 9"
     1622        -font "Arial 9"
    16231623
    16241624    checkbutton $inner.axes \
     
    16261626        -variable [itcl::scope _settings($this-axes)] \
    16271627        -command [itcl::code $this FixSettings axes] \
    1628         -font "Arial 9"
     1628        -font "Arial 9"
    16291629
    16301630    checkbutton $inner.grid \
     
    16321632        -variable [itcl::scope _settings($this-grid)] \
    16331633        -command [itcl::code $this FixSettings grid] \
    1634         -font "Arial 9"
     1634        -font "Arial 9"
    16351635
    16361636    checkbutton $inner.outline \
     
    16381638        -variable [itcl::scope _settings($this-outline)] \
    16391639        -command [itcl::code $this FixSettings outline] \
    1640         -font "Arial 9"
     1640        -font "Arial 9"
    16411641
    16421642    checkbutton $inner.legend \
     
    16441644        -variable [itcl::scope _settings($this-legend)] \
    16451645        -command [itcl::code $this FixSettings legend] \
    1646         -font "Arial 9"
     1646        -font "Arial 9"
    16471647
    16481648    checkbutton $inner.volume \
     
    16501650        -variable [itcl::scope _settings($this-volume)] \
    16511651        -command [itcl::code $this FixSettings volume] \
    1652         -font "Arial 9"
     1652        -font "Arial 9"
    16531653
    16541654    blt::table $inner \
    1655         0,0 $inner.axes  -columnspan 2 -anchor w \
    1656         1,0 $inner.grid  -columnspan 2 -anchor w \
    1657         2,0 $inner.outline  -columnspan 2 -anchor w \
    1658         3,0 $inner.volume  -columnspan 2 -anchor w \
    1659         4,0 $inner.legend  -columnspan 2 -anchor w
     1655        0,0 $inner.axes  -columnspan 2 -anchor w \
     1656        1,0 $inner.grid  -columnspan 2 -anchor w \
     1657        2,0 $inner.outline  -columnspan 2 -anchor w \
     1658        3,0 $inner.volume  -columnspan 2 -anchor w \
     1659        4,0 $inner.legend  -columnspan 2 -anchor w
    16601660
    16611661    if 0 {
     
    16681668itcl::body Rappture::NanovisViewer::BuildVolumeTab {} {
    16691669    foreach { key value } {
    1670         light           40
    1671         transp          50
    1672         opacity         100
    1673         thickness       350
     1670        light                40
     1671        transp                50
     1672        opacity                100
     1673        thickness        350
    16741674    } {
    1675         set _settings($this-$key) $value
     1675        set _settings($this-$key) $value
    16761676    }
    16771677
     
    16921692    ::scale $inner.light -from 0 -to 100 -orient horizontal \
    16931693        -variable [itcl::scope _settings($this-light)] \
    1694         -width 10 \
     1694        -width 10 \
    16951695        -showvalue off -command [itcl::code $this FixSettings light]
    16961696    label $inner.bright -text "Bright" -font $fg
     
    16991699    ::scale $inner.transp -from 0 -to 100 -orient horizontal \
    17001700        -variable [itcl::scope _settings($this-transp)] \
    1701         -width 10 \
     1701        -width 10 \
    17021702        -showvalue off -command [itcl::code $this FixSettings transp]
    17031703    label $inner.plastic -text "Plastic" -font $fg
     
    17061706    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    17071707        -variable [itcl::scope _settings($this-opacity)] \
    1708         -width 10 \
     1708        -width 10 \
    17091709        -showvalue off -command [itcl::code $this FixSettings opacity]
    17101710    label $inner.opaque -text "Opaque" -font $fg
     
    17131713    ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \
    17141714        -variable [itcl::scope _settings($this-thickness)] \
    1715         -width 10 \
     1715        -width 10 \
    17161716        -showvalue off -command [itcl::code $this FixSettings thickness]
    17171717    label $inner.thick -text "Thick" -font $fg
    17181718
    17191719    blt::table $inner \
    1720         0,0 $inner.vol -columnspan 4 -anchor w -pady 2 \
    1721         1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \
    1722         2,0 $inner.dim -anchor e -pady 2 \
    1723         2,1 $inner.light -columnspan 2 -pady 2 -fill x \
    1724         2,3 $inner.bright -anchor w -pady 2 \
    1725         3,0 $inner.fog -anchor e -pady 2 \
    1726         3,1 $inner.transp -columnspan 2 -pady 2 -fill x \
    1727         3,3 $inner.plastic -anchor w -pady 2 \
    1728         4,0 $inner.clear -anchor e -pady 2 \
    1729         4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\
    1730         4,3 $inner.opaque -anchor w -pady 2 \
    1731         5,0 $inner.thin -anchor e -pady 2 \
    1732         5,1 $inner.thickness -columnspan 2 -pady 2 -fill x\
    1733         5,3 $inner.thick -anchor w -pady 2
     1720        0,0 $inner.vol -columnspan 4 -anchor w -pady 2 \
     1721        1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \
     1722        2,0 $inner.dim -anchor e -pady 2 \
     1723        2,1 $inner.light -columnspan 2 -pady 2 -fill x \
     1724        2,3 $inner.bright -anchor w -pady 2 \
     1725        3,0 $inner.fog -anchor e -pady 2 \
     1726        3,1 $inner.transp -columnspan 2 -pady 2 -fill x \
     1727        3,3 $inner.plastic -anchor w -pady 2 \
     1728        4,0 $inner.clear -anchor e -pady 2 \
     1729        4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\
     1730        4,3 $inner.opaque -anchor w -pady 2 \
     1731        5,0 $inner.thin -anchor e -pady 2 \
     1732        5,1 $inner.thickness -columnspan 2 -pady 2 -fill x\
     1733        5,3 $inner.thick -anchor w -pady 2
    17341734
    17351735    blt::table configure $inner c0 c1 c3 r* -resize none
     
    17461746    itk_component add xCutButton {
    17471747        Rappture::PushButton $inner.xbutton \
    1748             -onimage [Rappture::icon x-cutplane] \
    1749             -offimage [Rappture::icon x-cutplane] \
    1750             -command [itcl::code $this FixSettings xcutplane] \
    1751             -variable [itcl::scope _settings($this-xcutplane)]
     1748            -onimage [Rappture::icon x-cutplane] \
     1749            -offimage [Rappture::icon x-cutplane] \
     1750            -command [itcl::code $this FixSettings xcutplane] \
     1751            -variable [itcl::scope _settings($this-xcutplane)]
    17521752    }
    17531753    Rappture::Tooltip::for $itk_component(xCutButton) \
     
    17591759            -borderwidth 1 -highlightthickness 0 \
    17601760            -command [itcl::code $this Slice move x] \
    1761             -variable [itcl::scope _settings($this-xcutposition)]
     1761            -variable [itcl::scope _settings($this-xcutposition)]
    17621762    } {
    17631763        usual
     
    17731773    itk_component add yCutButton {
    17741774        Rappture::PushButton $inner.ybutton \
    1775             -onimage [Rappture::icon y-cutplane] \
    1776             -offimage [Rappture::icon y-cutplane] \
    1777             -command [itcl::code $this FixSettings ycutplane] \
    1778             -variable [itcl::scope _settings($this-ycutplane)]
     1775            -onimage [Rappture::icon y-cutplane] \
     1776            -offimage [Rappture::icon y-cutplane] \
     1777            -command [itcl::code $this FixSettings ycutplane] \
     1778            -variable [itcl::scope _settings($this-ycutplane)]
    17791779    }
    17801780    Rappture::Tooltip::for $itk_component(yCutButton) \
     
    17861786            -borderwidth 1 -highlightthickness 0 \
    17871787            -command [itcl::code $this Slice move y] \
    1788             -variable [itcl::scope _settings($this-ycutposition)]
     1788            -variable [itcl::scope _settings($this-ycutposition)]
    17891789    } {
    17901790        usual
     
    18001800    itk_component add zCutButton {
    18011801        Rappture::PushButton $inner.zbutton \
    1802             -onimage [Rappture::icon z-cutplane] \
    1803             -offimage [Rappture::icon z-cutplane] \
    1804             -command [itcl::code $this FixSettings zcutplane] \
    1805             -variable [itcl::scope _settings($this-zcutplane)]
     1802            -onimage [Rappture::icon z-cutplane] \
     1803            -offimage [Rappture::icon z-cutplane] \
     1804            -command [itcl::code $this FixSettings zcutplane] \
     1805            -variable [itcl::scope _settings($this-zcutplane)]
    18061806    }
    18071807    Rappture::Tooltip::for $itk_component(zCutButton) \
     
    18131813            -borderwidth 1 -highlightthickness 0 \
    18141814            -command [itcl::code $this Slice move z] \
    1815             -variable [itcl::scope _settings($this-zcutposition)]
     1815            -variable [itcl::scope _settings($this-zcutposition)]
    18161816    } {
    18171817        usual
     
    18251825
    18261826    blt::table $inner \
    1827         1,1 $itk_component(xCutButton) \
    1828         1,2 $itk_component(yCutButton) \
    1829         1,3 $itk_component(zCutButton) \
    1830         0,1 $itk_component(xCutScale) \
    1831         0,2 $itk_component(yCutScale) \
    1832         0,3 $itk_component(zCutScale) \
     1827        1,1 $itk_component(xCutButton) \
     1828        1,2 $itk_component(yCutButton) \
     1829        1,3 $itk_component(zCutButton) \
     1830        0,1 $itk_component(xCutScale) \
     1831        0,2 $itk_component(yCutScale) \
     1832        0,3 $itk_component(zCutScale) \
    18331833
    18341834    blt::table configure $inner r0 r1 c* -resize none
     
    18471847    set row 0
    18481848    foreach tag $labels {
    1849         label $inner.${tag}label -text $tag -font "Arial 9"
    1850         entry $inner.${tag} -font "Arial 9"  -bg white \
    1851             -textvariable [itcl::scope _settings($this-$tag)]
    1852         bind $inner.${tag} <KeyPress-Return> \
    1853             [itcl::code $this camera set ${tag}]
    1854         blt::table $inner \
    1855             $row,0 $inner.${tag}label -anchor e -pady 2 \
    1856             $row,1 $inner.${tag} -anchor w -pady 2
     1849        label $inner.${tag}label -text $tag -font "Arial 9"
     1850        entry $inner.${tag} -font "Arial 9"  -bg white \
     1851            -textvariable [itcl::scope _settings($this-$tag)]
     1852        bind $inner.${tag} <KeyPress-Return> \
     1853            [itcl::code $this camera set ${tag}]
     1854        blt::table $inner \
     1855            $row,0 $inner.${tag}label -anchor e -pady 2 \
     1856            $row,1 $inner.${tag} -anchor w -pady 2
    18571857        blt::table configure $inner r$row -resize none
    1858         incr row
     1858        incr row
    18591859    }
    18601860    blt::table configure $inner c0 c1 -resize none
     
    19151915    set _height $h
    19161916    if { !$_resizePending } {
    1917         $_dispatcher event -idle !resize
    1918         set _resizePending 1
     1917        $_dispatcher event -idle !resize
     1918        set _resizePending 1
    19191919    }
    19201920}
     
    19221922itcl::body Rappture::NanovisViewer::EventuallyResizeLegend {} {
    19231923    if { !$_resizeLegendPending } {
    1924         $_dispatcher event -idle !legend
    1925         set _resizeLegendPending 1
     1924        $_dispatcher event -idle !legend
     1925        set _resizeLegendPending 1
    19261926    }
    19271927}
     
    19321932itcl::body Rappture::NanovisViewer::camera {option args} {
    19331933    switch -- $option {
    1934         "show" {
    1935             puts [array get _view]
    1936         }
    1937         "set" {
    1938             set who [lindex $args 0]
    1939             set x $_settings($this-$who)
    1940             set code [catch { string is double $x } result]
    1941             if { $code != 0 || !$result } {
    1942                 set _settings($this-$who) $_view($who)
    1943                 return
    1944             }
    1945             switch -- $who {
    1946                 "pan-x" - "pan-y" {
    1947                     set _view($who) $_settings($this-$who)
    1948                     PanCamera
    1949                 }
    1950                 "phi" - "theta" - "psi" {
    1951                     set _view($who) $_settings($this-$who)
    1952                     set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    1953                     SendCmd "camera angle $xyz"
    1954                 }
    1955                 "zoom" {
    1956                     set _view($who) $_settings($this-$who)
    1957                     SendCmd "camera zoom $_view(zoom)"
    1958                 }
    1959             }
    1960         }
     1934        "show" {
     1935            puts [array get _view]
     1936        }
     1937        "set" {
     1938            set who [lindex $args 0]
     1939            set x $_settings($this-$who)
     1940            set code [catch { string is double $x } result]
     1941            if { $code != 0 || !$result } {
     1942                set _settings($this-$who) $_view($who)
     1943                return
     1944            }
     1945            switch -- $who {
     1946                "pan-x" - "pan-y" {
     1947                    set _view($who) $_settings($this-$who)
     1948                    PanCamera
     1949                }
     1950                "phi" - "theta" - "psi" {
     1951                    set _view($who) $_settings($this-$who)
     1952                    set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     1953                    SendCmd "camera angle $xyz"
     1954                }
     1955                "zoom" {
     1956                    set _view($who) $_settings($this-$who)
     1957                    SendCmd "camera zoom $_view(zoom)"
     1958                }
     1959            }
     1960        }
    19611961    }
    19621962}
     
    19651965    set flowobj ""
    19661966    foreach key [array names _obj2flow] {
    1967         set flowobj $_obj2flow($key)
    1968         break
     1967        set flowobj $_obj2flow($key)
     1968        break
    19691969    }
    19701970    if { $flowobj == "" } {
    1971         return
     1971        return
    19721972    }
    19731973    if { [winfo exists $w.frame] } {
    1974         destroy $w.frame
     1974        destroy $w.frame
    19751975    }
    19761976    set inner [frame $w.frame]
    19771977    blt::table $w \
    1978         5,0 $inner -fill both -columnspan 2 -anchor nw
     1978        5,0 $inner -fill both -columnspan 2 -anchor nw
    19791979    array set hints [$dataobj hints]
    19801980
    19811981    label $inner.volumes -text "Volumes" -font "Arial 9 bold"
    19821982    blt::table $inner \
    1983         1,0 $inner.volumes  -anchor w \
     1983        1,0 $inner.volumes  -anchor w \
    19841984    blt::table configure $inner c0 c1 -resize none
    19851985    blt::table configure $inner c2 -resize expand
     
    19881988    set volumes [get]
    19891989    if { [llength $volumes] > 0 } {
    1990         blt::table $inner $row,0 $inner.volumes  -anchor w
    1991         incr row
     1990        blt::table $inner $row,0 $inner.volumes  -anchor w
     1991        incr row
    19921992    }
    19931993    foreach vol $volumes {
    1994         array unset info
    1995         array set info $vol
    1996         set name $info(name)
    1997         if { ![info exists _settings($this-volume-$name)] } {
    1998             set _settings($this-volume-$name) $info(hide)
    1999         }
    2000         checkbutton $inner.vol$row -text $info(label) \
    2001             -variable [itcl::scope _settings($this-volume-$name)] \
    2002             -onvalue 0 -offvalue 1 \
    2003             -command [itcl::code $this volume $key $name] \
    2004             -font "Arial 9"
    2005         Rappture::Tooltip::for $inner.vol$row $info(description)
    2006         blt::table $inner $row,0 $inner.vol$row -anchor w
    2007         if { !$_settings($this-volume-$name) } {
    2008             $inner.vol$row select
    2009         }
    2010         incr row
     1994        array unset info
     1995        array set info $vol
     1996        set name $info(name)
     1997        if { ![info exists _settings($this-volume-$name)] } {
     1998            set _settings($this-volume-$name) $info(hide)
     1999        }
     2000        checkbutton $inner.vol$row -text $info(label) \
     2001            -variable [itcl::scope _settings($this-volume-$name)] \
     2002            -onvalue 0 -offvalue 1 \
     2003            -command [itcl::code $this volume $key $name] \
     2004            -font "Arial 9"
     2005        Rappture::Tooltip::for $inner.vol$row $info(description)
     2006        blt::table $inner $row,0 $inner.vol$row -anchor w
     2007        if { !$_settings($this-volume-$name) } {
     2008            $inner.vol$row select
     2009        }
     2010        incr row
    20112011    }
    20122012    blt::table configure $inner r* -resize none
Note: See TracChangeset for help on using the changeset viewer.