Changeset 5014 for branches/1.3


Ignore:
Timestamp:
Feb 12, 2015 12:59:45 PM (9 years ago)
Author:
ldelgass
Message:

update vtkglyphviewer from 1.4 branch

File:
1 edited

Legend:

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

    r4951 r5014  
    11# -*- mode: tcl; indent-tabs-mode: nil -*-
    2 
    32# ----------------------------------------------------------------------
    43#  COMPONENT: vtkglyphviewer - Vtk 3D glyphs object viewer
     
    87# ======================================================================
    98#  AUTHOR:  Michael McLennan, Purdue University
    10 #  Copyright (c) 2004-2005  Purdue Research Foundation
     9#  Copyright (c) 2004-2014  HUBzero Foundation, LLC
    1110#
    1211#  See the file "license.terms" for information on usage and
     
    5857    public method get {args}
    5958    public method isconnected {}
    60     public method limits { colormap }
    6159    public method parameters {title args} {
    6260        # do nothing
     
    6462    public method scale {args}
    6563
    66     protected method Connect {}
    67     protected method CurrentDatasets {args}
    68     protected method Disconnect {}
    69     protected method DoResize {}
    70     protected method DoRotate {}
    71     protected method AdjustSetting {what {value ""}}
    72     protected method InitSettings { args  }
    73     protected method Pan {option x y}
    74     protected method Pick {x y}
    75     protected method Rebuild {}
    76     protected method ReceiveDataset { args }
    77     protected method ReceiveImage { args }
    78     protected method ReceiveLegend { colormap title vmin vmax size }
    79     protected method Rotate {option x y}
    80     protected method Zoom {option}
    81 
    8264    # The following methods are only used by this class.
     65    private method AdjustSetting {what {value ""}}
    8366    private method BuildAxisTab {}
    8467    private method BuildCameraTab {}
     
    8972    private method DrawLegend {}
    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 EnterLegend { x y }
    9280    private method EventuallyResize { w h }
     
    9684    private method GetImage { args }
    9785    private method GetVtkData { args }
     86    private method InitSettings { args  }
    9887    private method IsValidObject { dataobj }
    9988    private method LeaveLegend {}
    10089    private method MotionLegend { x y }
     90    private method Pan {option x y}
    10191    private method PanCamera {}
     92    private method Pick {x y}
     93    private method QuaternionToView { q } {
     94        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     95    }
     96    private method Rebuild {}
     97    private method ReceiveDataset { args }
     98    private method ReceiveImage { args }
     99    private method ReceiveLegend { colormap title vmin vmax size }
    102100    private method RequestLegend {}
     101    private method Rotate {option x y}
    103102    private method SetLegendTip { x y }
    104103    private method SetObjectStyle { dataobj comp }
     
    106105    private method SetCurrentColormap { color }
    107106    private method SetOrientation { side }
     107    private method ViewToQuaternion {} {
     108        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     109    }
     110    private method Zoom {option}
    108111
    109112    private variable _arcball ""
     
    119122    # heightmaps displayed.
    120123    private variable _currentColormap ""
    121     private variable _currentOpacity ""
    122124
    123125    private variable _dataset2style    ;# maps dataobj-component to transfunc
     
    146148    private variable _legendPending 0
    147149    private variable _field      ""
    148     private variable _colorMode "vmag"; #  Mode of colormap (vmag or scalar)
     150    private variable _colorMode "vmag"; #  Mode of colormap (vmag or scalar)
    149151    private variable _fieldNames {}
    150152    private variable _fields
     
    184186    $_dispatcher register !xcutplane
    185187    $_dispatcher dispatch $this !xcutplane \
    186         "[itcl::code $this AdjustSetting cutplaneXPosition]; list"
     188        "[itcl::code $this AdjustSetting -cutplanexposition]; list"
    187189
    188190    # Y-Cutplane event
    189191    $_dispatcher register !ycutplane
    190192    $_dispatcher dispatch $this !ycutplane \
    191         "[itcl::code $this AdjustSetting cutplaneYPosition]; list"
     193        "[itcl::code $this AdjustSetting -cutplaneyposition]; list"
    192194
    193195    # Z-Cutplane event
    194196    $_dispatcher register !zcutplane
    195197    $_dispatcher dispatch $this !zcutplane \
    196         "[itcl::code $this AdjustSetting cutplaneZPosition]; list"
     198        "[itcl::code $this AdjustSetting -cutplanezposition]; list"
    197199
    198200    #
     
    205207    # Initialize the view to some default parameters.
    206208    array set _view {
    207         qw              0.853553
    208         qx              -0.353553
    209         qy              0.353553
    210         qz              0.146447
    211         zoom            1.0
    212         xpan            0
    213         ypan            0
    214         ortho           0
     209        -ortho           0
     210        -qw              0.853553
     211        -qx              -0.353553
     212        -qy              0.353553
     213        -qz              0.146447
     214        -xpan            0
     215        -ypan            0
     216        -zoom            1.0
    215217    }
    216218    set _arcball [blt::arcball create 100 100]
    217     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    218     $_arcball quaternion $q
     219    $_arcball quaternion [ViewToQuaternion]
    219220
    220221    array set _settings [subst {
    221         background              black
    222         colormap                BCGYR
    223         colormapVisible         1
    224         field                   "Default"
    225         axesVisible             1
    226         axisLabelsVisible       1
    227         axisXGrid               0
    228         axisYGrid               0
    229         axisZGrid               0
    230         cutplaneEdges           0
    231         cutplaneLighting        1
    232         cutplanePreinterp       1
    233         cutplaneOpacity         100
    234         cutplaneVisible         0
    235         cutplaneWireframe       0
    236         cutplaneXPosition       50
    237         cutplaneXVisible        1
    238         cutplaneYPosition       50
    239         cutplaneYVisible        1
    240         cutplaneZPosition       50
    241         cutplaneZVisible        1
    242         glyphEdges              0
    243         glyphLighting           1
    244         glyphOpacity            100
    245         saveGlyphOpacity        100
    246         glyphOutline            0
    247         glyphVisible            1
    248         glyphWireframe          0
    249         legendVisible           1
     222        -axesvisible            1
     223        -axislabels             1
     224        -axisminorticks         1
     225        -axismode               "static"
     226        -background             black
     227        -colormap               BCGYR
     228        -colormapvisible        1
     229        -cutplaneedges          0
     230        -cutplanelighting       1
     231        -cutplanepreinterp      1
     232        -cutplaneopacity        100
     233        -cutplanevisible        0
     234        -cutplanewireframe      0
     235        -cutplanexposition      50
     236        -cutplanexvisible       1
     237        -cutplaneyposition      50
     238        -cutplaneyvisible       1
     239        -cutplanezposition      50
     240        -cutplanezvisible       1
     241        -field                  "Default"
     242        -glyphedges             0
     243        -glyphlighting          1
     244        -glyphnormscale         1
     245        -glyphopacity           100
     246        -glyphorient            1
     247        -glyphoutline           0
     248        -glyphscale             1
     249        -glyphscalemode         "vmag"
     250        -glyphshape             "arrow"
     251        -glyphvisible           1
     252        -glyphwireframe         0
     253        -legendvisible          1
     254        -saveglyphopacity       100
     255        -xgrid                  0
     256        -ygrid                  0
     257        -zgrid                  0
    250258    }]
    251259    array set _changed {
    252         glyphOpacity            0
    253         colormap                0
     260        -colormap               0
     261        -glyphopacity           0
    254262    }
    255263
     
    331339            -onimage [Rappture::icon volume-on] \
    332340            -offimage [Rappture::icon volume-off] \
    333             -variable [itcl::scope _settings(glyphVisible)] \
    334             -command [itcl::code $this AdjustSetting glyphVisible]
     341            -variable [itcl::scope _settings(-glyphvisible)] \
     342            -command [itcl::code $this AdjustSetting -glyphvisible]
    335343    }
    336344    $itk_component(glyphs) select
     
    344352            -onimage [Rappture::icon cutbutton] \
    345353            -offimage [Rappture::icon cutbutton] \
    346             -variable [itcl::scope _settings(cutplaneVisible)] \
    347             -command [itcl::code $this AdjustSetting cutplaneVisible]
     354            -variable [itcl::scope _settings(-cutplanevisible)] \
     355            -command [itcl::code $this AdjustSetting -cutplanevisible]
    348356    }
    349357    Rappture::Tooltip::for $itk_component(cutplane) \
     
    462470
    463471itcl::body Rappture::VtkGlyphViewer::DoRotate {} {
    464     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    465     SendCmd "camera orient $q"
     472    SendCmd "camera orient [ViewToQuaternion]"
    466473    set _rotatePending 0
    467474}
     
    487494
    488495itcl::body Rappture::VtkGlyphViewer::EventuallyRotate { q } {
    489     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     496    QuaternionToView $q
    490497    if { !$_rotatePending } {
    491498        set _rotatePending 1
     
    542549}
    543550
    544 
    545551# ----------------------------------------------------------------------
    546552# USAGE: delete ?<dataobj1> <dataobj2> ...?
    547553#
    548 #       Clients use this to delete a dataobj from the plot.  If no dataobjs
    549 #       are specified, then all dataobjs are deleted.  No data objects are
    550 #       deleted.  They are only removed from the display list.
     554#    Clients use this to delete a dataobj from the plot.  If no dataobjs
     555#    are specified, then all dataobjs are deleted.  No data objects are
     556#    deleted.  They are only removed from the display list.
    551557#
    552558# ----------------------------------------------------------------------
     
    798804# isconnected --
    799805#
    800 #       Indicates if we are currently connected to the visualization server.
     806#    Indicates if we are currently connected to the visualization server.
    801807#
    802808itcl::body Rappture::VtkGlyphViewer::isconnected {} {
     
    815821# Disconnect --
    816822#
    817 #       Clients use this method to disconnect from the current rendering
    818 #       server.
     823#    Clients use this method to disconnect from the current rendering
     824#    server.
    819825#
    820826itcl::body Rappture::VtkGlyphViewer::Disconnect {} {
     
    833839    array unset _data
    834840    array unset _colormaps
    835     array unset _seeds
    836841    array unset _dataset2style
    837842    array unset _obj2datasets
     
    855860    if { $info(-type) == "image" } {
    856861        if 0 {
    857             set f [open "last.ppm" "w"]
    858             puts $f $bytes
     862            set f [open "last.ppm" "w"]
     863            fconfigure $f -encoding binary
     864            puts -nonewline $f $bytes
    859865            close $f
    860866        }
     
    944950        # Reset the camera and other view parameters
    945951        #
    946         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    947         $_arcball quaternion $q
    948         if {$_view(ortho)} {
     952        $_arcball quaternion [ViewToQuaternion]
     953        if {$_view(-ortho)} {
    949954            SendCmd "camera mode ortho"
    950955        } else {
     
    954959        PanCamera
    955960        set _first ""
    956         InitSettings axisXGrid axisYGrid axisZGrid axisMode \
    957             axesVisible axisLabelsVisible
    958         foreach axis { x y z } {
    959             SendCmd "axis lformat $axis %g"
    960         }
     961        InitSettings -xgrid -ygrid -zgrid -axismode \
     962            -axesvisible -axislabels -axisminorticks
     963        #SendCmd "axis lformat all %g"
    961964        StopBufferingCommands
    962965        SendCmd "imgflush"
     
    974977            if { ![info exists _datasets($tag)] } {
    975978                set bytes [$dataobj vtkdata $comp]
    976                 if 0 {
    977                     set f [open "/tmp/glyph.vtk" "w"]
    978                     puts $f $bytes
    979                     close $f
     979                if 0 {
     980                    set f [open "/tmp/glyph.vtk" "w"]
     981                    fconfigure $f -translation binary -encoding binary
     982                    puts -nonewline $f $bytes
     983                    close $f
    980984                }
    981985                set length [string length $bytes]
     
    992996                    SendCmd "clientinfo [list $info]"
    993997                }
    994                 append _outbuf "dataset add $tag data follows $length\n"
     998                SendCmd "dataset add $tag data follows $length"
    995999                append _outbuf $bytes
    9961000                set _datasets($tag) 1
     
    10011005                # Setting dataset visible enables outline
    10021006                # and glyphs
    1003                 SendCmd "dataset visible 1 $tag"
     1007                SendCmd "dataset visible 1 $tag"
    10041008            }
    10051009        }
     
    10071011
    10081012    if { $_first != "" } {
    1009         $itk_component(field) choices delete 0 end
    1010         $itk_component(fieldmenu) delete 0 end
    1011         array unset _fields
     1013        $itk_component(field) choices delete 0 end
     1014        $itk_component(fieldmenu) delete 0 end
     1015        array unset _fields
    10121016        set _curFldName ""
    10131017        foreach cname [$_first components] {
     
    10351039        $itk_component(field) value $_curFldLabel
    10361040    }
    1037     InitSettings glyphOutline
    1038         #cutplaneVisible
     1041    InitSettings -glyphoutline
     1042        #-cutplanevisible
    10391043    if { $_reset } {
    1040         # These are settings that rely on a dataset being loaded.
     1044        # These are settings that rely on a dataset being loaded.
    10411045        InitSettings \
    1042             glyphLighting \
    1043             field \
    1044             glyphEdges glyphLighting glyphOpacity \
    1045             glyphWireframe
    1046 
    1047         #cutplaneXPosition cutplaneYPosition cutplaneZPosition \
    1048             cutplaneXVisible cutplaneYVisible cutplaneZVisible \
    1049             cutplanePreinterp
     1046            -field \
     1047            -glyphedges -glyphlighting -glyphopacity \
     1048            -glyphwireframe
     1049
     1050        #-cutplanexposition -cutplaneyposition -cutplanezposition \
     1051            -cutplanexvisible -cutplaneyvisible -cutplanezvisible \
     1052            -cutplanepreinterp
    10501053
    10511054        Zoom reset
    1052         foreach axis { x y z } {
     1055        foreach axis { x y z } {
    10531056            # Another problem fixed by a <view>. We looking into a data
    10541057            # object for the name of the axes. This should be global to
    10551058            # the viewer itself.
    1056             set label [$_first hints ${axis}label]
    1057             if { $label == "" } {
     1059            set label [$_first hints ${axis}label]
     1060            if { $label == "" } {
    10581061                set label [string toupper $axis]
    1059             }
    1060             # May be a space in the axis label.
    1061             SendCmd [list axis name $axis $label]
     1062            }
     1063            # May be a space in the axis label.
     1064            SendCmd [list axis name $axis $label]
    10621065        }
    10631066        if { [array size _fields] < 2 } {
     
    11301133    switch -- $option {
    11311134        "in" {
    1132             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1133             SendCmd "camera zoom $_view(zoom)"
     1135            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1136            SendCmd "camera zoom $_view(-zoom)"
    11341137        }
    11351138        "out" {
    1136             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1137             SendCmd "camera zoom $_view(zoom)"
     1139            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1140            SendCmd "camera zoom $_view(-zoom)"
    11381141        }
    11391142        "reset" {
    11401143            array set _view {
    1141                 qw     0.853553
    1142                 qx     -0.353553
    1143                 qy     0.353553
    1144                 qz     0.146447
    1145                 zoom   1.0
    1146                 xpan   0
    1147                 ypan   0
     1144                -qw      0.853553
     1145                -qx      -0.353553
     1146                -qy      0.353553
     1147                -qz      0.146447
     1148                -xpan    0
     1149                -ypan    0
     1150                -zoom    1.0
    11481151            }
    11491152            if { $_first != "" } {
     
    11531156                }
    11541157            }
    1155             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1156             $_arcball quaternion $q
     1158            $_arcball quaternion [ViewToQuaternion]
    11571159            DoRotate
    11581160            SendCmd "camera reset"
     
    11621164
    11631165itcl::body Rappture::VtkGlyphViewer::PanCamera {} {
    1164     set x $_view(xpan)
    1165     set y $_view(ypan)
     1166    set x $_view(-xpan)
     1167    set y $_view(-ypan)
    11661168    SendCmd "camera pan $x $y"
    11671169}
    1168 
    11691170
    11701171# ----------------------------------------------------------------------
     
    12221223itcl::body Rappture::VtkGlyphViewer::Pick {x y} {
    12231224    foreach tag [CurrentDatasets -visible] {
    1224         SendCmdNoSplash "dataset getscalar pixel $x $y $tag"
     1225        SendCmd "dataset getscalar pixel $x $y $tag"
    12251226    }
    12261227}
     
    12411242            set x [expr $x / double($w)]
    12421243            set y [expr $y / double($h)]
    1243             set _view(xpan) [expr $_view(xpan) + $x]
    1244             set _view(ypan) [expr $_view(ypan) + $y]
     1244            set _view(-xpan) [expr $_view(-xpan) + $x]
     1245            set _view(-ypan) [expr $_view(-ypan) + $y]
    12451246            PanCamera
    12461247            return
     
    12641265            set _click(x) $x
    12651266            set _click(y) $y
    1266             set _view(xpan) [expr $_view(xpan) - $dx]
    1267             set _view(ypan) [expr $_view(ypan) - $dy]
     1267            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1268            set _view(-ypan) [expr $_view(-ypan) - $dy]
    12681269            PanCamera
    12691270        }
     
    12871288itcl::body Rappture::VtkGlyphViewer::InitSettings { args } {
    12881289    foreach spec $args {
    1289         if { [info exists _settings($_first-$spec)] } {
     1290        if { [info exists _settings($_first${spec})] } {
    12901291            # Reset global setting with dataobj specific setting
    1291             set _settings($spec) $_settings($_first-$spec)
     1292            set _settings($spec) $_settings($_first${spec})
    12921293        }
    12931294        AdjustSetting $spec
     
    12981299# AdjustSetting --
    12991300#
    1300 #       Changes/updates a specific setting in the widget.  There are
    1301 #       usually user-setable option.  Commands are sent to the render
    1302 #       server.
     1301#    Changes/updates a specific setting in the widget.  There are
     1302#    usually user-setable option.  Commands are sent to the render
     1303#    server.
    13031304#
    13041305itcl::body Rappture::VtkGlyphViewer::AdjustSetting {what {value ""}} {
     
    13071308    }
    13081309    switch -- $what {
    1309         "background" {
     1310        "-background" {
    13101311            set bgcolor [$itk_component(background) value]
    1311             array set fgcolors {
    1312                 "black" "white"
    1313                 "white" "black"
    1314                 "grey"  "black"
    1315             }
     1312            array set fgcolors {
     1313                "black" "white"
     1314                "white" "black"
     1315                "grey"  "black"
     1316            }
    13161317            configure -plotbackground $bgcolor \
    1317                 -plotforeground $fgcolors($bgcolor)
    1318             $itk_component(view) delete "legend"
    1319             DrawLegend
    1320         }
    1321         "axesVisible" {
    1322             set bool $_settings(axesVisible)
     1318                -plotforeground $fgcolors($bgcolor)
     1319            $itk_component(view) delete "legend"
     1320            DrawLegend
     1321        }
     1322        "-axesvisible" {
     1323            set bool $_settings($what)
    13231324            SendCmd "axis visible all $bool"
    13241325        }
    1325         "axisLabelsVisible" {
    1326             set bool $_settings(axisLabelsVisible)
     1326        "-axislabels" {
     1327            set bool $_settings($what)
    13271328            SendCmd "axis labels all $bool"
    13281329        }
    1329         "axisXGrid" - "axisYGrid" - "axisZGrid" {
    1330             set axis [string tolower [string range $what 4 4]]
     1330        "-axisminorticks" {
     1331            set bool $_settings($what)
     1332            SendCmd "axis minticks all $bool"
     1333        }
     1334        "-xgrid" - "-ygrid" - "-zgrid" {
     1335            set axis [string tolower [string range $what 1 1]]
    13311336            set bool $_settings($what)
    13321337            SendCmd "axis grid $axis $bool"
    13331338        }
    1334         "axisMode" {
     1339        "-axismode" {
    13351340            set mode [$itk_component(axisMode) value]
    13361341            set mode [$itk_component(axisMode) translate $mode]
     
    13381343            SendCmd "axis flymode $mode"
    13391344        }
    1340         "cutplaneEdges" {
     1345        "-cutplaneedges" {
    13411346            set bool $_settings($what)
    13421347            SendCmd "cutplane edges $bool"
    13431348        }
    1344         "cutplaneVisible" {
     1349        "-cutplanevisible" {
    13451350            set bool $_settings($what)
    1346             SendCmd "cutplane visible $bool"
    1347         }
    1348         "cutplaneWireframe" {
     1351            SendCmd "cutplane visible 0"
     1352            if { $bool } {
     1353                foreach tag [CurrentDatasets -visible] {
     1354                    SendCmd "cutplane visible $bool $tag"
     1355                }
     1356            }
     1357        }
     1358        "-cutplanewireframe" {
    13491359            set bool $_settings($what)
    13501360            SendCmd "cutplane wireframe $bool"
    13511361        }
    1352         "cutplaneLighting" {
     1362        "-cutplanelighting" {
    13531363            set bool $_settings($what)
    13541364            SendCmd "cutplane lighting $bool"
    13551365        }
    1356         "cutplaneOpacity" {
     1366        "-cutplaneopacity" {
    13571367            set val $_settings($what)
    13581368            set sval [expr { 0.01 * double($val) }]
    13591369            SendCmd "cutplane opacity $sval"
    13601370        }
    1361         "cutplanePreinterp" {
     1371        "-cutplanepreinterp" {
    13621372            set bool $_settings($what)
    13631373            SendCmd "cutplane preinterp $bool"
    13641374        }
    1365         "cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" {
    1366             set axis [string tolower [string range $what 8 8]]
     1375        "-cutplanexvisible" - "-cutplaneyvisible" - "-cutplanezvisible" {
     1376            set axis [string tolower [string range $what 9 9]]
    13671377            set bool $_settings($what)
    13681378            if { $bool } {
     
    13731383                    -troughcolor grey82
    13741384            }
    1375             SendCmd "cutplane axis $axis $bool"
    1376         }
    1377         "cutplaneXPosition" - "cutplaneYPosition" - "cutplaneZPosition" {
    1378             set axis [string tolower [string range $what 8 8]]
     1385            SendCmd "cutplane axis $axis $bool"
     1386        }
     1387        "-cutplanexposition" - "-cutplaneyposition" - "-cutplanezposition" {
     1388            set axis [string tolower [string range $what 9 9]]
    13791389            set pos [expr $_settings($what) * 0.01]
    13801390            SendCmd "cutplane slice ${axis} ${pos}"
    13811391            set _cutplanePending 0
    13821392        }
    1383         "colormap" {
    1384             set _changed(colormap) 1
     1393        "-colormap" {
     1394            set _changed($what) 1
    13851395            StartBufferingCommands
    13861396            set color [$itk_component(colormap) value]
    1387             set _settings(colormap) $color
    1388             if { $color == "none" } {
    1389                 if { $_settings(colormapVisible) } {
    1390                     SendCmd "glyphs colormode constant {}"
    1391                     set _settings(colormapVisible) 0
    1392                 }
    1393             } else {
    1394                 if { !$_settings(colormapVisible) } {
    1395                     SendCmd "glyphs colormode $_colorMode $_curFldName"
    1396                     set _settings(colormapVisible) 1
    1397                 }
    1398                 SetCurrentColormap $color
    1399             }
     1397            set _settings($what) $color
     1398            if { $color == "none" } {
     1399                if { $_settings(-colormapvisible) } {
     1400                    SendCmd "glyphs colormode constant {}"
     1401                    set _settings(-colormapvisible) 0
     1402                }
     1403            } else {
     1404                if { !$_settings(-colormapvisible) } {
     1405                    SendCmd "glyphs colormode $_colorMode $_curFldName"
     1406                    set _settings(-colormapvisible) 1
     1407                }
     1408                SetCurrentColormap $color
     1409            }
    14001410            StopBufferingCommands
    1401             EventuallyRequestLegend
    1402         }
    1403         "glyphWireframe" {
    1404             set bool $_settings(glyphWireframe)
    1405             SendCmd "glyphs wireframe $bool"
    1406         }
    1407         "glyphVisible" {
    1408             set bool $_settings(glyphVisible)
    1409             SendCmd "glyphs visible $bool"
     1411            EventuallyRequestLegend
     1412        }
     1413        "-glyphwireframe" {
     1414            set bool $_settings($what)
     1415            SendCmd "glyphs wireframe $bool"
     1416        }
     1417        "-glyphvisible" {
     1418            set bool $_settings($what)
     1419            SendCmd "glyphs visible 0"
     1420            if { $bool } {
     1421                foreach tag [CurrentDatasets -visible] {
     1422                    SendCmd "glyphs visible $bool $tag"
     1423                }
     1424            }
    14101425            if { $bool } {
    14111426                Rappture::Tooltip::for $itk_component(glyphs) \
     
    14151430                    "Show the glyph"
    14161431            }
    1417             DrawLegend
    1418         }
    1419         "glyphLighting" {
    1420             set bool $_settings(glyphLighting)
    1421             SendCmd "glyphs lighting $bool"
    1422         }
    1423         "glyphEdges" {
    1424             set bool $_settings(glyphEdges)
    1425             SendCmd "glyphs edges $bool"
    1426         }
    1427         "glyphOutline" {
    1428             set bool $_settings(glyphOutline)
    1429             SendCmd "outline visible $bool"
    1430         }
    1431         "glyphOpacity" {
    1432             set val $_settings(glyphOpacity)
     1432            DrawLegend
     1433        }
     1434        "-glyphlighting" {
     1435            set bool $_settings($what)
     1436            SendCmd "glyphs lighting $bool"
     1437        }
     1438        "-glyphedges" {
     1439            set bool $_settings($what)
     1440            SendCmd "glyphs edges $bool"
     1441        }
     1442        "-glyphoutline" {
     1443            set bool $_settings($what)
     1444            SendCmd "outline visible 0"
     1445            if { $bool } {
     1446                foreach tag [CurrentDatasets -visible] {
     1447                    SendCmd "outline visible $bool $tag"
     1448                }
     1449            }
     1450        }
     1451        "-glyphopacity" {
     1452            set val $_settings($what)
    14331453            set sval [expr { 0.01 * double($val) }]
    1434             SendCmd "glyphs opacity $sval"
    1435         }
    1436         "field" {
     1454            SendCmd "glyphs opacity $sval"
     1455        }
     1456        "-glyphnormscale" {
     1457            set bool $_settings($what)
     1458            SendCmd "glyphs normscale $bool"
     1459        }
     1460        "-glyphorient" {
     1461            set bool $_settings($what)
     1462            SendCmd "glyphs gorient $bool {}"
     1463        }
     1464        "-glyphscale" {
     1465            set val $_settings($what)
     1466            if { [string is double $val] } {
     1467                SendCmd "glyphs gscale $val"
     1468            }
     1469        }
     1470        "-glyphscalemode" {
     1471            set label [$itk_component(scaleMode) value]
     1472            set mode [$itk_component(scaleMode) translate $label]
     1473            set _settings($what) $mode
     1474            SendCmd "glyphs smode $mode {}"
     1475        }
     1476        "-glyphshape" {
     1477            set label [$itk_component(gshape) value]
     1478            set shape [$itk_component(gshape) translate $label]
     1479            set _settings($what) $shape
     1480            SendCmd "glyphs shape $shape"
     1481        }
     1482        "-field" {
    14371483            set label [$itk_component(field) value]
    14381484            set fname [$itk_component(field) translate $label]
    1439             set _settings(field) $fname
     1485            set _settings($what) $fname
    14401486            if { [info exists _fields($fname)] } {
    14411487                foreach { label units components } $_fields($fname) break
     
    14511497                return
    14521498            }
    1453             #SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"
     1499            #if { ![info exists _limits($_curFldName)] } {
     1500            #    SendCmd "dataset maprange all"
     1501            #} else {
     1502            #    SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"
     1503            #}
    14541504            #SendCmd "cutplane colormode $_colorMode $_curFldName"
    14551505            SendCmd "glyphs colormode $_colorMode $_curFldName"
    14561506            DrawLegend
    14571507        }
    1458         "legendVisible" {
    1459             if { !$_settings(legendVisible) } {
     1508        "-legendvisible" {
     1509            if { !$_settings($what) } {
    14601510                $itk_component(view) delete legend
    1461             }
    1462             DrawLegend
     1511            }
     1512            DrawLegend
    14631513        }
    14641514        default {
     
    14681518}
    14691519
    1470 
    14711520#
    14721521# RequestLegend --
    14731522#
    1474 #       Request a new legend from the server.  The size of the legend
    1475 #       is determined from the height of the canvas. 
     1523#    Request a new legend from the server.  The size of the legend
     1524#    is determined from the height of the canvas. 
    14761525#
    14771526# This should be called when
    1478 #       1.  A new current colormap is set.
    1479 #       2.  Window is resized.
    1480 #       3.  The limits of the data have changed.  (Just need a redraw).
    1481 #       4.  Number of glyph have changed. (Just need a redraw).
    1482 #       5.  Legend becomes visible (Just need a redraw).
     1527#    1.  A new current colormap is set.
     1528#    2.  Window is resized.
     1529#    3.  The limits of the data have changed.  (Just need a redraw).
     1530#    4.  Number of glyph have changed. (Just need a redraw).
     1531#    5.  Legend becomes visible (Just need a redraw).
    14831532#
    14841533itcl::body Rappture::VtkGlyphViewer::RequestLegend {} {
    14851534    set _legendPending 0
    1486     if { ![info exists _fields($_curFldName)] } {
    1487         return
    1488     }
     1535    set font "Arial 8"
     1536    set w 12
     1537    set lineht [font metrics $font -linespace]
     1538    # color ramp height = (canvas height) - (min and max value lines) - 2
     1539    set h [expr {$_height - 2 * ($lineht + 2)}]
     1540
    14891541    set fname $_curFldName
    1490     set font "Arial 8"
    1491     set lineht [font metrics $font -linespace]
    1492     set w 12
    1493     set h [expr {$_height - 2 * ($lineht + 2)}]
    1494     if { $h < 1 } {
    1495         return
    1496     }
    14971542    if { [string match "component*" $fname] } {
    1498         set title ""
     1543        set title ""
    14991544    } else {
    1500         if { [info exists _fields($fname)] } {
    1501             foreach { title units } $_fields($fname) break
    1502             if { $units != "" } {
    1503                 set title [format "%s (%s)" $title $units]
    1504             }
    1505         } else {
    1506             set title $fname
    1507         }
     1545        if { [info exists _fields($fname)] } {
     1546            foreach { title units } $_fields($fname) break
     1547            if { $units != "" } {
     1548                set title [format "%s (%s)" $title $units]
     1549            }
     1550        } else {
     1551            set title $fname
     1552        }
    15081553    }
    15091554    # If there's a title too, substract one more line
     
    15111556        incr h -$lineht
    15121557    }
     1558    if { $h < 1 } {
     1559        return
     1560    }
    15131561    # Set the legend on the first heightmap dataset.
    15141562    if { $_currentColormap != ""  } {
    1515         set cmap $_currentColormap
    1516         SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0"
     1563        set cmap $_currentColormap
     1564        SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0"
    15171565    }
    15181566}
     
    15341582    if { [isconnected] } {
    15351583        set rgb [Color2RGB $itk_option(-plotforeground)]
    1536         SendCmd "axis color all $rgb"
     1584        SendCmd "axis color all $rgb"
    15371585        SendCmd "outline color $rgb"
    15381586        #SendCmd "cutplane color $rgb"
    15391587    }
    1540 }
    1541 
    1542 itcl::body Rappture::VtkGlyphViewer::limits { dataobj } {
    1543     foreach { limits(xmin) limits(xmax) } [$dataobj limits x] break
    1544     foreach { limits(ymin) limits(ymax) } [$dataobj limits y] break
    1545     foreach { limits(zmin) limits(zmax) } [$dataobj limits z] break
    1546     foreach { limits(vmin) limits(vmax) } [$dataobj limits v] break
    1547     return [array get limits]
    15481588}
    15491589
     
    15601600    checkbutton $inner.glyphs \
    15611601        -text "Glyphs" \
    1562         -variable [itcl::scope _settings(glyphVisible)] \
    1563         -command [itcl::code $this AdjustSetting glyphVisible] \
     1602        -variable [itcl::scope _settings(-glyphvisible)] \
     1603        -command [itcl::code $this AdjustSetting -glyphvisible] \
    15641604        -font "Arial 9"
     1605
     1606    label $inner.gshape_l -text "Glyph shape" -font "Arial 9"
     1607    itk_component add gshape {
     1608        Rappture::Combobox $inner.gshape -width 10 -editable no
     1609    }
     1610    $inner.gshape choices insert end \
     1611        "arrow"              "arrow"           \
     1612        "cone"               "cone"            \
     1613        "cube"               "cube"            \
     1614        "cylinder"           "cylinder"        \
     1615        "dodecahedron"       "dodecahedron"    \
     1616        "icosahedron"        "icosahedron"     \
     1617        "line"               "line"            \
     1618        "octahedron"         "octahedron"      \
     1619        "point"              "point"           \
     1620        "sphere"             "sphere"          \
     1621        "tetrahedron"        "tetrahedron"
     1622
     1623    $itk_component(gshape) value $_settings(-glyphshape)
     1624    bind $inner.gshape <<Value>> [itcl::code $this AdjustSetting -glyphshape]
     1625
     1626    label $inner.scaleMode_l -text "Scale by" -font "Arial 9"
     1627    itk_component add scaleMode {
     1628        Rappture::Combobox $inner.scaleMode -width 10 -editable no
     1629    }
     1630    $inner.scaleMode choices insert end \
     1631        "scalar" "Scalar"            \
     1632        "vmag"   "Vector magnitude"  \
     1633        "vcomp"  "Vector components" \
     1634        "off"    "Constant size"
     1635
     1636    $itk_component(scaleMode) value "[$itk_component(scaleMode) label $_settings(-glyphscalemode)]"
     1637    bind $inner.scaleMode <<Value>> [itcl::code $this AdjustSetting -glyphscalemode]
     1638
     1639    checkbutton $inner.normscale \
     1640        -text "Normalize scaling" \
     1641        -variable [itcl::scope _settings(-glyphnormscale)] \
     1642        -command [itcl::code $this AdjustSetting -glyphnormscale] \
     1643        -font "Arial 9"
     1644    Rappture::Tooltip::for $inner.normscale "If enabled, field values are normalized to \[0,1\] before scaling and scale factor is relative to a default size"
     1645
     1646    checkbutton $inner.gorient \
     1647        -text "Orient" \
     1648        -variable [itcl::scope _settings(-glyphorient)] \
     1649        -command [itcl::code $this AdjustSetting -glyphorient] \
     1650        -font "Arial 9"
     1651    Rappture::Tooltip::for $inner.gorient "Orient glyphs by vector field directions"
    15651652
    15661653    checkbutton $inner.wireframe \
    15671654        -text "Wireframe" \
    1568         -variable [itcl::scope _settings(glyphWireframe)] \
    1569         -command [itcl::code $this AdjustSetting glyphWireframe] \
     1655        -variable [itcl::scope _settings(-glyphwireframe)] \
     1656        -command [itcl::code $this AdjustSetting -glyphwireframe] \
    15701657        -font "Arial 9"
    15711658
    15721659    checkbutton $inner.lighting \
    15731660        -text "Enable Lighting" \
    1574         -variable [itcl::scope _settings(glyphLighting)] \
    1575         -command [itcl::code $this AdjustSetting glyphLighting] \
     1661        -variable [itcl::scope _settings(-glyphlighting)] \
     1662        -command [itcl::code $this AdjustSetting -glyphlighting] \
    15761663        -font "Arial 9"
    15771664
    15781665    checkbutton $inner.edges \
    15791666        -text "Edges" \
    1580         -variable [itcl::scope _settings(glyphEdges)] \
    1581         -command [itcl::code $this AdjustSetting glyphEdges] \
     1667        -variable [itcl::scope _settings(-glyphedges)] \
     1668        -command [itcl::code $this AdjustSetting -glyphedges] \
    15821669        -font "Arial 9"
    15831670
    15841671    checkbutton $inner.outline \
    15851672        -text "Outline" \
    1586         -variable [itcl::scope _settings(glyphOutline)] \
    1587         -command [itcl::code $this AdjustSetting glyphOutline] \
     1673        -variable [itcl::scope _settings(-glyphoutline)] \
     1674        -command [itcl::code $this AdjustSetting -glyphoutline] \
    15881675        -font "Arial 9"
    15891676
    15901677    checkbutton $inner.legend \
    15911678        -text "Legend" \
    1592         -variable [itcl::scope _settings(legendVisible)] \
    1593         -command [itcl::code $this AdjustSetting legendVisible] \
     1679        -variable [itcl::scope _settings(-legendvisible)] \
     1680        -command [itcl::code $this AdjustSetting -legendvisible] \
    15941681        -font "Arial 9"
    15951682
     
    16031690        "grey"               "grey"             
    16041691
    1605     $itk_component(background) value $_settings(background)
    1606     bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]
     1692    $itk_component(background) value $_settings(-background)
     1693    bind $inner.background <<Value>> [itcl::code $this AdjustSetting -background]
    16071694
    16081695    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    16091696    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1610         -variable [itcl::scope _settings(glyphOpacity)] \
     1697        -variable [itcl::scope _settings(-glyphopacity)] \
    16111698        -width 10 \
    16121699        -showvalue off \
    1613         -command [itcl::code $this AdjustSetting glyphOpacity]
    1614 
    1615     label $inner.scale_l -text "Scale" -font "Arial 9"
    1616     ::scale $inner.scale -from 1 -to 100 -orient horizontal \
    1617         -variable [itcl::scope _settings(glyphs-scale)] \
     1700        -command [itcl::code $this AdjustSetting -glyphopacity]
     1701
     1702    label $inner.gscale_l -text "Scale factor" -font "Arial 9"
     1703    if {0} {
     1704    ::scale $inner.gscale -from 1 -to 100 -orient horizontal \
     1705        -variable [itcl::scope _settings(-glyphscale)] \
    16181706        -width 10 \
    16191707        -showvalue off \
    1620         -command [itcl::code $this AdjustSetting glyphs-scale]
     1708        -command [itcl::code $this AdjustSetting -glyphscale]
     1709    } else {
     1710    itk_component add gscale {
     1711        entry $inner.gscale -font "Arial 9" -bg white \
     1712            -textvariable [itcl::scope _settings(-glyphscale)]
     1713    } {
     1714        ignore -font -background
     1715    }
     1716    bind $inner.gscale <Return> \
     1717        [itcl::code $this AdjustSetting -glyphscale]
     1718    bind $inner.gscale <KP_Enter> \
     1719        [itcl::code $this AdjustSetting -glyphscale]
     1720    }
     1721    Rappture::Tooltip::for $inner.gscale "Set scaling multiplier (or constant size)"
    16211722
    16221723    itk_component add field_l {
     
    16291730    }
    16301731    bind $inner.field <<Value>> \
    1631         [itcl::code $this AdjustSetting field]
     1732        [itcl::code $this AdjustSetting -field]
    16321733
    16331734    label $inner.colormap_l -text "Colormap" -font "Arial 9"
     
    16351736        Rappture::Combobox $inner.colormap -width 10 -editable no
    16361737    }
    1637     $inner.colormap choices insert end \
    1638         "BCGYR"              "BCGYR"            \
    1639         "BGYOR"              "BGYOR"            \
    1640         "blue"               "blue"             \
    1641         "blue-to-brown"      "blue-to-brown"    \
    1642         "blue-to-orange"     "blue-to-orange"   \
    1643         "blue-to-grey"       "blue-to-grey"     \
    1644         "green-to-magenta"   "green-to-magenta" \
    1645         "greyscale"          "greyscale"        \
    1646         "nanohub"            "nanohub"          \
    1647         "rainbow"            "rainbow"          \
    1648         "spectral"           "spectral"         \
    1649         "ROYGB"              "ROYGB"            \
    1650         "RYGCB"              "RYGCB"            \
    1651         "brown-to-blue"      "brown-to-blue"    \
    1652         "grey-to-blue"       "grey-to-blue"     \
    1653         "orange-to-blue"     "orange-to-blue"   
    1654 
     1738
     1739    $inner.colormap choices insert end [GetColormapList]
    16551740    $itk_component(colormap) value "BCGYR"
    16561741    bind $inner.colormap <<Value>> \
    1657         [itcl::code $this AdjustSetting colormap]
     1742        [itcl::code $this AdjustSetting -colormap]
    16581743
    16591744    blt::table $inner \
    1660         0,0 $inner.field_l   -anchor w -pady 2  \
    1661         0,1 $inner.field     -anchor w -pady 2  -fill x \
    1662         1,0 $inner.colormap_l -anchor w -pady 2  \
    1663         1,1 $inner.colormap   -anchor w -pady 2  -fill x \
    1664         3,0 $inner.background_l -anchor w -pady 2 \
    1665         3,1 $inner.background -anchor w -pady 2  -fill x \
    1666         5,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \
    1667         6,0 $inner.lighting  -anchor w -pady 2 -cspan 2 \
    1668         7,0 $inner.edges     -anchor w -pady 2 -cspan 2 \
    1669         8,0 $inner.outline   -anchor w -pady 2 -cspan 2 \
    1670         9,0 $inner.legend    -anchor w -pady 2 \
    1671         10,0 $inner.opacity_l -anchor w -pady 2 \
    1672         10,1 $inner.opacity   -fill x   -pady 2 -fill x \
     1745        0,0 $inner.field_l      -anchor w -pady 2  \
     1746        0,1 $inner.field        -anchor w -pady 2  -fill x \
     1747        1,0 $inner.colormap_l   -anchor w -pady 2  \
     1748        1,1 $inner.colormap     -anchor w -pady 2  -fill x \
     1749        3,0 $inner.background_l -anchor w -pady 2 \
     1750        3,1 $inner.background  -anchor w -pady 2  -fill x \
     1751        5,0 $inner.wireframe    -anchor w -pady 2 -cspan 2 \
     1752        6,0 $inner.lighting     -anchor w -pady 2 -cspan 2 \
     1753        7,0 $inner.edges        -anchor w -pady 2 -cspan 2 \
     1754        8,0 $inner.outline      -anchor w -pady 2 -cspan 2 \
     1755        9,0 $inner.legend       -anchor w -pady 2 \
     1756        10,0 $inner.opacity_l   -anchor w -pady 2 \
     1757        10,1 $inner.opacity     -fill x   -pady 2 -fill x \
    16731758
    16741759    blt::table configure $inner r* c* -resize none
     
    16871772
    16881773    checkbutton $inner.visible \
    1689         -text "Show Axes" \
    1690         -variable [itcl::scope _settings(axesVisible)] \
    1691         -command [itcl::code $this AdjustSetting axesVisible] \
     1774        -text "Axes" \
     1775        -variable [itcl::scope _settings(-axesvisible)] \
     1776        -command [itcl::code $this AdjustSetting -axesvisible] \
    16921777        -font "Arial 9"
    16931778
    16941779    checkbutton $inner.labels \
    1695         -text "Show Axis Labels" \
    1696         -variable [itcl::scope _settings(axisLabelsVisible)] \
    1697         -command [itcl::code $this AdjustSetting axisLabelsVisible] \
     1780        -text "Axis Labels" \
     1781        -variable [itcl::scope _settings(-axislabels)] \
     1782        -command [itcl::code $this AdjustSetting -axislabels] \
    16981783        -font "Arial 9"
    1699 
    1700     checkbutton $inner.gridx \
    1701         -text "Show X Grid" \
    1702         -variable [itcl::scope _settings(axisXGrid)] \
    1703         -command [itcl::code $this AdjustSetting axisXGrid] \
     1784    label $inner.grid_l -text "Grid" -font "Arial 9"
     1785    checkbutton $inner.xgrid \
     1786        -text "X" \
     1787        -variable [itcl::scope _settings(-xgrid)] \
     1788        -command [itcl::code $this AdjustSetting -xgrid] \
    17041789        -font "Arial 9"
    1705     checkbutton $inner.gridy \
    1706         -text "Show Y Grid" \
    1707         -variable [itcl::scope _settings(axisYGrid)] \
    1708         -command [itcl::code $this AdjustSetting axisYGrid] \
     1790    checkbutton $inner.ygrid \
     1791        -text "Y" \
     1792        -variable [itcl::scope _settings(-ygrid)] \
     1793        -command [itcl::code $this AdjustSetting -ygrid] \
    17091794        -font "Arial 9"
    1710     checkbutton $inner.gridz \
    1711         -text "Show Z Grid" \
    1712         -variable [itcl::scope _settings(axisZGrid)] \
    1713         -command [itcl::code $this AdjustSetting axisZGrid] \
     1795    checkbutton $inner.zgrid \
     1796        -text "Z" \
     1797        -variable [itcl::scope _settings(-zgrid)] \
     1798        -command [itcl::code $this AdjustSetting -zgrid] \
     1799        -font "Arial 9"
     1800    checkbutton $inner.minorticks \
     1801        -text "Minor Ticks" \
     1802        -variable [itcl::scope _settings(-axisminorticks)] \
     1803        -command [itcl::code $this AdjustSetting -axisminorticks] \
    17141804        -font "Arial 9"
    17151805
     
    17241814        "furthest_triad"  "farthest" \
    17251815        "outer_edges"     "outer"         
    1726     $itk_component(axisMode) value "static"
    1727     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisMode]
     1816    $itk_component(axisMode) value $_settings(-axismode)
     1817    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
    17281818
    17291819    blt::table $inner \
    1730         0,0 $inner.visible -anchor w -cspan 2 \
    1731         1,0 $inner.labels  -anchor w -cspan 2 \
    1732         2,0 $inner.gridx   -anchor w -cspan 2 \
    1733         3,0 $inner.gridy   -anchor w -cspan 2 \
    1734         4,0 $inner.gridz   -anchor w -cspan 2 \
    1735         5,0 $inner.mode_l  -anchor w -cspan 2 -padx { 2 0 } \
    1736         6,0 $inner.mode    -fill x   -cspan 2
     1820        0,0 $inner.visible    -anchor w -cspan 4 \
     1821        1,0 $inner.labels     -anchor w -cspan 4 \
     1822        2,0 $inner.minorticks -anchor w -cspan 4 \
     1823        4,0 $inner.grid_l     -anchor w \
     1824        4,1 $inner.xgrid      -anchor w \
     1825        4,2 $inner.ygrid      -anchor w \
     1826        4,3 $inner.zgrid      -anchor w \
     1827        5,0 $inner.mode_l     -anchor w -padx { 2 0 } \
     1828        5,1 $inner.mode       -fill x   -cspan 3
    17371829
    17381830    blt::table configure $inner r* c* -resize none
    1739     blt::table configure $inner r7 c1 -resize expand
    1740 }
    1741 
     1831    blt::table configure $inner r7 c6 -resize expand
     1832    blt::table configure $inner r3 -height 0.125i
     1833}
    17421834
    17431835itcl::body Rappture::VtkGlyphViewer::BuildCameraTab {} {
     
    17591851        0,0 $inner.view_l -anchor e -pady 2 \
    17601852        0,1 $inner.view -anchor w -pady 2
     1853    blt::table configure $inner r0 -resize none
    17611854
    17621855    set labels { qx qy qz qw xpan ypan zoom }
     
    17651858        label $inner.${tag}label -text $tag -font "Arial 9"
    17661859        entry $inner.${tag} -font "Arial 9"  -bg white \
    1767             -textvariable [itcl::scope _view($tag)]
    1768         bind $inner.${tag} <KeyPress-Return> \
    1769             [itcl::code $this camera set ${tag}]
     1860            -textvariable [itcl::scope _view(-$tag)]
     1861        bind $inner.${tag} <Return> \
     1862            [itcl::code $this camera set -${tag}]
     1863        bind $inner.${tag} <KP_Enter> \
     1864            [itcl::code $this camera set -${tag}]
    17701865        blt::table $inner \
    17711866            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    17761871    checkbutton $inner.ortho \
    17771872        -text "Orthographic Projection" \
    1778         -variable [itcl::scope _view(ortho)] \
    1779         -command [itcl::code $this camera set ortho] \
     1873        -variable [itcl::scope _view(-ortho)] \
     1874        -command [itcl::code $this camera set -ortho] \
    17801875        -font "Arial 9"
    17811876    blt::table $inner \
     
    17841879    incr row
    17851880
    1786     blt::table configure $inner c* r* -resize none
     1881    blt::table configure $inner c* -resize none
    17871882    blt::table configure $inner c2 -resize expand
    17881883    blt::table configure $inner r$row -resize expand
     
    18011896    checkbutton $inner.visible \
    18021897        -text "Cutplanes" \
    1803         -variable [itcl::scope _settings(cutplaneVisible)] \
    1804         -command [itcl::code $this AdjustSetting cutplaneVisible] \
     1898        -variable [itcl::scope _settings(-cutplanevisible)] \
     1899        -command [itcl::code $this AdjustSetting -cutplanevisible] \
    18051900        -font "Arial 9"
    18061901
    18071902    checkbutton $inner.wireframe \
    18081903        -text "Wireframe" \
    1809         -variable [itcl::scope _settings(cutplaneWireframe)] \
    1810         -command [itcl::code $this AdjustSetting cutplaneWireframe] \
     1904        -variable [itcl::scope _settings(-cutplanewireframe)] \
     1905        -command [itcl::code $this AdjustSetting -cutplanewireframe] \
    18111906        -font "Arial 9"
    18121907
    18131908    checkbutton $inner.lighting \
    18141909        -text "Enable Lighting" \
    1815         -variable [itcl::scope _settings(cutplaneLighting)] \
    1816         -command [itcl::code $this AdjustSetting cutplaneLighting] \
     1910        -variable [itcl::scope _settings(-cutplanelighting)] \
     1911        -command [itcl::code $this AdjustSetting -cutplanelighting] \
    18171912        -font "Arial 9"
    18181913
    18191914    checkbutton $inner.edges \
    18201915        -text "Edges" \
    1821         -variable [itcl::scope _settings(cutplaneEdges)] \
    1822         -command [itcl::code $this AdjustSetting cutplaneEdges] \
     1916        -variable [itcl::scope _settings(-cutplaneedges)] \
     1917        -command [itcl::code $this AdjustSetting -cutplaneedges] \
    18231918        -font "Arial 9"
    18241919
    18251920    checkbutton $inner.preinterp \
    18261921        -text "Interpolate Scalars" \
    1827         -variable [itcl::scope _settings(cutplanePreinterp)] \
    1828         -command [itcl::code $this AdjustSetting cutplanePreinterp] \
     1922        -variable [itcl::scope _settings(-cutplanepreinterp)] \
     1923        -command [itcl::code $this AdjustSetting -cutplanepreinterp] \
    18291924        -font "Arial 9"
    18301925
    18311926    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    18321927    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1833         -variable [itcl::scope _settings(cutplaneOpacity)] \
     1928        -variable [itcl::scope _settings(-cutplaneopacity)] \
    18341929        -width 10 \
    18351930        -showvalue off \
    1836         -command [itcl::code $this AdjustSetting cutplaneOpacity]
    1837     $inner.opacity set $_settings(cutplaneOpacity)
     1931        -command [itcl::code $this AdjustSetting -cutplaneopacity]
     1932    $inner.opacity set $_settings(-cutplaneopacity)
    18381933
    18391934    # X-value slicer...
     
    18421937            -onimage [Rappture::icon x-cutplane-red] \
    18431938            -offimage [Rappture::icon x-cutplane-red] \
    1844             -command [itcl::code $this AdjustSetting cutplaneXVisible] \
    1845             -variable [itcl::scope _settings(cutplaneXVisible)] \
     1939            -command [itcl::code $this AdjustSetting -cutplanexvisible] \
     1940            -variable [itcl::scope _settings(-cutplanexvisible)] \
    18461941    }
    18471942    Rappture::Tooltip::for $itk_component(xbutton) \
     
    18531948            -borderwidth 1 -highlightthickness 0 \
    18541949            -command [itcl::code $this EventuallySetCutplane x] \
    1855             -variable [itcl::scope _settings(cutplaneXPosition)] \
    1856             -foreground red2 -font "Arial 9 bold"
     1950            -variable [itcl::scope _settings(-cutplanexposition)] \
     1951            -foreground red2 -font "Arial 9 bold"
    18571952    } {
    18581953        usual
     
    18701965            -onimage [Rappture::icon y-cutplane-green] \
    18711966            -offimage [Rappture::icon y-cutplane-green] \
    1872             -command [itcl::code $this AdjustSetting cutplaneYVisible] \
    1873             -variable [itcl::scope _settings(cutplaneYVisible)] \
     1967            -command [itcl::code $this AdjustSetting -cutplaneyvisible] \
     1968            -variable [itcl::scope _settings(-cutplaneyvisible)] \
    18741969    }
    18751970    Rappture::Tooltip::for $itk_component(ybutton) \
     
    18821977            -borderwidth 1 -highlightthickness 0 \
    18831978            -command [itcl::code $this EventuallySetCutplane y] \
    1884             -variable [itcl::scope _settings(cutplaneYPosition)] \
    1885             -foreground green3 -font "Arial 9 bold"
     1979            -variable [itcl::scope _settings(-cutplaneyposition)] \
     1980            -foreground green3 -font "Arial 9 bold"
    18861981    } {
    18871982        usual
     
    18991994            -onimage [Rappture::icon z-cutplane-blue] \
    19001995            -offimage [Rappture::icon z-cutplane-blue] \
    1901             -command [itcl::code $this AdjustSetting cutplaneZVisible] \
    1902             -variable [itcl::scope _settings(cutplaneZVisible)] \
     1996            -command [itcl::code $this AdjustSetting -cutplanezvisible] \
     1997            -variable [itcl::scope _settings(-cutplanezvisible)] \
    19031998    } {
    1904         usual
    1905         ignore -foreground
     1999        usual
     2000        ignore -foreground
    19062001    }
    19072002    Rappture::Tooltip::for $itk_component(zbutton) \
     
    19142009            -borderwidth 1 -highlightthickness 0 \
    19152010            -command [itcl::code $this EventuallySetCutplane z] \
    1916             -variable [itcl::scope _settings(cutplaneZPosition)] \
    1917             -foreground blue3 -font "Arial 9 bold"
     2011            -variable [itcl::scope _settings(-cutplanezposition)] \
     2012            -foreground blue3 -font "Arial 9 bold"
    19182013    } {
    19192014        usual
     
    19262021
    19272022    blt::table $inner \
    1928         0,0 $inner.visible              -anchor w -pady 2 -cspan 3 \
    1929         1,0 $inner.lighting             -anchor w -pady 2 -cspan 3 \
    1930         2,0 $inner.wireframe            -anchor w -pady 2 -cspan 3 \
    1931         3,0 $inner.edges                -anchor w -pady 2 -cspan 3 \
    1932         4,0 $inner.preinterp            -anchor w -pady 2 -cspan 3 \
    1933         5,0 $inner.opacity_l            -anchor w -pady 2 -cspan 1 \
    1934         5,1 $inner.opacity              -fill x   -pady 2 -cspan 3 \
    1935         6,0 $inner.xbutton              -anchor w -padx 2 -pady 2 \
    1936         7,0 $inner.ybutton              -anchor w -padx 2 -pady 2 \
    1937         8,0 $inner.zbutton              -anchor w -padx 2 -pady 2 \
    1938         6,1 $inner.xval                 -fill y -rspan 4 \
    1939         6,2 $inner.yval                 -fill y -rspan 4 \
    1940         6,3 $inner.zval                 -fill y -rspan 4 \
    1941 
     2023        0,0 $inner.visible   -anchor w -pady 2 -cspan 3 \
     2024        1,0 $inner.lighting  -anchor w -pady 2 -cspan 3 \
     2025        2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \
     2026        3,0 $inner.edges     -anchor w -pady 2 -cspan 3 \
     2027        4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \
     2028        5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \
     2029        5,1 $inner.opacity   -fill x   -pady 2 -cspan 3 \
     2030        6,0 $inner.xbutton   -anchor w -padx 2 -pady 2 \
     2031        7,0 $inner.ybutton   -anchor w -padx 2 -pady 2 \
     2032        8,0 $inner.zbutton   -anchor w -padx 2 -pady 2 \
     2033        6,1 $inner.xval      -fill y -rspan 4 \
     2034        6,2 $inner.yval      -fill y -rspan 4 \
     2035        6,3 $inner.zval      -fill y -rspan 4 \
    19422036
    19432037    blt::table configure $inner r* c* -resize none
    19442038    blt::table configure $inner r9 c4 -resize expand
    19452039}
    1946 
    1947 
    19482040
    19492041#
     
    19562048        }
    19572049        "set" {
    1958             set who [lindex $args 0]
    1959             set x $_view($who)
     2050            set what [lindex $args 0]
     2051            set x $_view($what)
    19602052            set code [catch { string is double $x } result]
    19612053            if { $code != 0 || !$result } {
    19622054                return
    19632055            }
    1964             switch -- $who {
    1965                 "ortho" {
    1966                     if {$_view(ortho)} {
     2056            switch -- $what {
     2057                "-ortho" {
     2058                    if {$_view($what)} {
    19672059                        SendCmd "camera mode ortho"
    19682060                    } else {
     
    19702062                    }
    19712063                }
    1972                 "xpan" - "ypan" {
     2064                "-xpan" - "-ypan" {
    19732065                    PanCamera
    19742066                }
    1975                 "qx" - "qy" - "qz" - "qw" {
    1976                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2067                "-qx" - "-qy" - "-qz" - "-qw" {
     2068                    set q [ViewToQuaternion]
    19772069                    $_arcball quaternion $q
    19782070                    EventuallyRotate $q
    19792071                }
    1980                 "zoom" {
    1981                     SendCmd "camera zoom $_view(zoom)"
     2072                "-zoom" {
     2073                    SendCmd "camera zoom $_view($what)"
    19822074                }
    19832075             }
     
    20972189    # the code to handle aberrant cases.
    20982190
    2099     if { $_changed(glyphOpacity) } {
    2100         set style(-opacity) $_settings(glyphOpacity)
    2101     }
    2102     if { $_changed(colormap) } {
    2103         set style(-color) $_settings(colormap)
     2191    if { $_changed(-glyphopacity) } {
     2192        set style(-opacity) [expr $_settings(-glyphopacity) * 0.01]
     2193    }
     2194    if { $_changed(-colormap) } {
     2195        set style(-color) $_settings(-colormap)
    21042196    }
    21052197    if { $_currentColormap == "" } {
    21062198        $itk_component(colormap) value $style(-color)
    21072199    }
    2108     set _currentOpacity $style(-opacity)
     2200
     2201    SendCmd "outline add $tag"
     2202    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
     2203    SendCmd "outline visible $style(-outline) $tag"
     2204    set _settings(-glyphoutline) $style(-outline)
     2205
    21092206    SendCmd "glyphs add $style(-shape) $tag"
     2207    set _settings(-glyphshape) $style(-shape)
     2208    $itk_component(gshape) value $style(-shape)
    21102209    SendCmd "glyphs edges $style(-edges) $tag"
     2210    set _settings(-glyphedges) $style(-edges)
     2211
    21112212    # normscale=1 and gscale=1 are defaults
    21122213    if {$style(-normscale) != 1} {
     
    21162217        SendCmd "glyphs gscale $style(-gscale) $tag"
    21172218    }
    2118     SendCmd "outline add $tag"
    2119     SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
    2120     SendCmd "outline visible $style(-outline) $tag"
    2121     set _settings(glyphOutline) $style(-outline)
    2122     set _settings(glyphEdges) $style(-edges)
     2219    set _settings(-glyphnormscale) $style(-normscale)
     2220    set _settings(-glyphscale) $style(-gscale)
     2221
    21232222    # constant color only used if colormode set to constant
    21242223    SendCmd "glyphs color [Color2RGB $itk_option(-plotforeground)] $tag"
     
    21262225    # defaults to active scalars or vectors depending on mode
    21272226    SendCmd "glyphs gorient $style(-orientGlyphs) {} $tag"
     2227    set _settings(-glyphorient) $style(-orientGlyphs)
    21282228    SendCmd "glyphs smode $style(-scaleMode) {} $tag"
     2229    set _settings(-glyphscalemode) $style(-scaleMode)
     2230    $itk_component(scaleMode) value "[$itk_component(scaleMode) label $style(-scaleMode)]"
    21292231    SendCmd "glyphs quality $style(-quality) $tag"
    21302232    SendCmd "glyphs lighting $style(-lighting) $tag"
    2131     set _settings(glyphLighting) $style(-lighting)
     2233    set _settings(-glyphlighting) $style(-lighting)
    21322234    SendCmd "glyphs linecolor [Color2RGB $style(-edgecolor)] $tag"
    21332235    SendCmd "glyphs linewidth $style(-linewidth) $tag"
    21342236    SendCmd "glyphs ptsize $style(-ptsize) $tag"
    2135     SendCmd "glyphs opacity $_currentOpacity $tag"
    2136     set _settings(glyphOpacity) $style(-opacity)
     2237    SendCmd "glyphs opacity $style(-opacity) $tag"
     2238    set _settings(-glyphopacity) [expr $style(-opacity) * 100.0]
    21372239    SetCurrentColormap $style(-color)
    21382240    SendCmd "glyphs wireframe $style(-wireframe) $tag"
    2139     set _settings(glyphWireframe) $style(-wireframe)
    2140     set _settings(glyphOpacity) [expr $style(-opacity) * 100.0]
     2241    set _settings(-glyphwireframe) $style(-wireframe)
    21412242}
    21422243
     
    21922293
    21932294    if { [string match "component*" $fname] } {
    2194         set title ""
     2295        set title ""
    21952296    } else {
    2196         if { [info exists _fields($fname)] } {
    2197             foreach { title units } $_fields($fname) break
    2198             if { $units != "" } {
    2199                 set title [format "%s (%s)" $title $units]
    2200             }
    2201         } else {
    2202             set title $fname
    2203         }
     2297        if { [info exists _fields($fname)] } {
     2298            foreach { title units } $_fields($fname) break
     2299            if { $units != "" } {
     2300                set title [format "%s (%s)" $title $units]
     2301            }
     2302        } else {
     2303            set title $fname
     2304        }
    22042305    }
    22052306    # If there's a legend title, increase the offset by the line height.
     
    22332334}
    22342335
    2235 
    22362336# ----------------------------------------------------------------------
    22372337# USAGE: Slice move x|y|z <newval>
     
    22672367# ReceiveLegend --
    22682368#
    2269 #       Invoked automatically whenever the "legend" command comes in from
    2270 #       the rendering server.  Indicates that binary image data with the
    2271 #       specified <size> will follow.
     2369#    Invoked automatically whenever the "legend" command comes in from
     2370#    the rendering server.  Indicates that binary image data with the
     2371#    specified <size> will follow.
    22722372#
    22732373itcl::body Rappture::VtkGlyphViewer::ReceiveLegend { colormap title min max size } {
     
    22832383        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    22842384        if { [catch {DrawLegend} errs] != 0 } {
    2285             global errorInfo
    2286             puts stderr "errs=$errs errorInfo=$errorInfo"
     2385            global errorInfo
     2386            puts stderr "errs=$errs errorInfo=$errorInfo"
    22872387        }
    22882388    }
     
    22922392# DrawLegend --
    22932393#
    2294 #       Draws the legend in the own canvas on the right side of the plot area.
     2394#    Draws the legend in the own canvas on the right side of the plot area.
    22952395#
    22962396itcl::body Rappture::VtkGlyphViewer::DrawLegend {} {
     
    23032403   
    23042404    if { [string match "component*" $fname] } {
    2305         set title ""
     2405        set title ""
    23062406    } else {
    2307         if { [info exists _fields($fname)] } {
    2308             foreach { title units } $_fields($fname) break
    2309             if { $units != "" } {
    2310                 set title [format "%s (%s)" $title $units]
    2311             }
    2312         } else {
    2313             set title $fname
    2314         }
     2407        if { [info exists _fields($fname)] } {
     2408            foreach { title units } $_fields($fname) break
     2409            if { $units != "" } {
     2410                set title [format "%s (%s)" $title $units]
     2411            }
     2412        } else {
     2413            set title $fname
     2414        }
    23152415    }
    23162416    set x [expr $w - 2]
    2317     if { !$_settings(legendVisible) } {
    2318         $c delete legend
    2319         return
     2417    if { !$_settings(-legendvisible) } {
     2418        $c delete legend
     2419        return
    23202420    }
    23212421    if { [$c find withtag "legend"] == "" } {
    2322         set y 2
    2323         # If there's a legend title, create a text item for the title.
     2422        set y 2
     2423        # If there's a legend title, create a text item for the title.
    23242424        $c create text $x $y \
    2325                 -anchor ne \
    2326                 -fill $itk_option(-plotforeground) -tags "title legend" \
    2327                 -font $font
    2328             incr y $lineht
    2329         $c create text $x $y \
    2330             -anchor ne \
    2331             -fill $itk_option(-plotforeground) -tags "vmax legend" \
    2332             -font $font
    2333         incr y $lineht
    2334         $c create image $x $y \
    2335             -anchor ne \
    2336             -image $_image(legend) -tags "colormap legend"
    2337         $c create rectangle $x $y 1 1 \
    2338             -fill "" -outline "" -tags "sensor legend"
    2339         $c create text $x [expr {$h-2}] \
    2340             -anchor se \
    2341             -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2342             -font $font
    2343         $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
    2344         $c bind sensor <Leave> [itcl::code $this LeaveLegend]
    2345         $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
     2425            -anchor ne \
     2426            -fill $itk_option(-plotforeground) -tags "title legend" \
     2427            -font $font
     2428        if { $title != "" } {
     2429            incr y $lineht
     2430        }
     2431        $c create text $x $y \
     2432            -anchor ne \
     2433            -fill $itk_option(-plotforeground) -tags "vmax legend" \
     2434            -font $font
     2435        incr y $lineht
     2436        $c create image $x $y \
     2437            -anchor ne \
     2438            -image $_image(legend) -tags "colormap legend"
     2439        $c create rectangle $x $y 1 1 \
     2440            -fill "" -outline "" -tags "sensor legend"
     2441        $c create text $x [expr {$h-2}] \
     2442            -anchor se \
     2443            -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2444            -font $font
     2445        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
     2446        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2447        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
    23462448    }
    23472449    set x2 $x
     
    23572459    if { [info exists _limits($_curFldName)] } {
    23582460        foreach { vmin vmax } $_limits($_curFldName) break
    2359         $c itemconfigure vmin -text [format %g $vmin]
    2360         $c itemconfigure vmax -text [format %g $vmax]
     2461        $c itemconfigure vmin -text [format %g $vmin]
     2462        $c itemconfigure vmax -text [format %g $vmax]
    23612463    }
    23622464    set y 2
     
    23642466    if { $title != "" } {
    23652467        $c itemconfigure title -text $title
    2366         $c coords title $x $y
    2367         incr y $lineht
     2468        $c coords title $x $y
     2469        incr y $lineht
    23682470        $c raise title
    23692471    }
     
    24072509        invoke {
    24082510            $itk_component(field) value $_curFldLabel
    2409             AdjustSetting field
     2511            AdjustSetting -field
    24102512        }
    24112513        default {
     
    24312533# BuildColormap --
    24322534#
    2433 #       Build the designated colormap on the server.
     2535#    Build the designated colormap on the server.
    24342536#
    24352537itcl::body Rappture::VtkGlyphViewer::BuildColormap { name } {
     
    24512553        bottom "0.707107 0.707107 0 0"
    24522554    }
    2453     foreach name { qw qx qy qz } value $positions($side) {
     2555    foreach name { -qw -qx -qy -qz } value $positions($side) {
    24542556        set _view($name) $value
    2455     } 
    2456     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2557    }
     2558    set q [ViewToQuaternion]
    24572559    $_arcball quaternion $q
    24582560    SendCmd "camera orient $q"
    24592561    SendCmd "camera reset"
    2460     set _view(xpan) 0
    2461     set _view(ypan) 0
    2462     set _view(zoom) 1.0
    2463 }
    2464 
     2562    set _view(-xpan) 0
     2563    set _view(-ypan) 0
     2564    set _view(-zoom) 1.0
     2565}
Note: See TracChangeset for help on using the changeset viewer.