Ignore:
Timestamp:
Dec 27, 2011 2:45:13 PM (12 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

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

    r2730 r2744  
    114114
    115115    private variable _arcball ""
    116     private variable _outbuf       ;    # buffer for outgoing commands
    117 
    118     private variable _dlist ""     ;    # list of data objects
     116    private variable _outbuf       ;    # buffer for outgoing commands
     117
     118    private variable _dlist ""     ;    # list of data objects
    119119    private variable _obj2datasets
    120     private variable _obj2ovride   ;    # maps dataobj => style override
    121     private variable _datasets     ;    # contains all the dataobj-component
    122                                    ;    # datasets in the server
    123     private variable _colormaps    ;    # contains all the colormaps
    124                                    ;    # in the server.
     120    private variable _obj2ovride   ;    # maps dataobj => style override
     121    private variable _datasets     ;    # contains all the dataobj-component
     122                                   ;    # datasets in the server
     123    private variable _colormaps    ;    # contains all the colormaps
     124                                   ;    # in the server.
    125125    private variable _dataset2style    ;# maps dataobj-component to transfunc
    126126
    127     private variable _click        ;    # info used for rotate operations
    128     private variable _limits       ;    # autoscale min/max for all axes
    129     private variable _view         ;    # view params for 3D view
     127    private variable _click        ;    # info used for rotate operations
     128    private variable _limits       ;    # autoscale min/max for all axes
     129    private variable _view         ;    # view params for 3D view
    130130    private variable _settings
    131     private variable _style;            # Array of current component styles.
    132     private variable _initialStyle;     # Array of initial component styles.
    133     private variable _reset 1;          # indicates if camera needs to be reset
    134                                         # to starting position.
    135 
    136     private variable _first ""     ;    # This is the topmost dataset.
     131    private variable _style;            # Array of current component styles.
     132    private variable _initialStyle;     # Array of initial component styles.
     133    private variable _reset 1;          # indicates if camera needs to be reset
     134                                        # to starting position.
     135
     136    private variable _first ""     ;    # This is the topmost dataset.
    137137    private variable _start 0
    138138    private variable _buffering 0
     
    140140    private variable _seeds
    141141
    142     common _downloadPopup;              # download options from popup
     142    common _downloadPopup;              # download options from popup
    143143    private common _hardcopy
    144144    private variable _width 0
     
    154154    private variable _fields
    155155    private variable _currentField ""
    156     private variable _field      ""
     156    private variable _field      ""
    157157    private variable _numSeeds 200
    158158    private variable _colorMode "vmag";#  Mode of colormap (vmag or scalar)
     
    193193    $_dispatcher register !xcutplane
    194194    $_dispatcher dispatch $this !xcutplane \
    195         "[itcl::code $this AdjustSetting cutplane-xposition]; list"
     195        "[itcl::code $this AdjustSetting cutplane-xposition]; list"
    196196
    197197    # Y-Cutplane event
    198198    $_dispatcher register !ycutplane
    199199    $_dispatcher dispatch $this !ycutplane \
    200         "[itcl::code $this AdjustSetting cutplane-yposition]; list"
     200        "[itcl::code $this AdjustSetting cutplane-yposition]; list"
    201201
    202202    # Z-Cutplane event
    203203    $_dispatcher register !zcutplane
    204204    $_dispatcher dispatch $this !zcutplane \
    205         "[itcl::code $this AdjustSetting cutplane-zposition]; list"
     205        "[itcl::code $this AdjustSetting cutplane-zposition]; list"
    206206
    207207    #
     
    213213
    214214    array set _outline {
    215         id -1
    216         afterId -1
    217         x1 -1
    218         y1 -1
    219         x2 -1
    220         y2 -1
     215        id -1
     216        afterId -1
     217        x1 -1
     218        y1 -1
     219        x2 -1
     220        y2 -1
    221221    }
    222222    # Initialize the view to some default parameters.
    223223    array set _view {
    224         qw              1
    225         qx              0
    226         qy              0
    227         qz              0
    228         zoom            1.0
    229         xpan            0
    230         ypan            0
    231         ortho           0
     224        qw              1
     225        qx              0
     226        qy              0
     227        qz              0
     228        zoom            1.0
     229        xpan            0
     230        ypan            0
     231        ortho           0
    232232    }
    233233    set _arcball [blt::arcball create 100 100]
     
    239239
    240240    array set _settings [subst {
    241         axis-xgrid              0
    242         axis-ygrid              0
    243         axis-zgrid              0
    244         axis-xcutplane          0
    245         axis-ycutplane          0
    246         axis-zcutplane          0
    247         axis-xposition          0
    248         axis-yposition          0
    249         axis-zposition          0
    250         axis-visible            1
    251         axis-labels             1
    252         cutplane-edges          0
    253         cutplane-xvisible       0
    254         cutplane-yvisible       0
    255         cutplane-zvisible       0
    256         cutplane-xposition      50
    257         cutplane-yposition      50
    258         cutplane-zposition      50
    259         cutplane-visible        1
    260         cutplane-wireframe      0
    261         cutplane-opacity        100
    262         volume-lighting         1
    263         volume-opacity          40
    264         volume-visible          1
    265         volume-wireframe        0
    266         legend-visible          1
     241        axis-xgrid              0
     242        axis-ygrid              0
     243        axis-zgrid              0
     244        axis-xcutplane          0
     245        axis-ycutplane          0
     246        axis-zcutplane          0
     247        axis-xposition          0
     248        axis-yposition          0
     249        axis-zposition          0
     250        axis-visible            1
     251        axis-labels             1
     252        cutplane-edges          0
     253        cutplane-xvisible       0
     254        cutplane-yvisible       0
     255        cutplane-zvisible       0
     256        cutplane-xposition      50
     257        cutplane-yposition      50
     258        cutplane-zposition      50
     259        cutplane-visible        1
     260        cutplane-wireframe      0
     261        cutplane-opacity        100
     262        volume-lighting         1
     263        volume-opacity          40
     264        volume-visible          1
     265        volume-wireframe        0
     266        legend-visible          1
    267267    }]
    268268
     
    277277    itk_component add fieldmenu {
    278278        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
    279             -tearoff no
     279            -tearoff no
    280280    } {
    281         usual
    282         ignore -background -foreground -relief -tearoff
     281        usual
     282        ignore -background -foreground -relief -tearoff
    283283    }
    284284    set c $itk_component(view)
     
    342342            -onimage [Rappture::icon volume-on] \
    343343            -offimage [Rappture::icon volume-off] \
    344             -variable [itcl::scope _settings(volume-visible)] \
    345             -command [itcl::code $this AdjustSetting volume-visible]
     344            -variable [itcl::scope _settings(volume-visible)] \
     345            -command [itcl::code $this AdjustSetting volume-visible]
    346346    }
    347347    $itk_component(volume) select
     
    354354            -onimage [Rappture::icon cutbutton] \
    355355            -offimage [Rappture::icon cutbutton] \
    356             -variable [itcl::scope _settings(cutplane-visible)] \
    357             -command [itcl::code $this AdjustSetting cutplane-visible]
     356            -variable [itcl::scope _settings(cutplane-visible)] \
     357            -command [itcl::code $this AdjustSetting cutplane-visible]
    358358    }
    359359    $itk_component(cutplane) select
     
    364364
    365365    if { [catch {
    366         BuildVolumeTab
    367         BuildCutplaneTab
    368         BuildAxisTab
    369         BuildCameraTab
     366        BuildVolumeTab
     367        BuildCutplaneTab
     368        BuildAxisTab
     369        BuildCameraTab
    370370    } errs] != 0 } {
    371         puts stderr errs=$errs
     371        puts stderr errs=$errs
    372372    }
    373373    # Legend
     
    467467itcl::body Rappture::VtkVolumeViewer::DoResize {} {
    468468    if { $_width < 2 } {
    469         set _width 500
     469        set _width 500
    470470    }
    471471    if { $_height < 2 } {
    472         set _height 500
     472        set _height 500
    473473    }
    474474    set _start [clock clicks -milliseconds]
     
    514514    if { !$_rotatePending } {
    515515        set _rotatePending 1
    516         global rotate_delay
     516        global rotate_delay
    517517        $_dispatcher event -after $rotate_delay !rotate
    518518    }
     
    542542        -description ""
    543543        -param ""
    544         -type ""
     544        -type ""
    545545    }
    546546    array set params $settings
     
    559559    set pos [lsearch -exact $dataobj $_dlist]
    560560    if {$pos < 0} {
    561         lappend _dlist $dataobj
     561        lappend _dlist $dataobj
    562562    }
    563563    set _obj2ovride($dataobj-color) $params(-color)
     
    584584    foreach dataobj $args {
    585585        set pos [lsearch -exact $_dlist $dataobj]
    586         if { $pos < 0 } {
    587             continue;                   # Don't know anything about it.
    588         }
    589         # Remove it from the dataobj list.
    590         set _dlist [lreplace $_dlist $pos $pos]
    591         SendCmd "dataset visible 0"
    592         array unset _obj2ovride $dataobj-*
    593         array unset _settings $dataobj-*
    594         # Append to the end of the dataobj list.
    595         lappend _dlist $dataobj
    596         set changed 1
     586        if { $pos < 0 } {
     587            continue;                   # Don't know anything about it.
     588        }
     589        # Remove it from the dataobj list.
     590        set _dlist [lreplace $_dlist $pos $pos]
     591        SendCmd "dataset visible 0"
     592        array unset _obj2ovride $dataobj-*
     593        array unset _settings $dataobj-*
     594        # Append to the end of the dataobj list.
     595        lappend _dlist $dataobj
     596        set changed 1
    597597    }
    598598    # If anything changed, then rebuild the plot
     
    618618    set op [lindex $args 0]
    619619    switch -- $op {
    620         "-objects" {
    621             # put the dataobj list in order according to -raise options
    622             set dlist {}
    623             foreach dataobj $_dlist {
    624                 if { ![IsValidObject $dataobj] } {
    625                     continue
    626                 }
    627                 if {[info exists _obj2ovride($dataobj-raise)] &&
    628                     $_obj2ovride($dataobj-raise)} {
    629                     set dlist [linsert $dlist 0 $dataobj]
    630                 } else {
    631                     lappend dlist $dataobj
    632                 }
    633             }
    634             return $dlist
    635         }
    636         "-visible" {
    637             set dlist {}
    638             foreach dataobj $_dlist {
    639                 if { ![IsValidObject $dataobj] } {
    640                     continue
    641                 }
    642                 if { ![info exists _obj2ovride($dataobj-raise)] } {
    643                     # No setting indicates that the object isn't visible.
    644                     continue
    645                 }
    646                 # Otherwise use the -raise parameter to put the object to
    647                 # the front of the list.
    648                 if { $_obj2ovride($dataobj-raise) } {
    649                     set dlist [linsert $dlist 0 $dataobj]
    650                 } else {
    651                     lappend dlist $dataobj
    652                 }
    653             }
    654             return $dlist
    655         }          
    656         -image {
    657             if {[llength $args] != 2} {
    658                 error "wrong # args: should be \"get -image view\""
    659             }
    660             switch -- [lindex $args end] {
    661                 view {
    662                     return $_image(plot)
    663                 }
    664                 default {
    665                     error "bad image name \"[lindex $args end]\": should be view"
    666                 }
    667             }
    668         }
    669         default {
    670             error "bad option \"$op\": should be -objects or -image"
    671         }
     620        "-objects" {
     621            # put the dataobj list in order according to -raise options
     622            set dlist {}
     623            foreach dataobj $_dlist {
     624                if { ![IsValidObject $dataobj] } {
     625                    continue
     626                }
     627                if {[info exists _obj2ovride($dataobj-raise)] &&
     628                    $_obj2ovride($dataobj-raise)} {
     629                    set dlist [linsert $dlist 0 $dataobj]
     630                } else {
     631                    lappend dlist $dataobj
     632                }
     633            }
     634            return $dlist
     635        }
     636        "-visible" {
     637            set dlist {}
     638            foreach dataobj $_dlist {
     639                if { ![IsValidObject $dataobj] } {
     640                    continue
     641                }
     642                if { ![info exists _obj2ovride($dataobj-raise)] } {
     643                    # No setting indicates that the object isn't visible.
     644                    continue
     645                }
     646                # Otherwise use the -raise parameter to put the object to
     647                # the front of the list.
     648                if { $_obj2ovride($dataobj-raise) } {
     649                    set dlist [linsert $dlist 0 $dataobj]
     650                } else {
     651                    lappend dlist $dataobj
     652                }
     653            }
     654            return $dlist
     655        }          
     656        -image {
     657            if {[llength $args] != 2} {
     658                error "wrong # args: should be \"get -image view\""
     659            }
     660            switch -- [lindex $args end] {
     661                view {
     662                    return $_image(plot)
     663                }
     664                default {
     665                    error "bad image name \"[lindex $args end]\": should be view"
     666                }
     667            }
     668        }
     669        default {
     670            error "bad option \"$op\": should be -objects or -image"
     671        }
    672672    }
    673673}
     
    685685    array unset _limits
    686686    foreach dataobj $args {
    687         set string [limits $dataobj]
    688         if { $string == "" } {
    689             continue
    690         }
    691         array set bounds $string
    692         if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} {
    693             set _limits(xmin) $bounds(xmin)
    694         }
    695         if {![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax)} {
    696             set _limits(xmax) $bounds(xmax)
    697         }
    698 
    699         if {![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin)} {
    700             set _limits(ymin) $bounds(ymin)
    701         }
    702         if {![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax)} {
    703             set _limits(ymax) $bounds(ymax)
    704         }
    705 
    706         if {![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin)} {
    707             set _limits(zmin) $bounds(zmin)
    708         }
    709         if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} {
    710             set _limits(zmax) $bounds(zmax)
    711         }
     687        set string [limits $dataobj]
     688        if { $string == "" } {
     689            continue
     690        }
     691        array set bounds $string
     692        if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} {
     693            set _limits(xmin) $bounds(xmin)
     694        }
     695        if {![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax)} {
     696            set _limits(xmax) $bounds(xmax)
     697        }
     698
     699        if {![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin)} {
     700            set _limits(ymin) $bounds(ymin)
     701        }
     702        if {![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax)} {
     703            set _limits(ymax) $bounds(ymax)
     704        }
     705
     706        if {![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin)} {
     707            set _limits(zmin) $bounds(zmin)
     708        }
     709        if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} {
     710            set _limits(zmax) $bounds(zmax)
     711        }
    712712    }
    713713}
     
    745745            set word [Rappture::filexfer::label downloadWord]
    746746            $inner.summary configure -text "$word $num in the following format:"
    747             update idletasks            ;# Fix initial sizes
     747            update idletasks            ;# Fix initial sizes
    748748            return $popup
    749749        }
     
    854854    } else {
    855855        SendBytes "$string\n"
    856         StartWaiting
     856        StartWaiting
    857857    }
    858858}
     
    890890    StopWaiting
    891891    if { $info(-type) == "image" } {
    892         if 0 {
    893             set f [open "last.ppm" "w"]
    894             puts $f $bytes
    895             close $f
    896         }
     892        if 0 {
     893            set f [open "last.ppm" "w"]
     894            puts $f $bytes
     895            close $f
     896        }
    897897        $_image(plot) configure -data $bytes
    898         set time [clock seconds]
    899         set date [clock format $time]
     898        set time [clock seconds]
     899        set date [clock format $time]
    900900        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
    901         if { $_start > 0 } {
    902             set finish [clock clicks -milliseconds]
    903             #puts stderr "round trip time [expr $finish -$_start] milliseconds"
    904             set _start 0
    905         }
     901        if { $_start > 0 } {
     902            set finish [clock clicks -milliseconds]
     903            #puts stderr "round trip time [expr $finish -$_start] milliseconds"
     904            set _start 0
     905        }
    906906    } elseif { $info(type) == "print" } {
    907907        set tag $this-print-$info(-token)
     
    909909    }
    910910    if { $_legendPending } {
    911         RequestLegend
     911        RequestLegend
    912912    }
    913913}
     
    922922    set option [lindex $args 0]
    923923    switch -- $option {
    924         "scalar" {
    925             set option [lindex $args 1]
    926             switch -- $option {
    927                 "world" {
    928                     foreach { x y z value tag } [lrange $args 2 end] break
    929                 }
    930                 "pixel" {
    931                     foreach { x y value tag } [lrange $args 2 end] break
    932                 }
    933             }
    934         }
    935         "vector" {
    936             set option [lindex $args 1]
    937             switch -- $option {
    938                 "world" {
    939                     foreach { x y z vx vy vz tag } [lrange $args 2 end] break
    940                 }
    941                 "pixel" {
    942                     foreach { x y vx vy vz tag } [lrange $args 2 end] break
    943                 }
    944             }
    945         }
    946         "names" {
     924        "scalar" {
     925            set option [lindex $args 1]
     926            switch -- $option {
     927                "world" {
     928                    foreach { x y z value tag } [lrange $args 2 end] break
     929                }
     930                "pixel" {
     931                    foreach { x y value tag } [lrange $args 2 end] break
     932                }
     933            }
     934        }
     935        "vector" {
     936            set option [lindex $args 1]
     937            switch -- $option {
     938                "world" {
     939                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
     940                }
     941                "pixel" {
     942                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
     943                }
     944            }
     945        }
     946        "names" {
    947947            foreach { name } [lindex $args 1] {
    948948                #puts stderr "Dataset: $name"
    949949            }
    950         }
    951         default {
    952             error "unknown dataset option \"$option\" from server"
    953         }
     950        }
     951        default {
     952            error "unknown dataset option \"$option\" from server"
     953        }
    954954    }
    955955}
     
    967967    set h [winfo height $itk_component(view)]
    968968    if { $w < 2 || $h < 2 } {
    969         $_dispatcher event -idle !rebuild
    970         return
     969        $_dispatcher event -idle !rebuild
     970        return
    971971    }
    972972
     
    994994    set _first ""
    995995    InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
    996         axis-visible axis-labels cutplane-visible \
    997         cutplane-xposition cutplane-yposition cutplane-zposition \
    998         cutplane-xvisible cutplane-yvisible cutplane-zvisible
     996        axis-visible axis-labels cutplane-visible \
     997        cutplane-xposition cutplane-yposition cutplane-zposition \
     998        cutplane-xvisible cutplane-yvisible cutplane-zvisible
    999999
    10001000    SendCmd "imgflush"
     
    10051005
    10061006    foreach dataobj [get -objects] {
    1007         if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    1008             set _first $dataobj
    1009         }
    1010         set _obj2datasets($dataobj) ""
     1007        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
     1008            set _first $dataobj
     1009        }
     1010        set _obj2datasets($dataobj) ""
    10111011        foreach comp [$dataobj components] {
    10121012            set tag $dataobj-$comp
     
    10171017                append _outbuf $bytes
    10181018                set _datasets($tag) 1
    1019                 SetObjectStyle $dataobj $comp
    1020             }
    1021             lappend _obj2datasets($dataobj) $tag
    1022             if { [info exists _obj2ovride($dataobj-raise)] } {
    1023                 SendCmd "dataset visible 1 $tag"
    1024             } else {
    1025                 SendCmd "dataset visible 0 $tag"
    1026             }
    1027             break
     1019                SetObjectStyle $dataobj $comp
     1020            }
     1021            lappend _obj2datasets($dataobj) $tag
     1022            if { [info exists _obj2ovride($dataobj-raise)] } {
     1023                SendCmd "dataset visible 1 $tag"
     1024            } else {
     1025                SendCmd "dataset visible 0 $tag"
     1026            }
     1027            break
    10281028        }
    10291029    }
     
    10341034        }
    10351035
    1036         if 0 {
    1037             # Tell the server the name of the tool, the version, and dataset
    1038             # that we are rendering.  Have to do it here because we don't know
    1039             # what data objects are using the renderer until be get here.
    1040             set args ""
    1041             lappend args tool [$_first hints toolId]
    1042             lappend args version [$_first hints toolRevision]
    1043             lappend args dataset [$_first hints label]
    1044             SendCmd "clientinfo $args"
    1045         }
    1046 
    1047         foreach axis { x y z } {
    1048             set label [$_first hints ${axis}label]
    1049             if { $label != "" } {
    1050                 SendCmd "axis name $axis $label"
    1051             }
    1052             set units [$_first hints ${axis}units]
    1053             if { $units != "" } {
    1054                 SendCmd "axis units $axis $units"
    1055             }
    1056         }
    1057         array unset _scalarFields
    1058         array unset _vectorFields
    1059         set _currentField [$_first hints default]
    1060         $itk_component(field) choices delete 0 end
    1061         $itk_component(fieldmenu) delete 0 end
    1062         array unset _fields
    1063         foreach { name title units } [$_first hints vectors] {
    1064             set _vectorFields($title) $name
    1065             $itk_component(field) choices insert end "$name" "$title"
    1066             $itk_component(fieldmenu) add radiobutton -label "$title" \
    1067                 -value $title -variable [itcl::scope _currentField] \
    1068                 -selectcolor red \
    1069                 -activebackground black \
    1070                 -activeforeground white \
    1071                 -font "Arial 8" \
    1072                 -command [itcl::code $this Combo invoke]
    1073             set _fields($name) [list $title $units]
    1074         }
    1075         foreach { name title units } [$_first hints scalars] {
    1076             set _scalarFields($title) $name
    1077             $itk_component(field) choices insert end "$name" "$title"
    1078             $itk_component(fieldmenu) add radiobutton -label "$title" \
    1079                 -value $title -variable [itcl::scope _currentField] \
    1080                 -selectcolor red \
    1081                 -activebackground black \
    1082                 -activeforeground white \
    1083                 -font "Arial 8" \
    1084                 -command [itcl::code $this Combo invoke]
    1085             set _fields($name) [list $title $units]
    1086         }
    1087         foreach { name title units } { default Default ??? } {
    1088             set _scalarFields($title) $name
    1089             $itk_component(field) choices insert end "$name" "$title"
    1090             $itk_component(fieldmenu) add radiobutton -label "$title" \
    1091                 -value $title -variable [itcl::scope _currentField] \
    1092                 -selectcolor red \
    1093                 -activebackground black \
    1094                 -activeforeground white \
    1095                 -font "Arial 8" \
    1096                 -command [itcl::code $this Combo invoke]
    1097             set _fields($name) [list $title $units]
    1098         }
    1099         $itk_component(field) value $_currentField
     1036        if 0 {
     1037            # Tell the server the name of the tool, the version, and dataset
     1038            # that we are rendering.  Have to do it here because we don't know
     1039            # what data objects are using the renderer until be get here.
     1040            set args ""
     1041            lappend args tool [$_first hints toolId]
     1042            lappend args version [$_first hints toolRevision]
     1043            lappend args dataset [$_first hints label]
     1044            SendCmd "clientinfo $args"
     1045        }
     1046
     1047        foreach axis { x y z } {
     1048            set label [$_first hints ${axis}label]
     1049            if { $label != "" } {
     1050                SendCmd "axis name $axis $label"
     1051            }
     1052            set units [$_first hints ${axis}units]
     1053            if { $units != "" } {
     1054                SendCmd "axis units $axis $units"
     1055            }
     1056        }
     1057        array unset _scalarFields
     1058        array unset _vectorFields
     1059        set _currentField [$_first hints default]
     1060        $itk_component(field) choices delete 0 end
     1061        $itk_component(fieldmenu) delete 0 end
     1062        array unset _fields
     1063        foreach { name title units } [$_first hints vectors] {
     1064            set _vectorFields($title) $name
     1065            $itk_component(field) choices insert end "$name" "$title"
     1066            $itk_component(fieldmenu) add radiobutton -label "$title" \
     1067                -value $title -variable [itcl::scope _currentField] \
     1068                -selectcolor red \
     1069                -activebackground black \
     1070                -activeforeground white \
     1071                -font "Arial 8" \
     1072                -command [itcl::code $this Combo invoke]
     1073            set _fields($name) [list $title $units]
     1074        }
     1075        foreach { name title units } [$_first hints scalars] {
     1076            set _scalarFields($title) $name
     1077            $itk_component(field) choices insert end "$name" "$title"
     1078            $itk_component(fieldmenu) add radiobutton -label "$title" \
     1079                -value $title -variable [itcl::scope _currentField] \
     1080                -selectcolor red \
     1081                -activebackground black \
     1082                -activeforeground white \
     1083                -font "Arial 8" \
     1084                -command [itcl::code $this Combo invoke]
     1085            set _fields($name) [list $title $units]
     1086        }
     1087        foreach { name title units } { default Default ??? } {
     1088            set _scalarFields($title) $name
     1089            $itk_component(field) choices insert end "$name" "$title"
     1090            $itk_component(fieldmenu) add radiobutton -label "$title" \
     1091                -value $title -variable [itcl::scope _currentField] \
     1092                -selectcolor red \
     1093                -activebackground black \
     1094                -activeforeground white \
     1095                -font "Arial 8" \
     1096                -command [itcl::code $this Combo invoke]
     1097            set _fields($name) [list $title $units]
     1098        }
     1099        $itk_component(field) value $_currentField
    11001100    }
    11011101
     
    11031103
    11041104    if { $_reset } {
    1105         InitSettings volume-lighting
    1106         Zoom reset
    1107         set _reset 0
     1105        InitSettings volume-lighting
     1106        Zoom reset
     1107        set _reset 0
    11081108    }
    11091109    set _buffering 0;                        # Turn off buffering.
     
    11271127    set flag [lindex $args 0]
    11281128    switch -- $flag {
    1129         "-all" {
    1130             if { [llength $args] > 1 } {
    1131                 error "CurrentDatasets: can't specify dataobj after \"-all\""
    1132             }
    1133             set dlist [get -objects]
    1134         }
    1135         "-visible" {
    1136             if { [llength $args] > 1 } {
    1137                 set dlist {}
    1138                 set args [lrange $args 1 end]
    1139                 foreach dataobj $args {
    1140                     if { [info exists _obj2ovride($dataobj-raise)] } {
    1141                         lappend dlist $dataobj
    1142                     }
    1143                 }
    1144             } else {
    1145                 set dlist [get -visible]
    1146             }
    1147         }          
    1148         default {
    1149             set dlist $args
    1150         }
     1129        "-all" {
     1130            if { [llength $args] > 1 } {
     1131                error "CurrentDatasets: can't specify dataobj after \"-all\""
     1132            }
     1133            set dlist [get -objects]
     1134        }
     1135        "-visible" {
     1136            if { [llength $args] > 1 } {
     1137                set dlist {}
     1138                set args [lrange $args 1 end]
     1139                foreach dataobj $args {
     1140                    if { [info exists _obj2ovride($dataobj-raise)] } {
     1141                        lappend dlist $dataobj
     1142                    }
     1143                }
     1144            } else {
     1145                set dlist [get -visible]
     1146            }
     1147        }          
     1148        default {
     1149            set dlist $args
     1150        }
    11511151    }
    11521152    set rlist ""
    11531153    foreach dataobj $dlist {
    1154         foreach comp [$dataobj components] {
    1155             set tag $dataobj-$comp
    1156             if { [info exists _datasets($tag)] && $_datasets($tag) } {
    1157                 lappend rlist $tag
    1158             }
    1159         }
     1154        foreach comp [$dataobj components] {
     1155            set tag $dataobj-$comp
     1156            if { [info exists _datasets($tag)] && $_datasets($tag) } {
     1157                lappend rlist $tag
     1158            }
     1159        }
    11601160    }
    11611161    return $rlist
     
    11741174        "in" {
    11751175            set _view(zoom) [expr {$_view(zoom)*1.25}]
    1176             SendCmd "camera zoom $_view(zoom)"
     1176            SendCmd "camera zoom $_view(zoom)"
    11771177        }
    11781178        "out" {
    11791179            set _view(zoom) [expr {$_view(zoom)*0.8}]
    1180             SendCmd "camera zoom $_view(zoom)"
     1180            SendCmd "camera zoom $_view(zoom)"
    11811181        }
    11821182        "reset" {
    11831183            array set _view {
    1184                 qw      1
    1185                 qx      0
    1186                 qy      0
    1187                 qz      0
     1184                qw      1
     1185                qx      0
     1186                qy      0
     1187                qz      0
    11881188                zoom    1.0
    11891189                xpan   0
     
    11971197                }
    11981198            }
    1199             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1200             $_arcball quaternion $q
    1201             DoRotate
     1199            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1200            $_arcball quaternion $q
     1201            DoRotate
    12021202        }
    12031203    }
     
    12431243                    return
    12441244                }
    1245                 if { $dx == 0 && $dy == 0 } {
    1246                     return
    1247                 }
    1248                 set q [$_arcball rotate $x $y $_click(x) $_click(y)]
    1249                 EventuallyRotate $q
     1245                if { $dx == 0 && $dy == 0 } {
     1246                    return
     1247                }
     1248                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
     1249                EventuallyRotate $q
    12501250                set _click(x) $x
    12511251                set _click(y) $y
     
    12791279itcl::body Rappture::VtkVolumeViewer::Pan {option x y} {
    12801280    switch -- $option {
    1281         "set" {
    1282             set w [winfo width $itk_component(view)]
    1283             set h [winfo height $itk_component(view)]
    1284             set x [expr $x / double($w)]
    1285             set y [expr $y / double($h)]
    1286             set _view(xpan) [expr $_view(xpan) + $x]
    1287             set _view(ypan) [expr $_view(ypan) + $y]
    1288             PanCamera
    1289             return
    1290         }
    1291         "click" {
    1292             set _click(x) $x
    1293             set _click(y) $y
    1294             $itk_component(view) configure -cursor hand1
    1295         }
    1296         "drag" {
    1297             if { ![info exists _click(x)] } {
    1298                 set _click(x) $x
    1299             }
    1300             if { ![info exists _click(y)] } {
    1301                 set _click(y) $y
    1302             }
    1303             set w [winfo width $itk_component(view)]
    1304             set h [winfo height $itk_component(view)]
    1305             set dx [expr ($_click(x) - $x)/double($w)]
    1306             set dy [expr ($_click(y) - $y)/double($h)]
    1307             set _click(x) $x
    1308             set _click(y) $y
    1309             set _view(xpan) [expr $_view(xpan) - $dx]
    1310             set _view(ypan) [expr $_view(ypan) - $dy]
    1311             PanCamera
    1312         }
    1313         "release" {
    1314             Pan drag $x $y
    1315             $itk_component(view) configure -cursor ""
    1316         }
    1317         default {
    1318             error "unknown option \"$option\": should set, click, drag, or release"
    1319         }
     1281        "set" {
     1282            set w [winfo width $itk_component(view)]
     1283            set h [winfo height $itk_component(view)]
     1284            set x [expr $x / double($w)]
     1285            set y [expr $y / double($h)]
     1286            set _view(xpan) [expr $_view(xpan) + $x]
     1287            set _view(ypan) [expr $_view(ypan) + $y]
     1288            PanCamera
     1289            return
     1290        }
     1291        "click" {
     1292            set _click(x) $x
     1293            set _click(y) $y
     1294            $itk_component(view) configure -cursor hand1
     1295        }
     1296        "drag" {
     1297            if { ![info exists _click(x)] } {
     1298                set _click(x) $x
     1299            }
     1300            if { ![info exists _click(y)] } {
     1301                set _click(y) $y
     1302            }
     1303            set w [winfo width $itk_component(view)]
     1304            set h [winfo height $itk_component(view)]
     1305            set dx [expr ($_click(x) - $x)/double($w)]
     1306            set dy [expr ($_click(y) - $y)/double($h)]
     1307            set _click(x) $x
     1308            set _click(y) $y
     1309            set _view(xpan) [expr $_view(xpan) - $dx]
     1310            set _view(ypan) [expr $_view(ypan) - $dy]
     1311            PanCamera
     1312        }
     1313        "release" {
     1314            Pan drag $x $y
     1315            $itk_component(view) configure -cursor ""
     1316        }
     1317        default {
     1318            error "unknown option \"$option\": should set, click, drag, or release"
     1319        }
    13201320    }
    13211321}
     
    13301330itcl::body Rappture::VtkVolumeViewer::InitSettings { args } {
    13311331    foreach spec $args {
    1332         if { [info exists _settings($_first-$spec)] } {
    1333             # Reset global setting with dataobj specific setting
    1334             set _settings($spec) $_settings($_first-$spec)
    1335         }
    1336         AdjustSetting $spec
     1332        if { [info exists _settings($_first-$spec)] } {
     1333            # Reset global setting with dataobj specific setting
     1334            set _settings($spec) $_settings($_first-$spec)
     1335        }
     1336        AdjustSetting $spec
    13371337    }
    13381338}
     
    13411341# AdjustSetting --
    13421342#
    1343 #       Changes/updates a specific setting in the widget.  There are
    1344 #       usually user-setable option.  Commands are sent to the render
    1345 #       server.
     1343#       Changes/updates a specific setting in the widget.  There are
     1344#       usually user-setable option.  Commands are sent to the render
     1345#       server.
    13461346#
    13471347itcl::body Rappture::VtkVolumeViewer::AdjustSetting {what {value ""}} {
    13481348    if { ![isconnected] } {
    1349         return
     1349        return
    13501350    }
    13511351    switch -- $what {
    13521352        "volume-visible" {
    1353             set bool $_settings(volume-visible)
    1354             foreach dataset [CurrentDatasets -visible] {
    1355                 SendCmd "volume visible $bool $dataset"
    1356             }
    1357             if { $bool } {
    1358                 Rappture::Tooltip::for $itk_component(volume) \
    1359                     "Hide the volume"
    1360             } else {
    1361                 Rappture::Tooltip::for $itk_component(volume) \
    1362                     "Show the volume"
    1363             }
     1353            set bool $_settings(volume-visible)
     1354            foreach dataset [CurrentDatasets -visible] {
     1355                SendCmd "volume visible $bool $dataset"
     1356            }
     1357            if { $bool } {
     1358                Rappture::Tooltip::for $itk_component(volume) \
     1359                    "Hide the volume"
     1360            } else {
     1361                Rappture::Tooltip::for $itk_component(volume) \
     1362                    "Show the volume"
     1363            }
    13641364        }
    13651365        "volume-lighting" {
    1366             set bool $_settings(volume-lighting)
    1367             foreach dataset [CurrentDatasets -visible] {
    1368                 SendCmd "volume lighting $bool $dataset"
     1366            set bool $_settings(volume-lighting)
     1367            foreach dataset [CurrentDatasets -visible] {
     1368                SendCmd "volume lighting $bool $dataset"
    13691369            }
    13701370        }
    13711371        "axis-visible" {
    1372             set bool $_settings(axis-visible)
    1373             SendCmd "axis visible all $bool"
     1372            set bool $_settings(axis-visible)
     1373            SendCmd "axis visible all $bool"
    13741374        }
    13751375        "axis-labels" {
    1376             set bool $_settings(axis-labels)
    1377             SendCmd "axis labels all $bool"
     1376            set bool $_settings(axis-labels)
     1377            SendCmd "axis labels all $bool"
    13781378        }
    13791379        "axis-xgrid" - "axis-ygrid" - "axis-zgrid" {
    1380             set axis [string range $what 5 5]
    1381             set bool $_settings($what)
    1382             SendCmd "axis grid $axis $bool"
     1380            set axis [string range $what 5 5]
     1381            set bool $_settings($what)
     1382            SendCmd "axis grid $axis $bool"
    13831383        }
    13841384        "axis-mode" {
    1385             set mode [$itk_component(axismode) value]
    1386             set mode [$itk_component(axismode) translate $mode]
    1387             set _settings($what) $mode
    1388             SendCmd "axis flymode $mode"
     1385            set mode [$itk_component(axismode) value]
     1386            set mode [$itk_component(axismode) translate $mode]
     1387            set _settings($what) $mode
     1388            SendCmd "axis flymode $mode"
    13891389        }
    13901390        "cutplane-edges" {
    1391             set bool $_settings($what)
    1392             foreach dataset [CurrentDatasets -visible] {
    1393                 SendCmd "cutplane edges $bool $dataset"
     1391            set bool $_settings($what)
     1392            foreach dataset [CurrentDatasets -visible] {
     1393                SendCmd "cutplane edges $bool $dataset"
    13941394            }
    13951395        }
    13961396        "cutplane-visible" {
    1397             set bool $_settings($what)
    1398             foreach dataset [CurrentDatasets -visible] {
    1399                 SendCmd "cutplane visible $bool $dataset"
     1397            set bool $_settings($what)
     1398            foreach dataset [CurrentDatasets -visible] {
     1399                SendCmd "cutplane visible $bool $dataset"
    14001400            }
    14011401        }
    14021402        "cutplane-wireframe" {
    1403             set bool $_settings($what)
    1404             foreach dataset [CurrentDatasets -visible] {
    1405                 SendCmd "cutplane wireframe $bool $dataset"
     1403            set bool $_settings($what)
     1404            foreach dataset [CurrentDatasets -visible] {
     1405                SendCmd "cutplane wireframe $bool $dataset"
    14061406            }
    14071407        }
    14081408        "cutplane-lighting" {
    1409             set bool $_settings($what)
    1410             foreach dataset [CurrentDatasets -visible] {
    1411                 SendCmd "cutplane lighting $bool $dataset"
     1409            set bool $_settings($what)
     1410            foreach dataset [CurrentDatasets -visible] {
     1411                SendCmd "cutplane lighting $bool $dataset"
    14121412            }
    14131413        }
    14141414        "cutplane-opacity" {
    1415             set val $_settings($what)
    1416             set sval [expr { 0.01 * double($val) }]
    1417             foreach dataset [CurrentDatasets -visible] {
    1418                 SendCmd "cutplane opacity $sval $dataset"
    1419             }
    1420         }
    1421         "cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" {
    1422             set axis [string range $what 9 9]
    1423             set bool $_settings($what)
     1415            set val $_settings($what)
     1416            set sval [expr { 0.01 * double($val) }]
     1417            foreach dataset [CurrentDatasets -visible] {
     1418                SendCmd "cutplane opacity $sval $dataset"
     1419            }
     1420        }
     1421        "cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" {
     1422            set axis [string range $what 9 9]
     1423            set bool $_settings($what)
    14241424            if { $bool } {
    14251425                $itk_component(${axis}CutScale) configure -state normal \
     
    14291429                    -troughcolor grey82
    14301430            }
    1431             SendCmd "cutplane axis $axis $bool"
    1432         }
    1433         "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" {
    1434             set axis [string range $what 9 9]
    1435             set pos [expr $_settings($what) * 0.01]
    1436             SendCmd "cutplane slice ${axis} ${pos}"
    1437             set _cutplanePending 0
    1438         }
     1431            SendCmd "cutplane axis $axis $bool"
     1432        }
     1433        "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" {
     1434            set axis [string range $what 9 9]
     1435            set pos [expr $_settings($what) * 0.01]
     1436            SendCmd "cutplane slice ${axis} ${pos}"
     1437            set _cutplanePending 0
     1438        }
    14391439        "volume-palette" {
    1440             set palette [$itk_component(palette) value]
    1441             set _settings(volume-palette) $palette
    1442             foreach dataset [CurrentDatasets -visible $_first] {
    1443                 foreach {dataobj comp} [split $dataset -] break
    1444                 ChangeColormap $dataobj $comp $palette
    1445             }
    1446             set _legendPending 1
     1440            set palette [$itk_component(palette) value]
     1441            set _settings(volume-palette) $palette
     1442            foreach dataset [CurrentDatasets -visible $_first] {
     1443                foreach {dataobj comp} [split $dataset -] break
     1444                ChangeColormap $dataobj $comp $palette
     1445            }
     1446            set _legendPending 1
    14471447        }
    14481448        "volume-palette" {
    1449             set palette [$itk_component(palette) value]
    1450             set _settings(volume-palette) $palette
    1451             foreach dataset [CurrentDatasets -visible $_first] {
    1452                 foreach {dataobj comp} [split $dataset -] break
    1453                 ChangeColormap $dataobj $comp $palette
    1454             }
    1455             set _legendPending 1
     1449            set palette [$itk_component(palette) value]
     1450            set _settings(volume-palette) $palette
     1451            foreach dataset [CurrentDatasets -visible $_first] {
     1452                foreach {dataobj comp} [split $dataset -] break
     1453                ChangeColormap $dataobj $comp $palette
     1454            }
     1455            set _legendPending 1
    14561456        }
    14571457        "volume-field" {
    1458             set new [$itk_component(field) value]
    1459             set value [$itk_component(field) translate $new]
    1460             set _settings(volume-field) $value
    1461             if { [info exists _scalarFields($new)] } {
    1462                 set name $_scalarFields($new)
    1463                 set _colorMode scalar
    1464                 set _currentField $new
    1465             } elseif { [info exists _vectorFields($new)] } {
    1466                 set name $_vectorFields($new)
    1467                 set _colorMode vmag
    1468                 set _currentField $new
    1469             } else {
    1470                 puts stderr "unknown field \"$new\""
    1471                 return
    1472             }
    1473             foreach dataset [CurrentDatasets -visible] {
    1474                 #puts stderr "volume colormode $_colorMode ${name} $dataset"
    1475                 puts stderr "cutplane colormode $_colorMode ${name} $dataset"
    1476                 #SendCmd "volume colormode $_colorMode ${name} $dataset"
    1477                 SendCmd "cutplane colormode $_colorMode ${name} $dataset"
    1478             }
    1479             set _legendPending 1
     1458            set new [$itk_component(field) value]
     1459            set value [$itk_component(field) translate $new]
     1460            set _settings(volume-field) $value
     1461            if { [info exists _scalarFields($new)] } {
     1462                set name $_scalarFields($new)
     1463                set _colorMode scalar
     1464                set _currentField $new
     1465            } elseif { [info exists _vectorFields($new)] } {
     1466                set name $_vectorFields($new)
     1467                set _colorMode vmag
     1468                set _currentField $new
     1469            } else {
     1470                puts stderr "unknown field \"$new\""
     1471                return
     1472            }
     1473            foreach dataset [CurrentDatasets -visible] {
     1474                #puts stderr "volume colormode $_colorMode ${name} $dataset"
     1475                puts stderr "cutplane colormode $_colorMode ${name} $dataset"
     1476                #SendCmd "volume colormode $_colorMode ${name} $dataset"
     1477                SendCmd "cutplane colormode $_colorMode ${name} $dataset"
     1478            }
     1479            set _legendPending 1
    14801480        }
    14811481        default {
     
    14881488# RequestLegend --
    14891489#
    1490 #       Request a new legend from the server.  The size of the legend
    1491 #       is determined from the height of the canvas.  It will be rotated
    1492 #       to be vertical when drawn.
     1490#       Request a new legend from the server.  The size of the legend
     1491#       is determined from the height of the canvas.  It will be rotated
     1492#       to be vertical when drawn.
    14931493#
    14941494itcl::body Rappture::VtkVolumeViewer::RequestLegend {} {
     
    14991499    set h [expr {$_height - 3 * ($lineht + 2)}]
    15001500    if { $h < 1} {
    1501         return
     1501        return
    15021502    }
    15031503    if { [info exists _scalarFields($_currentField)] } {
    1504         set name $_scalarFields($_currentField)
     1504        set name $_scalarFields($_currentField)
    15051505    } elseif { [info exists _vectorFields($_currentField)] } {
    1506         set name $_vectorFields($_currentField)
     1506        set name $_vectorFields($_currentField)
    15071507    } else {
    1508         return
     1508        return
    15091509    }
    15101510    # Set the legend on the first volume dataset.
    15111511    foreach dataset [CurrentDatasets -visible $_first] {
    1512         foreach {dataobj comp} [split $dataset -] break
    1513         if { [info exists _dataset2style($dataset)] } {
     1512        foreach {dataobj comp} [split $dataset -] break
     1513        if { [info exists _dataset2style($dataset)] } {
    15141514            SendCmdNoWait \
    1515                 "legend $_dataset2style($dataset) $_colorMode $name {} $w $h 0"
    1516             break;
     1515                "legend $_dataset2style($dataset) $_colorMode $name {} $w $h 0"
     1516            break;
    15171517        }
    15181518    }
     
    15251525    set tag $dataobj-$comp
    15261526    if { ![info exist _style($tag)] } {
    1527         error "no initial colormap"
     1527        error "no initial colormap"
    15281528    }
    15291529    array set style $_style($tag)
     
    15441544    set tag $dataobj-$comp
    15451545    if { ![info exists _initialStyle($tag)] } {
    1546         # Save the initial component style.
    1547         set _initialStyle($tag) [$dataobj style $comp]
     1546        # Save the initial component style.
     1547        set _initialStyle($tag) [$dataobj style $comp]
    15481548    }
    15491549
     
    15521552
    15531553    if { ![info exists _style($tag)] } {
    1554         set _style($tag) [array get style]
     1554        set _style($tag) [array get style]
    15551555    }
    15561556    # Override initial style with current style.
     
    15591559    set name "$style(-color):$style(-levels):$style(-opacity)"
    15601560    if { ![info exists _colormaps($name)] } {
    1561         BuildColormap $name [array get style]
    1562         set _colormaps($name) 1
     1561        BuildColormap $name [array get style]
     1562        set _colormaps($name) 1
    15631563    }
    15641564    if { ![info exists _dataset2style($tag)] ||
    1565         $_dataset2style($tag) != $name } {
    1566         SendCmd "volume colormap $name $tag"
    1567         SendCmd "cutplane colormap $name $tag"
    1568         set _dataset2style($tag) $name
     1565        $_dataset2style($tag) != $name } {
     1566        SendCmd "volume colormap $name $tag"
     1567        SendCmd "cutplane colormap $name $tag"
     1568        set _dataset2style($tag) $name
    15691569    }
    15701570}
     
    15731573puts stderr colors=$colors
    15741574    switch -- $colors {
    1575         "grey-to-blue" {
    1576             return {
    1577                 0.0                      0.200 0.200 0.200
    1578                 0.14285714285714285      0.400 0.400 0.400
    1579                 0.2857142857142857      0.600 0.600 0.600
    1580                 0.42857142857142855      0.900 0.900 0.900
    1581                 0.5714285714285714      0.800 1.000 1.000
    1582                 0.7142857142857143      0.600 1.000 1.000
    1583                 0.8571428571428571      0.400 0.900 1.000
    1584                 1.0                      0.000 0.600 0.800
    1585             }
    1586         }
    1587         "blue-to-grey" {
    1588             return {
    1589                 0.0                     0.000 0.600 0.800
    1590                 0.14285714285714285     0.400 0.900 1.000
    1591                 0.2857142857142857      0.600 1.000 1.000
    1592                 0.42857142857142855     0.800 1.000 1.000
    1593                 0.5714285714285714      0.900 0.900 0.900
    1594                 0.7142857142857143      0.600 0.600 0.600
    1595                 0.8571428571428571      0.400 0.400 0.400
    1596                 1.0                     0.200 0.200 0.200
    1597             }
    1598         }
    1599         "blue" {
    1600             return {
    1601                 0.0                     0.900 1.000 1.000
    1602                 0.1111111111111111      0.800 0.983 1.000
    1603                 0.2222222222222222      0.700 0.950 1.000
    1604                 0.3333333333333333      0.600 0.900 1.000
    1605                 0.4444444444444444      0.500 0.833 1.000
    1606                 0.5555555555555556      0.400 0.750 1.000
    1607                 0.6666666666666666      0.300 0.650 1.000
    1608                 0.7777777777777778      0.200 0.533 1.000
    1609                 0.8888888888888888      0.100 0.400 1.000
    1610                 1.0                     0.000 0.250 1.000
    1611             }
    1612         }
    1613         "brown-to-blue" {
    1614             return {
    1615                 0.0                             0.200   0.100   0.000
    1616                 0.09090909090909091             0.400   0.187   0.000
    1617                 0.18181818181818182             0.600   0.379   0.210
    1618                 0.2727272727272727              0.800   0.608   0.480
    1619                 0.36363636363636365             0.850   0.688   0.595
    1620                 0.45454545454545453             0.950   0.855   0.808
    1621                 0.5454545454545454              0.800   0.993   1.000
    1622                 0.6363636363636364              0.600   0.973   1.000
    1623                 0.7272727272727273              0.400   0.940   1.000
    1624                 0.8181818181818182              0.200   0.893   1.000
    1625                 0.9090909090909091              0.000   0.667   0.800
    1626                 1.0                             0.000   0.480   0.600
    1627             }
    1628         }
    1629         "blue-to-brown" {
    1630             return {
    1631                 0.0                             0.000   0.480   0.600
    1632                 0.09090909090909091             0.000   0.667   0.800
    1633                 0.18181818181818182             0.200   0.893   1.000
    1634                 0.2727272727272727              0.400   0.940   1.000
    1635                 0.36363636363636365             0.600   0.973   1.000
    1636                 0.45454545454545453             0.800   0.993   1.000
    1637                 0.5454545454545454              0.950   0.855   0.808
    1638                 0.6363636363636364              0.850   0.688   0.595
    1639                 0.7272727272727273              0.800   0.608   0.480
    1640                 0.8181818181818182              0.600   0.379   0.210
    1641                 0.9090909090909091              0.400   0.187   0.000
    1642                 1.0                             0.200   0.100   0.000
    1643             }
    1644         }
    1645         "blue-to-orange" {
    1646             return {
    1647                 0.0                             0.000   0.167   1.000
    1648                 0.09090909090909091             0.100   0.400   1.000
    1649                 0.18181818181818182             0.200   0.600   1.000
    1650                 0.2727272727272727              0.400   0.800   1.000
    1651                 0.36363636363636365             0.600   0.933   1.000
    1652                 0.45454545454545453             0.800   1.000   1.000
    1653                 0.5454545454545454              1.000   1.000   0.800
    1654                 0.6363636363636364              1.000   0.933   0.600
    1655                 0.7272727272727273              1.000   0.800   0.400
    1656                 0.8181818181818182              1.000   0.600   0.200
    1657                 0.9090909090909091              1.000   0.400   0.100
    1658                 1.0                             1.000   0.167   0.000
    1659             }
    1660         }
    1661         "orange-to-blue" {
    1662             return {
    1663                 0.0                             1.000   0.167   0.000
    1664                 0.09090909090909091             1.000   0.400   0.100
    1665                 0.18181818181818182             1.000   0.600   0.200
    1666                 0.2727272727272727              1.000   0.800   0.400
    1667                 0.36363636363636365             1.000   0.933   0.600
    1668                 0.45454545454545453             1.000   1.000   0.800
    1669                 0.5454545454545454              0.800   1.000   1.000
    1670                 0.6363636363636364              0.600   0.933   1.000
    1671                 0.7272727272727273              0.400   0.800   1.000
    1672                 0.8181818181818182              0.200   0.600   1.000
    1673                 0.9090909090909091              0.100   0.400   1.000
    1674                 1.0                             0.000   0.167   1.000
    1675             }
    1676         }
    1677         "rainbow" {
    1678             set clist {
    1679                 "#EE82EE"
    1680                 "#4B0082"
    1681                 "blue"
    1682                 "#008000"
    1683                 "yellow"
    1684                 "#FFA500"
    1685                 "red"
    1686             }
    1687         }
    1688         "BGYOR" {
    1689             set clist {
    1690                 "blue"
    1691                 "#008000"
    1692                 "yellow"
    1693                 "#FFA500"
    1694                 "red"
    1695             }
    1696         }
    1697         "ROYGB" {
    1698             set clist {
    1699                 "red"
    1700                 "#FFA500"
    1701                 "yellow"
    1702                 "#008000"
    1703                 "blue"
    1704             }
    1705         }
    1706         "RYGCB" {
    1707             set clist {
    1708                 "red"
    1709                 "yellow"
    1710                 "green"
    1711                 "cyan"
    1712                 "blue"
    1713             }
    1714         }
    1715         "BCGYR" {
    1716             set clist {
    1717                 "blue"
    1718                 "cyan"
    1719                 "green"
    1720                 "yellow"
    1721                 "red"
    1722             }
    1723         }
    1724         "spectral" {
    1725             return {
    1726                 0.0 0.150 0.300 1.000
    1727                 0.1 0.250 0.630 1.000
    1728                 0.2 0.450 0.850 1.000
    1729                 0.3 0.670 0.970 1.000
    1730                 0.4 0.880 1.000 1.000
    1731                 0.5 1.000 1.000 0.750
    1732                 0.6 1.000 0.880 0.600
    1733                 0.7 1.000 0.680 0.450
    1734                 0.8 0.970 0.430 0.370
    1735                 0.9 0.850 0.150 0.196
    1736                 1.0 0.650 0.000 0.130
    1737             }
    1738         }
    1739         "green-to-magenta" {
    1740             return {
    1741                 0.0 0.000 0.316 0.000
    1742                 0.06666666666666667 0.000 0.526 0.000
    1743                 0.13333333333333333 0.000 0.737 0.000
    1744                 0.2 0.000 0.947 0.000
    1745                 0.26666666666666666 0.316 1.000 0.316
    1746                 0.3333333333333333 0.526 1.000 0.526
    1747                 0.4 0.737 1.000 0.737
    1748                 0.4666666666666667 1.000 1.000 1.000
    1749                 0.5333333333333333 1.000 0.947 1.000
    1750                 0.6 1.000 0.737 1.000
    1751                 0.6666666666666666 1.000 0.526 1.000
    1752                 0.7333333333333333 1.000 0.316 1.000
    1753                 0.8 0.947 0.000 0.947
    1754                 0.8666666666666667 0.737 0.000 0.737
    1755                 0.9333333333333333 0.526 0.000 0.526
    1756                 1.0 0.316 0.000 0.316
    1757             }
    1758         }
    1759         "greyscale" {
    1760             return {
    1761                 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0
    1762             }
    1763         }
    1764         "nanohub" {
    1765             set clist "white yellow green cyan blue magenta"
    1766         }
    1767         default {
    1768             set clist [split $colors :]
    1769         }
     1575        "grey-to-blue" {
     1576            return {
     1577                0.0                      0.200 0.200 0.200
     1578                0.14285714285714285      0.400 0.400 0.400
     1579                0.2857142857142857      0.600 0.600 0.600
     1580                0.42857142857142855      0.900 0.900 0.900
     1581                0.5714285714285714      0.800 1.000 1.000
     1582                0.7142857142857143      0.600 1.000 1.000
     1583                0.8571428571428571      0.400 0.900 1.000
     1584                1.0                      0.000 0.600 0.800
     1585            }
     1586        }
     1587        "blue-to-grey" {
     1588            return {
     1589                0.0                     0.000 0.600 0.800
     1590                0.14285714285714285     0.400 0.900 1.000
     1591                0.2857142857142857      0.600 1.000 1.000
     1592                0.42857142857142855     0.800 1.000 1.000
     1593                0.5714285714285714      0.900 0.900 0.900
     1594                0.7142857142857143      0.600 0.600 0.600
     1595                0.8571428571428571      0.400 0.400 0.400
     1596                1.0                     0.200 0.200 0.200
     1597            }
     1598        }
     1599        "blue" {
     1600            return {
     1601                0.0                     0.900 1.000 1.000
     1602                0.1111111111111111      0.800 0.983 1.000
     1603                0.2222222222222222      0.700 0.950 1.000
     1604                0.3333333333333333      0.600 0.900 1.000
     1605                0.4444444444444444      0.500 0.833 1.000
     1606                0.5555555555555556      0.400 0.750 1.000
     1607                0.6666666666666666      0.300 0.650 1.000
     1608                0.7777777777777778      0.200 0.533 1.000
     1609                0.8888888888888888      0.100 0.400 1.000
     1610                1.0                     0.000 0.250 1.000
     1611            }
     1612        }
     1613        "brown-to-blue" {
     1614            return {
     1615                0.0                             0.200   0.100   0.000
     1616                0.09090909090909091             0.400   0.187   0.000
     1617                0.18181818181818182             0.600   0.379   0.210
     1618                0.2727272727272727              0.800   0.608   0.480
     1619                0.36363636363636365             0.850   0.688   0.595
     1620                0.45454545454545453             0.950   0.855   0.808
     1621                0.5454545454545454              0.800   0.993   1.000
     1622                0.6363636363636364              0.600   0.973   1.000
     1623                0.7272727272727273              0.400   0.940   1.000
     1624                0.8181818181818182              0.200   0.893   1.000
     1625                0.9090909090909091              0.000   0.667   0.800
     1626                1.0                             0.000   0.480   0.600
     1627            }
     1628        }
     1629        "blue-to-brown" {
     1630            return {
     1631                0.0                             0.000   0.480   0.600
     1632                0.09090909090909091             0.000   0.667   0.800
     1633                0.18181818181818182             0.200   0.893   1.000
     1634                0.2727272727272727              0.400   0.940   1.000
     1635                0.36363636363636365             0.600   0.973   1.000
     1636                0.45454545454545453             0.800   0.993   1.000
     1637                0.5454545454545454              0.950   0.855   0.808
     1638                0.6363636363636364              0.850   0.688   0.595
     1639                0.7272727272727273              0.800   0.608   0.480
     1640                0.8181818181818182              0.600   0.379   0.210
     1641                0.9090909090909091              0.400   0.187   0.000
     1642                1.0                             0.200   0.100   0.000
     1643            }
     1644        }
     1645        "blue-to-orange" {
     1646            return {
     1647                0.0                             0.000   0.167   1.000
     1648                0.09090909090909091             0.100   0.400   1.000
     1649                0.18181818181818182             0.200   0.600   1.000
     1650                0.2727272727272727              0.400   0.800   1.000
     1651                0.36363636363636365             0.600   0.933   1.000
     1652                0.45454545454545453             0.800   1.000   1.000
     1653                0.5454545454545454              1.000   1.000   0.800
     1654                0.6363636363636364              1.000   0.933   0.600
     1655                0.7272727272727273              1.000   0.800   0.400
     1656                0.8181818181818182              1.000   0.600   0.200
     1657                0.9090909090909091              1.000   0.400   0.100
     1658                1.0                             1.000   0.167   0.000
     1659            }
     1660        }
     1661        "orange-to-blue" {
     1662            return {
     1663                0.0                             1.000   0.167   0.000
     1664                0.09090909090909091             1.000   0.400   0.100
     1665                0.18181818181818182             1.000   0.600   0.200
     1666                0.2727272727272727              1.000   0.800   0.400
     1667                0.36363636363636365             1.000   0.933   0.600
     1668                0.45454545454545453             1.000   1.000   0.800
     1669                0.5454545454545454              0.800   1.000   1.000
     1670                0.6363636363636364              0.600   0.933   1.000
     1671                0.7272727272727273              0.400   0.800   1.000
     1672                0.8181818181818182              0.200   0.600   1.000
     1673                0.9090909090909091              0.100   0.400   1.000
     1674                1.0                             0.000   0.167   1.000
     1675            }
     1676        }
     1677        "rainbow" {
     1678            set clist {
     1679                "#EE82EE"
     1680                "#4B0082"
     1681                "blue"
     1682                "#008000"
     1683                "yellow"
     1684                "#FFA500"
     1685                "red"
     1686            }
     1687        }
     1688        "BGYOR" {
     1689            set clist {
     1690                "blue"
     1691                "#008000"
     1692                "yellow"
     1693                "#FFA500"
     1694                "red"
     1695            }
     1696        }
     1697        "ROYGB" {
     1698            set clist {
     1699                "red"
     1700                "#FFA500"
     1701                "yellow"
     1702                "#008000"
     1703                "blue"
     1704            }
     1705        }
     1706        "RYGCB" {
     1707            set clist {
     1708                "red"
     1709                "yellow"
     1710                "green"
     1711                "cyan"
     1712                "blue"
     1713            }
     1714        }
     1715        "BCGYR" {
     1716            set clist {
     1717                "blue"
     1718                "cyan"
     1719                "green"
     1720                "yellow"
     1721                "red"
     1722            }
     1723        }
     1724        "spectral" {
     1725            return {
     1726                0.0 0.150 0.300 1.000
     1727                0.1 0.250 0.630 1.000
     1728                0.2 0.450 0.850 1.000
     1729                0.3 0.670 0.970 1.000
     1730                0.4 0.880 1.000 1.000
     1731                0.5 1.000 1.000 0.750
     1732                0.6 1.000 0.880 0.600
     1733                0.7 1.000 0.680 0.450
     1734                0.8 0.970 0.430 0.370
     1735                0.9 0.850 0.150 0.196
     1736                1.0 0.650 0.000 0.130
     1737            }
     1738        }
     1739        "green-to-magenta" {
     1740            return {
     1741                0.0 0.000 0.316 0.000
     1742                0.06666666666666667 0.000 0.526 0.000
     1743                0.13333333333333333 0.000 0.737 0.000
     1744                0.2 0.000 0.947 0.000
     1745                0.26666666666666666 0.316 1.000 0.316
     1746                0.3333333333333333 0.526 1.000 0.526
     1747                0.4 0.737 1.000 0.737
     1748                0.4666666666666667 1.000 1.000 1.000
     1749                0.5333333333333333 1.000 0.947 1.000
     1750                0.6 1.000 0.737 1.000
     1751                0.6666666666666666 1.000 0.526 1.000
     1752                0.7333333333333333 1.000 0.316 1.000
     1753                0.8 0.947 0.000 0.947
     1754                0.8666666666666667 0.737 0.000 0.737
     1755                0.9333333333333333 0.526 0.000 0.526
     1756                1.0 0.316 0.000 0.316
     1757            }
     1758        }
     1759        "greyscale" {
     1760            return {
     1761                0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0
     1762            }
     1763        }
     1764        "nanohub" {
     1765            set clist "white yellow green cyan blue magenta"
     1766        }
     1767        default {
     1768            set clist [split $colors :]
     1769        }
    17701770    }
    17711771    set cmap {}
     
    17751775        append cmap "1.0 [Color2RGB $colors] "
    17761776    } else {
    1777         for {set i 0} {$i < [llength $clist]} {incr i} {
    1778             set x [expr {double($i)/([llength $clist]-1)}]
    1779             set color [lindex $clist $i]
    1780             append cmap "$x [Color2RGB $color] "
    1781         }
     1777        for {set i 0} {$i < [llength $clist]} {incr i} {
     1778            set x [expr {double($i)/([llength $clist]-1)}]
     1779            set color [lindex $clist $i]
     1780            append cmap "$x [Color2RGB $color] "
     1781        }
    17821782    }
    17831783    return $cmap
     
    17911791    set cmap [ColorsToColormap $style(-color)]
    17921792    if { [llength $cmap] == 0 } {
    1793         set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
     1793        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    17941794    }
    17951795    if { ![info exists _settings(volume-opacity)] } {
     
    18281828    array unset _limits $dataobj-*
    18291829    foreach comp [$dataobj components] {
    1830         set tag $dataobj-$comp
    1831         if { ![info exists _limits($tag)] } {
    1832             set data [$dataobj blob $comp]
    1833             set tmpfile file[pid].vtk
    1834             set f [open "$tmpfile" "w"]
    1835             fconfigure $f -translation binary -encoding binary
    1836             puts $f $data
    1837             close $f
    1838             set reader [vtkDataSetReader $tag-xvtkDataSetReader]
    1839             $reader SetFileName $tmpfile
    1840             $reader ReadAllScalarsOn
    1841             $reader ReadAllVectorsOn
    1842             $reader ReadAllFieldsOn
    1843             $reader Update
    1844             set output [$reader GetOutput]
    1845             set _limits($tag) [$output GetBounds]
    1846             set pointData [$output GetPointData]
    1847             puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]"
    1848             puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]"
    1849             puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]"
    1850             set fieldData [$output GetFieldData]
    1851             set pointData [$output GetPointData]
    1852             puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]"
    1853             for { set i 0 } { $i < [$fieldData GetNumberOfArrays] } { incr i } {
    1854                 puts stderr [$fieldData GetArrayName $i]
    1855             }
    1856             puts stderr "point \#arrays=[$pointData GetNumberOfArrays]"
    1857             for { set i 0 } { $i < [$pointData GetNumberOfArrays] } { incr i } {
    1858                 set name [$pointData GetArrayName $i]
    1859                 if { ![info exists _fields($name)] } {
    1860                     $itk_component(field) choices insert end "$name" "$name"
    1861                     set _fields($name) 1
    1862                 }
    1863             }
    1864             puts stderr "field \#components=[$fieldData GetNumberOfComponents]"
    1865             puts stderr "point \#components=[$pointData GetNumberOfComponents]"
    1866             puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]"
    1867             puts stderr "point \#tuples=[$pointData GetNumberOfTuples]"
    1868             puts stderr "point \#scalars=[$pointData GetScalars]"
    1869             puts stderr vectors=[$pointData GetVectors]
    1870             rename $output ""
    1871             rename $reader ""
    1872             file delete $tmpfile
    1873         }
     1830        set tag $dataobj-$comp
     1831        if { ![info exists _limits($tag)] } {
     1832            set data [$dataobj blob $comp]
     1833            set tmpfile file[pid].vtk
     1834            set f [open "$tmpfile" "w"]
     1835            fconfigure $f -translation binary -encoding binary
     1836            puts $f $data
     1837            close $f
     1838            set reader [vtkDataSetReader $tag-xvtkDataSetReader]
     1839            $reader SetFileName $tmpfile
     1840            $reader ReadAllScalarsOn
     1841            $reader ReadAllVectorsOn
     1842            $reader ReadAllFieldsOn
     1843            $reader Update
     1844            set output [$reader GetOutput]
     1845            set _limits($tag) [$output GetBounds]
     1846            set pointData [$output GetPointData]
     1847            puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]"
     1848            puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]"
     1849            puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]"
     1850            set fieldData [$output GetFieldData]
     1851            set pointData [$output GetPointData]
     1852            puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]"
     1853            for { set i 0 } { $i < [$fieldData GetNumberOfArrays] } { incr i } {
     1854                puts stderr [$fieldData GetArrayName $i]
     1855            }
     1856            puts stderr "point \#arrays=[$pointData GetNumberOfArrays]"
     1857            for { set i 0 } { $i < [$pointData GetNumberOfArrays] } { incr i } {
     1858                set name [$pointData GetArrayName $i]
     1859                if { ![info exists _fields($name)] } {
     1860                    $itk_component(field) choices insert end "$name" "$name"
     1861                    set _fields($name) 1
     1862                }
     1863            }
     1864            puts stderr "field \#components=[$fieldData GetNumberOfComponents]"
     1865            puts stderr "point \#components=[$pointData GetNumberOfComponents]"
     1866            puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]"
     1867            puts stderr "point \#tuples=[$pointData GetNumberOfTuples]"
     1868            puts stderr "point \#scalars=[$pointData GetScalars]"
     1869            puts stderr vectors=[$pointData GetVectors]
     1870            rename $output ""
     1871            rename $reader ""
     1872            file delete $tmpfile
     1873        }
    18741874        foreach { xMin xMax yMin yMax zMin zMax} $_limits($tag) break
    1875         if {![info exists limits(xmin)] || $limits(xmin) > $xMin} {
    1876             set limits(xmin) $xMin
    1877         }
    1878         if {![info exists limits(xmax)] || $limits(xmax) < $xMax} {
    1879             set limits(xmax) $xMax
    1880         }
    1881         if {![info exists limits(ymin)] || $limits(ymin) > $yMin} {
    1882             set limits(ymin) $xMin
    1883         }
    1884         if {![info exists limits(ymax)] || $limits(ymax) < $yMax} {
    1885             set limits(ymax) $yMax
    1886         }
    1887         if {![info exists limits(zmin)] || $limits(zmin) > $zMin} {
    1888             set limits(zmin) $zMin
    1889         }
    1890         if {![info exists limits(zmax)] || $limits(zmax) < $zMax} {
    1891             set limits(zmax) $zMax
    1892         }
     1875        if {![info exists limits(xmin)] || $limits(xmin) > $xMin} {
     1876            set limits(xmin) $xMin
     1877        }
     1878        if {![info exists limits(xmax)] || $limits(xmax) < $xMax} {
     1879            set limits(xmax) $xMax
     1880        }
     1881        if {![info exists limits(ymin)] || $limits(ymin) > $yMin} {
     1882            set limits(ymin) $xMin
     1883        }
     1884        if {![info exists limits(ymax)] || $limits(ymax) < $yMax} {
     1885            set limits(ymax) $yMax
     1886        }
     1887        if {![info exists limits(zmin)] || $limits(zmin) > $zMin} {
     1888            set limits(zmin) $zMin
     1889        }
     1890        if {![info exists limits(zmax)] || $limits(zmax) < $zMax} {
     1891            set limits(zmax) $zMax
     1892        }
    18931893    }
    18941894    return [array get limits]
     
    19221922        -width 10 \
    19231923        -showvalue off \
    1924         -command [itcl::code $this AdjustSetting volume-opacity]
     1924        -command [itcl::code $this AdjustSetting volume-opacity]
    19251925
    19261926    label $inner.field_l -text "Field" -font "Arial 9"
    19271927    itk_component add field {
    1928         Rappture::Combobox $inner.field -width 10 -editable no
     1928        Rappture::Combobox $inner.field -width 10 -editable no
    19291929    }
    19301930    bind $inner.field <<Value>> \
    1931         [itcl::code $this AdjustSetting volume-field]
     1931        [itcl::code $this AdjustSetting volume-field]
    19321932
    19331933    label $inner.palette_l -text "Palette" -font "Arial 9"
    19341934    itk_component add palette {
    1935         Rappture::Combobox $inner.palette -width 10 -editable no
     1935        Rappture::Combobox $inner.palette -width 10 -editable no
    19361936    }
    19371937    $inner.palette choices insert end \
    1938         "BCGYR"              "BCGYR"            \
    1939         "BGYOR"              "BGYOR"            \
    1940         "blue"               "blue"             \
    1941         "blue-to-brown"      "blue-to-brown"    \
    1942         "blue-to-orange"     "blue-to-orange"   \
    1943         "blue-to-grey"       "blue-to-grey"     \
    1944         "green-to-magenta"   "green-to-magenta" \
    1945         "greyscale"          "greyscale"        \
    1946         "nanohub"            "nanohub"          \
    1947         "rainbow"            "rainbow"          \
    1948         "spectral"           "spectral"         \
    1949         "ROYGB"              "ROYGB"            \
    1950         "RYGCB"              "RYGCB"            \
    1951         "brown-to-blue"      "brown-to-blue"    \
    1952         "grey-to-blue"       "grey-to-blue"     \
    1953         "orange-to-blue"     "orange-to-blue"   
     1938        "BCGYR"              "BCGYR"            \
     1939        "BGYOR"              "BGYOR"            \
     1940        "blue"               "blue"             \
     1941        "blue-to-brown"      "blue-to-brown"    \
     1942        "blue-to-orange"     "blue-to-orange"   \
     1943        "blue-to-grey"       "blue-to-grey"     \
     1944        "green-to-magenta"   "green-to-magenta" \
     1945        "greyscale"          "greyscale"        \
     1946        "nanohub"            "nanohub"          \
     1947        "rainbow"            "rainbow"          \
     1948        "spectral"           "spectral"         \
     1949        "ROYGB"              "ROYGB"            \
     1950        "RYGCB"              "RYGCB"            \
     1951        "brown-to-blue"      "brown-to-blue"    \
     1952        "grey-to-blue"       "grey-to-blue"     \
     1953        "orange-to-blue"     "orange-to-blue"   
    19541954
    19551955    $itk_component(palette) value "nanohub"
    19561956    bind $inner.palette <<Value>> \
    1957         [itcl::code $this AdjustSetting volume-palette]
     1957        [itcl::code $this AdjustSetting volume-palette]
    19581958
    19591959    blt::table $inner \
     
    20102010
    20112011    itk_component add axismode {
    2012         Rappture::Combobox $inner.mode -width 10 -editable no
     2012        Rappture::Combobox $inner.mode -width 10 -editable no
    20132013    }
    20142014    $inner.mode choices insert end \
     
    20752075    set inner [$itk_component(main) insert end \
    20762076        -title "Cutplane Settings" \
    2077         -icon [Rappture::icon cutbutton]]
     2077        -icon [Rappture::icon cutbutton]]
    20782078
    20792079    $inner configure -borderwidth 4
     
    21082108        -width 10 \
    21092109        -showvalue off \
    2110         -command [itcl::code $this AdjustSetting cutplane-opacity]
     2110        -command [itcl::code $this AdjustSetting cutplane-opacity]
    21112111    $inner.opacity set $_settings(cutplane-opacity)
    21122112
     
    21932193
    21942194    blt::table $inner \
    2195         0,0 $inner.visible              -anchor w -pady 2 -cspan 4 \
    2196         1,0 $inner.lighting             -anchor w -pady 2 -cspan 4 \
    2197         2,0 $inner.wireframe            -anchor w -pady 2 -cspan 4 \
    2198         3,0 $inner.edges                -anchor w -pady 2 -cspan 4 \
    2199         4,0 $inner.opacity_l            -anchor w -pady 2 -cspan 3 \
    2200         5,0 $inner.opacity              -fill x   -pady 2 -cspan 3 \
     2195        0,0 $inner.visible              -anchor w -pady 2 -cspan 4 \
     2196        1,0 $inner.lighting             -anchor w -pady 2 -cspan 4 \
     2197        2,0 $inner.wireframe            -anchor w -pady 2 -cspan 4 \
     2198        3,0 $inner.edges                -anchor w -pady 2 -cspan 4 \
     2199        4,0 $inner.opacity_l            -anchor w -pady 2 -cspan 3 \
     2200        5,0 $inner.opacity              -fill x   -pady 2 -cspan 3 \
    22012201        6,0 $itk_component(xCutButton)  -anchor e -padx 2 -pady 2 \
    22022202        7,0 $itk_component(xCutScale)   -fill y \
     
    22402240                "qx" - "qy" - "qz" - "qw" {
    22412241                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    2242                     $_arcball quaternion $q
    2243                     EventuallyRotate $q
     2242                    $_arcball quaternion $q
     2243                    EventuallyRotate $q
    22442244                }
    22452245                "zoom" {
     
    22752275        foreach comp [$dataobj components] {
    22762276            set tag $dataobj-$comp
    2277             #set contents [ConvertToVtkData $dataobj $comp]
    2278             set contents [$dataobj blob $comp]
    2279             append bytes "$contents\n\n"
     2277            #set contents [ConvertToVtkData $dataobj $comp]
     2278            set contents [$dataobj blob $comp]
     2279            append bytes "$contents\n\n"
    22802280        }
    22812281    }
     
    22852285itcl::body Rappture::VtkVolumeViewer::GetImage { args } {
    22862286    if { [image width $_image(download)] > 0 &&
    2287         [image height $_image(download)] > 0 } {
    2288         set bytes [$_image(download) data -format "jpeg -quality 100"]
    2289         set bytes [Rappture::encoding::decode -as b64 $bytes]
    2290         return [list .jpg $bytes]
     2287        [image height $_image(download)] > 0 } {
     2288        set bytes [$_image(download) data -format "jpeg -quality 100"]
     2289        set bytes [Rappture::encoding::decode -as b64 $bytes]
     2290        return [list .jpg $bytes]
    22912291    }
    22922292    return ""
     
    23102310
    23112311    button $inner.ok -text "Save" \
    2312         -highlightthickness 0 -pady 2 -padx 3 \
     2312        -highlightthickness 0 -pady 2 -padx 3 \
    23132313        -command $command \
    2314         -compound left \
    2315         -image [Rappture::icon download]
     2314        -compound left \
     2315        -image [Rappture::icon download]
    23162316
    23172317    button $inner.cancel -text "Cancel" \
    2318         -highlightthickness 0 -pady 2 -padx 3 \
    2319         -command [list $popup deactivate] \
    2320         -compound left \
    2321         -image [Rappture::icon cancel]
     2318        -highlightthickness 0 -pady 2 -padx 3 \
     2319        -command [list $popup deactivate] \
     2320        -compound left \
     2321        -image [Rappture::icon cancel]
    23222322
    23232323    blt::table $inner \
     
    23392339    set style [$dataobj style $comp]
    23402340    array set settings {
    2341         -color \#808080
    2342         -edges 0
    2343         -edgecolor black
    2344         -linewidth 1.0
    2345         -opacity 0.4
    2346         -wireframe 0
    2347         -lighting 1
    2348         -seeds 1
    2349         -seedcolor white
    2350         -visible 1
     2341        -color \#808080
     2342        -edges 0
     2343        -edgecolor black
     2344        -linewidth 1.0
     2345        -opacity 0.4
     2346        -wireframe 0
     2347        -lighting 1
     2348        -seeds 1
     2349        -seedcolor white
     2350        -visible 1
    23512351    }
    23522352    if { $dataobj != $_first } {
    2353         set settings(-opacity) 1
     2353        set settings(-opacity) 1
    23542354    }
    23552355    array set settings $style
     
    23632363    #SendCmd "cutplane visible $tag"
    23642364    foreach axis { x y z } {
    2365         SendCmd "cutplane slice $axis 1.0 $tag"
    2366         SendCmd "cutplane axis $axis 0 $tag"
     2365        SendCmd "cutplane slice $axis 1.0 $tag"
     2366        SendCmd "cutplane axis $axis 0 $tag"
    23672367    }
    23682368
     
    23742374itcl::body Rappture::VtkVolumeViewer::IsValidObject { dataobj } {
    23752375    if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} {
    2376         return 0
     2376        return 0
    23772377    }
    23782378    return 1
     
    24002400        $_image(legend) configure -data $bytes
    24012401        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    2402         if { [catch {DrawLegend $_title} errs] != 0 } {
    2403             puts stderr errs=$errs
    2404         }
     2402        if { [catch {DrawLegend $_title} errs] != 0 } {
     2403            puts stderr errs=$errs
     2404        }
    24052405    }
    24062406}
     
    24092409# DrawLegend --
    24102410#
    2411 #       Draws the legend in it's own canvas which resides to the right
    2412 #       of the contour plot area.
     2411#       Draws the legend in it's own canvas which resides to the right
     2412#       of the contour plot area.
    24132413#
    24142414itcl::body Rappture::VtkVolumeViewer::DrawLegend { name } {
     
    24202420   
    24212421    if { [info exists _fields($name)] } {
    2422         foreach { title units } $_fields($name) break
    2423         if { $units != "" } {
    2424             set title [format "%s (%s)" $title $units]
    2425         }
     2422        foreach { title units } $_fields($name) break
     2423        if { $units != "" } {
     2424            set title [format "%s (%s)" $title $units]
     2425        }
    24262426    } else {
    2427         set title $name
     2427        set title $name
    24282428    }
    24292429    if { $_settings(legend-visible) } {
    2430         set x [expr $w - 2]
    2431         if { [$c find withtag "legend"] == "" } {
    2432             set y 2
    2433             $c create text $x $y \
    2434                 -anchor ne \
    2435                 -fill $itk_option(-plotforeground) -tags "title legend" \
    2436                 -font $font
    2437             incr y $lineht
    2438             $c create text $x $y \
    2439                 -anchor ne \
    2440                 -fill $itk_option(-plotforeground) -tags "vmax legend" \
    2441                 -font $font
    2442             incr y $lineht
    2443             $c create image $x $y \
    2444                 -anchor ne \
    2445                 -image $_image(legend) -tags "colormap legend"
    2446             $c create text $x [expr {$h-2}] \
    2447                 -anchor se \
    2448                 -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2449                 -font $font
    2450             #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y]
    2451             $c bind colormap <Leave> [itcl::code $this LeaveLegend]
    2452             $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
    2453         }
    2454         $c bind title <ButtonPress> [itcl::code $this Combo post]
    2455         $c bind title <Enter> [itcl::code $this Combo activate]
    2456         $c bind title <Leave> [itcl::code $this Combo deactivate]
    2457         # Reset the item coordinates according the current size of the plot.
    2458         $c itemconfigure title -text $title
    2459         if { $_limits(vmin) != "" } {
    2460             $c itemconfigure vmin -text [format %g $_limits(vmin)]
    2461         }
    2462         if { $_limits(vmax) != "" } {
    2463             $c itemconfigure vmax -text [format %g $_limits(vmax)]
    2464         }
    2465         set y 2
    2466         $c coords title $x $y
    2467         incr y $lineht
    2468         $c coords vmax $x $y
    2469         incr y $lineht
    2470         $c coords colormap $x $y
    2471         $c coords vmin $x [expr {$h - 2}]
     2430        set x [expr $w - 2]
     2431        if { [$c find withtag "legend"] == "" } {
     2432            set y 2
     2433            $c create text $x $y \
     2434                -anchor ne \
     2435                -fill $itk_option(-plotforeground) -tags "title legend" \
     2436                -font $font
     2437            incr y $lineht
     2438            $c create text $x $y \
     2439                -anchor ne \
     2440                -fill $itk_option(-plotforeground) -tags "vmax legend" \
     2441                -font $font
     2442            incr y $lineht
     2443            $c create image $x $y \
     2444                -anchor ne \
     2445                -image $_image(legend) -tags "colormap legend"
     2446            $c create text $x [expr {$h-2}] \
     2447                -anchor se \
     2448                -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2449                -font $font
     2450            #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y]
     2451            $c bind colormap <Leave> [itcl::code $this LeaveLegend]
     2452            $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
     2453        }
     2454        $c bind title <ButtonPress> [itcl::code $this Combo post]
     2455        $c bind title <Enter> [itcl::code $this Combo activate]
     2456        $c bind title <Leave> [itcl::code $this Combo deactivate]
     2457        # Reset the item coordinates according the current size of the plot.
     2458        $c itemconfigure title -text $title
     2459        if { $_limits(vmin) != "" } {
     2460            $c itemconfigure vmin -text [format %g $_limits(vmin)]
     2461        }
     2462        if { $_limits(vmax) != "" } {
     2463            $c itemconfigure vmax -text [format %g $_limits(vmax)]
     2464        }
     2465        set y 2
     2466        $c coords title $x $y
     2467        incr y $lineht
     2468        $c coords vmax $x $y
     2469        incr y $lineht
     2470        $c coords colormap $x $y
     2471        $c coords vmin $x [expr {$h - 2}]
    24722472    }
    24732473}
     
    25132513
    25142514    if { [info exists _fields($_title)] } {
    2515         foreach { title units } $_fields($_title) break
    2516         if { $units != "" } {
    2517             set title [format "%s (%s)" $title $units]
    2518         }
     2515        foreach { title units } $_fields($_title) break
     2516        if { $units != "" } {
     2517            set title [format "%s (%s)" $title $units]
     2518        }
    25192519    } else {
    2520         set title $_title
     2520        set title $_title
    25212521    }
    25222522    # Make a swatch of the selected color
    25232523    if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
    2524         #puts stderr "out of range: $imgY"
    2525         return
     2524        #puts stderr "out of range: $imgY"
     2525        return
    25262526    }
    25272527    if { ![info exists _image(swatch)] } {
    2528         set _image(swatch) [image create photo -width 24 -height 24]
     2528        set _image(swatch) [image create photo -width 24 -height 24]
    25292529    }
    25302530    set color [eval format "\#%02x%02x%02x" $pixel]
     
    25352535    # Compute the value of the point
    25362536    if { [info exists _limits(vmax)] && [info exists _limits(vmin)] } {
    2537         set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
    2538         set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
     2537        set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
     2538        set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
    25392539    } else {
    2540         set value 0.0
     2540        set value 0.0
    25412541    }
    25422542    set tipx [expr $x + 15]
     
    25672567            SendCmd "cutplane slice $axis $newpos"
    25682568        }
    2569         "tooltip" {
    2570             set axis [lindex $args 0]
    2571             set val [$itk_component(${axis}CutScale) get]
    2572             return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
    2573         }
     2569        "tooltip" {
     2570            set axis [lindex $args 0]
     2571            set val [$itk_component(${axis}CutScale) get]
     2572            return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
     2573        }
    25742574        default {
    25752575            error "bad option \"$option\": should be axis, move, or tooltip"
     
    25942594    switch -- $option {
    25952595        post {
    2596             foreach { x1 y1 x2 y2 } [$c bbox title] break
    2597             set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]]
    2598             set x [expr $x1 + [winfo rootx $itk_component(view)]]
    2599             set y [expr $y2 + [winfo rooty $itk_component(view)]]
    2600             puts stderr "combo x=$x y=$y"
    2601             tk_popup $itk_component(fieldmenu) $x $y
     2596            foreach { x1 y1 x2 y2 } [$c bbox title] break
     2597            set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]]
     2598            set x [expr $x1 + [winfo rootx $itk_component(view)]]
     2599            set y [expr $y2 + [winfo rooty $itk_component(view)]]
     2600            puts stderr "combo x=$x y=$y"
     2601            tk_popup $itk_component(fieldmenu) $x $y
    26022602        }
    26032603        activate {
    2604             $c itemconfigure title -fill red
     2604            $c itemconfigure title -fill red
    26052605        }
    26062606        deactivate {
    2607             $c itemconfigure title -fill white
    2608         }
    2609         invoke {
    2610             $itk_component(field) value $_currentField
    2611             AdjustSetting volume-field
    2612         }
     2607            $c itemconfigure title -fill white
     2608        }
     2609        invoke {
     2610            $itk_component(field) value $_currentField
     2611            AdjustSetting volume-field
     2612        }
    26132613        default {
    26142614            error "bad option \"$option\": should be post, unpost, select"
Note: See TracChangeset for help on using the changeset viewer.