Changeset 4848 for branches/1.3/gui


Ignore:
Timestamp:
Dec 11, 2014 2:10:15 PM (9 years ago)
Author:
ldelgass
Message:

revert viewers to 1.3.5 tag versions

Location:
branches/1.3/gui/scripts
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3/gui/scripts/flowvisviewer.tcl

    r4772 r4848  
    6363    public method get {args}
    6464    public method isconnected {}
    65     public method limits { cname }
    66     public method overMarker { m x }
     65    public method limits { tf }
     66    public method overmarker { m x }
    6767    public method parameters {title args} {
    6868        # do nothing
    6969    }
    70     public method removeDuplicateMarker { m x }
     70    public method rmdupmarker { m x }
    7171    public method scale {args}
    72     public method updateTransferFunctions {}
     72    public method updatetransferfuncs {}
     73
     74    protected method Connect {}
     75    protected method CurrentVolumeIds {{what -all}}
     76    protected method Disconnect {}
     77    protected method Resize {}
     78    protected method ResizeLegend {}
     79    protected method AdjustSetting {what {value ""}}
     80    protected method InitSettings { args }
     81    protected method Pan {option x y}
     82    protected method Rebuild {}
     83    protected method ReceiveData { args }
     84    protected method ReceiveImage { args }
     85    protected method ReceiveLegend { tf vmin vmax size }
     86    protected method Rotate {option x y}
     87    protected method SendDataObjs {}
     88    protected method SendTransferFuncs {}
     89    protected method Slice {option args}
     90    protected method SlicerTip {axis}
     91    protected method Zoom {option}
    7392
    7493    # soon to be removed.
    75     private method Flow {option args}
    76     private method Play {}
    77     private method Pause {}
     94    protected method Flow {option args}
     95    protected method Play {}
     96    protected method Pause {}
     97
    7898
    7999    # The following methods are only used by this class.
    80     private method AdjustSetting {what {value ""}}
     100
    81101    private method AddIsoMarker { x y }
    82102    private method BuildCameraTab {}
    83103    private method BuildCutplanesTab {}
    84104    private method BuildViewTab {}
    85     private method BuildVolumeComponents {}
    86105    private method BuildVolumeTab {}
    87106    private method ComputeTransferFunc { tf }
    88     private method Connect {}
    89     private method CurrentVolumeIds {{what -all}}
    90     private method Disconnect {}
    91107    private method EventuallyResize { w h }
    92108    private method EventuallyGoto { nSteps }
    93109    private method EventuallyResizeLegend { }
    94110    private method FlowCmd { dataobj comp nbytes extents }
    95     private method GetDatasetsWithComponent { cname }
    96     private method GetFlowInfo { widget }
    97111    private method GetMovie { widget width height }
    98112    private method GetPngImage { widget width height }
    99     private method InitSettings { args }
    100113    private method NameTransferFunc { dataobj comp }
    101     private method Pan {option x y}
    102114    private method PanCamera {}
    103115    private method ParseLevelsOption { tf levels }
    104116    private method ParseMarkersOption { tf markers }
    105     private method QuaternionToView { q } {
    106         foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    107     }
    108     private method Rebuild {}
    109     private method ReceiveData { args }
    110     private method ReceiveImage { args }
    111     private method ReceiveLegend { tf vmin vmax size }
    112     private method Resize {}
    113     private method ResizeLegend {}
    114     private method Rotate {option x y}
    115     private method SendTransferFuncs {}
     117    private method WaitIcon { option widget }
     118    private method str2millisecs { value }
     119    private method millisecs2str { value }
     120    private method GetFlowInfo { widget }
     121    private method particles { tag name }
     122    private method box { tag name }
     123    private method streams { tag name }
     124    private method arrows { tag name }
    116125    private method SetOrientation { side }
    117     private method Slice {option args}
    118     private method SlicerTip {axis}
    119     private method ViewToQuaternion {} {
    120         return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    121     }
    122     private method WaitIcon { option widget }
    123     private method Zoom {option}
    124     private method arrows { tag name }
    125     private method box { tag name }
    126     private method millisecs2str { value }
    127     private method particles { tag name }
    128     private method str2millisecs { value }
    129     private method streams { tag name }
    130126
    131127    private variable _arcball ""
     
    135131    private variable _serverObjs   ;# maps dataobj-component to volume ID
    136132                                    # in the server
     133    private variable _sendobjs ""  ;# list of data objs to send to server
    137134    private variable _recvObjs  ;# list of data objs to send to server
    138135    private variable _obj2style    ;# maps dataobj-component to transfunc
     
    149146    private variable _activeTf ""  ;# The currently active transfer function.
    150147    private variable _first ""     ;# This is the topmost volume.
    151     private variable _volcomponents   ; # Array of components found
    152     private variable _componentsList   ; # Array of components found
    153148    private variable _nextToken 0
    154149    private variable _icon 0
     
    183178    $_dispatcher dispatch $this !legend "[itcl::code $this ResizeLegend]; list"
    184179
     180    # Send dataobjs event
     181    $_dispatcher register !send_dataobjs
     182    $_dispatcher dispatch $this !send_dataobjs \
     183        "[itcl::code $this SendDataObjs]; list"
     184
    185185    # Send transferfunctions event
    186186    $_dispatcher register !send_transfunc
     
    220220    # Initialize the view to some default parameters.
    221221    array set _view {
    222         -qw      0.853553
    223         -qx      -0.353553
    224         -qy      0.353553
    225         -qz      0.146447
    226         -xpan    0
    227         -ypan    0
    228         -zoom    1.0
     222        qw      0.853553
     223        qx      -0.353553
     224        qy      0.353553
     225        qz      0.146447
     226        zoom    1.0
     227        xpan    0
     228        ypan    0
    229229    }
    230230    set _arcball [blt::arcball create 100 100]
    231     $_arcball quaternion [ViewToQuaternion]
    232 
    233     set _limits(v) [list 0.0 1.0]
     231    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     232    $_arcball quaternion $q
     233
     234    set _limits(vmin) 0.0
     235    set _limits(vmax) 1.0
    234236    set _reset 1
    235237
    236238    array set _settings [subst {
    237         $this-qw                $_view(-qw)
    238         $this-qx                $_view(-qx)
    239         $this-qy                $_view(-qy)
    240         $this-qz                $_view(-qz)
    241         $this-zoom              $_view(-zoom)   
    242         $this-xpan              $_view(-xpan)
    243         $this-ypan              $_view(-ypan)
     239        $this-qw                $_view(qw)
     240        $this-qx                $_view(qx)
     241        $this-qy                $_view(qy)
     242        $this-qz                $_view(qz)
     243        $this-zoom              $_view(zoom)   
     244        $this-xpan              $_view(xpan)
     245        $this-ypan              $_view(ypan)
    244246        $this-arrows            0
    245247        $this-currenttime       0
     
    251253        $this-streams           0
    252254        $this-volume            1
    253         $this-light             40
    254         $this-light2side        1
    255         $this-opacity           50
    256         $this-thickness         350
    257255        $this-xcutplane         0
    258256        $this-xcutposition      0
     
    337335    set _image(legend) [image create photo]
    338336    itk_component add legend {
    339         canvas $itk_component(plotarea).legend -height 50 -highlightthickness 0
     337        canvas $itk_component(plotarea).legend \
     338            -height 50 -highlightthickness 0 -background black
    340339    } {
    341340        usual
     
    561560# ----------------------------------------------------------------------
    562561itcl::body Rappture::FlowvisViewer::destructor {} {
     562    set _sendobjs ""  ;# stop any send in progress
    563563    $_dispatcher cancel !rebuild
     564    $_dispatcher cancel !send_dataobjs
    564565    $_dispatcher cancel !send_transfunc
    565566    image delete $_image(plot)
     
    671672# ----------------------------------------------------------------------
    672673itcl::body Rappture::FlowvisViewer::delete {args} {
    673     flow stop
     674     flow stop
    674675    if {[llength $args] == 0} {
    675676        set args $_dlist
     
    721722# ----------------------------------------------------------------------
    722723itcl::body Rappture::FlowvisViewer::scale {args} {
    723     array set styles {
    724         -color BCGYR
    725         -levels 6
    726         -markers ""
    727         -opacity 0.5
    728     }
    729     array unset _limits
    730     array unset _volcomponents
    731     foreach dataobj $args {
    732         if { ![$dataobj isvalid] } {
    733             continue;                     # Object doesn't contain valid data.
    734         }
    735         foreach cname [$dataobj components] {
    736             if { ![info exists _volcomponents($cname)] } {
    737                 lappend _componentsList $cname
    738                 array set styles [lindex [$dataobj components -style $cname] 0]
    739                 set cmap [ColorsToColormap $styles(-color)]
    740                 set _cname2defaultcolormap($cname) $cmap
    741                 set _settings($cname-colormap) $styles(-color)
    742             }
    743             lappend _volcomponents($cname) $dataobj-$cname
    744             array unset limits
    745             array set limits [$dataobj valueLimits $cname]
    746             set _limits($cname) $limits(v)
    747         }
    748         foreach axis {x y z v} {
    749             foreach { min max } [$dataobj limits $axis] break
     724    foreach val {xmin xmax ymin ymax vmin vmax} {
     725        set _limits($val) ""
     726    }
     727    foreach obj $args {
     728        foreach axis {x y v} {
     729
     730            foreach { min max } [$obj limits $axis] break
     731
    750732            if {"" != $min && "" != $max} {
    751                 if { ![info exists _limits($axis)] } {
    752                     set _limits($axis) [list $min $max]
     733                if {"" == $_limits(${axis}min)} {
     734                    set _limits(${axis}min) $min
     735                    set _limits(${axis}max) $max
    753736                } else {
    754                     foreach {amin amax} $_limits($axis) break
    755                     if {$min < $amin} {
    756                         set amin $min
     737                    if {$min < $_limits(${axis}min)} {
     738                        set _limits(${axis}min) $min
    757739                    }
    758                     if {$max > $amax} {
    759                         set amax $max
     740                    if {$max > $_limits(${axis}max)} {
     741                        set _limits(${axis}max) $max
    760742                    }
    761                     set _limits($axis) [list $amin $amax]
    762743                }
    763744            }
    764745        }
    765746    }
    766     #BuildVolumeComponents
    767747}
    768748
     
    877857        if { $_reportClientInfo }  {
    878858            # Tell the server the viewer, hub, user and session.
    879             # Do this immediately on connect before buffering any commands
     859            # Do this immediately on connect before buffing any commands
    880860            global env
    881861
     
    934914    # disconnected -- no more data sitting on server
    935915    array unset _serverObjs
     916    set _sendobjs ""
     917}
     918
     919# ----------------------------------------------------------------------
     920# USAGE: SendDataObjs
     921#
     922# Used internally to send a series of volume objects off to the
     923# server.  Sends each object, a little at a time, with updates in
     924# between so the interface doesn't lock up.
     925# ----------------------------------------------------------------------
     926itcl::body Rappture::FlowvisViewer::SendDataObjs {} {
     927    blt::busy hold $itk_component(hull)
     928    foreach dataobj $_sendobjs {
     929        foreach comp [$dataobj components] {
     930            # Send the data as one huge base64-encoded mess -- yuck!
     931            set data [$dataobj blob $comp]
     932            set nbytes [string length $data]
     933            set extents [$dataobj extents $comp]
     934
     935            # I have a field. Is a vector field or a volume field?
     936            if { $extents == 1 } {
     937                set cmd "volume data follows $nbytes $dataobj-$comp\n"
     938            } else {
     939                set cmd [FlowCmd $dataobj $comp $nbytes $extents]
     940                if { $cmd == "" } {
     941                    puts stderr "no command"
     942                    continue
     943                }
     944            }
     945            f { ![SendBytes $cmd] } {
     946                puts stderr "can't send"
     947                return
     948            }
     949            if { ![SendBytes $data] } {
     950                puts stderr "can't send"
     951                return
     952            }
     953            NameTransferFunc $dataobj $comp
     954            set _recvObjs($dataobj-$comp) 1
     955        }
     956    }
     957    set _sendobjs ""
     958    blt::busy release $itk_component(hull)
     959
     960    # Turn on buffering of commands to the server.  We don't want to
     961    # be preempted by a server disconnect/reconnect (which automatically
     962    # generates a new call to Rebuild).   
     963    StartBufferingCommands
     964
     965    # activate the proper volume
     966    set _first [lindex [get] 0]
     967    if { "" != $_first } {
     968        set axis [$_first hints updir]
     969        if {"" != $axis} {
     970            SendCmd "up $axis"
     971        }
     972
     973        if 0 {
     974        set location [$_first hints camera]
     975        if { $location != "" } {
     976            array set _view $location
     977        }
     978        set _settings($this-qw)    $_view(qw)
     979        set _settings($this-qx)    $_view(qx)
     980        set _settings($this-qy)    $_view(qy)
     981        set _settings($this-qz)    $_view(qz)
     982        set _settings($this-xpan)  $_view(xpan)
     983        set _settings($this-ypan)  $_view(ypan)
     984        set _settings($this-zoom)  $_view(zoom)
     985        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     986        $_arcball quaternion $q
     987        SendCmd "camera orient $q"
     988        SendCmd "camera reset"
     989        PanCamera
     990        SendCmd "camera zoom $_view(zoom)"
     991        }
     992        # The active transfer function is by default the first component of
     993        # the first data object.  This assumes that the data is always
     994        # successfully transferred.
     995        set comp [lindex [$_first components] 0]
     996        set _activeTf [lindex $_obj2style($_first-$comp) 0]
     997    }
     998
     999    SendCmd "flow reset"
     1000    StopBufferingCommands
    9361001}
    9371002
     
    9501015    }
    9511016
    952     # Ensure that the global thickness setting (in the slider settings widget)
    953     # is used for the active transfer-function. Update the values in the
    954     # _settings varible.
    955 
     1017    # Ensure that the global opacity and thickness settings (in the slider
     1018    # settings widgets) are used for the active transfer-function.  Update the
     1019    # values in the _settings varible.
     1020    set value $_settings($this-opacity)
     1021    set opacity [expr { double($value) * 0.01 }]
     1022    set _settings($this-$tf-opacity) $opacity
    9561023    set value $_settings($this-thickness)
    9571024    # Scale values between 0.00001 and 0.01000
     
    10301097    set h [winfo height $c]
    10311098    set lx 10
     1099    # FIXME:  I don't know what I have to do this for the 2D flow
     1100    #         example.  Otherwise the canvas background is white.
     1101    #         I'll get to this when we add background changes into
     1102    #         nanvis.
     1103    $c configure -background black
    10321104    set ly [expr {$h - 1}]
    1033     if {"" == [$c find withtag colorbar]} {
     1105    if {"" == [$c find withtag transfunc]} {
    10341106        $c create image 10 10 -anchor nw \
    1035             -image $_image(legend) -tags colorbar
     1107            -image $_image(legend) -tags transfunc
    10361108        $c create text $lx $ly -anchor sw \
    10371109            -fill $itk_option(-plotforeground) -tags "limits vmin"
    10381110        $c create text [expr {$w-$lx}] $ly -anchor se \
    10391111            -fill $itk_option(-plotforeground) -tags "limits vmax"
    1040         $c lower colorbar
    1041         $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y]
     1112        $c lower transfunc
     1113        $c bind transfunc <ButtonRelease-1> \
     1114            [itcl::code $this AddIsoMarker %x %y]
    10421115    }
    10431116    # Display the markers used by the active transfer function.
    10441117    set tf $_obj2style($tag)
    1045     foreach {vmin vmax} [limits $tf] break
    1046     $c itemconfigure vmin -text [format %g $vmin]
     1118    array set limits [limits $tf]
     1119    $c itemconfigure vmin -text [format %.2g $limits(vmin)]
    10471120    $c coords vmin $lx $ly
    10481121
    1049     $c itemconfigure vmax -text [format %g $vmax]
     1122    $c itemconfigure vmax -text [format %.2g $limits(vmax)]
    10501123    $c coords vmax [expr {$w-$lx}] $ly
    10511124
     
    10871160    set dataobj [lindex $parts 0]
    10881161    set _serverObjs($tag) 0
    1089     set _limits($tag) [list $values(min) $values(max)]
     1162    set _limits($tag-min)  $values(min);  # Minimum value of the volume.
     1163    set _limits($tag-max)  $values(max);  # Maximum value of the volume.
    10901164    unset _recvObjs($tag)
    10911165    if { [array size _recvObjs] == 0 } {
    1092         updateTransferFunctions
     1166        updatetransferfuncs
    10931167    }
    10941168}
     
    11341208        foreach comp [$dataobj components] {
    11351209            set tag $dataobj-$comp
    1136             set isvtk 0
    1137             # FIXME: Would like to use the type method of the dataobj
    1138             # but the returned value isn't well defined now
    1139             if {[catch {
    1140                 # Send the data as one huge base64-encoded mess -- yuck!
    1141                 set data [$dataobj blob $comp]
    1142             }]} {
    1143                 set data [$dataobj vtkdata $comp]
    1144                 set isvtk 1
    1145             }
     1210            # Send the data as one huge base64-encoded mess -- yuck!
     1211            set data [$dataobj blob $comp]
    11461212            set nbytes [string length $data]
    11471213            if { $_reportClientInfo }  {
     
    11591225            set extents [$dataobj extents $comp]
    11601226            # I have a field. Is a vector field or a volume field?
    1161             if { !$isvtk && $extents == 1 } {
    1162                 SendCmd "volume data follows $nbytes $tag"
     1227            if { $extents == 1 } {
     1228                set cmd "volume data follows $nbytes $tag\n"
    11631229            } else {
    11641230                set cmd [FlowCmd $dataobj $comp $nbytes $extents]
     
    11671233                    continue
    11681234                }
    1169                 append _outbuf $cmd
    1170             }
     1235            }
     1236            append _outbuf $cmd
    11711237            append _outbuf $data
    11721238            NameTransferFunc $dataobj $comp
     
    11781244
    11791245    # Reset the camera and other view parameters
    1180     InitSettings light2side light opacity isosurface grid axes volume outline
    1181 
     1246    InitSettings light2side light transp isosurface grid axes volume outline
     1247   
    11821248    # nothing to send -- activate the proper volume
    11831249    if {"" != $_first} {
     1250        AdjustSetting light
     1251        AdjustSetting transp
    11841252        set axis [$_first hints updir]
    11851253        if {"" != $axis} {
     
    11921260
    11931261    }
    1194     set _settings($this-qw)    $_view(-qw)
    1195     set _settings($this-qx)    $_view(-qx)
    1196     set _settings($this-qy)    $_view(-qy)
    1197     set _settings($this-qz)    $_view(-qz)
    1198     set _settings($this-xpan)  $_view(-xpan)
    1199     set _settings($this-ypan)  $_view(-ypan)
    1200     set _settings($this-zoom)  $_view(-zoom)
    1201 
    1202     set q [ViewToQuaternion]
     1262    set _settings($this-qw)    $_view(qw)
     1263    set _settings($this-qx)    $_view(qx)
     1264    set _settings($this-qy)    $_view(qy)
     1265    set _settings($this-qz)    $_view(qz)
     1266    set _settings($this-xpan)  $_view(xpan)
     1267    set _settings($this-ypan)  $_view(ypan)
     1268    set _settings($this-zoom)  $_view(zoom)
     1269
     1270    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    12031271    $_arcball quaternion $q
    12041272    SendCmd "camera orient $q"
    12051273    SendCmd "camera reset"
    12061274    PanCamera
    1207     SendCmd "camera zoom $_view(-zoom)"
     1275    SendCmd "camera zoom $_view(zoom)"
    12081276
    12091277    foreach dataobj [get] {
     
    12611329    foreach key [array names _serverObjs *-*] {
    12621330        if {[string match $_first-* $key]} {
    1263             array set styles {
     1331            array set style {
    12641332                -cutplanes 1
    12651333            }
    12661334            foreach {dataobj comp} [split $key -] break
    1267             array set styles [lindex [$dataobj components -style $comp] 0]
    1268             if {$what != "-cutplanes" || $styles(-cutplanes)} {
     1335            array set style [lindex [$dataobj components -style $comp] 0]
     1336            if {$what != "-cutplanes" || $style(-cutplanes)} {
    12691337                lappend rlist $_serverObjs($key)
    12701338            }
     
    12851353    switch -- $option {
    12861354        "in" {
    1287             set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1288             set _settings($this-zoom) $_view(-zoom)
    1289             SendCmd "camera zoom $_view(-zoom)"
     1355            set _view(zoom) [expr {$_view(zoom)*1.25}]
     1356            set _settings($this-zoom) $_view(zoom)
     1357            SendCmd "camera zoom $_view(zoom)"
    12901358        }
    12911359        "out" {
    1292             set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1293             set _settings($this-zoom) $_view(-zoom)
    1294             SendCmd "camera zoom $_view(-zoom)"
     1360            set _view(zoom) [expr {$_view(zoom)*0.8}]
     1361            set _settings($this-zoom) $_view(zoom)
     1362            SendCmd "camera zoom $_view(zoom)"
    12951363        }
    12961364        "reset" {
    12971365            array set _view {
    1298                 -qw      0.853553
    1299                 -qx      -0.353553
    1300                 -qy      0.353553
    1301                 -qz      0.146447
    1302                 -zoom    1.0
    1303                 -xpan    0
    1304                 -ypan    0
     1366                qw      0.853553
     1367                qx      -0.353553
     1368                qy      0.353553
     1369                qz      0.146447
     1370                zoom    1.0
     1371                xpan   0
     1372                ypan   0
    13051373            }
    13061374            if { $_first != "" } {
     
    13101378                }
    13111379            }
    1312             set q [ViewToQuaternion]
     1380            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    13131381            $_arcball quaternion $q
    13141382            SendCmd "camera orient $q"
    13151383            SendCmd "camera reset"
    1316             set _settings($this-qw)    $_view(-qw)
    1317             set _settings($this-qx)    $_view(-qx)
    1318             set _settings($this-qy)    $_view(-qy)
    1319             set _settings($this-qz)    $_view(-qz)
    1320             set _settings($this-xpan)  $_view(-xpan)
    1321             set _settings($this-ypan)  $_view(-ypan)
    1322             set _settings($this-zoom)  $_view(-zoom)
     1384            set _settings($this-qw)    $_view(qw)
     1385            set _settings($this-qx)    $_view(qx)
     1386            set _settings($this-qy)    $_view(qy)
     1387            set _settings($this-qz)    $_view(qz)
     1388            set _settings($this-xpan)  $_view(xpan)
     1389            set _settings($this-ypan)  $_view(ypan)
     1390            set _settings($this-zoom)  $_view(zoom)
    13231391        }
    13241392    }
     
    13261394
    13271395itcl::body Rappture::FlowvisViewer::PanCamera {} {
    1328     set x $_view(-xpan)
    1329     set y $_view(-ypan)
     1396    #set x [expr ($_view(xpan)) / $_limits(xrange)]
     1397    #set y [expr ($_view(ypan)) / $_limits(yrange)]
     1398    set x $_view(xpan)
     1399    set y $_view(ypan)
    13301400    SendCmd "camera pan $x $y"
    13311401}
     
    13651435
    13661436                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
    1367                 QuaternionToView $q
    1368                 set _settings($this-qw) $_view(-qw)
    1369                 set _settings($this-qx) $_view(-qx)
    1370                 set _settings($this-qy) $_view(-qy)
    1371                 set _settings($this-qz) $_view(-qz)
     1437                foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     1438                set _settings($this-qw) $_view(qw)
     1439                set _settings($this-qx) $_view(qx)
     1440                set _settings($this-qy) $_view(qy)
     1441                set _settings($this-qz) $_view(qz)
    13721442                SendCmd "camera orient $q"
    13731443
     
    14021472        set x [expr $x / double($w)]
    14031473        set y [expr $y / double($h)]
    1404         set _view(-xpan) [expr $_view(-xpan) + $x]
    1405         set _view(-ypan) [expr $_view(-ypan) + $y]
     1474        set _view(xpan) [expr $_view(xpan) + $x]
     1475        set _view(ypan) [expr $_view(ypan) + $y]
    14061476        PanCamera
    1407         set _settings($this-xpan) $_view(-xpan)
    1408         set _settings($this-ypan) $_view(-ypan)
     1477        set _settings($this-xpan) $_view(xpan)
     1478        set _settings($this-ypan) $_view(ypan)
    14091479        return
    14101480    }
     
    14191489        set _click(x) $x
    14201490        set _click(y) $y
    1421         set _view(-xpan) [expr $_view(-xpan) - $dx]
    1422         set _view(-ypan) [expr $_view(-ypan) - $dy]
     1491        set _view(xpan) [expr $_view(xpan) - $dx]
     1492        set _view(ypan) [expr $_view(ypan) - $dy]
    14231493        PanCamera
    1424         set _settings($this-xpan) $_view(-xpan)
    1425         set _settings($this-ypan) $_view(-ypan)
     1494        set _settings($this-xpan) $_view(xpan)
     1495        set _settings($this-ypan) $_view(ypan)
    14261496    }
    14271497    if { $option == "release" } {
     
    15761646            }
    15771647        }
    1578         opacity {
     1648        transp {
    15791649            if { $_first != "" } {
    15801650                set comp [lindex [$_first components] 0]
    15811651                set tag $_first-$comp
     1652                set opacity [expr { 0.01 * double($_settings($this-transp)) }]
     1653                SendCmd "$tag configure -opacity $opacity"
     1654            }
     1655        }
     1656        opacity {
     1657            if { $_first != "" && $_activeTf != "" } {
    15821658                set opacity [expr { 0.01 * double($_settings($this-opacity)) }]
    1583                 SendCmd "$tag configure -opacity $opacity"
    1584             }
    1585         }
     1659                set tf $_activeTf
     1660                set _settings($this-$tf-opacity) $opacity
     1661                updatetransferfuncs
     1662            }
     1663        }
     1664
    15861665        thickness {
    15871666            if { $_first != "" && $_activeTf != "" } {
     
    15911670                set tf $_activeTf
    15921671                set _settings($this-$tf-thickness) $sval
    1593                 updateTransferFunctions
     1672                updatetransferfuncs
    15941673            }
    15951674        }
     
    16991778#              now.
    17001779#
    1701 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj cname } {
    1702     array set styles {
     1780itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj comp } {
     1781    array set style {
    17031782        -color BCGYR
    17041783        -levels 6
    1705         -opacity 0.5
    1706     }
    1707     array set styles [lindex [$dataobj components -style $cname] 0]
    1708     set _settings($this-opacity) [expr $styles(-opacity) * 100]
    1709     set _obj2style($dataobj-$cname) $cname
    1710     lappend _style2objs($cname) $dataobj $cname
    1711     return $cname
     1784        -opacity 1.0
     1785        -light 40
     1786        -transp 50
     1787    }
     1788    array set style [lindex [$dataobj components -style $comp] 0]
     1789    set _settings($this-light) $style(-light)
     1790    set _settings($this-transp) $style(-transp)
     1791    set _settings($this-opacity) [expr $style(-opacity) * 100]
     1792    set tf "$style(-color):$style(-levels):$style(-opacity)"
     1793    set _obj2style($dataobj-$comp) $tf
     1794    lappend _style2objs($tf) $dataobj $comp
     1795    return $tf
    17121796}
    17131797
     
    17221806#
    17231807itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } {
    1724     array set styles {
     1808    array set style {
    17251809        -color BCGYR
    17261810        -levels 6
    1727         -opacity 0.5
     1811        -opacity 1.0
     1812        -light 40
     1813        -transp 50
    17281814    }
    17291815    set dataobj ""; set comp ""
     
    17321818        return 0
    17331819    }
    1734     array set styles [lindex [$dataobj components -style $comp] 0]
     1820    array set style [lindex [$dataobj components -style $comp] 0]
     1821
    17351822
    17361823    # We have to parse the style attributes for a volume using this
     
    17491836    if { ![info exists _isomarkers($tf)] } {
    17501837        # Have to defer creation of isomarkers until we have data limits
    1751         if { [info exists styles(-markers)] &&
    1752              [llength $styles(-markers)] > 0  } {
    1753             ParseMarkersOption $tf $styles(-markers)
     1838        if { [info exists style(-markers)] &&
     1839             [llength $style(-markers)] > 0  } {
     1840            ParseMarkersOption $tf $style(-markers)
    17541841        } else {
    1755             ParseLevelsOption $tf $styles(-levels)
    1756         }
    1757     }
    1758     if { [info exists styles(-nonuniformcolors)] } {
    1759         foreach { value color } $styles(-nonuniformcolors) {
     1842            ParseLevelsOption $tf $style(-levels)
     1843        }
     1844    }
     1845    if { [info exists style(-nonuniformcolors)] } {
     1846        foreach { value color } $style(-nonuniformcolors) {
    17601847            append cmap "$value [Color2RGB $color] "
    17611848        }
    17621849    } else {
    1763         set cmap [ColorsToColormap $styles(-color)]
    1764     }
    1765 
    1766     if { ![info exists _settings($this-opacity)] } {
    1767         set _settings($this-opacity) [expr $styles(-opacity) * 100]
    1768     }
    1769 
    1770     # Transfer function should be normalized with [0,1] range
    1771     # The volume shading opacity setting is used to scale opacity
    1772     # in the volume shader.
    1773     set max 1.0
    1774 
     1850        set cmap [ColorsToColormap $style(-color)]
     1851    }
     1852    set tag $this-$tf
     1853    if { ![info exists _settings($tag-opacity)] } {
     1854        set _settings($tag-opacity) $style(-opacity)
     1855    }
     1856    set max 1.0 ;#$_settings($tag-opacity)
     1857   
    17751858    set isovalues {}
    17761859    foreach m $_isomarkers($tf) {
     
    17801863    set isovalues [lsort -real $isovalues]
    17811864
    1782     set tag $this-$tf
    17831865    if { ![info exists _settings($tag-thickness)]} {
    17841866        set _settings($tag-thickness) 0.005
     
    18351917itcl::configbody Rappture::FlowvisViewer::plotbackground {
    18361918    if { [isconnected] } {
    1837         set color $itk_option(-plotbackground)
    1838         set rgb [Color2RGB $color]
    1839         SendCmd "screen bgcolor $rgb"
    1840         $itk_component(legend) configure -background $color
     1919        foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
     1920        #fix this!
     1921        #SendCmd "color background $r $g $b"
    18411922    }
    18421923}
     
    18471928itcl::configbody Rappture::FlowvisViewer::plotforeground {
    18481929    if { [isconnected] } {
    1849         set color $itk_option(-plotforeground)
    1850         set rgb [Color2RGB $color]
    1851         SendCmd "volume outline color $rgb"
    1852         SendCmd "grid axiscolor $rgb"
    1853         SendCmd "grid linecolor $rgb"
    1854         $itk_component(legend) itemconfigure labels -fill $color
    1855         $itk_component(legend) itemconfigure limits -fill $color
     1930        foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
     1931        #fix this!
     1932        #SendCmd "color background $r $g $b"
    18561933    }
    18571934}
     
    18871964            set x [expr {double($i)/($levels+1)}]
    18881965            set m [Rappture::IsoMarker \#auto $c $this $tf]
    1889             $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
    18901966            $m relval $x
    18911967            lappend _isomarkers($tf) $m
     
    18941970        foreach x $levels {
    18951971            set m [Rappture::IsoMarker \#auto $c $this $tf]
    1896             $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
    18971972            $m relval $x
    18981973            lappend _isomarkers($tf) $m
     
    19221997            set value [expr {$value * 0.01}]
    19231998            set m [Rappture::IsoMarker \#auto $c $this $tf]
    1924             $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
    19251999            $m relval $value
    19262000            lappend _isomarkers($tf) $m
     
    19282002            # ${n} : Set absolute value.
    19292003            set m [Rappture::IsoMarker \#auto $c $this $tf]
    1930             $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
    19312004            $m absval $value
    19322005            lappend _isomarkers($tf) $m
     
    19382011# USAGE: UndateTransferFuncs
    19392012# ----------------------------------------------------------------------
    1940 itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} {
     2013itcl::body Rappture::FlowvisViewer::updatetransferfuncs {} {
    19412014    $_dispatcher event -after 100 !send_transfunc
    19422015}
     
    19492022    set c $itk_component(legend)
    19502023    set m [Rappture::IsoMarker \#auto $c $this $tf]
    1951     $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
    19522024    set w [winfo width $c]
    19532025    $m relval [expr {double($x-10)/($w-20)}]
    19542026    lappend _isomarkers($tf) $m
    1955     updateTransferFunctions
     2027    updatetransferfuncs
    19562028    return 1
    19572029}
    19582030
    1959 itcl::body Rappture::FlowvisViewer::removeDuplicateMarker { marker x } {
     2031itcl::body Rappture::FlowvisViewer::rmdupmarker { marker x } {
    19602032    set tf [$marker transferfunc]
    19612033    set bool 0
     
    19772049        }
    19782050        set _isomarkers($tf) $list
    1979         updateTransferFunctions
     2051        updatetransferfuncs
    19802052    }
    19812053    return $bool
    19822054}
    19832055
    1984 itcl::body Rappture::FlowvisViewer::overMarker { marker x } {
     2056itcl::body Rappture::FlowvisViewer::overmarker { marker x } {
    19852057    set tf [$marker transferfunc]
    19862058    if { [info exists _isomarkers($tf)] } {
     
    19972069}
    19982070
    1999 itcl::body Rappture::FlowvisViewer::limits { cname } {
    2000     set _limits(v) [list 0.0 1.0]
    2001     if { ![info exists _style2objs($cname)] } {
    2002         puts stderr "no style2objs for $cname cname=($cname)"
     2071itcl::body Rappture::FlowvisViewer::limits { tf } {
     2072    set _limits(vmin) 0.0
     2073    set _limits(vmax) 1.0
     2074    if { ![info exists _style2objs($tf)] } {
     2075        puts stderr "no style2objs for $tf tf=($tf)"
    20032076        return [array get _limits]
    20042077    }
    20052078    set min ""; set max ""
    2006     foreach tag [GetDatasetsWithComponent $cname] {
     2079    foreach {dataobj comp} $_style2objs($tf) {
     2080        set tag $dataobj-$comp
    20072081        if { ![info exists _serverObjs($tag)] } {
    20082082            puts stderr "$tag not in serverObjs?"
    20092083            continue
    20102084        }
    2011         if { ![info exists _limits($tag)] } {
     2085        if { ![info exists _limits($tag-min)] } {
    20122086            puts stderr "$tag no min?"
    20132087            continue
    20142088        }
    2015         foreach {vmin vmax} $_limits($tag) break
    2016         if { $min == "" || $min > $vmin } {
    2017             set min $vmin
    2018         }
    2019         if { $max == "" || $max < $vmax } {
    2020             set max $vmax
    2021         }
    2022     }
    2023     if { $min != "" && $max != "" } {
    2024         set _limits(v) [list $min $max]
    2025         set _limits($cname) [list $min $max]
    2026     }
    2027     return $_limits($cname)
     2089        if { $min == "" || $min > $_limits($tag-min) } {
     2090            set min $_limits($tag-min)
     2091        }
     2092        if { $max == "" || $max < $_limits($tag-max) } {
     2093            set max $_limits($tag-max)
     2094        }
     2095    }
     2096    if { $min != "" } {
     2097        set _limits(vmin) $min
     2098    }
     2099    if { $max != "" } {
     2100        set _limits(vmax) $max
     2101    }
     2102    return [array get _limits]
    20282103}
    20292104
     
    21142189
    21152190itcl::body Rappture::FlowvisViewer::BuildVolumeTab {} {
     2191    foreach { key value } {
     2192        light2side      1
     2193        light           40
     2194        transp          50
     2195        opacity         100
     2196        thickness       350
     2197    } {
     2198        set _settings($this-$key) $value
     2199    }
     2200
    21162201    set inner [$itk_component(main) insert end \
    21172202        -title "Volume Settings" \
     
    21412226    label $inner.bright -text "Surface" -font $fg
    21422227
     2228    label $inner.fog -text "Clear" -font $fg
     2229    ::scale $inner.transp -from 0 -to 100 -orient horizontal \
     2230        -variable [itcl::scope _settings($this-transp)] \
     2231        -width 10 \
     2232        -showvalue off -command [itcl::code $this AdjustSetting transp]
     2233    label $inner.plastic -text "Opaque" -font $fg
     2234
    21432235    label $inner.clear -text "Clear" -font $fg
    21442236    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
     
    21602252    }
    21612253
    2162     $inner.colormap choices insert end [GetColormapList -includeNone]
     2254    $inner.colormap choices insert end \
     2255        "BCGYR"              "BCGYR"            \
     2256        "BGYOR"              "BGYOR"            \
     2257        "blue"               "blue"             \
     2258        "blue-to-brown"      "blue-to-brown"    \
     2259        "blue-to-orange"     "blue-to-orange"   \
     2260        "blue-to-grey"       "blue-to-grey"     \
     2261        "green-to-magenta"   "green-to-magenta" \
     2262        "greyscale"          "greyscale"        \
     2263        "nanohub"            "nanohub"          \
     2264        "rainbow"            "rainbow"          \
     2265        "spectral"           "spectral"         \
     2266        "ROYGB"              "ROYGB"            \
     2267        "RYGCB"              "RYGCB"            \
     2268        "brown-to-blue"      "brown-to-blue"    \
     2269        "grey-to-blue"       "grey-to-blue"     \
     2270        "orange-to-blue"     "orange-to-blue"   \
     2271        "none"               "none"
     2272
    21632273    $itk_component(colormap) value "BCGYR"
    21642274    bind $inner.colormap <<Value>> \
     
    21722282        3,1 $inner.light -cspan 2 -pady 2 -fill x \
    21732283        3,3 $inner.bright -anchor w -pady 2 \
    2174         4,0 $inner.clear -anchor e -pady 2 \
    2175         4,1 $inner.opacity -cspan 2 -pady 2 -fill x \
    2176         4,3 $inner.opaque -anchor w -pady 2 \
     2284        4,0 $inner.fog -anchor e -pady 2 \
     2285        4,1 $inner.transp -cspan 2 -pady 2 -fill x \
     2286        4,3 $inner.plastic -anchor w -pady 2 \
    21772287        5,0 $inner.thin -anchor e -pady 2 \
    21782288        5,1 $inner.thickness -cspan 2 -pady 2 -fill x\
     
    23022412        0,0 $inner.view_l -anchor e -pady 2 \
    23032413        0,1 $inner.view -anchor w -pady 2
    2304     blt::table configure $inner r0 -resize none
    23052414
    23062415    set row 1
     
    23102419        entry $inner.${tag} -font "Arial 9"  -bg white \
    23112420            -textvariable [itcl::scope _settings($this-$tag)]
    2312         bind $inner.${tag} <Return> \
    2313             [itcl::code $this camera set -${tag}]
    2314         bind $inner.${tag} <KP_Enter> \
    2315             [itcl::code $this camera set -${tag}]
     2421        bind $inner.${tag} <KeyPress-Return> \
     2422            [itcl::code $this camera set ${tag}]
    23162423        blt::table $inner \
    23172424            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    23212428    }
    23222429
    2323     blt::table configure $inner c* -resize none
     2430    blt::table configure $inner c* r* -resize none
    23242431    blt::table configure $inner c2 -resize expand
    23252432    blt::table configure $inner r$row -resize expand
     
    24742581itcl::body Rappture::FlowvisViewer::SlicerTip {axis} {
    24752582    set val [$itk_component(${axis}CutScale) get]
     2583#    set val [expr {0.01*($val-50)
     2584#        *($_limits(${axis}max)-$_limits(${axis}min))
     2585#          + 0.5*($_limits(${axis}max)+$_limits(${axis}min))}]
    24762586    return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
    24772587}
     
    25152625        }
    25162626        "set" {
    2517             set what [lindex $args 0]
    2518             set x $_settings(${this}${what})
     2627            set who [lindex $args 0]
     2628            set x $_settings($this-$who)
    25192629            set code [catch { string is double $x } result]
    25202630            if { $code != 0 || !$result } {
    2521                 set _settings(${this}${what}) $_view($what)
     2631                set _settings($this-$who) $_view($who)
    25222632                return
    25232633            }
    2524             switch -- $what {
    2525                 "-xpan" - "-ypan" {
    2526                     set _view($what) $_settings(${this}${what})
     2634            switch -- $who {
     2635                "xpan" - "ypan" {
     2636                    set _view($who) $_settings($this-$who)
    25272637                    PanCamera
    25282638                }
    2529                 "-qx" - "-qy" - "-qz" - "-qw" {
    2530                     set _view($what) $_settings(${this}${what})
    2531                     set q [ViewToQuaternion]
     2639                "qx" - "qy" - "qz" - "qw" {
     2640                    set _view($who) $_settings($this-$who)
     2641                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    25322642                    $_arcball quaternion $q
    25332643                    SendCmd "camera orient $q"
    25342644                }
    2535                 "-zoom" {
    2536                     set _view($what) $_settings(${this}${what})
    2537                     SendCmd "camera zoom $_view($what)"
     2645                "zoom" {
     2646                    set _view($who) $_settings($this-$who)
     2647                    SendCmd "camera zoom $_view(zoom)"
    25382648                }
    25392649            }
     
    29133023        bottom "0.707107 0.707107 0 0"
    29143024    }
    2915     foreach name { -qw -qx -qy -qz } value $positions($side) {
     3025    foreach name { qw qx qy qz } value $positions($side) {
    29163026        set _view($name) $value
    29173027    }
    2918     set q [ViewToQuaternion]
     3028    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    29193029    $_arcball quaternion $q
    29203030    SendCmd "camera orient $q"
    29213031    SendCmd "camera reset"
    2922     set _view(-xpan) 0.0
    2923     set _view(-ypan) 0.0
    2924     set _view(-zoom) 1.0
    2925     set _settings($this-xpan) $_view(-xpan)
    2926     set _settings($this-ypan) $_view(-ypan)
    2927     set _settings($this-zoom) $_view(-zoom)
    2928 }
    2929 
    2930 # Reset global settings from dataset's settings.
    2931 itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} {
    2932     $itk_component(volcomponents) choices delete 0 end
    2933     foreach name $_componentsList {
    2934         $itk_component(volcomponents) choices insert end $name $name
    2935     }
    2936     set _current [lindex $_componentsList 0]
    2937     $itk_component(volcomponents) value $_current
    2938 }
    2939 
    2940 # Reset global settings from dataset's settings.
    2941 itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } {
    2942     if { ![info exists _volcomponents($cname)] } {
    2943         return ""
    2944     }
    2945     set list ""
    2946     foreach tag $_volcomponents($cname) {
    2947         if { ![info exists _serverObjs($tag)] } {
    2948             continue
    2949         }
    2950         lappend list $tag
    2951     }
    2952     return $list
    2953 }
     3032    set _view(xpan) 0.0
     3033    set _view(ypan) 0.0
     3034    set _view(zoom) 1.0
     3035    set _settings($this-xpan) $_view(xpan)
     3036    set _settings($this-ypan) $_view(ypan)
     3037    set _settings($this-zoom) $_view(zoom)
     3038}
  • branches/1.3/gui/scripts/isomarker.tcl

    r4546 r4848  
    3030    private common   _normalIcon [Rappture::icon nvlegendmark]
    3131    private common   _activeIcon [Rappture::icon nvlegendmark2]
    32     private method EnterTick {}
    33     private method LeaveTick {}
    34     private method StartDrag { x y }
    35     private method ContinueDrag { x y }
    36     private method StopDrag { x y }
    3732
    38     constructor {c obj tf args} {}
    39     destructor {}
    40     public method transferfunc {}
    41     public method activate { bool }
    42     public method visible { bool }
    43     public method screenpos {}
    44     public method absval { {x "-get"} }
    45     public method relval  { {x "-get"} }
    46 }
    47 
    48 itcl::body Rappture::IsoMarker::constructor {c obj tf args} {
    49     set _canvas $c
    50     set _nvobj $obj
    51     set _tf $tf
    52     set w [winfo width $_canvas]
    53     set h [winfo height $_canvas]
    54     set _tick [$c create image 0 $h \
    55                    -image $_normalIcon -anchor s \
    56                    -tags "tick $this $obj" -state hidden]
    57     set _label [$c create text 0 $h \
    58                     -anchor n -fill white -font "Helvetica 8" \
    59                     -tags "labels $this $obj" -state hidden]
    60     $c bind $_tick <Enter>           [itcl::code $this EnterTick]
    61     $c bind $_tick <Leave>           [itcl::code $this LeaveTick]
    62     $c bind $_tick <ButtonPress-1>   [itcl::code $this StartDrag %x %y]
    63     $c bind $_tick <B1-Motion>       [itcl::code $this ContinueDrag %x %y]
    64     $c bind $_tick <ButtonRelease-1> [itcl::code $this StopDrag %x %y]
    65 }
    66 
    67 itcl::body Rappture::IsoMarker::destructor {} {
    68     $_canvas delete $this
    69 }
    70 
    71 itcl::body Rappture::IsoMarker::transferfunc {} {
    72     return $_tf
    73 }
    74 
    75 itcl::body Rappture::IsoMarker::activate { bool } {
    76     if  { $bool || $_activePress || $_activeMotion } {
    77         $_canvas itemconfigure $_label -state normal
    78         $_canvas itemconfigure $_tick -image $_activeIcon
    79         $_canvas itemconfigure title -state hidden
    80     } else {
    81         $_canvas itemconfigure $_label -state hidden
    82         $_canvas itemconfigure $_tick -image $_normalIcon
    83         $_canvas itemconfigure title -state normal
     33    constructor {c obj tf args} {
     34        set _canvas $c
     35        set _nvobj $obj
     36        set _tf $tf
     37        set w [winfo width $_canvas]
     38        set h [winfo height $_canvas]
     39        set _tick [$c create image 0 $h \
     40                -image $_normalIcon -anchor s \
     41                -tags "$this $obj" -state hidden]
     42        set _label [$c create text 0 $h \
     43                -anchor n -fill white -font "Helvetica 8" \
     44                -tags "$this $obj" -state hidden]
     45        $c bind $_tick <Enter> [itcl::code $this HandleEvent "enter"]
     46        $c bind $_tick <Leave> [itcl::code $this HandleEvent "leave"]
     47        $c bind $_tick <ButtonPress-1> \
     48            [itcl::code $this HandleEvent "start" %x %y]
     49        $c bind $_tick <B1-Motion> \
     50            [itcl::code $this HandleEvent "update" %x %y]
     51        $c bind $_tick <ButtonRelease-1> \
     52            [itcl::code $this HandleEvent "end" %x %y]
     53    }
     54    destructor {
     55        $_canvas delete $this
     56    }
     57    public method transferfunc {} {
     58        return $_tf
     59    }
     60    public method activate { bool } {
     61        if  { $bool || $_activePress || $_activeMotion } {
     62            $_canvas itemconfigure $_label -state normal
     63            $_canvas itemconfigure $_tick -image $_activeIcon
     64        } else {
     65            $_canvas itemconfigure $_label -state hidden
     66            $_canvas itemconfigure $_tick -image $_normalIcon
     67        }
     68    }
     69    public method visible { bool } {
     70        if { $bool } {
     71            absval $_value
     72            $_canvas itemconfigure $_tick -state normal
     73            $_canvas raise $_tick
     74        } else {
     75            $_canvas itemconfigure $_tick -state hidden
     76        }
     77    }
     78    public method screenpos { } {
     79        set x [relval]
     80        if { $x < 0.0 } {
     81            set x 0.0
     82        } elseif { $x > 1.0 } {
     83            set x 1.0
     84        }
     85        set low 10
     86        set w [winfo width $_canvas]
     87        set high [expr {$w  - 10}]
     88        set x [expr {round($x*($high - $low) + $low)}]
     89        return $x
     90    }
     91    public method absval { {x "-get"} } {
     92        if { $x != "-get" } {
     93            set _value $x
     94            set y 31
     95            $_canvas itemconfigure $_label -text [format %.2g $_value]
     96            set x [screenpos]
     97            $_canvas coords $_tick $x [expr {$y+3}]
     98            $_canvas coords $_label $x [expr {$y+5}]
     99        }
     100        return $_value
     101    }
     102    public method relval  { {x "-get"} } {
     103        if { $x == "-get" } {
     104            array set limits [$_nvobj limits $_tf]
     105            if { $limits(vmax) == $limits(vmin) } {
     106                if { $limits(vmax) == 0.0 } {
     107                    set limits(vmin) 0.0
     108                    set limits(vmax) 1.0
     109                } else {
     110                    set limits(vmax) [expr $limits(vmin) + 1.0]
     111                }
     112            }
     113            return [expr {($_value-$limits(vmin))/
     114                          ($limits(vmax) - $limits(vmin))}]
     115        }
     116        array set limits [$_nvobj limits $_tf]
     117        if { $limits(vmax) == $limits(vmin) } {
     118            set limits(vmin) 0.0
     119            set limits(vmax) 1.0
     120        }
     121        if { [catch {expr $limits(vmax) - $limits(vmin)} r] != 0 } {
     122            return 0.0
     123        }           
     124        absval [expr {($x * $r) + $limits(vmin)}]
     125    }
     126    private method HandleEvent { option args } {
     127        switch -- $option {
     128            enter {
     129                set _activeMotion 1
     130                activate yes
     131                $_canvas raise $_tick
     132            }
     133            leave {
     134                set _activeMotion 0
     135                activate no
     136            }
     137            start {
     138                $_canvas raise $_tick
     139                set _activePress 1
     140                activate yes
     141                $_canvas itemconfigure limits -state hidden
     142            }
     143            update {
     144                set w [winfo width $_canvas]
     145                set x [lindex $args 0]
     146                relval [expr {double($x-10)/($w-20)}]
     147                $_nvobj overmarker $this $x
     148                $_nvobj updatetransferfuncs
     149            }
     150            end {
     151                set x [lindex $args 0]
     152                if { ![$_nvobj rmdupmarker $this $x]} {
     153                    eval HandleEvent update $args
     154                }
     155                set _activePress 0
     156                activate no
     157                $_canvas itemconfigure limits -state normal
     158            }
     159            default {
     160                error "bad option \"$option\": should be start, update, end"
     161            }
     162        }
    84163    }
    85164}
    86 
    87 itcl::body Rappture::IsoMarker::visible { bool } {
    88     if { $bool } {
    89         absval $_value
    90         $_canvas itemconfigure $_tick -state normal
    91         $_canvas raise $_tick
    92     } else {
    93         $_canvas itemconfigure $_tick -state hidden
    94     }
    95 }
    96 
    97 itcl::body Rappture::IsoMarker::screenpos { } {
    98     set x [relval]
    99     if { $x < 0.0 } {
    100         set x 0.0
    101     } elseif { $x > 1.0 } {
    102         set x 1.0
    103     }
    104     set low 10
    105     set w [winfo width $_canvas]
    106     set high [expr {$w  - 10}]
    107     set x [expr {round($x*($high - $low) + $low)}]
    108     return $x
    109 }
    110 
    111 itcl::body Rappture::IsoMarker::absval { {x "-get"} } {
    112     if { $x != "-get" } {
    113         set _value $x
    114         set y 31
    115         $_canvas itemconfigure $_label -text [format %g $_value]
    116         set x [screenpos]
    117         $_canvas coords $_tick $x [expr {$y+3}]
    118         $_canvas coords $_label $x [expr {$y+5}]
    119     }
    120     return $_value
    121 }
    122 
    123 itcl::body Rappture::IsoMarker::relval  { {x "-get"} } {
    124     foreach {min max} [$_nvobj limits $_tf] break
    125     if { $x == "-get" } {
    126         if { $max == $min } {
    127             if { $max == 0.0 } {
    128                 set min 0.0
    129                 set max 1.0
    130             } else {
    131                 set max [expr $min + 1.0]
    132             }
    133         }
    134         return [expr {($_value - $min) / ($max - $min)}]
    135     }
    136     if { $max == $min } {
    137         set min 0.0
    138         set max 1.0
    139     }
    140     if { [catch {expr $max - $min} r] != 0 } {
    141         return 0.0
    142     }           
    143     absval [expr {($x * $r) + $min}]
    144 }
    145 
    146 itcl::body Rappture::IsoMarker::EnterTick {} {
    147     set _activeMotion 1
    148     activate yes
    149     $_canvas raise $_tick
    150 }
    151 
    152 itcl::body Rappture::IsoMarker::LeaveTick {} {
    153     set _activeMotion 0
    154     activate no
    155 }
    156 
    157 itcl::body Rappture::IsoMarker::StartDrag { x y } {
    158     $_canvas raise $_tick
    159     set _activePress 1
    160     activate yes
    161     $_canvas itemconfigure limits -state hidden
    162     $_canvas itemconfigure title -state hidden
    163 }
    164 
    165 itcl::body Rappture::IsoMarker::StopDrag { x y } {
    166     if { ![$_nvobj removeDuplicateMarker $this $x]} {
    167         ContinueDrag $x $y
    168     }
    169     set _activePress 0
    170     activate no
    171     $_canvas itemconfigure limits -state normal
    172     $_canvas itemconfigure title -state normal
    173 }
    174 
    175 itcl::body Rappture::IsoMarker::ContinueDrag { x y } {
    176     set w [winfo width $_canvas]
    177     relval [expr {double($x-10)/($w-20)}]
    178     $_nvobj overMarker $this $x
    179     $_nvobj updateTransferFunctions
    180     $_canvas raise $_tick
    181     set _activePress 1
    182     activate yes
    183     $_canvas itemconfigure limits -state hidden
    184     $_canvas itemconfigure title -state hidden
    185 }
    186 
  • branches/1.3/gui/scripts/nanovisviewer.tcl

    r4772 r4848  
    11# -*- mode: tcl; indent-tabs-mode: nil -*-
     2
    23# ----------------------------------------------------------------------
    34#  COMPONENT: nanovisviewer - 3D volume rendering
     
    7576    public method isconnected {}
    7677    public method limits { tf }
     78    public method overmarker { m x }
    7779    public method parameters {title args} {
    7880        # do nothing
    7981    }
     82    public method rmdupmarker { m x }
    8083    public method scale {args}
    81     public method updateTransferFunctions {}
     84    public method updatetransferfuncs {}
     85
     86    protected method Connect {}
     87    protected method CurrentDatasets {{what -all}}
     88    protected method Disconnect {}
     89    protected method DoResize {}
     90    protected method FixLegend {}
     91    protected method AdjustSetting {what {value ""}}
     92    protected method InitSettings { args }
     93    protected method Pan {option x y}
     94    protected method Rebuild {}
     95    protected method ReceiveData { args }
     96    protected method ReceiveImage { args }
     97    protected method ReceiveLegend { tf vmin vmax size }
     98    protected method Rotate {option x y}
     99    protected method SendTransferFuncs {}
     100    protected method Slice {option args}
     101    protected method SlicerTip {axis}
     102    protected method Zoom {option}
    82103
    83104    # The following methods are only used by this class.
    84 
    85     private method AddNewMarker { x y }
    86     private method AdjustSetting {what {value ""}}
     105    private method AddIsoMarker { x y }
    87106    private method BuildCameraTab {}
    88107    private method BuildCutplanesTab {}
    89108    private method BuildViewTab {}
    90     private method BuildVolumeComponents {}
    91109    private method BuildVolumeTab {}
    92     private method ComputeAlphamap { cname }
    93     private method ComputeTransferFunction { cname }
    94     private method Connect {}
    95     private method CurrentDatasets {{what -all}}
    96     private method Disconnect {}
    97     private method DoResize {}
    98     private method DrawLegend { cname }
    99     private method EventuallyRedrawLegend { }
     110    private method ResetColormap { color }
     111    private method ComputeTransferFunc { tf }
    100112    private method EventuallyResize { w h }
    101     private method FixLegend {}
    102     private method GetAlphamap { cname color }
    103     private method GetColormap { cname color }
    104     private method GetDatasetsWithComponent { cname }
     113    private method EventuallyResizeLegend { }
     114    private method NameTransferFunc { dataobj comp }
     115    private method PanCamera {}
     116    private method ParseLevelsOption { tf levels }
     117    private method ParseMarkersOption { tf markers }
     118    private method volume { tag name }
    105119    private method GetVolumeInfo { w }
    106     private method HideAllMarkers {}
    107     private method InitComponentSettings { cname }
    108     private method InitSettings { args }
    109     private method NameToAlphamap { name }
    110     private method NameTransferFunction { dataobj comp }
    111     private method Pan {option x y}
    112     private method PanCamera {}
    113     private method ParseLevelsOption { cname levels }
    114     private method ParseMarkersOption { cname markers }
    115     private method QuaternionToView { q } {
    116         foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    117     }
    118     private method Rebuild {}
    119     private method ReceiveData { args }
    120     private method ReceiveImage { args }
    121     private method ReceiveLegend { tf vmin vmax size }
    122     private method RemoveMarker { x y }
    123     private method ResetColormap { cname color }
    124     private method Rotate {option x y}
    125     private method SendTransferFunctions {}
    126     private method SetObjectStyle { dataobj cname }
    127120    private method SetOrientation { side }
    128     private method Slice {option args}
    129     private method SlicerTip {axis}
    130     private method SwitchComponent { cname }
    131     private method ToggleVolume { tag name }
    132     private method ViewToQuaternion {} {
    133         return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    134     }
    135     private method Zoom {option}
    136121
    137122    private variable _arcball ""
    138123
    139124    private variable _dlist ""     ;# list of data objects
     125    private variable _allDataObjs
    140126    private variable _obj2ovride   ;# maps dataobj => style override
    141127    private variable _serverDatasets   ;# contains all the dataobj-component
    142128                                   ;# to volumes in the server
    143     private variable _recvdDatasets;    # list of data objs to send to server
    144     private variable _dataset2style;    # maps dataobj-component to transfunc
    145     private variable _style2datasets;   # maps tf back to list of
    146                                         # dataobj-components using the tf.
    147 
    148     private variable _reset 1;          # Connection to server has been reset.
    149     private variable _click;            # Info used for rotate operations.
    150     private variable _limits;           # Autoscale min/max for all axes
    151     private variable _view;             # View params for 3D view
    152     private variable _parsedFunction
    153     private variable _transferFunctionEditors
    154     private variable _settings
    155     private variable _widget
    156 
    157     private variable _first "" ;        # This is the topmost volume.
    158     private variable _current "";       # Currently selected component
    159     private variable _volcomponents   ; # Array of components found
    160     private variable _componentsList   ; # Array of components found
    161     private variable _cname2style
    162     private variable _cname2transferFunction
    163     private variable _cname2defaultcolormap
    164     private variable _cname2defaultalphamap
    165 
     129    private variable _serverTfs    ;# contains all the transfer functions
     130                                   ;# in the server.
     131    private variable _recvdDatasets    ;# list of data objs to send to server
     132    private variable _dataset2style    ;# maps dataobj-component to transfunc
     133    private variable _style2datasets   ;# maps tf back to list of
     134                                    # dataobj-components using the tf.
     135
     136    private variable _reset 1;          # Connection to server has been reset
     137    private variable _click        ;# info used for rotate operations
     138    private variable _limits       ;# autoscale min/max for all axes
     139    private variable _view         ;# view params for 3D view
     140    private variable _isomarkers    ;# array of isosurface level values 0..1
     141    private variable  _settings
     142    # Array of transfer functions in server.  If 0 the transfer has been
     143    # defined but not loaded.  If 1 the transfer function has been named
     144    # and loaded.
     145    private variable _activeTfs
     146    private variable _first ""     ;# This is the topmost volume.
     147
     148    # This
     149    # indicates which isomarkers and transfer
     150    # function to use when changing markers,
     151    # opacity, or thickness.
    166152    common _downloadPopup          ;# download options from popup
    167153    private common _hardcopy
     
    190176    $_dispatcher register !send_transfunc
    191177    $_dispatcher dispatch $this !send_transfunc \
    192         "[itcl::code $this SendTransferFunctions]; list"
     178        "[itcl::code $this SendTransferFuncs]; list"
    193179
    194180    # Rebuild event
     
    209195    # Initialize the view to some default parameters.
    210196    array set _view {
    211         -qw      0.853553
    212         -qx      -0.353553
    213         -qy      0.353553
    214         -qz      0.146447
    215         -xpan    0
    216         -ypan    0
    217         -zoom    1.0
     197        qw      0.853553
     198        qx      -0.353553
     199        qy      0.353553
     200        qz      0.146447
     201        zoom    1.0
     202        xpan    0
     203        ypan    0
    218204    }
    219205    set _arcball [blt::arcball create 100 100]
    220     $_arcball quaternion [ViewToQuaternion]
    221 
    222     set _limits(v) [list 0.0 1.0]
     206    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     207    $_arcball quaternion $q
     208
     209    set _limits(vmin) 0.0
     210    set _limits(vmax) 1.0
    223211    set _reset 1
    224212
    225     array set _settings {
    226         -axesvisible            1
    227         -background             black
    228         -colormap               "default"
    229         -cutplanesvisible       0
    230         -gridvisible            0
    231         -isosurfaceshading      0
    232         -legendvisible          1
    233         -light                  40
    234         -light2side             1
    235         -outlinevisible         0
    236         -qw                     0.853553
    237         -qx                     -0.353553
    238         -qy                     0.353553
    239         -qz                     0.146447
    240         -thickness              350
    241         -volume                 1
    242         -volumeopacity          0.5
    243         -volumevisible          1
    244         -xcutplaneposition      50
    245         -xcutplanevisible       1
    246         -xpan                   0
    247         -ycutplaneposition      50
    248         -ycutplanevisible       1
    249         -ypan                   0
    250         -zcutplaneposition      50
    251         -zcutplanevisible       1
    252         -zoom                   1.0
    253     }
    254     array set _widget {
    255         -volumeopacity          50
    256     }
     213    array set _settings [subst {
     214        $this-qw                $_view(qw)
     215        $this-qx                $_view(qx)
     216        $this-qy                $_view(qy)
     217        $this-qz                $_view(qz)
     218        $this-zoom              $_view(zoom)   
     219        $this-xpan              $_view(xpan)
     220        $this-ypan              $_view(ypan)
     221        $this-volume            1
     222        $this-xcutplane         0
     223        $this-xcutposition      0
     224        $this-ycutplane         0
     225        $this-ycutposition      0
     226        $this-zcutplane         0
     227        $this-zcutposition      0
     228    }]
     229
    257230    itk_component add 3dview {
    258231        label $itk_component(plotarea).view -image $_image(plot) \
     
    275248    }
    276249    pack $itk_component(reset) -side top -padx 2 -pady 2
    277     Rappture::Tooltip::for $itk_component(reset) \
    278         "Reset the view to the default zoom level"
     250    Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
    279251
    280252    itk_component add zoomin {
     
    306278            -onimage [Rappture::icon volume-on] \
    307279            -offimage [Rappture::icon volume-off] \
    308             -command [itcl::code $this AdjustSetting -volume] \
    309             -variable [itcl::scope _settings(-volume)]
     280            -command [itcl::code $this AdjustSetting volume] \
     281            -variable [itcl::scope _settings($this-volume)]
    310282    }
    311283    $itk_component(volume) select
     
    313285        "Toggle the volume cloud on/off"
    314286    pack $itk_component(volume) -padx 2 -pady 2
    315 
    316     itk_component add cutplane {
    317         Rappture::PushButton $f.cutplane \
    318             -onimage [Rappture::icon cutbutton] \
    319             -offimage [Rappture::icon cutbutton] \
    320             -variable [itcl::scope _settings(-cutplanesvisible)] \
    321             -command [itcl::code $this AdjustSetting -cutplanesvisible]
    322     }
    323     Rappture::Tooltip::for $itk_component(cutplane) \
    324         "Show/Hide cutplanes"
    325     pack $itk_component(cutplane) -padx 2 -pady 2
    326287
    327288    if { [catch {
     
    336297
    337298    # Legend
     299
    338300    set _image(legend) [image create photo]
    339301    itk_component add legend {
     
    345307    }
    346308    bind $itk_component(legend) <Configure> \
    347         [itcl::code $this EventuallyRedrawLegend]
    348     bind $itk_component(legend) <KeyPress-Delete> \
    349         [itcl::code $this RemoveMarker %x %y]
    350     bind $itk_component(legend) <Enter> \
    351         [list focus $itk_component(legend)]
     309        [itcl::code $this EventuallyResizeLegend]
    352310
    353311    # Hack around the Tk panewindow.  The problem is that the requested
     
    428386    image delete $_image(legend)
    429387    image delete $_image(download)
    430     foreach name [array names _transferFunctionEditors] {
    431         itcl::delete object $_transferFunctionEditors($cname)
    432     }
    433388    catch { blt::arcball destroy $_arcball }
    434     array unset _settings
     389    array unset _settings $this-*
    435390}
    436391
     
    464419    if {$pos < 0} {
    465420        lappend _dlist $dataobj
     421        set _allDataObjs($dataobj) 1
    466422        set _obj2ovride($dataobj-color) $params(-color)
    467423        set _obj2ovride($dataobj-width) $params(-width)
     
    540496        if { $pos >= 0 } {
    541497            set _dlist [lreplace $_dlist $pos $pos]
     498            array unset _limits $dataobj*
    542499            array unset _obj2ovride $dataobj-*
    543             array unset _dataset2style $dataobj-*
    544500            set changed 1
    545501        }
     
    561517# ----------------------------------------------------------------------
    562518itcl::body Rappture::NanovisViewer::scale {args} {
    563     array set styles {
    564         -color    BCGYR
    565         -levels   6
    566         -markers  ""
    567     }
    568     array unset _limits
    569     array unset _volcomponents
     519    foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} {
     520        set _limits($val) ""
     521    }
    570522    foreach dataobj $args {
    571523        if { ![$dataobj isvalid] } {
    572524            continue;                     # Object doesn't contain valid data.
    573525        }
    574         foreach cname [$dataobj components] {
    575             if { ![info exists _volcomponents($cname)] } {
    576                 lappend _componentsList $cname
    577                 array set styles [lindex [$dataobj components -style $cname] 0]
    578                 set cmap [ColorsToColormap $styles(-color)]
    579                 set _cname2defaultcolormap($cname) $cmap
    580                 set _settings($cname-colormap) $styles(-color)
    581             }
    582             lappend _volcomponents($cname) $dataobj-$cname
    583             array unset limits
    584             array set limits [$dataobj valueLimits $cname]
    585             set _limits($cname) $limits(v)
    586         }
    587526        foreach axis {x y z v} {
    588527            foreach { min max } [$dataobj limits $axis] break
    589528            if {"" != $min && "" != $max} {
    590                 if { ![info exists _limits($axis)] } {
    591                     set _limits($axis) [list $min $max]
     529                if {"" == $_limits(${axis}min)} {
     530                    set _limits(${axis}min) $min
     531                    set _limits(${axis}max) $max
    592532                } else {
    593                     foreach {amin amax} $_limits($axis) break
    594                     if {$min < $amin} {
    595                         set amin $min
     533                    if {$min < $_limits(${axis}min)} {
     534                        set _limits(${axis}min) $min
    596535                    }
    597                     if {$max > $amax} {
    598                         set amax $max
     536                    if {$max > $_limits(${axis}max)} {
     537                        set _limits(${axis}max) $max
    599538                    }
    600                     set _limits($axis) [list $amin $amax]
    601539                }
    602540            }
    603541        }
    604542    }
    605     BuildVolumeComponents
    606543}
    607544
     
    666603        if { $_reportClientInfo }  {
    667604            # Tell the server the viewer, hub, user and session.
    668             # Do this immediately on connect before buffering any commands
     605            # Do this immediately on connect before buffing any commands
    669606            global env
    670607
     
    726663
    727664# ----------------------------------------------------------------------
    728 # USAGE: SendTransferFunctions
    729 # ----------------------------------------------------------------------
    730 itcl::body Rappture::NanovisViewer::SendTransferFunctions {} {
    731     foreach cname [array names _volcomponents] {
    732         ComputeTransferFunction $cname
     665# USAGE: SendTransferFuncs
     666# ----------------------------------------------------------------------
     667itcl::body Rappture::NanovisViewer::SendTransferFuncs {} {
     668    if { $_first == "" } {
     669        puts stderr "first not set"
     670        return
     671    }
     672    # Ensure that the global opacity and thickness settings (in the slider
     673    # settings widgets) are used for the active transfer-function.  Update
     674    # the values in the _settings varible.
     675    set opacity [expr { double($_settings($this-opacity)) * 0.01 }]
     676    # Scale values between 0.00001 and 0.01000
     677    set thickness [expr {double($_settings($this-thickness)) * 0.0001}]
     678
     679    foreach tag [CurrentDatasets] {
     680        if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } {
     681            # The volume hasn't reached the server yet.  How did we get
     682            # here?
     683            puts stderr "Don't have $tag in _serverDatasets"
     684            continue
     685        }
     686        if { ![info exists _dataset2style($tag)] } {
     687            puts stderr "don't have style for volume $tag"
     688            continue;                        # How does this happen?
     689        }
     690        set tf $_dataset2style($tag)
     691        set _settings($this-$tf-opacity) $opacity
     692        set _settings($this-$tf-thickness) $thickness
     693        ComputeTransferFunc $tf
     694        # FIXME: Need to the send information as to what transfer functions
     695        #        to update so that we only update the transfer function
     696        #        as necessary.  Right now, all transfer functions are
     697        #        updated. This makes moving the isomarker slider chunky.
     698        if { ![info exists _activeTfs($tf)] || !$_activeTfs($tf) } {
     699            set _activeTfs($tf) 1
     700        }
     701        SendCmd "volume shading transfunc $tf $tag"
    733702    }
    734703    FixLegend
     
    761730
    762731#
    763 # DrawLegend --
    764 #
    765 itcl::body Rappture::NanovisViewer::DrawLegend { cname } {
     732# ReceiveLegend --
     733#
     734#       The procedure is the response from the render server to each "legend"
     735#       command.  The server sends back a "legend" command invoked our
     736#       the slave interpreter.  The purpose is to collect data of the image
     737#       representing the legend in the canvas.  In addition, the isomarkers
     738#       of the active transfer function are displayed.
     739#
     740#       I don't know is this is the right place to display the isomarkers.
     741#       I don't know all the different paths used to draw the plot. There's
     742#       "Rebuild", "add", etc.
     743#
     744itcl::body Rappture::NanovisViewer::ReceiveLegend { tf vmin vmax size } {
     745    if { ![isconnected] } {
     746        return
     747    }
     748    set bytes [ReceiveBytes $size]
     749    $_image(legend) configure -data $bytes
     750    ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
     751
    766752    set c $itk_component(legend)
    767753    set w [winfo width $c]
     
    769755    set lx 10
    770756    set ly [expr {$h - 1}]
    771     if {"" == [$c find withtag colorbar]} {
     757    if {"" == [$c find withtag transfunc]} {
    772758        $c create image 10 10 -anchor nw \
    773             -image $_image(legend) -tags colorbar
     759            -image $_image(legend) -tags transfunc
    774760        $c create text $lx $ly -anchor sw \
    775             -fill $itk_option(-plotforeground) -tags "limits text vmin"
     761            -fill $itk_option(-plotforeground) -tags "limits vmin"
    776762        $c create text [expr {$w-$lx}] $ly -anchor se \
    777             -fill $itk_option(-plotforeground) -tags "limits text vmax"
    778         $c create text [expr {$w/2}] $ly -anchor s \
    779             -fill $itk_option(-plotforeground) -tags "limits text title"
    780         $c lower colorbar
    781         $c bind colorbar <ButtonRelease-1> [itcl::code $this AddNewMarker %x %y]
    782     }
    783 
    784     # Display the markers used by the current transfer function.
    785     HideAllMarkers
    786     $_transferFunctionEditors($cname) showMarkers $_limits($cname)
    787 
    788     foreach {min max} $_limits($cname) break
    789     $c itemconfigure vmin -text [format %g $min]
     763            -fill $itk_option(-plotforeground) -tags "limits vmax"
     764        $c lower transfunc
     765        $c bind transfunc <ButtonRelease-1> \
     766            [itcl::code $this AddIsoMarker %x %y]
     767    }
     768    # Display the markers used by the active transfer function.
     769
     770    array set limits [limits $tf]
     771    $c itemconfigure vmin -text [format %.2g $limits(min)]
    790772    $c coords vmin $lx $ly
    791773
    792     $c itemconfigure vmax -text [format %g $max]
     774    $c itemconfigure vmax -text [format %.2g $limits(max)]
    793775    $c coords vmax [expr {$w-$lx}] $ly
    794776
    795     set title [$_first hints label]
    796     set units [$_first hints units]
    797     if { $units != "" } {
    798         set title "$title ($units)"
    799     }
    800     $c itemconfigure title -text $title
    801     $c coords title [expr {$w/2}] $ly
     777    if { [info exists _isomarkers($tf)] } {
     778        foreach m $_isomarkers($tf) {
     779            $m visible yes
     780        }
     781    }
    802782
    803783    # The colormap may have changed. Resync the slicers with the colormap.
    804     InitSettings -cutplanesvisible -xcutplanevisible -ycutplanevisible \
    805         -zcutplanevisible
    806 }
    807 
    808 #
    809 #
    810 # ReceiveLegend --
    811 #
    812 #       The procedure is the response from the render server to each "legend"
    813 #       command.  The server sends back a "legend" command invoked our
    814 #       the slave interpreter.  The purpose is to collect data of the image
    815 #       representing the legend in the canvas.  In addition, the
    816 #       active transfer function is displayed.
    817 #
    818 #
    819 itcl::body Rappture::NanovisViewer::ReceiveLegend { cname vmin vmax size } {
    820     if { ![isconnected] } {
    821         return
    822     }
    823     set bytes [ReceiveBytes $size]
    824     $_image(legend) configure -data $bytes
    825     ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    826 
    827     DrawLegend $_current
     784    set datasets [CurrentDatasets -cutplanes]
     785    SendCmd "volume data state $_settings($this-volume) $datasets"
     786
     787    # Adjust the cutplane for only the first component in the topmost volume
     788    # (i.e. the first volume designated in the field).
     789    set tag [lindex $datasets 0]
     790    foreach axis {x y z} {
     791        # Turn off cutplanes for all volumes
     792        SendCmd "cutplane state 0 $axis"
     793        if { $_settings($this-${axis}cutplane) } {
     794            # Turn on cutplane for this particular volume and set the position
     795            SendCmd "cutplane state 1 $axis $tag"
     796            set pos [expr {0.01*$_settings($this-${axis}cutposition)}]
     797            SendCmd "cutplane position $pos $axis $tag"
     798        }
     799    }
    828800}
    829801
     
    865837    set dataobj [lindex $parts 0]
    866838    set _serverDatasets($tag) 1
    867     if { $_settings(-volumevisible) && $dataobj == $_first } {
     839    if { $_settings($this-volume) && $dataobj == $_first } {
    868840        SendCmd "volume state 1 $tag"
    869841    }
    870     set _limits($tag) [list $info(min)  $info(max)]
    871     set _limits(v)    [list $info(vmin) $info(vmax)]
     842    set _limits($tag-min)  $info(min);  # Minimum value of the volume.
     843    set _limits($tag-max)  $info(max);  # Maximum value of the volume.
     844    set _limits(vmin)      $info(vmin); # Overall minimum value.
     845    set _limits(vmax)      $info(vmax); # Overall maximum value.
    872846
    873847    unset _recvdDatasets($tag)
    874848    if { [array size _recvdDatasets] == 0 } {
    875         updateTransferFunctions
     849        # The active transfer function is by default the first component of
     850        # the first data object.  This assumes that the data is always
     851        # successfully transferred.
     852        updatetransferfuncs
    876853    }
    877854}
     
    897874    StartBufferingCommands
    898875
     876    # Hide all the isomarkers. Can't remove them. Have to remember the
     877    # settings since the user may have created/deleted/moved markers.
     878
     879    foreach tf [array names _isomarkers] {
     880        foreach m $_isomarkers($tf) {
     881            $m visible no
     882        }
     883    }
     884
    899885    if { $_width != $w || $_height != $h || $_reset } {
    900886        set _width $w
     
    903889        DoResize
    904890    }
    905 
    906891    foreach dataobj [get] {
    907892        foreach cname [$dataobj components] {
     
    913898                        puts stderr "??? $dataobj is invalid"
    914899                    }
    915                     set data [$dataobj blob $cname]
     900                    set data [$dataobj values $cname]
    916901                } else {
    917902                    set data [$dataobj vtkdata $cname]
    918903                    if 0 {
    919904                        set f [open "/tmp/volume.vtk" "w"]
    920                         fconfigure $f -translation binary -encoding binary
    921                         puts -nonewline $f $data
     905                        puts $f $data
    922906                        close $f
    923907                    }
     
    941925                set _serverDatasets($tag) 0
    942926            }
    943             SetObjectStyle $dataobj $cname
    944         }
    945     }
    946 
    947     # Outline seems to need to be reset every update.
    948     InitSettings -outlinevisible -cutplanesvisible -current
    949 
     927            NameTransferFunc $dataobj $cname
     928        }
     929    }
    950930    set _first [lindex [get] 0]
    951931    if { $_reset } {
     
    953933        # Reset the camera and other view parameters
    954934        #
    955         set _settings(-qw)    $_view(-qw)
    956         set _settings(-qx)    $_view(-qx)
    957         set _settings(-qy)    $_view(-qy)
    958         set _settings(-qz)    $_view(-qz)
    959         set _settings(-xpan)  $_view(-xpan)
    960         set _settings(-ypan)  $_view(-ypan)
    961         set _settings(-zoom)  $_view(-zoom)
    962 
    963         set q [ViewToQuaternion]
     935        set _settings($this-qw)    $_view(qw)
     936        set _settings($this-qx)    $_view(qx)
     937        set _settings($this-qy)    $_view(qy)
     938        set _settings($this-qz)    $_view(qz)
     939        set _settings($this-xpan)  $_view(xpan)
     940        set _settings($this-ypan)  $_view(ypan)
     941        set _settings($this-zoom)  $_view(zoom)
     942
     943        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    964944        $_arcball quaternion $q
    965945        SendCmd "camera orient $q"
    966946        SendCmd "camera reset"
    967947        PanCamera
    968         SendCmd "camera zoom $_view(-zoom)"
     948        SendCmd "camera zoom $_view(zoom)"
     949        InitSettings light2side light transp isosurface grid axes
    969950       
    970         #cutplane state 0 all
    971951        foreach axis {x y z} {
    972952            # Turn off cutplanes for all volumes
    973953            SendCmd "cutplane state 0 $axis"
    974954        }
    975 
    976         InitSettings -light2side -light -volumeopacity \
    977             -isosurfaceshading -gridvisible -axesvisible \
    978 
    979955        if {"" != $_first} {
    980956            set axis [$_first hints updir]
     
    988964        }
    989965    }
    990 
     966    # Outline seems to need to be reset every update.
     967    InitSettings outline
    991968    # nothing to send -- activate the proper ivol
    992969    SendCmd "volume state 0"
     
    1000977        set cname [lindex [$_first components] 0]
    1001978        if { [info exists _serverDatasets($_first-$cname)] } {
    1002             updateTransferFunctions
     979            updatetransferfuncs
    1003980        }
    1004981    }
     
    10261003        set tag $_first-$cname
    10271004        if { [info exists _serverDatasets($tag)] && $_serverDatasets($tag) } {
    1028             array set styles {
     1005            array set style {
    10291006                -cutplanes 1
    10301007            }
    1031             array set styles [lindex [$_first components -style $cname] 0]
    1032             if { $what != "-cutplanes" || $styles(-cutplanes) } {
     1008            array set style [lindex [$_first components -style $cname] 0]
     1009            if { $what != "-cutplanes" || $style(-cutplanes) } {
    10331010                lappend rlist $tag
    10341011            }
     
    10491026    switch -- $option {
    10501027        "in" {
    1051             set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1052             set _settings(-zoom) $_view(-zoom)
    1053             SendCmd "camera zoom $_view(-zoom)"
     1028            set _view(zoom) [expr {$_view(zoom)*1.25}]
     1029            set _settings($this-zoom) $_view(zoom)
     1030            SendCmd "camera zoom $_view(zoom)"
    10541031        }
    10551032        "out" {
    1056             set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1057             set _settings(-zoom) $_view(-zoom)
    1058             SendCmd "camera zoom $_view(-zoom)"
     1033            set _view(zoom) [expr {$_view(zoom)*0.8}]
     1034            set _settings($this-zoom) $_view(zoom)
     1035            SendCmd "camera zoom $_view(zoom)"
    10591036        }
    10601037        "reset" {
    10611038            array set _view {
    1062                 -qw      0.853553
    1063                 -qx      -0.353553
    1064                 -qy      0.353553
    1065                 -qz      0.146447
    1066                 -xpan    0
    1067                 -ypan    0
    1068                 -zoom    1.0
     1039                qw      0.853553
     1040                qx      -0.353553
     1041                qy      0.353553
     1042                qz      0.146447
     1043                zoom    1.0
     1044                xpan   0
     1045                ypan   0
    10691046            }
    10701047            if { $_first != "" } {
     
    10741051                }
    10751052            }
    1076             set q [ViewToQuaternion]         
     1053            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    10771054            $_arcball quaternion $q
    10781055            SendCmd "camera orient $q"
    10791056            SendCmd "camera reset"
    1080             set _settings(-qw)    $_view(-qw)
    1081             set _settings(-qx)    $_view(-qx)
    1082             set _settings(-qy)    $_view(-qy)
    1083             set _settings(-qz)    $_view(-qz)
    1084             set _settings(-xpan)  $_view(-xpan)
    1085             set _settings(-ypan)  $_view(-ypan)
    1086             set _settings(-zoom)  $_view(-zoom)
     1057            set _settings($this-qw)    $_view(qw)
     1058            set _settings($this-qx)    $_view(qx)
     1059            set _settings($this-qy)    $_view(qy)
     1060            set _settings($this-qz)    $_view(qz)
     1061            set _settings($this-xpan)  $_view(xpan)
     1062            set _settings($this-ypan)  $_view(ypan)
     1063            set _settings($this-zoom)  $_view(zoom)
    10871064        }
    10881065    }
     
    10901067
    10911068itcl::body Rappture::NanovisViewer::PanCamera {} {
    1092     set x $_view(-xpan)
    1093     set y $_view(-ypan)
     1069    #set x [expr ($_view(xpan)) / $_limits(xrange)]
     1070    #set y [expr ($_view(ypan)) / $_limits(yrange)]
     1071    set x $_view(xpan)
     1072    set y $_view(ypan)
    10941073    SendCmd "camera pan $x $y"
    10951074}
     
    11301109
    11311110                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
    1132                 QuaternionToView $q
    1133                 set _settings(-qw) $_view(-qw)
    1134                 set _settings(-qx) $_view(-qx)
    1135                 set _settings(-qy) $_view(-qy)
    1136                 set _settings(-qz) $_view(-qz)
     1111                foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     1112                set _settings($this-qw) $_view(qw)
     1113                set _settings($this-qx) $_view(qx)
     1114                set _settings($this-qy) $_view(qy)
     1115                set _settings($this-qz) $_view(qz)
    11371116                SendCmd "camera orient $q"
    11381117
     
    11671146        set x [expr $x / double($w)]
    11681147        set y [expr $y / double($h)]
    1169         set _view(-xpan) [expr $_view(-xpan) + $x]
    1170         set _view(-ypan) [expr $_view(-ypan) + $y]
     1148        set _view(xpan) [expr $_view(xpan) + $x]
     1149        set _view(ypan) [expr $_view(ypan) + $y]
    11711150        PanCamera
    1172         set _settings(-xpan) $_view(-xpan)
    1173         set _settings(-ypan) $_view(-ypan)
     1151        set _settings($this-xpan) $_view(xpan)
     1152        set _settings($this-ypan) $_view(ypan)
    11741153        return
    11751154    }
     
    11841163        set _click(x) $x
    11851164        set _click(y) $y
    1186         set _view(-xpan) [expr $_view(-xpan) - $dx]
    1187         set _view(-ypan) [expr $_view(-ypan) - $dy]
     1165        set _view(xpan) [expr $_view(xpan) - $dx]
     1166        set _view(ypan) [expr $_view(ypan) - $dy]
    11881167        PanCamera
    1189         set _settings(-xpan) $_view(-xpan)
    1190         set _settings(-ypan) $_view(-ypan)
     1168        set _settings($this-xpan) $_view(xpan)
     1169        set _settings($this-ypan) $_view(ypan)
    11911170    }
    11921171    if { $option == "release" } {
     
    12201199    }
    12211200    switch -- $what {
    1222         "-axesvisible" {
    1223             SendCmd "axis visible $_settings($what)"
    1224         }
    1225         "-background" {
    1226             set bgcolor [$itk_component(background) value]
    1227             array set fgcolors {
    1228                 "black" "white"
    1229                 "white" "black"
    1230                 "grey"  "black"
    1231             }
    1232             configure -plotbackground $bgcolor \
    1233                 -plotforeground $fgcolors($bgcolor)
    1234             DrawLegend $_current
    1235         }
    1236         "-colormap" {
     1201        light {
     1202            set val $_settings($this-light)
     1203            set diffuse [expr {0.01*$val}]
     1204            set ambient [expr {1.0-$diffuse}]
     1205            set specularLevel 0.3
     1206            set specularExp 90.0
     1207            SendCmd "volume shading ambient $ambient"
     1208            SendCmd "volume shading diffuse $diffuse"
     1209            SendCmd "volume shading specularLevel $specularLevel"
     1210            SendCmd "volume shading specularExp $specularExp"
     1211        }
     1212        light2side {
     1213            set val $_settings($this-light2side)
     1214            SendCmd "volume shading light2side $val"
     1215        }
     1216        transp {
     1217            set val $_settings($this-transp)
     1218            set sval [expr { 0.01 * double($val) }]
     1219            SendCmd "volume shading opacity $sval"
     1220        }
     1221        opacity {
     1222            set val $_settings($this-opacity)
     1223            set sval [expr { 0.01 * double($val) }]
     1224            foreach tf [array names _activeTfs] {
     1225                set _settings($this-$tf-opacity) $sval
     1226                set _activeTfs($tf) 0
     1227            }
     1228            updatetransferfuncs
     1229        }
     1230        thickness {
     1231            if { [array names _activeTfs] > 0 } {
     1232                set val $_settings($this-thickness)
     1233                # Scale values between 0.00001 and 0.01000
     1234                set sval [expr {0.0001*double($val)}]
     1235                foreach tf [array names _activeTfs] {
     1236                    set _settings($this-$tf-thickness) $sval
     1237                    set _activeTfs($tf) 0
     1238                }
     1239                updatetransferfuncs
     1240            }
     1241        }
     1242        "outline" {
     1243            SendCmd "volume outline state $_settings($this-outline)"
     1244        }
     1245        "isosurface" {
     1246            SendCmd "volume shading isosurface $_settings($this-isosurface)"
     1247        }
     1248        "colormap" {
    12371249            set color [$itk_component(colormap) value]
    1238             set _settings($what) $color
    1239             set _settings($_current${what}) $color
    1240             ResetColormap $_current $color
    1241         }
    1242         "-current" {
    1243             set cname [$itk_component(volcomponents) value]
    1244             SwitchComponent $cname
    1245         }
    1246         "-cutplanesvisible" {
    1247             set bool $_settings($what)
    1248             # We only set cutplanes on the first dataset.
    1249             set datasets [CurrentDatasets -cutplanes]
    1250             set tag [lindex $datasets 0]
    1251             if { $bool } {
    1252                 foreach axis { x y z } {
    1253                     if { $_settings(-${axis}cutplanevisible) } {
    1254                         SendCmd "cutplane state 1 $axis $tag"
    1255                     }
    1256                 }
    1257             } else {
    1258                 foreach axis { x y z } {
    1259                     SendCmd "cutplane state 0 $axis $tag"
    1260                 }
    1261             }
    1262         }
    1263         "-gridvisible" {
    1264             SendCmd "grid visible $_settings($what)"
    1265         }
    1266         "-isosurfaceshading" {
    1267             SendCmd "volume shading isosurface $_settings($what)"
    1268         }
    1269         "-legendvisible" {
    1270             if { $_settings($what) } {
     1250            set _settings(colormap) $color
     1251            # Only set the colormap on the first volume. Ignore the others.
     1252            #ResetColormap $color
     1253        }
     1254        "grid" {
     1255            SendCmd "grid visible $_settings($this-grid)"
     1256        }
     1257        "axes" {
     1258            SendCmd "axis visible $_settings($this-axes)"
     1259        }
     1260        "legend" {
     1261            if { $_settings($this-legend) } {
    12711262                blt::table $itk_component(plotarea) \
    12721263                    0,0 $itk_component(3dview) -fill both \
     
    12771268            }
    12781269        }
    1279         "-light" {
    1280             set _settings($_current${what}) $_settings($what)
    1281             set val $_settings($what)
    1282             set diffuse [expr {0.01*$val}]
    1283             set ambient [expr {1.0-$diffuse}]
    1284             set specularLevel 0.3
    1285             set specularExp 90.0
    1286             foreach tag [GetDatasetsWithComponent $_current] {
    1287                 SendCmd "volume shading ambient $ambient $tag"
    1288                 SendCmd "volume shading diffuse $diffuse $tag"
    1289                 SendCmd "volume shading specularLevel $specularLevel $tag"
    1290                 SendCmd "volume shading specularExp $specularExp $tag"
    1291             }
    1292         }
    1293         "-light2side" {
    1294             set _settings($_current${what}) $_settings($what)
    1295             set val $_settings($what)
    1296             foreach tag [GetDatasetsWithComponent $_current] {
    1297                 SendCmd "volume shading light2side $val $tag"
    1298             }
    1299         }
    1300         "-outlinevisible" {
    1301             SendCmd "volume outline state $_settings($what)"
    1302         }
    1303         "-thickness" {
    1304             set val $_settings($what)
    1305             set _settings($_current${what}) $val
    1306             updateTransferFunctions
    1307         }
    1308         "-volume" {
    1309             # This is the global volume visibility control.  It controls the
    1310             # visibility of all the all volumes.  Whenever it's changed, you
    1311             # have to synchronize each of the local controls (see below) with
    1312             # this.
    1313             set datasets [CurrentDatasets]
    1314             set bool $_settings($what)
    1315             SendCmd "volume data state $bool $datasets"
    1316             foreach cname $_componentsList {
    1317                 set _settings($cname-volumevisible) $bool
    1318             }
    1319             set _settings(-volumevisible) $bool
    1320         }
    1321         "-volumeopacity" {
    1322             set _settings($what) [expr $_widget($what) * 0.01]
    1323             set _settings($_current${what}) $_settings($what)
    1324             foreach tag [GetDatasetsWithComponent $_current] {
    1325                 SendCmd "volume shading opacity $_settings($what) $tag"
    1326             }
    1327         }
    1328         "-volumevisible" {
    1329             # This is the component specific control.  It changes the
    1330             # visibility of only the current component.
    1331             set _settings($_current${what}) $_settings($what)
    1332             foreach tag [GetDatasetsWithComponent $_current] {
    1333                 SendCmd "volume data state $_settings($what) $tag"
    1334             }
    1335         }
    1336         "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
    1337             set axis [string range $what 1 1]
    1338             set bool $_settings($what)
    1339             # We only set cutplanes on the first dataset.
     1270        "volume" {
     1271            set datasets [CurrentDatasets -cutplanes]
     1272            SendCmd "volume data state $_settings($this-volume) $datasets"
     1273        }
     1274        "xcutplane" - "ycutplane" - "zcutplane" {
     1275            set axis [string range $what 0 0]
     1276            set bool $_settings($this-$what)
    13401277            set datasets [CurrentDatasets -cutplanes]
    13411278            set tag [lindex $datasets 0]
    1342             if { $_settings(-cutplanesvisible) } {
    1343                 SendCmd "cutplane state $bool $axis $tag"
    1344             }
     1279            SendCmd "cutplane state $bool $axis $tag"
    13451280            if { $bool } {
    13461281                $itk_component(${axis}CutScale) configure -state normal \
     
    13691304    set w [expr {$_width-20}]
    13701305    set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
    1371     if {$w > 0 && $h > 0 && $_first != "" } {
    1372         if { [info exists _cname2transferFunction($_current)] } {
    1373             SendCmd "legend $_current $w $h"
    1374         }
    1375     }
    1376 }
    1377 
    1378 #
    1379 # NameTransferFunction --
     1306    if {$w > 0 && $h > 0 && [array names _activeTfs] > 0 && $_first != "" } {
     1307        set tag [lindex [CurrentDatasets] 0]
     1308        if { [info exists _dataset2style($tag)] } {
     1309            SendCmd "legend $_dataset2style($tag) $w $h"
     1310        }
     1311    } else {
     1312        # Can't do this as this will remove the items associated with the
     1313        # isomarkers.
     1314       
     1315        #$itk_component(legend) delete all
     1316    }
     1317}
     1318
     1319#
     1320# NameTransferFunc --
    13801321#
    13811322#       Creates a transfer function name based on the <style> settings in the
     
    13851326#       server parses the 3D data and sends back the limits via ReceiveData.]
    13861327#
    1387 itcl::body Rappture::NanovisViewer::NameTransferFunction { dataobj cname } {
    1388     array set styles {
     1328#       FIXME: The current way we generate transfer-function names completely
     1329#              ignores the -markers option.  The problem is that we are forced
     1330#              to compute the name from an increasing complex set of values:
     1331#              color, levels, marker, opacity.  I think we're stuck doing it
     1332#              now.
     1333#
     1334itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj cname } {
     1335    array set style {
    13891336        -color BCGYR
    13901337        -levels 6
     1338        -opacity 1.0
    13911339        -markers ""
    13921340    }
    13931341    set tag $dataobj-$cname
    1394     array set styles [lindex [$dataobj components -style $cname] 0]
    1395     if { ![info exists _cname2transferFunction($cname)] } {
    1396         # Get the colormap right now, since it doesn't change with marker
    1397         # changes.
    1398         set cmap [ColorsToColormap $styles(-color)]
    1399         set wmap [list 0.0 0.0 1.0 1.0]
    1400         set _cname2transferFunction($cname) [list $cmap $wmap]
    1401         SendCmd [list transfunc define $cname $cmap $wmap]
    1402     }
    1403     SendCmd "volume shading transfunc $cname $tag"
    1404     if { ![info exists _transferFunctionEditors($cname)] } {
    1405         set _transferFunctionEditors($cname) \
    1406             [Rappture::TransferFunctionEditor ::\#auto $itk_component(legend) \
    1407                  $cname \
    1408                  -command [itcl::code $this updateTransferFunctions]]
    1409     }
    1410     set _dataset2style($tag) $cname
    1411     lappend _style2datasets($cname) $tag
    1412     return $cname
    1413 }
    1414 
    1415 #
    1416 # ComputeTransferFunction --
    1417 #
    1418 #       Computes and sends the transfer function to the render server.  It's
    1419 #       assumed that the volume data limits are known and that the global
    1420 #       transfer-functions slider values have been set up.  Both parts are
    1421 #       needed to compute the relative value (location) of the marker, and
    1422 #       the alpha map of the transfer function.
    1423 #
    1424 itcl::body Rappture::NanovisViewer::ComputeTransferFunction { cname } {
    1425     foreach {cmap wmap} $_cname2transferFunction($cname) break
     1342    array set style [lindex [$dataobj components -style $cname] 0]
     1343    set tf "$style(-color):$style(-levels):$style(-opacity)"
     1344    set _dataset2style($tag) $tf
     1345    lappend _style2datasets($tf) $tag
     1346    return $tf
     1347}
     1348
     1349#
     1350# ComputeTransferFunc --
     1351#
     1352#   Computes and sends the transfer function to the render server.  It's
     1353#   assumed that the volume data limits are known and that the global
     1354#   transfer-functions slider values have been set up.  Both parts are
     1355#   needed to compute the relative value (location) of the marker, and
     1356#   the alpha map of the transfer function.
     1357#
     1358itcl::body Rappture::NanovisViewer::ComputeTransferFunc { tf } {
     1359    array set style {
     1360        -color BCGYR
     1361        -levels 6
     1362        -opacity 1.0
     1363        -markers ""
     1364    }
     1365
     1366    foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break
     1367    array set style [lindex [$dataobj components -style $cname] 0]
    14261368
    14271369    # We have to parse the style attributes for a volume using this
     
    14311373    # of the volumes (the first in the list) using the transfer-function as a
    14321374    # reference.
    1433     if { ![info exists _parsedFunction($cname)] } {
    1434         array set styles {
    1435             -color BCGYR
    1436             -levels 6
    1437             -markers ""
    1438         }
    1439         # Accumulate the style from all the datasets using it.
    1440         foreach tag [GetDatasetsWithComponent $cname] {
    1441             foreach {dataobj cname} [split [lindex $tag 0] -] break
    1442             array set styles [lindex [$dataobj components -style $cname] 0]
    1443         }
    1444         eval $_transferFunctionEditors($cname) limits $_limits($cname)
     1375    #
     1376    # FIXME: The current way we generate transfer-function names completely
     1377    #        ignores the -markers option.  The problem is that we are forced
     1378    #        to compute the name from an increasing complex set of values:
     1379    #        color, levels, marker, opacity.  I think the cow's out of the
     1380    #        barn on this one.
     1381
     1382    if { ![info exists _isomarkers($tf)] } {
    14451383        # Have to defer creation of isomarkers until we have data limits
    1446         if { [info exists styles(-markers)] &&
    1447              [llength $styles(-markers)] > 0 } {
    1448             ParseMarkersOption $cname $styles(-markers)
     1384        if { [info exists style(-markers)] &&
     1385             [llength $style(-markers)] > 0 } {
     1386            ParseMarkersOption $tf $style(-markers)
    14491387        } else {
    1450             ParseLevelsOption $cname $styles(-levels)
    1451         }
    1452        
    1453     }
    1454     set wmap [ComputeAlphamap $cname]
    1455     set _cname2transferFunction($cname) [list $cmap $wmap]
    1456     SendCmd [list transfunc define $cname $cmap $wmap]
    1457 }
    1458 
    1459 itcl::body Rappture::NanovisViewer::AddNewMarker { x y } {
    1460     if { ![info exists _transferFunctionEditors($_current)] } {
    1461         continue
    1462     }
    1463     # Add a new marker to the current transfer function
    1464     $_transferFunctionEditors($_current) newMarker $x $y normal
    1465     $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
    1466 }
    1467 
    1468 itcl::body Rappture::NanovisViewer::RemoveMarker { x y } {
    1469     if { ![info exists _transferFunctionEditors($_current)] } {
    1470         continue
    1471     }
    1472     # Add a new marker to the current transfer function
    1473     $_transferFunctionEditors($_current) deleteMarker $x $y
     1388            ParseLevelsOption $tf $style(-levels)
     1389        }
     1390    }
     1391    set cmap [ColorsToColormap $style(-color)]
     1392    set tag $this-$tf
     1393    if { ![info exists _settings($tag-opacity)] } {
     1394        set _settings($tag-opacity) $style(-opacity)
     1395    }
     1396    set max 1.0 ;#$_settings($tag-opacity)
     1397
     1398    set isovalues {}
     1399    foreach m $_isomarkers($tf) {
     1400        lappend isovalues [$m relval]
     1401    }
     1402    # Sort the isovalues
     1403    set isovalues [lsort -real $isovalues]
     1404
     1405    if { ![info exists _settings($tag-thickness)]} {
     1406        set _settings($tag-thickness) 0.005
     1407    }
     1408    set delta $_settings($tag-thickness)
     1409
     1410    set first [lindex $isovalues 0]
     1411    set last [lindex $isovalues end]
     1412    set wmap ""
     1413    if { $first == "" || $first != 0.0 } {
     1414        lappend wmap 0.0 0.0
     1415    }
     1416    foreach x $isovalues {
     1417        set x1 [expr {$x-$delta-0.00001}]
     1418        set x2 [expr {$x-$delta}]
     1419        set x3 [expr {$x+$delta}]
     1420        set x4 [expr {$x+$delta+0.00001}]
     1421        if { $x1 < 0.0 } {
     1422            set x1 0.0
     1423        } elseif { $x1 > 1.0 } {
     1424            set x1 1.0
     1425        }
     1426        if { $x2 < 0.0 } {
     1427            set x2 0.0
     1428        } elseif { $x2 > 1.0 } {
     1429            set x2 1.0
     1430        }
     1431        if { $x3 < 0.0 } {
     1432            set x3 0.0
     1433        } elseif { $x3 > 1.0 } {
     1434            set x3 1.0
     1435        }
     1436        if { $x4 < 0.0 } {
     1437            set x4 0.0
     1438        } elseif { $x4 > 1.0 } {
     1439            set x4 1.0
     1440        }
     1441        # add spikes in the middle
     1442        lappend wmap $x1 0.0
     1443        lappend wmap $x2 $max
     1444        lappend wmap $x3 $max
     1445        lappend wmap $x4 0.0
     1446    }
     1447    if { $last == "" || $last != 1.0 } {
     1448        lappend wmap 1.0 0.0
     1449    }
     1450    SendCmd "transfunc define $tf { $cmap } { $wmap }"
    14741451}
    14751452
     
    14791456itcl::configbody Rappture::NanovisViewer::plotbackground {
    14801457    if { [isconnected] } {
    1481         set color $itk_option(-plotbackground)
    1482         set rgb [Color2RGB $color]
    1483         SendCmd "screen bgcolor $rgb"
    1484         $itk_component(legend) configure -background $color
     1458        foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
     1459        #fix this!
     1460        #SendCmd "color background $r $g $b"
    14851461    }
    14861462}
     
    14911467itcl::configbody Rappture::NanovisViewer::plotforeground {
    14921468    if { [isconnected] } {
    1493         set color $itk_option(-plotforeground)
    1494         set rgb [Color2RGB $color]
    1495         SendCmd "volume outline color $rgb"
    1496         SendCmd "grid axiscolor $rgb"
    1497         SendCmd "grid linecolor $rgb"
    1498         $itk_component(legend) itemconfigure labels -fill $color
    1499         $itk_component(legend) itemconfigure limits -fill $color
     1469        foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
     1470        #fix this!
     1471        #SendCmd "color background $r $g $b"
    15001472    }
    15011473}
     
    15241496# marker is a relative value from 0.0 to 1.0.
    15251497#
    1526 itcl::body Rappture::NanovisViewer::ParseLevelsOption { cname levels } {
     1498itcl::body Rappture::NanovisViewer::ParseLevelsOption { tf levels } {
    15271499    set c $itk_component(legend)
    1528     set list {}
    15291500    regsub -all "," $levels " " levels
    15301501    if {[string is int $levels]} {
    15311502        for {set i 1} { $i <= $levels } {incr i} {
    1532             lappend list [expr {double($i)/($levels+1)}]
     1503            set x [expr {double($i)/($levels+1)}]
     1504            set m [Rappture::IsoMarker \#auto $c $this $tf]
     1505            $m relval $x
     1506            lappend _isomarkers($tf) $m
    15331507        }
    15341508    } else {
    15351509        foreach x $levels {
    1536             lappend list $x
    1537         }
    1538     }
    1539     set _parsedFunction($cname) 1
    1540     $_transferFunctionEditors($cname) addMarkers $list
    1541     $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
     1510            set m [Rappture::IsoMarker \#auto $c $this $tf]
     1511            $m relval $x
     1512            lappend _isomarkers($tf) $m
     1513        }
     1514    }
    15421515}
    15431516
     
    15541527#       not be seen.
    15551528#
    1556 itcl::body Rappture::NanovisViewer::ParseMarkersOption { cname markers } {
     1529itcl::body Rappture::NanovisViewer::ParseMarkersOption { tf markers } {
    15571530    set c $itk_component(legend)
    1558     set list {}
    1559     foreach { min max } $_limits($cname) break
    15601531    regsub -all "," $markers " " markers
    15611532    foreach marker $markers {
    15621533        set n [scan $marker "%g%s" value suffix]
    15631534        if { $n == 2 && $suffix == "%" } {
    1564             # $n% : Set relative value (0..1).
    1565             lappend list [expr {$value * 0.01}]
     1535            # ${n}% : Set relative value.
     1536            set value [expr {$value * 0.01}]
     1537            set m [Rappture::IsoMarker \#auto $c $this $tf]
     1538            $m relval $value
     1539            lappend _isomarkers($tf) $m
    15661540        } else {
    1567             # $n : absolute value, compute relative
    1568             lappend list  [expr {(double($value)-$min)/($max-$min)]}
    1569         }
    1570     }
    1571     set _parsedFunction($cname) 1
    1572     $_transferFunctionEditors($cname) addMarkers $list
    1573     $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
     1541            # ${n} : Set absolute value.
     1542            set m [Rappture::IsoMarker \#auto $c $this $tf]
     1543            $m absval $value
     1544            lappend _isomarkers($tf) $m
     1545        }
     1546    }
    15741547}
    15751548
     
    15771550# USAGE: UndateTransferFuncs
    15781551# ----------------------------------------------------------------------
    1579 itcl::body Rappture::NanovisViewer::updateTransferFunctions {} {
     1552itcl::body Rappture::NanovisViewer::updatetransferfuncs {} {
    15801553    $_dispatcher event -idle !send_transfunc
    15811554}
    15821555
    1583 itcl::body Rappture::NanovisViewer::limits { cname } {
     1556itcl::body Rappture::NanovisViewer::AddIsoMarker { x y } {
     1557    if { $_first == "" } {
     1558        error "active transfer function isn't set"
     1559    }
     1560    set tag [lindex [CurrentDatasets] 0]
     1561    set tf $_dataset2style($tag)
     1562    set c $itk_component(legend)
     1563    set m [Rappture::IsoMarker \#auto $c $this $tf]
     1564    set w [winfo width $c]
     1565    $m relval [expr {double($x-10)/($w-20)}]
     1566    lappend _isomarkers($tf) $m
     1567    updatetransferfuncs
     1568    return 1
     1569}
     1570
     1571itcl::body Rappture::NanovisViewer::rmdupmarker { marker x } {
     1572    set tf [$marker transferfunc]
     1573    set bool 0
     1574    if { [info exists _isomarkers($tf)] } {
     1575        set list {}
     1576        set marker [namespace tail $marker]
     1577        foreach m $_isomarkers($tf) {
     1578            set sx [$m screenpos]
     1579            if { $m != $marker } {
     1580                if { $x >= ($sx-3) && $x <= ($sx+3) } {
     1581                    $marker relval [$m relval]
     1582                    itcl::delete object $m
     1583                    bell
     1584                    set bool 1
     1585                    continue
     1586                }
     1587            }
     1588            lappend list $m
     1589        }
     1590        set _isomarkers($tf) $list
     1591        updatetransferfuncs
     1592    }
     1593    return $bool
     1594}
     1595
     1596itcl::body Rappture::NanovisViewer::overmarker { marker x } {
     1597    set tf [$marker transferfunc]
     1598    if { [info exists _isomarkers($tf)] } {
     1599        set marker [namespace tail $marker]
     1600        foreach m $_isomarkers($tf) {
     1601            set sx [$m screenpos]
     1602            if { $m != $marker } {
     1603                set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }]
     1604                $m activate $bool
     1605            }
     1606        }
     1607    }
     1608    return ""
     1609}
     1610
     1611itcl::body Rappture::NanovisViewer::limits { tf } {
    15841612    set _limits(min) 0.0
    15851613    set _limits(max) 1.0
    1586     if { ![info exists _style2datasets($cname)] } {
     1614    if { ![info exists _style2datasets($tf)] } {
    15871615        return [array get _limits]
    15881616    }
    15891617    set min ""; set max ""
    1590     foreach tag [GetDatasetsWithComponent $cname] {
    1591         if { ![info exists _limits($tag)] } {
     1618    foreach tag $_style2datasets($tf) {
     1619        if { ![info exists _serverDatasets($tag)] } {
    15921620            continue
    15931621        }
    1594         foreach {amin amax} $_limits($tag) break
    1595         if { $min == "" || $min > $amin } {
    1596             set min $amin
    1597         }
    1598         if { $max == "" || $max < $amax } {
    1599             set max $amax
     1622        if { ![info exists _limits($tag-min)] } {
     1623            continue
     1624        }
     1625        if { $min == "" || $min > $_limits($tag-min) } {
     1626            set min $_limits($tag-min)
     1627        }
     1628        if { $max == "" || $max < $_limits($tag-max) } {
     1629            set max $_limits($tag-max)
    16001630        }
    16011631    }
     
    16061636        set _limits(max) $max
    16071637    }
    1608     return [list $_limits(min) $_limits(max)]
     1638    return [array get _limits]
    16091639}
    16101640
    16111641
    16121642itcl::body Rappture::NanovisViewer::BuildViewTab {} {
     1643    foreach { key value } {
     1644        grid            0
     1645        axes            1
     1646        outline         0
     1647        volume          1
     1648        legend          1
     1649        particles       1
     1650        lic             1
     1651    } {
     1652        set _settings($this-$key) $value
     1653    }
     1654
    16131655    set fg [option get $itk_component(hull) font Font]
    16141656    #set bfg [option get $itk_component(hull) boldFont Font]
     
    16191661    $inner configure -borderwidth 4
    16201662
    1621     set ::Rappture::NanovisViewer::_settings(-isosurfaceshading) 0
     1663    set ::Rappture::NanovisViewer::_settings($this-isosurface) 0
    16221664    checkbutton $inner.isosurface \
    16231665        -text "Isosurface shading" \
    1624         -variable [itcl::scope _settings(-isosurfaceshading)] \
    1625         -command [itcl::code $this AdjustSetting -isosurfaceshading] \
     1666        -variable [itcl::scope _settings($this-isosurface)] \
     1667        -command [itcl::code $this AdjustSetting isosurface] \
    16261668        -font "Arial 9"
    16271669
    16281670    checkbutton $inner.axes \
    16291671        -text "Axes" \
    1630         -variable [itcl::scope _settings(-axesvisible)] \
    1631         -command [itcl::code $this AdjustSetting -axesvisible] \
     1672        -variable [itcl::scope _settings($this-axes)] \
     1673        -command [itcl::code $this AdjustSetting axes] \
    16321674        -font "Arial 9"
    16331675
    16341676    checkbutton $inner.grid \
    16351677        -text "Grid" \
    1636         -variable [itcl::scope _settings(-gridvisible)] \
    1637         -command [itcl::code $this AdjustSetting -gridvisible] \
     1678        -variable [itcl::scope _settings($this-grid)] \
     1679        -command [itcl::code $this AdjustSetting grid] \
    16381680        -font "Arial 9"
    16391681
    16401682    checkbutton $inner.outline \
    16411683        -text "Outline" \
    1642         -variable [itcl::scope _settings(-outlinevisible)] \
    1643         -command [itcl::code $this AdjustSetting -outlinevisible] \
     1684        -variable [itcl::scope _settings($this-outline)] \
     1685        -command [itcl::code $this AdjustSetting outline] \
    16441686        -font "Arial 9"
    16451687
    16461688    checkbutton $inner.legend \
    16471689        -text "Legend" \
    1648         -variable [itcl::scope _settings(-legendvisible)] \
    1649         -command [itcl::code $this AdjustSetting -legendvisible] \
     1690        -variable [itcl::scope _settings($this-legend)] \
     1691        -command [itcl::code $this AdjustSetting legend] \
    16501692        -font "Arial 9"
    16511693
    16521694    checkbutton $inner.volume \
    16531695        -text "Volume" \
    1654         -variable [itcl::scope _settings(-volume)] \
    1655         -command [itcl::code $this AdjustSetting -volume] \
     1696        -variable [itcl::scope _settings($this-volume)] \
     1697        -command [itcl::code $this AdjustSetting volume] \
    16561698        -font "Arial 9"
    1657 
    1658     label $inner.background_l -text "Background" -font "Arial 9"
    1659     itk_component add background {
    1660         Rappture::Combobox $inner.background -width 10 -editable no
    1661     }
    1662     $inner.background choices insert end \
    1663         "black"              "black"            \
    1664         "white"              "white"            \
    1665         "grey"               "grey"             
    1666 
    1667     $itk_component(background) value $_settings(-background)
    1668     bind $inner.background <<Value>> \
    1669         [itcl::code $this AdjustSetting -background]
    16701699
    16711700    blt::table $inner \
     
    16741703        2,0 $inner.outline  -cspan 2 -anchor w \
    16751704        3,0 $inner.volume  -cspan 2 -anchor w \
    1676         4,0 $inner.legend  -cspan 2 -anchor w \
    1677         5,0 $inner.background_l       -anchor e -pady 2 \
    1678         5,1 $inner.background                   -fill x \
     1705        4,0 $inner.legend  -cspan 2 -anchor w
    16791706
    16801707    if 0 {
     
    16821709    }
    16831710    blt::table configure $inner r* -resize none
    1684     blt::table configure $inner r6 -resize expand
     1711    blt::table configure $inner r5 -resize expand
    16851712}
    16861713
    16871714itcl::body Rappture::NanovisViewer::BuildVolumeTab {} {
     1715    foreach { key value } {
     1716        light2side      1
     1717        light           40
     1718        transp          50
     1719        opacity         100
     1720        thickness       350
     1721    } {
     1722        set _settings($this-$key) $value
     1723    }
     1724
    16881725    set inner [$itk_component(main) insert end \
    16891726        -title "Volume Settings" \
     
    16941731    #set bfg [option get $itk_component(hull) boldFont Font]
    16951732
     1733    checkbutton $inner.vol -text "Show volume" -font $fg \
     1734        -variable [itcl::scope _settings($this-volume)] \
     1735        -command [itcl::code $this AdjustSetting volume]
    16961736    label $inner.shading -text "Shading:" -font $fg
    16971737
    16981738    checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \
    1699         -variable [itcl::scope _settings(-light2side)] \
    1700         -command [itcl::code $this AdjustSetting -light2side]
    1701 
    1702     checkbutton $inner.visibility -text "Visible" -font $fg \
    1703         -variable [itcl::scope _settings(-volumevisible)] \
    1704         -command [itcl::code $this AdjustSetting -volumevisible]
     1739        -variable [itcl::scope _settings($this-light2side)] \
     1740        -command [itcl::code $this AdjustSetting light2side]
    17051741
    17061742    label $inner.dim -text "Glow" -font $fg
    17071743    ::scale $inner.light -from 0 -to 100 -orient horizontal \
    1708         -variable [itcl::scope _settings(-light)] \
     1744        -variable [itcl::scope _settings($this-light)] \
    17091745        -width 10 \
    1710         -showvalue off -command [itcl::code $this AdjustSetting -light]
     1746        -showvalue off -command [itcl::code $this AdjustSetting light]
    17111747    label $inner.bright -text "Surface" -font $fg
    17121748
    1713     # Opacity
    17141749    label $inner.fog -text "Clear" -font $fg
    17151750    ::scale $inner.transp -from 0 -to 100 -orient horizontal \
    1716         -variable [itcl::scope _widget(-volumeopacity)] \
     1751        -variable [itcl::scope _settings($this-transp)] \
    17171752        -width 10 \
    1718         -showvalue off -command [itcl::code $this AdjustSetting -volumeopacity]
     1753        -showvalue off -command [itcl::code $this AdjustSetting transp]
    17191754    label $inner.plastic -text "Opaque" -font $fg
    17201755
    1721     # Tooth thickness
     1756    label $inner.clear -text "Clear" -font $fg
     1757    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
     1758        -variable [itcl::scope _settings($this-opacity)] \
     1759        -width 10 \
     1760        -showvalue off -command [itcl::code $this AdjustSetting opacity]
     1761    label $inner.opaque -text "Opaque" -font $fg
     1762
    17221763    label $inner.thin -text "Thin" -font $fg
    17231764    ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \
    1724         -variable [itcl::scope _settings(-thickness)] \
     1765        -variable [itcl::scope _settings($this-thickness)] \
    17251766        -width 10 \
    1726         -showvalue off -command [itcl::code $this AdjustSetting -thickness]
     1767        -showvalue off -command [itcl::code $this AdjustSetting thickness]
    17271768    label $inner.thick -text "Thick" -font $fg
    17281769
    1729     # Colormap
    1730     label $inner.colormap_l -text "Colormap" -font $fg
     1770    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    17311771    itk_component add colormap {
    17321772        Rappture::Combobox $inner.colormap -width 10 -editable no
    17331773    }
    17341774
    1735     $inner.colormap choices insert end [GetColormapList -includeDefault -includeNone]
     1775    $inner.colormap choices insert end \
     1776        "BCGYR"              "BCGYR"            \
     1777        "BGYOR"              "BGYOR"            \
     1778        "blue"               "blue"             \
     1779        "blue-to-brown"      "blue-to-brown"    \
     1780        "blue-to-orange"     "blue-to-orange"   \
     1781        "blue-to-grey"       "blue-to-grey"     \
     1782        "green-to-magenta"   "green-to-magenta" \
     1783        "greyscale"          "greyscale"        \
     1784        "nanohub"            "nanohub"          \
     1785        "rainbow"            "rainbow"          \
     1786        "spectral"           "spectral"         \
     1787        "ROYGB"              "ROYGB"            \
     1788        "RYGCB"              "RYGCB"            \
     1789        "brown-to-blue"      "brown-to-blue"    \
     1790        "grey-to-blue"       "grey-to-blue"     \
     1791        "orange-to-blue"     "orange-to-blue"   \
     1792        "none"               "none"
     1793
     1794    $itk_component(colormap) value "BCGYR"
    17361795    bind $inner.colormap <<Value>> \
    1737         [itcl::code $this AdjustSetting -colormap]
    1738     $itk_component(colormap) value "default"
    1739     set _settings(-colormap) "default"
    1740 
    1741     # Component
    1742     label $inner.volcomponents_l -text "Component" -font $fg
    1743     itk_component add volcomponents {
    1744         Rappture::Combobox $inner.volcomponents -editable no
    1745     }
    1746     bind $inner.volcomponents <<Value>> \
    1747         [itcl::code $this AdjustSetting -current]
     1796        [itcl::code $this AdjustSetting colormap]
    17481797
    17491798    blt::table $inner \
    1750         0,0 $inner.volcomponents_l -anchor e -cspan 2 \
    1751         0,2 $inner.volcomponents             -cspan 3 -fill x \
     1799        0,0 $inner.vol -cspan 4 -anchor w -pady 2 \
    17521800        1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \
    17531801        2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \
    1754         3,0 $inner.visibility -cspan 4 -anchor w -pady 2 \
    1755         4,0 $inner.dim -anchor e -pady 2 \
    1756         4,1 $inner.light -cspan 2 -pady 2 -fill x \
    1757         4,3 $inner.bright -anchor w -pady 2 \
    1758         5,0 $inner.fog -anchor e -pady 2 \
    1759         5,1 $inner.transp -cspan 2 -pady 2 -fill x \
    1760         5,3 $inner.plastic -anchor w -pady 2 \
    1761         6,0 $inner.thin -anchor e -pady 2 \
    1762         6,1 $inner.thickness -cspan 2 -pady 2 -fill x\
    1763         6,3 $inner.thick -anchor w -pady 2
     1802        3,0 $inner.dim -anchor e -pady 2 \
     1803        3,1 $inner.light -cspan 2 -pady 2 -fill x \
     1804        3,3 $inner.bright -anchor w -pady 2 \
     1805        4,0 $inner.fog -anchor e -pady 2 \
     1806        4,1 $inner.transp -cspan 2 -pady 2 -fill x \
     1807        4,3 $inner.plastic -anchor w -pady 2 \
     1808        5,0 $inner.thin -anchor e -pady 2 \
     1809        5,1 $inner.thickness -cspan 2 -pady 2 -fill x\
     1810        5,3 $inner.thick -anchor w -pady 2
    17641811
    17651812    blt::table configure $inner c0 c1 c3 r* -resize none
    1766     blt::table configure $inner r7 -resize expand
     1813    blt::table configure $inner r6 -resize expand
    17671814}
    17681815
     
    17731820    $inner configure -borderwidth 4
    17741821
    1775     checkbutton $inner.visible \
    1776         -text "Show Cutplanes" \
    1777         -variable [itcl::scope _settings(-cutplanesvisible)] \
    1778         -command [itcl::code $this AdjustSetting -cutplanesvisible] \
    1779         -font "Arial 9"
    1780 
    17811822    # X-value slicer...
    17821823    itk_component add xCutButton {
     
    17841825            -onimage [Rappture::icon x-cutplane] \
    17851826            -offimage [Rappture::icon x-cutplane] \
    1786             -command [itcl::code $this AdjustSetting -xcutplanevisible] \
    1787             -variable [itcl::scope _settings(-xcutplanevisible)]
     1827            -command [itcl::code $this AdjustSetting xcutplane] \
     1828            -variable [itcl::scope _settings($this-xcutplane)]
    17881829    }
    17891830    Rappture::Tooltip::for $itk_component(xCutButton) \
    17901831        "Toggle the X cut plane on/off"
    1791     $itk_component(xCutButton) select
    17921832
    17931833    itk_component add xCutScale {
     
    17961836            -borderwidth 1 -highlightthickness 0 \
    17971837            -command [itcl::code $this Slice move x] \
    1798             -variable [itcl::scope _settings(-xcutplaneposition)]
     1838            -variable [itcl::scope _settings($this-xcutposition)]
    17991839    } {
    18001840        usual
     
    18121852            -onimage [Rappture::icon y-cutplane] \
    18131853            -offimage [Rappture::icon y-cutplane] \
    1814             -command [itcl::code $this AdjustSetting -ycutplanevisible] \
    1815             -variable [itcl::scope _settings(-ycutplanevisible)]
     1854            -command [itcl::code $this AdjustSetting ycutplane] \
     1855            -variable [itcl::scope _settings($this-ycutplane)]
    18161856    }
    18171857    Rappture::Tooltip::for $itk_component(yCutButton) \
    18181858        "Toggle the Y cut plane on/off"
    1819     $itk_component(yCutButton) select
    18201859
    18211860    itk_component add yCutScale {
     
    18241863            -borderwidth 1 -highlightthickness 0 \
    18251864            -command [itcl::code $this Slice move y] \
    1826             -variable [itcl::scope _settings(-ycutplaneposition)]
     1865            -variable [itcl::scope _settings($this-ycutposition)]
    18271866    } {
    18281867        usual
     
    18401879            -onimage [Rappture::icon z-cutplane] \
    18411880            -offimage [Rappture::icon z-cutplane] \
    1842             -command [itcl::code $this AdjustSetting -zcutplanevisible] \
    1843             -variable [itcl::scope _settings(-zcutplanevisible)]
     1881            -command [itcl::code $this AdjustSetting zcutplane] \
     1882            -variable [itcl::scope _settings($this-zcutplane)]
    18441883    }
    18451884    Rappture::Tooltip::for $itk_component(zCutButton) \
    18461885        "Toggle the Z cut plane on/off"
    1847     $itk_component(zCutButton) select
    18481886
    18491887    itk_component add zCutScale {
     
    18521890            -borderwidth 1 -highlightthickness 0 \
    18531891            -command [itcl::code $this Slice move z] \
    1854             -variable [itcl::scope _settings(-zcutplaneposition)]
     1892            -variable [itcl::scope _settings($this-zcutposition)]
    18551893    } {
    18561894        usual
     
    18591897    $itk_component(zCutScale) set 50
    18601898    $itk_component(zCutScale) configure -state disabled
     1899    #$itk_component(zCutScale) configure -state disabled
    18611900    Rappture::Tooltip::for $itk_component(zCutScale) \
    18621901        "@[itcl::code $this SlicerTip z]"
    18631902
    18641903    blt::table $inner \
    1865         0,1 $inner.visible              -anchor w -pady 2 -cspan 4 \
    1866         1,1 $itk_component(xCutScale) \
    1867         1,2 $itk_component(yCutScale) \
    1868         1,3 $itk_component(zCutScale) \
    1869         2,1 $itk_component(xCutButton) \
    1870         2,2 $itk_component(yCutButton) \
    1871         2,3 $itk_component(zCutButton)
    1872 
    1873     blt::table configure $inner r0 r1 r2 c* -resize none
    1874     blt::table configure $inner r3 c4 -resize expand
     1904        1,1 $itk_component(xCutButton) \
     1905        1,2 $itk_component(yCutButton) \
     1906        1,3 $itk_component(zCutButton) \
     1907        0,1 $itk_component(xCutScale) \
     1908        0,2 $itk_component(yCutScale) \
     1909        0,3 $itk_component(zCutScale)
     1910
     1911    blt::table configure $inner r0 r1 c* -resize none
     1912    blt::table configure $inner r2 c4 -resize expand
    18751913    blt::table configure $inner c0 -width 2
    18761914    blt::table configure $inner c1 c2 c3 -padx 2
     
    18951933        0,0 $inner.view_l -anchor e -pady 2 \
    18961934        0,1 $inner.view -anchor w -pady 2
    1897     blt::table configure $inner r0 -resize none
    18981935
    18991936    set row 1
     
    19021939        label $inner.${tag}label -text $tag -font "Arial 9"
    19031940        entry $inner.${tag} -font "Arial 9"  -bg white \
    1904             -textvariable [itcl::scope _settings(-$tag)]
     1941            -textvariable [itcl::scope _settings($this-$tag)]
    19051942        bind $inner.${tag} <Return> \
    1906             [itcl::code $this camera set -${tag}]
     1943            [itcl::code $this camera set ${tag}]
    19071944        bind $inner.${tag} <KP_Enter> \
    1908             [itcl::code $this camera set -${tag}]
     1945            [itcl::code $this camera set ${tag}]
    19091946        blt::table $inner \
    19101947            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    19141951    }
    19151952
    1916     blt::table configure $inner c* -resize none
     1953    blt::table configure $inner c* r* -resize none
    19171954    blt::table configure $inner c2 -resize expand
    19181955    blt::table configure $inner r$row -resize expand
     
    19551992itcl::body Rappture::NanovisViewer::SlicerTip {axis} {
    19561993    set val [$itk_component(${axis}CutScale) get]
     1994#    set val [expr {0.01*($val-50)
     1995#        *($_limits(${axis}max)-$_limits(${axis}min))
     1996#          + 0.5*($_limits(${axis}max)+$_limits(${axis}min))}]
    19571997    return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
    19581998}
     
    19752015}
    19762016
    1977 itcl::body Rappture::NanovisViewer::EventuallyRedrawLegend {} {
     2017itcl::body Rappture::NanovisViewer::EventuallyResizeLegend {} {
    19782018    if { !$_resizeLegendPending } {
    19792019        $_dispatcher event -idle !legend
     
    19902030        }
    19912031        "set" {
    1992             set what [lindex $args 0]
    1993             set x $_settings($what)
     2032            set who [lindex $args 0]
     2033            set x $_settings($this-$who)
    19942034            set code [catch { string is double $x } result]
    19952035            if { $code != 0 || !$result } {
    1996                 set _settings($what) $_view($what)
     2036                set _settings($this-$who) $_view($who)
    19972037                return
    19982038            }
    1999             switch -- $what {
    2000                 "-xpan" - "-ypan" {
    2001                     set _view($what) $_settings($what)
     2039            switch -- $who {
     2040                "xpan" - "ypan" {
     2041                    set _view($who) $_settings($this-$who)
    20022042                    PanCamera
    20032043                }
    2004                 "-qx" - "-qy" - "-qz" - "-qw" {
    2005                     set _view($what) $_settings($what)
    2006                     set q [ViewToQuaternion]
     2044                "qx" - "qy" - "qz" - "qw" {
     2045                    set _view($who) $_settings($this-$who)
     2046                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    20072047                    $_arcball quaternion $q
    20082048                    SendCmd "camera orient $q"
    20092049                }
    2010                 "-zoom" {
    2011                     set _view($what) $_settings($what)
    2012                     SendCmd "camera zoom $_view($what)"
     2050                "zoom" {
     2051                    set _view($who) $_settings($this-$who)
     2052                    SendCmd "camera zoom $_view(zoom)"
    20132053                }
    20142054            }
     
    20502090        array set info $vol
    20512091        set name $info(name)
    2052         if { ![info exists _settings(-volumevisible-$name)] } {
    2053             set _settings(-volumevisible-$name) $info(hide)
     2092        if { ![info exists _settings($this-volume-$name)] } {
     2093            set _settings($this-volume-$name) $info(hide)
    20542094        }
    20552095        checkbutton $inner.vol$row -text $info(label) \
    2056             -variable [itcl::scope _settings(-volumevisible-$name)] \
     2096            -variable [itcl::scope _settings($this-volume-$name)] \
    20572097            -onvalue 0 -offvalue 1 \
    2058             -command [itcl::code $this ToggleVolume $key $name] \
     2098            -command [itcl::code $this volume $key $name] \
    20592099            -font "Arial 9"
    20602100        Rappture::Tooltip::for $inner.vol$row $info(description)
    20612101        blt::table $inner $row,0 $inner.vol$row -anchor w
    2062         if { !$_settings(-volume-$name) } {
     2102        if { !$_settings($this-volume-$name) } {
    20632103            $inner.vol$row select
    20642104        }
     
    20712111}
    20722112
    2073 itcl::body Rappture::NanovisViewer::ToggleVolume { tag name } {
    2074     set bool $_settings(-volumevisible-$name)
    2075     SendCmd "volume state $bool $name"
     2113itcl::body Rappture::NanovisViewer::volume { tag name } {
     2114    set bool $_settings($this-volume-$name)
     2115    SendCmd "volume statue $bool $name"
    20762116}
    20772117
     
    20852125        bottom "0.707107 0.707107 0 0"
    20862126    }
    2087     foreach name { -qw -qx -qy -qz } value $positions($side) {
     2127    foreach name { qw qx qy qz } value $positions($side) {
    20882128        set _view($name) $value
    20892129    }
    2090     set q [ViewToQuaternion]
     2130    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    20912131    $_arcball quaternion $q
    20922132    SendCmd "camera orient $q"
    20932133    SendCmd "camera reset"
    2094     set _view(-xpan) 0
    2095     set _view(-ypan) 0
    2096     set _view(-zoom) 1.0
    2097     set _settings(-xpan) $_view(-xpan)
    2098     set _settings(-ypan) $_view(-ypan)
    2099     set _settings(-zoom) $_view(-zoom)
    2100 }
    2101 
    2102 
    2103 #
    2104 # InitComponentSettings --
    2105 #
    2106 #    Initializes the volume settings for a specific component. This should
    2107 #    match what's used as global settings above. This is called the first
    2108 #    time we try to switch to a given component in SwitchComponent below.
    2109 #
    2110 itcl::body Rappture::NanovisViewer::InitComponentSettings { cname } {
    2111     foreach {key value} {
    2112         -colormap          "default"
    2113         -light             40
    2114         -light2side        1
    2115         -thickness         350
    2116         -volumeopacity     1.0
    2117         -volumevisible     1
    2118     } {
    2119         if { ![info exists _settings($cname${key})] } {
    2120             # Don't override existing component settings
    2121             set _settings($cname${key}) $value
    2122         }
    2123     }
    2124 }
    2125 
    2126 #
    2127 # SwitchComponent --
    2128 #
    2129 #    This is called when the current component is changed by the dropdown
    2130 #    menu in the volume tab.  It synchronizes the global volume settings
    2131 #    with the settings of the new current component.
    2132 #
    2133 itcl::body Rappture::NanovisViewer::SwitchComponent { cname } {
    2134     if { ![info exists _settings($cname-light)] } {
    2135         InitComponentSettings $cname
    2136     }
    2137     if { $_settings(-colormap) != $_settings($cname-colormap) } {
    2138         set _settings(-colormap)         $_settings($cname-colormap)
    2139         EventuallyRedrawLegend
    2140     }
    2141     # _settings variables change widgets, except for colormap
    2142     set _settings(-light)            $_settings($cname-light)
    2143     set _settings(-light2side)       $_settings($cname-light2side)
    2144     set _settings(-volumeopacity)    $_settings($cname-volumeopacity)
    2145     set _settings(-thickness)        $_settings($cname-thickness)
    2146     set _settings(-volumevisible)    $_settings($cname-volumevisible)
    2147     $itk_component(colormap) value   $_settings($cname-colormap)
    2148 
    2149     set _widget(-volumeopacity) [expr $_settings(-volumeopacity) * 100.0]
    2150 
    2151     set _current $cname;                # Reset the current component
    2152 }
    2153 
    2154 #
    2155 # BuildVolumeComponents --
    2156 #
    2157 #    This is called from the "scale" method which is called when a new
    2158 #    dataset is added or deleted.  It repopulates the dropdown menu of
    2159 #    volume component names.  It sets the current component to the first
    2160 #    component in the list (of components found).  Finally, if there is
    2161 #    only one component, don't display the label or the combobox in the
    2162 #    volume settings tab.
    2163 #
    2164 itcl::body Rappture::NanovisViewer::BuildVolumeComponents {} {
    2165     $itk_component(volcomponents) choices delete 0 end
    2166     foreach name $_componentsList {
    2167         $itk_component(volcomponents) choices insert end $name $name
    2168     }
    2169     set _current [lindex $_componentsList 0]
    2170     $itk_component(volcomponents) value $_current
    2171     set parent [winfo parent $itk_component(volcomponents)]
    2172     if { [llength $_componentsList] <= 1 } {
    2173         # Unpack the components label and dropdown if there's only one
    2174         # component.
    2175         blt::table forget $parent.volcomponents_l $parent.volcomponents
    2176     } else {
    2177         # Pack the components label and dropdown into the table there's
    2178         # more than one component to select.
    2179         blt::table $parent \
    2180             0,0 $parent.volcomponents_l -anchor e -cspan 2 \
    2181             0,2 $parent.volcomponents -cspan 3 -fill x
    2182     }
    2183 }
    2184 
    2185 #
    2186 # GetDatasetsWithComponents --
    2187 #
    2188 #    Returns a list of all the datasets (known by the combination of their
    2189 #    data object and component name) that match the given component name.
    2190 #    For example, this is used where we want to change the settings of
    2191 #    volumes that have the current component.
    2192 #
    2193 itcl::body Rappture::NanovisViewer::GetDatasetsWithComponent { cname } {
    2194     if { ![info exists _volcomponents($cname)] } {
    2195         return ""
    2196     }
    2197     set list ""
    2198     foreach tag $_volcomponents($cname) {
    2199         if { ![info exists _serverDatasets($tag)] } {
    2200             continue
    2201         }
    2202         lappend list $tag
    2203     }
    2204     return $list
    2205 }
    2206 
    2207 #
    2208 # HideAllMarkers --
    2209 #
    2210 #    Hide all the markers in all the transfer functions.  Can't simply
    2211 #    delete and recreate markers from the <style> since the user may have
    2212 #    created, deleted, or moved markers.
    2213 #
    2214 itcl::body Rappture::NanovisViewer::HideAllMarkers {} {
    2215     foreach cname [array names _transferFunctionEditors] {
    2216         $_transferFunctionEditors($cname) hideMarkers
    2217     }
    2218 }
    2219 
    2220 itcl::body Rappture::NanovisViewer::GetColormap { cname color } {
    2221     if { $color == "default" } {
    2222         return $_cname2defaultcolormap($cname)
    2223     }
    2224     return [ColorsToColormap $color]
    2225 }
    2226 
    2227 itcl::body Rappture::NanovisViewer::GetAlphamap { cname name } {
    2228     if { $name == "default" } {
    2229         return $_cname2defaultalphamap($cname)
    2230     }
    2231     return [NameToAlphamap $name]
    2232 }
    2233 
    2234 itcl::body Rappture::NanovisViewer::ResetColormap { cname color } {
    2235     # Get the current transfer function
    2236     if { ![info exists _cname2transferFunction($cname)] } {
    2237         return
    2238     }
    2239     foreach { cmap wmap } $_cname2transferFunction($cname) break
    2240     set cmap [GetColormap $cname $color]
    2241     set _cname2transferFunction($cname) [list $cmap $wmap]
    2242     SendCmd [list transfunc define $cname $cmap $wmap]
    2243     EventuallyRedrawLegend
    2244 }
    2245 
    2246 itcl::body Rappture::NanovisViewer::ComputeAlphamap { cname } {
    2247     if { ![info exists _transferFunctionEditors($cname)] } {
    2248         return [list 0.0 0.0 1.0 1.0]
    2249     }
    2250     if { ![info exists _settings($cname-light)] } {
    2251         InitComponentSettings $cname
    2252     }
    2253 
    2254     set isovalues [$_transferFunctionEditors($cname) values]
    2255 
    2256     # Transfer function should be normalized with [0,1] range
    2257     # The volume shading opacity setting is used to scale opacity
    2258     # in the volume shader.
    2259     set max 1.0
    2260 
    2261     # Use the component-wise thickness setting from the slider
    2262     # settings widget
    2263     # Scale values between 0.00001 and 0.01000
    2264     set delta [expr {double($_settings($cname-thickness)) * 0.0001}]
    2265    
    2266     set first [lindex $isovalues 0]
    2267     set last [lindex $isovalues end]
    2268     set wmap ""
    2269     if { $first == "" || $first != 0.0 } {
    2270         lappend wmap 0.0 0.0
    2271     }
    2272     foreach x $isovalues {
    2273         set x1 [expr {$x-$delta-0.00001}]
    2274         set x2 [expr {$x-$delta}]
    2275         set x3 [expr {$x+$delta}]
    2276         set x4 [expr {$x+$delta+0.00001}]
    2277         if { $x1 < 0.0 } {
    2278             set x1 0.0
    2279         } elseif { $x1 > 1.0 } {
    2280             set x1 1.0
    2281         }
    2282         if { $x2 < 0.0 } {
    2283             set x2 0.0
    2284         } elseif { $x2 > 1.0 } {
    2285             set x2 1.0
    2286         }
    2287         if { $x3 < 0.0 } {
    2288             set x3 0.0
    2289         } elseif { $x3 > 1.0 } {
    2290             set x3 1.0
    2291         }
    2292         if { $x4 < 0.0 } {
    2293             set x4 0.0
    2294         } elseif { $x4 > 1.0 } {
    2295             set x4 1.0
    2296         }
    2297         # add spikes in the middle
    2298         lappend wmap $x1 0.0
    2299         lappend wmap $x2 $max
    2300         lappend wmap $x3 $max
    2301         lappend wmap $x4 0.0
    2302     }
    2303     if { $last == "" || $last != 1.0 } {
    2304         lappend wmap 1.0 0.0
    2305     }
    2306     return $wmap
    2307 }
    2308 
    2309 itcl::body Rappture::NanovisViewer::NameToAlphamap { name } {
    2310     switch -- $name {
    2311         "ramp-up" {
    2312             set wmap {
    2313                 0.0 0.0
    2314                 1.0 1.0
    2315             }
    2316         }
    2317         "ramp-down" {
    2318             set wmap {
    2319                 0.0 1.0
    2320                 1.0 0.0
    2321             }
    2322         }
    2323         "vee" {
    2324             set wmap {
    2325                 0.0 1.0
    2326                 0.5 0.0
    2327                 1.0 1.0
    2328             }
    2329         }
    2330         "tent-1" {
    2331             set wmap {
    2332                 0.0 0.0
    2333                 0.5 1.0
    2334                 1.0 0.0
    2335             }
    2336         }
    2337         "tent-2" {
    2338             set wmap {
    2339                 0.0 0.0
    2340                 0.25 1.0
    2341                 0.5 0.0
    2342                 0.75 1.0
    2343                 1.0 0.0
    2344             }
    2345         }
    2346         "tent-3" {
    2347             set wmap {
    2348                 0.0 0.0
    2349                 0.16666 1.0
    2350                 0.33333 0.0
    2351                 0.5     1.0
    2352                 0.66666 0.0
    2353                 0.83333 1.0
    2354                 1.0 0.0
    2355             }
    2356         }
    2357         "tent-4" {
    2358             set wmap {
    2359                 0.0     0.0
    2360                 0.125   1.0
    2361                 0.25    0.0
    2362                 0.375   1.0
    2363                 0.5     0.0       
    2364                 0.625   1.0
    2365                 0.75    0.0
    2366                 0.875   1.0
    2367                 1.0     0.0
    2368             }
    2369         }
    2370         "sinusoid-1" {
    2371             set wmap {
    2372                 0.0                     0.000 0.600 0.800
    2373                 0.14285714285714285     0.400 0.900 1.000
    2374                 0.2857142857142857      0.600 1.000 1.000
    2375                 0.42857142857142855     0.800 1.000 1.000
    2376                 0.5714285714285714      0.900 0.900 0.900
    2377                 0.7142857142857143      0.600 0.600 0.600
    2378                 0.8571428571428571      0.400 0.400 0.400
    2379                 1.0                     0.200 0.200 0.200
    2380             }
    2381         }
    2382         "sinusoid-2" {
    2383             set wmap {
    2384                 0.0                     0.900 1.000 1.000
    2385                 0.1111111111111111      0.800 0.983 1.000
    2386                 0.2222222222222222      0.700 0.950 1.000
    2387                 0.3333333333333333      0.600 0.900 1.000
    2388                 0.4444444444444444      0.500 0.833 1.000
    2389                 0.5555555555555556      0.400 0.750 1.000
    2390                 0.6666666666666666      0.300 0.650 1.000
    2391                 0.7777777777777778      0.200 0.533 1.000
    2392                 0.8888888888888888      0.100 0.400 1.000
    2393                 1.0                     0.000 0.250 1.000
    2394             }
    2395         }
    2396         "sinusoid-6" {
    2397             set wmap {
    2398                 0.0                             0.200   0.100   0.000
    2399                 0.09090909090909091             0.400   0.187   0.000
    2400                 0.18181818181818182             0.600   0.379   0.210
    2401                 0.2727272727272727              0.800   0.608   0.480
    2402                 0.36363636363636365             0.850   0.688   0.595
    2403                 0.45454545454545453             0.950   0.855   0.808
    2404                 0.5454545454545454              0.800   0.993   1.000
    2405                 0.6363636363636364              0.600   0.973   1.000
    2406                 0.7272727272727273              0.400   0.940   1.000
    2407                 0.8181818181818182              0.200   0.893   1.000
    2408                 0.9090909090909091              0.000   0.667   0.800
    2409                 1.0                             0.000   0.480   0.600
    2410             }
    2411         }
    2412         "sinusoid-10" {
    2413             set wmap {
    2414                 0.0                             0.000   0.480   0.600
    2415                 0.09090909090909091             0.000   0.667   0.800
    2416                 0.18181818181818182             0.200   0.893   1.000
    2417                 0.2727272727272727              0.400   0.940   1.000
    2418                 0.36363636363636365             0.600   0.973   1.000
    2419                 0.45454545454545453             0.800   0.993   1.000
    2420                 0.5454545454545454              0.950   0.855   0.808
    2421                 0.6363636363636364              0.850   0.688   0.595
    2422                 0.7272727272727273              0.800   0.608   0.480
    2423                 0.8181818181818182              0.600   0.379   0.210
    2424                 0.9090909090909091              0.400   0.187   0.000
    2425                 1.0                             0.200   0.100   0.000
    2426             }
    2427         }
    2428         "step-2" {
    2429             set wmap {
    2430                 0.0                             0.000   0.167   1.000
    2431                 0.09090909090909091             0.100   0.400   1.000
    2432                 0.18181818181818182             0.200   0.600   1.000
    2433                 0.2727272727272727              0.400   0.800   1.000
    2434                 0.36363636363636365             0.600   0.933   1.000
    2435                 0.45454545454545453             0.800   1.000   1.000
    2436                 0.5454545454545454              1.000   1.000   0.800
    2437                 0.6363636363636364              1.000   0.933   0.600
    2438                 0.7272727272727273              1.000   0.800   0.400
    2439                 0.8181818181818182              1.000   0.600   0.200
    2440                 0.9090909090909091              1.000   0.400   0.100
    2441                 1.0                             1.000   0.167   0.000
    2442             }
    2443         }
    2444         "step-5" {
    2445             set wmap {
    2446                 0.0                             1.000   0.167   0.000
    2447                 0.09090909090909091             1.000   0.400   0.100
    2448                 0.18181818181818182             1.000   0.600   0.200
    2449                 0.2727272727272727              1.000   0.800   0.400
    2450                 0.36363636363636365             1.000   0.933   0.600
    2451                 0.45454545454545453             1.000   1.000   0.800
    2452                 0.5454545454545454              0.800   1.000   1.000
    2453                 0.6363636363636364              0.600   0.933   1.000
    2454                 0.7272727272727273              0.400   0.800   1.000
    2455                 0.8181818181818182              0.200   0.600   1.000
    2456                 0.9090909090909091              0.100   0.400   1.000
    2457                 1.0                             0.000   0.167   1.000
    2458             }
    2459         }
    2460         "step-12" {
    2461             set wmap {
    2462                 "#EE82EE"
    2463                 "#4B0082"
    2464                 "blue"
    2465                 "#008000"
    2466                 "yellow"
    2467                 "#FFA500"
    2468                 "red"
    2469             }
    2470         }
    2471         default {
    2472         }
    2473     }
    2474     return ""
    2475 }
    2476 
    2477 itcl::body Rappture::NanovisViewer::SetObjectStyle { dataobj cname } {
    2478     array set styles {
    2479         -opacity  0.5
    2480     }
    2481     array set styles [lindex [$dataobj components -style $cname] 0]
    2482     set _settings($cname-volumeopacity) $styles(-opacity)
    2483     set tag $dataobj-$cname
    2484     SendCmd "volume shading opacity $_settings($cname-volumeopacity) $tag"
    2485     NameTransferFunction $dataobj $cname
    2486 }
     2134    set _view(xpan) 0
     2135    set _view(ypan) 0
     2136    set _view(zoom) 1.0
     2137    set _settings($this-xpan) $_view(xpan)
     2138    set _settings($this-ypan) $_view(ypan)
     2139    set _settings($this-zoom) $_view(zoom)
     2140}
     2141
  • branches/1.3/gui/scripts/vtkglyphviewer.tcl

    r4768 r4848  
    11# -*- mode: tcl; indent-tabs-mode: nil -*-
     2
    23# ----------------------------------------------------------------------
    34#  COMPONENT: vtkglyphviewer - Vtk 3D glyphs object viewer
     
    78# ======================================================================
    89#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2004-2014  HUBzero Foundation, LLC
     10#  Copyright (c) 2004-2005  Purdue Research Foundation
    1011#
    1112#  See the file "license.terms" for information on usage and
     
    5758    public method get {args}
    5859    public method isconnected {}
     60    public method limits { colormap }
    5961    public method parameters {title args} {
    6062        # do nothing
     
    6264    public method scale {args}
    6365
     66    protected method Connect {}
     67    protected method CurrentDatasets {args}
     68    protected method Disconnect {}
     69    protected method DoResize {}
     70    protected method DoRotate {}
     71    protected method AdjustSetting {what {value ""}}
     72    protected method InitSettings { args  }
     73    protected method Pan {option x y}
     74    protected method Pick {x y}
     75    protected method Rebuild {}
     76    protected method ReceiveDataset { args }
     77    protected method ReceiveImage { args }
     78    protected method ReceiveLegend { colormap title vmin vmax size }
     79    protected method Rotate {option x y}
     80    protected method Zoom {option}
     81
    6482    # The following methods are only used by this class.
    65     private method AdjustSetting {what {value ""}}
    6683    private method BuildAxisTab {}
    6784    private method BuildCameraTab {}
     
    7289    private method DrawLegend {}
    7390    private method Combo { option }
    74     private method Connect {}
    75     private method CurrentDatasets {args}
    76     private method Disconnect {}
    77     private method DoResize {}
    78     private method DoRotate {}
    7991    private method EnterLegend { x y }
    8092    private method EventuallyResize { w h }
     
    8496    private method GetImage { args }
    8597    private method GetVtkData { args }
    86     private method InitSettings { args  }
    8798    private method IsValidObject { dataobj }
    8899    private method LeaveLegend {}
    89100    private method MotionLegend { x y }
    90     private method Pan {option x y}
    91101    private method PanCamera {}
    92     private method Pick {x y}
    93     private method QuaternionToView { q } {
    94         foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    95     }
    96     private method Rebuild {}
    97     private method ReceiveDataset { args }
    98     private method ReceiveImage { args }
    99     private method ReceiveLegend { colormap title vmin vmax size }
    100102    private method RequestLegend {}
    101     private method Rotate {option x y}
    102103    private method SetLegendTip { x y }
    103104    private method SetObjectStyle { dataobj comp }
     
    105106    private method SetCurrentColormap { color }
    106107    private method SetOrientation { side }
    107     private method ViewToQuaternion {} {
    108         return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    109     }
    110     private method Zoom {option}
    111108
    112109    private variable _arcball ""
     
    122119    # heightmaps displayed.
    123120    private variable _currentColormap ""
     121    private variable _currentOpacity ""
    124122
    125123    private variable _dataset2style    ;# maps dataobj-component to transfunc
     
    148146    private variable _legendPending 0
    149147    private variable _field      ""
    150     private variable _colorMode "vmag"; #  Mode of colormap (vmag or scalar)
     148    private variable _colorMode "vmag"; #  Mode of colormap (vmag or scalar)
    151149    private variable _fieldNames {}
    152150    private variable _fields
     
    186184    $_dispatcher register !xcutplane
    187185    $_dispatcher dispatch $this !xcutplane \
    188         "[itcl::code $this AdjustSetting -cutplanexposition]; list"
     186        "[itcl::code $this AdjustSetting cutplaneXPosition]; list"
    189187
    190188    # Y-Cutplane event
    191189    $_dispatcher register !ycutplane
    192190    $_dispatcher dispatch $this !ycutplane \
    193         "[itcl::code $this AdjustSetting -cutplaneyposition]; list"
     191        "[itcl::code $this AdjustSetting cutplaneYPosition]; list"
    194192
    195193    # Z-Cutplane event
    196194    $_dispatcher register !zcutplane
    197195    $_dispatcher dispatch $this !zcutplane \
    198         "[itcl::code $this AdjustSetting -cutplanezposition]; list"
     196        "[itcl::code $this AdjustSetting cutplaneZPosition]; list"
    199197
    200198    #
     
    207205    # Initialize the view to some default parameters.
    208206    array set _view {
    209         -ortho           0
    210         -qw              0.853553
    211         -qx              -0.353553
    212         -qy              0.353553
    213         -qz              0.146447
    214         -xpan            0
    215         -ypan            0
    216         -zoom            1.0
     207        qw              0.853553
     208        qx              -0.353553
     209        qy              0.353553
     210        qz              0.146447
     211        zoom            1.0
     212        xpan            0
     213        ypan            0
     214        ortho           0
    217215    }
    218216    set _arcball [blt::arcball create 100 100]
    219     $_arcball quaternion [ViewToQuaternion]
     217    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     218    $_arcball quaternion $q
    220219
    221220    array set _settings [subst {
    222         -axesvisible            1
    223         -axislabels             1
    224         -axisminorticks         1
    225         -axismode               "static"
    226         -background             black
    227         -colormap               BCGYR
    228         -colormapvisible        1
    229         -cutplaneedges          0
    230         -cutplanelighting       1
    231         -cutplanepreinterp      1
    232         -cutplaneopacity        100
    233         -cutplanevisible        0
    234         -cutplanewireframe      0
    235         -cutplanexposition      50
    236         -cutplanexvisible       1
    237         -cutplaneyposition      50
    238         -cutplaneyvisible       1
    239         -cutplanezposition      50
    240         -cutplanezvisible       1
    241         -field                  "Default"
    242         -glyphedges             0
    243         -glyphlighting          1
    244         -glyphnormscale         1
    245         -glyphopacity           100
    246         -glyphorient            1
    247         -glyphoutline           0
    248         -glyphscale             1
    249         -glyphscalemode         "vmag"
    250         -glyphshape             "arrow"
    251         -glyphvisible           1
    252         -glyphwireframe         0
    253         -legendvisible          1
    254         -saveglyphopacity       100
    255         -xgrid                  0
    256         -ygrid                  0
    257         -zgrid                  0
     221        background              black
     222        colormap                BCGYR
     223        colormapVisible         1
     224        field                   "Default"
     225        axesVisible             1
     226        axisLabelsVisible       1
     227        axisXGrid               0
     228        axisYGrid               0
     229        axisZGrid               0
     230        cutplaneEdges           0
     231        cutplaneLighting        1
     232        cutplanePreinterp       1
     233        cutplaneOpacity         100
     234        cutplaneVisible         0
     235        cutplaneWireframe       0
     236        cutplaneXPosition       50
     237        cutplaneXVisible        1
     238        cutplaneYPosition       50
     239        cutplaneYVisible        1
     240        cutplaneZPosition       50
     241        cutplaneZVisible        1
     242        glyphEdges              0
     243        glyphLighting           1
     244        glyphOpacity            100
     245        saveGlyphOpacity        100
     246        glyphOutline            0
     247        glyphVisible            1
     248        glyphWireframe          0
     249        legendVisible           1
    258250    }]
    259251    array set _changed {
    260         -colormap               0
    261         -glyphopacity           0
     252        glyphOpacity            0
     253        colormap                0
    262254    }
    263255
     
    339331            -onimage [Rappture::icon volume-on] \
    340332            -offimage [Rappture::icon volume-off] \
    341             -variable [itcl::scope _settings(-glyphvisible)] \
    342             -command [itcl::code $this AdjustSetting -glyphvisible]
     333            -variable [itcl::scope _settings(glyphVisible)] \
     334            -command [itcl::code $this AdjustSetting glyphVisible]
    343335    }
    344336    $itk_component(glyphs) select
     
    352344            -onimage [Rappture::icon cutbutton] \
    353345            -offimage [Rappture::icon cutbutton] \
    354             -variable [itcl::scope _settings(-cutplanevisible)] \
    355             -command [itcl::code $this AdjustSetting -cutplanevisible]
     346            -variable [itcl::scope _settings(cutplaneVisible)] \
     347            -command [itcl::code $this AdjustSetting cutplaneVisible]
    356348    }
    357349    Rappture::Tooltip::for $itk_component(cutplane) \
     
    443435    eval itk_initialize $args
    444436    Connect
     437    update
    445438}
    446439
     
    470463
    471464itcl::body Rappture::VtkGlyphViewer::DoRotate {} {
    472     SendCmd "camera orient [ViewToQuaternion]"
     465    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     466    SendCmd "camera orient $q"
    473467    set _rotatePending 0
    474468}
     
    494488
    495489itcl::body Rappture::VtkGlyphViewer::EventuallyRotate { q } {
    496     QuaternionToView $q
     490    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
    497491    if { !$_rotatePending } {
    498492        set _rotatePending 1
     
    549543}
    550544
     545
    551546# ----------------------------------------------------------------------
    552547# USAGE: delete ?<dataobj1> <dataobj2> ...?
    553548#
    554 #    Clients use this to delete a dataobj from the plot.  If no dataobjs
    555 #    are specified, then all dataobjs are deleted.  No data objects are
    556 #    deleted.  They are only removed from the display list.
     549#       Clients use this to delete a dataobj from the plot.  If no dataobjs
     550#       are specified, then all dataobjs are deleted.  No data objects are
     551#       deleted.  They are only removed from the display list.
    557552#
    558553# ----------------------------------------------------------------------
     
    804799# isconnected --
    805800#
    806 #    Indicates if we are currently connected to the visualization server.
     801#       Indicates if we are currently connected to the visualization server.
    807802#
    808803itcl::body Rappture::VtkGlyphViewer::isconnected {} {
     
    821816# Disconnect --
    822817#
    823 #    Clients use this method to disconnect from the current rendering
    824 #    server.
     818#       Clients use this method to disconnect from the current rendering
     819#       server.
    825820#
    826821itcl::body Rappture::VtkGlyphViewer::Disconnect {} {
     
    839834    array unset _data
    840835    array unset _colormaps
     836    array unset _seeds
    841837    array unset _dataset2style
    842838    array unset _obj2datasets
     
    860856    if { $info(-type) == "image" } {
    861857        if 0 {
    862             set f [open "last.ppm" "w"]
    863             fconfigure $f -encoding binary
    864             puts -nonewline $f $bytes
     858            set f [open "last.ppm" "w"]
     859            puts $f $bytes
    865860            close $f
    866861        }
     
    950945        # Reset the camera and other view parameters
    951946        #
    952         $_arcball quaternion [ViewToQuaternion]
    953         if {$_view(-ortho)} {
     947        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     948        $_arcball quaternion $q
     949        if {$_view(ortho)} {
    954950            SendCmd "camera mode ortho"
    955951        } else {
     
    959955        PanCamera
    960956        set _first ""
    961         InitSettings -xgrid -ygrid -zgrid -axismode \
    962             -axesvisible -axislabels -axisminorticks
    963         #SendCmd "axis lformat all %g"
     957        InitSettings axisXGrid axisYGrid axisZGrid axisMode \
     958            axesVisible axisLabelsVisible
     959        foreach axis { x y z } {
     960            SendCmd "axis lformat $axis %g"
     961        }
    964962        StopBufferingCommands
    965963        SendCmd "imgflush"
     
    977975            if { ![info exists _datasets($tag)] } {
    978976                set bytes [$dataobj vtkdata $comp]
    979                 if 0 {
    980                     set f [open "/tmp/glyph.vtk" "w"]
    981                     fconfigure $f -translation binary -encoding binary
    982                     puts -nonewline $f $bytes
    983                     close $f
     977                if 0 {
     978                    set f [open "/tmp/glyph.vtk" "w"]
     979                    puts $f $bytes
     980                    close $f
    984981                }
    985982                set length [string length $bytes]
     
    996993                    SendCmd "clientinfo [list $info]"
    997994                }
    998                 SendCmd "dataset add $tag data follows $length"
     995                append _outbuf "dataset add $tag data follows $length\n"
    999996                append _outbuf $bytes
    1000997                set _datasets($tag) 1
     
    10051002                # Setting dataset visible enables outline
    10061003                # and glyphs
    1007                 SendCmd "dataset visible 1 $tag"
     1004                SendCmd "dataset visible 1 $tag"
    10081005            }
    10091006        }
     
    10111008
    10121009    if { $_first != "" } {
    1013         $itk_component(field) choices delete 0 end
    1014         $itk_component(fieldmenu) delete 0 end
    1015         array unset _fields
     1010        $itk_component(field) choices delete 0 end
     1011        $itk_component(fieldmenu) delete 0 end
     1012        array unset _fields
    10161013        set _curFldName ""
    10171014        foreach cname [$_first components] {
     
    10391036        $itk_component(field) value $_curFldLabel
    10401037    }
    1041     InitSettings -glyphoutline
    1042         #-cutplanevisible
     1038    InitSettings glyphOutline
     1039        #cutplaneVisible
    10431040    if { $_reset } {
    1044         # These are settings that rely on a dataset being loaded.
     1041        # These are settings that rely on a dataset being loaded.
    10451042        InitSettings \
    1046             -field \
    1047             -glyphedges -glyphlighting -glyphopacity \
    1048             -glyphwireframe
    1049 
    1050         #-cutplanexposition -cutplaneyposition -cutplanezposition \
    1051             -cutplanexvisible -cutplaneyvisible -cutplanezvisible \
    1052             -cutplanepreinterp
     1043            glyphLighting \
     1044            field \
     1045            glyphEdges glyphLighting glyphOpacity \
     1046            glyphWireframe
     1047
     1048        #cutplaneXPosition cutplaneYPosition cutplaneZPosition \
     1049            cutplaneXVisible cutplaneYVisible cutplaneZVisible \
     1050            cutplanePreinterp
    10531051
    10541052        Zoom reset
    1055         foreach axis { x y z } {
     1053        foreach axis { x y z } {
    10561054            # Another problem fixed by a <view>. We looking into a data
    10571055            # object for the name of the axes. This should be global to
    10581056            # the viewer itself.
    1059             set label [$_first hints ${axis}label]
    1060             if { $label == "" } {
     1057            set label [$_first hints ${axis}label]
     1058            if { $label == "" } {
    10611059                set label [string toupper $axis]
    1062             }
    1063             # May be a space in the axis label.
    1064             SendCmd [list axis name $axis $label]
     1060            }
     1061            # May be a space in the axis label.
     1062            SendCmd [list axis name $axis $label]
    10651063        }
    10661064        if { [array size _fields] < 2 } {
    1067             catch {blt::table forget $itk_component(field) $itk_component(field_l)}
     1065            blt::table forget $itk_component(field) $itk_component(field_l)
    10681066        }
    10691067        set _reset 0
     
    11331131    switch -- $option {
    11341132        "in" {
    1135             set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1136             SendCmd "camera zoom $_view(-zoom)"
     1133            set _view(zoom) [expr {$_view(zoom)*1.25}]
     1134            SendCmd "camera zoom $_view(zoom)"
    11371135        }
    11381136        "out" {
    1139             set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1140             SendCmd "camera zoom $_view(-zoom)"
     1137            set _view(zoom) [expr {$_view(zoom)*0.8}]
     1138            SendCmd "camera zoom $_view(zoom)"
    11411139        }
    11421140        "reset" {
    11431141            array set _view {
    1144                 -qw      0.853553
    1145                 -qx      -0.353553
    1146                 -qy      0.353553
    1147                 -qz      0.146447
    1148                 -xpan    0
    1149                 -ypan    0
    1150                 -zoom    1.0
     1142                qw     0.853553
     1143                qx     -0.353553
     1144                qy     0.353553
     1145                qz     0.146447
     1146                zoom   1.0
     1147                xpan   0
     1148                ypan   0
    11511149            }
    11521150            if { $_first != "" } {
     
    11561154                }
    11571155            }
    1158             $_arcball quaternion [ViewToQuaternion]
     1156            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1157            $_arcball quaternion $q
    11591158            DoRotate
    11601159            SendCmd "camera reset"
     
    11641163
    11651164itcl::body Rappture::VtkGlyphViewer::PanCamera {} {
    1166     set x $_view(-xpan)
    1167     set y $_view(-ypan)
     1165    set x $_view(xpan)
     1166    set y $_view(ypan)
    11681167    SendCmd "camera pan $x $y"
    11691168}
     1169
    11701170
    11711171# ----------------------------------------------------------------------
     
    12231223itcl::body Rappture::VtkGlyphViewer::Pick {x y} {
    12241224    foreach tag [CurrentDatasets -visible] {
    1225         SendCmd "dataset getscalar pixel $x $y $tag"
     1225        SendCmdNoSplash "dataset getscalar pixel $x $y $tag"
    12261226    }
    12271227}
     
    12421242            set x [expr $x / double($w)]
    12431243            set y [expr $y / double($h)]
    1244             set _view(-xpan) [expr $_view(-xpan) + $x]
    1245             set _view(-ypan) [expr $_view(-ypan) + $y]
     1244            set _view(xpan) [expr $_view(xpan) + $x]
     1245            set _view(ypan) [expr $_view(ypan) + $y]
    12461246            PanCamera
    12471247            return
     
    12651265            set _click(x) $x
    12661266            set _click(y) $y
    1267             set _view(-xpan) [expr $_view(-xpan) - $dx]
    1268             set _view(-ypan) [expr $_view(-ypan) - $dy]
     1267            set _view(xpan) [expr $_view(xpan) - $dx]
     1268            set _view(ypan) [expr $_view(ypan) - $dy]
    12691269            PanCamera
    12701270        }
     
    12881288itcl::body Rappture::VtkGlyphViewer::InitSettings { args } {
    12891289    foreach spec $args {
    1290         if { [info exists _settings($_first${spec})] } {
     1290        if { [info exists _settings($_first-$spec)] } {
    12911291            # Reset global setting with dataobj specific setting
    1292             set _settings($spec) $_settings($_first${spec})
     1292            set _settings($spec) $_settings($_first-$spec)
    12931293        }
    12941294        AdjustSetting $spec
     
    12991299# AdjustSetting --
    13001300#
    1301 #    Changes/updates a specific setting in the widget.  There are
    1302 #    usually user-setable option.  Commands are sent to the render
    1303 #    server.
     1301#       Changes/updates a specific setting in the widget.  There are
     1302#       usually user-setable option.  Commands are sent to the render
     1303#       server.
    13041304#
    13051305itcl::body Rappture::VtkGlyphViewer::AdjustSetting {what {value ""}} {
     
    13081308    }
    13091309    switch -- $what {
    1310         "-background" {
     1310        "background" {
    13111311            set bgcolor [$itk_component(background) value]
    1312             array set fgcolors {
    1313                 "black" "white"
    1314                 "white" "black"
    1315                 "grey"  "black"
    1316             }
     1312            array set fgcolors {
     1313                "black" "white"
     1314                "white" "black"
     1315                "grey"  "black"
     1316            }
    13171317            configure -plotbackground $bgcolor \
    1318                 -plotforeground $fgcolors($bgcolor)
    1319             $itk_component(view) delete "legend"
    1320             DrawLegend
    1321         }
    1322         "-axesvisible" {
    1323             set bool $_settings($what)
     1318                -plotforeground $fgcolors($bgcolor)
     1319            $itk_component(view) delete "legend"
     1320            DrawLegend
     1321        }
     1322        "axesVisible" {
     1323            set bool $_settings(axesVisible)
    13241324            SendCmd "axis visible all $bool"
    13251325        }
    1326         "-axislabels" {
    1327             set bool $_settings($what)
     1326        "axisLabelsVisible" {
     1327            set bool $_settings(axisLabelsVisible)
    13281328            SendCmd "axis labels all $bool"
    13291329        }
    1330         "-axisminorticks" {
    1331             set bool $_settings($what)
    1332             SendCmd "axis minticks all $bool"
    1333         }
    1334         "-xgrid" - "-ygrid" - "-zgrid" {
    1335             set axis [string tolower [string range $what 1 1]]
     1330        "axisXGrid" - "axisYGrid" - "axisZGrid" {
     1331            set axis [string tolower [string range $what 4 4]]
    13361332            set bool $_settings($what)
    13371333            SendCmd "axis grid $axis $bool"
    13381334        }
    1339         "-axismode" {
     1335        "axisMode" {
    13401336            set mode [$itk_component(axisMode) value]
    13411337            set mode [$itk_component(axisMode) translate $mode]
     
    13431339            SendCmd "axis flymode $mode"
    13441340        }
    1345         "-cutplaneedges" {
     1341        "cutplaneEdges" {
    13461342            set bool $_settings($what)
    13471343            SendCmd "cutplane edges $bool"
    13481344        }
    1349         "-cutplanevisible" {
     1345        "cutplaneVisible" {
    13501346            set bool $_settings($what)
    1351             SendCmd "cutplane visible 0"
    1352             if { $bool } {
    1353                 foreach tag [CurrentDatasets -visible] {
    1354                     SendCmd "cutplane visible $bool $tag"
    1355                 }
    1356             }
    1357         }
    1358         "-cutplanewireframe" {
     1347            SendCmd "cutplane visible $bool"
     1348        }
     1349        "cutplaneWireframe" {
    13591350            set bool $_settings($what)
    13601351            SendCmd "cutplane wireframe $bool"
    13611352        }
    1362         "-cutplanelighting" {
     1353        "cutplaneLighting" {
    13631354            set bool $_settings($what)
    13641355            SendCmd "cutplane lighting $bool"
    13651356        }
    1366         "-cutplaneopacity" {
     1357        "cutplaneOpacity" {
    13671358            set val $_settings($what)
    13681359            set sval [expr { 0.01 * double($val) }]
    13691360            SendCmd "cutplane opacity $sval"
    13701361        }
    1371         "-cutplanepreinterp" {
     1362        "cutplanePreinterp" {
    13721363            set bool $_settings($what)
    13731364            SendCmd "cutplane preinterp $bool"
    13741365        }
    1375         "-cutplanexvisible" - "-cutplaneyvisible" - "-cutplanezvisible" {
    1376             set axis [string tolower [string range $what 9 9]]
     1366        "cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" {
     1367            set axis [string tolower [string range $what 8 8]]
    13771368            set bool $_settings($what)
    13781369            if { $bool } {
     
    13831374                    -troughcolor grey82
    13841375            }
    1385             SendCmd "cutplane axis $axis $bool"
    1386         }
    1387         "-cutplanexposition" - "-cutplaneyposition" - "-cutplanezposition" {
    1388             set axis [string tolower [string range $what 9 9]]
     1376            SendCmd "cutplane axis $axis $bool"
     1377        }
     1378        "cutplaneXPosition" - "cutplaneYPosition" - "cutplaneZPosition" {
     1379            set axis [string tolower [string range $what 8 8]]
    13891380            set pos [expr $_settings($what) * 0.01]
    13901381            SendCmd "cutplane slice ${axis} ${pos}"
    13911382            set _cutplanePending 0
    13921383        }
    1393         "-colormap" {
    1394             set _changed($what) 1
     1384        "colormap" {
     1385            set _changed(colormap) 1
    13951386            StartBufferingCommands
    13961387            set color [$itk_component(colormap) value]
    1397             set _settings($what) $color
    1398             if { $color == "none" } {
    1399                 if { $_settings(-colormapvisible) } {
    1400                     SendCmd "glyphs colormode constant {}"
    1401                     set _settings(-colormapvisible) 0
    1402                 }
    1403             } else {
    1404                 if { !$_settings(-colormapvisible) } {
    1405                     SendCmd "glyphs colormode $_colorMode $_curFldName"
    1406                     set _settings(-colormapvisible) 1
    1407                 }
    1408                 SetCurrentColormap $color
    1409             }
     1388            set _settings(colormap) $color
     1389            if { $color == "none" } {
     1390                if { $_settings(colormapVisible) } {
     1391                    SendCmd "glyphs colormode constant {}"
     1392                    set _settings(colormapVisible) 0
     1393                }
     1394            } else {
     1395                if { !$_settings(colormapVisible) } {
     1396                    SendCmd "glyphs colormode $_colorMode $_curFldName"
     1397                    set _settings(colormapVisible) 1
     1398                }
     1399                SetCurrentColormap $color
     1400            }
    14101401            StopBufferingCommands
    1411             EventuallyRequestLegend
    1412         }
    1413         "-glyphwireframe" {
    1414             set bool $_settings($what)
    1415             SendCmd "glyphs wireframe $bool"
    1416         }
    1417         "-glyphvisible" {
    1418             set bool $_settings($what)
    1419             SendCmd "glyphs visible 0"
    1420             if { $bool } {
    1421                 foreach tag [CurrentDatasets -visible] {
    1422                     SendCmd "glyphs visible $bool $tag"
    1423                 }
    1424             }
     1402            EventuallyRequestLegend
     1403        }
     1404        "glyphWireframe" {
     1405            set bool $_settings(glyphWireframe)
     1406            SendCmd "glyphs wireframe $bool"
     1407        }
     1408        "glyphVisible" {
     1409            set bool $_settings(glyphVisible)
     1410            SendCmd "glyphs visible $bool"
    14251411            if { $bool } {
    14261412                Rappture::Tooltip::for $itk_component(glyphs) \
     
    14301416                    "Show the glyph"
    14311417            }
    1432             DrawLegend
    1433         }
    1434         "-glyphlighting" {
    1435             set bool $_settings($what)
    1436             SendCmd "glyphs lighting $bool"
    1437         }
    1438         "-glyphedges" {
    1439             set bool $_settings($what)
    1440             SendCmd "glyphs edges $bool"
    1441         }
    1442         "-glyphoutline" {
    1443             set bool $_settings($what)
    1444             SendCmd "outline visible 0"
    1445             if { $bool } {
    1446                 foreach tag [CurrentDatasets -visible] {
    1447                     SendCmd "outline visible $bool $tag"
    1448                 }
    1449             }
    1450         }
    1451         "-glyphopacity" {
    1452             set val $_settings($what)
     1418            DrawLegend
     1419        }
     1420        "glyphLighting" {
     1421            set bool $_settings(glyphLighting)
     1422            SendCmd "glyphs lighting $bool"
     1423        }
     1424        "glyphEdges" {
     1425            set bool $_settings(glyphEdges)
     1426            SendCmd "glyphs edges $bool"
     1427        }
     1428        "glyphOutline" {
     1429            set bool $_settings(glyphOutline)
     1430            SendCmd "outline visible $bool"
     1431        }
     1432        "glyphOpacity" {
     1433            set val $_settings(glyphOpacity)
    14531434            set sval [expr { 0.01 * double($val) }]
    1454             SendCmd "glyphs opacity $sval"
    1455         }
    1456         "-glyphnormscale" {
    1457             set bool $_settings($what)
    1458             SendCmd "glyphs normscale $bool"
    1459         }
    1460         "-glyphorient" {
    1461             set bool $_settings($what)
    1462             SendCmd "glyphs gorient $bool {}"
    1463         }
    1464         "-glyphscale" {
    1465             set val $_settings($what)
    1466             if { [string is double $val] } {
    1467                 SendCmd "glyphs gscale $val"
    1468             }
    1469         }
    1470         "-glyphscalemode" {
    1471             set label [$itk_component(scaleMode) value]
    1472             set mode [$itk_component(scaleMode) translate $label]
    1473             set _settings($what) $mode
    1474             SendCmd "glyphs smode $mode {}"
    1475         }
    1476         "-glyphshape" {
    1477             set label [$itk_component(gshape) value]
    1478             set shape [$itk_component(gshape) translate $label]
    1479             set _settings($what) $shape
    1480             SendCmd "glyphs shape $shape"
    1481         }
    1482         "-field" {
     1435            SendCmd "glyphs opacity $sval"
     1436        }
     1437        "field" {
    14831438            set label [$itk_component(field) value]
    14841439            set fname [$itk_component(field) translate $label]
    1485             set _settings($what) $fname
     1440            set _settings(field) $fname
    14861441            if { [info exists _fields($fname)] } {
    14871442                foreach { label units components } $_fields($fname) break
     
    14971452                return
    14981453            }
    1499             #if { ![info exists _limits($_curFldName)] } {
    1500             #    SendCmd "dataset maprange all"
    1501             #} else {
    1502             #    SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"
    1503             #}
     1454            #SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"
    15041455            #SendCmd "cutplane colormode $_colorMode $_curFldName"
    15051456            SendCmd "glyphs colormode $_colorMode $_curFldName"
    15061457            DrawLegend
    15071458        }
    1508         "-legendvisible" {
    1509             if { !$_settings($what) } {
     1459        "legendVisible" {
     1460            if { !$_settings(legendVisible) } {
    15101461                $itk_component(view) delete legend
    1511             }
    1512             DrawLegend
     1462            }
     1463            DrawLegend
    15131464        }
    15141465        default {
     
    15181469}
    15191470
     1471
    15201472#
    15211473# RequestLegend --
    15221474#
    1523 #    Request a new legend from the server.  The size of the legend
    1524 #    is determined from the height of the canvas. 
     1475#       Request a new legend from the server.  The size of the legend
     1476#       is determined from the height of the canvas. 
    15251477#
    15261478# This should be called when
    1527 #    1.  A new current colormap is set.
    1528 #    2.  Window is resized.
    1529 #    3.  The limits of the data have changed.  (Just need a redraw).
    1530 #    4.  Number of glyph have changed. (Just need a redraw).
    1531 #    5.  Legend becomes visible (Just need a redraw).
     1479#       1.  A new current colormap is set.
     1480#       2.  Window is resized.
     1481#       3.  The limits of the data have changed.  (Just need a redraw).
     1482#       4.  Number of glyph have changed. (Just need a redraw).
     1483#       5.  Legend becomes visible (Just need a redraw).
    15321484#
    15331485itcl::body Rappture::VtkGlyphViewer::RequestLegend {} {
    15341486    set _legendPending 0
     1487    if { ![info exists _fields($_curFldName)] } {
     1488        return
     1489    }
     1490    set fname $_curFldName
    15351491    set font "Arial 8"
     1492    set lineht [font metrics $font -linespace]
    15361493    set w 12
    1537     set lineht [font metrics $font -linespace]
    1538     # color ramp height = (canvas height) - (min and max value lines) - 2
    15391494    set h [expr {$_height - 2 * ($lineht + 2)}]
    1540 
    1541     set fname $_curFldName
     1495    if { $h < 1 } {
     1496        return
     1497    }
    15421498    if { [string match "component*" $fname] } {
    1543         set title ""
     1499        set title ""
    15441500    } else {
    1545         if { [info exists _fields($fname)] } {
    1546             foreach { title units } $_fields($fname) break
    1547             if { $units != "" } {
    1548                 set title [format "%s (%s)" $title $units]
    1549             }
    1550         } else {
    1551             set title $fname
    1552         }
     1501        if { [info exists _fields($fname)] } {
     1502            foreach { title units } $_fields($fname) break
     1503            if { $units != "" } {
     1504                set title [format "%s (%s)" $title $units]
     1505            }
     1506        } else {
     1507            set title $fname
     1508        }
    15531509    }
    15541510    # If there's a title too, substract one more line
     
    15561512        incr h -$lineht
    15571513    }
    1558     if { $h < 1 } {
    1559         return
    1560     }
    15611514    # Set the legend on the first heightmap dataset.
    15621515    if { $_currentColormap != ""  } {
    1563         set cmap $_currentColormap
    1564         SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0"
     1516        set cmap $_currentColormap
     1517        SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0"
    15651518    }
    15661519}
     
    15821535    if { [isconnected] } {
    15831536        set rgb [Color2RGB $itk_option(-plotforeground)]
    1584         SendCmd "axis color all $rgb"
     1537        SendCmd "axis color all $rgb"
    15851538        SendCmd "outline color $rgb"
    15861539        #SendCmd "cutplane color $rgb"
    15871540    }
     1541}
     1542
     1543itcl::body Rappture::VtkGlyphViewer::limits { dataobj } {
     1544    foreach { limits(xmin) limits(xmax) } [$dataobj limits x] break
     1545    foreach { limits(ymin) limits(ymax) } [$dataobj limits y] break
     1546    foreach { limits(zmin) limits(zmax) } [$dataobj limits z] break
     1547    foreach { limits(vmin) limits(vmax) } [$dataobj limits v] break
     1548    return [array get limits]
    15881549}
    15891550
     
    16001561    checkbutton $inner.glyphs \
    16011562        -text "Glyphs" \
    1602         -variable [itcl::scope _settings(-glyphvisible)] \
    1603         -command [itcl::code $this AdjustSetting -glyphvisible] \
     1563        -variable [itcl::scope _settings(glyphVisible)] \
     1564        -command [itcl::code $this AdjustSetting glyphVisible] \
    16041565        -font "Arial 9"
    1605 
    1606     label $inner.gshape_l -text "Glyph shape" -font "Arial 9"
    1607     itk_component add gshape {
    1608         Rappture::Combobox $inner.gshape -width 10 -editable no
    1609     }
    1610     $inner.gshape choices insert end \
    1611         "arrow"              "arrow"           \
    1612         "cone"               "cone"            \
    1613         "cube"               "cube"            \
    1614         "cylinder"           "cylinder"        \
    1615         "dodecahedron"       "dodecahedron"    \
    1616         "icosahedron"        "icosahedron"     \
    1617         "line"               "line"            \
    1618         "octahedron"         "octahedron"      \
    1619         "point"              "point"           \
    1620         "sphere"             "sphere"          \
    1621         "tetrahedron"        "tetrahedron"
    1622 
    1623     $itk_component(gshape) value $_settings(-glyphshape)
    1624     bind $inner.gshape <<Value>> [itcl::code $this AdjustSetting -glyphshape]
    1625 
    1626     label $inner.scaleMode_l -text "Scale by" -font "Arial 9"
    1627     itk_component add scaleMode {
    1628         Rappture::Combobox $inner.scaleMode -width 10 -editable no
    1629     }
    1630     $inner.scaleMode choices insert end \
    1631         "scalar" "Scalar"            \
    1632         "vmag"   "Vector magnitude"  \
    1633         "vcomp"  "Vector components" \
    1634         "off"    "Constant size"
    1635 
    1636     $itk_component(scaleMode) value "[$itk_component(scaleMode) label $_settings(-glyphscalemode)]"
    1637     bind $inner.scaleMode <<Value>> [itcl::code $this AdjustSetting -glyphscalemode]
    1638 
    1639     checkbutton $inner.normscale \
    1640         -text "Normalize scaling" \
    1641         -variable [itcl::scope _settings(-glyphnormscale)] \
    1642         -command [itcl::code $this AdjustSetting -glyphnormscale] \
    1643         -font "Arial 9"
    1644     Rappture::Tooltip::for $inner.normscale "If enabled, field values are normalized to \[0,1\] before scaling and scale factor is relative to a default size"
    1645 
    1646     checkbutton $inner.gorient \
    1647         -text "Orient" \
    1648         -variable [itcl::scope _settings(-glyphorient)] \
    1649         -command [itcl::code $this AdjustSetting -glyphorient] \
    1650         -font "Arial 9"
    1651     Rappture::Tooltip::for $inner.gorient "Orient glyphs by vector field directions"
    16521566
    16531567    checkbutton $inner.wireframe \
    16541568        -text "Wireframe" \
    1655         -variable [itcl::scope _settings(-glyphwireframe)] \
    1656         -command [itcl::code $this AdjustSetting -glyphwireframe] \
     1569        -variable [itcl::scope _settings(glyphWireframe)] \
     1570        -command [itcl::code $this AdjustSetting glyphWireframe] \
    16571571        -font "Arial 9"
    16581572
    16591573    checkbutton $inner.lighting \
    16601574        -text "Enable Lighting" \
    1661         -variable [itcl::scope _settings(-glyphlighting)] \
    1662         -command [itcl::code $this AdjustSetting -glyphlighting] \
     1575        -variable [itcl::scope _settings(glyphLighting)] \
     1576        -command [itcl::code $this AdjustSetting glyphLighting] \
    16631577        -font "Arial 9"
    16641578
    16651579    checkbutton $inner.edges \
    16661580        -text "Edges" \
    1667         -variable [itcl::scope _settings(-glyphedges)] \
    1668         -command [itcl::code $this AdjustSetting -glyphedges] \
     1581        -variable [itcl::scope _settings(glyphEdges)] \
     1582        -command [itcl::code $this AdjustSetting glyphEdges] \
    16691583        -font "Arial 9"
    16701584
    16711585    checkbutton $inner.outline \
    16721586        -text "Outline" \
    1673         -variable [itcl::scope _settings(-glyphoutline)] \
    1674         -command [itcl::code $this AdjustSetting -glyphoutline] \
     1587        -variable [itcl::scope _settings(glyphOutline)] \
     1588        -command [itcl::code $this AdjustSetting glyphOutline] \
    16751589        -font "Arial 9"
    16761590
    16771591    checkbutton $inner.legend \
    16781592        -text "Legend" \
    1679         -variable [itcl::scope _settings(-legendvisible)] \
    1680         -command [itcl::code $this AdjustSetting -legendvisible] \
     1593        -variable [itcl::scope _settings(legendVisible)] \
     1594        -command [itcl::code $this AdjustSetting legendVisible] \
    16811595        -font "Arial 9"
    16821596
     
    16901604        "grey"               "grey"             
    16911605
    1692     $itk_component(background) value $_settings(-background)
    1693     bind $inner.background <<Value>> [itcl::code $this AdjustSetting -background]
     1606    $itk_component(background) value $_settings(background)
     1607    bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]
    16941608
    16951609    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    16961610    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1697         -variable [itcl::scope _settings(-glyphopacity)] \
     1611        -variable [itcl::scope _settings(glyphOpacity)] \
    16981612        -width 10 \
    16991613        -showvalue off \
    1700         -command [itcl::code $this AdjustSetting -glyphopacity]
    1701 
    1702     label $inner.gscale_l -text "Scale factor" -font "Arial 9"
    1703     if {0} {
    1704     ::scale $inner.gscale -from 1 -to 100 -orient horizontal \
    1705         -variable [itcl::scope _settings(-glyphscale)] \
     1614        -command [itcl::code $this AdjustSetting glyphOpacity]
     1615
     1616    label $inner.scale_l -text "Scale" -font "Arial 9"
     1617    ::scale $inner.scale -from 1 -to 100 -orient horizontal \
     1618        -variable [itcl::scope _settings(glyphs-scale)] \
    17061619        -width 10 \
    17071620        -showvalue off \
    1708         -command [itcl::code $this AdjustSetting -glyphscale]
    1709     } else {
    1710     itk_component add gscale {
    1711         entry $inner.gscale -font "Arial 9" -bg white \
    1712             -textvariable [itcl::scope _settings(-glyphscale)]
    1713     } {
    1714         ignore -font -background
    1715     }
    1716     bind $inner.gscale <Return> \
    1717         [itcl::code $this AdjustSetting -glyphscale]
    1718     bind $inner.gscale <KP_Enter> \
    1719         [itcl::code $this AdjustSetting -glyphscale]
    1720     }
    1721     Rappture::Tooltip::for $inner.gscale "Set scaling multiplier (or constant size)"
     1621        -command [itcl::code $this AdjustSetting glyphs-scale]
    17221622
    17231623    itk_component add field_l {
     
    17301630    }
    17311631    bind $inner.field <<Value>> \
    1732         [itcl::code $this AdjustSetting -field]
     1632        [itcl::code $this AdjustSetting field]
    17331633
    17341634    label $inner.colormap_l -text "Colormap" -font "Arial 9"
     
    17361636        Rappture::Combobox $inner.colormap -width 10 -editable no
    17371637    }
    1738 
    1739     $inner.colormap choices insert end [GetColormapList]
     1638    $inner.colormap choices insert end \
     1639        "BCGYR"              "BCGYR"            \
     1640        "BGYOR"              "BGYOR"            \
     1641        "blue"               "blue"             \
     1642        "blue-to-brown"      "blue-to-brown"    \
     1643        "blue-to-orange"     "blue-to-orange"   \
     1644        "blue-to-grey"       "blue-to-grey"     \
     1645        "green-to-magenta"   "green-to-magenta" \
     1646        "greyscale"          "greyscale"        \
     1647        "nanohub"            "nanohub"          \
     1648        "rainbow"            "rainbow"          \
     1649        "spectral"           "spectral"         \
     1650        "ROYGB"              "ROYGB"            \
     1651        "RYGCB"              "RYGCB"            \
     1652        "brown-to-blue"      "brown-to-blue"    \
     1653        "grey-to-blue"       "grey-to-blue"     \
     1654        "orange-to-blue"     "orange-to-blue"   
     1655
    17401656    $itk_component(colormap) value "BCGYR"
    17411657    bind $inner.colormap <<Value>> \
    1742         [itcl::code $this AdjustSetting -colormap]
     1658        [itcl::code $this AdjustSetting colormap]
    17431659
    17441660    blt::table $inner \
    1745         0,0 $inner.field_l      -anchor w -pady 2  \
    1746         0,1 $inner.field        -anchor w -pady 2  -fill x \
    1747         1,0 $inner.colormap_l   -anchor w -pady 2  \
    1748         1,1 $inner.colormap     -anchor w -pady 2  -fill x \
    1749         3,0 $inner.background_l -anchor w -pady 2 \
    1750         3,1 $inner.background  -anchor w -pady 2  -fill x \
    1751         5,0 $inner.wireframe    -anchor w -pady 2 -cspan 2 \
    1752         6,0 $inner.lighting     -anchor w -pady 2 -cspan 2 \
    1753         7,0 $inner.edges        -anchor w -pady 2 -cspan 2 \
    1754         8,0 $inner.outline      -anchor w -pady 2 -cspan 2 \
    1755         9,0 $inner.legend       -anchor w -pady 2 \
    1756         10,0 $inner.opacity_l   -anchor w -pady 2 \
    1757         10,1 $inner.opacity     -fill x   -pady 2 -fill x \
     1661        0,0 $inner.field_l   -anchor w -pady 2  \
     1662        0,1 $inner.field     -anchor w -pady 2  -fill x \
     1663        1,0 $inner.colormap_l -anchor w -pady 2  \
     1664        1,1 $inner.colormap   -anchor w -pady 2  -fill x \
     1665        3,0 $inner.background_l -anchor w -pady 2 \
     1666        3,1 $inner.background -anchor w -pady 2  -fill x \
     1667        5,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \
     1668        6,0 $inner.lighting  -anchor w -pady 2 -cspan 2 \
     1669        7,0 $inner.edges     -anchor w -pady 2 -cspan 2 \
     1670        8,0 $inner.outline   -anchor w -pady 2 -cspan 2 \
     1671        9,0 $inner.legend    -anchor w -pady 2 \
     1672        10,0 $inner.opacity_l -anchor w -pady 2 \
     1673        10,1 $inner.opacity   -fill x   -pady 2 -fill x \
    17581674
    17591675    blt::table configure $inner r* c* -resize none
     
    17721688
    17731689    checkbutton $inner.visible \
    1774         -text "Axes" \
    1775         -variable [itcl::scope _settings(-axesvisible)] \
    1776         -command [itcl::code $this AdjustSetting -axesvisible] \
     1690        -text "Show Axes" \
     1691        -variable [itcl::scope _settings(axesVisible)] \
     1692        -command [itcl::code $this AdjustSetting axesVisible] \
    17771693        -font "Arial 9"
    17781694
    17791695    checkbutton $inner.labels \
    1780         -text "Axis Labels" \
    1781         -variable [itcl::scope _settings(-axislabels)] \
    1782         -command [itcl::code $this AdjustSetting -axislabels] \
     1696        -text "Show Axis Labels" \
     1697        -variable [itcl::scope _settings(axisLabelsVisible)] \
     1698        -command [itcl::code $this AdjustSetting axisLabelsVisible] \
    17831699        -font "Arial 9"
    1784     label $inner.grid_l -text "Grid" -font "Arial 9"
    1785     checkbutton $inner.xgrid \
    1786         -text "X" \
    1787         -variable [itcl::scope _settings(-xgrid)] \
    1788         -command [itcl::code $this AdjustSetting -xgrid] \
     1700
     1701    checkbutton $inner.gridx \
     1702        -text "Show X Grid" \
     1703        -variable [itcl::scope _settings(axisXGrid)] \
     1704        -command [itcl::code $this AdjustSetting axisXGrid] \
    17891705        -font "Arial 9"
    1790     checkbutton $inner.ygrid \
    1791         -text "Y" \
    1792         -variable [itcl::scope _settings(-ygrid)] \
    1793         -command [itcl::code $this AdjustSetting -ygrid] \
     1706    checkbutton $inner.gridy \
     1707        -text "Show Y Grid" \
     1708        -variable [itcl::scope _settings(axisYGrid)] \
     1709        -command [itcl::code $this AdjustSetting axisYGrid] \
    17941710        -font "Arial 9"
    1795     checkbutton $inner.zgrid \
    1796         -text "Z" \
    1797         -variable [itcl::scope _settings(-zgrid)] \
    1798         -command [itcl::code $this AdjustSetting -zgrid] \
    1799         -font "Arial 9"
    1800     checkbutton $inner.minorticks \
    1801         -text "Minor Ticks" \
    1802         -variable [itcl::scope _settings(-axisminorticks)] \
    1803         -command [itcl::code $this AdjustSetting -axisminorticks] \
     1711    checkbutton $inner.gridz \
     1712        -text "Show Z Grid" \
     1713        -variable [itcl::scope _settings(axisZGrid)] \
     1714        -command [itcl::code $this AdjustSetting axisZGrid] \
    18041715        -font "Arial 9"
    18051716
     
    18141725        "furthest_triad"  "farthest" \
    18151726        "outer_edges"     "outer"         
    1816     $itk_component(axisMode) value $_settings(-axismode)
    1817     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
     1727    $itk_component(axisMode) value "static"
     1728    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisMode]
    18181729
    18191730    blt::table $inner \
    1820         0,0 $inner.visible    -anchor w -cspan 4 \
    1821         1,0 $inner.labels     -anchor w -cspan 4 \
    1822         2,0 $inner.minorticks -anchor w -cspan 4 \
    1823         4,0 $inner.grid_l     -anchor w \
    1824         4,1 $inner.xgrid      -anchor w \
    1825         4,2 $inner.ygrid      -anchor w \
    1826         4,3 $inner.zgrid      -anchor w \
    1827         5,0 $inner.mode_l     -anchor w -padx { 2 0 } \
    1828         5,1 $inner.mode       -fill x   -cspan 3
     1731        0,0 $inner.visible -anchor w -cspan 2 \
     1732        1,0 $inner.labels  -anchor w -cspan 2 \
     1733        2,0 $inner.gridx   -anchor w -cspan 2 \
     1734        3,0 $inner.gridy   -anchor w -cspan 2 \
     1735        4,0 $inner.gridz   -anchor w -cspan 2 \
     1736        5,0 $inner.mode_l  -anchor w -cspan 2 -padx { 2 0 } \
     1737        6,0 $inner.mode    -fill x   -cspan 2
    18291738
    18301739    blt::table configure $inner r* c* -resize none
    1831     blt::table configure $inner r7 c6 -resize expand
    1832     blt::table configure $inner r3 -height 0.125i
    1833 }
     1740    blt::table configure $inner r7 c1 -resize expand
     1741}
     1742
    18341743
    18351744itcl::body Rappture::VtkGlyphViewer::BuildCameraTab {} {
     
    18511760        0,0 $inner.view_l -anchor e -pady 2 \
    18521761        0,1 $inner.view -anchor w -pady 2
    1853     blt::table configure $inner r0 -resize none
    18541762
    18551763    set labels { qx qy qz qw xpan ypan zoom }
     
    18581766        label $inner.${tag}label -text $tag -font "Arial 9"
    18591767        entry $inner.${tag} -font "Arial 9"  -bg white \
    1860             -textvariable [itcl::scope _view(-$tag)]
    1861         bind $inner.${tag} <Return> \
    1862             [itcl::code $this camera set -${tag}]
    1863         bind $inner.${tag} <KP_Enter> \
    1864             [itcl::code $this camera set -${tag}]
     1768            -textvariable [itcl::scope _view($tag)]
     1769        bind $inner.${tag} <KeyPress-Return> \
     1770            [itcl::code $this camera set ${tag}]
    18651771        blt::table $inner \
    18661772            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    18711777    checkbutton $inner.ortho \
    18721778        -text "Orthographic Projection" \
    1873         -variable [itcl::scope _view(-ortho)] \
    1874         -command [itcl::code $this camera set -ortho] \
     1779        -variable [itcl::scope _view(ortho)] \
     1780        -command [itcl::code $this camera set ortho] \
    18751781        -font "Arial 9"
    18761782    blt::table $inner \
     
    18791785    incr row
    18801786
    1881     blt::table configure $inner c* -resize none
     1787    blt::table configure $inner c* r* -resize none
    18821788    blt::table configure $inner c2 -resize expand
    18831789    blt::table configure $inner r$row -resize expand
     
    18961802    checkbutton $inner.visible \
    18971803        -text "Cutplanes" \
    1898         -variable [itcl::scope _settings(-cutplanevisible)] \
    1899         -command [itcl::code $this AdjustSetting -cutplanevisible] \
     1804        -variable [itcl::scope _settings(cutplaneVisible)] \
     1805        -command [itcl::code $this AdjustSetting cutplaneVisible] \
    19001806        -font "Arial 9"
    19011807
    19021808    checkbutton $inner.wireframe \
    19031809        -text "Wireframe" \
    1904         -variable [itcl::scope _settings(-cutplanewireframe)] \
    1905         -command [itcl::code $this AdjustSetting -cutplanewireframe] \
     1810        -variable [itcl::scope _settings(cutplaneWireframe)] \
     1811        -command [itcl::code $this AdjustSetting cutplaneWireframe] \
    19061812        -font "Arial 9"
    19071813
    19081814    checkbutton $inner.lighting \
    19091815        -text "Enable Lighting" \
    1910         -variable [itcl::scope _settings(-cutplanelighting)] \
    1911         -command [itcl::code $this AdjustSetting -cutplanelighting] \
     1816        -variable [itcl::scope _settings(cutplaneLighting)] \
     1817        -command [itcl::code $this AdjustSetting cutplaneLighting] \
    19121818        -font "Arial 9"
    19131819
    19141820    checkbutton $inner.edges \
    19151821        -text "Edges" \
    1916         -variable [itcl::scope _settings(-cutplaneedges)] \
    1917         -command [itcl::code $this AdjustSetting -cutplaneedges] \
     1822        -variable [itcl::scope _settings(cutplaneEdges)] \
     1823        -command [itcl::code $this AdjustSetting cutplaneEdges] \
    19181824        -font "Arial 9"
    19191825
    19201826    checkbutton $inner.preinterp \
    19211827        -text "Interpolate Scalars" \
    1922         -variable [itcl::scope _settings(-cutplanepreinterp)] \
    1923         -command [itcl::code $this AdjustSetting -cutplanepreinterp] \
     1828        -variable [itcl::scope _settings(cutplanePreinterp)] \
     1829        -command [itcl::code $this AdjustSetting cutplanePreinterp] \
    19241830        -font "Arial 9"
    19251831
    19261832    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    19271833    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1928         -variable [itcl::scope _settings(-cutplaneopacity)] \
     1834        -variable [itcl::scope _settings(cutplaneOpacity)] \
    19291835        -width 10 \
    19301836        -showvalue off \
    1931         -command [itcl::code $this AdjustSetting -cutplaneopacity]
    1932     $inner.opacity set $_settings(-cutplaneopacity)
     1837        -command [itcl::code $this AdjustSetting cutplaneOpacity]
     1838    $inner.opacity set $_settings(cutplaneOpacity)
    19331839
    19341840    # X-value slicer...
     
    19371843            -onimage [Rappture::icon x-cutplane-red] \
    19381844            -offimage [Rappture::icon x-cutplane-red] \
    1939             -command [itcl::code $this AdjustSetting -cutplanexvisible] \
    1940             -variable [itcl::scope _settings(-cutplanexvisible)] \
     1845            -command [itcl::code $this AdjustSetting cutplaneXVisible] \
     1846            -variable [itcl::scope _settings(cutplaneXVisible)] \
    19411847    }
    19421848    Rappture::Tooltip::for $itk_component(xbutton) \
     
    19481854            -borderwidth 1 -highlightthickness 0 \
    19491855            -command [itcl::code $this EventuallySetCutplane x] \
    1950             -variable [itcl::scope _settings(-cutplanexposition)] \
    1951             -foreground red2 -font "Arial 9 bold"
     1856            -variable [itcl::scope _settings(cutplaneXPosition)] \
     1857            -foreground red2 -font "Arial 9 bold"
    19521858    } {
    19531859        usual
     
    19651871            -onimage [Rappture::icon y-cutplane-green] \
    19661872            -offimage [Rappture::icon y-cutplane-green] \
    1967             -command [itcl::code $this AdjustSetting -cutplaneyvisible] \
    1968             -variable [itcl::scope _settings(-cutplaneyvisible)] \
     1873            -command [itcl::code $this AdjustSetting cutplaneYVisible] \
     1874            -variable [itcl::scope _settings(cutplaneYVisible)] \
    19691875    }
    19701876    Rappture::Tooltip::for $itk_component(ybutton) \
     
    19771883            -borderwidth 1 -highlightthickness 0 \
    19781884            -command [itcl::code $this EventuallySetCutplane y] \
    1979             -variable [itcl::scope _settings(-cutplaneyposition)] \
    1980             -foreground green3 -font "Arial 9 bold"
     1885            -variable [itcl::scope _settings(cutplaneYPosition)] \
     1886            -foreground green3 -font "Arial 9 bold"
    19811887    } {
    19821888        usual
     
    19941900            -onimage [Rappture::icon z-cutplane-blue] \
    19951901            -offimage [Rappture::icon z-cutplane-blue] \
    1996             -command [itcl::code $this AdjustSetting -cutplanezvisible] \
    1997             -variable [itcl::scope _settings(-cutplanezvisible)] \
     1902            -command [itcl::code $this AdjustSetting cutplaneZVisible] \
     1903            -variable [itcl::scope _settings(cutplaneZVisible)] \
    19981904    } {
    1999         usual
    2000         ignore -foreground
     1905        usual
     1906        ignore -foreground
    20011907    }
    20021908    Rappture::Tooltip::for $itk_component(zbutton) \
     
    20091915            -borderwidth 1 -highlightthickness 0 \
    20101916            -command [itcl::code $this EventuallySetCutplane z] \
    2011             -variable [itcl::scope _settings(-cutplanezposition)] \
    2012             -foreground blue3 -font "Arial 9 bold"
     1917            -variable [itcl::scope _settings(cutplaneZPosition)] \
     1918            -foreground blue3 -font "Arial 9 bold"
    20131919    } {
    20141920        usual
     
    20211927
    20221928    blt::table $inner \
    2023         0,0 $inner.visible   -anchor w -pady 2 -cspan 3 \
    2024         1,0 $inner.lighting  -anchor w -pady 2 -cspan 3 \
    2025         2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \
    2026         3,0 $inner.edges     -anchor w -pady 2 -cspan 3 \
    2027         4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \
    2028         5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \
    2029         5,1 $inner.opacity   -fill x   -pady 2 -cspan 3 \
    2030         6,0 $inner.xbutton   -anchor w -padx 2 -pady 2 \
    2031         7,0 $inner.ybutton   -anchor w -padx 2 -pady 2 \
    2032         8,0 $inner.zbutton   -anchor w -padx 2 -pady 2 \
    2033         6,1 $inner.xval      -fill y -rspan 4 \
    2034         6,2 $inner.yval      -fill y -rspan 4 \
    2035         6,3 $inner.zval      -fill y -rspan 4 \
     1929        0,0 $inner.visible              -anchor w -pady 2 -cspan 3 \
     1930        1,0 $inner.lighting             -anchor w -pady 2 -cspan 3 \
     1931        2,0 $inner.wireframe            -anchor w -pady 2 -cspan 3 \
     1932        3,0 $inner.edges                -anchor w -pady 2 -cspan 3 \
     1933        4,0 $inner.preinterp            -anchor w -pady 2 -cspan 3 \
     1934        5,0 $inner.opacity_l            -anchor w -pady 2 -cspan 1 \
     1935        5,1 $inner.opacity              -fill x   -pady 2 -cspan 3 \
     1936        6,0 $inner.xbutton              -anchor w -padx 2 -pady 2 \
     1937        7,0 $inner.ybutton              -anchor w -padx 2 -pady 2 \
     1938        8,0 $inner.zbutton              -anchor w -padx 2 -pady 2 \
     1939        6,1 $inner.xval                 -fill y -rspan 4 \
     1940        6,2 $inner.yval                 -fill y -rspan 4 \
     1941        6,3 $inner.zval                 -fill y -rspan 4 \
     1942
    20361943
    20371944    blt::table configure $inner r* c* -resize none
    20381945    blt::table configure $inner r9 c4 -resize expand
    20391946}
     1947
     1948
    20401949
    20411950#
     
    20481957        }
    20491958        "set" {
    2050             set what [lindex $args 0]
    2051             set x $_view($what)
     1959            set who [lindex $args 0]
     1960            set x $_view($who)
    20521961            set code [catch { string is double $x } result]
    20531962            if { $code != 0 || !$result } {
    20541963                return
    20551964            }
    2056             switch -- $what {
    2057                 "-ortho" {
    2058                     if {$_view($what)} {
     1965            switch -- $who {
     1966                "ortho" {
     1967                    if {$_view(ortho)} {
    20591968                        SendCmd "camera mode ortho"
    20601969                    } else {
     
    20621971                    }
    20631972                }
    2064                 "-xpan" - "-ypan" {
     1973                "xpan" - "ypan" {
    20651974                    PanCamera
    20661975                }
    2067                 "-qx" - "-qy" - "-qz" - "-qw" {
    2068                     set q [ViewToQuaternion]
     1976                "qx" - "qy" - "qz" - "qw" {
     1977                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    20691978                    $_arcball quaternion $q
    20701979                    EventuallyRotate $q
    20711980                }
    2072                 "-zoom" {
    2073                     SendCmd "camera zoom $_view($what)"
     1981                "zoom" {
     1982                    SendCmd "camera zoom $_view(zoom)"
    20741983                }
    20751984             }
     
    21892098    # the code to handle aberrant cases.
    21902099
    2191     if { $_changed(-glyphopacity) } {
    2192         set style(-opacity) [expr $_settings(-glyphopacity) * 0.01]
    2193     }
    2194     if { $_changed(-colormap) } {
    2195         set style(-color) $_settings(-colormap)
     2100    if { $_changed(glyphOpacity) } {
     2101        set style(-opacity) $_settings(glyphOpacity)
     2102    }
     2103    if { $_changed(colormap) } {
     2104        set style(-color) $_settings(colormap)
    21962105    }
    21972106    if { $_currentColormap == "" } {
    21982107        $itk_component(colormap) value $style(-color)
    21992108    }
    2200 
     2109    set _currentOpacity $style(-opacity)
     2110    SendCmd "glyphs add $style(-shape) $tag"
     2111    SendCmd "glyphs edges $style(-edges) $tag"
     2112    # normscale=1 and gscale=1 are defaults
     2113    if {$style(-normscale) != 1} {
     2114        SendCmd "glyphs normscale $style(-normscale) $tag"
     2115    }
     2116    if {$style(-gscale) != 1} {
     2117        SendCmd "glyphs gscale $style(-gscale) $tag"
     2118    }
    22012119    SendCmd "outline add $tag"
    22022120    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
    22032121    SendCmd "outline visible $style(-outline) $tag"
    2204     set _settings(-glyphoutline) $style(-outline)
    2205 
    2206     SendCmd "glyphs add $style(-shape) $tag"
    2207     set _settings(-glyphshape) $style(-shape)
    2208     $itk_component(gshape) value $style(-shape)
    2209     SendCmd "glyphs edges $style(-edges) $tag"
    2210     set _settings(-glyphedges) $style(-edges)
    2211 
    2212     # normscale=1 and gscale=1 are defaults
    2213     if {$style(-normscale) != 1} {
    2214         SendCmd "glyphs normscale $style(-normscale) $tag"
    2215     }
    2216     if {$style(-gscale) != 1} {
    2217         SendCmd "glyphs gscale $style(-gscale) $tag"
    2218     }
    2219     set _settings(-glyphnormscale) $style(-normscale)
    2220     set _settings(-glyphscale) $style(-gscale)
    2221 
     2122    set _settings(glyphOutline) $style(-outline)
     2123    set _settings(glyphEdges) $style(-edges)
    22222124    # constant color only used if colormode set to constant
    22232125    SendCmd "glyphs color [Color2RGB $itk_option(-plotforeground)] $tag"
     
    22252127    # defaults to active scalars or vectors depending on mode
    22262128    SendCmd "glyphs gorient $style(-orientGlyphs) {} $tag"
    2227     set _settings(-glyphorient) $style(-orientGlyphs)
    22282129    SendCmd "glyphs smode $style(-scaleMode) {} $tag"
    2229     set _settings(-glyphscalemode) $style(-scaleMode)
    2230     $itk_component(scaleMode) value "[$itk_component(scaleMode) label $style(-scaleMode)]"
    22312130    SendCmd "glyphs quality $style(-quality) $tag"
    22322131    SendCmd "glyphs lighting $style(-lighting) $tag"
    2233     set _settings(-glyphlighting) $style(-lighting)
     2132    set _settings(glyphLighting) $style(-lighting)
    22342133    SendCmd "glyphs linecolor [Color2RGB $style(-edgecolor)] $tag"
    22352134    SendCmd "glyphs linewidth $style(-linewidth) $tag"
    22362135    SendCmd "glyphs ptsize $style(-ptsize) $tag"
    2237     SendCmd "glyphs opacity $style(-opacity) $tag"
    2238     set _settings(-glyphopacity) [expr $style(-opacity) * 100.0]
     2136    SendCmd "glyphs opacity $_currentOpacity $tag"
     2137    set _settings(glyphOpacity) $style(-opacity)
    22392138    SetCurrentColormap $style(-color)
    22402139    SendCmd "glyphs wireframe $style(-wireframe) $tag"
    2241     set _settings(-glyphwireframe) $style(-wireframe)
     2140    set _settings(glyphWireframe) $style(-wireframe)
     2141    set _settings(glyphOpacity) [expr $style(-opacity) * 100.0]
    22422142}
    22432143
     
    22932193
    22942194    if { [string match "component*" $fname] } {
    2295         set title ""
     2195        set title ""
    22962196    } else {
    2297         if { [info exists _fields($fname)] } {
    2298             foreach { title units } $_fields($fname) break
    2299             if { $units != "" } {
    2300                 set title [format "%s (%s)" $title $units]
    2301             }
    2302         } else {
    2303             set title $fname
    2304         }
     2197        if { [info exists _fields($fname)] } {
     2198            foreach { title units } $_fields($fname) break
     2199            if { $units != "" } {
     2200                set title [format "%s (%s)" $title $units]
     2201            }
     2202        } else {
     2203            set title $fname
     2204        }
    23052205    }
    23062206    # If there's a legend title, increase the offset by the line height.
     
    23342234}
    23352235
     2236
    23362237# ----------------------------------------------------------------------
    23372238# USAGE: Slice move x|y|z <newval>
     
    23672268# ReceiveLegend --
    23682269#
    2369 #    Invoked automatically whenever the "legend" command comes in from
    2370 #    the rendering server.  Indicates that binary image data with the
    2371 #    specified <size> will follow.
     2270#       Invoked automatically whenever the "legend" command comes in from
     2271#       the rendering server.  Indicates that binary image data with the
     2272#       specified <size> will follow.
    23722273#
    23732274itcl::body Rappture::VtkGlyphViewer::ReceiveLegend { colormap title min max size } {
     
    23832284        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    23842285        if { [catch {DrawLegend} errs] != 0 } {
    2385             global errorInfo
    2386             puts stderr "errs=$errs errorInfo=$errorInfo"
     2286            global errorInfo
     2287            puts stderr "errs=$errs errorInfo=$errorInfo"
    23872288        }
    23882289    }
     
    23922293# DrawLegend --
    23932294#
    2394 #    Draws the legend in the own canvas on the right side of the plot area.
     2295#       Draws the legend in the own canvas on the right side of the plot area.
    23952296#
    23962297itcl::body Rappture::VtkGlyphViewer::DrawLegend {} {
     
    24032304   
    24042305    if { [string match "component*" $fname] } {
    2405         set title ""
     2306        set title ""
    24062307    } else {
    2407         if { [info exists _fields($fname)] } {
    2408             foreach { title units } $_fields($fname) break
    2409             if { $units != "" } {
    2410                 set title [format "%s (%s)" $title $units]
    2411             }
    2412         } else {
    2413             set title $fname
    2414         }
     2308        if { [info exists _fields($fname)] } {
     2309            foreach { title units } $_fields($fname) break
     2310            if { $units != "" } {
     2311                set title [format "%s (%s)" $title $units]
     2312            }
     2313        } else {
     2314            set title $fname
     2315        }
    24152316    }
    24162317    set x [expr $w - 2]
    2417     if { !$_settings(-legendvisible) } {
    2418         $c delete legend
    2419         return
     2318    if { !$_settings(legendVisible) } {
     2319        $c delete legend
     2320        return
    24202321    }
    24212322    if { [$c find withtag "legend"] == "" } {
    2422         set y 2
    2423         # If there's a legend title, create a text item for the title.
     2323        set y 2
     2324        # If there's a legend title, create a text item for the title.
    24242325        $c create text $x $y \
    2425             -anchor ne \
    2426             -fill $itk_option(-plotforeground) -tags "title legend" \
    2427             -font $font
    2428         if { $title != "" } {
    2429             incr y $lineht
    2430         }
    2431         $c create text $x $y \
    2432             -anchor ne \
    2433             -fill $itk_option(-plotforeground) -tags "vmax legend" \
    2434             -font $font
    2435         incr y $lineht
    2436         $c create image $x $y \
    2437             -anchor ne \
    2438             -image $_image(legend) -tags "colormap legend"
    2439         $c create rectangle $x $y 1 1 \
    2440             -fill "" -outline "" -tags "sensor legend"
    2441         $c create text $x [expr {$h-2}] \
    2442             -anchor se \
    2443             -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2444             -font $font
    2445         $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
    2446         $c bind sensor <Leave> [itcl::code $this LeaveLegend]
    2447         $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
     2326                -anchor ne \
     2327                -fill $itk_option(-plotforeground) -tags "title legend" \
     2328                -font $font
     2329            incr y $lineht
     2330        $c create text $x $y \
     2331            -anchor ne \
     2332            -fill $itk_option(-plotforeground) -tags "vmax legend" \
     2333            -font $font
     2334        incr y $lineht
     2335        $c create image $x $y \
     2336            -anchor ne \
     2337            -image $_image(legend) -tags "colormap legend"
     2338        $c create rectangle $x $y 1 1 \
     2339            -fill "" -outline "" -tags "sensor legend"
     2340        $c create text $x [expr {$h-2}] \
     2341            -anchor se \
     2342            -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2343            -font $font
     2344        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
     2345        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2346        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
    24482347    }
    24492348    set x2 $x
     
    24592358    if { [info exists _limits($_curFldName)] } {
    24602359        foreach { vmin vmax } $_limits($_curFldName) break
    2461         $c itemconfigure vmin -text [format %g $vmin]
    2462         $c itemconfigure vmax -text [format %g $vmax]
     2360        $c itemconfigure vmin -text [format %g $vmin]
     2361        $c itemconfigure vmax -text [format %g $vmax]
    24632362    }
    24642363    set y 2
     
    24662365    if { $title != "" } {
    24672366        $c itemconfigure title -text $title
    2468         $c coords title $x $y
    2469         incr y $lineht
     2367        $c coords title $x $y
     2368        incr y $lineht
    24702369        $c raise title
    24712370    }
     
    25092408        invoke {
    25102409            $itk_component(field) value $_curFldLabel
    2511             AdjustSetting -field
     2410            AdjustSetting field
    25122411        }
    25132412        default {
     
    25332432# BuildColormap --
    25342433#
    2535 #    Build the designated colormap on the server.
     2434#       Build the designated colormap on the server.
    25362435#
    25372436itcl::body Rappture::VtkGlyphViewer::BuildColormap { name } {
     
    25532452        bottom "0.707107 0.707107 0 0"
    25542453    }
    2555     foreach name { -qw -qx -qy -qz } value $positions($side) {
     2454    foreach name { qw qx qy qz } value $positions($side) {
    25562455        set _view($name) $value
    2557     }
    2558     set q [ViewToQuaternion]
     2456    } 
     2457    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    25592458    $_arcball quaternion $q
    25602459    SendCmd "camera orient $q"
    25612460    SendCmd "camera reset"
    2562     set _view(-xpan) 0
    2563     set _view(-ypan) 0
    2564     set _view(-zoom) 1.0
    2565 }
     2461    set _view(xpan) 0
     2462    set _view(ypan) 0
     2463    set _view(zoom) 1.0
     2464}
     2465
  • branches/1.3/gui/scripts/vtkheightmapviewer.tcl

    r4770 r4848  
    77# ======================================================================
    88#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2004-2014  HUBzero Foundation, LLC
     9#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1010#
    1111#  See the file "license.terms" for information on usage and
     
    5858    public method get {args}
    5959    public method isconnected {}
     60    public method limits3 { dataobj }
    6061    public method parameters {title args} {
    6162        # do nothing
     
    6364    public method scale {args}
    6465
     66    protected method CameraReset {}
     67    protected method Connect {}
     68    protected method CurrentDatasets {args}
     69    protected method Disconnect {}
     70    protected method DoResize {}
     71    protected method DoRotate {}
     72    protected method AdjustSetting {what {value ""}}
     73    protected method AdjustMode {}
     74    protected method InitSettings { args  }
     75    protected method Pan {option x y}
     76    protected method Pick {x y}
     77    protected method Rebuild {}
     78    protected method ReceiveDataset { args }
     79    protected method ReceiveImage { args }
     80    protected method ReceiveLegend { colormap title min max size }
     81    protected method Rotate {option x y}
     82    protected method Zoom {option}
     83
    6584    # The following methods are only used by this class.
    66     private method AdjustSetting {what {value ""}}
    6785    private method BuildAxisTab {}
    6886    private method BuildCameraTab {}
     
    7088    private method BuildContourTab {}
    7189    private method BuildDownloadPopup { widget command }
    72     private method CameraReset {}
    7390    private method Combo { option }
    74     private method Connect {}
    75     private method CurrentDatasets {args}
    76     private method Disconnect {}
    77     private method DoResize {}
    78     private method DoRotate {}
    7991    private method DrawLegend {}
    8092    private method EnterLegend { x y }
    8193    private method EventuallyRequestLegend {}
    8294    private method EventuallyResize { w h }
    83     private method EventuallyRotate { q }
    84     private method GetHeightmapScale {}
     95    private method EventuallyRotate { q }
    8596    private method GetImage { args }
    8697    private method GetVtkData { args }
    87     private method InitSettings { args  }
    8898    private method IsValidObject { dataobj }
    8999    private method LeaveLegend {}
    90100    private method MotionLegend { x y }
    91     private method Pan {option x y}
    92101    private method PanCamera {}
    93     private method Pick {x y}
    94     private method QuaternionToView { q } {
    95         foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    96     }
    97     private method Rebuild {}
    98     private method ReceiveDataset { args }
    99     private method ReceiveImage { args }
    100     private method ReceiveLegend { colormap title min max size }
    101102    private method RequestLegend {}
    102     private method ResetAxes {}
    103     private method Rotate {option x y}
    104103    private method SetCurrentColormap { color }
    105104    private method SetLegendTip { x y }
    106105    private method SetObjectStyle { dataobj comp }
     106    private method GetHeightmapScale {}
     107    private method ResetAxes {}
    107108    private method SetOrientation { side }
    108109    private method UpdateContourList {}
    109     private method ViewToQuaternion {} {
    110         return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    111     }
    112     private method Zoom {option}
    113110
    114111    private variable _arcball ""
     
    126123    private variable _currentColormap ""
    127124    private variable _currentNumIsolines -1
     125    private variable _currentOpacity ""
    128126
    129127    private variable _maxScale 100;     # This is the # of times the x-axis
     
    205203    # Initialize the view to some default parameters.
    206204    array set _view {
    207         -ortho           0
    208         -qw              0.36
    209         -qx              0.25
    210         -qy              0.50
    211         -qz              0.70
    212         -xpan            0
    213         -ypan            0
    214         -zoom            1.0
     205        qw      0.36
     206        qx      0.25
     207        qy      0.50
     208        qz      0.70
     209        zoom    1.0
     210        xpan    0
     211        ypan    0
     212        ortho   0
    215213    }
    216214    set _arcball [blt::arcball create 100 100]
    217     $_arcball quaternion [ViewToQuaternion]
     215    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     216    $_arcball quaternion $q
    218217
    219218    array set _settings {
    220         -axisflymode            "static"
    221         -axislabels             1
    222         -axisminorticks         1
    223         -axisvisible            1
    224         -colormap               BCGYR
    225         -colormapdiscrete       0
    226         -colormapvisible        1
    227         -edges                  0
    228         -field                  "Default"
    229         -heightmapscale         50
    230         -isheightmap            0
    231         -isolinecolor           black
    232         -isolinesvisible        1
    233         -legendvisible          1
    234         -lighting               1
    235         -numisolines            10
    236         -opacity                100
    237         -outline                0
    238         -savelighting           1
    239         -saveopacity            100
    240         -saveoutline            0
    241         -stretchtofit           0
    242         -wireframe              0
    243         -xgrid                  0
    244         -ygrid                  0
    245         -zgrid                  0
     219        axisFlymode             "static"
     220        axisMinorTicks          1
     221        stretchToFit            0
     222        axisLabels              1
     223        axisVisible             1
     224        axisXGrid               0
     225        axisYGrid               0
     226        axisZGrid               0
     227        colormapVisible         1
     228        colormapDiscrete        0
     229        edges                   0
     230        field                   "Default"
     231        heightmapScale          50
     232        isHeightmap             0
     233        isolineColor            black
     234        isolinesVisible         1
     235        legendVisible           1
     236        lighting                1
     237        saveLighting            1
     238        numIsolines             10
     239        opacity                 100
     240        outline                 0
     241        wireframe               0
     242        saveOpacity             100
     243        saveOutline             0
    246244    }
    247245    array set _changed {
    248         -colormap               0
    249         -numisolines            0
    250         -opacity                0
     246        opacity                 0
     247        colormap                0
     248        numIsolines             0
    251249    }
    252250    itk_component add view {
     
    327325            -onimage [Rappture::icon surface] \
    328326            -offimage [Rappture::icon surface] \
    329             -variable [itcl::scope _settings(-isheightmap)] \
    330             -command [itcl::code $this AdjustSetting -isheightmap] \
     327            -variable [itcl::scope _settings(isHeightmap)] \
     328            -command [itcl::code $this AdjustSetting isHeightmap] \
    331329    }
    332330    Rappture::Tooltip::for $itk_component(mode) \
     
    338336            -onimage [Rappture::icon stretchtofit] \
    339337            -offimage [Rappture::icon stretchtofit] \
    340             -variable [itcl::scope _settings(-stretchtofit)] \
    341             -command [itcl::code $this AdjustSetting -stretchtofit] \
     338            -variable [itcl::scope _settings(stretchToFit)] \
     339            -command [itcl::code $this AdjustSetting stretchToFit] \
    342340    }
    343341    Rappture::Tooltip::for $itk_component(stretchtofit) \
     
    444442
    445443itcl::body Rappture::VtkHeightmapViewer::DoRotate {} {
    446     SendCmd "camera orient [ViewToQuaternion]"
     444    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     445    SendCmd "camera orient $q"
    447446    set _rotatePending 0
    448447}
     
    468467
    469468itcl::body Rappture::VtkHeightmapViewer::EventuallyRotate { q } {
    470     QuaternionToView $q
     469    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
    471470    if { !$_rotatePending } {
    472471        set _rotatePending 1
     
    667666    }
    668667    if { [array size found] > 1 } {
    669         set _settings(-stretchtofit) 1
     668        set _settings(stretchToFit) 1
    670669    } else {
    671670        # Check if the range of the x and y axes requires that we stretch
     
    676675        if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) ||
    677676             ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } {
    678             set _settings(-stretchtofit) 1
     677            set _settings(stretchToFit) 1
    679678        }
    680679    }
     
    843842    if { $info(-type) == "image" } {
    844843        if 0 {
    845             set f [open "last.ppm" "w"]
    846             fconfigure $f -encoding binary
    847             puts -nonewline $f $bytes
     844            set f [open "last.ppm" "w"]
     845            puts $f $bytes
    848846            close $f
    849847        }
     
    930928        $_arcball resize $w $h
    931929        DoResize
    932         if { $_settings(-stretchtofit) } {
    933             AdjustSetting -stretchtofit
     930        if { $_settings(stretchToFit) } {
     931            AdjustSetting stretchToFit
    934932        }
    935933    }
     
    938936        # Reset the camera and other view parameters
    939937        #
    940         InitSettings -isheightmap -background
    941 
    942         # Setting a custom exponent and label format for axes is causing
    943         # a problem with rounding.  Near zero ticks aren't rounded by
    944         # the %g format.  The VTK CubeAxes seem to currently work best
    945         # when allowed to automatically set the exponent and precision
    946         # based on the axis ranges.  This does tend to result in less
    947         # visual clutter, so I think it is best to use the automatic
    948         # settings by default.  We can test more fine-grained
    949         # controls on the axis settings tab if necessary.
    950         # -Leif
    951         #SendCmd "axis exp 0 0 0 1"
     938        InitSettings isHeightmap background
     939
     940        # Let's see how this goes.  I think it's preferable to overloading the
     941        # axis title with the exponent.
     942        SendCmd "axis exp 0 0 0 1"
    952943
    953944        SendCmd "axis lrot z 90"
    954         $_arcball quaternion [ViewToQuaternion]
    955         if {$_settings(-isheightmap) } {
    956             if { $_view(-ortho)} {
     945        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     946        $_arcball quaternion $q
     947        if {$_settings(isHeightmap) } {
     948            if { $_view(ortho)} {
    957949                SendCmd "camera mode ortho"
    958950            } else {
     
    983975                if 0 {
    984976                    set f [open /tmp/vtkheightmap.vtk "w"]
    985                     fconfigure $f -translation binary -encoding binary
    986                     puts -nonewline $f $bytes
     977                    puts $f $bytes
    987978                    close $f
    988979                }
     
    998989                    lappend info "dataset_size"  $length
    999990                    lappend info "dataset_tag"   $tag
    1000                     SendCmd "clientinfo [list $info]"
     991                    SendCmd [list "clientinfo" $info]
    1001992                }
    1002993                SendCmd "dataset add $tag data follows $length"
     
    10471038        $itk_component(field) value $_curFldLabel
    10481039    }
    1049     InitSettings -stretchtofit -outline
     1040    InitSettings stretchToFit outline
    10501041
    10511042    if { $_reset } {
    10521043        SendCmd "axis tickpos outside"
    1053         #SendCmd "axis lformat all %g"
     1044        foreach axis { x y z } {
     1045            SendCmd "axis lformat $axis %g"
     1046        }
    10541047       
    10551048        foreach axis { x y z } {
     
    10741067
    10751068            if {$axis == "z" && [$_first hints ${axis}units] == ""} {
    1076                 if {$_curFldName != ""} {
    1077                     set units [lindex $_fields($_curFldName) 1]
    1078                 }
     1069                set units [lindex $_fields($_curFldName) 1]
    10791070            } else {
    10801071                set units [$_first hints ${axis}units]
     
    10891080        #
    10901081        ResetAxes
    1091         $_arcball quaternion [ViewToQuaternion]
    1092         if {$_settings(-isheightmap) } {
    1093             if { $_view(-ortho)} {
     1082        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1083        $_arcball quaternion $q
     1084        if {$_settings(isHeightmap) } {
     1085            if { $_view(ortho)} {
    10941086                SendCmd "camera mode ortho"
    10951087            } else {
     
    11001092        }
    11011093        PanCamera
    1102         InitSettings -xgrid -ygrid -zgrid \
    1103             -axisvisible -axislabels -heightmapscale -field -isheightmap \
    1104             -numisolines
     1094        InitSettings axisXGrid axisYGrid axisZGrid \
     1095            axisVisible axisLabels heightmapScale field isHeightmap \
     1096            numIsolines
    11051097        if { [array size _fields] < 2 } {
    1106             catch {blt::table forget $itk_component(field) $itk_component(field_l)}
     1098            blt::table forget $itk_component(field) $itk_component(field_l)
    11071099        }
    11081100        RequestLegend
     
    11661158itcl::body Rappture::VtkHeightmapViewer::CameraReset {} {
    11671159    array set _view {
    1168         -qw      0.36
    1169         -qx      0.25
    1170         -qy      0.50
    1171         -qz      0.70
    1172         -xpan    0
    1173         -ypan    0
    1174         -zoom    1.0
     1160        qw      0.36
     1161        qx      0.25
     1162        qy      0.50
     1163        qz      0.70
     1164        zoom    1.0
     1165        xpan    0
     1166        ypan    0
    11751167    }
    11761168    if { $_first != "" } {
     
    11801172        }
    11811173    }
    1182     $_arcball quaternion [ViewToQuaternion]
    1183     if {$_settings(-isheightmap) } {
     1174    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1175    $_arcball quaternion $q
     1176    if {$_settings(isHeightmap) } {
    11841177        DoRotate
    11851178    }
     
    11981191    switch -- $option {
    11991192        "in" {
    1200             set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1201             SendCmd "camera zoom $_view(-zoom)"
     1193            set _view(zoom) [expr {$_view(zoom)*1.25}]
     1194            SendCmd "camera zoom $_view(zoom)"
    12021195        }
    12031196        "out" {
    1204             set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1205             SendCmd "camera zoom $_view(-zoom)"
     1197            set _view(zoom) [expr {$_view(zoom)*0.8}]
     1198            SendCmd "camera zoom $_view(zoom)"
    12061199        }
    12071200        "reset" {
    12081201            array set _view {
    1209                 -xpan    0
    1210                 -ypan    0
    1211                 -zoom    1.0
     1202                zoom    1.0
     1203                xpan    0
     1204                ypan    0
    12121205            }
    12131206            SendCmd "camera reset"
     
    12171210
    12181211itcl::body Rappture::VtkHeightmapViewer::PanCamera {} {
    1219     set x $_view(-xpan)
    1220     set y $_view(-ypan)
     1212    set x $_view(xpan)
     1213    set y $_view(ypan)
    12211214    SendCmd "camera pan $x $y"
    12221215}
     
    12961289            set x [expr $x / double($w)]
    12971290            set y [expr $y / double($h)]
    1298             set _view(-xpan) [expr $_view(-xpan) + $x]
    1299             set _view(-ypan) [expr $_view(-ypan) + $y]
     1291            set _view(xpan) [expr $_view(xpan) + $x]
     1292            set _view(ypan) [expr $_view(ypan) + $y]
    13001293            PanCamera
    13011294            return
     
    13191312            set _click(x) $x
    13201313            set _click(y) $y
    1321             set _view(-xpan) [expr $_view(-xpan) - $dx]
    1322             set _view(-ypan) [expr $_view(-ypan) - $dy]
     1314            set _view(xpan) [expr $_view(xpan) - $dx]
     1315            set _view(ypan) [expr $_view(ypan) - $dy]
    13231316            PanCamera
    13241317        }
     
    13421335itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } {
    13431336    foreach spec $args {
    1344         if { [info exists _settings($_first${spec})] } {
     1337        if { [info exists _settings($_first-$spec)] } {
    13451338            # Reset global setting with dataobj specific setting
    1346             set _settings($spec) $_settings($_first${spec})
     1339            set _settings($spec) $_settings($_first-$spec)
    13471340        }
    13481341        AdjustSetting $spec
     
    13621355    }
    13631356    switch -- $what {
    1364         "-axisflymode" {
     1357        "axisFlymode" {
    13651358            set mode [$itk_component(axisflymode) value]
    13661359            set mode [$itk_component(axisflymode) translate $mode]
     
    13681361            SendCmd "axis flymode $mode"
    13691362        }
    1370         "-axislabels" {
     1363        "axisLabels" {
     1364            set bool $_settings(axisLabels)
     1365            SendCmd "axis labels all $bool"
     1366        }
     1367        "axisMinorTicks" {
     1368            set bool $_settings(axisMinorTicks)
     1369            foreach axis { x y z } {
     1370                SendCmd "axis minticks ${axis} $bool"
     1371            }
     1372        }
     1373        "axisVisible" {
     1374            set bool $_settings(axisVisible)
     1375            SendCmd "axis visible all $bool"
     1376        }
     1377        "axisXGrid" - "axisYGrid" - "axisZGrid" {
     1378            set axis [string tolower [string range $what 4 4]]
    13711379            set bool $_settings($what)
    1372             SendCmd "axis labels all $bool"
    1373         }
    1374         "-axisminorticks" {
    1375             set bool $_settings($what)
    1376             SendCmd "axis minticks all $bool"
    1377         }
    1378         "-axisvisible" {
    1379             set bool $_settings($what)
    1380             SendCmd "axis visible all $bool"
    1381         }
    1382         "-background" {
     1380            SendCmd "axis grid $axis $bool"
     1381        }
     1382        "background" {
    13831383            set bg [$itk_component(background) value]
    13841384            array set fgcolors {
     
    13951395            DrawLegend
    13961396        }
    1397         "-colormap" {
    1398             set _changed($what) 1
     1397        "colormap" {
     1398            set _changed(colormap) 1
    13991399            StartBufferingCommands
    14001400            set color [$itk_component(colormap) value]
    1401             set _settings($what) $color
     1401            set _settings(colormap) $color
    14021402            if { $color == "none" } {
    1403                 if { $_settings(-colormapvisible) } {
     1403                if { $_settings(colormapVisible) } {
    14041404                    SendCmd "heightmap surface 0"
    1405                     set _settings(-colormapvisible) 0
     1405                    set _settings(colormapVisible) 0
    14061406                }
    14071407            } else {
    1408                 if { !$_settings(-colormapvisible) } {
     1408                if { !$_settings(colormapVisible) } {
    14091409                    SendCmd "heightmap surface 1"
    1410                     set _settings(-colormapvisible) 1
     1410                    set _settings(colormapVisible) 1
    14111411                }
    14121412                SetCurrentColormap $color
    1413                 if {$_settings(-colormapdiscrete)} {
    1414                     set numColors [expr $_settings(-numisolines) + 1]
     1413                if {$_settings(colormapDiscrete)} {
     1414                    set numColors [expr $_settings(numIsolines) + 1]
    14151415                    SendCmd "colormap res $numColors $color"
    14161416                }
     
    14191419            EventuallyRequestLegend
    14201420        }
    1421         "-colormapvisible" {
     1421        "colormapVisible" {
    14221422            set bool $_settings($what)
    14231423            SendCmd "heightmap surface $bool"
    14241424        }
    1425         "-colormapdiscrete" {
     1425        "colormapDiscrete" {
    14261426            set bool $_settings($what)
    1427             set numColors [expr $_settings(-numisolines) + 1]
     1427            set numColors [expr $_settings(numIsolines) + 1]
    14281428            StartBufferingCommands
    14291429            if {$bool} {
     
    14391439            EventuallyRequestLegend
    14401440        }
    1441         "-edges" {
    1442             set bool $_settings($what)
     1441        "edges" {
     1442            set bool $_settings(edges)
    14431443            SendCmd "heightmap edges $bool"
    14441444        }
    1445         "-field" {
     1445        "field" {
    14461446            set label [$itk_component(field) value]
    14471447            set fname [$itk_component(field) translate $label]
    1448             set _settings($what) $fname
     1448            set _settings(field) $fname
    14491449            if { [info exists _fields($fname)] } {
    14501450                foreach { label units components } $_fields($fname) break
     
    14881488            DrawLegend
    14891489        }
    1490         "-heightmapscale" {
    1491             if { $_settings(-isheightmap) } {
     1490        "heightmapScale" {
     1491            if { $_settings(isHeightmap) } {
    14921492                set scale [GetHeightmapScale]
    14931493                # Have to set the datasets individually because we are
     
    15001500            }
    15011501        }
    1502         "-isheightmap" {
    1503             set bool $_settings($what)
     1502        "isHeightmap" {
     1503            set bool $_settings(isHeightmap)
    15041504            set c $itk_component(view)
    15051505            StartBufferingCommands
    15061506            # Fix heightmap scale: 0 for contours, 1 for heightmaps.
    15071507            if { $bool } {
    1508                 set _settings(-heightmapscale) 50
    1509                 set _settings(-opacity) $_settings(-saveopacity)
    1510                 set _settings(-lighting) $_settings(-savelighting)
    1511                 set _settings(-outline) 0
     1508                set _settings(heightmapScale) 50
     1509                set _settings(opacity) $_settings(saveOpacity)
     1510                set _settings(lighting) $_settings(saveLighting)
     1511                set _settings(outline) 0
    15121512            } else {
    1513                 set _settings(-heightmapscale) 0
    1514                 set _settings(-lighting) 0
    1515                 set _settings(-opacity) 100
    1516                 set _settings(-outline)  $_settings(-saveoutline)
    1517             }
    1518             InitSettings -lighting -opacity -outline
     1513                set _settings(heightmapScale) 0
     1514                set _settings(lighting) 0
     1515                set _settings(opacity) 100
     1516                set _settings(outline)  $_settings(saveOutline)
     1517            }
     1518            AdjustSetting lighting
     1519            AdjustSetting opacity
     1520            AdjustSetting outline
    15191521            set scale [GetHeightmapScale]
    15201522            # Have to set the datasets individually because we are
     
    15311533                $itk_component(scale_l) configure -state normal
    15321534                $itk_component(outline) configure -state disabled
    1533                 if {$_view(-ortho)} {
     1535                if {$_view(ortho)} {
    15341536                    SendCmd "camera mode ortho"
    15351537                } else {
     
    15451547                SendCmd "camera mode image"
    15461548            }
    1547             if {$_settings(-stretchtofit)} {
     1549            if {$_settings(stretchToFit)} {
    15481550                if {$scale == 0} {
    15491551                    SendCmd "camera aspect window"
     
    15541556            ResetAxes
    15551557            if { $bool } {
    1556                 set q [ViewToQuaternion]
     1558                set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    15571559                $_arcball quaternion $q
    15581560                SendCmd "camera orient $q"
     
    15761578            StopBufferingCommands
    15771579        }
    1578         "-isolinecolor" {
     1580        "isolineColor" {
    15791581            set color [$itk_component(isolinecolor) value]
    15801582            if { $color == "none" } {
    1581                 if { $_settings(-isolinesvisible) } {
     1583                if { $_settings(isolinesVisible) } {
    15821584                    SendCmd "heightmap isolines 0"
    1583                     set _settings(-isolinesvisible) 0
     1585                    set _settings(isolinesVisible) 0
    15841586                }
    15851587            } else {
    1586                 if { !$_settings(-isolinesvisible) } {
     1588                if { !$_settings(isolinesVisible) } {
    15871589                    SendCmd "heightmap isolines 1"
    1588                     set _settings(-isolinesvisible) 1
     1590                    set _settings(isolinesVisible) 1
    15891591                }
    15901592                SendCmd "heightmap isolinecolor [Color2RGB $color]"
     
    15921594            DrawLegend
    15931595        }
    1594         "-isolinesvisible" {
     1596        "isolinesVisible" {
    15951597            set bool $_settings($what)
    15961598            SendCmd "heightmap isolines $bool"
    15971599            DrawLegend
    15981600        }
    1599         "-legendvisible" {
     1601        "legendVisible" {
    16001602            if { !$_settings($what) } {
    16011603                $itk_component(view) delete legend
     
    16031605            DrawLegend
    16041606        }
    1605         "-lighting" {
    1606             if { $_settings(-isheightmap) } {
    1607                 set _settings(-savelighting) $_settings($what)
     1607        "lighting" {
     1608            if { $_settings(isHeightmap) } {
     1609                set _settings(saveLighting) $_settings(lighting)
    16081610                set bool $_settings($what)
    16091611                SendCmd "heightmap lighting $bool"
     
    16121614            }
    16131615        }
    1614         "-numisolines" {
    1615             set _settings($what) [$itk_component(numisolines) value]
    1616             set _currentNumIsolines $_settings($what)
     1616        "numIsolines" {
     1617            set _settings(numIsolines) [$itk_component(numisolines) value]
     1618            set _currentNumIsolines $_settings(numIsolines)
    16171619            UpdateContourList
    1618             set _changed($what) 1
     1620            set _changed(numIsolines) 1
    16191621            SendCmd "heightmap contourlist [list $_contourList]"
    1620             if {$_settings(-colormapdiscrete)} {
    1621                 set numColors [expr $_settings($what) + 1]
     1622            if {$_settings(colormapDiscrete)} {
     1623                set numColors [expr $_settings(numIsolines) + 1]
    16221624                SendCmd "colormap res $numColors"
    16231625                EventuallyRequestLegend
     
    16261628            }
    16271629        }
    1628         "-opacity" {
    1629             set _changed($what) 1
    1630             set val [expr $_settings($what) * 0.01]
    1631             if { $_settings(-isheightmap) } {
    1632                 set _settings(-saveopacity) $_settings($what)
    1633                 SendCmd "heightmap opacity $val"
     1630        "opacity" {
     1631            set _changed(opacity) 1
     1632            if { $_settings(isHeightmap) } {
     1633                set _settings(saveOpacity) $_settings(opacity)
     1634                set val $_settings(opacity)
     1635                set sval [expr { 0.01 * double($val) }]
     1636                SendCmd "heightmap opacity $sval"
    16341637            } else {
    1635                 SendCmd "heightmap opacity 1.0"
    1636             }
    1637         }
    1638         "-outline" {
    1639             if { $_settings(-isheightmap) } {
     1638                SendCmd "heightmap opacity 1"
     1639            }
     1640        }
     1641        "outline" {
     1642            if { $_settings(isHeightmap) } {
    16401643                SendCmd "outline visible 0"
    16411644            } else {
    1642                 set _settings(-saveoutline) $_settings($what)
    1643                 set bool $_settings($what)
     1645                set _settings(saveOutline) $_settings(outline)
     1646                set bool $_settings(outline)
    16441647                SendCmd "outline visible $bool"
    16451648            }
    16461649        }
    1647         "-stretchtofit" {
     1650        "stretchToFit" {
    16481651            set bool $_settings($what)
    16491652            if { $bool } {
     
    16591662            Zoom reset
    16601663        }
    1661         "-wireframe" {
     1664        "wireframe" {
    16621665            set bool $_settings($what)
    16631666            SendCmd "heightmap wireframe $bool"
    1664         }
    1665         "-xgrid" - "-ygrid" - "-zgrid" {
    1666             set axis [string tolower [string range $what 1 1]]
    1667             set bool $_settings($what)
    1668             SendCmd "axis grid $axis $bool"
    16691667        }
    16701668        default {
     
    17191717    if { $_currentColormap != ""  } {
    17201718        set cmap $_currentColormap
    1721         #SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
    1722         SendCmd "legend2 $cmap $w $h"
     1719        SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
    17231720    }
    17241721}
     
    17801777}
    17811778
     1779
    17821780#
    17831781# BuildColormap --
     
    18001798    switch -- $itk_option(-mode) {
    18011799        "heightmap" {
    1802             set _settings(-isheightmap) 1
     1800            set _settings(isHeightmap) 1
    18031801        }
    18041802        "contour" {
    1805             set _settings(-isheightmap) 0
     1803            set _settings(isHeightmap) 0
    18061804        }
    18071805        default {
     
    18101808    }
    18111809    if { !$_reset } {
    1812         AdjustSetting -isheightmap
     1810        AdjustSetting isHeightmap
    18131811    }
    18141812}
     
    18341832        set rgb [Color2RGB $itk_option(-plotforeground)]
    18351833        if { !$_reset } {
     1834            SendCmd "outline color $rgb"
    18361835            SendCmd "axis color all $rgb"
    1837             SendCmd "outline color $rgb"
    1838         }
    1839     }
     1836        }
     1837    }
     1838}
     1839
     1840itcl::body Rappture::VtkHeightmapViewer::limits3 { dataobj } {
     1841    lappend limits x [$dataobj limits x]
     1842    lappend limits y [$dataobj limits y]
     1843    if { [catch { $dataobj limits $_curFldName } vlim] != 0 } {
     1844        set vlim [$dataobj limits v]
     1845    }
     1846    lappend limits v $vlim
     1847    return $limits
    18401848}
    18411849
     
    18521860    checkbutton $inner.legend \
    18531861        -text "Legend" \
    1854         -variable [itcl::scope _settings(-legendvisible)] \
    1855         -command [itcl::code $this AdjustSetting -legendvisible] \
     1862        -variable [itcl::scope _settings(legendVisible)] \
     1863        -command [itcl::code $this AdjustSetting legendVisible] \
    18561864        -font "Arial 9"
    18571865
    18581866    checkbutton $inner.wireframe \
    18591867        -text "Wireframe" \
    1860         -variable [itcl::scope _settings(-wireframe)] \
    1861         -command [itcl::code $this AdjustSetting -wireframe] \
     1868        -variable [itcl::scope _settings(wireframe)] \
     1869        -command [itcl::code $this AdjustSetting wireframe] \
    18621870        -font "Arial 9"
    18631871
     
    18651873        checkbutton $inner.lighting \
    18661874            -text "Enable Lighting" \
    1867             -variable [itcl::scope _settings(-lighting)] \
    1868             -command [itcl::code $this AdjustSetting -lighting] \
     1875            -variable [itcl::scope _settings(lighting)] \
     1876            -command [itcl::code $this AdjustSetting lighting] \
    18691877            -font "Arial 9"
    18701878    } {
     
    18731881    checkbutton $inner.edges \
    18741882        -text "Edges" \
    1875         -variable [itcl::scope _settings(-edges)] \
    1876         -command [itcl::code $this AdjustSetting -edges] \
     1883        -variable [itcl::scope _settings(edges)] \
     1884        -command [itcl::code $this AdjustSetting edges] \
    18771885        -font "Arial 9"
    18781886
     
    18801888        checkbutton $inner.outline \
    18811889            -text "Outline" \
    1882             -variable [itcl::scope _settings(-outline)] \
    1883             -command [itcl::code $this AdjustSetting -outline] \
     1890            -variable [itcl::scope _settings(outline)] \
     1891            -command [itcl::code $this AdjustSetting outline] \
    18841892            -font "Arial 9"
    18851893    } {
     
    18881896    checkbutton $inner.stretch \
    18891897        -text "Stretch to fit" \
    1890         -variable [itcl::scope _settings(-stretchtofit)] \
    1891         -command [itcl::code $this AdjustSetting -stretchtofit] \
     1898        -variable [itcl::scope _settings(stretchToFit)] \
     1899        -command [itcl::code $this AdjustSetting stretchToFit] \
    18921900        -font "Arial 9"
    18931901
    18941902    checkbutton $inner.isolines \
    18951903        -text "Isolines" \
    1896         -variable [itcl::scope _settings(-isolinesvisible)] \
    1897         -command [itcl::code $this AdjustSetting -isolinesvisible] \
     1904        -variable [itcl::scope _settings(isolinesVisible)] \
     1905        -command [itcl::code $this AdjustSetting isolinesVisible] \
    18981906        -font "Arial 9"
    18991907
    19001908    checkbutton $inner.colormapDiscrete \
    19011909        -text "Discrete Colormap" \
    1902         -variable [itcl::scope _settings(-colormapdiscrete)] \
    1903         -command [itcl::code $this AdjustSetting -colormapdiscrete] \
     1910        -variable [itcl::scope _settings(colormapDiscrete)] \
     1911        -command [itcl::code $this AdjustSetting colormapDiscrete] \
    19041912        -font "Arial 9"
    19051913
     
    19131921    }
    19141922    bind $inner.field <<Value>> \
    1915         [itcl::code $this AdjustSetting -field]
     1923        [itcl::code $this AdjustSetting field]
    19161924
    19171925    label $inner.colormap_l -text "Colormap" -font "Arial 9"
     
    19191927        Rappture::Combobox $inner.colormap -width 10 -editable no
    19201928    }
    1921     $inner.colormap choices insert end [GetColormapList -includeNone]
    1922     $itk_component(colormap) value $_settings(-colormap)
     1929    $inner.colormap choices insert end \
     1930        "BCGYR"              "BCGYR"            \
     1931        "BGYOR"              "BGYOR"            \
     1932        "blue"               "blue"             \
     1933        "blue-to-brown"      "blue-to-brown"    \
     1934        "blue-to-orange"     "blue-to-orange"   \
     1935        "blue-to-grey"       "blue-to-grey"     \
     1936        "green-to-magenta"   "green-to-magenta" \
     1937        "greyscale"          "greyscale"        \
     1938        "nanohub"            "nanohub"          \
     1939        "rainbow"            "rainbow"          \
     1940        "spectral"           "spectral"         \
     1941        "ROYGB"              "ROYGB"            \
     1942        "RYGCB"              "RYGCB"            \
     1943        "brown-to-blue"      "brown-to-blue"    \
     1944        "grey-to-blue"       "grey-to-blue"     \
     1945        "orange-to-blue"     "orange-to-blue"   \
     1946        "none"               "none"
     1947
     1948    $itk_component(colormap) value "BCGYR"
    19231949    bind $inner.colormap <<Value>> \
    1924         [itcl::code $this AdjustSetting -colormap]
     1950        [itcl::code $this AdjustSetting colormap]
    19251951
    19261952    label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9"
     
    19401966        "none"               "none"
    19411967
    1942     $itk_component(isolinecolor) value $_settings(-isolinecolor)
     1968    $itk_component(isolinecolor) value "black"
    19431969    bind $inner.isolinecolor <<Value>> \
    1944         [itcl::code $this AdjustSetting -isolinecolor]
     1970        [itcl::code $this AdjustSetting isolineColor]
    19451971
    19461972    label $inner.background_l -text "Background Color" -font "Arial 9"
     
    19541980
    19551981    $itk_component(background) value "white"
    1956     bind $inner.background <<Value>> \
    1957         [itcl::code $this AdjustSetting -background]
     1982    bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]
    19581983
    19591984    itk_component add opacity_l {
     
    19641989    itk_component add opacity {
    19651990        ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1966             -variable [itcl::scope _settings(-opacity)] \
     1991            -variable [itcl::scope _settings(opacity)] \
    19671992            -showvalue off \
    1968             -command [itcl::code $this AdjustSetting -opacity]
     1993            -command [itcl::code $this AdjustSetting opacity]
    19691994    }
    19701995    itk_component add scale_l {
     
    19752000    itk_component add scale {
    19762001        ::scale $inner.scale -from 0 -to 100 -orient horizontal \
    1977             -variable [itcl::scope _settings(-heightmapscale)] \
     2002            -variable [itcl::scope _settings(heightmapScale)] \
    19782003            -showvalue off \
    1979             -command [itcl::code $this AdjustSetting -heightmapscale]
     2004            -command [itcl::code $this AdjustSetting heightmapScale]
    19802005    }
    19812006    label $inner.numisolines_l -text "Number of Isolines" -font "Arial 9"
     
    19842009            -min 0 -max 50 -font "arial 9"
    19852010    }
    1986     $itk_component(numisolines) value $_settings(-numisolines)
     2011    $itk_component(numisolines) value $_settings(numIsolines)
    19872012    bind $itk_component(numisolines) <<Value>> \
    1988         [itcl::code $this AdjustSetting -numisolines]
     2013        [itcl::code $this AdjustSetting numIsolines]
    19892014
    19902015    frame $inner.separator1 -height 2 -relief sunken -bd 1
     
    20332058    checkbutton $inner.visible \
    20342059        -text "Axes" \
    2035         -variable [itcl::scope _settings(-axisvisible)] \
    2036         -command [itcl::code $this AdjustSetting -axisvisible] \
     2060        -variable [itcl::scope _settings(axisVisible)] \
     2061        -command [itcl::code $this AdjustSetting axisVisible] \
    20372062        -font "Arial 9"
    20382063    checkbutton $inner.labels \
    20392064        -text "Axis Labels" \
    2040         -variable [itcl::scope _settings(-axislabels)] \
    2041         -command [itcl::code $this AdjustSetting -axislabels] \
     2065        -variable [itcl::scope _settings(axisLabels)] \
     2066        -command [itcl::code $this AdjustSetting axisLabels] \
    20422067        -font "Arial 9"
    20432068    label $inner.grid_l -text "Grid" -font "Arial 9"
    20442069    checkbutton $inner.xgrid \
    20452070        -text "X" \
    2046         -variable [itcl::scope _settings(-xgrid)] \
    2047         -command [itcl::code $this AdjustSetting -xgrid] \
     2071        -variable [itcl::scope _settings(axisXGrid)] \
     2072        -command [itcl::code $this AdjustSetting axisXGrid] \
    20482073        -font "Arial 9"
    20492074    checkbutton $inner.ygrid \
    20502075        -text "Y" \
    2051         -variable [itcl::scope _settings(-ygrid)] \
    2052         -command [itcl::code $this AdjustSetting -ygrid] \
     2076        -variable [itcl::scope _settings(axisYGrid)] \
     2077        -command [itcl::code $this AdjustSetting axisYGrid] \
    20532078        -font "Arial 9"
    20542079    checkbutton $inner.zgrid \
    20552080        -text "Z" \
    2056         -variable [itcl::scope _settings(-zgrid)] \
    2057         -command [itcl::code $this AdjustSetting -zgrid] \
     2081        -variable [itcl::scope _settings(axisZGrid)] \
     2082        -command [itcl::code $this AdjustSetting axisZGrid] \
    20582083        -font "Arial 9"
    20592084    checkbutton $inner.minorticks \
    20602085        -text "Minor Ticks" \
    2061         -variable [itcl::scope _settings(-axisminorticks)] \
    2062         -command [itcl::code $this AdjustSetting -axisminorticks] \
     2086        -variable [itcl::scope _settings(axisMinorTicks)] \
     2087        -command [itcl::code $this AdjustSetting axisMinorTicks] \
    20632088        -font "Arial 9"
     2089
    20642090
    20652091    label $inner.mode_l -text "Mode" -font "Arial 9"
     
    20732099        "furthest_triad"  "farthest" \
    20742100        "outer_edges"     "outer"         
    2075     $itk_component(axisflymode) value $_settings(-axisflymode)
    2076     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     2101    $itk_component(axisflymode) value "static"
     2102    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlymode]
    20772103
    20782104    blt::table $inner \
     
    20922118}
    20932119
     2120
    20942121itcl::body Rappture::VtkHeightmapViewer::BuildCameraTab {} {
    20952122    set inner [$itk_component(main) insert end \
     
    21102137        0,0 $inner.view_l -anchor e -pady 2 \
    21112138        0,1 $inner.view -anchor w -pady 2
    2112     blt::table configure $inner r0 -resize none
    21132139
    21142140    set labels { qx qy qz qw xpan ypan zoom }
     
    21172143        label $inner.${tag}label -text $tag -font "Arial 9"
    21182144        entry $inner.${tag} -font "Arial 9"  -bg white \
    2119             -textvariable [itcl::scope _view(-$tag)]
     2145            -textvariable [itcl::scope _view($tag)]
    21202146        bind $inner.${tag} <Return> \
    2121             [itcl::code $this camera set -${tag}]
     2147            [itcl::code $this camera set ${tag}]
    21222148        bind $inner.${tag} <KP_Enter> \
    2123             [itcl::code $this camera set -${tag}]
     2149            [itcl::code $this camera set ${tag}]
    21242150        blt::table $inner \
    21252151            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    21302156    checkbutton $inner.ortho \
    21312157        -text "Orthographic Projection" \
    2132         -variable [itcl::scope _view(-ortho)] \
    2133         -command [itcl::code $this camera set -ortho] \
     2158        -variable [itcl::scope _view(ortho)] \
     2159        -command [itcl::code $this camera set ortho] \
    21342160        -font "Arial 9"
    21352161    blt::table $inner \
     
    21382164    incr row
    21392165
    2140     blt::table configure $inner c* -resize none
     2166    blt::table configure $inner c* r* -resize none
    21412167    blt::table configure $inner c2 -resize expand
    21422168    blt::table configure $inner r$row -resize expand
     
    21522178        }
    21532179        "set" {
    2154             set what [lindex $args 0]
    2155             set x $_view($what)
     2180            set who [lindex $args 0]
     2181            set x $_view($who)
    21562182            set code [catch { string is double $x } result]
    21572183            if { $code != 0 || !$result } {
    21582184                return
    21592185            }
    2160             switch -- $what {
    2161                 "-ortho" {
    2162                     if {$_view($what)} {
     2186            switch -- $who {
     2187                "ortho" {
     2188                    if {$_view(ortho)} {
    21632189                        SendCmd "camera mode ortho"
    21642190                    } else {
     
    21662192                    }
    21672193                }
    2168                 "-xpan" - "-ypan" {
     2194                "xpan" - "ypan" {
    21692195                    PanCamera
    21702196                }
    2171                 "-qx" - "-qy" - "-qz" - "-qw" {
    2172                     set q [ViewToQuaternion]
     2197                "qx" - "qy" - "qz" - "qw" {
     2198                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    21732199                    $_arcball quaternion $q
    21742200                    EventuallyRotate $q
    21752201                }
    2176                 "-zoom" {
    2177                     SendCmd "camera zoom $_view($what)"
     2202                "zoom" {
     2203                    SendCmd "camera zoom $_view(zoom)"
    21782204                }
    21792205            }
     
    22592285    array set style {
    22602286        -color BCGYR
     2287        -opacity 100
    22612288        -levels 10
    2262         -opacity 1.0
    22632289    }
    22642290    set stylelist [$dataobj style $comp]
     
    22752301    # the code to handle aberrant cases.
    22762302
    2277     if { $_changed(-opacity) } {
    2278         set style(-opacity) [expr $_settings(-opacity) * 0.01]
    2279     }
    2280     if { $_changed(-numisolines) } {
    2281         set style(-levels) $_settings(-numisolines)
    2282     }
    2283     if { $_changed(-colormap) } {
    2284         set style(-color) $_settings(-colormap)
     2303    if { $_changed(opacity) } {
     2304        set style(-opacity) $_settings(opacity)
     2305    }
     2306    if { $_changed(numIsolines) } {
     2307        set style(-levels) $_settings(numIsolines)
     2308    }
     2309    if { $_changed(colormap) } {
     2310        set style(-color) $_settings(colormap)
    22852311    }
    22862312    if { $_currentColormap == "" } {
     
    22882314    }
    22892315    if { [info exists style(-stretchtofit)] } {
    2290         set _settings(-stretchtofit) $style(-stretchtofit)
    2291         AdjustSetting -stretchtofit
    2292     }
     2316        set _settings(stretchToFit) $style(-stretchtofit)
     2317        AdjustSetting stretchToFit
     2318    }
     2319    set _currentOpacity $style(-opacity)
    22932320    if { $_currentNumIsolines != $style(-levels) } {
    22942321        set _currentNumIsolines $style(-levels)
    2295         set _settings(-numisolines) $_currentNumIsolines
     2322        set _settings(numIsolines) $_currentNumIsolines
    22962323        $itk_component(numisolines) value $_currentNumIsolines
    22972324        UpdateContourList
     
    23002327    SendCmd "outline add $tag"
    23012328    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
    2302     SendCmd "outline visible $_settings(-outline) $tag"
     2329    SendCmd "outline visible $_settings(outline) $tag"
    23032330    set scale [GetHeightmapScale]
    23042331    SendCmd "[list heightmap add contourlist $_contourList $scale $tag]"
    2305     set _comp2scale($tag) $_settings(-heightmapscale)
    2306     SendCmd "heightmap edges $_settings(-edges) $tag"
    2307     SendCmd "heightmap wireframe $_settings(-wireframe) $tag"
    2308     SetCurrentColormap $style(-color)
     2332    set _comp2scale($tag) $_settings(heightmapScale)
     2333    SendCmd "heightmap edges $_settings(edges) $tag"
     2334    SendCmd "heightmap wireframe $_settings(wireframe) $tag"
     2335    SetCurrentColormap $style(-color) 
    23092336    set color [$itk_component(isolinecolor) value]
    23102337    SendCmd "heightmap isolinecolor [Color2RGB $color] $tag"
    2311     SendCmd "heightmap lighting $_settings(-isheightmap) $tag"
    2312     SendCmd "heightmap isolines $_settings(-isolinesvisible) $tag"
    2313     SendCmd "heightmap surface $_settings(-colormapvisible) $tag"
    2314     SendCmd "heightmap opacity $style(-opacity) $tag"
    2315     set _settings(-opacity) [expr $style(-opacity) * 100.0]
     2338    SendCmd "heightmap lighting $_settings(isHeightmap) $tag"
     2339    SendCmd "heightmap isolines $_settings(isolinesVisible) $tag"
     2340    SendCmd "heightmap surface $_settings(colormapVisible) $tag"
    23162341}
    23172342
     
    23722397    }
    23732398    set x [expr $w - 2]
    2374     if { !$_settings(-legendvisible) } {
     2399    if { !$_settings(legendVisible) } {
    23752400        $c delete legend
    23762401        return
     
    23802405        # If there's a legend title, create a text item for the title.
    23812406        $c create text $x $y \
    2382             -anchor ne \
    2383             -fill $itk_option(-plotforeground) -tags "title legend" \
    2384             -font $font
    2385         if { $title != "" } {
    2386             incr y $lineht
    2387         }
     2407                -anchor ne \
     2408                -fill $itk_option(-plotforeground) -tags "title legend" \
     2409                -font $font
    23882410        $c create text $x $y \
    2389             -anchor ne \
    2390             -fill $itk_option(-plotforeground) -tags "vmax legend" \
    2391             -font $font
    2392         incr y $lineht
     2411            -anchor ne \
     2412            -fill $itk_option(-plotforeground) -tags "vmax legend" \
     2413            -font $font
     2414        incr y $lineht
    23932415        $c create image $x $y \
    23942416            -anchor ne \
     
    24142436    array unset _isolines
    24152437    if { $color != "none"  && [info exists _limits($_curFldName)] &&
    2416          $_settings(-isolinesvisible) && $_currentNumIsolines > 0 } {
     2438         $_settings(isolinesVisible) && $_currentNumIsolines > 0 } {
    24172439
    24182440        foreach { vmin vmax } $_limits($_curFldName) break
     
    25812603        invoke {
    25822604            $itk_component(field) value $_curFldLabel
    2583             AdjustSetting -field
     2605            AdjustSetting field
    25842606        }
    25852607        default {
     
    25902612
    25912613itcl::body Rappture::VtkHeightmapViewer::GetHeightmapScale {} {
    2592     if {  $_settings(-isheightmap) } {
    2593         set val $_settings(-heightmapscale)
     2614    if {  $_settings(isHeightmap) } {
     2615        set val $_settings(heightmapScale)
    25942616        set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }]
    25952617        return $sval
     
    26072629        bottom "0 1 0 0"
    26082630    }
    2609     foreach name { -qw -qx -qy -qz } value $positions($side) {
     2631    foreach name { qw qx qy qz } value $positions($side) {
    26102632        set _view($name) $value
    26112633    }
    2612     set q [ViewToQuaternion]
     2634    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    26132635    $_arcball quaternion $q
    26142636    SendCmd "camera orient $q"
    26152637    SendCmd "camera reset"
    2616     set _view(-xpan) 0
    2617     set _view(-ypan) 0
    2618     set _view(-zoom) 1.0
     2638    set _view(xpan) 0
     2639    set _view(ypan) 0
     2640    set _view(zoom) 1.0
    26192641}
    26202642
  • branches/1.3/gui/scripts/vtkstreamlinesviewer.tcl

    r4772 r4848  
    11# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    3 #  COMPONENT: vtkstreamlinesviewer - Vtk streamlines object viewer
     3#  COMPONENT: vtkviewer - Vtk drawing object viewer
    44#
    55#  It connects to the Vtk server running on a rendering farm,
     
    77# ======================================================================
    88#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2004-2014  HUBzero Foundation, LLC
     9#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1010#
    1111#  See the file "license.terms" for information on usage and
     
    6262    public method scale {args}
    6363
     64    protected method Connect {}
     65    protected method CurrentDatasets {args}
     66    protected method Disconnect {}
     67    protected method DoResize {}
     68    protected method DoReseed {}
     69    protected method DoRotate {}
     70    protected method AdjustSetting {what {value ""}}
     71    protected method InitSettings { args  }
     72    protected method Pan {option x y}
     73    protected method Pick {x y}
     74    protected method Rebuild {}
     75    protected method ReceiveDataset { args }
     76    protected method ReceiveImage { args }
     77    protected method ReceiveLegend { colormap title vmin vmax size }
     78    protected method Rotate {option x y}
     79    protected method Zoom {option}
     80
    6481    # The following methods are only used by this class.
    65     private method AdjustSetting {what {value ""}}
    6682    private method BuildAxisTab {}
    6783    private method BuildCameraTab {}
     
    7389    private method DrawLegend {}
    7490    private method Combo { option }
    75     private method Connect {}
    76     private method CurrentDatasets {args}
    77     private method Disconnect {}
    78     private method DoResize {}
    79     private method DoReseed {}
    80     private method DoRotate {}
    8191    private method EnterLegend { x y }
    8292    private method EventuallyResize { w h }
     
    8696    private method GetImage { args }
    8797    private method GetVtkData { args }
    88     private method InitSettings { args  }
    8998    private method IsValidObject { dataobj }
    9099    private method LeaveLegend {}
    91100    private method MotionLegend { x y }
    92     private method Pan {option x y}
    93101    private method PanCamera {}
    94     private method Pick {x y}
    95     private method QuaternionToView { q } {
    96         foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    97     }
    98     private method Rebuild {}
    99     private method ReceiveDataset { args }
    100     private method ReceiveImage { args }
    101     private method ReceiveLegend { colormap title vmin vmax size }
    102102    private method RequestLegend {}
    103     private method Rotate {option x y}
    104103    private method SetColormap { dataobj comp }
    105104    private method ChangeColormap { dataobj comp color }
     
    108107    private method Slice {option args}
    109108    private method SetOrientation { side }
    110     private method ViewToQuaternion {} {
    111         return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    112     }
    113     private method Zoom {option}
    114109
    115110    private variable _arcball ""
     
    194189    $_dispatcher register !xcutplane
    195190    $_dispatcher dispatch $this !xcutplane \
    196         "[itcl::code $this AdjustSetting -cutplanexposition]; list"
     191        "[itcl::code $this AdjustSetting cutplaneXPosition]; list"
    197192
    198193    # Y-Cutplane event
    199194    $_dispatcher register !ycutplane
    200195    $_dispatcher dispatch $this !ycutplane \
    201         "[itcl::code $this AdjustSetting -cutplaneyposition]; list"
     196        "[itcl::code $this AdjustSetting cutplaneYPosition]; list"
    202197
    203198    # Z-Cutplane event
    204199    $_dispatcher register !zcutplane
    205200    $_dispatcher dispatch $this !zcutplane \
    206         "[itcl::code $this AdjustSetting -cutplanezposition]; list"
     201        "[itcl::code $this AdjustSetting cutplaneZPosition]; list"
    207202
    208203    #
     
    215210    # Initialize the view to some default parameters.
    216211    array set _view {
    217         -ortho           0
    218         -qw              0.853553
    219         -qx              -0.353553
    220         -qy              0.353553
    221         -qz              0.146447
    222         -xpan            0
    223         -ypan            0
    224         -zoom            1.0
     212        qw              0.853553
     213        qx              -0.353553
     214        qy              0.353553
     215        qz              0.146447
     216        zoom            1.0
     217        xpan            0
     218        ypan            0
     219        ortho           0
    225220    }
    226221    set _arcball [blt::arcball create 100 100]
    227     $_arcball quaternion [ViewToQuaternion]
     222    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     223    $_arcball quaternion $q
    228224
    229225    array set _settings [subst {
    230         -axesvisible                1
    231         -axislabelsvisible          1
    232         -axisminorticks             1
    233         -axismode                   "static"
    234         -cutplaneedges              0
    235         -cutplanelighting           1
    236         -cutplaneopacity            100
    237         -cutplanevisible            0
    238         -cutplanewireframe          0
    239         -cutplanexposition          50
    240         -cutplanexvisible           1
    241         -cutplaneyposition          50
    242         -cutplaneyvisible           1
    243         -cutplanezposition          50
    244         -cutplanezvisible           1
    245         -legendvisible              1
    246         -streamlineslighting        1
    247         -streamlinesmode            lines
    248         -streamlinesnumseeds        200
    249         -streamlinesopacity         100
    250         -streamlinesscale           1
    251         -streamlinesseedsvisible    0
    252         -streamlinesvisible         1
    253         -volumeedges                0
    254         -volumelighting             1
    255         -volumeopacity              40
    256         -volumevisible              1
    257         -volumewireframe            0
    258         -xgrid                      0
    259         -ygrid                      0
    260         -zgrid                      0
     226        axesVisible             1
     227        axisLabelsVisible       1
     228        axisXGrid               0
     229        axisYGrid               0
     230        axisZGrid               0
     231        cutplaneEdges           0
     232        cutplaneLighting        1
     233        cutplaneOpacity         100
     234        cutplaneVisible         0
     235        cutplaneWireframe       0
     236        cutplaneXPosition       50
     237        cutplaneXVisible        1
     238        cutplaneYPosition       50
     239        cutplaneYVisible        1
     240        cutplaneZPosition       50
     241        cutplaneZVisible        1
     242        legendVisible           1
     243        streamlinesLighting     1
     244        streamlinesMode         lines
     245        streamlinesNumSeeds     200
     246        streamlinesOpacity      100
     247        streamlinesScale        1
     248        streamlinesSeedsVisible 0
     249        streamlinesVisible      1
     250        volumeEdges             0
     251        volumeLighting          1
     252        volumeOpacity           40
     253        volumeVisible           1
     254        volumeWireframe         0
    261255    }]
    262256
     
    337331            -onimage [Rappture::icon volume-on] \
    338332            -offimage [Rappture::icon volume-off] \
    339             -variable [itcl::scope _settings(-volumevisible)] \
    340             -command [itcl::code $this AdjustSetting -volumevisible]
     333            -variable [itcl::scope _settings(volumeVisible)] \
     334            -command [itcl::code $this AdjustSetting volumeVisible]
    341335    }
    342336    $itk_component(volume) select
     
    349343            -onimage [Rappture::icon streamlines-on] \
    350344            -offimage [Rappture::icon streamlines-off] \
    351             -variable [itcl::scope _settings(-streamlinesvisible)] \
    352             -command [itcl::code $this AdjustSetting -streamlinesvisible] \
     345            -variable [itcl::scope _settings(streamlinesVisible)] \
     346            -command [itcl::code $this AdjustSetting streamlinesVisible] \
    353347    }
    354348    $itk_component(streamlines) select
     
    361355            -onimage [Rappture::icon cutbutton] \
    362356            -offimage [Rappture::icon cutbutton] \
    363             -variable [itcl::scope _settings(-cutplanevisible)] \
    364             -command [itcl::code $this AdjustSetting -cutplanevisible]
     357            -variable [itcl::scope _settings(cutplaneVisible)] \
     358            -command [itcl::code $this AdjustSetting cutplaneVisible]
    365359    }
    366360    Rappture::Tooltip::for $itk_component(cutplane) \
     
    405399    bind $itk_component(view) <ButtonRelease-1> \
    406400        [itcl::code $this Rotate release %x %y]
    407 
     401    bind $itk_component(view) <Configure> \
     402        [itcl::code $this EventuallyResize %w %h]
     403
     404    if 0 {
     405    bind $itk_component(view) <Configure> \
     406        [itcl::code $this EventuallyResize %w %h]
     407    }
    408408    # Bindings for panning via mouse
    409409    bind $itk_component(view) <ButtonPress-2> \
     
    453453    eval itk_initialize $args
    454454    Connect
     455    update
    455456}
    456457
     
    480481
    481482itcl::body Rappture::VtkStreamlinesViewer::DoRotate {} {
    482     SendCmd "camera orient [ViewToQuaternion]"
     483    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     484    SendCmd "camera orient $q"
    483485    set _rotatePending 0
    484486}
     
    514516
    515517itcl::body Rappture::VtkStreamlinesViewer::EventuallyRotate { q } {
    516     QuaternionToView $q
     518    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
    517519    if { !$_rotatePending } {
    518520        set _rotatePending 1
     
    786788        if { $_reportClientInfo }  {
    787789            # Tell the server the viewer, hub, user and session.
    788             # Do this immediately on connect before buffering any commands
     790            # Do this immediately on connect before buffing any commands
    789791            global env
    790792
     
    876878    if { $info(-type) == "image" } {
    877879        if 0 {
    878             set f [open "last.ppm" "w"]
    879             fconfigure $f -encoding binary
    880             puts -nonewline $f $bytes
     880            set f [open "last.ppm" "w"]
     881            puts $f $bytes
    881882            close $f
    882883        }
     
    969970        $_arcball resize $w $h
    970971        DoResize
    971         InitSettings -xgrid -ygrid -zgrid -axismode \
    972             -axesvisible -axislabelsvisible -axisminorticks
     972        InitSettings axisXGrid axisYGrid axisZGrid axis-mode \
     973            axesVisible axisLabelsVisible
    973974        # This "imgflush" is to force an image returned before vtkvis starts
    974975        # reading a (big) dataset.  This will display an empty plot with axes
     
    992993                    set f [open /tmp/vtkstreamlines.vtk "w"]
    993994                    fconfigure $f -translation binary -encoding binary
    994                     puts -nonewline $f $bytes
     995                    puts $f $bytes
    995996                    close $f
    996997                }
     
    10261027            set label [$_first hints ${axis}label]
    10271028            if { $label != "" } {
    1028                 SendCmd [list axis name $axis $label]
     1029                SendCmd "axis name $axis $label"
    10291030            }
    10301031            set units [$_first hints ${axis}units]
    10311032            if { $units != "" } {
    1032                 SendCmd [list axis units $axis $units]
     1033                SendCmd "axis units $axis $units"
    10331034            }
    10341035        }
     
    10631064
    10641065    if { $_reset } {
    1065         InitSettings -streamlinesseedsvisible -streamlinesopacity \
    1066             -streamlinesvisible -streamlinescolormap \
    1067             -streamlineslighting \
    1068             -streamlinescolormap -field \
    1069             -volumevisible -volumeedges -volumelighting -volumeopacity \
    1070             -volumewireframe \
    1071             -cutplanevisible \
    1072             -cutplanexposition -cutplaneyposition -cutplanezposition \
    1073             -cutplanexvisible -cutplaneyvisible -cutplanezvisible
     1066        InitSettings streamlinesSeedsVisible streamlinesOpacity \
     1067            streamlinesVisible streamlinesColormap \
     1068            streamlinesLighting \
     1069            streamlinesColormap field \
     1070            volumeVisible volumeEdges volumeLighting volumeOpacity \
     1071            volumeWireframe \
     1072            cutplaneVisible \
     1073            cutplaneXPosition cutplaneYPosition cutplaneZPosition \
     1074            cutplaneXVisible cutplaneYVisible cutplaneZVisible
    10741075
    10751076        # Reset the camera and other view parameters
    1076         $_arcball quaternion [ViewToQuaternion]
    1077         if {$_view(-ortho)} {
     1077        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1078        $_arcball quaternion $q
     1079        if {$_view(ortho)} {
    10781080            SendCmd "camera mode ortho"
    10791081        } else {
     
    11491151    switch -- $option {
    11501152        "in" {
    1151             set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1152             SendCmd "camera zoom $_view(-zoom)"
     1153            set _view(zoom) [expr {$_view(zoom)*1.25}]
     1154            SendCmd "camera zoom $_view(zoom)"
    11531155        }
    11541156        "out" {
    1155             set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1156             SendCmd "camera zoom $_view(-zoom)"
     1157            set _view(zoom) [expr {$_view(zoom)*0.8}]
     1158            SendCmd "camera zoom $_view(zoom)"
    11571159        }
    11581160        "reset" {
    11591161            array set _view {
    1160                 -qw      0.853553
    1161                 -qx      -0.353553
    1162                 -qy      0.353553
    1163                 -qz      0.146447
    1164                 -xpan    0
    1165                 -ypan    0
    1166                 -zoom    1.0
     1162                qw      0.853553
     1163                qx      -0.353553
     1164                qy      0.353553
     1165                qz      0.146447
     1166                zoom    1.0
     1167                xpan    0
     1168                ypan    0
    11671169            }
    11681170            if { $_first != "" } {
     
    11721174                }
    11731175            }
    1174             $_arcball quaternion [ViewToQuaternion]
     1176            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1177            $_arcball quaternion $q
    11751178            DoRotate
    11761179            SendCmd "camera reset"
     
    11801183
    11811184itcl::body Rappture::VtkStreamlinesViewer::PanCamera {} {
    1182     set x $_view(-xpan)
    1183     set y $_view(-ypan)
     1185    set x $_view(xpan)
     1186    set y $_view(ypan)
    11841187    SendCmd "camera pan $x $y"
    11851188}
     1189
    11861190
    11871191# ----------------------------------------------------------------------
     
    12581262            set x [expr $x / double($w)]
    12591263            set y [expr $y / double($h)]
    1260             set _view(-xpan) [expr $_view(-xpan) + $x]
    1261             set _view(-ypan) [expr $_view(-ypan) + $y]
     1264            set _view(xpan) [expr $_view(xpan) + $x]
     1265            set _view(ypan) [expr $_view(ypan) + $y]
    12621266            PanCamera
    12631267            return
     
    12811285            set _click(x) $x
    12821286            set _click(y) $y
    1283             set _view(-xpan) [expr $_view(-xpan) - $dx]
    1284             set _view(-ypan) [expr $_view(-ypan) - $dy]
     1287            set _view(xpan) [expr $_view(xpan) - $dx]
     1288            set _view(ypan) [expr $_view(ypan) - $dy]
    12851289            PanCamera
    12861290        }
     
    13041308itcl::body Rappture::VtkStreamlinesViewer::InitSettings { args } {
    13051309    foreach spec $args {
    1306         if { [info exists _settings($_first${spec})] } {
     1310        if { [info exists _settings($_first-$spec)] } {
    13071311            # Reset global setting with dataobj specific setting
    1308             set _settings($spec) $_settings($_first${spec})
     1312            set _settings($spec) $_settings($_first-$spec)
    13091313        }
    13101314        AdjustSetting $spec
     
    13241328    }
    13251329    switch -- $what {
    1326         "-axesvisible" {
     1330        "volumeOpacity" {
     1331            set val $_settings(volumeOpacity)
     1332            set sval [expr { 0.01 * double($val) }]
     1333            SendCmd "polydata opacity $sval"
     1334        }
     1335        "volumeWireframe" {
     1336            set bool $_settings(volumeWireframe)
     1337            SendCmd "polydata wireframe $bool"
     1338        }
     1339        "volumeVisible" {
     1340            set bool $_settings(volumeVisible)
     1341            SendCmd "polydata visible $bool"
     1342            if { $bool } {
     1343                Rappture::Tooltip::for $itk_component(volume) \
     1344                    "Hide the volume"
     1345            } else {
     1346                Rappture::Tooltip::for $itk_component(volume) \
     1347                    "Show the volume"
     1348            }
     1349        }
     1350        "volumeLighting" {
     1351            set bool $_settings(volumeLighting)
     1352            SendCmd "polydata lighting $bool"
     1353        }
     1354        "volumeEdges" {
     1355            set bool $_settings(volumeEdges)
     1356            SendCmd "polydata edges $bool"
     1357        }
     1358        "axesVisible" {
     1359            set bool $_settings(axesVisible)
     1360            SendCmd "axis visible all $bool"
     1361        }
     1362        "axisLabelsVisible" {
     1363            set bool $_settings(axisLabelsVisible)
     1364            SendCmd "axis labels all $bool"
     1365        }
     1366        "axisXGrid" - "axisYGrid" - "axisZGrid" {
     1367            set axis [string tolower [string range $what 4 4]]
    13271368            set bool $_settings($what)
    1328             SendCmd "axis visible all $bool"
    1329         }
    1330         "-axislabelsvisible" {
    1331             set bool $_settings($what)
    1332             SendCmd "axis labels all $bool"
    1333         }
    1334         "-axisminorticks" {
    1335             set bool $_settings($what)
    1336             SendCmd "axis minticks all $bool"
    1337         }
    1338         "-axismode" {
     1369            SendCmd "axis grid $axis $bool"
     1370        }
     1371        "axis-mode" {
    13391372            set mode [$itk_component(axismode) value]
    13401373            set mode [$itk_component(axismode) translate $mode]
     
    13421375            SendCmd "axis flymode $mode"
    13431376        }
    1344         "-cutplaneedges" {
     1377        "cutplaneEdges" {
    13451378            set bool $_settings($what)
    13461379            SendCmd "cutplane edges $bool"
    13471380        }
    1348         "-cutplanevisible" {
     1381        "cutplaneVisible" {
    13491382            set bool $_settings($what)
    13501383            SendCmd "cutplane visible $bool"
    13511384        }
    1352         "-cutplanewireframe" {
     1385        "cutplaneWireframe" {
    13531386            set bool $_settings($what)
    13541387            SendCmd "cutplane wireframe $bool"
    13551388        }
    1356         "-cutplanelighting" {
     1389        "cutplaneLighting" {
    13571390            set bool $_settings($what)
    13581391            SendCmd "cutplane lighting $bool"
    13591392        }
    1360         "-cutplaneopacity" {
     1393        "cutplaneOpacity" {
    13611394            set val $_settings($what)
    13621395            set sval [expr { 0.01 * double($val) }]
    13631396            SendCmd "cutplane opacity $sval"
    13641397        }
    1365         "-cutplanexvisible" - "-cutplaneyvisible" - "-cutplanezvisible" {
    1366             set axis [string range $what 9 9]
     1398        "cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" {
     1399            set axis [string tolower [string range $what 8 8]]
    13671400            set bool $_settings($what)
    13681401            if { $bool } {
     
    13751408            SendCmd "cutplane axis $axis $bool"
    13761409        }
    1377         "-cutplanexposition" - "-cutplaneyposition" - "-cutplanezposition" {
    1378             set axis [string range $what 9 9]
     1410        "cutplaneXPosition" - "cutplaneYPosition" - "cutplaneZPosition" {
     1411            set axis [string tolower [string range $what 8 8]]
    13791412            set pos [expr $_settings($what) * 0.01]
    13801413            SendCmd "cutplane slice ${axis} ${pos}"
    13811414            set _cutplanePending 0
    13821415        }
    1383         "-field" {
    1384             set label [$itk_component(field) value]
    1385             set fname [$itk_component(field) translate $label]
    1386             set _settings($what) $fname
    1387             if { [info exists _fields($fname)] } {
    1388                 foreach { label units components } $_fields($fname) break
    1389                 if { $components > 1 } {
    1390                     set _colorMode vmag
    1391                 } else {
    1392                     set _colorMode scalar
    1393                 }
    1394                 set _curFldName $fname
    1395                 set _curFldLabel $label
    1396             } else {
    1397                 puts stderr "unknown field \"$fname\""
    1398                 return
    1399             }
    1400             # Get the new limits because the field changed.
    1401             if { ![info exists _limits($_curFldName)] } {
    1402                 SendCmd "dataset maprange all"
    1403             } else {
    1404                 SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"
    1405             }
    1406             SendCmd "streamlines colormode $_colorMode $_curFldName"
    1407             SendCmd "cutplane colormode $_colorMode $_curFldName"
    1408             DrawLegend
    1409         }
    1410         "-streamlinesseedsvisible" {
     1416        "streamlinesSeedsVisible" {
    14111417            set bool $_settings($what)
    14121418            SendCmd "streamlines seed visible $bool"
    14131419        }
    1414         "-streamlinesnumseeds" {
     1420        "streamlinesNumSeeds" {
    14151421            set density $_settings($what)
    14161422            EventuallyReseed $density
    14171423        }
    1418         "-streamlinesvisible" {
     1424        "streamlinesVisible" {
    14191425            set bool $_settings($what)
    14201426            SendCmd "streamlines visible $bool"
     
    14271433            }
    14281434        }
    1429         "-streamlinesmode" {
     1435        "streamlinesMode" {
    14301436            set mode [$itk_component(streammode) value]
    1431             set _settings($what) $mode
     1437            set _settings(streamlinesMode) $mode
    14321438            switch -- $mode {
    14331439                "lines" {
     
    14421448            }
    14431449        }
    1444         "-streamlinescolormap" {
     1450        "streamlinesColormap" {
    14451451            set colormap [$itk_component(colormap) value]
    1446             set _settings($what) $colormap
     1452            set _settings(streamlinesColormap) $colormap
    14471453            foreach dataset [CurrentDatasets -visible $_first] {
    14481454                foreach {dataobj comp} [split $dataset -] break
     
    14511457            set _legendPending 1
    14521458        }
    1453         "-streamlinesopacity" {
    1454             set val $_settings($what)
     1459        "streamlinesOpacity" {
     1460            set val $_settings(streamlinesOpacity)
    14551461            set sval [expr { 0.01 * double($val) }]
    14561462            SendCmd "streamlines opacity $sval"
    14571463        }
    1458         "-streamlinesscale" {
    1459             set val $_settings($what)
     1464        "streamlinesScale" {
     1465            set val $_settings(streamlinesScale)
    14601466            set sval [expr { 0.01 * double($val) }]
    14611467            SendCmd "streamlines scale $sval $sval $sval"
    14621468        }
    1463         "-streamlineslighting" {
    1464             set bool $_settings($what)
     1469        "streamlinesLighting" {
     1470            set bool $_settings(streamlinesLighting)
    14651471            SendCmd "streamlines lighting $bool"
    14661472        }
    1467         "-volumeopacity" {
    1468             set val $_settings($what)
    1469             set sval [expr { 0.01 * double($val) }]
    1470             SendCmd "polydata opacity $sval"
    1471         }
    1472         "-volumewireframe" {
    1473             set bool $_settings($what)
    1474             SendCmd "polydata wireframe $bool"
    1475         }
    1476         "-volumevisible" {
    1477             set bool $_settings($what)
    1478             SendCmd "polydata visible $bool"
    1479             if { $bool } {
    1480                 Rappture::Tooltip::for $itk_component(volume) \
    1481                     "Hide the volume"
     1473        "field" {
     1474            set label [$itk_component(field) value]
     1475            set fname [$itk_component(field) translate $label]
     1476            set _settings(field) $fname
     1477            if { [info exists _fields($fname)] } {
     1478                foreach { label units components } $_fields($fname) break
     1479                if { $components > 1 } {
     1480                    set _colorMode vmag
     1481                } else {
     1482                    set _colorMode scalar
     1483                }
     1484                set _curFldName $fname
     1485                set _curFldLabel $label
    14821486            } else {
    1483                 Rappture::Tooltip::for $itk_component(volume) \
    1484                     "Show the volume"
    1485             }
    1486         }
    1487         "-volumelighting" {
    1488             set bool $_settings($what)
    1489             SendCmd "polydata lighting $bool"
    1490         }
    1491         "-volumeedges" {
    1492             set bool $_settings($what)
    1493             SendCmd "polydata edges $bool"
    1494         }
    1495         "-xgrid" - "-ygrid" - "-zgrid" {
    1496             set axis [string range $what 1 1]
    1497             set bool $_settings($what)
    1498             SendCmd "axis grid $axis $bool"
     1487                puts stderr "unknown field \"$fname\""
     1488                return
     1489            }
     1490            # Get the new limits because the field changed.
     1491            SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"
     1492            SendCmd "streamlines colormode $_colorMode $_curFldName"
     1493            SendCmd "cutplane colormode $_colorMode $_curFldName"
     1494            DrawLegend
    14991495        }
    15001496        default {
     
    15141510    set font "Arial 8"
    15151511    set lineht [font metrics $font -linespace]
     1512    set c $itk_component(legend)
    15161513    set w 12
    15171514    set h [expr {$_height - 3 * ($lineht + 2)}]
    1518     if { $h < 1 } {
     1515    if { $h < 1} {
    15191516        return
    15201517    }
     
    15811578}
    15821579
     1580
    15831581#
    15841582# BuildColormap --
     
    15901588        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    15911589    }
    1592     if { ![info exists _settings(-volumeopacity)] } {
    1593         set _settings(-volumeopacity) $style(-opacity)
    1594     }
    1595     set max $_settings(-volumeopacity)
     1590    if { ![info exists _settings(volumeOpacity)] } {
     1591        set _settings(volumeOpacity) $style(-opacity)
     1592    }
     1593    set max $_settings(volumeOpacity)
    15961594
    15971595    set wmap "0.0 1.0 1.0 1.0"
     
    16041602itcl::configbody Rappture::VtkStreamlinesViewer::plotbackground {
    16051603    if { [isconnected] } {
    1606         set rgb [Color2RGB $itk_option(-plotbackground)]
    1607         SendCmd "screen bgcolor $rgb"
     1604        foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
     1605        SendCmd "screen bgcolor $r $g $b"
    16081606    }
    16091607}
     
    16141612itcl::configbody Rappture::VtkStreamlinesViewer::plotforeground {
    16151613    if { [isconnected] } {
    1616         set rgb [Color2RGB $itk_option(-plotforeground)]
    1617         SendCmd "axis color all $rgb"
    1618         SendCmd "outline color $rgb"
    1619         SendCmd "cutplane color $rgb"
     1614        foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
     1615        #fix this!
     1616        #SendCmd "color background $r $g $b"
    16201617    }
    16211618}
     
    16331630    checkbutton $inner.volume \
    16341631        -text "Show Volume" \
    1635         -variable [itcl::scope _settings(-volumevisible)] \
    1636         -command [itcl::code $this AdjustSetting -volumevisible] \
     1632        -variable [itcl::scope _settings(volumeVisible)] \
     1633        -command [itcl::code $this AdjustSetting volumeVisible] \
    16371634        -font "Arial 9"
    16381635
    16391636    checkbutton $inner.wireframe \
    16401637        -text "Show Wireframe" \
    1641         -variable [itcl::scope _settings(-volumewireframe)] \
    1642         -command [itcl::code $this AdjustSetting -volumewireframe] \
     1638        -variable [itcl::scope _settings(volumeWireframe)] \
     1639        -command [itcl::code $this AdjustSetting volumeWireframe] \
    16431640        -font "Arial 9"
    16441641
    16451642    checkbutton $inner.lighting \
    16461643        -text "Enable Lighting" \
    1647         -variable [itcl::scope _settings(-volumelighting)] \
    1648         -command [itcl::code $this AdjustSetting -volumelighting] \
     1644        -variable [itcl::scope _settings(volumeLighting)] \
     1645        -command [itcl::code $this AdjustSetting volumeLighting] \
    16491646        -font "Arial 9"
    16501647
    16511648    checkbutton $inner.edges \
    16521649        -text "Show Edges" \
    1653         -variable [itcl::scope _settings(-volumeedges)] \
    1654         -command [itcl::code $this AdjustSetting -volumeedges] \
     1650        -variable [itcl::scope _settings(volumeEdges)] \
     1651        -command [itcl::code $this AdjustSetting volumeEdges] \
    16551652        -font "Arial 9"
    16561653
    16571654    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    16581655    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1659         -variable [itcl::scope _settings(-volumeopacity)] \
     1656        -variable [itcl::scope _settings(volumeOpacity)] \
    16601657        -width 10 \
    16611658        -showvalue off \
    1662         -command [itcl::code $this AdjustSetting -volumeopacity]
     1659        -command [itcl::code $this AdjustSetting volumeOpacity]
    16631660
    16641661    blt::table $inner \
     
    16731670}
    16741671
     1672
    16751673itcl::body Rappture::VtkStreamlinesViewer::BuildStreamsTab {} {
    16761674
     
    16851683    checkbutton $inner.streamlines \
    16861684        -text "Show Streamlines" \
    1687         -variable [itcl::scope _settings(-streamlinesvisible)] \
    1688         -command [itcl::code $this AdjustSetting -streamlinesvisible] \
     1685        -variable [itcl::scope _settings(streamlinesVisible)] \
     1686        -command [itcl::code $this AdjustSetting streamlinesVisible] \
    16891687        -font "Arial 9"
    16901688   
    16911689    checkbutton $inner.lighting \
    16921690        -text "Enable Lighting" \
    1693         -variable [itcl::scope _settings(-streamlineslighting)] \
    1694         -command [itcl::code $this AdjustSetting -streamlineslighting] \
     1691        -variable [itcl::scope _settings(streamlinesLighting)] \
     1692        -command [itcl::code $this AdjustSetting streamlinesLighting] \
    16951693        -font "Arial 9"
    16961694
    16971695    checkbutton $inner.seeds \
    16981696        -text "Show Seeds" \
    1699         -variable [itcl::scope _settings(-streamlinesseedsvisible)] \
    1700         -command [itcl::code $this AdjustSetting -streamlinesseedsvisible] \
     1697        -variable [itcl::scope _settings(streamlinesSeedsVisible)] \
     1698        -command [itcl::code $this AdjustSetting streamlinesSeedsVisible] \
    17011699        -font "Arial 9"
    17021700
     
    17091707        "ribbons"   "ribbons" \
    17101708        "tubes"     "tubes"
    1711     $itk_component(streammode) value $_settings(-streamlinesmode)
    1712     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -streamlinesmode]
     1709    $itk_component(streammode) value $_settings(streamlinesMode)
     1710    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting streamlinesMode]
    17131711
    17141712    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    17151713    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1716         -variable [itcl::scope _settings(-streamlinesopacity)] \
     1714        -variable [itcl::scope _settings(streamlinesOpacity)] \
    17171715        -width 10 \
    17181716        -showvalue off \
    1719         -command [itcl::code $this AdjustSetting -streamlinesopacity]
     1717        -command [itcl::code $this AdjustSetting streamlinesOpacity]
    17201718
    17211719    label $inner.density_l -text "No. Seeds" -font "Arial 9"
    17221720    ::scale $inner.density -from 1 -to 1000 -orient horizontal \
    1723         -variable [itcl::scope _settings(-streamlinesnumseeds)] \
     1721        -variable [itcl::scope _settings(streamlinesNumSeeds)] \
    17241722        -width 10 \
    17251723        -showvalue on \
    1726         -command [itcl::code $this AdjustSetting -streamlinesnumseeds]
     1724        -command [itcl::code $this AdjustSetting streamlinesNumSeeds]
    17271725
    17281726    label $inner.scale_l -text "Scale" -font "Arial 9"
    17291727    ::scale $inner.scale -from 1 -to 100 -orient horizontal \
    1730         -variable [itcl::scope _settings(-streamlinesscale)] \
     1728        -variable [itcl::scope _settings(streamlinesScale)] \
    17311729        -width 10 \
    17321730        -showvalue off \
    1733         -command [itcl::code $this AdjustSetting -streamlinesscale]
     1731        -command [itcl::code $this AdjustSetting streamlinesScale]
    17341732
    17351733    label $inner.field_l -text "Color by" -font "Arial 9"
     
    17381736    }
    17391737    bind $inner.field <<Value>> \
    1740         [itcl::code $this AdjustSetting -field]
     1738        [itcl::code $this AdjustSetting field]
    17411739
    17421740    label $inner.colormap_l -text "Colormap" -font "Arial 9"
     
    17441742        Rappture::Combobox $inner.colormap -width 10 -editable no
    17451743    }
    1746     $inner.colormap choices insert end [GetColormapList]
     1744    $inner.colormap choices insert end \
     1745        "BCGYR"              "BCGYR"            \
     1746        "BGYOR"              "BGYOR"            \
     1747        "blue"               "blue"             \
     1748        "blue-to-brown"      "blue-to-brown"    \
     1749        "blue-to-orange"     "blue-to-orange"   \
     1750        "blue-to-grey"       "blue-to-grey"     \
     1751        "green-to-magenta"   "green-to-magenta" \
     1752        "greyscale"          "greyscale"        \
     1753        "nanohub"            "nanohub"          \
     1754        "rainbow"            "rainbow"          \
     1755        "spectral"           "spectral"         \
     1756        "ROYGB"              "ROYGB"            \
     1757        "RYGCB"              "RYGCB"            \
     1758        "brown-to-blue"      "brown-to-blue"    \
     1759        "grey-to-blue"       "grey-to-blue"     \
     1760        "orange-to-blue"     "orange-to-blue"   
    17471761
    17481762    $itk_component(colormap) value "BCGYR"
    17491763    bind $inner.colormap <<Value>> \
    1750         [itcl::code $this AdjustSetting -streamlinescolormap]
     1764        [itcl::code $this AdjustSetting streamlinesColormap]
    17511765
    17521766    blt::table $inner \
     
    17751789    set inner [$itk_component(main) insert end \
    17761790        -title "Axis Settings" \
    1777         -icon [Rappture::icon axis2]]
     1791        -icon [Rappture::icon axis1]]
    17781792    $inner configure -borderwidth 4
    17791793
    17801794    checkbutton $inner.visible \
    1781         -text "Axes" \
    1782         -variable [itcl::scope _settings(-axesvisible)] \
    1783         -command [itcl::code $this AdjustSetting -axesvisible] \
     1795        -text "Show Axes" \
     1796        -variable [itcl::scope _settings(axesVisible)] \
     1797        -command [itcl::code $this AdjustSetting axesVisible] \
    17841798        -font "Arial 9"
    17851799
    17861800    checkbutton $inner.labels \
    1787         -text "Axis Labels" \
    1788         -variable [itcl::scope _settings(-axislabelsvisible)] \
    1789         -command [itcl::code $this AdjustSetting -axislabelsvisible] \
     1801        -text "Show Axis Labels" \
     1802        -variable [itcl::scope _settings(axisLabelsVisible)] \
     1803        -command [itcl::code $this AdjustSetting axisLabelsVisible] \
    17901804        -font "Arial 9"
    1791     label $inner.grid_l -text "Grid" -font "Arial 9"
     1805
    17921806    checkbutton $inner.xgrid \
    1793         -text "X" \
    1794         -variable [itcl::scope _settings(-xgrid)] \
    1795         -command [itcl::code $this AdjustSetting -xgrid] \
     1807        -text "Show X Grid" \
     1808        -variable [itcl::scope _settings(axisXGrid)] \
     1809        -command [itcl::code $this AdjustSetting axisXGrid] \
    17961810        -font "Arial 9"
    17971811    checkbutton $inner.ygrid \
    1798         -text "Y" \
    1799         -variable [itcl::scope _settings(-ygrid)] \
    1800         -command [itcl::code $this AdjustSetting -ygrid] \
     1812        -text "Show Y Grid" \
     1813        -variable [itcl::scope _settings(axisYGrid)] \
     1814        -command [itcl::code $this AdjustSetting axisYGrid] \
    18011815        -font "Arial 9"
    18021816    checkbutton $inner.zgrid \
    1803         -text "Z" \
    1804         -variable [itcl::scope _settings(-zgrid)] \
    1805         -command [itcl::code $this AdjustSetting -zgrid] \
    1806         -font "Arial 9"
    1807     checkbutton $inner.minorticks \
    1808         -text "Minor Ticks" \
    1809         -variable [itcl::scope _settings(-axisminorticks)] \
    1810         -command [itcl::code $this AdjustSetting -axisminorticks] \
     1817        -text "Show Z Grid" \
     1818        -variable [itcl::scope _settings(axisZGrid)] \
     1819        -command [itcl::code $this AdjustSetting axisZGrid] \
    18111820        -font "Arial 9"
    18121821
     
    18191828        "static_triad"    "static" \
    18201829        "closest_triad"   "closest" \
    1821         "furthest_triad"  "farthest" \
     1830        "furthest_triad"  "furthest" \
    18221831        "outer_edges"     "outer"         
    1823     $itk_component(axismode) value $_settings(-axismode)
    1824     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
     1832    $itk_component(axismode) value "static"
     1833    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode]
    18251834
    18261835    blt::table $inner \
    1827         0,0 $inner.visible -anchor w -cspan 4 \
    1828         1,0 $inner.labels  -anchor w -cspan 4 \
    1829         2,0 $inner.minorticks  -anchor w -cspan 4 \
    1830         4,0 $inner.grid_l  -anchor w \
    1831         4,1 $inner.xgrid   -anchor w \
    1832         4,2 $inner.ygrid   -anchor w \
    1833         4,3 $inner.zgrid   -anchor w \
    1834         5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
    1835         5,1 $inner.mode    -fill x   -cspan 3
     1836        0,0 $inner.visible -anchor w -cspan 2 \
     1837        1,0 $inner.labels  -anchor w -cspan 2 \
     1838        2,0 $inner.xgrid   -anchor w -cspan 2 \
     1839        3,0 $inner.ygrid   -anchor w -cspan 2 \
     1840        4,0 $inner.zgrid   -anchor w -cspan 2 \
     1841        5,0 $inner.mode_l  -anchor w -cspan 2 -padx { 2 0 } \
     1842        6,0 $inner.mode    -fill x   -cspan 2
    18361843
    18371844    blt::table configure $inner r* c* -resize none
    1838     blt::table configure $inner r7 c6 -resize expand
    1839     blt::table configure $inner r3 -height 0.125i
    1840 }
     1845    blt::table configure $inner r7 c1 -resize expand
     1846}
     1847
    18411848
    18421849itcl::body Rappture::VtkStreamlinesViewer::BuildCameraTab {} {
     
    18581865        0,0 $inner.view_l -anchor e -pady 2 \
    18591866        0,1 $inner.view -anchor w -pady 2
    1860     blt::table configure $inner r0 -resize none
    18611867
    18621868    set labels { qx qy qz qw xpan ypan zoom }
     
    18651871        label $inner.${tag}label -text $tag -font "Arial 9"
    18661872        entry $inner.${tag} -font "Arial 9"  -bg white \
    1867             -textvariable [itcl::scope _view(-$tag)]
    1868         bind $inner.${tag} <Return> \
    1869             [itcl::code $this camera set -${tag}]
    1870         bind $inner.${tag} <KP_Enter> \
    1871             [itcl::code $this camera set -${tag}]
     1873            -textvariable [itcl::scope _view($tag)]
     1874        bind $inner.${tag} <KeyPress-Return> \
     1875            [itcl::code $this camera set ${tag}]
    18721876        blt::table $inner \
    18731877            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    18781882    checkbutton $inner.ortho \
    18791883        -text "Orthographic Projection" \
    1880         -variable [itcl::scope _view(-ortho)] \
    1881         -command [itcl::code $this camera set -ortho] \
     1884        -variable [itcl::scope _view(ortho)] \
     1885        -command [itcl::code $this camera set ortho] \
    18821886        -font "Arial 9"
    18831887    blt::table $inner \
     
    18861890    incr row
    18871891
    1888     blt::table configure $inner c* -resize none
     1892    blt::table configure $inner c* r* -resize none
    18891893    blt::table configure $inner c2 -resize expand
    18901894    blt::table configure $inner r$row -resize expand
     
    19031907    checkbutton $inner.visible \
    19041908        -text "Show Cutplanes" \
    1905         -variable [itcl::scope _settings(-cutplanevisible)] \
    1906         -command [itcl::code $this AdjustSetting -cutplanevisible] \
     1909        -variable [itcl::scope _settings(cutplaneVisible)] \
     1910        -command [itcl::code $this AdjustSetting cutplaneVisible] \
    19071911        -font "Arial 9"
    19081912
    19091913    checkbutton $inner.wireframe \
    19101914        -text "Show Wireframe" \
    1911         -variable [itcl::scope _settings(-cutplanewireframe)] \
    1912         -command [itcl::code $this AdjustSetting -cutplanewireframe] \
     1915        -variable [itcl::scope _settings(cutplaneWireframe)] \
     1916        -command [itcl::code $this AdjustSetting cutplaneWireframe] \
    19131917        -font "Arial 9"
    19141918
    19151919    checkbutton $inner.lighting \
    19161920        -text "Enable Lighting" \
    1917         -variable [itcl::scope _settings(-cutplanelighting)] \
    1918         -command [itcl::code $this AdjustSetting -cutplanelighting] \
     1921        -variable [itcl::scope _settings(cutplaneLighting)] \
     1922        -command [itcl::code $this AdjustSetting cutplaneLighting] \
    19191923        -font "Arial 9"
    19201924
    19211925    checkbutton $inner.edges \
    19221926        -text "Show Edges" \
    1923         -variable [itcl::scope _settings(-cutplaneedges)] \
    1924         -command [itcl::code $this AdjustSetting -cutplaneedges] \
     1927        -variable [itcl::scope _settings(cutplaneEdges)] \
     1928        -command [itcl::code $this AdjustSetting cutplaneEdges] \
    19251929        -font "Arial 9"
    19261930
    19271931    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    19281932    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1929         -variable [itcl::scope _settings(-cutplaneopacity)] \
     1933        -variable [itcl::scope _settings(cutplaneOpacity)] \
    19301934        -width 10 \
    19311935        -showvalue off \
    1932         -command [itcl::code $this AdjustSetting -cutplaneopacity]
    1933     $inner.opacity set $_settings(-cutplaneopacity)
     1936        -command [itcl::code $this AdjustSetting cutplaneOpacity]
     1937    $inner.opacity set $_settings(cutplaneOpacity)
    19341938
    19351939    # X-value slicer...
     
    19381942            -onimage [Rappture::icon x-cutplane-red] \
    19391943            -offimage [Rappture::icon x-cutplane-red] \
    1940             -command [itcl::code $this AdjustSetting -cutplanexvisible] \
    1941             -variable [itcl::scope _settings(-cutplanexvisible)]
     1944            -command [itcl::code $this AdjustSetting cutplaneXVisible] \
     1945            -variable [itcl::scope _settings(cutplaneXVisible)]
    19421946    }
    19431947    Rappture::Tooltip::for $itk_component(xCutButton) \
     
    19501954            -borderwidth 1 -highlightthickness 0 \
    19511955            -command [itcl::code $this EventuallySetCutplane x] \
    1952             -variable [itcl::scope _settings(-cutplanexposition)] \
     1956            -variable [itcl::scope _settings(cutplaneXPosition)] \
    19531957            -foreground red3 -font "Arial 9 bold"
    19541958    } {
     
    19671971            -onimage [Rappture::icon y-cutplane-green] \
    19681972            -offimage [Rappture::icon y-cutplane-green] \
    1969             -command [itcl::code $this AdjustSetting -cutplaneyvisible] \
    1970             -variable [itcl::scope _settings(-cutplaneyvisible)]
     1973            -command [itcl::code $this AdjustSetting cutplaneYVisible] \
     1974            -variable [itcl::scope _settings(cutplaneYVisible)]
    19711975    }
    19721976    Rappture::Tooltip::for $itk_component(yCutButton) \
     
    19791983            -borderwidth 1 -highlightthickness 0 \
    19801984            -command [itcl::code $this EventuallySetCutplane y] \
    1981             -variable [itcl::scope _settings(-cutplaneyposition)] \
     1985            -variable [itcl::scope _settings(cutplaneYPosition)] \
    19821986            -foreground green3 -font "Arial 9 bold"
    19831987    } {
     
    19962000            -onimage [Rappture::icon z-cutplane-blue] \
    19972001            -offimage [Rappture::icon z-cutplane-blue] \
    1998             -command [itcl::code $this AdjustSetting -cutplanezvisible] \
    1999             -variable [itcl::scope _settings(-cutplanezvisible)]
     2002            -command [itcl::code $this AdjustSetting cutplaneZVisible] \
     2003            -variable [itcl::scope _settings(cutplaneZVisible)]
    20002004    }
    20012005    Rappture::Tooltip::for $itk_component(zCutButton) \
     
    20082012            -borderwidth 1 -highlightthickness 0 \
    20092013            -command [itcl::code $this EventuallySetCutplane z] \
    2010             -variable [itcl::scope _settings(-cutplanezposition)] \
     2014            -variable [itcl::scope _settings(cutplaneZPosition)] \
    20112015            -foreground blue3 -font "Arial 9 bold"
    20122016    } {
     
    20452049        }
    20462050        "set" {
    2047             set what [lindex $args 0]
    2048             set x $_view($what)
     2051            set who [lindex $args 0]
     2052            set x $_view($who)
    20492053            set code [catch { string is double $x } result]
    20502054            if { $code != 0 || !$result } {
    20512055                return
    20522056            }
    2053             switch -- $what {
    2054                 "-ortho" {
    2055                     if {$_view($what)} {
     2057            switch -- $who {
     2058                "ortho" {
     2059                    if {$_view(ortho)} {
    20562060                        SendCmd "camera mode ortho"
    20572061                    } else {
     
    20592063                    }
    20602064                }
    2061                 "-xpan" - "-ypan" {
     2065                "xpan" - "ypan" {
    20622066                    PanCamera
    20632067                }
    2064                 "-qx" - "-qy" - "-qz" - "-qw" {
    2065                     set q [ViewToQuaternion]
     2068                "qx" - "qy" - "qz" - "qw" {
     2069                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    20662070                    $_arcball quaternion $q
    20672071                    EventuallyRotate $q
    20682072                }
    2069                 "-zoom" {
    2070                     SendCmd "camera zoom $_view($what)"
     2073                "zoom" {
     2074                    SendCmd "camera zoom $_view(zoom)"
    20712075                }
    20722076            }
     
    21582162    }
    21592163    array set settings $style
    2160     StartBufferingCommands
    21612164    SendCmd "streamlines add $tag"
    21622165    SendCmd "streamlines seed visible off $tag"
     
    21652168        set length [string length $seeds]
    21662169        SendCmd "streamlines seed fmesh 200 data follows $length $tag"
    2167         append _outbuf $seeds
     2170        SendCmd "$seeds"
    21682171        set _seeds($dataobj) 1
    21692172    }
     
    21712174    SendCmd "polydata add $tag"
    21722175    SendCmd "polydata colormode constant {} $tag"
    2173     set _settings(-volumeedges) $settings(-edges)
    2174     set _settings(-volumelighting) $settings(-lighting)
    2175     set _settings(-volumeopacity) $settings(-opacity)
    2176     set _settings(-volumewireframe) $settings(-wireframe)
    2177     set _settings(-volumeopacity) [expr $settings(-opacity) * 100.0]
    2178     StopBufferingCommands
     2176    set _settings(volumeEdges) $settings(-edges)
     2177    set _settings(volumeLighting) $settings(-lighting)
     2178    set _settings(volumeOpacity) $settings(-opacity)
     2179    set _settings(volumeWireframe) $settings(-wireframe)
     2180    set _settings(volumeOpacity) [expr $settings(-opacity) * 100.0]
    21792181    SetColormap $dataobj $comp
    21802182}
     
    22332235        set title $fname
    22342236    }
    2235     if { $_settings(-legendvisible) } {
     2237    if { $_settings(legendVisible) } {
    22362238        set x [expr $w - 2]
    22372239        if { [$c find withtag "legend"] == "" } {
     
    23642366        "move" {
    23652367            set axis [lindex $args 0]
     2368            set oldval $_settings(axis-${axis}position)
    23662369            set newval [lindex $args 1]
    23672370            if {[llength $args] != 2} {
     
    24112414        invoke {
    24122415            $itk_component(field) value $_curFldLabel
    2413             AdjustSetting -field
     2416            AdjustSetting field
    24142417        }
    24152418        default {
     
    24282431        bottom "0.707107 0.707107 0 0"
    24292432    }
    2430     foreach name { -qw -qx -qy -qz } value $positions($side) {
     2433    foreach name { qw qx qy qz } value $positions($side) {
    24312434        set _view($name) $value
    24322435    }
    2433     set q [ViewToQuaternion]
     2436    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    24342437    $_arcball quaternion $q
    24352438    SendCmd "camera orient $q"
    24362439    SendCmd "camera reset"
    2437     set _view(-xpan) 0
    2438     set _view(-ypan) 0
    2439     set _view(-zoom) 1.0
    2440 }
     2440    set _view(xpan) 0
     2441    set _view(ypan) 0
     2442    set _view(zoom) 1.0
     2443}
  • branches/1.3/gui/scripts/vtkviewer.tcl

    r4775 r4848  
    11# -*- mode: tcl; indent-tabs-mode: nil -*-
     2
    23# ----------------------------------------------------------------------
    34#  COMPONENT: vtkviewer - Vtk drawing object viewer
     
    78# ======================================================================
    89#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2004-2014  HUBzero Foundation, LLC
     10#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1011#
    1112#  See the file "license.terms" for information on usage and
     
    5758    public method get {args}
    5859    public method isconnected {}
    59     public method limits { dataobj }
     60    public method limits { colormap }
    6061    public method parameters {title args} {
    6162        # do nothing
     
    6364    public method scale {args}
    6465
     66    protected method Connect {}
     67    protected method CurrentDatasets {args}
     68    protected method Disconnect {}
     69    protected method DoResize {}
     70    protected method DoRotate {}
     71    protected method AdjustSetting {what {value ""}}
     72    protected method FixSettings { args  }
     73    protected method Pan {option x y}
     74    protected method Pick {x y}
     75    protected method Rebuild {}
     76    protected method ReceiveDataset { args }
     77    protected method ReceiveImage { args }
     78    protected method ReceiveLegend { colormap title vmin vmax size }
     79    protected method Rotate {option x y}
     80    protected method Zoom {option}
     81
    6582    # The following methods are only used by this class.
    66     private method AdjustSetting {what {value ""}}
    6783    private method BuildAxisTab {}
    6884    private method BuildCameraTab {}
     
    7086    private method BuildCutawayTab {}
    7187    private method BuildDownloadPopup { widget command }
    72     private method BuildGlyphsTab {}
    7388    private method BuildMoleculeTab {}
    7489    private method BuildPolydataTab {}
    7590    private method ChangeColormap { dataobj comp color }
    76     private method Connect {}
    77     private method CurrentDatasets {args}
    78     private method Disconnect {}
    79     private method DoResize {}
    80     private method DoRotate {}
    8191    private method DrawLegend {}
    8292    private method EnterLegend { x y }
    83     private method EventuallyResize { w h }
    84     private method EventuallyRotate { q }
    8593    private method EventuallySetAtomScale { args }
    8694    private method EventuallySetBondScale { args }
    87     private method EventuallySetGlyphsOpacity { args }
    8895    private method EventuallySetMoleculeOpacity { args }
    8996    private method EventuallySetMoleculeQuality { args }
    9097    private method EventuallySetPolydataOpacity { args }
     98    private method EventuallyResize { w h }
     99    private method EventuallyRotate { q }
    91100    private method GetImage { args }
    92101    private method GetVtkData { args }
    93     private method InitSettings { args  }
    94102    private method IsValidObject { dataobj }
    95103    private method LeaveLegend {}
    96104    private method MotionLegend { x y }
    97     private method Pan {option x y}
    98105    private method PanCamera {}
    99     private method Pick {x y}
    100     private method QuaternionToView { q } {
    101         foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    102     }
    103     private method Rebuild {}
    104     private method ReceiveDataset { args }
    105     private method ReceiveImage { args }
    106     private method ReceiveLegend { colormap title vmin vmax size }
    107106    private method RequestLegend {}
    108     private method Rotate {option x y}
    109107    private method SetAtomScale {}
    110108    private method SetBondScale {}
    111109    private method SetColormap { dataobj comp }
    112     private method SetGlyphsOpacity {}
    113110    private method SetLegendTip { x y }
    114111    private method SetMoleculeOpacity {}
     
    119116    private method SetPolydataOpacity {}
    120117    private method Slice {option args}
    121     private method ViewToQuaternion {} {
    122         return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    123     }
    124     private method Zoom {option}
    125118
    126119    private variable _arcball ""
     
    164157    private variable _polydataOpacityPending 0
    165158    private variable _glyphsOpacityPending 0
     159    private variable _updatePending 0;
    166160    private variable _rotateDelay 150
    167161    private variable _scaleDelay 100
     
    187181    $_dispatcher register !resize
    188182    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
     183
     184    # Update state event
     185    $_dispatcher register !update
     186    $_dispatcher dispatch $this !update "[itcl::code $this DoUpdate]; list"
    189187
    190188    # Rotate event
     
    216214    $_dispatcher dispatch $this !polydataOpacity \
    217215        "[itcl::code $this SetPolydataOpacity]; list"
    218 
    219     # Glyphs opacity event
    220     $_dispatcher register !glyphsOpacity
    221     $_dispatcher dispatch $this !glyphsOpacity \
    222         "[itcl::code $this SetGlyphsOpacity]; list"
    223 
    224216    #
    225217    # Populate parser with commands handle incoming requests
    226218    #
    227     $_parser alias image [itcl::code $this ReceiveImage]
    228     $_parser alias dataset [itcl::code $this ReceiveDataset]
    229     $_parser alias legend [itcl::code $this ReceiveLegend]
     219    $_parser alias image    [itcl::code $this ReceiveImage]
     220    $_parser alias dataset  [itcl::code $this ReceiveDataset]
     221    $_parser alias legend   [itcl::code $this ReceiveLegend]
    230222
    231223    # Initialize the view to some default parameters.
    232224    array set _view {
    233         -ortho           0
    234         -qw              0.853553
    235         -qx              -0.353553
    236         -qy              0.353553
    237         -qz              0.146447
    238         -xpan            0
    239         -ypan            0
    240         -zoom            1.0
     225        qw              0.853553
     226        qx              -0.353553
     227        qy              0.353553
     228        qz              0.146447
     229        zoom            1.0
     230        xpan            0
     231        ypan            0
     232        ortho           0
    241233    }
    242234    set _arcball [blt::arcball create 100 100]
    243     $_arcball quaternion [ViewToQuaternion]
     235    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     236    $_arcball quaternion $q
    244237
    245238    set _limits(zmin) 0.0
     
    247240
    248241    array set _axis [subst {
    249         labels          1
    250         minorticks      1
    251         visible         1
    252242        xgrid           0
    253243        ygrid           0
     
    262252        ydirection      -1
    263253        zdirection      -1
     254        visible         1
     255        labels          1
    264256    }]
    265257    array set _settings [subst {
    266         glyphs-edges            0
    267         glyphs-lighting         1
     258        legend                  1
    268259        glyphs-opacity          100
    269         glyphs-outline          0
    270         glyphs-palette          BCGYR
    271         glyphs-visible          1
    272260        glyphs-wireframe        0
    273         legend                  1
    274         molecule-atoms-visible  1
     261        polydata-edges          0
     262        polydata-lighting       1
     263        polydata-opacity        100
     264        polydata-palette        rainbow
     265        polydata-visible        1
     266        polydata-wireframe      0
    275267        molecule-atomscale      0.3
    276         molecule-bonds-visible  1
    277268        molecule-bondscale      0.075
    278269        molecule-bondstyle      "cylinder"
     270        molecule-atoms-visible  1
     271        molecule-bonds-visible  1
    279272        molecule-edges          0
    280273        molecule-labels         0
    281274        molecule-lighting       1
    282275        molecule-opacity        100
    283         molecule-outline        0
    284276        molecule-palette        elementDefault
    285277        molecule-quality        1.0
     
    288280        molecule-visible        1
    289281        molecule-wireframe      0
    290         polydata-edges          0
    291         polydata-lighting       1
    292         polydata-opacity        100
    293         polydata-outline        0
    294         polydata-palette        BCGYR
    295         polydata-visible        1
    296         polydata-wireframe      0
    297282    }]
    298283    itk_component add view {
     
    362347    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
    363348
    364     if { [catch {
    365         BuildAxisTab
    366         #BuildCutawayTab
    367         BuildCameraTab
    368     } errs] != 0 } {
    369         puts stderr errs=$errs
    370     }
     349    BuildAxisTab
     350    #BuildCutawayTab
     351    BuildCameraTab
    371352
    372353    # Legend
     354
    373355    set _image(legend) [image create photo]
    374356    itk_component add legend {
     
    396378    bind $itk_component(view) <ButtonRelease-1> \
    397379        [itcl::code $this Rotate release %x %y]
     380    bind $itk_component(view) <Configure> \
     381        [itcl::code $this EventuallyResize %w %h]
    398382
    399383    # Bindings for panning via mouse
     
    473457
    474458itcl::body Rappture::VtkViewer::DoRotate {} {
    475     SendCmd "camera orient [ViewToQuaternion]"
     459    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     460    SendCmd "camera orient $q"
    476461    set _rotatePending 0
    477462}
     
    488473
    489474itcl::body Rappture::VtkViewer::EventuallyRotate { q } {
    490     QuaternionToView $q
     475    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
    491476    if { !$_rotatePending } {
    492477        set _rotatePending 1
     
    521506}
    522507
    523 itcl::body Rappture::VtkViewer::SetGlyphsOpacity {} {
    524     set _glyphsOpacityPending 0
    525     foreach dataset [CurrentDatasets -visible $_first] {
    526         foreach { dataobj comp } [split $dataset -] break
    527         if { [$dataobj type $comp] == "glyphs" } {
    528             SetOpacity $dataset
    529         }
    530     }
    531 }
    532 
    533508itcl::body Rappture::VtkViewer::SetPolydataOpacity {} {
    534509    set _polydataOpacityPending 0
     
    573548        set _polydataOpacityPending 1
    574549        $_dispatcher event -after $_scaleDelay !polydataOpacity
    575     }
    576 }
    577 
    578 itcl::body Rappture::VtkViewer::EventuallySetGlyphsOpacity { args } {
    579     if { !$_glyphsOpacityPending } {
    580         set _glyphsOpacityPending 1
    581         $_dispatcher event -after $_scaleDelay !glyphsOpacity
    582550    }
    583551}
     
    748716        }
    749717        array set bounds [limits $dataobj]
    750         if {[info exists bounds(xmin)] && (![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin))} {
     718        if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} {
    751719            set _limits(xmin) $bounds(xmin)
    752720        }
    753         if {[info exists bounds(xmax)] && (![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax))} {
     721        if {![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax)} {
    754722            set _limits(xmax) $bounds(xmax)
    755723        }
    756724
    757         if {[info exists bounds(ymin)] && (![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin))} {
     725        if {![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin)} {
    758726            set _limits(ymin) $bounds(ymin)
    759727        }
    760         if {[info exists bounds(ymax)] && (![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax))} {
     728        if {![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax)} {
    761729            set _limits(ymax) $bounds(ymax)
    762730        }
    763731
    764         if {[info exists bounds(zmin)] && (![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin))} {
     732        if {![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin)} {
    765733            set _limits(zmin) $bounds(zmin)
    766734        }
    767         if {[info exists bounds(zmax)] && (![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax))} {
     735        if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} {
    768736            set _limits(zmax) $bounds(zmax)
    769         }
    770     }
    771     if { $_haveGlyphs } {
    772         if { ![$itk_component(main) exists "Glyphs Settings"] } {
    773             if { [catch { BuildGlyphsTab } errs ]  != 0 } {
    774                 puts stderr "errs=$errs"
    775             }
    776737        }
    777738    }
     
    867828        if { $_reportClientInfo }  {
    868829            # Tell the server the viewer, hub, user and session.
    869             # Do this immediately on connect before buffering any commands
     830            # Do this immediately on connect before buffing any commands
    870831            global env
    871832
     
    924885
    925886    # disconnected -- no more data sitting on server
    926     set _outbuf ""
    927887    array unset _datasets
    928888    array unset _data
     
    951911    if { $info(-type) == "image" } {
    952912        if 0 {
    953             set f [open "last.ppm" "w"]
     913            set f [open "last.ppm" "w"] 
    954914            fconfigure $f -encoding binary
    955915            puts -nonewline $f $bytes
     
    1037997        $_arcball resize $w $h
    1038998        DoResize
    1039         InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
    1040             axis-visible axis-labels axis-minorticks
    1041 
     999        FixSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
     1000            axis-visible axis-labels
     1001
     1002        if { $_havePolydata } {
     1003            FixSettings polydata-edges polydata-lighting polydata-opacity \
     1004                polydata-visible polydata-wireframe
     1005        }
    10421006        StopBufferingCommands
    10431007        SendCmd "imgflush"
     
    10611025                if { $bytes == "" } {
    10621026                    continue
    1063                 }
    1064                 if 0 {
    1065                     set f [open /tmp/vtkviewer.vtk "w"]
    1066                     fconfigure $f -translation binary -encoding binary
    1067                     puts -nonewline $f $bytes
    1068                     close $f
    10691027                }
    10701028                set length [string length $bytes]
     
    10791037                    lappend info "dataset_size"  $length
    10801038                    lappend info "dataset_tag"   $tag
    1081                     SendCmd "clientinfo [list $info]"
     1039                    SendCmd [list "clientinfo" $info]
    10821040                }
    10831041                SendCmd "dataset add $tag data follows $length"
     
    10871045            }
    10881046            lappend _obj2datasets($dataobj) $tag
    1089             set type [$dataobj type $comp]
    10901047            if { [info exists _obj2ovride($dataobj-raise)] } {
    1091                 SendCmd "$type visible 1 $tag"
     1048                SendCmd "dataset visible 1 $tag"
    10921049                SetOpacity $tag
    10931050            }
     
    11031060            set label [$_first hints ${axis}label]
    11041061            if { $label != "" } {
    1105                 SendCmd [list axis name $axis $label]
     1062                SendCmd "axis name $axis $label"
    11061063            }
    11071064            set units [$_first hints ${axis}units]
    11081065            if { $units != "" } {
    1109                 SendCmd [list axis units $axis $units]
    1110             }
    1111         }
    1112     }
    1113     if { $_haveGlyphs } {
    1114         InitSettings glyphs-outline
    1115     }
    1116     if { $_haveMolecules } {
    1117         InitSettings molecule-outline
    1118     }
    1119     if { $_havePolydata } {
    1120         InitSettings polydata-outline
     1066                SendCmd "axis units $axis $units"
     1067            }
     1068        }
    11211069    }
    11221070    if { $_reset } {
    1123         if { $_haveGlyphs } {
    1124             InitSettings glyphs-edges glyphs-lighting glyphs-opacity \
    1125                 glyphs-visible glyphs-wireframe
    1126         }
    1127         if { $_havePolydata } {
    1128             InitSettings polydata-edges polydata-lighting polydata-opacity \
    1129                 polydata-visible polydata-wireframe
    1130         }
    1131         if { $_haveMolecules } {
    1132             InitSettings molecule-edges molecule-lighting molecule-opacity \
    1133                 molecule-visible molecule-wireframe molecule-labels
    1134         }
    1135 
    1136         $_arcball quaternion [ViewToQuaternion]
     1071        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1072        $_arcball quaternion $q
    11371073        SendCmd "camera reset"
    1138         if { $_view(-ortho)} {
     1074        if { $_view(ortho)} {
    11391075            SendCmd "camera mode ortho"
    11401076        } else {
     
    11471083
    11481084    if { $_haveMolecules } {
    1149         #InitSettings molecule-representation
     1085        #FixSettings molecule-representation
    11501086    }
    11511087    set _reset 0
     
    12171153    switch -- $option {
    12181154        "in" {
    1219             set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1220             SendCmd "camera zoom $_view(-zoom)"
     1155            set _view(zoom) [expr {$_view(zoom)*1.25}]
     1156            SendCmd "camera zoom $_view(zoom)"
    12211157        }
    12221158        "out" {
    1223             set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1224             SendCmd "camera zoom $_view(-zoom)"
     1159            set _view(zoom) [expr {$_view(zoom)*0.8}]
     1160            SendCmd "camera zoom $_view(zoom)"
    12251161        }
    12261162        "reset" {
    12271163            array set _view {
    1228                 -qw      0.853553
    1229                 -qx      -0.353553
    1230                 -qy      0.353553
    1231                 -qz      0.146447
    1232                 -xpan    0
    1233                 -ypan    0
    1234                 -zoom    1.0
     1164                qw      0.853553
     1165                qx      -0.353553
     1166                qy      0.353553
     1167                qz      0.146447
     1168                zoom    1.0
     1169                xpan    0
     1170                ypan    0
    12351171            }
    12361172            if { $_first != "" } {
     
    12401176                }
    12411177            }
    1242             $_arcball quaternion [ViewToQuaternion]
     1178            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1179            $_arcball quaternion $q
    12431180            DoRotate
    12441181            SendCmd "camera reset"
     
    12481185
    12491186itcl::body Rappture::VtkViewer::PanCamera {} {
    1250     set x $_view(-xpan)
    1251     set y $_view(-ypan)
     1187    set x $_view(xpan)
     1188    set y $_view(ypan)
    12521189    SendCmd "camera pan $x $y"
    12531190}
     
    13261263            set x [expr $x / double($w)]
    13271264            set y [expr $y / double($h)]
    1328             set _view(-xpan) [expr $_view(-xpan) + $x]
    1329             set _view(-ypan) [expr $_view(-ypan) + $y]
     1265            set _view(xpan) [expr $_view(xpan) + $x]
     1266            set _view(ypan) [expr $_view(ypan) + $y]
    13301267            PanCamera
    13311268            return
     
    13491286            set _click(x) $x
    13501287            set _click(y) $y
    1351             set _view(-xpan) [expr $_view(-xpan) - $dx]
    1352             set _view(-ypan) [expr $_view(-ypan) - $dy]
     1288            set _view(xpan) [expr $_view(xpan) - $dx]
     1289            set _view(ypan) [expr $_view(ypan) - $dy]
    13531290            PanCamera
    13541291        }
     
    13641301
    13651302# ----------------------------------------------------------------------
    1366 # USAGE: InitSettings <what> ?<value>?
     1303# USAGE: FixSettings <what> ?<value>?
    13671304#
    13681305# Used internally to update rendering settings whenever parameters
     
    13701307# to the back end.
    13711308# ----------------------------------------------------------------------
    1372 itcl::body Rappture::VtkViewer::InitSettings { args } {
     1309itcl::body Rappture::VtkViewer::FixSettings { args } {
    13731310    foreach setting $args {
    13741311        AdjustSetting $setting
     
    13881325    }
    13891326    switch -- $what {
    1390         "glyphs-opacity" {
    1391             foreach dataset [CurrentDatasets -visible $_first] {
    1392                 foreach { dataobj comp } [split $dataset -] break
    1393                 if { [$dataobj type $comp] == "glyphs" } {
    1394                     SetOpacity $dataset
    1395                 }
    1396             }
    1397         }
    1398         "glyphs-outline" {
    1399             set bool $_settings($what)
    1400             foreach dataset [CurrentDatasets -visible $_first] {
    1401                 foreach { dataobj comp } [split $dataset -] break
    1402                 set type [$dataobj type $comp]
    1403                 if { $type == "glyphs" } {
    1404                     SendCmd "outline visible $bool $dataset"
    1405                 }
    1406             }
    1407         }
    1408         "glyphs-wireframe" {
    1409             set bool $_settings($what)
    1410             foreach dataset [CurrentDatasets -visible $_first] {
    1411                 foreach { dataobj comp } [split $dataset -] break
    1412                 set type [$dataobj type $comp]
    1413                 if { $type == "glyphs" } {
    1414                     SendCmd "$type wireframe $bool $dataset"
    1415                 }
    1416             }
    1417         }
    1418         "glyphs-visible" {
    1419             set bool $_settings($what)
    1420             foreach dataset [CurrentDatasets -visible $_first] {
    1421                 foreach { dataobj comp } [split $dataset -] break
    1422                 set type [$dataobj type $comp]
    1423                 if { $type == "glyphs" } {
    1424                     SendCmd "$type visible $bool $dataset"
    1425                 }
    1426             }
    1427         }
    1428         "glyphs-lighting" {
    1429             set bool $_settings($what)
    1430             foreach dataset [CurrentDatasets -visible $_first] {
    1431                 foreach { dataobj comp } [split $dataset -] break
    1432                 set type [$dataobj type $comp]
    1433                 if { $type == "glyphs" } {
    1434                     SendCmd "$type lighting $bool $dataset"
    1435                 }
    1436             }
    1437         }
    1438         "glyphs-edges" {
    1439             set bool $_settings($what)
    1440             foreach dataset [CurrentDatasets -visible $_first] {
    1441                 foreach { dataobj comp } [split $dataset -] break
    1442                 set type [$dataobj type $comp]
    1443                 if { $type == "glyphs" } {
    1444                     SendCmd "$type edges $bool $dataset"
    1445                 }
    1446             }
    1447         }
    1448         "glyphs-palette" {
    1449             set palette [$itk_component(glyphspalette) value]
    1450             set _settings($what) $palette
    1451             foreach dataset [CurrentDatasets -visible $_first] {
    1452                 foreach {dataobj comp} [split $dataset -] break
    1453                 set type [$dataobj type $comp]
    1454                 if { $type == "glyphs" } {
    1455                     ChangeColormap $dataobj $comp $palette
    1456                     # FIXME: fill in current selected fieldname
    1457                     #SendCmd "glyphs colormode scalar {} $dataset"
    1458                 }
    1459             }
    1460             set _legendPending 1
    1461         }
    14621327        "polydata-opacity" {
    14631328            foreach dataset [CurrentDatasets -visible $_first] {
     
    14681333            }
    14691334        }
    1470         "polydata-outline" {
    1471             set bool $_settings($what)
    1472             foreach dataset [CurrentDatasets -visible $_first] {
    1473                 foreach { dataobj comp } [split $dataset -] break
    1474                 set type [$dataobj type $comp]
    1475                 if { $type == "polydata" } {
    1476                     SendCmd "outline visible $bool $dataset"
    1477                 }
    1478             }
    1479         }
    14801335        "polydata-wireframe" {
    1481             set bool $_settings($what)
     1336            set bool $_settings(polydata-wireframe)
    14821337            foreach dataset [CurrentDatasets -visible $_first] {
    14831338                foreach { dataobj comp } [split $dataset -] break
     
    14891344        }
    14901345        "polydata-visible" {
    1491             set bool $_settings($what)
     1346            set bool $_settings(polydata-visible)
    14921347            foreach dataset [CurrentDatasets -visible $_first] {
    14931348                foreach { dataobj comp } [split $dataset -] break
     
    14991354        }
    15001355        "polydata-lighting" {
    1501             set bool $_settings($what)
     1356            set bool $_settings(polydata-lighting)
    15021357            foreach dataset [CurrentDatasets -visible $_first] {
    15031358                foreach { dataobj comp } [split $dataset -] break
     
    15091364        }
    15101365        "polydata-edges" {
    1511             set bool $_settings($what)
     1366            set bool $_settings(polydata-edges)
    15121367            foreach dataset [CurrentDatasets -visible $_first] {
    15131368                foreach { dataobj comp } [split $dataset -] break
     
    15201375        "polydata-palette" {
    15211376            set palette [$itk_component(meshpalette) value]
    1522             set _settings($what) $palette
     1377            set _settings(polydata-palette) $palette
    15231378            foreach dataset [CurrentDatasets -visible $_first] {
    15241379                foreach {dataobj comp} [split $dataset -] break
     
    15331388        }
    15341389        "molecule-opacity" {
     1390            set val $_settings(molecule-opacity)
     1391            set sval [expr { 0.01 * double($val) }]
    15351392            foreach dataset [CurrentDatasets -visible $_first] {
    15361393                foreach { dataobj comp } [split $dataset -] break
     
    15401397            }
    15411398        }
    1542         "molecule-outline" {
    1543             set bool $_settings($what)
    1544             foreach dataset [CurrentDatasets -visible $_first] {
    1545                 foreach { dataobj comp } [split $dataset -] break
    1546                 set type [$dataobj type $comp]
    1547                 if { $type == "molecule" } {
    1548                     SendCmd "outline visible $bool $dataset"
    1549                 }
    1550             }
    1551         }
    15521399        "molecule-wireframe" {
    1553             set bool $_settings($what)
     1400            set bool $_settings(molecule-wireframe)
    15541401            foreach dataset [CurrentDatasets -visible $_first] {
    15551402                foreach { dataobj comp } [split $dataset -] break
     
    15611408        }
    15621409        "molecule-visible" {
    1563             set bool $_settings($what)
     1410            set bool $_settings(molecule-visible)
    15641411            foreach dataset [CurrentDatasets -visible $_first] {
    15651412                foreach { dataobj comp } [split $dataset -] break
     
    15711418        }
    15721419        "molecule-lighting" {
    1573             set bool $_settings($what)
     1420            set bool $_settings(molecule-lighting)
    15741421            foreach dataset [CurrentDatasets -visible $_first] {
    15751422                foreach { dataobj comp } [split $dataset -] break
     
    15811428        }
    15821429        "molecule-edges" {
    1583             set bool $_settings($what)
     1430            set bool $_settings(molecule-edges)
    15841431            foreach dataset [CurrentDatasets -visible $_first] {
    15851432                foreach { dataobj comp } [split $dataset -] break
     
    15921439        "molecule-palette" {
    15931440            set palette [$itk_component(moleculepalette) value]
    1594             set _settings($what) $palette
     1441            set _moelculeSettings(palette) $palette
    15951442            foreach dataset [CurrentDatasets -visible $_first] {
    15961443                foreach {dataobj comp} [split $dataset -] break
     
    16561503                    set _settings(molecule-atoms-visible) 0
    16571504                    set _settings(molecule-bonds-visible) 1
    1658                     set _settings(molecule-bondstyle) line
     1505                    set _settings(molecule-bondstyle) cylinder
    16591506                    set _settings(molecule-atomscale) 1.0
    16601507                    set _settings(molecule-bondscale) 1.0
     
    16771524                set type [$dataobj type $comp]
    16781525                if { $type == "molecule" } {
    1679                     StartBufferingCommands
    1680                     SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset}]
    1681                     SendCmd [subst {molecule ascale $_settings(molecule-atomscale) $dataset}]
    1682                     SendCmd [subst {molecule bscale $_settings(molecule-bondscale) $dataset}]
    1683                     SendCmd [subst {molecule bstyle $_settings(molecule-bondstyle) $dataset}]
    1684                     SendCmd [subst {molecule atoms $_settings(molecule-atoms-visible) $dataset}]
    1685                     SendCmd [subst {molecule bonds $_settings(molecule-bonds-visible) $dataset}]
    1686                     StopBufferingCommands
     1526                    SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset
     1527molecule ascale $_settings(molecule-atomscale) $dataset
     1528molecule bscale $_settings(molecule-bondscale) $dataset
     1529molecule bstyle $_settings(molecule-bondstyle) $dataset
     1530molecule atoms $_settings(molecule-atoms-visible) $dataset
     1531molecule bonds $_settings(molecule-bonds-visible) $dataset}]
    16871532                }
    16881533            }
     
    16911536            set value [$itk_component(rscale) value]
    16921537            set value [$itk_component(rscale) translate $value]
    1693             set _settings($what) $value
     1538            set _settings(molecule-rscale) $value
    16941539            foreach dataset [CurrentDatasets -visible $_first] {
    16951540                foreach {dataobj comp} [split $dataset -] break
    16961541                set type [$dataobj type $comp]
    16971542                if { $type == "molecule" } {
    1698                     SendCmd [subst {molecule rscale $_settings($what) $dataset}]
     1543                    SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset}]
    16991544                }
    17001545            }
    17011546        }
    17021547        "molecule-labels" {
    1703             set bool $_settings($what)
     1548            set bool $_settings(molecule-labels)
    17041549            foreach dataset [CurrentDatasets -visible $_first] {
    17051550               foreach { dataobj comp } [split $dataset -] break
     
    17171562            set bool $_axis(labels)
    17181563            SendCmd "axis labels all $bool"
    1719         }
    1720         "axis-minorticks" {
    1721             set bool $_axis(minorticks)
    1722             SendCmd "axis minticks all $bool"
    17231564        }
    17241565        "axis-xgrid" {
     
    17771618    set font "Arial 8"
    17781619    set lineht [font metrics $font -linespace]
     1620    set c $itk_component(legend)
    17791621    set w 12
    17801622    set h [expr {$_height - 2 * ($lineht + 2)}]
    1781     if { $h < 1 } {
     1623    if { $h < 1} {
    17821624        return
    17831625    }
     
    18851727itcl::configbody Rappture::VtkViewer::plotbackground {
    18861728    if { [isconnected] } {
    1887         set rgb [Color2RGB $itk_option(-plotbackground)]
    1888         SendCmd "screen bgcolor $rgb"
     1729        foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
     1730        SendCmd "screen bgcolor $r $g $b"
    18891731    }
    18901732}
     
    18951737itcl::configbody Rappture::VtkViewer::plotforeground {
    18961738    if { [isconnected] } {
    1897         set rgb [Color2RGB $itk_option(-plotforeground)]
    1898         SendCmd "axis color all $rgb"
    1899         SendCmd "outline color $rgb"
     1739        foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
     1740        #fix this!
     1741        #SendCmd "color background $r $g $b"
    19001742    }
    19011743}
     
    19301772            file delete $tmpfile
    19311773            set output [$reader GetOutput]
    1932             if { $output == "" } {
    1933                 # Invalid VTK file -- loader failed to parse
    1934                 continue
    1935             }
    19361774            set _limits($tag) [$output GetBounds]
    19371775            if {$debug} {
     
    19921830}
    19931831
    1994 itcl::body Rappture::VtkViewer::BuildGlyphsTab {} {
     1832itcl::body Rappture::VtkViewer::BuildPolydataTab {} {
    19951833
    19961834    set fg [option get $itk_component(hull) font Font]
    19971835    #set bfg [option get $itk_component(hull) boldFont Font]
    19981836
    1999     set inner [$itk_component(main) insert 0 \
    2000         -title "Glyph Settings" \
    2001         -icon [Rappture::icon volume-on]]
    2002     $inner configure -borderwidth 4
    2003 
    2004     checkbutton $inner.glyphs \
    2005         -text "Show Glyphs" \
    2006         -variable [itcl::scope _settings(glyphs-visible)] \
    2007         -command [itcl::code $this AdjustSetting glyphs-visible] \
    2008         -font "Arial 9" -anchor w
    2009 
    2010     checkbutton $inner.outline \
    2011         -text "Show Outline" \
    2012         -variable [itcl::scope _settings(glyphs-outline)] \
    2013         -command [itcl::code $this AdjustSetting glyphs-outline] \
    2014         -font "Arial 9" -anchor w
    2015 
    2016     checkbutton $inner.wireframe \
    2017         -text "Show Wireframe" \
    2018         -variable [itcl::scope _settings(glyphs-wireframe)] \
    2019         -command [itcl::code $this AdjustSetting glyphs-wireframe] \
    2020         -font "Arial 9" -anchor w
    2021 
    2022     checkbutton $inner.lighting \
    2023         -text "Enable Lighting" \
    2024         -variable [itcl::scope _settings(glyphs-lighting)] \
    2025         -command [itcl::code $this AdjustSetting glyphs-lighting] \
    2026         -font "Arial 9" -anchor w
    2027 
    2028     checkbutton $inner.edges \
    2029         -text "Show Edges" \
    2030         -variable [itcl::scope _settings(glyphs-edges)] \
    2031         -command [itcl::code $this AdjustSetting glyphs-edges] \
    2032         -font "Arial 9" -anchor w
    2033 
    2034     label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w
    2035     itk_component add glyphspalette {
    2036         Rappture::Combobox $inner.palette -width 10 -editable no
    2037     }
    2038     $inner.palette choices insert end [GetColormapList]
    2039     $itk_component(glyphspalette) value "BCGYR"
    2040     bind $inner.palette <<Value>> \
    2041         [itcl::code $this AdjustSetting glyphs-palette]
    2042 
    2043     label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
    2044     ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    2045         -variable [itcl::scope _settings(glyphs-opacity)] \
    2046         -width 10 \
    2047         -showvalue off \
    2048         -command [itcl::code $this EventuallySetGlyphsOpacity]
    2049     $inner.opacity set $_settings(glyphs-opacity)
    2050 
    2051     blt::table $inner \
    2052         0,0 $inner.glyphs    -cspan 2  -anchor w -pady 2 \
    2053         1,0 $inner.outline   -cspan 2  -anchor w -pady 2 \
    2054         2,0 $inner.wireframe -cspan 2  -anchor w -pady 2 \
    2055         3,0 $inner.lighting  -cspan 2  -anchor w -pady 2 \
    2056         4,0 $inner.edges     -cspan 2  -anchor w -pady 2 \
    2057         5,0 $inner.opacity_l -anchor w -pady 2 \
    2058         5,1 $inner.opacity   -fill x   -pady 2 \
    2059         6,0 $inner.palette_l -anchor w -pady 2 \
    2060         6,1 $inner.palette   -fill x   -pady 2 
    2061 
    2062     blt::table configure $inner r* c* -resize none
    2063     blt::table configure $inner r8 c1 -resize expand
    2064 }
    2065 
    2066 itcl::body Rappture::VtkViewer::BuildPolydataTab {} {
    2067 
    2068     set fg [option get $itk_component(hull) font Font]
    2069     #set bfg [option get $itk_component(hull) boldFont Font]
    2070 
    2071     set inner [$itk_component(main) insert 0 \
     1837    set inner [$itk_component(main) insert end \
    20721838        -title "Mesh Settings" \
    20731839        -icon [Rappture::icon mesh]]
     
    20801846        -font "Arial 9" -anchor w
    20811847
    2082     checkbutton $inner.outline \
    2083         -text "Show Outline" \
    2084         -variable [itcl::scope _settings(polydata-outline)] \
    2085         -command [itcl::code $this AdjustSetting polydata-outline] \
    2086         -font "Arial 9" -anchor w
    2087 
    20881848    checkbutton $inner.wireframe \
    20891849        -text "Show Wireframe" \
     
    21081868        Rappture::Combobox $inner.palette -width 10 -editable no
    21091869    }
    2110     $inner.palette choices insert end [GetColormapList]
     1870    $inner.palette choices insert end \
     1871        "BCGYR"              "BCGYR"            \
     1872        "BGYOR"              "BGYOR"            \
     1873        "blue"               "blue"             \
     1874        "blue-to-brown"      "blue-to-brown"    \
     1875        "blue-to-orange"     "blue-to-orange"   \
     1876        "blue-to-grey"       "blue-to-grey"     \
     1877        "green-to-magenta"   "green-to-magenta" \
     1878        "greyscale"          "greyscale"        \
     1879        "nanohub"            "nanohub"          \
     1880        "rainbow"            "rainbow"          \
     1881        "spectral"           "spectral"         \
     1882        "ROYGB"              "ROYGB"            \
     1883        "RYGCB"              "RYGCB"            \
     1884        "brown-to-blue"      "brown-to-blue"    \
     1885        "grey-to-blue"       "grey-to-blue"     \
     1886        "orange-to-blue"     "orange-to-blue"   
     1887
    21111888    $itk_component(meshpalette) value "BCGYR"
    21121889    bind $inner.palette <<Value>> \
     
    21181895        -width 10 \
    21191896        -showvalue off \
    2120         -command [itcl::code $this EventuallySetPolydataOpacity]
     1897        -command [itcl::code $this AdjustSetting polydata-opacity]
    21211898    $inner.opacity set $_settings(polydata-opacity)
    21221899
    21231900    blt::table $inner \
    21241901        0,0 $inner.mesh      -cspan 2  -anchor w -pady 2 \
    2125         1,0 $inner.outline   -cspan 2  -anchor w -pady 2 \
    2126         2,0 $inner.wireframe -cspan 2  -anchor w -pady 2 \
    2127         3,0 $inner.lighting  -cspan 2  -anchor w -pady 2 \
    2128         4,0 $inner.edges     -cspan 2  -anchor w -pady 2 \
    2129         5,0 $inner.opacity_l -anchor w -pady 2 \
    2130         5,1 $inner.opacity   -fill x   -pady 2 \
    2131         6,0 $inner.palette_l -anchor w -pady 2 \
    2132         6,1 $inner.palette   -fill x   -pady 2 
     1902        1,0 $inner.wireframe -cspan 2  -anchor w -pady 2 \
     1903        2,0 $inner.lighting  -cspan 2  -anchor w -pady 2 \
     1904        3,0 $inner.edges     -cspan 2  -anchor w -pady 2 \
     1905        4,0 $inner.opacity_l -anchor w -pady 2 \
     1906        4,1 $inner.opacity   -fill x   -pady 2 \
     1907        5,0 $inner.palette_l -anchor w -pady 2 \
     1908        5,1 $inner.palette   -fill x   -pady 2 
    21331909
    21341910    blt::table configure $inner r* c* -resize none
    2135     blt::table configure $inner r8 c1 -resize expand
     1911    blt::table configure $inner r7 c1 -resize expand
    21361912}
    21371913
     
    21431919    set inner [$itk_component(main) insert end \
    21441920        -title "Axis Settings" \
    2145         -icon [Rappture::icon axis2]]
     1921        -icon [Rappture::icon axis1]]
    21461922    $inner configure -borderwidth 4
    21471923
    21481924    checkbutton $inner.visible \
    2149         -text "Axes" \
     1925        -text "Show Axes" \
    21501926        -variable [itcl::scope _axis(visible)] \
    21511927        -command [itcl::code $this AdjustSetting axis-visible] \
     
    21531929
    21541930    checkbutton $inner.labels \
    2155         -text "Axis Labels" \
     1931        -text "Show Axis Labels" \
    21561932        -variable [itcl::scope _axis(labels)] \
    21571933        -command [itcl::code $this AdjustSetting axis-labels] \
    21581934        -font "Arial 9"
    2159     label $inner.grid_l -text "Grid" -font "Arial 9"
    2160     checkbutton $inner.xgrid \
    2161         -text "X" \
     1935
     1936    checkbutton $inner.gridx \
     1937        -text "Show X Grid" \
    21621938        -variable [itcl::scope _axis(xgrid)] \
    21631939        -command [itcl::code $this AdjustSetting axis-xgrid] \
    21641940        -font "Arial 9"
    2165     checkbutton $inner.ygrid \
    2166         -text "Y" \
     1941    checkbutton $inner.gridy \
     1942        -text "Show Y Grid" \
    21671943        -variable [itcl::scope _axis(ygrid)] \
    21681944        -command [itcl::code $this AdjustSetting axis-ygrid] \
    21691945        -font "Arial 9"
    2170     checkbutton $inner.zgrid \
    2171         -text "Z" \
     1946    checkbutton $inner.gridz \
     1947        -text "Show Z Grid" \
    21721948        -variable [itcl::scope _axis(zgrid)] \
    21731949        -command [itcl::code $this AdjustSetting axis-zgrid] \
    21741950        -font "Arial 9"
    2175     checkbutton $inner.minorticks \
    2176         -text "Minor Ticks" \
    2177         -variable [itcl::scope _axis(minorticks)] \
    2178         -command [itcl::code $this AdjustSetting axis-minorticks] \
    2179         -font "Arial 9"
    21801951
    21811952    label $inner.mode_l -text "Mode" -font "Arial 9"
     
    21871958        "static_triad"    "static" \
    21881959        "closest_triad"   "closest" \
    2189         "furthest_triad"  "farthest" \
     1960        "furthest_triad"  "furthest" \
    21901961        "outer_edges"     "outer"         
    21911962    $itk_component(axismode) value "static"
     
    21931964
    21941965    blt::table $inner \
    2195         0,0 $inner.visible -anchor w -cspan 4 \
    2196         1,0 $inner.labels  -anchor w -cspan 4 \
    2197         2,0 $inner.minorticks  -anchor w -cspan 4 \
    2198         4,0 $inner.grid_l  -anchor w \
    2199         4,1 $inner.xgrid   -anchor w \
    2200         4,2 $inner.ygrid   -anchor w \
    2201         4,3 $inner.zgrid   -anchor w \
    2202         5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
    2203         5,1 $inner.mode    -fill x   -cspan 3
     1966        0,0 $inner.visible -anchor w -cspan 2 \
     1967        1,0 $inner.labels  -anchor w -cspan 2 \
     1968        2,0 $inner.gridx   -anchor w -cspan 2 \
     1969        3,0 $inner.gridy   -anchor w -cspan 2 \
     1970        4,0 $inner.gridz   -anchor w -cspan 2 \
     1971        5,0 $inner.mode_l  -anchor w -cspan 2 -padx { 2 0 } \
     1972        6,0 $inner.mode    -fill x   -cspan 2
    22041973
    22051974    blt::table configure $inner r* c* -resize none
    2206     blt::table configure $inner r7 c6 -resize expand
    2207     blt::table configure $inner r3 -height 0.125i
     1975    blt::table configure $inner r7 c1 -resize expand
    22081976}
    22091977
     
    22261994        0,0 $inner.view_l -anchor e -pady 2 \
    22271995        0,1 $inner.view -anchor w -pady 2
    2228     blt::table configure $inner r0 -resize none
    22291996
    22301997    set labels { qx qy qz qw xpan ypan zoom }
     
    22332000        label $inner.${tag}label -text $tag -font "Arial 9"
    22342001        entry $inner.${tag} -font "Arial 9"  -bg white \
    2235             -textvariable [itcl::scope _view(-$tag)]
    2236         bind $inner.${tag} <Return> \
    2237             [itcl::code $this camera set -${tag}]
    2238         bind $inner.${tag} <KP_Enter> \
    2239             [itcl::code $this camera set -${tag}]
     2002            -textvariable [itcl::scope _view($tag)]
     2003        bind $inner.${tag} <KeyPress-Return> \
     2004            [itcl::code $this camera set ${tag}]
    22402005        blt::table $inner \
    22412006            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    22462011    checkbutton $inner.ortho \
    22472012        -text "Orthographic Projection" \
    2248         -variable [itcl::scope _view(-ortho)] \
    2249         -command [itcl::code $this camera set -ortho] \
     2013        -variable [itcl::scope _view(ortho)] \
     2014        -command [itcl::code $this camera set ortho] \
    22502015        -font "Arial 9"
    22512016    blt::table $inner \
     
    22542019    incr row
    22552020
    2256     blt::table configure $inner c* -resize none
     2021    blt::table configure $inner c* r* -resize none
    22572022    blt::table configure $inner c2 -resize expand
    22582023    blt::table configure $inner r$row -resize expand
     
    23722137    $itk_component(zCutScale) set 100
    23732138    $itk_component(zCutScale) configure -state disabled
     2139    #$itk_component(zCutScale) configure -state disabled
    23742140    Rappture::Tooltip::for $itk_component(zCutScale) \
    23752141        "@[itcl::code $this Slice tooltip z]"
     
    24032169    set fg [option get $itk_component(hull) font Font]
    24042170
    2405     set inner [$itk_component(main) insert 0 \
     2171    set inner [$itk_component(main) insert end \
    24062172        -title "Molecule Settings" \
    24072173        -icon [Rappture::icon molecule]]
     
    24122178        -variable [itcl::scope _settings(molecule-visible)] \
    24132179        -command [itcl::code $this AdjustSetting molecule-visible] \
    2414         -font "Arial 9"
    2415 
    2416     checkbutton $inner.outline \
    2417         -text "Show Outline" \
    2418         -variable [itcl::scope _settings(molecule-outline)] \
    2419         -command [itcl::code $this AdjustSetting molecule-outline] \
    24202180        -font "Arial 9"
    24212181
     
    24822242        Rappture::Combobox $inner.palette -width 10 -editable no
    24832243    }
    2484     $inner.palette choices insert end [GetColormapList -includeElementDefault]
     2244    $inner.palette choices insert end \
     2245        "elementDefault"     "elementDefault"   \
     2246        "BCGYR"              "BCGYR"            \
     2247        "BGYOR"              "BGYOR"            \
     2248        "blue"               "blue"             \
     2249        "blue-to-brown"      "blue-to-brown"    \
     2250        "blue-to-orange"     "blue-to-orange"   \
     2251        "blue-to-grey"       "blue-to-grey"     \
     2252        "green-to-magenta"   "green-to-magenta" \
     2253        "greyscale"          "greyscale"        \
     2254        "nanohub"            "nanohub"          \
     2255        "rainbow"            "rainbow"          \
     2256        "spectral"           "spectral"         \
     2257        "ROYGB"              "ROYGB"            \
     2258        "RYGCB"              "RYGCB"            \
     2259        "brown-to-blue"      "brown-to-blue"    \
     2260        "grey-to-blue"       "grey-to-blue"     \
     2261        "orange-to-blue"     "orange-to-blue"   
     2262
    24852263    $itk_component(moleculepalette) value "elementDefault"
    24862264    bind $inner.palette <<Value>> \
    24872265        [itcl::code $this AdjustSetting molecule-palette]
     2266
     2267    checkbutton $inner.labels -text "Show labels on atoms" \
     2268        -command [itcl::code $this labels update] \
     2269        -variable [itcl::scope _settings(molecule-labels)] \
     2270        -font "Arial 9"
     2271    Rappture::Tooltip::for $inner.labels \
     2272        "Display atom symbol and serial number."
     2273
     2274    checkbutton $inner.rock -text "Rock molecule back and forth" \
     2275        -variable [itcl::scope _settings(molecule-rock)] \
     2276        -font "Arial 9"
     2277    Rappture::Tooltip::for $inner.rock \
     2278        "Rotate the object back and forth around the y-axis."
     2279
     2280    checkbutton $inner.cell -text "Parallelepiped" \
     2281        -font "Arial 9"
     2282    $inner.cell select
    24882283
    24892284    label $inner.atomscale_l -text "Atom Scale" -font "Arial 9"
     
    25262321    blt::table $inner \
    25272322        0,0 $inner.molecule     -anchor w -pady {1 0} \
    2528         1,0 $inner.outline      -anchor w -pady {1 0} \
    2529         2,0 $inner.label        -anchor w -pady {1 0} \
    2530         3,0 $inner.edges        -anchor w -pady {1 0} \
    2531         4,0 $inner.rep_l        -anchor w -pady { 2 0 } \
    2532         5,0 $inner.rep          -fill x    -pady 2 \
    2533         6,0 $inner.rscale_l     -anchor w -pady { 2 0 } \
    2534         7,0 $inner.rscale       -fill x    -pady 2 \
    2535         8,0 $inner.palette_l    -anchor w  -pady 0 \
    2536         9,0 $inner.palette      -fill x    -padx 2 \
    2537         10,0 $inner.atomscale_l  -anchor w -pady {3 0} \
    2538         11,0 $inner.atomscale   -fill x    -padx 2 \
    2539         12,0 $inner.bondscale_l -anchor w -pady {3 0} \
    2540         13,0 $inner.bondscale   -fill x   -padx 2 \
    2541         14,0 $inner.opacity_l   -anchor w -pady {3 0} \
    2542         15,0 $inner.opacity     -fill x    -padx 2 \
    2543         16,0 $inner.quality_l   -anchor w -pady {3 0} \
    2544         17,0 $inner.quality     -fill x    -padx 2
     2323        1,0 $inner.label        -anchor w -pady {1 0} \
     2324        2,0 $inner.edges        -anchor w -pady {1 0} \
     2325        3,0 $inner.rep_l        -anchor w -pady { 2 0 } \
     2326        4,0 $inner.rep          -fill x    -pady 2 \
     2327        5,0 $inner.rscale_l     -anchor w -pady { 2 0 } \
     2328        6,0 $inner.rscale       -fill x    -pady 2 \
     2329        7,0 $inner.palette_l    -anchor w  -pady 0 \
     2330        8,0 $inner.palette      -fill x    -padx 2 \
     2331        9,0 $inner.atomscale_l  -anchor w -pady {3 0} \
     2332        10,0 $inner.atomscale   -fill x    -padx 2 \
     2333        11,0 $inner.bondscale_l -anchor w -pady {3 0} \
     2334        12,0 $inner.bondscale   -fill x   -padx 2 \
     2335        13,0 $inner.opacity_l   -anchor w -pady {3 0} \
     2336        14,0 $inner.opacity     -fill x    -padx 2 \
     2337        15,0 $inner.quality_l   -anchor w -pady {3 0} \
     2338        16,0 $inner.quality     -fill x    -padx 2
    25452339   
    25462340    blt::table configure $inner r* -resize none
    2547     blt::table configure $inner r18 -resize expand
     2341    blt::table configure $inner r17 -resize expand
    25482342}
    25492343
     
    25572351        }
    25582352        "set" {
    2559             set what [lindex $args 0]
    2560             set x $_view($what)
     2353            set who [lindex $args 0]
     2354            set x $_view($who)
    25612355            set code [catch { string is double $x } result]
    25622356            if { $code != 0 || !$result } {
    25632357                return
    25642358            }
    2565             switch -- $what {
    2566                 "-ortho" {
    2567                     if {$_view($what)} {
     2359            switch -- $who {
     2360                "ortho" {
     2361                    if {$_view(ortho)} {
    25682362                        SendCmd "camera mode ortho"
    25692363                    } else {
     
    25712365                    }
    25722366                }
    2573                 "-xpan" - "-ypan" {
     2367                "xpan" - "ypan" {
    25742368                    PanCamera
    25752369                }
    2576                 "-qx" - "-qy" - "-qz" - "-qw" {
    2577                     set q [ViewToQuaternion]
     2370                "qx" - "qy" - "qz" - "qw" {
     2371                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    25782372                    $_arcball quaternion $q
    25792373                    EventuallyRotate $q
    25802374                }
    2581                 "-zoom" {
    2582                     SendCmd "camera zoom $_view($what)"
     2375                "zoom" {
     2376                    SendCmd "camera zoom $_view(zoom)"
    25832377                }
    25842378            }
     
    26612455        "glyphs" {
    26622456            array set settings {
    2663                 -color white
     2457                -color \#FFFFFF
     2458                -gscale 1
     2459                -edges 0
    26642460                -edgecolor black
    2665                 -edges 0
    2666                 -gscale 1
     2461                -linewidth 1.0
     2462                -opacity 1.0
     2463                -wireframe 0
    26672464                -lighting 1
    2668                 -linewidth 1.0
    2669                 -normscale 0
    2670                 -opacity 1.0
    2671                 -orientGlyphs 0
    2672                 -outline 0
    2673                 -ptsize 1.0
    2674                 -quality 1
    2675                 -scaleMode "vcomp"
    2676                 -shape "sphere"
    26772465                -visible 1
    2678                 -wireframe 0
    2679             }
     2466            }
     2467            set shape [$dataobj shape $comp]
    26802468            array set settings $style
    2681             set shape [$dataobj shape $comp]
    2682             if {$shape != ""} {
    2683                 set settings(-shape) $shape
    2684             }
    2685             SendCmd "outline add $tag"
    2686             SendCmd "outline color [Color2RGB $settings(-color)] $tag"
    2687             SendCmd "outline visible $settings(-outline) $tag"
    2688             set _settings(glyphs-outline) $settings(-outline)
    2689 
    2690             SendCmd "glyphs add $settings(-shape) $tag"
    2691             SendCmd "glyphs normscale $settings(-normscale) $tag"
     2469            SendCmd "glyphs add $shape $tag"
     2470            SendCmd "glyphs normscale 0 $tag"
    26922471            SendCmd "glyphs gscale $settings(-gscale) $tag"
    26932472            SendCmd "glyphs wireframe $settings(-wireframe) $tag"
    26942473            SendCmd "glyphs color [Color2RGB $settings(-color)] $tag"
    26952474            #SendCmd "glyphs colormode constant {} $tag"
    2696             # Omitting field name for gorient and smode commands
    2697             # defaults to active scalars or vectors depending on mode
    2698             SendCmd "glyphs gorient $settings(-orientGlyphs) {} $tag"
    2699             SendCmd "glyphs smode $settings(-scaleMode) {} $tag"
    2700             SendCmd "glyphs edges $settings(-edges) $tag"
    2701             SendCmd "glyphs linecolor [Color2RGB $settings(-edgecolor)] $tag"
    2702             SendCmd "glyphs linewidth $settings(-linewidth) $tag"
    2703             SendCmd "glyphs ptsize $settings(-ptsize) $tag"
    2704             SendCmd "glyphs quality $settings(-quality) $tag"
    2705             SendCmd "glyphs lighting $settings(-lighting) $tag"
     2475            SendCmd "glyphs gorient 0 {} $tag"
     2476            SendCmd "glyphs smode vcomp {} $tag"
    27062477            SendCmd "glyphs opacity $settings(-opacity) $tag"
    2707             set _settings(glyphs-opacity) [expr 100.0 * $settings(-opacity)]
    27082478            SendCmd "glyphs visible $settings(-visible) $tag"
    27092479            set _settings(glyphs-wireframe) $settings(-wireframe)
    27102480        }
    27112481        "molecule" {
     2482            SendCmd "molecule add $tag"
     2483            SendCmd "molecule ascale $_settings(molecule-atomscale) $tag"
     2484            SendCmd "molecule bscale $_settings(molecule-bondscale) $tag"
     2485            SendCmd "molecule bstyle $_settings(molecule-bondstyle) $tag"
     2486            SendCmd "molecule atoms $_settings(molecule-atoms-visible) $tag"
     2487            SendCmd "molecule bonds $_settings(molecule-bonds-visible) $tag"
     2488            set _haveMolecules 1
     2489        }
     2490        "polydata" {
    27122491            array set settings {
    2713                 -atomscale 0.3
    2714                 -atomsvisible 1
    2715                 -bondscale 0.075
    2716                 -bondstyle "cylinder"
    2717                 -bondsvisible 1
    2718                 -color "elementDefault"
     2492                -color \#FFFFFF
     2493                -edges 1
    27192494                -edgecolor black
    2720                 -edges 0
    2721                 -labels 0
    2722                 -lighting 1
    27232495                -linewidth 1.0
    27242496                -opacity 1.0
    2725                 -outline 0
    2726                 -quality 1.0
    2727                 -representation ""
    2728                 -rscale "covalent"
     2497                -wireframe 0
     2498                -lighting 1
    27292499                -visible 1
    2730                 -wireframe 0
    27312500            }
    27322501            array set settings $style
    2733 
    2734             SendCmd "outline add $tag"
    2735             SendCmd "outline color [Color2RGB white] $tag"
    2736             SendCmd "outline visible $settings(-outline) $tag"
    2737             set _settings(molecule-outline) $settings(-outline)
    2738 
    2739             SendCmd "molecule add $tag"
    2740             if {$settings(-representation) != ""} {
    2741                 switch -- $settings(-representation) {
    2742                     "ballandstick" {
    2743                         set _settings(molecule-rscale) covalent
    2744                         set _settings(molecule-atoms-visible) 1
    2745                         set _settings(molecule-bonds-visible) 1
    2746                         set _settings(molecule-bondstyle) cylinder
    2747                         set _settings(molecule-atomscale) 0.3
    2748                         set _settings(molecule-bondscale) 0.075
    2749                     }
    2750                     "balls" - "spheres" {
    2751                         set _settings(molecule-rscale) covalent
    2752                         set _settings(molecule-atoms-visible) 1
    2753                         set _settings(molecule-bonds-visible) 0
    2754                         set _settings(molecule-bondstyle) cylinder
    2755                         set _settings(molecule-atomscale) 0.3
    2756                         set _settings(molecule-bondscale) 0.075
    2757                     }
    2758                     "sticks" {
    2759                         set _settings(molecule-rscale) none
    2760                         set _settings(molecule-atoms-visible) 1
    2761                         set _settings(molecule-bonds-visible) 1
    2762                         set _settings(molecule-bondstyle) cylinder
    2763                         set _settings(molecule-atomscale) 0.075
    2764                         set _settings(molecule-bondscale) 0.075
    2765                     }
    2766                     "spacefilling" {
    2767                         set _settings(molecule-rscale) van_der_waals
    2768                         set _settings(molecule-atoms-visible) 1
    2769                         set _settings(molecule-bonds-visible) 0
    2770                         set _settings(molecule-bondstyle) cylinder
    2771                         set _settings(molecule-atomscale) 1.0
    2772                         set _settings(molecule-bondscale) 0.075
    2773                     }
    2774                     "rods"  {
    2775                         set _settings(molecule-rscale) none
    2776                         set _settings(molecule-atoms-visible) 1
    2777                         set _settings(molecule-bonds-visible) 1
    2778                         set _settings(molecule-bondstyle) cylinder
    2779                         set _settings(molecule-atomscale) 0.1
    2780                         set _settings(molecule-bondscale) 0.1
    2781                     }
    2782                     "wireframe" - "lines" {
    2783                         set _settings(molecule-rscale) none
    2784                         set _settings(molecule-atoms-visible) 0
    2785                         set _settings(molecule-bonds-visible) 1
    2786                         set _settings(molecule-bondstyle) line
    2787                         set _settings(molecule-atomscale) 1.0
    2788                         set _settings(molecule-bondscale) 1.0
    2789                     }
    2790                     default {
    2791                         error "unknown representation $value"
    2792                     }
    2793                 }
    2794                 SendCmd "molecule rscale $_settings(molecule-rscale) $tag"
    2795                 SendCmd "molecule atoms $_settings(molecule-atoms-visible) $tag"
    2796                 SendCmd "molecule bonds $_settings(molecule-bonds-visible) $tag"
    2797                 SendCmd "molecule bstyle $_settings(molecule-bondstyle) $tag"
    2798                 SendCmd "molecule ascale $_settings(molecule-atomscale) $tag"
    2799                 SendCmd "molecule bscale $_settings(molecule-bondscale) $tag"
    2800                 $itk_component(representation) value [$itk_component(representation) label $settings(-representation)]
    2801                 $itk_component(rscale) value [$itk_component(rscale) label $_settings(molecule-rscale)]
    2802                 switch -- $settings(-representation) {
    2803                     "ballandstick" - "balls" - "spheres" {
    2804                         $itk_component(rscale) configure -state normal
    2805                     }
    2806                     default {
    2807                         $itk_component(rscale) configure -state disabled
    2808                     }
    2809                 }
    2810             } else {
    2811                 SendCmd "molecule rscale $settings(-rscale) $tag"
    2812                 set _settings(molecule-rscale) $settings(-rscale)
    2813                 SendCmd "molecule atoms $settings(-atomsvisible) $tag"
    2814                 set _settings(molecule-atoms-visible) $settings(-atomsvisible)
    2815                 SendCmd "molecule bonds $settings(-bondsvisible) $tag"
    2816                 set _settings(molecule-bonds-visible) $settings(-bondsvisible)
    2817                 SendCmd "molecule bstyle $settings(-bondstyle) $tag"
    2818                 set _settings(molecule-bondstyle) $settings(-bondstyle)
    2819                 SendCmd "molecule ascale $settings(-atomscale) $tag"
    2820                 set _settings(molecule-atomscale) $settings(-atomscale)
    2821                 SendCmd "molecule bscale $settings(-bondscale) $tag"
    2822                 set _settings(molecule-bondscale) $settings(-bondscale)
    2823             }
    2824             SendCmd "molecule labels $settings(-labels) $tag"
    2825             set _settings(molecule-labels) $settings(-labels)
    2826             SendCmd "molecule linecolor [Color2RGB $settings(-edgecolor)] $tag"
    2827             SendCmd "molecule linewidth $settings(-linewidth) $tag"
    2828             SendCmd "molecule edges $settings(-edges) $tag"
    2829             set _settings(molecule-edges) $settings(-edges)
    2830             SendCmd "molecule lighting $settings(-lighting) $tag"
    2831             set _settings(molecule-lighting) $settings(-lighting)
    2832             SendCmd "molecule aquality $settings(-quality) $tag"
    2833             SendCmd "molecule bquality $settings(-quality) $tag"
    2834             set _settings(molecule-quality) $settings(-quality)
    2835             SendCmd "molecule visible $settings(-visible) $tag"
    2836             set _settings(molecule-visible) $settings(-visible)
    2837             set _haveMolecules 1
    2838         }
    2839         "polydata" {
    2840             array set settings {
    2841                 -cloudstyle "mesh"
    2842                 -color white
    2843                 -edgecolor black
    2844                 -edges 1
    2845                 -lighting 1
    2846                 -linewidth 1.0
    2847                 -opacity 1.0
    2848                 -outline 0
    2849                 -visible 1
    2850                 -wireframe 0
    2851             }
    2852             array set settings $style
    2853 
    2854             SendCmd "outline add $tag"
    2855             SendCmd "outline color [Color2RGB $settings(-color)] $tag"
    2856             SendCmd "outline visible $settings(-outline) $tag"
    2857             set _settings(polydata-outline) $settings(-outline)
    2858 
    28592502            SendCmd "polydata add $tag"
    28602503            SendCmd "polydata visible $settings(-visible) $tag"
     
    28622505            SendCmd "polydata edges $settings(-edges) $tag"
    28632506            set _settings(polydata-edges) $settings(-edges)
    2864             SendCmd "polydata cloudstyle $settings(-cloudstyle) $tag"
    28652507            SendCmd "polydata color [Color2RGB $settings(-color)] $tag"
    28662508            #SendCmd "polydata colormode constant {} $tag"
     
    30232665        "move" {
    30242666            set axis [lindex $args 0]
     2667            set oldval $_axis(${axis}position)
    30252668            set newval [lindex $args 1]
    30262669            if {[llength $args] != 2} {
     
    30502693        bottom "0.707107 0.707107 0 0"
    30512694    }
    3052     foreach name { -qw -qx -qy -qz } value $positions($side) {
     2695    foreach name { qw qx qy qz } value $positions($side) {
    30532696        set _view($name) $value
    30542697    }
    3055     set q [ViewToQuaternion]
     2698    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    30562699    $_arcball quaternion $q
    30572700    SendCmd "camera orient $q"
    30582701    SendCmd "camera reset"
    3059     set _view(-xpan) 0
    3060     set _view(-ypan) 0
    3061     set _view(-zoom) 1.0
     2702    set _view(xpan) 0
     2703    set _view(ypan) 0
     2704    set _view(zoom) 1.0
    30622705}
    30632706
  • branches/1.3/gui/scripts/vtkvolumeviewer.tcl

    r4774 r4848  
    11# -*- mode: tcl; indent-tabs-mode: nil -*-
    2 # ----------------------------------------------------------------------
    3 #  COMPONENT: vtkvolumeviewer - Vtk volume viewer
     2
     3# ----------------------------------------------------------------------
     4#  COMPONENT: VtkVolumeViewer - Vtk volume viewer
    45#
    56#  It connects to the Vtk server running on a rendering farm,
     
    78# ======================================================================
    89#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2004-2014  HUBzero Foundation, LLC
     10#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
    1011#
    1112#  See the file "license.terms" for information on usage and
     
    6263    public method scale {args}
    6364
    64     private method GetDatasetsWithComponent { cname }
    65 
    66     private variable _volcomponents   ; # Array of components found
    67     private variable _componentsList   ; # List of component names
     65    protected method Connect {}
     66    protected method CurrentDatasets {args}
     67    protected method Disconnect {}
     68    protected method DoResize {}
     69    protected method DoReseed {}
     70    protected method DoRotate {}
     71    protected method AdjustSetting {what {value ""}}
     72    protected method InitSettings { args  }
     73    protected method Pan {option x y}
     74    protected method Pick {x y}
     75    protected method Rebuild {}
     76    protected method ReceiveDataset { args }
     77    protected method ReceiveImage { args }
     78    protected method ReceiveLegend { colormap title vmin vmax size }
     79    protected method Rotate {option x y}
     80    protected method Zoom {option}
    6881
    6982    # The following methods are only used by this class.
    70     private method AdjustSetting {what {value ""}}
    7183    private method BuildAxisTab {}
    7284    private method BuildCameraTab {}
     
    7486    private method BuildCutplaneTab {}
    7587    private method BuildDownloadPopup { widget command }
    76     private method BuildViewTab {}
    7788    private method BuildVolumeTab {}
    7889    private method DrawLegend {}
    79     private method ChangeColormap { dataobj comp color }
    8090    private method Combo { option }
    81     private method Connect {}
    82     private method CurrentDatasets {args}
    83     private method Disconnect {}
    84     private method DoResize {}
    85     private method DoRotate {}
    8691    private method EnterLegend { x y }
    8792    private method EventuallyResize { w h }
    88     private method EventuallyRequestLegend {}
     93    private method EventuallyReseed { numPoints }
    8994    private method EventuallyRotate { q }
    9095    private method EventuallySetCutplane { axis args }
    9196    private method GetImage { args }
    9297    private method GetVtkData { args }
    93     private method InitSettings { args  }
    9498    private method IsValidObject { dataobj }
    9599    private method LeaveLegend {}
    96     private method MotionLegend { x y }
    97     private method Pan {option x y}
     100    private method MotionLegend { x y }
    98101    private method PanCamera {}
    99     private method Pick {x y}
    100     private method QuaternionToView { q } {
    101         foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    102     }
    103     private method Rebuild {}
    104     private method ReceiveDataset { args }
    105     private method ReceiveImage { args }
    106     private method ReceiveLegend { colormap title vmin vmax size }
    107102    private method RequestLegend {}
    108103    private method SetColormap { dataobj comp }
    109     private method Rotate {option x y}
     104    private method ChangeColormap { dataobj comp color }
    110105    private method SetLegendTip { x y }
    111106    private method SetObjectStyle { dataobj comp }
    112     private method SetOrientation { side }
    113107    private method Slice {option args}
    114     private method ViewToQuaternion {} {
    115         return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    116     }
    117     private method Zoom {option}
    118108
    119109    private variable _arcball ""
     
    139129    private variable _start 0
    140130    private variable _title ""
     131    private variable _seeds
    141132
    142133    common _downloadPopup;              # download options from popup
     
    145136    private variable _height 0
    146137    private variable _resizePending 0
     138    private variable _reseedPending 0
    147139    private variable _rotatePending 0
    148140    private variable _cutplanePending 0
     
    151143    private variable _curFldName ""
    152144    private variable _curFldLabel ""
    153     private variable _colorMode "scalar"; #  Mode of colormap (vmag or scalar)
    154     private variable _cutplaneCmd "cutplane"
    155     private variable _allowMultiComponent 0
     145    private variable _colorMode "vmag";#  Mode of colormap (vmag or scalar)
    156146}
    157147
     
    168158    set _serverType "vtkvis"
    169159
    170     EnableWaitDialog 900
    171 
    172160    # Rebuild event
    173161    $_dispatcher register !rebuild
     
    178166    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
    179167
     168    # Reseed event
     169    $_dispatcher register !reseed
     170    $_dispatcher dispatch $this !reseed "[itcl::code $this DoReseed]; list"
     171
    180172    # Rotate event
    181173    $_dispatcher register !rotate
     
    189181    $_dispatcher register !xcutplane
    190182    $_dispatcher dispatch $this !xcutplane \
    191         "[itcl::code $this AdjustSetting -xcutplaneposition]; list"
     183        "[itcl::code $this AdjustSetting cutplane-xposition]; list"
    192184
    193185    # Y-Cutplane event
    194186    $_dispatcher register !ycutplane
    195187    $_dispatcher dispatch $this !ycutplane \
    196         "[itcl::code $this AdjustSetting -ycutplaneposition]; list"
     188        "[itcl::code $this AdjustSetting cutplane-yposition]; list"
    197189
    198190    # Z-Cutplane event
    199191    $_dispatcher register !zcutplane
    200192    $_dispatcher dispatch $this !zcutplane \
    201         "[itcl::code $this AdjustSetting -zcutplaneposition]; list"
     193        "[itcl::code $this AdjustSetting cutplane-zposition]; list"
    202194
    203195    #
     
    210202    # Initialize the view to some default parameters.
    211203    array set _view {
    212         -ortho           0
    213         -qw              0.853553
    214         -qx              -0.353553
    215         -qy              0.353553
    216         -qz              0.146447
    217         -xpan            0
    218         -ypan            0
    219         -zoom            1.0
     204        qw              0.853553
     205        qx              -0.353553
     206        qy              0.353553
     207        qz              0.146447
     208        zoom            1.0
     209        xpan            0
     210        ypan            0
     211        ortho           0
    220212    }
    221213    set _arcball [blt::arcball create 100 100]
    222     $_arcball quaternion [ViewToQuaternion]
     214    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     215    $_arcball quaternion $q
    223216
    224217    array set _settings {
    225         -axesvisible                    1
    226         -axisflymode                    static
    227         -axislabels                     1
    228         -axisminorticks                 1
    229         -background                     black
    230         -color                          BCGYR
    231         -cutplanelighting               1
    232         -cutplaneopacity                100
    233         -cutplanesvisible               0
    234         -legendvisible                  1
    235         -volumelighting                 1
    236         -volumematerial                 80
    237         -volumeopacity                  50
    238         -volumeoutline                  0
    239         -volumequality                  80
    240         -volumevisible                  1
    241         -xcutplaneposition              50
    242         -xcutplanevisible               1
    243         -xgrid                          0
    244         -ycutplaneposition              50
    245         -ycutplanevisible               1
    246         -ygrid                          0
    247         -zcutplaneposition              50
    248         -zcutplanevisible               1
    249         -zgrid                          0
     218        axis-xgrid              0
     219        axis-ygrid              0
     220        axis-zgrid              0
     221        axesVisible             1
     222        axisLabels              1
     223        cutplaneEdges           0
     224        cutplane-xvisible       1
     225        cutplane-yvisible       1
     226        cutplane-zvisible       1
     227        cutplane-xposition      50
     228        cutplane-yposition      50
     229        cutplane-zposition      50
     230        cutplaneVisible         0
     231        cutplaneLighting        1
     232        cutplaneWireframe       0
     233        cutplane-opacity        100
     234        volumeLighting          1
     235        volume-material         80
     236        volume-opacity          40
     237        volume-quality          50
     238        volumeVisible           1
     239        legendVisible           1
    250240    }
    251241
     
    326316            -onimage [Rappture::icon volume-on] \
    327317            -offimage [Rappture::icon volume-off] \
    328             -variable [itcl::scope _settings(-volumevisible)] \
    329             -command [itcl::code $this AdjustSetting -volumevisible]
     318            -variable [itcl::scope _settings(volumeVisible)] \
     319            -command [itcl::code $this AdjustSetting volumeVisible]
    330320    }
    331321    $itk_component(volume) select
     
    338328            -onimage [Rappture::icon cutbutton] \
    339329            -offimage [Rappture::icon cutbutton] \
    340             -variable [itcl::scope _settings(-cutplanesvisible)] \
    341             -command [itcl::code $this AdjustSetting -cutplanesvisible]
     330            -variable [itcl::scope _settings(cutplaneVisible)] \
     331            -command [itcl::code $this AdjustSetting cutplaneVisible]
    342332    }
    343333    Rappture::Tooltip::for $itk_component(cutplane) \
     
    347337
    348338    if { [catch {
    349         BuildViewTab
    350339        BuildVolumeTab
    351340        BuildCutplaneTab
     
    355344        puts stderr errs=$errs
    356345    }
    357 
    358346    # Legend
     347
    359348    set _image(legend) [image create photo]
    360349    itk_component add legend {
     
    382371    bind $itk_component(view) <ButtonRelease-1> \
    383372        [itcl::code $this Rotate release %x %y]
    384 
     373    bind $itk_component(view) <Configure> \
     374        [itcl::code $this EventuallyResize %w %h]
     375
     376    if 0 {
     377    bind $itk_component(view) <Configure> \
     378        [itcl::code $this EventuallyResize %w %h]
     379    }
    385380    # Bindings for panning via mouse
    386381    bind $itk_component(view) <ButtonPress-2> \
     
    430425    eval itk_initialize $args
    431426    Connect
     427    update
    432428}
    433429
     
    457453
    458454itcl::body Rappture::VtkVolumeViewer::DoRotate {} {
    459     SendCmd "camera orient [ViewToQuaternion]"
     455    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     456    SendCmd "camera orient $q"
    460457    set _rotatePending 0
    461458}
     
    471468}
    472469
    473 itcl::body Rappture::VtkVolumeViewer::EventuallyRequestLegend {} {
    474     if { !$_legendPending } {
    475         set _legendPending 1
    476         $_dispatcher event -idle !legend
     470itcl::body Rappture::VtkVolumeViewer::EventuallyReseed { numPoints } {
     471    set _numSeeds $numPoints
     472    if { !$_reseedPending } {
     473        set _reseedPending 1
     474        $_dispatcher event -after 600 !reseed
    477475    }
    478476}
     
    481479
    482480itcl::body Rappture::VtkVolumeViewer::EventuallyRotate { q } {
    483     QuaternionToView $q
     481    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
    484482    if { !$_rotatePending } {
    485483        set _rotatePending 1
     
    504502# ----------------------------------------------------------------------
    505503itcl::body Rappture::VtkVolumeViewer::add {dataobj {settings ""}} {
    506     if { ![IsValidObject $dataobj] } {
    507         return;                         # Ignore invalid objects.
    508     }
    509504    array set params {
    510505        -color auto
     
    649644# ----------------------------------------------------------------------
    650645itcl::body Rappture::VtkVolumeViewer::scale {args} {
    651     array unset _limits
    652     array unset _volcomponents
    653     set _componentsList ""
    654 
    655646    foreach dataobj $args {
    656         if { ![$dataobj isvalid] } {
    657             continue;                     # Object doesn't contain valid data.
    658         }
    659         # Determine limits for each axis.
    660647        foreach axis { x y z } {
    661648            set lim [$dataobj limits $axis]
     
    674661            set _limits($axis) [list $amin $amax]
    675662        }
    676         # Determine limits for each field.
    677663        foreach { fname lim } [$dataobj fieldlimits] {
    678664            if { ![info exists _limits($fname)] } {
     
    689675            }
    690676            set _limits($fname) [list $fmin $fmax]
    691         }
    692         # Get limits for each component.
    693         foreach cname [$dataobj components] {
    694             if { ![info exists _volcomponents($cname)] } {
    695                 lappend _componentsList $cname
    696             }
    697             lappend _volcomponents($cname) $dataobj-$cname
    698             array unset limits
    699             array set limits [$dataobj valueLimits $cname]
    700             if { ![info exists _limits($cname)] } {
    701                 set _limits($cname) $limits(v)
    702                 continue
    703             }
    704             foreach {min max} $limits(v) break
    705             foreach {vmin vmax} $_limits($cname) break
    706             if { $vmin > $min } {
    707                 set vmin $min
    708             }
    709             if { $vmax < $max } {
    710                 set vmax $max
    711             }
    712             set _limits($cname) [list $vmin $vmax]
    713677        }
    714678    }
     
    787751        if { $_reportClientInfo }  {
    788752            # Tell the server the viewer, hub, user and session.
    789             # Do this immediately on connect before buffering any commands
     753            # Do this immediately on connect before buffing any commands
    790754            global env
    791755
     
    845809    $_dispatcher cancel !rebuild
    846810    $_dispatcher cancel !resize
     811    $_dispatcher cancel !reseed
    847812    $_dispatcher cancel !rotate
    848813    $_dispatcher cancel !xcutplane
     
    855820    array unset _data
    856821    array unset _colormaps
     822    array unset _seeds
    857823    array unset _dataset2style
    858824    array unset _obj2datasets
    859 
    860     set _resizePending 0
    861     set _rotatePending 0
    862     set _cutplanePending 0
    863     set _legendPending 0
    864     set _reset 1
    865825}
    866826
     
    883843    if { $info(-type) == "image" } {
    884844        if 0 {
    885             set f [open "last.ppm" "w"]
    886             fconfigure $f -encoding binary
    887             puts -nonewline $f $bytes
     845            set f [open "last.ppm" "w"]
     846            puts $f $bytes
    888847            close $f
    889848        }
    890849        $_image(plot) configure -data $bytes
    891         #puts stderr "[clock format [clock seconds]]: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
     850        set time [clock seconds]
     851        set date [clock format $time]
     852        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
    892853        if { $_start > 0 } {
    893854            set finish [clock clicks -milliseconds]
     
    954915# ----------------------------------------------------------------------
    955916itcl::body Rappture::VtkVolumeViewer::Rebuild {} {
     917    update
    956918    set w [winfo width $itk_component(view)]
    957919    set h [winfo height $itk_component(view)]
    958 
    959920    if { $w < 2 || $h < 2 } {
    960921        $_dispatcher event -idle !rebuild
     
    969930    set _legendPending 1
    970931
    971     if { $_width != $w || $_height != $h || $_reset } {
     932    if { $_reset } {
    972933        set _width $w
    973934        set _height $h
    974935        $_arcball resize $w $h
    975936        DoResize
    976     }
    977     if { $_reset } {
    978937        #
    979938        # Reset the camera and other view parameters
    980939        #
    981         $_arcball quaternion [ViewToQuaternion]
    982         if {$_view(-ortho)} {
     940        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     941        $_arcball quaternion $q
     942        if {$_view(ortho)} {
    983943            SendCmd "camera mode ortho"
    984944        } else {
     
    986946        }
    987947        DoRotate
     948        InitSettings axis-xgrid axis-ygrid axis-zgrid axisFlyMode \
     949            axesVisible axisLabels
    988950        PanCamera
    989         set _first ""
    990         InitSettings -background \
    991             -xgrid -ygrid -zgrid -axisflymode \
    992             -axesvisible -axislabels -axisminorticks
    993         StopBufferingCommands
    994         SendCmd "imgflush"
    995         StartBufferingCommands
    996      }
     951    }
     952    set _first ""
     953
     954    SendCmd "imgflush"
    997955    set _first ""
    998956
     
    1007965            if { ![info exists _datasets($tag)] } {
    1008966                set bytes [$dataobj vtkdata $comp]
    1009                 if 0 {
    1010                     set f [open /tmp/vtkvolume.vtk "w"]
    1011                     fconfigure $f -translation binary -encoding binary
    1012                     puts -nonewline $f $bytes
    1013                     close $f
    1014                 }
    1015967                set length [string length $bytes]
    1016968                if { $_reportClientInfo }  {
     
    1024976                    lappend info "dataset_size"  $length
    1025977                    lappend info "dataset_tag"   $tag
    1026                     SendCmd "clientinfo [list $info]"
    1027                 }
    1028                 SendCmd "dataset add $tag data follows $length"
     978                    SendCmd [list "clientinfo" $info]
     979                }
     980                append _outbuf "dataset add $tag data follows $length\n"
    1029981                append _outbuf $bytes
    1030982                set _datasets($tag) 1
     
    1033985            lappend _obj2datasets($dataobj) $tag
    1034986            if { [info exists _obj2ovride($dataobj-raise)] } {
    1035                 SendCmd "volume visible 1 $tag"
     987                SendCmd "dataset visible 1 $tag"
    1036988            }
    1037989            break
     
    1047999            set label [$_first hints ${axis}label]
    10481000            if { $label != "" } {
    1049                 SendCmd [list axis name $axis $label]
     1001                SendCmd "axis name $axis $label"
    10501002            }
    10511003            set units [$_first hints ${axis}units]
    10521004            if { $units != "" } {
    1053                 SendCmd [list axis units $axis $units]
     1005                SendCmd "axis units $axis $units"
    10541006            }
    10551007        }
     
    10661018                    [$_first fieldinfo $fname] break
    10671019                # Only scalar fields are valid
    1068                 if {$_allowMultiComponent || $components == 1} {
     1020                if {$components == 1} {
    10691021                    $itk_component(field) choices insert end "$fname" "$label"
    10701022                    $itk_component(fieldmenu) add radiobutton -label "$label" \
     
    10861038    }
    10871039
    1088     InitSettings -color \
    1089         -volumematerial \
    1090         -volumelighting -volumeopacity -volumequality -volumeoutline -volumevisible \
    1091         -cutplanesvisible \
    1092         -xcutplaneposition -ycutplaneposition -zcutplaneposition \
    1093         -xcutplanevisible -ycutplanevisible -zcutplanevisible
     1040    InitSettings volume-palette volume-material volume-quality volumeVisible \
     1041        cutplaneVisible \
     1042        cutplane-xposition cutplane-yposition cutplane-zposition \
     1043        cutplane-xvisible cutplane-yvisible cutplane-zvisible
    10941044
    10951045    if { $_reset } {
     1046        InitSettings volumeLighting
    10961047        Zoom reset
    10971048        set _reset 0
     
    11601111    switch -- $option {
    11611112        "in" {
    1162             set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1163             SendCmd "camera zoom $_view(-zoom)"
     1113            set _view(zoom) [expr {$_view(zoom)*1.25}]
     1114            SendCmd "camera zoom $_view(zoom)"
    11641115        }
    11651116        "out" {
    1166             set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1167             SendCmd "camera zoom $_view(-zoom)"
     1117            set _view(zoom) [expr {$_view(zoom)*0.8}]
     1118            SendCmd "camera zoom $_view(zoom)"
    11681119        }
    11691120        "reset" {
    11701121            array set _view {
    1171                 -qw      0.853553
    1172                 -qx      -0.353553
    1173                 -qy      0.353553
    1174                 -qz      0.146447
    1175                 -xpan    0
    1176                 -ypan    0
    1177                 -zoom    1.0
     1122                qw      0.853553
     1123                qx      -0.353553
     1124                qy      0.353553
     1125                qz      0.146447
     1126                zoom    1.0
     1127                xpan   0
     1128                ypan   0
    11781129            }
    11791130            if { $_first != "" } {
     
    11831134                }
    11841135            }
    1185             $_arcball quaternion [ViewToQuaternion]
     1136            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1137            $_arcball quaternion $q
    11861138            DoRotate
    11871139            SendCmd "camera reset"
     
    11911143
    11921144itcl::body Rappture::VtkVolumeViewer::PanCamera {} {
    1193     set x $_view(-xpan)
    1194     set y $_view(-ypan)
     1145    set x $_view(xpan)
     1146    set y $_view(ypan)
    11951147    SendCmd "camera pan $x $y"
    11961148}
     1149
    11971150
    11981151# ----------------------------------------------------------------------
     
    12691222            set x [expr $x / double($w)]
    12701223            set y [expr $y / double($h)]
    1271             set _view(-xpan) [expr $_view(-xpan) + $x]
    1272             set _view(-ypan) [expr $_view(-ypan) + $y]
     1224            set _view(xpan) [expr $_view(xpan) + $x]
     1225            set _view(ypan) [expr $_view(ypan) + $y]
    12731226            PanCamera
    12741227            return
     
    12921245            set _click(x) $x
    12931246            set _click(y) $y
    1294             set _view(-xpan) [expr $_view(-xpan) - $dx]
    1295             set _view(-ypan) [expr $_view(-ypan) - $dy]
     1247            set _view(xpan) [expr $_view(xpan) - $dx]
     1248            set _view(ypan) [expr $_view(ypan) - $dy]
    12961249            PanCamera
    12971250        }
     
    13151268itcl::body Rappture::VtkVolumeViewer::InitSettings { args } {
    13161269    foreach spec $args {
    1317         if { [info exists _settings($_first${spec})] } {
     1270        if { [info exists _settings($_first-$spec)] } {
    13181271            # Reset global setting with dataobj specific setting
    1319             set _settings($spec) $_settings($_first${spec})
     1272            set _settings($spec) $_settings($_first-$spec)
    13201273        }
    13211274        AdjustSetting $spec
     
    13351288    }
    13361289    switch -- $what {
    1337         "-background" {
    1338             set bgcolor [$itk_component(background) value]
    1339             set _settings($what) $bgcolor
    1340             array set fgcolors {
    1341                 "black" "white"
    1342                 "white" "black"
    1343                 "grey"  "black"
    1344             }
    1345             configure -plotbackground $bgcolor \
    1346                 -plotforeground $fgcolors($bgcolor)
    1347             $itk_component(view) delete "legend"
    1348             DrawLegend
    1349         }
    1350         "-volumeoutline" {
    1351             set bool $_settings($what)
    1352             SendCmd "outline visible 0"
    1353             foreach tag [CurrentDatasets -visible] {
    1354                 SendCmd "outline visible $bool $tag"
    1355             }
    1356         }
    1357         "-legendvisible" {
    1358             set bool $_settings($what)
    1359         }
    1360         "-volumevisible" {
    1361             set bool $_settings($what)
    1362             foreach tag [CurrentDatasets -visible] {
    1363                 SendCmd "volume visible $bool $tag"
     1290        "volumeVisible" {
     1291            set bool $_settings(volumeVisible)
     1292            foreach dataset [CurrentDatasets -visible] {
     1293                SendCmd "volume visible $bool $dataset"
    13641294            }
    13651295            if { $bool } {
     
    13711301            }
    13721302        }
    1373         "-volumematerial" {
    1374             set val $_settings($what)
     1303        "volume-material" {
     1304            set val $_settings(volume-material)
    13751305            set diffuse [expr {0.01*$val}]
    13761306            set specular [expr {0.01*$val}]
    13771307            #set power [expr {sqrt(160*$val+1.0)}]
    13781308            set power [expr {$val+1.0}]
    1379             foreach tag [CurrentDatasets -visible] {
    1380                 SendCmd "volume shading diffuse $diffuse $tag"
    1381                 SendCmd "volume shading specular $specular $power $tag"
    1382             }
    1383         }
    1384         "-volumelighting" {
    1385             set bool $_settings($what)
    1386             foreach tag [CurrentDatasets -visible] {
    1387                 SendCmd "volume lighting $bool $tag"
    1388             }
    1389         }
    1390         "-volumeopacity" {
    1391             set val $_settings($what)
     1309            foreach dataset [CurrentDatasets -visible] {
     1310                SendCmd "volume shading diffuse $diffuse $dataset"
     1311                SendCmd "volume shading specular $specular $power $dataset"
     1312            }
     1313        }
     1314        "volumeLighting" {
     1315            set bool $_settings(volumeLighting)
     1316            foreach dataset [CurrentDatasets -visible] {
     1317                SendCmd "volume lighting $bool $dataset"
     1318            }
     1319        }
     1320        "volume-quality" {
     1321            set val $_settings(volume-quality)
    13921322            set val [expr {0.01*$val}]
    1393             foreach tag [CurrentDatasets -visible] {
    1394                 SendCmd "volume opacity $val $tag"
    1395             }
    1396         }
    1397         "-volumequality" {
    1398             set val $_settings($what)
    1399             set val [expr {0.01*$val}]
    1400             foreach tag [CurrentDatasets -visible] {
    1401                 SendCmd "volume quality $val $tag"
    1402             }
    1403         }
    1404         "-axesvisible" {
    1405             set bool $_settings($what)
     1323            foreach dataset [CurrentDatasets -visible] {
     1324                SendCmd "volume quality $val $dataset"
     1325            }
     1326        }
     1327        "axesVisible" {
     1328            set bool $_settings(axesVisible)
    14061329            SendCmd "axis visible all $bool"
    14071330        }
    1408         "-axislabels" {
    1409             set bool $_settings($what)
     1331        "axisLabels" {
     1332            set bool $_settings(axisLabels)
    14101333            SendCmd "axis labels all $bool"
    14111334        }
    1412         "-axisminorticks" {
    1413             set bool $_settings($what)
    1414             SendCmd "axis minticks all $bool"
    1415         }
    1416         "-xgrid" - "-ygrid" - "-zgrid" {
    1417             set axis [string range $what 1 1]
     1335        "axis-xgrid" - "axis-ygrid" - "axis-zgrid" {
     1336            set axis [string range $what 5 5]
    14181337            set bool $_settings($what)
    14191338            SendCmd "axis grid $axis $bool"
    14201339        }
    1421         "-axisflymode" {
     1340        "axisFlyMode" {
    14221341            set mode [$itk_component(axismode) value]
    14231342            set mode [$itk_component(axismode) translate $mode]
     
    14251344            SendCmd "axis flymode $mode"
    14261345        }
    1427         "-cutplanesvisible" {
     1346        "cutplaneEdges" {
    14281347            set bool $_settings($what)
    14291348            foreach dataset [CurrentDatasets -visible] {
    1430                 SendCmd "$_cutplaneCmd visible $bool $dataset"
    1431             }
    1432         }
    1433         "-cutplanelighting" {
     1349                SendCmd "cutplane edges $bool $dataset"
     1350            }
     1351        }
     1352        "cutplaneVisible" {
    14341353            set bool $_settings($what)
    14351354            foreach dataset [CurrentDatasets -visible] {
    1436                 if {$_cutplaneCmd != "imgcutplane"} {
    1437                     SendCmd "$_cutplaneCmd lighting $bool $dataset"
    1438                 } else {
    1439                     if {$bool} {
    1440                         set ambient 0.0
    1441                         set diffuse 1.0
    1442                     } else {
    1443                         set ambient 1.0
    1444                         set diffuse 0.0
    1445                     }
    1446                     SendCmd "imgcutplane material $ambient $diffuse $dataset"
    1447                 }
    1448             }
    1449         }
    1450         "-cutplaneopacity" {
     1355                SendCmd "cutplane visible $bool $dataset"
     1356            }
     1357        }
     1358        "cutplaneWireframe" {
     1359            set bool $_settings($what)
     1360            foreach dataset [CurrentDatasets -visible] {
     1361                SendCmd "cutplane wireframe $bool $dataset"
     1362            }
     1363        }
     1364        "cutplaneLighting" {
     1365            set bool $_settings($what)
     1366            foreach dataset [CurrentDatasets -visible] {
     1367                SendCmd "cutplane lighting $bool $dataset"
     1368            }
     1369        }
     1370        "cutplane-opacity" {
    14511371            set val $_settings($what)
    14521372            set sval [expr { 0.01 * double($val) }]
    14531373            foreach dataset [CurrentDatasets -visible] {
    1454                 SendCmd "$_cutplaneCmd opacity $sval $dataset"
    1455             }
    1456         }
    1457         "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
    1458             set axis [string range $what 1 1]
     1374                SendCmd "cutplane opacity $sval $dataset"
     1375            }
     1376        }
     1377        "cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" {
     1378            set axis [string range $what 9 9]
    14591379            set bool $_settings($what)
    14601380            if { $bool } {
     
    14661386            }
    14671387            foreach dataset [CurrentDatasets -visible] {
    1468                 SendCmd "$_cutplaneCmd axis $axis $bool $dataset"
    1469             }
    1470         }
    1471         "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
    1472             set axis [string range $what 1 1]
     1388                SendCmd "cutplane axis $axis $bool $dataset"
     1389            }
     1390        }
     1391        "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" {
     1392            set axis [string range $what 9 9]
    14731393            set pos [expr $_settings($what) * 0.01]
    14741394            foreach dataset [CurrentDatasets -visible] {
    1475                 SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset"
     1395                SendCmd "cutplane slice ${axis} ${pos} $dataset"
    14761396            }
    14771397            set _cutplanePending 0
    14781398        }
    1479         "-color" {
    1480             set color [$itk_component(colormap) value]
    1481             set _settings($what) $color
     1399        "volume-palette" {
     1400            set palette [$itk_component(palette) value]
     1401            set _settings(volume-palette) $palette
    14821402            foreach dataset [CurrentDatasets -visible $_first] {
    14831403                foreach {dataobj comp} [split $dataset -] break
    1484                 ChangeColormap $dataobj $comp $color
     1404                ChangeColormap $dataobj $comp $palette
    14851405            }
    14861406            set _legendPending 1
    14871407        }
    1488         "-field" {
     1408        "volume-palette" {
     1409            set palette [$itk_component(palette) value]
     1410            set _settings(volume-palette) $palette
     1411            foreach dataset [CurrentDatasets -visible $_first] {
     1412                foreach {dataobj comp} [split $dataset -] break
     1413                ChangeColormap $dataobj $comp $palette
     1414            }
     1415            set _legendPending 1
     1416        }
     1417        "field" {
    14891418            set label [$itk_component(field) value]
    14901419            set fname [$itk_component(field) translate $label]
    1491             set _settings($what) $fname
     1420            set _settings(field) $fname
    14921421            if { [info exists _fields($fname)] } {
    14931422                foreach { label units components } $_fields($fname) break
    1494                 if { !$_allowMultiComponent && $components > 1 } {
     1423                if { $components > 1 } {
    14951424                    puts stderr "Can't use a vector field in a volume"
    14961425                    return
    14971426                } else {
    1498                     if { $components > 1 } {
    1499                         set _colorMode vmag
    1500                     } else {
    1501                         set _colorMode scalar
    1502                     }
     1427                    set _colorMode scalar
    15031428                }
    15041429                set _curFldName $fname
     
    15091434            }
    15101435            foreach dataset [CurrentDatasets -visible $_first] {
    1511                 #SendCmd "$_cutplaneCmd colormode $_colorMode $_curFldName $dataset"
    1512                 SendCmd "dataset scalar $_curFldName $dataset"
     1436                #SendCmd "volume colormode $_colorMode ${fname} $dataset"
     1437                SendCmd "cutplane colormode $_colorMode ${fname} $dataset"
    15131438            }
    15141439            SendCmd "camera reset"
     
    15421467        if { [info exists _dataset2style($dataset)] } {
    15431468            SendCmdNoWait \
    1544                 "legend2 $_dataset2style($dataset) $w $h"
    1545                 #"legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0"
     1469                "legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0"
    15461470            break;
    15471471        }
     
    15701494        -color BCGYR
    15711495        -levels 6
     1496        -opacity 1.0
    15721497    }
    15731498    set tag $dataobj-$comp
     
    15861511    array set style $_style($tag)
    15871512
    1588     set name "$style(-color):$style(-levels)"
     1513    set name "$style(-color):$style(-levels):$style(-opacity)"
    15891514    if { ![info exists _colormaps($name)] } {
    15901515        BuildColormap $name [array get style]
     
    15941519         $_dataset2style($tag) != $name } {
    15951520        SendCmd "volume colormap $name $tag"
    1596         SendCmd "$_cutplaneCmd colormap $name-opaque $tag"
     1521        SendCmd "cutplane colormap $name-opaque $tag"
    15971522        set _dataset2style($tag) $name
    15981523    }
     
    16081533        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    16091534    }
    1610     set max 1.0
     1535    if { ![info exists _settings(volume-opacity)] } {
     1536        set _settings(volume-opacity) $style(-opacity)
     1537    }
     1538    set max $_settings(volume-opacity)
    16111539
    16121540    set opaqueWmap "0.0 1.0 1.0 1.0"
     
    16231551itcl::configbody Rappture::VtkVolumeViewer::plotbackground {
    16241552    if { [isconnected] } {
    1625         set color $itk_option(-plotbackground)
    1626         set rgb [Color2RGB $color]
    1627         SendCmd "screen bgcolor $rgb"
    1628         $itk_component(legend) configure -background $color
     1553        foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
     1554        SendCmd "screen bgcolor $r $g $b"
    16291555    }
    16301556}
     
    16351561itcl::configbody Rappture::VtkVolumeViewer::plotforeground {
    16361562    if { [isconnected] } {
    1637         set color $itk_option(-plotforeground)
    1638         set rgb [Color2RGB $color]
    1639         SendCmd "axis color all $rgb"
    1640         SendCmd "outline color $rgb"
    1641         SendCmd "$_cutplaneCmd color $rgb"
    1642         $itk_component(legend) itemconfigure labels -fill $color
    1643         $itk_component(legend) itemconfigure limits -fill $color
    1644     }
    1645 }
    1646 
    1647 itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} {
     1563        foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
     1564        #fix this!
     1565        #SendCmd "color background $r $g $b"
     1566    }
     1567}
     1568
     1569itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} {
     1570
    16481571    set fg [option get $itk_component(hull) font Font]
    16491572    #set bfg [option get $itk_component(hull) boldFont Font]
    1650 
    1651     set inner [$itk_component(main) insert end \
    1652         -title "View Settings" \
    1653         -icon [Rappture::icon wrench]]
    1654     $inner configure -borderwidth 4
    1655 
    1656     checkbutton $inner.axes \
    1657         -text "Axes" \
    1658         -variable [itcl::scope _settings(-axesvisible)] \
    1659         -command [itcl::code $this AdjustSetting -axesvisible] \
    1660         -font "Arial 9"
    1661 
    1662     checkbutton $inner.outline \
    1663         -text "Outline" \
    1664         -variable [itcl::scope _settings(-volumeoutline)] \
    1665         -command [itcl::code $this AdjustSetting -volumeoutline] \
    1666         -font "Arial 9"
    1667 
    1668     checkbutton $inner.legend \
    1669         -text "Legend" \
    1670         -variable [itcl::scope _settings(-legendvisible)] \
    1671         -command [itcl::code $this AdjustSetting -legendvisible] \
    1672         -font "Arial 9"
    1673 
    1674     checkbutton $inner.volume \
    1675         -text "Volume" \
    1676         -variable [itcl::scope _settings(-volumevisible)] \
    1677         -command [itcl::code $this AdjustSetting -volumevisible] \
    1678         -font "Arial 9"
    1679 
    1680     label $inner.background_l -text "Background" -font "Arial 9"
    1681     itk_component add background {
    1682         Rappture::Combobox $inner.background -width 10 -editable no
    1683     }
    1684     $inner.background choices insert end \
    1685         "black"              "black"            \
    1686         "white"              "white"            \
    1687         "grey"               "grey"             
    1688 
    1689     $itk_component(background) value $_settings(-background)
    1690     bind $inner.background <<Value>> \
    1691         [itcl::code $this AdjustSetting -background]
    1692 
    1693     blt::table $inner \
    1694         0,0 $inner.axes  -cspan 2 -anchor w \
    1695         1,0 $inner.outline  -cspan 2 -anchor w \
    1696         2,0 $inner.volume  -cspan 2 -anchor w \
    1697         3,0 $inner.legend  -cspan 2 -anchor w \
    1698         4,0 $inner.background_l       -anchor e -pady 2 \
    1699         4,1 $inner.background                   -fill x \
    1700 
    1701     blt::table configure $inner r* -resize none
    1702     blt::table configure $inner r5 -resize expand
    1703 }
    1704 
    1705 itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} {
    1706     set font [option get $itk_component(hull) font Font]
    1707     #set bfont [option get $itk_component(hull) boldFont Font]
    17081573
    17091574    set inner [$itk_component(main) insert end \
     
    17121577    $inner configure -borderwidth 4
    17131578
    1714     checkbutton $inner.visibility \
    1715         -text "Visible" \
    1716         -font $font \
    1717         -variable [itcl::scope _settings(-volumevisible)] \
    1718         -command [itcl::code $this AdjustSetting -volumevisible]
     1579    checkbutton $inner.volume \
     1580        -text "Show Volume" \
     1581        -variable [itcl::scope _settings(volumeVisible)] \
     1582        -command [itcl::code $this AdjustSetting volumeVisible] \
     1583        -font "Arial 9"
    17191584
    17201585    checkbutton $inner.lighting \
    17211586        -text "Enable Lighting" \
    1722         -font $font \
    1723         -variable [itcl::scope _settings(-volumelighting)] \
    1724         -command [itcl::code $this AdjustSetting -volumelighting]
    1725 
    1726     label $inner.dim_l -text "Dim" -font $font
     1587        -variable [itcl::scope _settings(volumeLighting)] \
     1588        -command [itcl::code $this AdjustSetting volumeLighting] \
     1589        -font "Arial 9"
     1590
     1591    label $inner.dim_l -text "Dim" -font "Arial 9"
    17271592    ::scale $inner.material -from 0 -to 100 -orient horizontal \
    1728         -variable [itcl::scope _settings(-volumematerial)] \
    1729         -showvalue off -command [itcl::code $this AdjustSetting -volumematerial]
    1730     label $inner.bright_l -text "Bright" -font $font
    1731 
    1732     label $inner.opacity_l -text "Opacity" -font $font
     1593        -variable [itcl::scope _settings(volume-material)] \
     1594        -width 10 \
     1595        -showvalue off -command [itcl::code $this AdjustSetting volume-material]
     1596    label $inner.bright_l -text "Bright" -font "Arial 9"
     1597
     1598    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    17331599    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1734         -variable [itcl::scope _settings(-volumeopacity)] \
     1600        -variable [itcl::scope _settings(volume-opacity)] \
     1601        -width 10 \
    17351602        -showvalue off \
    1736         -command [itcl::code $this AdjustSetting -volumeopacity]
    1737 
    1738     label $inner.quality_l -text "Quality" -font $font
     1603        -command [itcl::code $this AdjustSetting volume-opacity]
     1604
     1605    label $inner.quality_l -text "Quality" -font "Arial 9"
    17391606    ::scale $inner.quality -from 0 -to 100 -orient horizontal \
    1740         -variable [itcl::scope _settings(-volumequality)] \
    1741         -showvalue off \
    1742         -command [itcl::code $this AdjustSetting -volumequality]
    1743 
    1744     label $inner.field_l -text "Field" -font $font
     1607        -variable [itcl::scope _settings(volume-quality)] \
     1608        -width 10 \
     1609        -showvalue off -command [itcl::code $this AdjustSetting volume-quality]
     1610
     1611    itk_component add field_l {
     1612        label $inner.field_l -text "Field" -font "Arial 9"
     1613    } {
     1614        ignore -font
     1615    }
    17451616    itk_component add field {
    1746         Rappture::Combobox $inner.field -editable no
     1617        Rappture::Combobox $inner.field -width 10 -editable no
    17471618    }
    17481619    bind $inner.field <<Value>> \
    1749         [itcl::code $this AdjustSetting -field]
    1750 
    1751     label $inner.colormap_l -text "Colormap" -font $font
    1752     itk_component add colormap {
    1753         Rappture::Combobox $inner.colormap -editable no
    1754     }
    1755     $inner.colormap choices insert end [GetColormapList]
    1756     bind $inner.colormap <<Value>> \
    1757         [itcl::code $this AdjustSetting -color]
    1758     $itk_component(colormap) value $_settings(-color)
     1620        [itcl::code $this AdjustSetting field]
     1621
     1622    label $inner.palette_l -text "Palette" -font "Arial 9"
     1623    itk_component add palette {
     1624        Rappture::Combobox $inner.palette -width 10 -editable no
     1625    }
     1626    $inner.palette choices insert end \
     1627        "BCGYR"              "BCGYR"            \
     1628        "BGYOR"              "BGYOR"            \
     1629        "blue"               "blue"             \
     1630        "blue-to-brown"      "blue-to-brown"    \
     1631        "blue-to-orange"     "blue-to-orange"   \
     1632        "blue-to-grey"       "blue-to-grey"     \
     1633        "green-to-magenta"   "green-to-magenta" \
     1634        "greyscale"          "greyscale"        \
     1635        "nanohub"            "nanohub"          \
     1636        "rainbow"            "rainbow"          \
     1637        "spectral"           "spectral"         \
     1638        "ROYGB"              "ROYGB"            \
     1639        "RYGCB"              "RYGCB"            \
     1640        "brown-to-blue"      "brown-to-blue"    \
     1641        "grey-to-blue"       "grey-to-blue"     \
     1642        "orange-to-blue"     "orange-to-blue"   
     1643
     1644    $itk_component(palette) value "BCGYR"
     1645    bind $inner.palette <<Value>> \
     1646        [itcl::code $this AdjustSetting volume-palette]
    17591647
    17601648    blt::table $inner \
    17611649        0,0 $inner.field_l   -anchor w -pady 2  \
    1762         0,1 $inner.field     -fill x   -pady 2 -cspan 3 \
    1763         1,0 $inner.visibility -anchor w -pady 2 -cspan 4 \
     1650        0,1 $inner.field     -anchor w -pady 2 -cspan 2 \
     1651        1,0 $inner.volume    -anchor w -pady 2 -cspan 4 \
    17641652        2,0 $inner.lighting  -anchor w -pady 2 -cspan 4 \
    17651653        3,0 $inner.dim_l     -anchor e -pady 2 \
    1766         3,1 $inner.material  -fill x   -pady 2 -cspan 2 \
    1767         3,3 $inner.bright_l  -anchor w -pady 2 \
    1768         4,0 $inner.opacity_l -anchor w -pady 2 -cspan 4 \
    1769         5,0 $inner.opacity   -fill x   -pady 2 -cspan 4 \
    1770         6,0 $inner.quality_l -anchor w -pady 2 -cspan 4 \
    1771         7,0 $inner.quality   -fill x   -pady 2 -cspan 4 \
    1772         8,0 $inner.colormap_l -anchor w -pady 2  \
    1773         8,1 $inner.colormap   -fill x   -pady 2 -cspan 3 \
    1774 
    1775     blt::table configure $inner r* c0 c1 c3 -resize none
    1776     blt::table configure $inner r9 c2 -resize expand
     1654        3,1 $inner.material  -fill x   -pady 2 \
     1655        3,2 $inner.bright_l  -anchor w -pady 2 \
     1656        4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \
     1657        5,0 $inner.quality   -fill x   -pady 2 -cspan 2 \
     1658        7,0 $inner.palette_l -anchor w -pady 2  \
     1659        7,1 $inner.palette   -anchor w -pady 2 -cspan 2 \
     1660
     1661    blt::table configure $inner r* c* -resize none
     1662    blt::table configure $inner r8 -resize expand
    17771663}
    17781664
    17791665itcl::body Rappture::VtkVolumeViewer::BuildAxisTab {} {
     1666
    17801667    set fg [option get $itk_component(hull) font Font]
    17811668    #set bfg [option get $itk_component(hull) boldFont Font]
     
    17831670    set inner [$itk_component(main) insert end \
    17841671        -title "Axis Settings" \
    1785         -icon [Rappture::icon axis2]]
     1672        -icon [Rappture::icon axis1]]
    17861673    $inner configure -borderwidth 4
    17871674
    17881675    checkbutton $inner.visible \
    1789         -text "Axes" \
    1790         -variable [itcl::scope _settings(-axesvisible)] \
    1791         -command [itcl::code $this AdjustSetting -axesvisible] \
     1676        -text "Show Axes" \
     1677        -variable [itcl::scope _settings(axesVisible)] \
     1678        -command [itcl::code $this AdjustSetting axesVisible] \
    17921679        -font "Arial 9"
    17931680
    17941681    checkbutton $inner.labels \
    1795         -text "Axis Labels" \
    1796         -variable [itcl::scope _settings(-axislabels)] \
    1797         -command [itcl::code $this AdjustSetting -axislabels] \
     1682        -text "Show Axis Labels" \
     1683        -variable [itcl::scope _settings(axisLabels)] \
     1684        -command [itcl::code $this AdjustSetting axisLabels] \
    17981685        -font "Arial 9"
    1799     label $inner.grid_l -text "Grid" -font "Arial 9"
    1800     checkbutton $inner.xgrid \
    1801         -text "X" \
    1802         -variable [itcl::scope _settings(-xgrid)] \
    1803         -command [itcl::code $this AdjustSetting -xgrid] \
     1686
     1687    checkbutton $inner.gridx \
     1688        -text "Show X Grid" \
     1689        -variable [itcl::scope _settings(axis-xgrid)] \
     1690        -command [itcl::code $this AdjustSetting axis-xgrid] \
    18041691        -font "Arial 9"
    1805     checkbutton $inner.ygrid \
    1806         -text "Y" \
    1807         -variable [itcl::scope _settings(-ygrid)] \
    1808         -command [itcl::code $this AdjustSetting -ygrid] \
     1692    checkbutton $inner.gridy \
     1693        -text "Show Y Grid" \
     1694        -variable [itcl::scope _settings(axis-ygrid)] \
     1695        -command [itcl::code $this AdjustSetting axis-ygrid] \
    18091696        -font "Arial 9"
    1810     checkbutton $inner.zgrid \
    1811         -text "Z" \
    1812         -variable [itcl::scope _settings(-zgrid)] \
    1813         -command [itcl::code $this AdjustSetting -zgrid] \
    1814         -font "Arial 9"
    1815     checkbutton $inner.minorticks \
    1816         -text "Minor Ticks" \
    1817         -variable [itcl::scope _settings(-axisminorticks)] \
    1818         -command [itcl::code $this AdjustSetting -axisminorticks] \
     1697    checkbutton $inner.gridz \
     1698        -text "Show Z Grid" \
     1699        -variable [itcl::scope _settings(axis-zgrid)] \
     1700        -command [itcl::code $this AdjustSetting axis-zgrid] \
    18191701        -font "Arial 9"
    18201702
     
    18271709        "static_triad"    "static" \
    18281710        "closest_triad"   "closest" \
    1829         "furthest_triad"  "farthest" \
     1711        "furthest_triad"  "furthest" \
    18301712        "outer_edges"     "outer"         
    1831     $itk_component(axismode) value $_settings(-axisflymode)
    1832     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     1713    $itk_component(axismode) value "static"
     1714    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlyMode]
    18331715
    18341716    blt::table $inner \
    1835         0,0 $inner.visible -anchor w -cspan 4 \
    1836         1,0 $inner.labels  -anchor w -cspan 4 \
    1837         2,0 $inner.minorticks  -anchor w -cspan 4 \
    1838         4,0 $inner.grid_l  -anchor w \
    1839         4,1 $inner.xgrid   -anchor w \
    1840         4,2 $inner.ygrid   -anchor w \
    1841         4,3 $inner.zgrid   -anchor w \
    1842         5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
    1843         5,1 $inner.mode    -fill x   -cspan 3
     1717        0,0 $inner.visible -anchor w -cspan 2 \
     1718        1,0 $inner.labels  -anchor w -cspan 2 \
     1719        2,0 $inner.gridx   -anchor w -cspan 2 \
     1720        3,0 $inner.gridy   -anchor w -cspan 2 \
     1721        4,0 $inner.gridz   -anchor w -cspan 2 \
     1722        5,0 $inner.mode_l  -anchor w -cspan 2 -padx { 2 0 } \
     1723        6,0 $inner.mode    -fill x   -cspan 2
    18441724
    18451725    blt::table configure $inner r* c* -resize none
    1846     blt::table configure $inner r7 c6 -resize expand
    1847     blt::table configure $inner r3 -height 0.125i
    1848 }
     1726    blt::table configure $inner r7 c1 -resize expand
     1727}
     1728
    18491729
    18501730itcl::body Rappture::VtkVolumeViewer::BuildCameraTab {} {
     
    18541734    $inner configure -borderwidth 4
    18551735
    1856     label $inner.view_l -text "view" -font "Arial 9"
    1857     set f [frame $inner.view]
    1858     foreach side { front back left right top bottom } {
    1859         button $f.$side  -image [Rappture::icon view$side] \
    1860             -command [itcl::code $this SetOrientation $side]
    1861         Rappture::Tooltip::for $f.$side "Change the view to $side"
    1862         pack $f.$side -side left
    1863     }
    1864     blt::table $inner \
    1865         0,0 $inner.view_l -anchor e -pady 2 \
    1866         0,1 $inner.view -anchor w -pady 2
    1867     blt::table configure $inner r0 -resize none
    1868 
    1869     set row 1
    18701736    set labels { qx qy qz qw xpan ypan zoom }
     1737    set row 0
    18711738    foreach tag $labels {
    1872         label $inner.${tag}-label -text $tag -font "Arial 9"
     1739        label $inner.${tag}label -text $tag -font "Arial 9"
    18731740        entry $inner.${tag} -font "Arial 9"  -bg white \
    1874             -textvariable [itcl::scope _view(-$tag)]
    1875         bind $inner.${tag} <Return> \
    1876             [itcl::code $this camera set -${tag}]
    1877         bind $inner.${tag} <KP_Enter> \
    1878             [itcl::code $this camera set -${tag}]
     1741            -textvariable [itcl::scope _view($tag)]
     1742        bind $inner.${tag} <KeyPress-Return> \
     1743            [itcl::code $this camera set ${tag}]
    18791744        blt::table $inner \
    1880             $row,0 $inner.${tag}-label -anchor e -pady 2 \
     1745            $row,0 $inner.${tag}label -anchor e -pady 2 \
    18811746            $row,1 $inner.${tag} -anchor w -pady 2
    18821747        blt::table configure $inner r$row -resize none
     
    18851750    checkbutton $inner.ortho \
    18861751        -text "Orthographic Projection" \
    1887         -variable [itcl::scope _view(-ortho)] \
    1888         -command [itcl::code $this camera set -ortho] \
     1752        -variable [itcl::scope _view(ortho)] \
     1753        -command [itcl::code $this camera set ortho] \
    18891754        -font "Arial 9"
    18901755    blt::table $inner \
     
    18991764
    19001765itcl::body Rappture::VtkVolumeViewer::BuildCutplaneTab {} {
    1901     set font [option get $itk_component(hull) font Font]
     1766
     1767    set fg [option get $itk_component(hull) font Font]
    19021768   
    19031769    set inner [$itk_component(main) insert end \
     
    19091775    checkbutton $inner.visible \
    19101776        -text "Show Cutplanes" \
    1911         -variable [itcl::scope _settings(-cutplanesvisible)] \
    1912         -command [itcl::code $this AdjustSetting -cutplanesvisible] \
     1777        -variable [itcl::scope _settings(cutplaneVisible)] \
     1778        -command [itcl::code $this AdjustSetting cutplaneVisible] \
     1779        -font "Arial 9"
     1780
     1781    checkbutton $inner.wireframe \
     1782        -text "Show Wireframe" \
     1783        -variable [itcl::scope _settings(cutplaneWireframe)] \
     1784        -command [itcl::code $this AdjustSetting cutplaneWireframe] \
    19131785        -font "Arial 9"
    19141786
    19151787    checkbutton $inner.lighting \
    19161788        -text "Enable Lighting" \
    1917         -variable [itcl::scope _settings(-cutplanelighting)] \
    1918         -command [itcl::code $this AdjustSetting -cutplanelighting] \
     1789        -variable [itcl::scope _settings(cutplaneLighting)] \
     1790        -command [itcl::code $this AdjustSetting cutplaneLighting] \
     1791        -font "Arial 9"
     1792
     1793    checkbutton $inner.edges \
     1794        -text "Show Edges" \
     1795        -variable [itcl::scope _settings(cutplaneEdges)] \
     1796        -command [itcl::code $this AdjustSetting cutplaneEdges] \
    19191797        -font "Arial 9"
    19201798
    19211799    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    19221800    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1923         -variable [itcl::scope _settings(-cutplaneopacity)] \
     1801        -variable [itcl::scope _settings(cutplane-opacity)] \
    19241802        -width 10 \
    19251803        -showvalue off \
    1926         -command [itcl::code $this AdjustSetting -cutplaneopacity]
    1927     $inner.opacity set $_settings(-cutplaneopacity)
     1804        -command [itcl::code $this AdjustSetting cutplane-opacity]
     1805    $inner.opacity set $_settings(cutplane-opacity)
    19281806
    19291807    # X-value slicer...
     
    19321810            -onimage [Rappture::icon x-cutplane] \
    19331811            -offimage [Rappture::icon x-cutplane] \
    1934             -command [itcl::code $this AdjustSetting -xcutplanevisible] \
    1935             -variable [itcl::scope _settings(-xcutplanevisible)]
     1812            -command [itcl::code $this AdjustSetting cutplane-xvisible] \
     1813            -variable [itcl::scope _settings(cutplane-xvisible)]
    19361814    }
    19371815    Rappture::Tooltip::for $itk_component(xCutButton) \
     
    19441822            -borderwidth 1 -highlightthickness 0 \
    19451823            -command [itcl::code $this EventuallySetCutplane x] \
    1946             -variable [itcl::scope _settings(-xcutplaneposition)]
     1824            -variable [itcl::scope _settings(cutplane-xposition)]
    19471825    } {
    19481826        usual
     
    19601838            -onimage [Rappture::icon y-cutplane] \
    19611839            -offimage [Rappture::icon y-cutplane] \
    1962             -command [itcl::code $this AdjustSetting -ycutplanevisible] \
    1963             -variable [itcl::scope _settings(-ycutplanevisible)]
     1840            -command [itcl::code $this AdjustSetting cutplane-yvisible] \
     1841            -variable [itcl::scope _settings(cutplane-yvisible)]
    19641842    }
    19651843    Rappture::Tooltip::for $itk_component(yCutButton) \
     
    19721850            -borderwidth 1 -highlightthickness 0 \
    19731851            -command [itcl::code $this EventuallySetCutplane y] \
    1974             -variable [itcl::scope _settings(-ycutplaneposition)]
     1852            -variable [itcl::scope _settings(cutplane-yposition)]
    19751853    } {
    19761854        usual
     
    19881866            -onimage [Rappture::icon z-cutplane] \
    19891867            -offimage [Rappture::icon z-cutplane] \
    1990             -command [itcl::code $this AdjustSetting -zcutplanevisible] \
    1991             -variable [itcl::scope _settings(-zcutplanevisible)]
     1868            -command [itcl::code $this AdjustSetting cutplane-zvisible] \
     1869            -variable [itcl::scope _settings(cutplane-zvisible)]
    19921870    }
    19931871    Rappture::Tooltip::for $itk_component(zCutButton) \
     
    20001878            -borderwidth 1 -highlightthickness 0 \
    20011879            -command [itcl::code $this EventuallySetCutplane z] \
    2002             -variable [itcl::scope _settings(-zcutplaneposition)]
     1880            -variable [itcl::scope _settings(cutplane-zposition)]
    20031881    } {
    20041882        usual
     
    20131891        0,0 $inner.visible              -anchor w -pady 2 -cspan 4 \
    20141892        1,0 $inner.lighting             -anchor w -pady 2 -cspan 4 \
    2015         2,0 $inner.opacity_l            -anchor w -pady 2 -cspan 3 \
    2016         3,0 $inner.opacity              -fill x   -pady 2 -cspan 3 \
    2017         4,0 $itk_component(xCutButton)  -anchor e -padx 2 -pady 2 \
    2018         5,0 $itk_component(xCutScale)   -fill y \
    2019         4,1 $itk_component(yCutButton)  -anchor e -padx 2 -pady 2 \
    2020         5,1 $itk_component(yCutScale)   -fill y \
    2021         4,2 $itk_component(zCutButton)  -anchor e -padx 2 -pady 2 \
    2022         5,2 $itk_component(zCutScale)   -fill y
     1893        2,0 $inner.wireframe            -anchor w -pady 2 -cspan 4 \
     1894        3,0 $inner.edges                -anchor w -pady 2 -cspan 4 \
     1895        4,0 $inner.opacity_l            -anchor w -pady 2 -cspan 3 \
     1896        5,0 $inner.opacity              -fill x   -pady 2 -cspan 3 \
     1897        6,0 $itk_component(xCutButton)  -anchor e -padx 2 -pady 2 \
     1898        7,0 $itk_component(xCutScale)   -fill y \
     1899        6,1 $itk_component(yCutButton)  -anchor e -padx 2 -pady 2 \
     1900        7,1 $itk_component(yCutScale)   -fill y \
     1901        6,2 $itk_component(zCutButton)  -anchor e -padx 2 -pady 2 \
     1902        7,2 $itk_component(zCutScale)   -fill y \
    20231903
    20241904    blt::table configure $inner r* c* -resize none
    2025     blt::table configure $inner r5 c3 -resize expand
     1905    blt::table configure $inner r7 c3 -resize expand
    20261906}
    20271907
     
    20421922            }
    20431923            switch -- $who {
    2044                 "-ortho" {
    2045                     if {$_view(-ortho)} {
     1924                "ortho" {
     1925                    if {$_view(ortho)} {
    20461926                        SendCmd "camera mode ortho"
    20471927                    } else {
     
    20491929                    }
    20501930                }
    2051                 "-xpan" - "-ypan" {
     1931                "xpan" - "ypan" {
    20521932                    PanCamera
    20531933                }
    2054                 "-qx" - "-qy" - "-qz" - "-qw" {
    2055                     set q [ViewToQuaternion]
     1934                "qx" - "qy" - "qz" - "qw" {
     1935                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    20561936                    $_arcball quaternion $q
    20571937                    EventuallyRotate $q
    20581938                }
    2059                 "-zoom" {
    2060                     SendCmd "camera zoom $_view(-zoom)"
     1939                "zoom" {
     1940                    SendCmd "camera zoom $_view(zoom)"
    20611941                }
    20621942            }
     
    21282008}
    21292009
    2130 itcl::body Rappture::VtkVolumeViewer::SetObjectStyle { dataobj cname } {
     2010itcl::body Rappture::VtkVolumeViewer::SetObjectStyle { dataobj comp } {
    21312011    # Parse style string.
    2132     set tag $dataobj-$cname
    2133     array set styles {
    2134         -lighting   1
    2135         -opacity    0.5
    2136         -outline    0
    2137         -visible    1
    2138     }
    2139     array set styles [$dataobj style $cname]
    2140     set _settings(-volumelighting) $styles(-lighting)
    2141     set _settings(-volumeopacity) [expr $styles(-opacity) * 100.0]
    2142     set _settings(-volumeoutline) $styles(-outline)
    2143     set _settings(-volumevisible) $styles(-visible)
    2144 
    2145     SendCmd "outline add $tag"
    2146     SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
    2147     SendCmd "outline visible $styles(-outline) $tag"
    2148 
    2149     SendCmd "$_cutplaneCmd add $tag"
    2150     SendCmd "$_cutplaneCmd color [Color2RGB $itk_option(-plotforeground)] $tag"
    2151     SendCmd "$_cutplaneCmd visible 0 $tag"
    2152 
     2012    set tag $dataobj-$comp
     2013    set style [$dataobj style $comp]
     2014    array set settings {
     2015        -color \#808080
     2016        -edges 0
     2017        -edgecolor black
     2018        -linewidth 1.0
     2019        -opacity 0.4
     2020        -wireframe 0
     2021        -lighting 1
     2022        -seeds 1
     2023        -seedcolor white
     2024        -visible 1
     2025    }
     2026    if { $dataobj != $_first } {
     2027        set settings(-opacity) 1
     2028    }
     2029    array set settings $style
    21532030    SendCmd "volume add $tag"
    2154     SendCmd "volume lighting $styles(-lighting) $tag"
    2155     SendCmd "volume opacity $styles(-opacity) $tag"
    2156     SendCmd "volume visible $styles(-visible) $tag"
    2157     SetColormap $dataobj $cname
     2031    SendCmd "cutplane add $tag"
     2032    SendCmd "cutplane visible 0 $tag"
     2033
     2034    SendCmd "volume lighting $settings(-lighting) $tag"
     2035    set _settings(volumeLighting) $settings(-lighting)
     2036    SetColormap $dataobj $comp
    21582037}
    21592038
     
    21742053itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title vmin vmax size } {
    21752054    set _legendPending 0
    2176     if { [isconnected] } {
     2055    #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size"
     2056    if { [IsConnected] } {
    21772057        set bytes [ReceiveBytes $size]
    21782058        if { ![info exists _image(legend)] } {
     
    22092089        set title $fname
    22102090    }
    2211     if { $_settings(-legendvisible) } {
     2091    if { $_settings(legendVisible) } {
    22122092        set x [expr $w - 2]
    22132093        if { [$c find withtag "legend"] == "" } {
     
    23462226            }
    23472227            set newpos [expr {0.01*$newval}]
    2348             SendCmd "$_cutplaneCmd slice $axis $newpos"
     2228            SendCmd "cutplane slice $axis $newpos"
    23492229        }
    23502230        "tooltip" {
     
    23582238    }
    23592239}
     2240
    23602241
    23612242# ----------------------------------------------------------------------
     
    23842265        }
    23852266        deactivate {
    2386             $c itemconfigure title -fill $itk_option(-plotforeground)
     2267            $c itemconfigure title -fill white
    23872268        }
    23882269        invoke {
    2389             $itk_component(field) value $_curFldLabel
    2390             AdjustSetting -field
     2270            $itk_component(field) value _curFldLabel
     2271            AdjustSetting field
    23912272        }
    23922273        default {
     
    23962277}
    23972278
    2398 itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } {
    2399     array set positions {
    2400         front "1 0 0 0"
    2401         back  "0 0 1 0"
    2402         left  "0.707107 0 -0.707107 0"
    2403         right "0.707107 0 0.707107 0"
    2404         top   "0.707107 -0.707107 0 0"
    2405         bottom "0.707107 0.707107 0 0"
    2406     }
    2407     foreach name { -qw -qx -qy -qz } value $positions($side) {
    2408         set _view($name) $value
    2409     }
    2410     set q [ViewToQuaternion]
    2411     $_arcball quaternion $q
    2412     SendCmd "camera orient $q"
    2413     SendCmd "camera reset"
    2414     set _view(-xpan) 0
    2415     set _view(-ypan) 0
    2416     set _view(-zoom) 1.0
    2417 }
    2418 
    2419 #
    2420 # GetDatasetsWithComponents --
    2421 #
    2422 #       Returns a list of all the datasets (known by the combination of
    2423 #       their data object and component name) that match the given
    2424 #       component name.  For example, this is used where we want to change
    2425 #       the settings of volumes that have the current component.
    2426 #
    2427 itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } {
    2428     if { ![info exists _volcomponents($cname)] } {
    2429         return ""
    2430     }
    2431     return $_volcomponents($cname)
    2432 }
Note: See TracChangeset for help on using the changeset viewer.