Ignore:
Timestamp:
Mar 11, 2015 10:26:15 AM (9 years ago)
Author:
dkearney
Message:

merging updates from 1.3 branch

looks like this branch originally came from the 1.3 branch and then had some
additions from the 1.4-pre branch and then a sync from the 1.3 branch. to get
this branch updated, I am reverting r4797 (additions from 1.4-pre branch),
reverting r4798 (additions from 1.3 branch), then merging in updates from 1.3
branch.

I fixed merge conflicts for the following files:

gui/scripts/gauge.tcl
gui/scripts/main.tcl
gui/scripts/tool.tcl
lang/tcl/scripts/task.tcl

Location:
branches/uq
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/uq

  • branches/uq/gui/scripts/vtkimageviewer.tcl

    r4798 r5121  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkimageviewer - Vtk image viewer
     
    5858    public method get {args}
    5959    public method isconnected {}
    60     public method limits3 { dataobj }
    61     public method parameters {title args} {
    62         # do nothing
     60    public method parameters {title args} {
     61        # do nothing
    6362    }
    6463    public method scale {args}
    6564
    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 AdjustMode {}
    73     protected method InitSettings { args  }
    74     protected method Pan {option x y}
    75     protected method Pick {x y}
    76     protected method Rebuild {}
    77     protected method ReceiveDataset { args }
    78     protected method ReceiveImage { args }
    79     protected method ReceiveLegend { colormap title min max size }
    80     protected method Rotate {option x y}
    81     protected method Zoom {option}
    82 
    8365    # The following methods are only used by this class.
     66    private method AdjustSetting {what {value ""}}
    8467    private method BuildAxisTab {}
    8568    private method BuildCameraTab {}
    8669    private method BuildColormap { name }
    8770    private method BuildImageTab {}
    88     private method BuildDownloadPopup { widget command } 
     71    private method BuildDownloadPopup { widget command }
    8972    private method Combo { option }
     73    private method Connect {}
     74    private method CurrentDatasets {args}
     75    private method Disconnect {}
     76    private method DoResize {}
     77    private method DoRotate {}
    9078    private method DrawLegend {}
    91     private method EnterLegend { x y }
    92     private method EventuallyRequestLegend {}
    93     private method EventuallyResize { w h }
    94     private method EventuallyRotate { q }
    95     private method GetImage { args }
    96     private method GetVtkData { args }
    97     private method IsValidObject { dataobj }
     79    private method EnterLegend { x y }
     80    private method EventuallyRequestLegend {}
     81    private method EventuallyResize { w h }
     82    private method EventuallyRotate { q }
     83    private method GetImage { args }
     84    private method GetVtkData { args }
     85    private method InitSettings { args  }
     86    private method IsValidObject { dataobj }
    9887    private method LeaveLegend {}
    99     private method MotionLegend { x y }
     88    private method MotionLegend { x y }
     89    private method Pan {option x y}
    10090    private method PanCamera {}
     91    private method Pick {x y}
     92    private method QuaternionToView { q } {
     93        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     94    }
     95    private method Rebuild {}
     96    private method ReceiveDataset { args }
     97    private method ReceiveImage { args }
     98    private method ReceiveLegend { colormap title min max size }
    10199    private method RequestLegend {}
     100    private method Rotate {option x y}
    102101    private method SetCurrentColormap { color }
    103102    private method SetLegendTip { x y }
    104     private method SetObjectStyle { dataobj comp } 
     103    private method SetObjectStyle { dataobj comp }
    105104    private method SetOrientation { side }
     105    private method ViewToQuaternion {} {
     106        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     107    }
     108    private method Zoom {option}
    106109
    107110    private variable _arcball ""
     
    109112    private variable _obj2datasets
    110113    private variable _obj2ovride   ;    # maps dataobj => style override
    111     private variable _datasets     ;    # contains all the dataobj-component 
     114    private variable _datasets     ;    # contains all the dataobj-component
    112115                                   ;    # datasets in the server
    113116    private variable _colormaps    ;    # contains all the colormaps
     
    125128
    126129    private variable _click        ;    # info used for rotate operations
    127     private variable _limits       ;    # Holds overall limits for all dataobjs 
     130    private variable _limits       ;    # Holds overall limits for all dataobjs
    128131                                        # using the viewer.
    129132    private variable _view         ;    # view params for 3D view
     
    150153    private variable _rotatePending 0
    151154    private variable _legendPending 0
    152     private variable _fieldNames {} 
    153     private variable _fields 
     155    private variable _fieldNames {}
     156    private variable _fields
    154157    private variable _curFldName ""
    155158    private variable _curFldLabel ""
     
    197200    # Initialize the view to some default parameters.
    198201    array set _view {
    199         qw      0.36
    200         qx      0.25
    201         qy      0.50
    202         qz      0.70
    203         zoom    1.0
    204         xpan    0
    205         ypan    0
    206         ortho   0
     202        -ortho           0
     203        -qw              0.36
     204        -qx              0.25
     205        -qy              0.50
     206        -qz              0.70
     207        -xpan            0
     208        -ypan            0
     209        -zoom            1.0
    207210    }
    208211    set _arcball [blt::arcball create 100 100]
    209     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    210     $_arcball quaternion $q
     212    $_arcball quaternion [ViewToQuaternion]
    211213
    212214    array set _settings {
    213         axisFlymode             "static"
    214         axisLabels              1
    215         axisMinorTicks          1
    216         axisVisible             1
    217         axisXGrid               0
    218         axisYGrid               0
    219         axisZGrid               0
    220         backingColor            white
    221         backingVisible          1
    222         colormapDiscrete        0
    223         field                   "Default"
    224         legendVisible           0
    225         level                   127.5
    226         numColors               256
    227         opacity                 100
    228         outline                 0
    229         saveOpacity             100
    230         stretchToFit            0
    231         view3D                  0
    232         window                  255.0
     215        -axisflymode            "static"
     216        -axislabels             1
     217        -axisminorticks         1
     218        -axisvisible            1
     219        -backingcolor           white
     220        -backingvisible         1
     221        -colormapdiscrete       0
     222        -field                  "Default"
     223        -legendvisible          0
     224        -level                  127.5
     225        -numcolors              256
     226        -opacity                100
     227        -outline                0
     228        -saveopacity            100
     229        -stretchtofit           0
     230        -view3d                 0
     231        -window                 255.0
     232        -xgrid                  0
     233        -ygrid                  0
     234        -zgrid                  0
    233235    }
    234236    array set _changed {
    235         opacity                 0
    236         colormap                0
     237        -colormap               0
     238        -opacity                0
    237239    }
    238240    itk_component add view {
     
    241243    } {
    242244        usual
    243         ignore -highlightthickness -borderwidth -background 
     245        ignore -highlightthickness -borderwidth -background
    244246    }
    245247
     
    247249        menu $itk_component(plotarea).menu \
    248250            -relief flat \
    249             -tearoff no 
     251            -tearoff no
    250252    } {
    251253        usual
     
    267269
    268270    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    269     set _map(cwidth) -1 
    270     set _map(cheight) -1 
     271    set _map(cwidth) -1
     272    set _map(cheight) -1
    271273    set _map(zoom) 1.0
    272274    set _map(original) ""
     
    313315            -onimage [Rappture::icon surface] \
    314316            -offimage [Rappture::icon surface] \
    315             -variable [itcl::scope _settings(view3D)] \
    316             -command [itcl::code $this AdjustSetting view3D] \
     317            -variable [itcl::scope _settings(-view3d)] \
     318            -command [itcl::code $this AdjustSetting -view3d] \
    317319    }
    318320    Rappture::Tooltip::for $itk_component(mode) \
     
    324326            -onimage [Rappture::icon stretchtofit] \
    325327            -offimage [Rappture::icon stretchtofit] \
    326             -variable [itcl::scope _settings(stretchToFit)] \
    327             -command [itcl::code $this AdjustSetting stretchToFit] \
     328            -variable [itcl::scope _settings(-stretchtofit)] \
     329            -command [itcl::code $this AdjustSetting -stretchtofit] \
    328330    }
    329331    Rappture::Tooltip::for $itk_component(stretchtofit) \
     
    336338        BuildCameraTab
    337339    } errs] != 0 } {
    338         global errorInfo
     340        global errorInfo
    339341        puts stderr "errs=$errs errorInfo=$errorInfo"
    340342    }
    341343
    342     # Hack around the Tk panewindow.  The problem is that the requested 
     344    # Hack around the Tk panewindow.  The problem is that the requested
    343345    # size of the 3d view isn't set until an image is retrieved from
    344346    # the server.  So the panewindow uses the tiny size.
     
    346348    pack forget $itk_component(view)
    347349    blt::table $itk_component(plotarea) \
    348         0,0 $itk_component(view) -fill both -reqwidth $w 
     350        0,0 $itk_component(view) -fill both -reqwidth $w
    349351    blt::table configure $itk_component(plotarea) c1 -resize none
    350352
     
    430432
    431433itcl::body Rappture::VtkImageViewer::DoRotate {} {
    432     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    433     SendCmd "camera orient $q"
     434    SendCmd "camera orient [ViewToQuaternion]"
    434435    set _rotatePending 0
    435436}
     
    455456
    456457itcl::body Rappture::VtkImageViewer::EventuallyRotate { q } {
    457     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     458    QuaternionToView $q
    458459    if { !$_rotatePending } {
    459460        set _rotatePending 1
    460         global rotate_delay 
     461        global rotate_delay
    461462        $_dispatcher event -after $rotate_delay !rotate
    462463    }
     
    557558                    continue
    558559                }
    559                 if {[info exists _obj2ovride($dataobj-raise)] && 
     560                if {[info exists _obj2ovride($dataobj-raise)] &&
    560561                    $_obj2ovride($dataobj-raise)} {
    561562                    set dlist [linsert $dlist 0 $dataobj]
     
    585586            }
    586587            return $dlist
    587         }           
     588        }
    588589        -image {
    589590            if {[llength $args] != 2} {
     
    605606}
    606607
    607 # 
     608#
    608609# scale  --
    609610#
    610611#       This gets called either incrementally as new simulations are
    611612#       added or all at once as a sequence of images.
    612 #       This  accounts for all objects--even those not showing on the 
    613 #       screen.  Because of this, the limits are appropriate for all 
     613#       This  accounts for all objects--even those not showing on the
     614#       screen.  Because of this, the limits are appropriate for all
    614615#       objects as the user scans through data in the ResultSet viewer.
    615616#
     
    654655    }
    655656    if { [array size found] > 1 } {
    656         set _settings(stretchToFit) 1
     657        set _settings(-stretchtofit) 1
    657658    } else {
    658659        # Check if the range of the x and y axes requires that we stretch
     
    663664        if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) ||
    664665             ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } {
    665             set _settings(stretchToFit) 1
     666            set _settings(-stretchtofit) 1
    666667        }
    667668    }
     
    803804    $_dispatcher cancel !legend
    804805    # disconnected -- no more data sitting on server
    805     array unset _datasets 
    806     array unset _data 
    807     array unset _colormaps 
    808     array unset _obj2datasets 
     806    array unset _datasets
     807    array unset _data
     808    array unset _colormaps
     809    array unset _obj2datasets
    809810    global readyForNextFrame
    810811    set readyForNextFrame 1
     
    830831    if { $info(-type) == "image" } {
    831832        if 0 {
    832             set f [open "last.ppm" "w"]
    833             puts $f $bytes
     833            set f [open "last.ppm" "w"]
     834            fconfigure $f -encoding binary
     835            puts -nonewline $f $bytes
    834836            close $f
    835837        }
     
    837839        set time [clock seconds]
    838840        set date [clock format $time]
    839         #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
     841        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
    840842        if { $_start > 0 } {
    841843            set finish [clock clicks -milliseconds]
     
    908910    # Turn on buffering of commands to the server.  We don't want to
    909911    # be preempted by a server disconnect/reconnect (which automatically
    910     # generates a new call to Rebuild).   
     912    # generates a new call to Rebuild).
    911913    StartBufferingCommands
    912914
    913915    if { $_width != $w || $_height != $h || $_reset } {
    914         set _width $w
    915         set _height $h
    916         $_arcball resize $w $h
    917         DoResize
    918         if { $_settings(stretchToFit) } {
    919             AdjustSetting stretchToFit
    920         }
     916        set _width $w
     917        set _height $h
     918        $_arcball resize $w $h
     919        DoResize
     920        if { $_settings(-stretchtofit) } {
     921            AdjustSetting -stretchToFit
     922        }
    921923    }
    922924    if { $_reset } {
    923         #
    924         # Reset the camera and other view parameters
    925         #
    926         InitSettings view3D background
    927 
    928         # Let's see how this goes.  I think it's preferable to overloading the
    929         # axis title with the exponent.
    930         SendCmd "axis exp 0 0 0 1"
    931 
    932         SendCmd "axis lrot z 90"
    933         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    934         $_arcball quaternion $q
    935         if {$_settings(view3D) } {
    936             if { $_view(ortho)} {
     925        #
     926        # Reset the camera and other view parameters
     927        #
     928        InitSettings -view3d -background
     929
     930        SendCmd "axis lrot z 90"
     931        $_arcball quaternion [ViewToQuaternion]
     932        if {$_settings(-view3d) } {
     933            if { $_view(-ortho)} {
    937934                SendCmd "camera mode ortho"
    938935            } else {
     
    941938            DoRotate
    942939            SendCmd "camera reset"
    943         }
    944         PanCamera
     940        }
     941        PanCamera
    945942        StopBufferingCommands
    946943        SendCmd "imgflush"
     
    960957            if { ![info exists _datasets($tag)] } {
    961958                set bytes [$dataobj vtkdata $comp]
    962                 if 0 {
     959                if 0 {
    963960                    set f [open /tmp/vtkimage.vtk "w"]
    964                     puts $f $bytes
     961                    fconfigure $f -translation binary -encoding binary
     962                    puts -nonewline $f $bytes
    965963                    close $f
    966                 }
     964                }
    967965                set length [string length $bytes]
    968966                if { $_reportClientInfo }  {
    969967                    set info {}
    970                     lappend info "tool_id"       [$dataobj hints toolId]
    971                     lappend info "tool_name"     [$dataobj hints toolName]
    972                     lappend info "tool_version"  [$dataobj hints toolRevision]
    973                     lappend info "tool_title"    [$dataobj hints toolTitle]
     968                    lappend info "tool_id"       [$dataobj hints toolid]
     969                    lappend info "tool_name"     [$dataobj hints toolname]
     970                    lappend info "tool_title"    [$dataobj hints tooltitle]
     971                    lappend info "tool_command"  [$dataobj hints toolcommand]
     972                    lappend info "tool_revision" [$dataobj hints toolrevision]
    974973                    lappend info "dataset_label" [$dataobj hints label]
    975974                    lappend info "dataset_size"  $length
    976975                    lappend info "dataset_tag"   $tag
    977                     SendCmd [list "clientinfo" $info]
     976                    SendCmd "clientinfo [list $info]"
    978977                }
    979978                SendCmd "dataset add $tag data follows $length"
     
    991990    }
    992991    if { $_first != ""  } {
    993         $itk_component(field) choices delete 0 end
    994         $itk_component(fieldmenu) delete 0 end
    995         array unset _fields
     992        $itk_component(field) choices delete 0 end
     993        $itk_component(fieldmenu) delete 0 end
     994        array unset _fields
    996995        set _curFldName ""
    997996        foreach cname [$_first components] {
     
    10191018        $itk_component(field) value $_curFldLabel
    10201019    }
    1021     InitSettings stretchToFit outline
     1020    InitSettings -stretchtofit -outline
    10221021
    10231022    if { $_reset } {
    1024         SendCmd "axis tickpos outside"
     1023        SendCmd "axis tickpos outside"
    10251024        #SendCmd "axis lformat all %g"
    1026        
    1027         foreach axis { x y z } {
     1025
     1026        foreach axis { x y z } {
    10281027            set label [$_first hints ${axis}label]
    1029             if { $label == "" } {
    1030                 set label [string toupper $axis]
    1031             }
    1032             # May be a space in the axis label.
    1033             SendCmd [list axis name $axis $label]
    1034 
    1035             if {$axis == "z" && [$_first hints ${axis}units] == ""} {
    1036                 set units [lindex $_fields($_curFldName) 1]
    1037             } else {
    1038                 set units [$_first hints ${axis}units]
    1039             }
    1040             if { $units != "" } {
    1041                 # May be a space in the axis units.
    1042                 SendCmd [list axis units $axis $units]
    1043             }
    1044         }
    1045         #
    1046         # Reset the camera and other view parameters
    1047         #
    1048         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1049         $_arcball quaternion $q
    1050         if {$_settings(view3D) } {
    1051             if { $_view(ortho)} {
     1028            if { $label == "" } {
     1029                set label [string toupper $axis]
     1030            }
     1031            # May be a space in the axis label.
     1032            SendCmd [list axis name $axis $label]
     1033
     1034            if {$axis == "z" && [$_first hints ${axis}units] == ""} {
     1035                if {$_curFldName != ""} {
     1036                    set units [lindex $_fields($_curFldName) 1]
     1037                }
     1038            } else {
     1039                set units [$_first hints ${axis}units]
     1040            }
     1041            if { $units != "" } {
     1042                # May be a space in the axis units.
     1043                SendCmd [list axis units $axis $units]
     1044            }
     1045        }
     1046        #
     1047        # Reset the camera and other view parameters
     1048        #
     1049        $_arcball quaternion [ViewToQuaternion]
     1050        if {$_settings(-view3d) } {
     1051            if { $_view(-ortho)} {
    10521052                SendCmd "camera mode ortho"
    10531053            } else {
     
    10571057            SendCmd "camera reset"
    10581058        }
    1059         PanCamera
    1060         InitSettings axisXGrid axisYGrid axisZGrid \
    1061             axisVisible axisLabels field view3D
     1059        PanCamera
     1060        InitSettings -xgrid -ygrid -zgrid \
     1061            -axisvisible -axislabels -field -view3d
    10621062        if { [array size _fields] < 2 } {
    1063             catch {
    1064                 blt::table forget $itk_component(field) $itk_component(field_l)
    1065             }
     1063            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
    10661064        }
    10671065        RequestLegend
     
    10691067    }
    10701068    global readyForNextFrame
    1071     set readyForNextFrame 0;            # Don't advance to the next frame
     1069    set readyForNextFrame 0;                # Don't advance to the next frame
    10721070
    10731071    # Actually write the commands to the server socket.  If it fails, we don't
     
    10871085itcl::body Rappture::VtkImageViewer::CurrentDatasets {args} {
    10881086    set flag [lindex $args 0]
    1089     switch -- $flag { 
     1087    switch -- $flag {
    10901088        "-all" {
    10911089            if { [llength $args] > 1 } {
     
    11061104                set dlist [get -visible]
    11071105            }
    1108         }           
     1106        }
    11091107        default {
    11101108            set dlist $args
     
    11341132    switch -- $option {
    11351133        "in" {
    1136             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1137             SendCmd "camera zoom $_view(zoom)"
     1134            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1135            SendCmd "camera zoom $_view(-zoom)"
    11381136        }
    11391137        "out" {
    1140             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1141             SendCmd "camera zoom $_view(zoom)"
     1138            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1139            SendCmd "camera zoom $_view(-zoom)"
    11421140        }
    11431141        "reset" {
    11441142            array set _view {
    1145                 qw      0.36
    1146                 qx      0.25
    1147                 qy      0.50
    1148                 qz      0.70
    1149                 zoom    1.0
    1150                 xpan    0
    1151                 ypan    0
     1143                -qw      0.36
     1144                -qx      0.25
     1145                -qy      0.50
     1146                -qz      0.70
     1147                -xpan    0
     1148                -ypan    0
     1149                -zoom    1.0
    11521150            }
    11531151            if { $_first != "" } {
     
    11571155                }
    11581156            }
    1159             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1160             $_arcball quaternion $q
    1161             if {$_settings(view3D) } {
     1157            $_arcball quaternion [ViewToQuaternion]
     1158            if {$_settings(-view3d) } {
    11621159                DoRotate
    11631160            }
     
    11681165
    11691166itcl::body Rappture::VtkImageViewer::PanCamera {} {
    1170     set x $_view(xpan)
    1171     set y $_view(ypan)
     1167    set x $_view(-xpan)
     1168    set y $_view(-ypan)
    11721169    SendCmd "camera pan $x $y"
    11731170}
     
    12291226    foreach tag [CurrentDatasets -visible] {
    12301227        SendCmd "dataset getscalar pixel $x $y $tag"
    1231     } 
     1228    }
    12321229}
    12331230
     
    12471244            set x [expr $x / double($w)]
    12481245            set y [expr $y / double($h)]
    1249             set _view(xpan) [expr $_view(xpan) + $x]
    1250             set _view(ypan) [expr $_view(ypan) + $y]
     1246            set _view(-xpan) [expr $_view(-xpan) + $x]
     1247            set _view(-ypan) [expr $_view(-ypan) + $y]
    12511248            PanCamera
    12521249            return
     
    12701267            set _click(x) $x
    12711268            set _click(y) $y
    1272             set _view(xpan) [expr $_view(xpan) - $dx]
    1273             set _view(ypan) [expr $_view(ypan) - $dy]
     1269            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1270            set _view(-ypan) [expr $_view(-ypan) - $dy]
    12741271            PanCamera
    12751272        }
     
    12931290itcl::body Rappture::VtkImageViewer::InitSettings { args } {
    12941291    foreach spec $args {
    1295         if { [info exists _settings($_first-$spec)] } {
     1292        if { [info exists _settings($_first${spec})] } {
    12961293            # Reset global setting with dataobj specific setting
    1297             set _settings($spec) $_settings($_first-$spec)
     1294            set _settings($spec) $_settings($_first${spec})
    12981295        }
    12991296        AdjustSetting $spec
     
    13131310    }
    13141311    switch -- $what {
    1315         "axisFlymode" {
     1312        "-axisflymode" {
    13161313            set mode [$itk_component(axisflymode) value]
    13171314            set mode [$itk_component(axisflymode) translate $mode]
     
    13191316            SendCmd "axis flymode $mode"
    13201317        }
    1321         "axisLabels" {
     1318        "-axislabels" {
    13221319            set bool $_settings($what)
    13231320            SendCmd "axis labels all $bool"
    13241321        }
    1325         "axisMinorTicks" {
     1322        "-axisminorticks" {
    13261323            set bool $_settings($what)
    13271324            SendCmd "axis minticks all $bool"
    13281325        }
    1329         "axisVisible" {
     1326        "-axisvisible" {
    13301327            set bool $_settings($what)
    13311328            SendCmd "axis visible all $bool"
    13321329        }
    1333         "axisXGrid" - "axisYGrid" - "axisZGrid" {
    1334             set axis [string tolower [string range $what 4 4]]
    1335             set bool $_settings($what)
    1336             SendCmd "axis grid $axis $bool"
    1337         }
    1338         "background" {
     1330        "-background" {
    13391331            set bg [$itk_component(background) value]
    1340             array set fgcolors {
    1341                 "black" "white"
    1342                 "white" "black"
    1343                 "grey"  "black"
    1344             }
     1332            array set fgcolors {
     1333                "black" "white"
     1334                "white" "black"
     1335                "grey"  "black"
     1336            }
    13451337            set fg $fgcolors($bg)
    13461338            configure -plotbackground $bg -plotforeground $fg
    1347             $itk_component(view) delete "legend"
     1339            $itk_component(view) delete "legend"
    13481340            SendCmd "screen bgcolor [Color2RGB $bg]"
    13491341            SendCmd "outline color [Color2RGB $fg]"
    13501342            SendCmd "axis color all [Color2RGB $fg]"
    1351             DrawLegend
    1352         }
    1353         "backingColor" {
     1343            DrawLegend
     1344        }
     1345        "-backingcolor" {
    13541346            set color [$itk_component(backingcolor) value]
    1355             if { $color == "none" } {
    1356                 if { $_settings(backingVisible) } {
    1357                     SendCmd "image backing 0"
    1358                     set _settings(backingVisible) 0
    1359                 }
    1360             } else {
    1361                 if { !$_settings(backingVisible) } {
    1362                     SendCmd "image backing 1"
    1363                     set _settings(backingVisible) 1
    1364                 }
    1365                 SendCmd "image color [Color2RGB $color]"
    1366             }
    1367         }
    1368         "backingVisible" {
    1369             set bool $_settings($what)
     1347            if { $color == "none" } {
     1348                if { $_settings(-backingvisible) } {
     1349                    SendCmd "image backing 0"
     1350                    set _settings(-backingvisible) 0
     1351                }
     1352            } else {
     1353                if { !$_settings(-backingvisible) } {
     1354                    SendCmd "image backing 1"
     1355                    set _settings(-backingvisible) 1
     1356                }
     1357                SendCmd "image color [Color2RGB $color]"
     1358            }
     1359        }
     1360        "-backingvisible" {
     1361            set bool $_settings($what)
    13701362            SendCmd "image backing $bool"
    13711363        }
    1372         "colormap" {
     1364        "-colormap" {
    13731365            set _changed($what) 1
    13741366            StartBufferingCommands
     
    13761368            set _settings($what) $color
    13771369            SetCurrentColormap $color
    1378             if {$_settings(colormapDiscrete)} {
    1379                  SendCmd "colormap res $_settings(numColors) $color"
     1370            if {$_settings(-colormapdiscrete)} {
     1371                 SendCmd "colormap res $_settings(-numcolors) $color"
    13801372            }
    13811373            StopBufferingCommands
    1382             EventuallyRequestLegend
    1383         }
    1384         "colormapDiscrete" {
     1374            EventuallyRequestLegend
     1375        }
     1376        "-colormapdiscrete" {
    13851377            set bool $_settings($what)
    13861378            StartBufferingCommands
    13871379            if {$bool} {
    1388                 SendCmd "colormap res $_settings(numColors)"
     1380                SendCmd "colormap res $_settings(-numcolors)"
    13891381            } else {
    13901382                SendCmd "colormap res default"
     
    13931385            EventuallyRequestLegend
    13941386        }
    1395         "field" {
     1387        "-field" {
    13961388            set label [$itk_component(field) value]
    13971389            set fname [$itk_component(field) translate $label]
     
    14171409            DrawLegend
    14181410        }
    1419         "view3D" {
    1420             set bool $_settings($what)
     1411        "-view3d" {
     1412            set bool $_settings($what)
    14211413            set c $itk_component(view)
    14221414            StartBufferingCommands
    14231415            # Fix image scale: 0 for contours, 1 for images.
    14241416            if { $bool } {
    1425                 set _settings(opacity) $_settings(saveOpacity)
     1417                set _settings(-opacity) $_settings(-saveopacity)
    14261418            } else {
    1427                 set _settings(opacity) 100
    1428             }
    1429             AdjustSetting opacity
    1430             if { $bool } {
    1431                 $itk_component(opacity) configure -state normal
    1432                 $itk_component(opacity_l) configure -state normal
    1433                 if {$_view(ortho)} {
     1419                set _settings(-opacity) 100
     1420            }
     1421            AdjustSetting -opacity
     1422            if { $bool } {
     1423                $itk_component(opacity) configure -state normal
     1424                $itk_component(opacity_l) configure -state normal
     1425                if {$_view(-ortho)} {
    14341426                    SendCmd "camera mode ortho"
    14351427                } else {
     
    14371429                }
    14381430                SendCmd "camera aspect native"
    1439             } else {
    1440                 $itk_component(opacity) configure -state disabled
    1441                 $itk_component(opacity_l) configure -state disabled
     1431            } else {
     1432                $itk_component(opacity) configure -state disabled
     1433                $itk_component(opacity_l) configure -state disabled
    14421434                SendCmd "camera mode image"
    1443                 if {$_settings(stretchToFit)} {
     1435                if {$_settings(-stretchtofit)} {
    14441436                    SendCmd "camera aspect window"
    14451437                }
    14461438            }
    14471439            if { $bool } {
    1448                 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1440                set q [ViewToQuaternion]
    14491441                $_arcball quaternion $q
    1450                 SendCmd "camera orient $q" 
     1442                SendCmd "camera orient $q"
    14511443            } else {
    14521444                bind $c <ButtonPress-1> {}
     
    14551447            }
    14561448            SendCmd "camera reset"
    1457             # Fix the mouse bindings for rotation/panning and the 
     1449            # Fix the mouse bindings for rotation/panning and the
    14581450            # camera mode. Ideally we'd create a bindtag for these.
    14591451            if { $bool } {
     
    14681460            StopBufferingCommands
    14691461        }
    1470         "window" {
     1462        "-window" {
    14711463            set val $_settings($what)
    14721464            SendCmd "image window $val"
    14731465        }
    1474         "level" {
     1466        "-level" {
    14751467            set val $_settings($what)
    14761468            SendCmd "image level $val"
    14771469        }
    1478         "legendVisible" {
     1470        "-legendvisible" {
    14791471            if { !$_settings($what) } {
    1480                 $itk_component(view) delete legend
    1481             }
    1482             DrawLegend
    1483         }
    1484         "opacity" {
     1472                $itk_component(view) delete legend
     1473            }
     1474            DrawLegend
     1475        }
     1476        "-opacity" {
    14851477            set _changed($what) 1
    1486             if { $_settings(view3D) } {
    1487                 set _settings(saveOpacity) $_settings($what)
     1478            if { $_settings(-view3d) } {
     1479                set _settings(-saveopacity) $_settings($what)
    14881480                set val [expr $_settings($what) * 0.01]
    14891481                SendCmd "image opacity $val"
    14901482            } else {
    1491                 SendCmd "image opacity 1.0"
    1492             }
    1493         }
    1494         "outline" {
     1483                SendCmd "image opacity 1.0"
     1484            }
     1485        }
     1486        "-outline" {
    14951487            set bool $_settings($what)
    14961488            SendCmd "outline visible $bool"
    1497         }
    1498         "stretchToFit" {
    1499             set bool $_settings($what)
    1500             if { $bool } {
    1501                 if { $_settings(view3D) } {
    1502                     SendCmd "camera aspect native"
    1503                 } else {
    1504                     SendCmd "camera aspect window"
    1505                 }
    1506             } else {
    1507                 SendCmd "camera aspect native"
    1508             }
    1509         }
    1510         default {
     1489        }
     1490        "-stretchtofit" {
     1491            set bool $_settings($what)
     1492            if { $bool } {
     1493                if { $_settings(-view3d) } {
     1494                    SendCmd "camera aspect native"
     1495                } else {
     1496                    SendCmd "camera aspect window"
     1497                }
     1498            } else {
     1499                SendCmd "camera aspect native"
     1500            }
     1501        }
     1502        "-xgrid" - "-ygrid" - "-zgrid" {
     1503            set axis [string tolower [string range $what 1 1]]
     1504            set bool $_settings($what)
     1505            SendCmd "axis grid $axis $bool"
     1506        }
     1507        default {
    15111508            error "don't know how to fix $what"
    15121509        }
     
    15181515#
    15191516#       Request a new legend from the server.  The size of the legend
    1520 #       is determined from the height of the canvas. 
     1517#       is determined from the height of the canvas.
    15211518#
    15221519# This should be called when
    1523 #       1.  A new current colormap is set.
    1524 #       2.  Window is resized.
    1525 #       3.  The limits of the data have changed.  (Just need a redraw).
    1526 #       4.  Number of isolines have changed. (Just need a redraw).
    1527 #       5.  Legend becomes visible (Just need a redraw).
     1520#        1.  A new current colormap is set.
     1521#        2.  Window is resized.
     1522#        3.  The limits of the data have changed.  (Just need a redraw).
     1523#        4.  Number of isolines have changed. (Just need a redraw).
     1524#        5.  Legend becomes visible (Just need a redraw).
    15281525#
    15291526itcl::body Rappture::VtkImageViewer::RequestLegend {} {
     
    15321529    set w 12
    15331530    set lineht [font metrics $font -linespace]
    1534     # color ramp height = (canvas height) - (min and max value lines) - 2 
     1531    # color ramp height = (canvas height) - (min and max value lines) - 2
    15351532    set h [expr {$_height - 2 * ($lineht + 2)}]
    15361533    set _legendHeight $h
     
    15381535    set fname $_curFldName
    15391536    if { [string match "component*" $fname] } {
    1540         set title ""
     1537        set title ""
    15411538    } else {
    1542         if { [info exists _fields($fname)] } {
    1543             foreach { title units } $_fields($fname) break
    1544             if { $units != "" } {
    1545                 set title [format "%s (%s)" $title $units]
    1546             }
    1547         } else {
    1548             set title $fname
    1549         }
     1539        if { [info exists _fields($fname)] } {
     1540            foreach { title units } $_fields($fname) break
     1541            if { $units != "" } {
     1542                set title [format "%s (%s)" $title $units]
     1543            }
     1544        } else {
     1545            set title $fname
     1546        }
    15501547    }
    15511548    # If there's a title too, substract one more line
    15521549    if { $title != "" } {
    1553         incr h -$lineht 
     1550        incr h -$lineht
    15541551    }
    15551552    if { $h < 1 } {
     
    15581555    # Set the legend on the first image dataset.
    15591556    if { $_currentColormap != "" && $_currentColormap != "none" } {
    1560         SendCmd "legend $_currentColormap scalar $_curFldName {} $w $h 0"
     1557        #SendCmd "legend $_currentColormap scalar $_curFldName {} $w $h 0"
     1558        SendCmd "legend2 $_currentColormap $w $h"
    15611559    }
    15621560}
     
    15681566    # Keep track of the colormaps that we build.
    15691567    if { $name != "none" && ![info exists _colormaps($name)] } {
    1570         BuildColormap $name 
     1568        BuildColormap $name
    15711569        set _colormaps($name) 1
    15721570    }
     
    15951593itcl::configbody Rappture::VtkImageViewer::mode {
    15961594    switch -- $itk_option(-mode) {
    1597         "volume" {
    1598             set _settings(view3D) 1
    1599         }
    1600         "vtkimage" {
    1601             set _settings(view3D) 0
    1602         }
    1603         default {
    1604             error "unknown mode settings \"$itk_option(-mode)\""
    1605         }
     1595        "volume" {
     1596            set _settings(-view3d) 1
     1597        }
     1598        "vtkimage" {
     1599            set _settings(-view3d) 0
     1600        }
     1601        default {
     1602            error "unknown mode settings \"$itk_option(-mode)\""
     1603        }
    16061604    }
    16071605    if { !$_reset } {
    1608         AdjustSetting view3D
     1606        AdjustSetting -view3d
    16091607    }
    16101608}
     
    16191617            SendCmd "screen bgcolor $rgb"
    16201618        }
    1621         $itk_component(view) configure -background $itk_option(-plotbackground)
     1619        $itk_component(view) configure -background $itk_option(-plotbackground)
    16221620    }
    16231621}
     
    16301628        set rgb [Color2RGB $itk_option(-plotforeground)]
    16311629        if { !$_reset } {
     1630            SendCmd "axis color all $rgb"
    16321631            SendCmd "outline color $rgb"
    1633             SendCmd "axis color all $rgb"
    1634         }
    1635     }
    1636 }
    1637 
    1638 itcl::body Rappture::VtkImageViewer::limits3 { dataobj } {
    1639     lappend limits x [$dataobj limits x]
    1640     lappend limits y [$dataobj limits y]
    1641     if { [catch { $dataobj limits $_curFldName } vlim] != 0 } {
    1642         set vlim [$dataobj limits v]
    1643     }
    1644     lappend limits v $vlim
    1645     return $limits
     1632        }
     1633    }
    16461634}
    16471635
     
    16581646    checkbutton $inner.legend \
    16591647        -text "Legend" \
    1660         -variable [itcl::scope _settings(legendVisible)] \
    1661         -command [itcl::code $this AdjustSetting legendVisible] \
     1648        -variable [itcl::scope _settings(-legendvisible)] \
     1649        -command [itcl::code $this AdjustSetting -legendvisible] \
    16621650        -font "Arial 9"
    16631651
    16641652    checkbutton $inner.outline \
    16651653        -text "Outline" \
    1666         -variable [itcl::scope _settings(outline)] \
    1667         -command [itcl::code $this AdjustSetting outline] \
     1654        -variable [itcl::scope _settings(-outline)] \
     1655        -command [itcl::code $this AdjustSetting -outline] \
    16681656        -font "Arial 9"
    16691657
    16701658    checkbutton $inner.backing \
    16711659        -text "Backing" \
    1672         -variable [itcl::scope _settings(backingVisible)] \
    1673         -command [itcl::code $this AdjustSetting backingVisible] \
     1660        -variable [itcl::scope _settings(-backingvisible)] \
     1661        -command [itcl::code $this AdjustSetting -backingvisible] \
    16741662        -font "Arial 9"
    16751663
    16761664    checkbutton $inner.stretch \
    16771665        -text "Stretch to fit" \
    1678         -variable [itcl::scope _settings(stretchToFit)] \
    1679         -command [itcl::code $this AdjustSetting stretchToFit] \
     1666        -variable [itcl::scope _settings(-stretchtofit)] \
     1667        -command [itcl::code $this AdjustSetting -stretchtofit] \
    16801668        -font "Arial 9"
    16811669
    16821670    checkbutton $inner.colormapDiscrete \
    16831671        -text "Discrete Colormap" \
    1684         -variable [itcl::scope _settings(colormapDiscrete)] \
    1685         -command [itcl::code $this AdjustSetting colormapDiscrete] \
     1672        -variable [itcl::scope _settings(-colormapdiscrete)] \
     1673        -command [itcl::code $this AdjustSetting -colormapdiscrete] \
    16861674        -font "Arial 9"
    16871675
    16881676    itk_component add field_l {
    1689         label $inner.field_l -text "Field" -font "Arial 9" 
     1677        label $inner.field_l -text "Field" -font "Arial 9"
    16901678    } {
    16911679        ignore -font
     
    16951683    }
    16961684    bind $inner.field <<Value>> \
    1697         [itcl::code $this AdjustSetting field]
    1698 
    1699     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     1685        [itcl::code $this AdjustSetting -field]
     1686
     1687    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    17001688    itk_component add colormap {
    17011689        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    17051693    $itk_component(colormap) value "BCGYR"
    17061694    bind $inner.colormap <<Value>> \
    1707         [itcl::code $this AdjustSetting colormap]
    1708 
    1709     label $inner.backingcolor_l -text "Backing Color" -font "Arial 9" 
     1695        [itcl::code $this AdjustSetting -colormap]
     1696
     1697    label $inner.backingcolor_l -text "Backing Color" -font "Arial 9"
    17101698    itk_component add backingcolor {
    17111699        Rappture::Combobox $inner.backingcolor -width 10 -editable no
     
    17211709        "red"                "red"              \
    17221710        "white"              "white"            \
    1723         "none"               "none"
    1724 
    1725     $itk_component(backingcolor) value "white"
     1711        "none"               "none"
     1712
     1713    $itk_component(backingcolor) value $_settings(-backingcolor)
    17261714    bind $inner.backingcolor <<Value>> \
    1727         [itcl::code $this AdjustSetting backingColor]
    1728 
    1729     label $inner.background_l -text "Background Color" -font "Arial 9" 
     1715        [itcl::code $this AdjustSetting -backingcolor]
     1716
     1717    label $inner.background_l -text "Background Color" -font "Arial 9"
    17301718    itk_component add background {
    17311719        Rappture::Combobox $inner.background -width 10 -editable no
     
    17341722        "black"              "black"            \
    17351723        "white"              "white"            \
    1736         "grey"               "grey"             
     1724        "grey"               "grey"
    17371725
    17381726    $itk_component(background) value "white"
    1739     bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]
     1727    bind $inner.background <<Value>> \
     1728        [itcl::code $this AdjustSetting -background]
    17401729
    17411730    itk_component add opacity_l {
     
    17461735    itk_component add opacity {
    17471736        ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1748             -variable [itcl::scope _settings(opacity)] \
     1737            -variable [itcl::scope _settings(-opacity)] \
    17491738            -showvalue off \
    1750             -command [itcl::code $this AdjustSetting opacity]
     1739            -command [itcl::code $this AdjustSetting -opacity]
    17511740    }
    17521741
     
    17581747    itk_component add window {
    17591748        ::scale $inner.window -from 0 -to 255 -orient horizontal \
    1760             -variable [itcl::scope _settings(window)] \
     1749            -variable [itcl::scope _settings(-window)] \
    17611750            -showvalue off \
    1762             -command [itcl::code $this AdjustSetting window]
     1751            -command [itcl::code $this AdjustSetting -window]
    17631752    }
    17641753    itk_component add level_l {
     
    17691758    itk_component add level {
    17701759        ::scale $inner.level -from 0 -to 255 -orient horizontal \
    1771             -variable [itcl::scope _settings(level)] \
     1760            -variable [itcl::scope _settings(-level)] \
    17721761            -showvalue off \
    1773             -command [itcl::code $this AdjustSetting level]
     1762            -command [itcl::code $this AdjustSetting -level]
    17741763    }
    17751764
     
    17841773        2,0 $inner.backingcolor_l  -anchor w -pady 2  \
    17851774        2,1 $inner.backingcolor    -anchor w -pady 2 -fill x  \
    1786         3,0 $inner.background_l -anchor w -pady 2 \
    1787         3,1 $inner.background -anchor w -pady 2  -fill x \
     1775        3,0 $inner.background_l -anchor w -pady 2 \
     1776        3,1 $inner.background -anchor w -pady 2  -fill x \
    17881777        4,0 $inner.backing -anchor w -pady 2 -cspan 2 \
    17891778        5,0 $inner.stretch    -anchor w -pady 2 -cspan 2 \
     
    17981787        16,1 $inner.window   -fill x   -pady 2 \
    17991788        17,0 $inner.level_l -anchor w -pady 2 \
    1800         17,1 $inner.level   -fill x   -pady 2 
     1789        17,1 $inner.level   -fill x   -pady 2
    18011790
    18021791    blt::table configure $inner r* c* -resize none
     
    18161805    checkbutton $inner.visible \
    18171806        -text "Axes" \
    1818         -variable [itcl::scope _settings(axisVisible)] \
    1819         -command [itcl::code $this AdjustSetting axisVisible] \
     1807        -variable [itcl::scope _settings(-axisvisible)] \
     1808        -command [itcl::code $this AdjustSetting -axisvisible] \
    18201809        -font "Arial 9"
    18211810    checkbutton $inner.labels \
    18221811        -text "Axis Labels" \
    1823         -variable [itcl::scope _settings(axisLabels)] \
    1824         -command [itcl::code $this AdjustSetting axisLabels] \
     1812        -variable [itcl::scope _settings(-axislabels)] \
     1813        -command [itcl::code $this AdjustSetting -axislabels] \
    18251814        -font "Arial 9"
    1826     label $inner.grid_l -text "Grid" -font "Arial 9" 
     1815    label $inner.grid_l -text "Grid" -font "Arial 9"
    18271816    checkbutton $inner.xgrid \
    18281817        -text "X" \
    1829         -variable [itcl::scope _settings(axisXGrid)] \
    1830         -command [itcl::code $this AdjustSetting axisXGrid] \
     1818        -variable [itcl::scope _settings(-xgrid)] \
     1819        -command [itcl::code $this AdjustSetting -xgrid] \
    18311820        -font "Arial 9"
    18321821    checkbutton $inner.ygrid \
    18331822        -text "Y" \
    1834         -variable [itcl::scope _settings(axisYGrid)] \
    1835         -command [itcl::code $this AdjustSetting axisYGrid] \
     1823        -variable [itcl::scope _settings(-ygrid)] \
     1824        -command [itcl::code $this AdjustSetting -ygrid] \
    18361825        -font "Arial 9"
    18371826    checkbutton $inner.zgrid \
    18381827        -text "Z" \
    1839         -variable [itcl::scope _settings(axisZGrid)] \
    1840         -command [itcl::code $this AdjustSetting axisZGrid] \
     1828        -variable [itcl::scope _settings(-zgrid)] \
     1829        -command [itcl::code $this AdjustSetting -zgrid] \
    18411830        -font "Arial 9"
    18421831    checkbutton $inner.minorticks \
    18431832        -text "Minor Ticks" \
    1844         -variable [itcl::scope _settings(axisMinorTicks)] \
    1845         -command [itcl::code $this AdjustSetting axisMinorTicks] \
     1833        -variable [itcl::scope _settings(-axisminorticks)] \
     1834        -command [itcl::code $this AdjustSetting -axisminorticks] \
    18461835        -font "Arial 9"
    18471836
    1848     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1837    label $inner.mode_l -text "Mode" -font "Arial 9"
    18491838
    18501839    itk_component add axisflymode {
     
    18551844        "closest_triad"   "closest" \
    18561845        "furthest_triad"  "farthest" \
    1857         "outer_edges"     "outer"         
    1858     $itk_component(axisflymode) value "static"
    1859     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlymode]
     1846        "outer_edges"     "outer"
     1847    $itk_component(axisflymode) value $_settings(-axisflymode)
     1848    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
    18601849
    18611850    blt::table $inner \
     
    18631852        1,0 $inner.labels  -anchor w -cspan 4 \
    18641853        2,0 $inner.minorticks  -anchor w -cspan 4 \
    1865         4,0 $inner.grid_l  -anchor w \
     1854        4,0 $inner.grid_l  -anchor w \
    18661855        4,1 $inner.xgrid   -anchor w \
    18671856        4,2 $inner.ygrid   -anchor w \
    18681857        4,3 $inner.zgrid   -anchor w \
    18691858        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
    1870         5,1 $inner.mode    -fill x -cspan 3 
     1859        5,1 $inner.mode    -fill x -cspan 3
    18711860
    18721861    blt::table configure $inner r* c* -resize none
     
    18741863    blt::table configure $inner r3 -height 0.125i
    18751864}
    1876 
    18771865
    18781866itcl::body Rappture::VtkImageViewer::BuildCameraTab {} {
     
    18941882        0,0 $inner.view_l -anchor e -pady 2 \
    18951883        0,1 $inner.view -anchor w -pady 2
     1884    blt::table configure $inner r0 -resize none
    18961885
    18971886    set labels { qx qy qz qw xpan ypan zoom }
     
    19001889        label $inner.${tag}label -text $tag -font "Arial 9"
    19011890        entry $inner.${tag} -font "Arial 9"  -bg white \
    1902             -textvariable [itcl::scope _view($tag)]
     1891            -textvariable [itcl::scope _view(-$tag)]
    19031892        bind $inner.${tag} <Return> \
    1904             [itcl::code $this camera set ${tag}]
     1893            [itcl::code $this camera set -${tag}]
    19051894        bind $inner.${tag} <KP_Enter> \
    1906             [itcl::code $this camera set ${tag}]
     1895            [itcl::code $this camera set -${tag}]
    19071896        blt::table $inner \
    19081897            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    19131902    checkbutton $inner.ortho \
    19141903        -text "Orthographic Projection" \
    1915         -variable [itcl::scope _view(ortho)] \
    1916         -command [itcl::code $this camera set ortho] \
     1904        -variable [itcl::scope _view(-ortho)] \
     1905        -command [itcl::code $this camera set -ortho] \
    19171906        -font "Arial 9"
    19181907    blt::table $inner \
     
    19211910    incr row
    19221911
    1923     blt::table configure $inner c* r* -resize none
     1912    blt::table configure $inner c* -resize none
    19241913    blt::table configure $inner c2 -resize expand
    19251914    blt::table configure $inner r$row -resize expand
     
    19271916
    19281917#
    1929 #  camera -- 
     1918#  camera --
    19301919#
    19311920itcl::body Rappture::VtkImageViewer::camera {option args} {
    1932     switch -- $option { 
     1921    switch -- $option {
    19331922        "show" {
    19341923            puts [array get _view]
    19351924        }
    19361925        "set" {
    1937             set who [lindex $args 0]
    1938             set x $_view($who)
     1926            set what [lindex $args 0]
     1927            set x $_view($what)
    19391928            set code [catch { string is double $x } result]
    19401929            if { $code != 0 || !$result } {
    19411930                return
    19421931            }
    1943             switch -- $who {
    1944                 "ortho" {
    1945                     if {$_view(ortho)} {
     1932            switch -- $what {
     1933                "-ortho" {
     1934                    if {$_view($what)} {
    19461935                        SendCmd "camera mode ortho"
    19471936                    } else {
     
    19491938                    }
    19501939                }
    1951                 "xpan" - "ypan" {
     1940                "-xpan" - "-ypan" {
    19521941                    PanCamera
    19531942                }
    1954                 "qx" - "qy" - "qz" - "qw" {
    1955                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1943                "-qx" - "-qy" - "-qz" - "-qw" {
     1944                    set q [ViewToQuaternion]
    19561945                    $_arcball quaternion $q
    19571946                    EventuallyRotate $q
    19581947                }
    1959                 "zoom" {
    1960                     SendCmd "camera zoom $_view(zoom)"
     1948                "-zoom" {
     1949                    SendCmd "camera zoom $_view($what)"
    19611950                }
    19621951            }
     
    19781967
    19791968itcl::body Rappture::VtkImageViewer::GetImage { args } {
    1980     if { [image width $_image(download)] > 0 && 
     1969    if { [image width $_image(download)] > 0 &&
    19811970         [image height $_image(download)] > 0 } {
    19821971        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    19911980        -title "[Rappture::filexfer::label downloadWord] as..."
    19921981    set inner [$popup component inner]
    1993     label $inner.summary -text "" -anchor w 
     1982    label $inner.summary -text "" -anchor w
    19941983    radiobutton $inner.vtk_button -text "VTK data file" \
    19951984        -variable [itcl::scope _downloadPopup(format)] \
    19961985        -font "Arial 9 " \
    1997         -value vtk 
     1986        -value vtk
    19981987    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    19991988    radiobutton $inner.image_button -text "Image File" \
    20001989        -variable [itcl::scope _downloadPopup(format)] \
    20011990        -font "Arial 9 " \
    2002         -value image 
     1991        -value image
    20031992    Rappture::Tooltip::for $inner.image_button \
    20041993        "Save as digital image."
     
    20212010        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    20222011        4,1 $inner.cancel -width .9i -fill y \
    2023         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2012        4,0 $inner.ok -padx 2 -width .9i -fill y
    20242013    blt::table configure $inner r3 -height 4
    20252014    blt::table configure $inner r4 -pady 4
     
    20322021# SetObjectStyle --
    20332022#
    2034 #       Set the style of the image/contour object.  This gets calls 
     2023#       Set the style of the image/contour object.  This gets calls
    20352024#       for each dataset once as it is loaded.  It can overridden by
    20362025#       the user controls.
     
    20572046    # the code to handle aberrant cases.
    20582047
    2059     if { $_changed(opacity) } {
    2060         set style(-opacity) [expr $_settings(opacity) * 0.01]
    2061     }
    2062     if { $_changed(colormap) } {
    2063         set style(-color) $_settings(colormap)
     2048    if { $_changed(-opacity) } {
     2049        set style(-opacity) [expr $_settings(-opacity) * 0.01]
     2050    }
     2051    if { $_changed(-colormap) } {
     2052        set style(-color) $_settings(-colormap)
    20642053    }
    20652054    if { $_currentColormap == "" } {
     
    20672056    }
    20682057    if { [info exists style(-stretchtofit)] } {
    2069         set _settings(stretchToFit) $style(-stretchtofit)
    2070         AdjustSetting stretchToFit
     2058        set _settings(-stretchtofit) $style(-stretchtofit)
     2059        AdjustSetting -stretchToFit
    20712060    }
    20722061    SendCmd "outline add $tag"
    20732062    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
    2074     SendCmd "outline visible $_settings(outline) $tag"
     2063    SendCmd "outline visible $_settings(-outline) $tag"
    20752064    SendCmd "image add $tag"
    2076     SetCurrentColormap $style(-color) 
     2065    SetCurrentColormap $style(-color)
    20772066    set color [$itk_component(backingcolor) value]
    20782067    SendCmd "image color [Color2RGB $color] $tag"
    20792068    SendCmd "image opacity $style(-opacity) $tag"
    2080     set _settings(opacity) [expr $style(-opacity) * 100.0]
     2069    set _settings(-opacity) [expr $style(-opacity) * 100.0]
    20812070}
    20822071
     
    21052094        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    21062095        if { [catch {DrawLegend} errs] != 0 } {
    2107             global errorInfo
    2108             puts stderr "errs=$errs errorInfo=$errorInfo"
     2096            global errorInfo
     2097            puts stderr "errs=$errs errorInfo=$errorInfo"
    21092098        }
    21102099    }
     
    21232112    set font "Arial 8"
    21242113    set lineht [font metrics $font -linespace]
    2125    
     2114
    21262115    if { [string match "component*" $fname] } {
    2127         set title ""
     2116        set title ""
    21282117    } else {
    2129         if { [info exists _fields($fname)] } {
    2130             foreach { title units } $_fields($fname) break
    2131             if { $units != "" } {
    2132                 set title [format "%s (%s)" $title $units]
    2133             }
    2134         } else {
    2135             set title $fname
    2136         }
     2118        if { [info exists _fields($fname)] } {
     2119            foreach { title units } $_fields($fname) break
     2120            if { $units != "" } {
     2121                set title [format "%s (%s)" $title $units]
     2122            }
     2123        } else {
     2124            set title $fname
     2125        }
    21372126    }
    21382127    set x [expr $w - 2]
    2139     if { !$_settings(legendVisible) } {
    2140         $c delete legend
    2141         return
    2142     } 
     2128    if { !$_settings(-legendvisible) } {
     2129        $c delete legend
     2130        return
     2131    }
    21432132    if { [$c find withtag "legend"] == "" } {
    2144         set y 2
    2145         # If there's a legend title, create a text item for the title.
     2133        set y 2
     2134        # If there's a legend title, create a text item for the title.
    21462135        $c create text $x $y \
    2147             -anchor ne \
    2148             -fill $itk_option(-plotforeground) -tags "title legend" \
    2149             -font $font
     2136            -anchor ne \
     2137            -fill $itk_option(-plotforeground) -tags "title legend" \
     2138            -font $font
    21502139        if { $title != "" } {
    21512140            incr y $lineht
    21522141        }
    2153         $c create text $x $y \
    2154             -anchor ne \
    2155             -fill $itk_option(-plotforeground) -tags "vmax legend" \
    2156             -font $font
    2157         incr y $lineht
    2158         $c create image $x $y \
    2159             -anchor ne \
    2160             -image $_image(legend) -tags "colormap legend"
    2161         $c create rectangle $x $y 1 1 \
    2162             -fill "" -outline "" -tags "sensor legend"
    2163         $c create text $x [expr {$h-2}] \
    2164             -anchor se \
    2165             -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2166             -font $font
    2167         $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
    2168         $c bind sensor <Leave> [itcl::code $this LeaveLegend]
    2169         $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
     2142        $c create text $x $y \
     2143            -anchor ne \
     2144            -fill $itk_option(-plotforeground) -tags "vmax legend" \
     2145            -font $font
     2146        incr y $lineht
     2147        $c create image $x $y \
     2148            -anchor ne \
     2149            -image $_image(legend) -tags "colormap legend"
     2150        $c create rectangle $x $y 1 1 \
     2151            -fill "" -outline "" -tags "sensor legend"
     2152        $c create text $x [expr {$h-2}] \
     2153            -anchor se \
     2154            -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2155            -font $font
     2156        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
     2157        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2158        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
    21702159    }
    21712160
     
    21812170    if { [info exists _limits($_curFldName)] } {
    21822171        foreach { vmin vmax } $_limits($_curFldName) break
    2183         $c itemconfigure vmin -text [format %g $vmin]
    2184         $c itemconfigure vmax -text [format %g $vmax]
     2172        $c itemconfigure vmin -text [format %g $vmin]
     2173        $c itemconfigure vmax -text [format %g $vmax]
    21852174    }
    21862175    set y 2
     
    21882177    if { $title != "" } {
    21892178        $c itemconfigure title -text $title
    2190         $c coords title $x $y
    2191         incr y $lineht
     2179        $c coords title $x $y
     2180        incr y $lineht
    21922181    }
    21932182    $c coords vmax $x $y
     
    22372226    set font "Arial 8"
    22382227    set lineht [font metrics $font -linespace]
    2239    
     2228
    22402229    set ih [image height $_image(legend)]
    22412230    # Subtract off the offset of the color ramp from the top of the canvas
     
    22432232
    22442233    if { [string match "component*" $fname] } {
    2245         set title ""
     2234        set title ""
    22462235    } else {
    2247         if { [info exists _fields($fname)] } {
    2248             foreach { title units } $_fields($fname) break
    2249             if { $units != "" } {
    2250                 set title [format "%s (%s)" $title $units]
    2251             }
    2252         } else {
    2253             set title $fname
    2254         }
     2236        if { [info exists _fields($fname)] } {
     2237            foreach { title units } $_fields($fname) break
     2238            if { $units != "" } {
     2239                set title [format "%s (%s)" $title $units]
     2240            }
     2241        } else {
     2242            set title $fname
     2243        }
    22552244    }
    22562245    # If there's a legend title, increase the offset by the line height.
     
    22682257    }
    22692258    set color [eval format "\#%02x%02x%02x" $pixel]
    2270     $_image(swatch) put black  -to 0 0 23 23 
    2271     $_image(swatch) put $color -to 1 1 22 22 
     2259    $_image(swatch) put black  -to 0 0 23 23
     2260    $_image(swatch) put $color -to 1 1 22 22
    22722261
    22732262    # Compute the value of the point
     
    22792268        set value 0.0
    22802269    }
    2281     set tipx [expr $x + 15] 
     2270    set tipx [expr $x + 15]
    22822271    set tipy [expr $y - 5]
    22832272    .rappturetooltip configure -icon $_image(swatch)
     
    22872276        Rappture::Tooltip::text $c [format "$title %g" $value]
    22882277    }
    2289     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2278    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    22902279}
    22912280
     
    23022291# ----------------------------------------------------------------------
    23032292itcl::body Rappture::VtkImageViewer::Combo {option} {
    2304     set c $itk_component(view) 
     2293    set c $itk_component(view)
    23052294    switch -- $option {
    23062295        post {
     
    23152304        }
    23162305        deactivate {
    2317             $c itemconfigure title -fill $itk_option(-plotforeground) 
     2306            $c itemconfigure title -fill $itk_option(-plotforeground)
    23182307        }
    23192308        invoke {
    23202309            $itk_component(field) value $_curFldLabel
    2321             AdjustSetting field
     2310            AdjustSetting -field
    23222311        }
    23232312        default {
     
    23272316}
    23282317
    2329 itcl::body Rappture::VtkImageViewer::SetOrientation { side } { 
     2318itcl::body Rappture::VtkImageViewer::SetOrientation { side } {
    23302319    array set positions {
    23312320        front  "0.707107 0.707107 0 0"
     
    23362325        bottom "0 1 0 0"
    23372326    }
    2338     foreach name { qw qx qy qz } value $positions($side) {
     2327    foreach name { -qw -qx -qy -qz } value $positions($side) {
    23392328        set _view($name) $value
    2340     } 
    2341     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2329    }
     2330    set q [ViewToQuaternion]
    23422331    $_arcball quaternion $q
    23432332    SendCmd "camera orient $q"
    23442333    SendCmd "camera reset"
    2345     set _view(xpan) 0
    2346     set _view(ypan) 0
    2347     set _view(zoom) 1.0
    2348 }
     2334    set _view(-xpan) 0
     2335    set _view(-ypan) 0
     2336    set _view(-zoom) 1.0
     2337}
Note: See TracChangeset for help on using the changeset viewer.