Changeset 5012 for branches/1.3


Ignore:
Timestamp:
Feb 12, 2015, 12:51:16 PM (10 years ago)
Author:
ldelgass
Message:

Update heightmap viewer from trunk/1.4 version

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

    • Property svn:mergeinfo changed
      /trunkmerged: 5004
  • branches/1.3/gui/scripts/vtkheightmapviewer.tcl

    r4951 r5012  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkheightmapviewer - Vtk heightmap viewer
     
    77# ======================================================================
    88#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2004-2012  HUBzero Foundation, LLC
     9#  Copyright (c) 2004-2014  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 }
    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 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 
    8465    # The following methods are only used by this class.
     66    private method AdjustSetting {what {value ""}}
    8567    private method BuildAxisTab {}
    8668    private method BuildCameraTab {}
    8769    private method BuildColormap { name }
    8870    private method BuildContourTab {}
    89     private method BuildDownloadPopup { widget command }
     71    private method BuildDownloadPopup { widget command }
     72    private method CameraReset {}
    9073    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 {}
    9179    private method DrawLegend {}
    92     private method EnterLegend { x y }
    93     private method EventuallyRequestLegend {}
    94     private method EventuallyResize { w h }
    95     private method EventuallyRotate { q }
    96     private method GetImage { args }
    97     private method GetVtkData { args }
    98     private method IsValidObject { dataobj }
     80    private method EnterLegend { x y }
     81    private method EventuallyRequestLegend {}
     82    private method EventuallyResize { w h }
     83    private method EventuallyRotate { q }
     84    private method GetHeightmapScale {}
     85    private method GetImage { args }
     86    private method GetVtkData { args }
     87    private method InitSettings { args  }
     88    private method IsValidObject { dataobj }
    9989    private method LeaveLegend {}
    100     private method MotionLegend { x y }
     90    private method MotionLegend { x y }
     91    private method Pan {option x y}
    10192    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 }
    102101    private method RequestLegend {}
     102    private method ResetAxes {}
     103    private method Rotate {option x y}
    103104    private method SetCurrentColormap { color }
    104105    private method SetLegendTip { x y }
    105     private method SetObjectStyle { dataobj comp }
    106     private method GetHeightmapScale {}
    107     private method ResetAxes {}
     106    private method SetObjectStyle { dataobj comp }
    108107    private method SetOrientation { side }
    109108    private method UpdateContourList {}
     109    private method ViewToQuaternion {} {
     110        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     111    }
     112    private method Zoom {option}
    110113
    111114    private variable _arcball ""
     
    113116    private variable _obj2datasets
    114117    private variable _obj2ovride   ;    # maps dataobj => style override
    115     private variable _comp2scale;       # maps dataset to the heightmap scale.
    116     private variable _datasets     ;    # contains all the dataobj-component 
     118    private variable _comp2scale;       # maps dataset to the heightmap scale.
     119    private variable _datasets     ;    # contains all the dataobj-component
    117120                                   ;    # datasets in the server
    118121    private variable _colormaps    ;    # contains all the colormaps
     
    123126    private variable _currentColormap ""
    124127    private variable _currentNumIsolines -1
    125     private variable _currentOpacity ""
    126128
    127129    private variable _maxScale 100;     # This is the # of times the x-axis
     
    131133
    132134    private variable _click        ;    # info used for rotate operations
    133     private variable _limits       ;    # Holds overall limits for all dataobjs 
     135    private variable _limits       ;    # Holds overall limits for all dataobjs
    134136                                        # using the viewer.
    135137    private variable _view         ;    # view params for 3D view
     
    156158    private variable _rotatePending 0
    157159    private variable _legendPending 0
    158     private variable _fieldNames {} 
    159     private variable _fields 
     160    private variable _fieldNames {}
     161    private variable _fields
    160162    private variable _curFldName ""
    161163    private variable _curFldLabel ""
     
    203205    # Initialize the view to some default parameters.
    204206    array set _view {
    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
     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
    213215    }
    214216    set _arcball [blt::arcball create 100 100]
    215     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    216     $_arcball quaternion $q
     217    $_arcball quaternion [ViewToQuaternion]
    217218
    218219    array set _settings {
    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
     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
    244246    }
    245247    array set _changed {
    246         opacity                 0
    247         colormap                0
    248         numIsolines             0
     248        -colormap               0
     249        -numisolines            0
     250        -opacity                0
    249251    }
    250252    itk_component add view {
     
    253255    } {
    254256        usual
    255         ignore -highlightthickness -borderwidth -background 
     257        ignore -highlightthickness -borderwidth -background
    256258    }
    257259
     
    259261        menu $itk_component(plotarea).menu \
    260262            -relief flat \
    261             -tearoff no 
     263            -tearoff no
    262264    } {
    263265        usual
     
    279281
    280282    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    281     set _map(cwidth) -1 
    282     set _map(cheight) -1 
     283    set _map(cwidth) -1
     284    set _map(cheight) -1
    283285    set _map(zoom) 1.0
    284286    set _map(original) ""
     
    325327            -onimage [Rappture::icon surface] \
    326328            -offimage [Rappture::icon surface] \
    327             -variable [itcl::scope _settings(isHeightmap)] \
    328             -command [itcl::code $this AdjustSetting isHeightmap] \
     329            -variable [itcl::scope _settings(-isheightmap)] \
     330            -command [itcl::code $this AdjustSetting -isheightmap] \
    329331    }
    330332    Rappture::Tooltip::for $itk_component(mode) \
     
    336338            -onimage [Rappture::icon stretchtofit] \
    337339            -offimage [Rappture::icon stretchtofit] \
    338             -variable [itcl::scope _settings(stretchToFit)] \
    339             -command [itcl::code $this AdjustSetting stretchToFit] \
     340            -variable [itcl::scope _settings(-stretchtofit)] \
     341            -command [itcl::code $this AdjustSetting -stretchtofit] \
    340342    }
    341343    Rappture::Tooltip::for $itk_component(stretchtofit) \
     
    348350        BuildCameraTab
    349351    } errs] != 0 } {
    350         global errorInfo
     352        global errorInfo
    351353        puts stderr "errs=$errs errorInfo=$errorInfo"
    352354    }
    353355
    354     # Hack around the Tk panewindow.  The problem is that the requested 
     356    # Hack around the Tk panewindow.  The problem is that the requested
    355357    # size of the 3d view isn't set until an image is retrieved from
    356358    # the server.  So the panewindow uses the tiny size.
     
    358360    pack forget $itk_component(view)
    359361    blt::table $itk_component(plotarea) \
    360         0,0 $itk_component(view) -fill both -reqwidth $w 
     362        0,0 $itk_component(view) -fill both -reqwidth $w
    361363    blt::table configure $itk_component(plotarea) c1 -resize none
    362364
     
    442444
    443445itcl::body Rappture::VtkHeightmapViewer::DoRotate {} {
    444     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    445     SendCmd "camera orient $q"
     446    SendCmd "camera orient [ViewToQuaternion]"
    446447    set _rotatePending 0
    447448}
     
    467468
    468469itcl::body Rappture::VtkHeightmapViewer::EventuallyRotate { q } {
    469     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     470    QuaternionToView $q
    470471    if { !$_rotatePending } {
    471472        set _rotatePending 1
    472         global rotate_delay 
     473        global rotate_delay
    473474        $_dispatcher event -after $rotate_delay !rotate
    474475    }
     
    569570                    continue
    570571                }
    571                 if {[info exists _obj2ovride($dataobj-raise)] && 
     572                if {[info exists _obj2ovride($dataobj-raise)] &&
    572573                    $_obj2ovride($dataobj-raise)} {
    573574                    set dlist [linsert $dlist 0 $dataobj]
     
    597598            }
    598599            return $dlist
    599         }           
     600        }
    600601        -image {
    601602            if {[llength $args] != 2} {
     
    617618}
    618619
    619 # 
     620#
    620621# scale  --
    621622#
    622623#       This gets called either incrementally as new simulations are
    623624#       added or all at once as a sequence of heightmaps.
    624 #       This  accounts for all objects--even those not showing on the 
    625 #       screen.  Because of this, the limits are appropriate for all 
     625#       This  accounts for all objects--even those not showing on the
     626#       screen.  Because of this, the limits are appropriate for all
    626627#       objects as the user scans through data in the ResultSet viewer.
    627628#
     
    666667    }
    667668    if { [array size found] > 1 } {
    668         set _settings(stretchToFit) 1
     669        set _settings(-stretchtofit) 1
    669670    } else {
    670671        # Check if the range of the x and y axes requires that we stretch
     
    675676        if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) ||
    676677             ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } {
    677             set _settings(stretchToFit) 1
     678            set _settings(-stretchtofit) 1
    678679        }
    679680    }
     
    815816    $_dispatcher cancel !legend
    816817    # disconnected -- no more data sitting on server
    817     array unset _datasets 
    818     array unset _data 
    819     array unset _colormaps 
    820     array unset _obj2datasets 
     818    array unset _datasets
     819    array unset _data
     820    array unset _colormaps
     821    array unset _obj2datasets
    821822    global readyForNextFrame
    822823    set readyForNextFrame 1
     
    842843    if { $info(-type) == "image" } {
    843844        if 0 {
    844             set f [open "last.ppm" "w"]
    845             puts $f $bytes
     845            set f [open "last.ppm" "w"]
     846            fconfigure $f -encoding binary
     847            puts -nonewline $f $bytes
    846848            close $f
    847849        }
     
    849851        set time [clock seconds]
    850852        set date [clock format $time]
    851         #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
     853        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
    852854        if { $_start > 0 } {
    853855            set finish [clock clicks -milliseconds]
     
    920922    # Turn on buffering of commands to the server.  We don't want to
    921923    # be preempted by a server disconnect/reconnect (which automatically
    922     # generates a new call to Rebuild).   
     924    # generates a new call to Rebuild).
    923925    StartBufferingCommands
    924926
    925927    if { $_width != $w || $_height != $h || $_reset } {
    926         set _width $w
    927         set _height $h
    928         $_arcball resize $w $h
    929         DoResize
    930         if { $_settings(stretchToFit) } {
    931             AdjustSetting stretchToFit
    932         }
     928        set _width $w
     929        set _height $h
     930        $_arcball resize $w $h
     931        DoResize
     932        if { $_settings(-stretchtofit) } {
     933            AdjustSetting -stretchtofit
     934        }
    933935    }
    934936    if { $_reset } {
    935         #
    936         # Reset the camera and other view parameters
    937         #
    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"
    943 
    944         SendCmd "axis lrot z 90"
    945         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    946         $_arcball quaternion $q
    947         if {$_settings(isHeightmap) } {
    948             if { $_view(ortho)} {
     937        #
     938        # Reset the camera and other view parameters
     939        #
     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"
     952
     953        SendCmd "axis lrot z 90"
     954        $_arcball quaternion [ViewToQuaternion]
     955        if {$_settings(-isheightmap) } {
     956            if { $_view(-ortho)} {
    949957                SendCmd "camera mode ortho"
    950958            } else {
     
    953961            DoRotate
    954962            SendCmd "camera reset"
    955         }
    956         PanCamera
     963        }
     964        PanCamera
    957965        StopBufferingCommands
    958966        SendCmd "imgflush"
     
    973981            if { ![info exists _datasets($tag)] } {
    974982                set bytes [$dataobj vtkdata $comp]
    975                 if 0 {
     983                if 0 {
    976984                    set f [open /tmp/vtkheightmap.vtk "w"]
    977                     puts $f $bytes
     985                    fconfigure $f -translation binary -encoding binary
     986                    puts -nonewline $f $bytes
    978987                    close $f
    979                 }
     988                }
    980989                set length [string length $bytes]
    981990                if { $_reportClientInfo }  {
     
    989998                    lappend info "dataset_size"  $length
    990999                    lappend info "dataset_tag"   $tag
    991                     SendCmd [list "clientinfo" $info]
     1000                    SendCmd "clientinfo [list $info]"
    9921001                }
    9931002                SendCmd "dataset add $tag data follows $length"
     
    10021011                SendCmd "dataset visible 1 $tag"
    10031012            }
    1004             if { ![info exists _comp2scale($tag)] ||
    1005                 $_comp2scale($tag) != $scale } {
    1006                 SendCmd "heightmap heightscale $scale $tag"
    1007                 set _comp2scale($tag) $scale
    1008             }
     1013            if { ![info exists _comp2scale($tag)] ||
     1014                $_comp2scale($tag) != $scale } {
     1015                SendCmd "heightmap heightscale $scale $tag"
     1016                set _comp2scale($tag) $scale
     1017            }
    10091018        }
    10101019    }
    10111020    if { $_first != ""  } {
    1012         $itk_component(field) choices delete 0 end
    1013         $itk_component(fieldmenu) delete 0 end
    1014         array unset _fields
     1021        $itk_component(field) choices delete 0 end
     1022        $itk_component(fieldmenu) delete 0 end
     1023        array unset _fields
    10151024        set _curFldName ""
    10161025        foreach cname [$_first components] {
     
    10381047        $itk_component(field) value $_curFldLabel
    10391048    }
    1040     InitSettings stretchToFit outline
     1049    InitSettings -stretchtofit -outline
    10411050
    10421051    if { $_reset } {
    1043         SendCmd "axis tickpos outside"
    1044         foreach axis { x y z } {
    1045             SendCmd "axis lformat $axis %g"
    1046         }
    1047        
    1048         foreach axis { x y z } {
     1052        SendCmd "axis tickpos outside"
     1053        #SendCmd "axis lformat all %g"
     1054
     1055        foreach axis { x y z } {
    10491056            if { $axis == "z" } {
    10501057                set label [$_first hints label]
     
    10521059                set label [$_first hints ${axis}label]
    10531060            }
    1054             if { $label == "" } {
    1055                 if {$axis == "z"} {
     1061            if { $label == "" } {
     1062                if {$axis == "z"} {
    10561063                    if { [string match "component*" $_curFldName] } {
    10571064                        set label [string toupper $axis]
     
    10591066                        set label $_curFldLabel
    10601067                    }
    1061                 } else {
    1062                     set label [string toupper $axis]
    1063                 }
    1064             }
    1065             # May be a space in the axis label.
    1066             SendCmd [list axis name $axis $label]
    1067 
    1068             if {$axis == "z" && [$_first hints ${axis}units] == ""} {
    1069                 set units [lindex $_fields($_curFldName) 1]
    1070             } else {
    1071                 set units [$_first hints ${axis}units]
    1072             }
    1073             if { $units != "" } {
    1074                 # May be a space in the axis units.
    1075                 SendCmd [list axis units $axis $units]
    1076             }
    1077         }
    1078         #
    1079         # Reset the camera and other view parameters
    1080         #
    1081         ResetAxes
    1082         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1083         $_arcball quaternion $q
    1084         if {$_settings(isHeightmap) } {
    1085             if { $_view(ortho)} {
     1068                } else {
     1069                    set label [string toupper $axis]
     1070                }
     1071            }
     1072            # May be a space in the axis label.
     1073            SendCmd [list axis name $axis $label]
     1074
     1075            set units ""
     1076            if {$axis == "z" && [$_first hints ${axis}units] == ""} {
     1077                if {$_curFldName != ""} {
     1078                    set units [lindex $_fields($_curFldName) 1]
     1079                }
     1080            } else {
     1081                set units [$_first hints ${axis}units]
     1082            }
     1083            if { $units != "" } {
     1084                # May be a space in the axis units.
     1085                SendCmd [list axis units $axis $units]
     1086            }
     1087        }
     1088        #
     1089        # Reset the camera and other view parameters
     1090        #
     1091        ResetAxes
     1092        $_arcball quaternion [ViewToQuaternion]
     1093        if {$_settings(-isheightmap) } {
     1094            if { $_view(-ortho)} {
    10861095                SendCmd "camera mode ortho"
    10871096            } else {
     
    10911100            SendCmd "camera reset"
    10921101        }
    1093         PanCamera
    1094         InitSettings axisXGrid axisYGrid axisZGrid \
    1095             axisVisible axisLabels heightmapScale field isHeightmap \
    1096             numIsolines
     1102        PanCamera
     1103        InitSettings -xgrid -ygrid -zgrid \
     1104            -axisvisible -axislabels -heightmapscale -field -isheightmap \
     1105            -numisolines
    10971106        if { [array size _fields] < 2 } {
    10981107            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
     
    11021111    }
    11031112    global readyForNextFrame
    1104     set readyForNextFrame 0;            # Don't advance to the next frame
     1113    set readyForNextFrame 0;                # Don't advance to the next frame
    11051114
    11061115    # Actually write the commands to the server socket.  If it fails, we don't
     
    11201129itcl::body Rappture::VtkHeightmapViewer::CurrentDatasets {args} {
    11211130    set flag [lindex $args 0]
    1122     switch -- $flag { 
     1131    switch -- $flag {
    11231132        "-all" {
    11241133            if { [llength $args] > 1 } {
     
    11391148                set dlist [get -visible]
    11401149            }
    1141         }           
     1150        }
    11421151        default {
    11431152            set dlist $args
     
    11581167itcl::body Rappture::VtkHeightmapViewer::CameraReset {} {
    11591168    array set _view {
    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
     1169        -qw      0.36
     1170        -qx      0.25
     1171        -qy      0.50
     1172        -qz      0.70
     1173        -xpan    0
     1174        -ypan    0
     1175        -zoom    1.0
    11671176    }
    11681177    if { $_first != "" } {
     
    11721181        }
    11731182    }
    1174     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1175     $_arcball quaternion $q
    1176     if {$_settings(isHeightmap) } {
     1183    $_arcball quaternion [ViewToQuaternion]
     1184    if {$_settings(-isheightmap) } {
    11771185        DoRotate
    11781186    }
     
    11911199    switch -- $option {
    11921200        "in" {
    1193             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1194             SendCmd "camera zoom $_view(zoom)"
     1201            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1202            SendCmd "camera zoom $_view(-zoom)"
    11951203        }
    11961204        "out" {
    1197             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1198             SendCmd "camera zoom $_view(zoom)"
     1205            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1206            SendCmd "camera zoom $_view(-zoom)"
    11991207        }
    12001208        "reset" {
    12011209            array set _view {
    1202                 zoom    1.0
    1203                 xpan    0
    1204                 ypan    0
     1210                -xpan    0
     1211                -ypan    0
     1212                -zoom    1.0
    12051213            }
    12061214            SendCmd "camera reset"
     
    12101218
    12111219itcl::body Rappture::VtkHeightmapViewer::PanCamera {} {
    1212     set x $_view(xpan)
    1213     set y $_view(ypan)
     1220    set x $_view(-xpan)
     1221    set y $_view(-ypan)
    12141222    SendCmd "camera pan $x $y"
    12151223}
     
    12711279    foreach tag [CurrentDatasets -visible] {
    12721280        SendCmd "dataset getscalar pixel $x $y $tag"
    1273     } 
     1281    }
    12741282}
    12751283
     
    12891297            set x [expr $x / double($w)]
    12901298            set y [expr $y / double($h)]
    1291             set _view(xpan) [expr $_view(xpan) + $x]
    1292             set _view(ypan) [expr $_view(ypan) + $y]
     1299            set _view(-xpan) [expr $_view(-xpan) + $x]
     1300            set _view(-ypan) [expr $_view(-ypan) + $y]
    12931301            PanCamera
    12941302            return
     
    13121320            set _click(x) $x
    13131321            set _click(y) $y
    1314             set _view(xpan) [expr $_view(xpan) - $dx]
    1315             set _view(ypan) [expr $_view(ypan) - $dy]
     1322            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1323            set _view(-ypan) [expr $_view(-ypan) - $dy]
    13161324            PanCamera
    13171325        }
     
    13351343itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } {
    13361344    foreach spec $args {
    1337         if { [info exists _settings($_first-$spec)] } {
     1345        if { [info exists _settings($_first${spec})] } {
    13381346            # Reset global setting with dataobj specific setting
    1339             set _settings($spec) $_settings($_first-$spec)
     1347            set _settings($spec) $_settings($_first${spec})
    13401348        }
    13411349        AdjustSetting $spec
     
    13551363    }
    13561364    switch -- $what {
    1357         "axisFlymode" {
     1365        "-axisflymode" {
    13581366            set mode [$itk_component(axisflymode) value]
    13591367            set mode [$itk_component(axisflymode) translate $mode]
     
    13611369            SendCmd "axis flymode $mode"
    13621370        }
    1363         "axisLabels" {
    1364             set bool $_settings(axisLabels)
     1371        "-axislabels" {
     1372            set bool $_settings($what)
    13651373            SendCmd "axis labels all $bool"
    13661374        }
    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        "-axisminorticks" {
     1376            set bool $_settings($what)
     1377            SendCmd "axis minticks all $bool"
     1378        }
     1379        "-axisvisible" {
     1380            set bool $_settings($what)
    13751381            SendCmd "axis visible all $bool"
    13761382        }
    1377         "axisXGrid" - "axisYGrid" - "axisZGrid" {
    1378             set axis [string tolower [string range $what 4 4]]
    1379             set bool $_settings($what)
    1380             SendCmd "axis grid $axis $bool"
    1381         }
    1382         "background" {
     1383        "-background" {
    13831384            set bg [$itk_component(background) value]
    1384             array set fgcolors {
    1385                 "black" "white"
    1386                 "white" "black"
    1387                 "grey"  "black"
    1388             }
     1385            array set fgcolors {
     1386                "black" "white"
     1387                "white" "black"
     1388                "grey"  "black"
     1389            }
    13891390            set fg $fgcolors($bg)
    13901391            configure -plotbackground $bg -plotforeground $fg
    1391             $itk_component(view) delete "legend"
     1392            $itk_component(view) delete "legend"
    13921393            SendCmd "screen bgcolor [Color2RGB $bg]"
    13931394            SendCmd "outline color [Color2RGB $fg]"
    13941395            SendCmd "axis color all [Color2RGB $fg]"
    1395             DrawLegend
    1396         }
    1397         "colormap" {
    1398             set _changed(colormap) 1
     1396            DrawLegend
     1397        }
     1398        "-colormap" {
     1399            set _changed($what) 1
    13991400            StartBufferingCommands
    14001401            set color [$itk_component(colormap) value]
    1401             set _settings(colormap) $color
    1402             if { $color == "none" } {
    1403                 if { $_settings(colormapVisible) } {
    1404                     SendCmd "heightmap surface 0"
    1405                     set _settings(colormapVisible) 0
    1406                 }
    1407             } else {
    1408                 if { !$_settings(colormapVisible) } {
    1409                     SendCmd "heightmap surface 1"
    1410                     set _settings(colormapVisible) 1
    1411                 }
    1412                 SetCurrentColormap $color
    1413                 if {$_settings(colormapDiscrete)} {
    1414                     set numColors [expr $_settings(numIsolines) + 1]
     1402            set _settings($what) $color
     1403            if { $color == "none" } {
     1404                if { $_settings(-colormapvisible) } {
     1405                    SendCmd "heightmap surface 0"
     1406                    set _settings(-colormapvisible) 0
     1407                }
     1408            } else {
     1409                if { !$_settings(-colormapvisible) } {
     1410                    SendCmd "heightmap surface 1"
     1411                    set _settings(-colormapvisible) 1
     1412                }
     1413                SetCurrentColormap $color
     1414                if {$_settings(-colormapdiscrete)} {
     1415                    set numColors [expr $_settings(-numisolines) + 1]
    14151416                    SendCmd "colormap res $numColors $color"
    14161417                }
    1417             }
     1418            }
    14181419            StopBufferingCommands
    1419             EventuallyRequestLegend
    1420         }
    1421         "colormapVisible" {
     1420            EventuallyRequestLegend
     1421        }
     1422        "-colormapvisible" {
    14221423            set bool $_settings($what)
    14231424            SendCmd "heightmap surface $bool"
    14241425        }
    1425         "colormapDiscrete" {
     1426        "-colormapdiscrete" {
    14261427            set bool $_settings($what)
    1427             set numColors [expr $_settings(numIsolines) + 1]
     1428            set numColors [expr $_settings(-numisolines) + 1]
    14281429            StartBufferingCommands
    14291430            if {$bool} {
     
    14391440            EventuallyRequestLegend
    14401441        }
    1441         "edges" {
    1442             set bool $_settings(edges)
     1442        "-edges" {
     1443            set bool $_settings($what)
    14431444            SendCmd "heightmap edges $bool"
    14441445        }
    1445         "field" {
     1446        "-field" {
    14461447            set label [$itk_component(field) value]
    14471448            set fname [$itk_component(field) translate $label]
    1448             set _settings(field) $fname
     1449            set _settings($what) $fname
    14491450            if { [info exists _fields($fname)] } {
    14501451                foreach { label units components } $_fields($fname) break
     
    14601461                return
    14611462            }
    1462             set label [$_first hints label]
    1463             if { $label == "" } {
     1463            set label [$_first hints label]
     1464            if { $label == "" } {
    14641465                if { [string match "component*" $_curFldName] } {
    14651466                    set label Z
     
    14671468                    set label $_curFldLabel
    14681469                }
    1469             }
    1470             # May be a space in the axis label.
    1471             SendCmd [list axis name z $label]
    1472 
    1473             if { [$_first hints zunits] == "" } {
    1474                 set units [lindex $_fields($_curFldName) 1]
    1475             } else {
    1476                 set units [$_first hints zunits]
    1477             }
    1478             if { $units != "" } {
    1479                 # May be a space in the axis units.
    1480                 SendCmd [list axis units z $units]
    1481             }
     1470            }
     1471            # May be a space in the axis label.
     1472            SendCmd [list axis name z $label]
     1473
     1474            if { [$_first hints zunits] == "" } {
     1475                set units [lindex $_fields($_curFldName) 1]
     1476            } else {
     1477                set units [$_first hints zunits]
     1478            }
     1479            if { $units != "" } {
     1480                # May be a space in the axis units.
     1481                SendCmd [list axis units z $units]
     1482            }
    14821483            # Get the new limits because the field changed.
    14831484            ResetAxes
     
    14881489            DrawLegend
    14891490        }
    1490         "heightmapScale" {
    1491             if { $_settings(isHeightmap) } {
    1492                 set scale [GetHeightmapScale]
    1493                 # Have to set the datasets individually because we are 
     1491        "-heightmapscale" {
     1492            if { $_settings(-isheightmap) } {
     1493                set scale [GetHeightmapScale]
     1494                # Have to set the datasets individually because we are
    14941495                # tracking them in _comp2scale.
    14951496                foreach dataset [CurrentDatasets -all] {
    1496                     SendCmd "heightmap heightscale $scale $dataset"
    1497                     set _comp2scale($dataset) $scale
    1498                 }
    1499                 ResetAxes
    1500             }
    1501         }
    1502         "isHeightmap" {
    1503             set bool $_settings(isHeightmap)
     1497                    SendCmd "heightmap heightscale $scale $dataset"
     1498                    set _comp2scale($dataset) $scale
     1499                }
     1500                ResetAxes
     1501            }
     1502        }
     1503        "-isheightmap" {
     1504            set bool $_settings($what)
    15041505            set c $itk_component(view)
    15051506            StartBufferingCommands
    15061507            # Fix heightmap scale: 0 for contours, 1 for heightmaps.
    15071508            if { $bool } {
    1508                 set _settings(heightmapScale) 50
    1509                 set _settings(opacity) $_settings(saveOpacity)
    1510                 set _settings(lighting) $_settings(saveLighting)
    1511                 set _settings(outline) 0
     1509                set _settings(-heightmapscale) 50
     1510                set _settings(-opacity) $_settings(-saveopacity)
     1511                set _settings(-lighting) $_settings(-savelighting)
     1512                set _settings(-outline) 0
    15121513            } else {
    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
     1514                set _settings(-heightmapscale) 0
     1515                set _settings(-lighting) 0
     1516                set _settings(-opacity) 100
     1517                set _settings(-outline)  $_settings(-saveoutline)
     1518            }
     1519            InitSettings -lighting -opacity -outline
    15211520            set scale [GetHeightmapScale]
    1522             # Have to set the datasets individually because we are 
     1521            # Have to set the datasets individually because we are
    15231522            # tracking them in _comp2scale.
    15241523            foreach dataset [CurrentDatasets -all] {
     
    15261525                set _comp2scale($dataset) $scale
    15271526            }
    1528             if { $bool } {
    1529                 $itk_component(lighting) configure -state normal
    1530                 $itk_component(opacity) configure -state normal
    1531                 $itk_component(scale) configure -state normal
    1532                 $itk_component(opacity_l) configure -state normal
    1533                 $itk_component(scale_l) configure -state normal
    1534                 $itk_component(outline) configure -state disabled
    1535                 if {$_view(ortho)} {
     1527            if { $bool } {
     1528                $itk_component(lighting) configure -state normal
     1529                $itk_component(opacity) configure -state normal
     1530                $itk_component(scale) configure -state normal
     1531                $itk_component(opacity_l) configure -state normal
     1532                $itk_component(scale_l) configure -state normal
     1533                $itk_component(outline) configure -state disabled
     1534                if {$_view(-ortho)} {
    15361535                    SendCmd "camera mode ortho"
    15371536                } else {
    15381537                    SendCmd "camera mode persp"
    15391538                }
    1540             } else {
    1541                 $itk_component(lighting) configure -state disabled
    1542                 $itk_component(opacity) configure -state disabled
    1543                 $itk_component(scale) configure -state disabled
    1544                 $itk_component(opacity_l) configure -state disabled
    1545                 $itk_component(scale_l) configure -state disabled
    1546                 $itk_component(outline) configure -state normal
     1539            } else {
     1540                $itk_component(lighting) configure -state disabled
     1541                $itk_component(opacity) configure -state disabled
     1542                $itk_component(scale) configure -state disabled
     1543                $itk_component(opacity_l) configure -state disabled
     1544                $itk_component(scale_l) configure -state disabled
     1545                $itk_component(outline) configure -state normal
    15471546                SendCmd "camera mode image"
    15481547            }
    1549             if {$_settings(stretchToFit)} {
     1548            if {$_settings(-stretchtofit)} {
    15501549                if {$scale == 0} {
    15511550                    SendCmd "camera aspect window"
     
    15561555            ResetAxes
    15571556            if { $bool } {
    1558                 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1557                set q [ViewToQuaternion]
    15591558                $_arcball quaternion $q
    1560                 SendCmd "camera orient $q" 
     1559                SendCmd "camera orient $q"
    15611560            } else {
    15621561                bind $c <ButtonPress-1> {}
     
    15651564            }
    15661565            Zoom reset
    1567             # Fix the mouse bindings for rotation/panning and the 
     1566            # Fix the mouse bindings for rotation/panning and the
    15681567            # camera mode. Ideally we'd create a bindtag for these.
    15691568            if { $bool } {
     
    15781577            StopBufferingCommands
    15791578        }
    1580         "isolineColor" {
     1579        "-isolinecolor" {
    15811580            set color [$itk_component(isolinecolor) value]
    1582             if { $color == "none" } {
    1583                 if { $_settings(isolinesVisible) } {
    1584                     SendCmd "heightmap isolines 0"
    1585                     set _settings(isolinesVisible) 0
    1586                 }
    1587             } else {
    1588                 if { !$_settings(isolinesVisible) } {
    1589                     SendCmd "heightmap isolines 1"
    1590                     set _settings(isolinesVisible) 1
    1591                 }
    1592                 SendCmd "heightmap isolinecolor [Color2RGB $color]"
    1593             }
    1594             DrawLegend
    1595         }
    1596         "isolinesVisible" {
    1597             set bool $_settings($what)
     1581            if { $color == "none" } {
     1582                if { $_settings(-isolinesvisible) } {
     1583                    SendCmd "heightmap isolines 0"
     1584                    set _settings(-isolinesvisible) 0
     1585                }
     1586            } else {
     1587                if { !$_settings(-isolinesvisible) } {
     1588                    SendCmd "heightmap isolines 1"
     1589                    set _settings(-isolinesvisible) 1
     1590                }
     1591                SendCmd "heightmap isolinecolor [Color2RGB $color]"
     1592            }
     1593            DrawLegend
     1594        }
     1595        "-isolinesvisible" {
     1596            set bool $_settings($what)
    15981597            SendCmd "heightmap isolines $bool"
    1599             DrawLegend
    1600         }
    1601         "legendVisible" {
     1598            DrawLegend
     1599        }
     1600        "-legendvisible" {
    16021601            if { !$_settings($what) } {
    1603                 $itk_component(view) delete legend
    1604             }
    1605             DrawLegend
    1606         }
    1607         "lighting" {
    1608             if { $_settings(isHeightmap) } {
    1609                 set _settings(saveLighting) $_settings(lighting)
    1610                 set bool $_settings($what)
    1611                 SendCmd "heightmap lighting $bool"
    1612             } else {
    1613                 SendCmd "heightmap lighting 0"
    1614             }
    1615         }
    1616         "numIsolines" {
    1617             set _settings(numIsolines) [$itk_component(numisolines) value]
    1618             set _currentNumIsolines $_settings(numIsolines)
     1602                $itk_component(view) delete legend
     1603            }
     1604            DrawLegend
     1605        }
     1606        "-lighting" {
     1607            if { $_settings(-isheightmap) } {
     1608                set _settings(-savelighting) $_settings($what)
     1609                set bool $_settings($what)
     1610                SendCmd "heightmap lighting $bool"
     1611            } else {
     1612                SendCmd "heightmap lighting 0"
     1613            }
     1614        }
     1615        "-numisolines" {
     1616            set _settings($what) [$itk_component(numisolines) value]
     1617            set _currentNumIsolines $_settings($what)
    16191618            UpdateContourList
    1620             set _changed(numIsolines) 1
     1619            set _changed($what) 1
    16211620            SendCmd "heightmap contourlist [list $_contourList]"
    1622             if {$_settings(colormapDiscrete)} {
    1623                 set numColors [expr $_settings(numIsolines) + 1]
     1621            if {$_settings(-colormapdiscrete)} {
     1622                set numColors [expr $_settings($what) + 1]
    16241623                SendCmd "colormap res $numColors"
    16251624                EventuallyRequestLegend
     
    16281627            }
    16291628        }
    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"
     1629        "-opacity" {
     1630            set _changed($what) 1
     1631            set val [expr $_settings($what) * 0.01]
     1632            if { $_settings(-isheightmap) } {
     1633                set _settings(-saveopacity) $_settings($what)
     1634                SendCmd "heightmap opacity $val"
    16371635            } else {
    1638                 SendCmd "heightmap opacity 1"
    1639             }
    1640         }
    1641         "outline" {
    1642             if { $_settings(isHeightmap) } {
    1643                 SendCmd "outline visible 0"
     1636                SendCmd "heightmap opacity 1.0"
     1637            }
     1638        }
     1639        "-outline" {
     1640            if { $_settings(-isheightmap) } {
     1641                SendCmd "outline visible 0"
    16441642            } else {
    1645                 set _settings(saveOutline) $_settings(outline)
    1646                 set bool $_settings(outline)
     1643                set _settings(-saveoutline) $_settings($what)
     1644                set bool $_settings($what)
    16471645                SendCmd "outline visible $bool"
    16481646            }
    1649         }
    1650         "stretchToFit" {
    1651             set bool $_settings($what)
    1652             if { $bool } {
    1653                 set heightScale [GetHeightmapScale]
    1654                 if {$heightScale == 0} {
    1655                     SendCmd "camera aspect window"
    1656                 } else {
    1657                     SendCmd "camera aspect square"
    1658                 }
    1659             } else {
    1660                 SendCmd "camera aspect native"
    1661             }
     1647        }
     1648        "-stretchtofit" {
     1649            set bool $_settings($what)
     1650            if { $bool } {
     1651                set heightScale [GetHeightmapScale]
     1652                if {$heightScale == 0} {
     1653                    SendCmd "camera aspect window"
     1654                } else {
     1655                    SendCmd "camera aspect square"
     1656                }
     1657            } else {
     1658                SendCmd "camera aspect native"
     1659            }
    16621660            Zoom reset
    1663         }
    1664         "wireframe" {
     1661        }
     1662        "-wireframe" {
    16651663            set bool $_settings($what)
    16661664            SendCmd "heightmap wireframe $bool"
    16671665        }
    1668         default {
     1666        "-xgrid" - "-ygrid" - "-zgrid" {
     1667            set axis [string tolower [string range $what 1 1]]
     1668            set bool $_settings($what)
     1669            SendCmd "axis grid $axis $bool"
     1670        }
     1671        default {
    16691672            error "don't know how to fix $what"
    16701673        }
     
    16761679#
    16771680#       Request a new legend from the server.  The size of the legend
    1678 #       is determined from the height of the canvas. 
     1681#       is determined from the height of the canvas.
    16791682#
    16801683# This should be called when
    1681 #       1.  A new current colormap is set.
    1682 #       2.  Window is resized.
    1683 #       3.  The limits of the data have changed.  (Just need a redraw).
    1684 #       4.  Number of isolines have changed. (Just need a redraw).
    1685 #       5.  Legend becomes visible (Just need a redraw).
     1684#        1.  A new current colormap is set.
     1685#        2.  Window is resized.
     1686#        3.  The limits of the data have changed.  (Just need a redraw).
     1687#        4.  Number of isolines have changed. (Just need a redraw).
     1688#        5.  Legend becomes visible (Just need a redraw).
    16861689#
    16871690itcl::body Rappture::VtkHeightmapViewer::RequestLegend {} {
     
    16901693    set w 12
    16911694    set lineht [font metrics $font -linespace]
    1692     # color ramp height = (canvas height) - (min and max value lines) - 2 
     1695    # color ramp height = (canvas height) - (min and max value lines) - 2
    16931696    set h [expr {$_height - 2 * ($lineht + 2)}]
    16941697    set _legendHeight $h
     
    16961699    set fname $_curFldName
    16971700    if { [string match "component*" $fname] } {
    1698         set title ""
     1701        set title ""
    16991702    } else {
    1700         if { [info exists _fields($fname)] } {
    1701             foreach { title units } $_fields($fname) break
    1702             if { $units != "" } {
    1703                 set title [format "%s (%s)" $title $units]
    1704             }
    1705         } else {
    1706             set title $fname
    1707         }
     1703        if { [info exists _fields($fname)] } {
     1704            foreach { title units } $_fields($fname) break
     1705            if { $units != "" } {
     1706                set title [format "%s (%s)" $title $units]
     1707            }
     1708        } else {
     1709            set title $fname
     1710        }
    17081711    }
    17091712    # If there's a title too, substract one more line
    17101713    if { $title != "" } {
    1711         incr h -$lineht 
     1714        incr h -$lineht
    17121715    }
    17131716    if { $h < 1 } {
     
    17161719    # Set the legend on the first heightmap dataset.
    17171720    if { $_currentColormap != ""  } {
    1718         set cmap $_currentColormap
    1719         SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
     1721        set cmap $_currentColormap
     1722        #SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
     1723        SendCmd "legend2 $cmap $w $h"
    17201724    }
    17211725}
     
    17701774    # Keep track of the colormaps that we build.
    17711775    if { $name != "none" && ![info exists _colormaps($name)] } {
    1772         BuildColormap $name 
     1776        BuildColormap $name
    17731777        set _colormaps($name) 1
    17741778    }
     
    17761780    SendCmd "heightmap colormap $_currentColormap"
    17771781}
    1778 
    17791782
    17801783#
     
    17971800itcl::configbody Rappture::VtkHeightmapViewer::mode {
    17981801    switch -- $itk_option(-mode) {
    1799         "heightmap" {
    1800             set _settings(isHeightmap) 1
    1801         }
    1802         "contour" {
    1803             set _settings(isHeightmap) 0
    1804         }
    1805         default {
    1806             error "unknown mode settings \"$itk_option(-mode)\""
    1807         }
     1802        "heightmap" {
     1803            set _settings(-isheightmap) 1
     1804        }
     1805        "contour" {
     1806            set _settings(-isheightmap) 0
     1807        }
     1808        default {
     1809            error "unknown mode settings \"$itk_option(-mode)\""
     1810        }
    18081811    }
    18091812    if { !$_reset } {
    1810         AdjustSetting isHeightmap
     1813        AdjustSetting -isheightmap
    18111814    }
    18121815}
     
    18211824            SendCmd "screen bgcolor $rgb"
    18221825        }
    1823         $itk_component(view) configure -background $itk_option(-plotbackground)
     1826        $itk_component(view) configure -background $itk_option(-plotbackground)
    18241827    }
    18251828}
     
    18321835        set rgb [Color2RGB $itk_option(-plotforeground)]
    18331836        if { !$_reset } {
     1837            SendCmd "axis color all $rgb"
    18341838            SendCmd "outline color $rgb"
    1835             SendCmd "axis color all $rgb"
    1836         }
    1837     }
    1838 }
    1839 
    1840 itcl::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
     1839        }
     1840    }
    18481841}
    18491842
     
    18601853    checkbutton $inner.legend \
    18611854        -text "Legend" \
    1862         -variable [itcl::scope _settings(legendVisible)] \
    1863         -command [itcl::code $this AdjustSetting legendVisible] \
     1855        -variable [itcl::scope _settings(-legendvisible)] \
     1856        -command [itcl::code $this AdjustSetting -legendvisible] \
    18641857        -font "Arial 9"
    18651858
    18661859    checkbutton $inner.wireframe \
    18671860        -text "Wireframe" \
    1868         -variable [itcl::scope _settings(wireframe)] \
    1869         -command [itcl::code $this AdjustSetting wireframe] \
     1861        -variable [itcl::scope _settings(-wireframe)] \
     1862        -command [itcl::code $this AdjustSetting -wireframe] \
    18701863        -font "Arial 9"
    18711864
    18721865    itk_component add lighting {
    1873         checkbutton $inner.lighting \
    1874             -text "Enable Lighting" \
    1875             -variable [itcl::scope _settings(lighting)] \
    1876             -command [itcl::code $this AdjustSetting lighting] \
    1877             -font "Arial 9"
     1866        checkbutton $inner.lighting \
     1867            -text "Enable Lighting" \
     1868            -variable [itcl::scope _settings(-lighting)] \
     1869            -command [itcl::code $this AdjustSetting -lighting] \
     1870            -font "Arial 9"
    18781871    } {
    1879         ignore -font
     1872        ignore -font
    18801873    }
    18811874    checkbutton $inner.edges \
    18821875        -text "Edges" \
    1883         -variable [itcl::scope _settings(edges)] \
    1884         -command [itcl::code $this AdjustSetting edges] \
     1876        -variable [itcl::scope _settings(-edges)] \
     1877        -command [itcl::code $this AdjustSetting -edges] \
    18851878        -font "Arial 9"
    18861879
     
    18881881        checkbutton $inner.outline \
    18891882            -text "Outline" \
    1890             -variable [itcl::scope _settings(outline)] \
    1891             -command [itcl::code $this AdjustSetting outline] \
     1883            -variable [itcl::scope _settings(-outline)] \
     1884            -command [itcl::code $this AdjustSetting -outline] \
    18921885            -font "Arial 9"
    18931886    } {
     
    18961889    checkbutton $inner.stretch \
    18971890        -text "Stretch to fit" \
    1898         -variable [itcl::scope _settings(stretchToFit)] \
    1899         -command [itcl::code $this AdjustSetting stretchToFit] \
     1891        -variable [itcl::scope _settings(-stretchtofit)] \
     1892        -command [itcl::code $this AdjustSetting -stretchtofit] \
    19001893        -font "Arial 9"
    19011894
    19021895    checkbutton $inner.isolines \
    19031896        -text "Isolines" \
    1904         -variable [itcl::scope _settings(isolinesVisible)] \
    1905         -command [itcl::code $this AdjustSetting isolinesVisible] \
     1897        -variable [itcl::scope _settings(-isolinesvisible)] \
     1898        -command [itcl::code $this AdjustSetting -isolinesvisible] \
    19061899        -font "Arial 9"
    19071900
    19081901    checkbutton $inner.colormapDiscrete \
    19091902        -text "Discrete Colormap" \
    1910         -variable [itcl::scope _settings(colormapDiscrete)] \
    1911         -command [itcl::code $this AdjustSetting colormapDiscrete] \
     1903        -variable [itcl::scope _settings(-colormapdiscrete)] \
     1904        -command [itcl::code $this AdjustSetting -colormapdiscrete] \
    19121905        -font "Arial 9"
    19131906
    19141907    itk_component add field_l {
    1915         label $inner.field_l -text "Field" -font "Arial 9" 
     1908        label $inner.field_l -text "Field" -font "Arial 9"
    19161909    } {
    19171910        ignore -font
     
    19211914    }
    19221915    bind $inner.field <<Value>> \
    1923         [itcl::code $this AdjustSetting field]
    1924 
    1925     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     1916        [itcl::code $this AdjustSetting -field]
     1917
     1918    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    19261919    itk_component add colormap {
    19271920        Rappture::Combobox $inner.colormap -width 10 -editable no
    19281921    }
    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"
     1922    $inner.colormap choices insert end [GetColormapList -includeNone]
     1923    $itk_component(colormap) value $_settings(-colormap)
    19491924    bind $inner.colormap <<Value>> \
    1950         [itcl::code $this AdjustSetting colormap]
    1951 
    1952     label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9" 
     1925        [itcl::code $this AdjustSetting -colormap]
     1926
     1927    label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9"
    19531928    itk_component add isolinecolor {
    19541929        Rappture::Combobox $inner.isolinecolor -width 10 -editable no
     
    19641939        "red"                "red"              \
    19651940        "white"              "white"            \
    1966         "none"               "none"
    1967 
    1968     $itk_component(isolinecolor) value "black"
     1941        "none"               "none"
     1942
     1943    $itk_component(isolinecolor) value $_settings(-isolinecolor)
    19691944    bind $inner.isolinecolor <<Value>> \
    1970         [itcl::code $this AdjustSetting isolineColor]
    1971 
    1972     label $inner.background_l -text "Background Color" -font "Arial 9" 
     1945        [itcl::code $this AdjustSetting -isolinecolor]
     1946
     1947    label $inner.background_l -text "Background Color" -font "Arial 9"
    19731948    itk_component add background {
    19741949        Rappture::Combobox $inner.background -width 10 -editable no
     
    19771952        "black"              "black"            \
    19781953        "white"              "white"            \
    1979         "grey"               "grey"             
     1954        "grey"               "grey"
    19801955
    19811956    $itk_component(background) value "white"
    1982     bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]
     1957    bind $inner.background <<Value>> \
     1958        [itcl::code $this AdjustSetting -background]
    19831959
    19841960    itk_component add opacity_l {
     
    19891965    itk_component add opacity {
    19901966        ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1991             -variable [itcl::scope _settings(opacity)] \
     1967            -variable [itcl::scope _settings(-opacity)] \
    19921968            -showvalue off \
    1993             -command [itcl::code $this AdjustSetting opacity]
     1969            -command [itcl::code $this AdjustSetting -opacity]
    19941970    }
    19951971    itk_component add scale_l {
     
    20001976    itk_component add scale {
    20011977        ::scale $inner.scale -from 0 -to 100 -orient horizontal \
    2002             -variable [itcl::scope _settings(heightmapScale)] \
     1978            -variable [itcl::scope _settings(-heightmapscale)] \
    20031979            -showvalue off \
    2004             -command [itcl::code $this AdjustSetting heightmapScale]
     1980            -command [itcl::code $this AdjustSetting -heightmapscale]
    20051981    }
    20061982    label $inner.numisolines_l -text "Number of Isolines" -font "Arial 9"
     
    20091985            -min 0 -max 50 -font "arial 9"
    20101986    }
    2011     $itk_component(numisolines) value $_settings(numIsolines)
     1987    $itk_component(numisolines) value $_settings(-numisolines)
    20121988    bind $itk_component(numisolines) <<Value>> \
    2013         [itcl::code $this AdjustSetting numIsolines]
     1989        [itcl::code $this AdjustSetting -numisolines]
    20141990
    20151991    frame $inner.separator1 -height 2 -relief sunken -bd 1
     
    20231999        2,0 $inner.isolinecolor_l  -anchor w -pady 2  \
    20242000        2,1 $inner.isolinecolor    -anchor w -pady 2 -fill x  \
    2025         3,0 $inner.background_l -anchor w -pady 2 \
    2026         3,1 $inner.background -anchor w -pady 2  -fill x \
     2001        3,0 $inner.background_l -anchor w -pady 2 \
     2002        3,1 $inner.background -anchor w -pady 2  -fill x \
    20272003        4,0 $inner.numisolines_l -anchor w -pady 2 \
    20282004        4,1 $inner.numisolines -anchor w -pady 2 \
     
    20582034    checkbutton $inner.visible \
    20592035        -text "Axes" \
    2060         -variable [itcl::scope _settings(axisVisible)] \
    2061         -command [itcl::code $this AdjustSetting axisVisible] \
     2036        -variable [itcl::scope _settings(-axisvisible)] \
     2037        -command [itcl::code $this AdjustSetting -axisvisible] \
    20622038        -font "Arial 9"
    20632039    checkbutton $inner.labels \
    20642040        -text "Axis Labels" \
    2065         -variable [itcl::scope _settings(axisLabels)] \
    2066         -command [itcl::code $this AdjustSetting axisLabels] \
     2041        -variable [itcl::scope _settings(-axislabels)] \
     2042        -command [itcl::code $this AdjustSetting -axislabels] \
    20672043        -font "Arial 9"
    2068     label $inner.grid_l -text "Grid" -font "Arial 9" 
     2044    label $inner.grid_l -text "Grid" -font "Arial 9"
    20692045    checkbutton $inner.xgrid \
    20702046        -text "X" \
    2071         -variable [itcl::scope _settings(axisXGrid)] \
    2072         -command [itcl::code $this AdjustSetting axisXGrid] \
     2047        -variable [itcl::scope _settings(-xgrid)] \
     2048        -command [itcl::code $this AdjustSetting -xgrid] \
    20732049        -font "Arial 9"
    20742050    checkbutton $inner.ygrid \
    20752051        -text "Y" \
    2076         -variable [itcl::scope _settings(axisYGrid)] \
    2077         -command [itcl::code $this AdjustSetting axisYGrid] \
     2052        -variable [itcl::scope _settings(-ygrid)] \
     2053        -command [itcl::code $this AdjustSetting -ygrid] \
    20782054        -font "Arial 9"
    20792055    checkbutton $inner.zgrid \
    20802056        -text "Z" \
    2081         -variable [itcl::scope _settings(axisZGrid)] \
    2082         -command [itcl::code $this AdjustSetting axisZGrid] \
     2057        -variable [itcl::scope _settings(-zgrid)] \
     2058        -command [itcl::code $this AdjustSetting -zgrid] \
    20832059        -font "Arial 9"
    20842060    checkbutton $inner.minorticks \
    20852061        -text "Minor Ticks" \
    2086         -variable [itcl::scope _settings(axisMinorTicks)] \
    2087         -command [itcl::code $this AdjustSetting axisMinorTicks] \
     2062        -variable [itcl::scope _settings(-axisminorticks)] \
     2063        -command [itcl::code $this AdjustSetting -axisminorticks] \
    20882064        -font "Arial 9"
    20892065
    2090 
    2091     label $inner.mode_l -text "Mode" -font "Arial 9"
     2066    label $inner.mode_l -text "Mode" -font "Arial 9"
    20922067
    20932068    itk_component add axisflymode {
     
    20982073        "closest_triad"   "closest" \
    20992074        "furthest_triad"  "farthest" \
    2100         "outer_edges"     "outer"         
    2101     $itk_component(axisflymode) value "static"
    2102     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlymode]
     2075        "outer_edges"     "outer"
     2076    $itk_component(axisflymode) value $_settings(-axisflymode)
     2077    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
    21032078
    21042079    blt::table $inner \
     
    21062081        1,0 $inner.labels  -anchor w -cspan 4 \
    21072082        2,0 $inner.minorticks  -anchor w -cspan 4 \
    2108         4,0 $inner.grid_l  -anchor w \
     2083        4,0 $inner.grid_l  -anchor w \
    21092084        4,1 $inner.xgrid   -anchor w \
    21102085        4,2 $inner.ygrid   -anchor w \
    21112086        4,3 $inner.zgrid   -anchor w \
    21122087        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
    2113         5,1 $inner.mode    -fill x -cspan 3 
     2088        5,1 $inner.mode    -fill x -cspan 3
    21142089
    21152090    blt::table configure $inner r* c* -resize none
     
    21172092    blt::table configure $inner r3 -height 0.125i
    21182093}
    2119 
    21202094
    21212095itcl::body Rappture::VtkHeightmapViewer::BuildCameraTab {} {
     
    21372111        0,0 $inner.view_l -anchor e -pady 2 \
    21382112        0,1 $inner.view -anchor w -pady 2
     2113    blt::table configure $inner r0 -resize none
    21392114
    21402115    set labels { qx qy qz qw xpan ypan zoom }
     
    21432118        label $inner.${tag}label -text $tag -font "Arial 9"
    21442119        entry $inner.${tag} -font "Arial 9"  -bg white \
    2145             -textvariable [itcl::scope _view($tag)]
     2120            -textvariable [itcl::scope _view(-$tag)]
    21462121        bind $inner.${tag} <Return> \
    2147             [itcl::code $this camera set ${tag}]
     2122            [itcl::code $this camera set -${tag}]
    21482123        bind $inner.${tag} <KP_Enter> \
    2149             [itcl::code $this camera set ${tag}]
     2124            [itcl::code $this camera set -${tag}]
    21502125        blt::table $inner \
    21512126            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    21562131    checkbutton $inner.ortho \
    21572132        -text "Orthographic Projection" \
    2158         -variable [itcl::scope _view(ortho)] \
    2159         -command [itcl::code $this camera set ortho] \
     2133        -variable [itcl::scope _view(-ortho)] \
     2134        -command [itcl::code $this camera set -ortho] \
    21602135        -font "Arial 9"
    21612136    blt::table $inner \
     
    21642139    incr row
    21652140
    2166     blt::table configure $inner c* r* -resize none
     2141    blt::table configure $inner c* -resize none
    21672142    blt::table configure $inner c2 -resize expand
    21682143    blt::table configure $inner r$row -resize expand
     
    21702145
    21712146#
    2172 #  camera -- 
     2147#  camera --
    21732148#
    21742149itcl::body Rappture::VtkHeightmapViewer::camera {option args} {
    2175     switch -- $option { 
     2150    switch -- $option {
    21762151        "show" {
    21772152            puts [array get _view]
    21782153        }
    21792154        "set" {
    2180             set who [lindex $args 0]
    2181             set x $_view($who)
     2155            set what [lindex $args 0]
     2156            set x $_view($what)
    21822157            set code [catch { string is double $x } result]
    21832158            if { $code != 0 || !$result } {
    21842159                return
    21852160            }
    2186             switch -- $who {
    2187                 "ortho" {
    2188                     if {$_view(ortho)} {
     2161            switch -- $what {
     2162                "-ortho" {
     2163                    if {$_view($what)} {
    21892164                        SendCmd "camera mode ortho"
    21902165                    } else {
     
    21922167                    }
    21932168                }
    2194                 "xpan" - "ypan" {
     2169                "-xpan" - "-ypan" {
    21952170                    PanCamera
    21962171                }
    2197                 "qx" - "qy" - "qz" - "qw" {
    2198                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2172                "-qx" - "-qy" - "-qz" - "-qw" {
     2173                    set q [ViewToQuaternion]
    21992174                    $_arcball quaternion $q
    22002175                    EventuallyRotate $q
    22012176                }
    2202                 "zoom" {
    2203                     SendCmd "camera zoom $_view(zoom)"
     2177                "-zoom" {
     2178                    SendCmd "camera zoom $_view($what)"
    22042179                }
    22052180            }
     
    22212196
    22222197itcl::body Rappture::VtkHeightmapViewer::GetImage { args } {
    2223     if { [image width $_image(download)] > 0 && 
     2198    if { [image width $_image(download)] > 0 &&
    22242199         [image height $_image(download)] > 0 } {
    22252200        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    22342209        -title "[Rappture::filexfer::label downloadWord] as..."
    22352210    set inner [$popup component inner]
    2236     label $inner.summary -text "" -anchor w 
     2211    label $inner.summary -text "" -anchor w
    22372212    radiobutton $inner.vtk_button -text "VTK data file" \
    22382213        -variable [itcl::scope _downloadPopup(format)] \
    22392214        -font "Arial 9 " \
    2240         -value vtk 
     2215        -value vtk
    22412216    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    22422217    radiobutton $inner.image_button -text "Image File" \
    22432218        -variable [itcl::scope _downloadPopup(format)] \
    22442219        -font "Arial 9 " \
    2245         -value image 
     2220        -value image
    22462221    Rappture::Tooltip::for $inner.image_button \
    22472222        "Save as digital image."
     
    22642239        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    22652240        4,1 $inner.cancel -width .9i -fill y \
    2266         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2241        4,0 $inner.ok -padx 2 -width .9i -fill y
    22672242    blt::table configure $inner r3 -height 4
    22682243    blt::table configure $inner r4 -pady 4
     
    22752250# SetObjectStyle --
    22762251#
    2277 #       Set the style of the heightmap/contour object.  This gets calls 
     2252#       Set the style of the heightmap/contour object.  This gets calls
    22782253#       for each dataset once as it is loaded.  It can overridden by
    22792254#       the user controls.
     
    22852260    array set style {
    22862261        -color BCGYR
    2287         -opacity 100
    22882262        -levels 10
     2263        -opacity 1.0
    22892264    }
    22902265    set stylelist [$dataobj style $comp]
     
    23012276    # the code to handle aberrant cases.
    23022277
    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)
     2278    if { $_changed(-opacity) } {
     2279        set style(-opacity) [expr $_settings(-opacity) * 0.01]
     2280    }
     2281    if { $_changed(-numisolines) } {
     2282        set style(-levels) $_settings(-numisolines)
     2283    }
     2284    if { $_changed(-colormap) } {
     2285        set style(-color) $_settings(-colormap)
    23112286    }
    23122287    if { $_currentColormap == "" } {
     
    23142289    }
    23152290    if { [info exists style(-stretchtofit)] } {
    2316         set _settings(stretchToFit) $style(-stretchtofit)
    2317         AdjustSetting stretchToFit
    2318     }
    2319     set _currentOpacity $style(-opacity)
     2291        set _settings(-stretchtofit) $style(-stretchtofit)
     2292        AdjustSetting -stretchtofit
     2293    }
    23202294    if { $_currentNumIsolines != $style(-levels) } {
    23212295        set _currentNumIsolines $style(-levels)
    2322         set _settings(numIsolines) $_currentNumIsolines
     2296        set _settings(-numisolines) $_currentNumIsolines
    23232297        $itk_component(numisolines) value $_currentNumIsolines
    23242298        UpdateContourList
     
    23272301    SendCmd "outline add $tag"
    23282302    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
    2329     SendCmd "outline visible $_settings(outline) $tag"
     2303    SendCmd "outline visible $_settings(-outline) $tag"
    23302304    set scale [GetHeightmapScale]
    23312305    SendCmd "[list heightmap add contourlist $_contourList $scale $tag]"
    2332     set _comp2scale($tag) $_settings(heightmapScale)
    2333     SendCmd "heightmap edges $_settings(edges) $tag"
    2334     SendCmd "heightmap wireframe $_settings(wireframe) $tag"
    2335     SetCurrentColormap $style(-color) 
     2306    set _comp2scale($tag) $_settings(-heightmapscale)
     2307    SendCmd "heightmap edges $_settings(-edges) $tag"
     2308    SendCmd "heightmap wireframe $_settings(-wireframe) $tag"
     2309    SetCurrentColormap $style(-color)
    23362310    set color [$itk_component(isolinecolor) value]
    23372311    SendCmd "heightmap isolinecolor [Color2RGB $color] $tag"
    2338     SendCmd "heightmap lighting $_settings(isHeightmap) $tag"
    2339     SendCmd "heightmap isolines $_settings(isolinesVisible) $tag"
    2340     SendCmd "heightmap surface $_settings(colormapVisible) $tag"
     2312    SendCmd "heightmap lighting $_settings(-isheightmap) $tag"
     2313    SendCmd "heightmap isolines $_settings(-isolinesvisible) $tag"
     2314    SendCmd "heightmap surface $_settings(-colormapvisible) $tag"
     2315    SendCmd "heightmap opacity $style(-opacity) $tag"
     2316    set _settings(-opacity) [expr $style(-opacity) * 100.0]
    23412317}
    23422318
     
    23652341        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    23662342        if { [catch {DrawLegend} errs] != 0 } {
    2367             global errorInfo
    2368             puts stderr "errs=$errs errorInfo=$errorInfo"
     2343            global errorInfo
     2344            puts stderr "errs=$errs errorInfo=$errorInfo"
    23692345        }
    23702346    }
     
    23832359    set font "Arial 8"
    23842360    set lineht [font metrics $font -linespace]
    2385    
     2361
    23862362    if { [string match "component*" $fname] } {
    2387         set title ""
     2363        set title ""
    23882364    } else {
    2389         if { [info exists _fields($fname)] } {
    2390             foreach { title units } $_fields($fname) break
    2391             if { $units != "" } {
    2392                 set title [format "%s (%s)" $title $units]
    2393             }
    2394         } else {
    2395             set title $fname
    2396         }
     2365        if { [info exists _fields($fname)] } {
     2366            foreach { title units } $_fields($fname) break
     2367            if { $units != "" } {
     2368                set title [format "%s (%s)" $title $units]
     2369            }
     2370        } else {
     2371            set title $fname
     2372        }
    23972373    }
    23982374    set x [expr $w - 2]
    2399     if { !$_settings(legendVisible) } {
    2400         $c delete legend
    2401         return
    2402     } 
     2375    if { !$_settings(-legendvisible) } {
     2376        $c delete legend
     2377        return
     2378    }
    24032379    if { [$c find withtag "legend"] == "" } {
    2404         set y 2
    2405         # If there's a legend title, create a text item for the title.
     2380        set y 2
     2381        # If there's a legend title, create a text item for the title.
    24062382        $c create text $x $y \
    2407                 -anchor ne \
    2408                 -fill $itk_option(-plotforeground) -tags "title legend" \
    2409                 -font $font
    2410         $c create text $x $y \
    2411             -anchor ne \
    2412             -fill $itk_option(-plotforeground) -tags "vmax legend" \
    2413             -font $font
    2414         incr y $lineht
    2415         $c create image $x $y \
    2416             -anchor ne \
    2417             -image $_image(legend) -tags "colormap legend"
    2418         $c create rectangle $x $y 1 1 \
    2419             -fill "" -outline "" -tags "sensor legend"
    2420         $c create text $x [expr {$h-2}] \
    2421             -anchor se \
    2422             -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2423             -font $font
    2424         $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
    2425         $c bind sensor <Leave> [itcl::code $this LeaveLegend]
    2426         $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
     2383            -anchor ne \
     2384            -fill $itk_option(-plotforeground) -tags "title legend" \
     2385            -font $font
     2386        if { $title != "" } {
     2387            incr y $lineht
     2388        }
     2389        $c create text $x $y \
     2390            -anchor ne \
     2391            -fill $itk_option(-plotforeground) -tags "vmax legend" \
     2392            -font $font
     2393        incr y $lineht
     2394        $c create image $x $y \
     2395            -anchor ne \
     2396            -image $_image(legend) -tags "colormap legend"
     2397        $c create rectangle $x $y 1 1 \
     2398            -fill "" -outline "" -tags "sensor legend"
     2399        $c create text $x [expr {$h-2}] \
     2400            -anchor se \
     2401            -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2402            -font $font
     2403        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
     2404        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2405        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
    24272406    }
    24282407    $c delete isoline
     
    24352414    # Draw the isolines on the legend.
    24362415    array unset _isolines
    2437     if { $color != "none"  && [info exists _limits($_curFldName)] && 
    2438          $_settings(isolinesVisible) && $_currentNumIsolines > 0 } {
     2416    if { $color != "none"  && [info exists _limits($_curFldName)] &&
     2417         $_settings(-isolinesvisible) && $_currentNumIsolines > 0 } {
    24392418
    24402419        foreach { vmin vmax } $_limits($_curFldName) break
     
    24442423        }
    24452424        set tags "isoline legend"
    2446         set offset [expr 2 + $lineht]
    2447         if { $title != "" } {
    2448             incr offset $lineht
    2449         }
     2425        set offset [expr 2 + $lineht]
     2426        if { $title != "" } {
     2427            incr offset $lineht
     2428        }
    24502429        foreach value $_contourList {
    24512430            set norm [expr 1.0 - (($value - $vmin) / $range)]
     
    24552434                set _isolines([expr $y1 - $off]) $value
    24562435            }
    2457             $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
    2458         }
     2436            $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
     2437        }
    24592438    }
    24602439
     
    24652444    if { [info exists _limits($_curFldName)] } {
    24662445        foreach { vmin vmax } $_limits($_curFldName) break
    2467         $c itemconfigure vmin -text [format %g $vmin]
    2468         $c itemconfigure vmax -text [format %g $vmax]
     2446        $c itemconfigure vmin -text [format %g $vmin]
     2447        $c itemconfigure vmax -text [format %g $vmax]
    24692448    }
    24702449    set y 2
     
    24722451    if { $title != "" } {
    24732452        $c itemconfigure title -text $title
    2474         $c coords title $x $y
    2475         incr y $lineht
     2453        $c coords title $x $y
     2454        incr y $lineht
    24762455    }
    24772456    $c coords vmax $x $y
     
    25212500    set font "Arial 8"
    25222501    set lineht [font metrics $font -linespace]
    2523    
     2502
    25242503    set ih [image height $_image(legend)]
    25252504    # Subtract off the offset of the color ramp from the top of the canvas
     
    25272506
    25282507    if { [string match "component*" $fname] } {
    2529         set title ""
     2508        set title ""
    25302509    } else {
    2531         if { [info exists _fields($fname)] } {
    2532             foreach { title units } $_fields($fname) break
    2533             if { $units != "" } {
    2534                 set title [format "%s (%s)" $title $units]
    2535             }
    2536         } else {
    2537             set title $fname
    2538         }
     2510        if { [info exists _fields($fname)] } {
     2511            foreach { title units } $_fields($fname) break
     2512            if { $units != "" } {
     2513                set title [format "%s (%s)" $title $units]
     2514            }
     2515        } else {
     2516            set title $fname
     2517        }
    25392518    }
    25402519    # If there's a legend title, increase the offset by the line height.
     
    25522531    }
    25532532    set color [eval format "\#%02x%02x%02x" $pixel]
    2554     $_image(swatch) put black  -to 0 0 23 23 
    2555     $_image(swatch) put $color -to 1 1 22 22 
     2533    $_image(swatch) put black  -to 0 0 23 23
     2534    $_image(swatch) put $color -to 1 1 22 22
    25562535
    25572536    # Compute the value of the point
     
    25632542        set value 0.0
    25642543    }
    2565     set tipx [expr $x + 15] 
     2544    set tipx [expr $x + 15]
    25662545    set tipy [expr $y - 5]
    25672546    .rappturetooltip configure -icon $_image(swatch)
     
    25712550        Rappture::Tooltip::text $c [format "$title %g" $value]
    25722551    }
    2573     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2552    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    25742553}
    25752554
     
    25862565# ----------------------------------------------------------------------
    25872566itcl::body Rappture::VtkHeightmapViewer::Combo {option} {
    2588     set c $itk_component(view) 
     2567    set c $itk_component(view)
    25892568    switch -- $option {
    25902569        post {
     
    25992578        }
    26002579        deactivate {
    2601             $c itemconfigure title -fill $itk_option(-plotforeground) 
     2580            $c itemconfigure title -fill $itk_option(-plotforeground)
    26022581        }
    26032582        invoke {
    26042583            $itk_component(field) value $_curFldLabel
    2605             AdjustSetting field
     2584            AdjustSetting -field
    26062585        }
    26072586        default {
     
    26122591
    26132592itcl::body Rappture::VtkHeightmapViewer::GetHeightmapScale {} {
    2614     if {  $_settings(isHeightmap) } {
    2615         set val $_settings(heightmapScale)
    2616         set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }]
    2617         return $sval
    2618     }
    2619     return 0 
    2620 }
    2621 
    2622 itcl::body Rappture::VtkHeightmapViewer::SetOrientation { side } { 
     2593    if {  $_settings(-isheightmap) } {
     2594        set val $_settings(-heightmapscale)
     2595        set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }]
     2596        return $sval
     2597    }
     2598    return 0
     2599}
     2600
     2601itcl::body Rappture::VtkHeightmapViewer::SetOrientation { side } {
    26232602    array set positions {
    26242603        front  "0.707107 0.707107 0 0"
     
    26292608        bottom "0 1 0 0"
    26302609    }
    2631     foreach name { qw qx qy qz } value $positions($side) {
     2610    foreach name { -qw -qx -qy -qz } value $positions($side) {
    26322611        set _view($name) $value
    2633     } 
    2634     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2612    }
     2613    set q [ViewToQuaternion]
    26352614    $_arcball quaternion $q
    26362615    SendCmd "camera orient $q"
    26372616    SendCmd "camera reset"
    2638     set _view(xpan) 0
    2639     set _view(ypan) 0
    2640     set _view(zoom) 1.0
    2641 }
    2642 
    2643 itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} { 
     2617    set _view(-xpan) 0
     2618    set _view(-ypan) 0
     2619    set _view(-zoom) 1.0
     2620}
     2621
     2622itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} {
    26442623    if {$_currentNumIsolines == 0} {
    26452624        set _contourList ""
Note: See TracChangeset for help on using the changeset viewer.