Ignore:
Timestamp:
Nov 14, 2014 3:32:10 AM (10 years ago)
Author:
ldelgass
Message:

port some refactoring changes to vtkvolumeviewer from trunk

File:
1 edited

Legend:

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

    r4670 r4729  
    6161    }
    6262    public method scale {args}
     63
     64    private method SetOrientation { side }
     65    private method ViewToQuaternion {} {
     66        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     67    }
     68    private method QuaternionToView { q } {
     69        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     70    }
    6371
    6472    protected method Connect {}
     
    140148    private variable _curFldLabel ""
    141149    private variable _colorMode "vmag";#  Mode of colormap (vmag or scalar)
     150    private variable _cutplaneCmd "cutplane"
    142151}
    143152
     
    175184    $_dispatcher register !xcutplane
    176185    $_dispatcher dispatch $this !xcutplane \
    177         "[itcl::code $this AdjustSetting cutplane-xposition]; list"
     186        "[itcl::code $this AdjustSetting -xcutplaneposition]; list"
    178187
    179188    # Y-Cutplane event
    180189    $_dispatcher register !ycutplane
    181190    $_dispatcher dispatch $this !ycutplane \
    182         "[itcl::code $this AdjustSetting cutplane-yposition]; list"
     191        "[itcl::code $this AdjustSetting -ycutplaneposition]; list"
    183192
    184193    # Z-Cutplane event
    185194    $_dispatcher register !zcutplane
    186195    $_dispatcher dispatch $this !zcutplane \
    187         "[itcl::code $this AdjustSetting cutplane-zposition]; list"
     196        "[itcl::code $this AdjustSetting -zcutplaneposition]; list"
    188197
    189198    #
     
    196205    # Initialize the view to some default parameters.
    197206    array set _view {
    198         qw              0.853553
    199         qx              -0.353553
    200         qy              0.353553
    201         qz              0.146447
    202         zoom            1.0
    203         xpan            0
    204         ypan            0
    205         ortho           0
     207        -qw              0.853553
     208        -qx              -0.353553
     209        -qy              0.353553
     210        -qz              0.146447
     211        -zoom            1.0
     212        -xpan            0
     213        -ypan            0
     214        -ortho           0
    206215    }
    207216    set _arcball [blt::arcball create 100 100]
    208     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    209     $_arcball quaternion $q
     217    $_arcball quaternion [ViewToQuaternion]
    210218
    211219    array set _settings {
    212         axis-xgrid              0
    213         axis-ygrid              0
    214         axis-zgrid              0
    215         axesVisible             1
    216         axisLabels              1
    217         background              black
    218         cutplaneEdges           0
    219         cutplane-xvisible       1
    220         cutplane-yvisible       1
    221         cutplane-zvisible       1
    222         cutplane-xposition      50
    223         cutplane-yposition      50
    224         cutplane-zposition      50
    225         cutplaneVisible         0
    226         cutplaneLighting        1
    227         cutplaneWireframe       0
    228         cutplane-opacity        100
    229         legendVisible           1
    230         outline                 0
    231         volumeLighting          1
    232         volume-material         80
    233         volume-opacity          40
    234         volume-quality          50
    235         volumeVisible           1
    236         legendVisible           1
     220        -axesvisible                    1
     221        -axisflymode                    static
     222        -axislabels                     1
     223        -axisminorticks                 1
     224        -background                     black
     225        -cutplaneedges                  0
     226        -cutplanelighting               1
     227        -cutplaneopacity                100
     228        -cutplanesvisible               0
     229        -cutplanewireframe              0
     230        -legendvisible                  1
     231        -volumelighting                 1
     232        -volumematerial                 80
     233        -volumeopacity                  50
     234        -volumeoutline                  0
     235        -volumequality                  80
     236        -volumevisible                  1
     237        -xcutplaneposition              50
     238        -xcutplanevisible               1
     239        -xgrid                          0
     240        -ycutplaneposition              50
     241        -ycutplanevisible               1
     242        -ygrid                          0
     243        -zcutplaneposition              50
     244        -zcutplanevisible               1
     245        -zgrid                          0
    237246    }
    238247
     
    313322            -onimage [Rappture::icon volume-on] \
    314323            -offimage [Rappture::icon volume-off] \
    315             -variable [itcl::scope _settings(volumeVisible)] \
    316             -command [itcl::code $this AdjustSetting volumeVisible]
     324            -variable [itcl::scope _settings(-volumevisible)] \
     325            -command [itcl::code $this AdjustSetting -volumevisible]
    317326    }
    318327    $itk_component(volume) select
     
    325334            -onimage [Rappture::icon cutbutton] \
    326335            -offimage [Rappture::icon cutbutton] \
    327             -variable [itcl::scope _settings(cutplaneVisible)] \
    328             -command [itcl::code $this AdjustSetting cutplaneVisible]
     336            -variable [itcl::scope _settings(-cutplanesvisible)] \
     337            -command [itcl::code $this AdjustSetting -cutplanesvisible]
    329338    }
    330339    Rappture::Tooltip::for $itk_component(cutplane) \
     
    446455
    447456itcl::body Rappture::VtkVolumeViewer::DoRotate {} {
    448     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    449     SendCmd "camera orient $q"
     457    SendCmd "camera orient [ViewToQuaternion]"
    450458    set _rotatePending 0
    451459}
     
    464472
    465473itcl::body Rappture::VtkVolumeViewer::EventuallyRotate { q } {
    466     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     474    QuaternionToView $q
    467475    if { !$_rotatePending } {
    468476        set _rotatePending 1
     
    809817    array unset _dataset2style
    810818    array unset _obj2datasets
     819
     820    set _resizePending 0
     821    set _rotatePending 0
     822    set _cutplanePending 0
     823    set _legendPending 0
     824    set _reset 1
    811825}
    812826
     
    901915    set w [winfo width $itk_component(view)]
    902916    set h [winfo height $itk_component(view)]
     917
    903918    if { $w < 2 || $h < 2 } {
    904919        $_dispatcher event -idle !rebuild
     
    923938        # Reset the camera and other view parameters
    924939        #
    925         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    926         $_arcball quaternion $q
    927         if {$_view(ortho)} {
     940        $_arcball quaternion [ViewToQuaternion]
     941        if {$_view(-ortho)} {
    928942            SendCmd "camera mode ortho"
    929943        } else {
     
    931945        }
    932946        DoRotate
    933         InitSettings outline background \
    934             axis-xgrid axis-ygrid axis-zgrid axisFlyMode \
    935             axesVisible axisLabels
     947        InitSettings -volumeoutline -background \
     948            -xgrid -ygrid -zgrid -axisflymode \
     949            -axesvisible -axislabels -axisminorticks
    936950        PanCamera
    937951    }
     
    10221036    }
    10231037
    1024     InitSettings volume-palette volume-material volume-quality volumeVisible \
    1025         cutplaneVisible \
    1026         cutplane-xposition cutplane-yposition cutplane-zposition \
    1027         cutplane-xvisible cutplane-yvisible cutplane-zvisible
     1038    InitSettings -volumepalette \
     1039        -volumematerial \
     1040        -volumeopacity -volumequality -volumevisible \
     1041        -cutplanesvisible \
     1042        -xcutplaneposition -ycutplaneposition -zcutplaneposition \
     1043        -xcutplanevisible -ycutplanevisible -zcutplanevisible
    10281044
    10291045    if { $_reset } {
    1030         InitSettings volumeLighting
     1046        InitSettings -volumelighting
    10311047        Zoom reset
    10321048        set _reset 0
     
    10951111    switch -- $option {
    10961112        "in" {
    1097             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1098             SendCmd "camera zoom $_view(zoom)"
     1113            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1114            SendCmd "camera zoom $_view(-zoom)"
    10991115        }
    11001116        "out" {
    1101             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1102             SendCmd "camera zoom $_view(zoom)"
     1117            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1118            SendCmd "camera zoom $_view(-zoom)"
    11031119        }
    11041120        "reset" {
    11051121            array set _view {
    1106                 qw      0.853553
    1107                 qx      -0.353553
    1108                 qy      0.353553
    1109                 qz      0.146447
    1110                 zoom    1.0
    1111                 xpan   0
    1112                 ypan   0
     1122                -qw      0.853553
     1123                -qx      -0.353553
     1124                -qy      0.353553
     1125                -qz      0.146447
     1126                -zoom    1.0
     1127                -xpan   0
     1128                -ypan   0
    11131129            }
    11141130            if { $_first != "" } {
     
    11181134                }
    11191135            }
    1120             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1121             $_arcball quaternion $q
     1136            $_arcball quaternion [ViewToQuaternion]
    11221137            DoRotate
    11231138            SendCmd "camera reset"
     
    11271142
    11281143itcl::body Rappture::VtkVolumeViewer::PanCamera {} {
    1129     set x $_view(xpan)
    1130     set y $_view(ypan)
     1144    set x $_view(-xpan)
     1145    set y $_view(-ypan)
    11311146    SendCmd "camera pan $x $y"
    11321147}
     
    12061221            set x [expr $x / double($w)]
    12071222            set y [expr $y / double($h)]
    1208             set _view(xpan) [expr $_view(xpan) + $x]
    1209             set _view(ypan) [expr $_view(ypan) + $y]
     1223            set _view(-xpan) [expr $_view(-xpan) + $x]
     1224            set _view(-ypan) [expr $_view(-ypan) + $y]
    12101225            PanCamera
    12111226            return
     
    12291244            set _click(x) $x
    12301245            set _click(y) $y
    1231             set _view(xpan) [expr $_view(xpan) - $dx]
    1232             set _view(ypan) [expr $_view(ypan) - $dy]
     1246            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1247            set _view(-ypan) [expr $_view(-ypan) - $dy]
    12331248            PanCamera
    12341249        }
     
    12521267itcl::body Rappture::VtkVolumeViewer::InitSettings { args } {
    12531268    foreach spec $args {
    1254         if { [info exists _settings($_first-$spec)] } {
     1269        if { [info exists _settings($_first${spec})] } {
    12551270            # Reset global setting with dataobj specific setting
    1256             set _settings($spec) $_settings($_first-$spec)
     1271            set _settings($spec) $_settings($_first${spec})
    12571272        }
    12581273        AdjustSetting $spec
     
    12721287    }
    12731288    switch -- $what {
    1274         "background" {
     1289        "-background" {
    12751290            set bgcolor [$itk_component(background) value]
     1291            set _settings($what) $bgcolor
    12761292            array set fgcolors {
    12771293                "black" "white"
     
    12841300            DrawLegend
    12851301        }
    1286         "outline" {
     1302        "-volumeoutline" {
    12871303            set bool $_settings($what)
    12881304            SendCmd "outline visible 0"
     
    12911307            }
    12921308        }
    1293         "legendVisible" {
     1309        "-legendvisible" {
    12941310            set bool $_settings($what)
    1295             set _settings($_current-$what) $bool
    1296         }
    1297         "volumeVisible" {
     1311        }
     1312        "-volumevisible" {
    12981313            set bool $_settings($what)
    1299             foreach dataset [CurrentDatasets -visible] {
    1300                 SendCmd "volume visible $bool $dataset"
     1314            foreach tag [CurrentDatasets -visible] {
     1315                SendCmd "volume visible $bool $tag"
    13011316            }
    13021317            if { $bool } {
     
    13081323            }
    13091324        }
    1310         "volume-material" {
     1325        "-volumematerial" {
    13111326            set val $_settings($what)
    13121327            set diffuse [expr {0.01*$val}]
     
    13141329            #set power [expr {sqrt(160*$val+1.0)}]
    13151330            set power [expr {$val+1.0}]
    1316             foreach dataset [CurrentDatasets -visible] {
    1317                 SendCmd "volume shading diffuse $diffuse $dataset"
    1318                 SendCmd "volume shading specular $specular $power $dataset"
    1319             }
    1320         }
    1321         "volumeLighting" {
     1331            foreach tag [CurrentDatasets -visible] {
     1332                SendCmd "volume shading diffuse $diffuse $tag"
     1333                SendCmd "volume shading specular $specular $power $tag"
     1334            }
     1335        }
     1336        "-volumelighting" {
    13221337            set bool $_settings($what)
    1323             foreach dataset [CurrentDatasets -visible] {
    1324                 SendCmd "volume lighting $bool $dataset"
    1325             }
    1326         }
    1327         "volume-quality" {
     1338            foreach tag [CurrentDatasets -visible] {
     1339                SendCmd "volume lighting $bool $tag"
     1340            }
     1341        }
     1342        "-volumeopacity" {
    13281343            set val $_settings($what)
    13291344            set val [expr {0.01*$val}]
    1330             foreach dataset [CurrentDatasets -visible] {
    1331                 SendCmd "volume quality $val $dataset"
    1332             }
    1333         }
    1334         "axesVisible" {
     1345            foreach tag [CurrentDatasets -visible] {
     1346                SendCmd "volume opacity $val $tag"
     1347            }
     1348        }
     1349        "-volumequality" {
     1350            set val $_settings($what)
     1351            set val [expr {0.01*$val}]
     1352            foreach tag [CurrentDatasets -visible] {
     1353                SendCmd "volume quality $val $tag"
     1354            }
     1355        }
     1356        "-axesvisible" {
    13351357            set bool $_settings($what)
    13361358            SendCmd "axis visible all $bool"
    13371359        }
    1338         "axisLabels" {
     1360        "-axislabels" {
    13391361            set bool $_settings($what)
    13401362            SendCmd "axis labels all $bool"
    13411363        }
    1342         "axis-xgrid" - "axis-ygrid" - "axis-zgrid" {
    1343             set axis [string range $what 5 5]
     1364        "-axisminorticks" {
     1365            set bool $_settings($what)
     1366            SendCmd "axis minticks all $bool"
     1367        }
     1368        "-xgrid" - "-ygrid" - "-zgrid" {
     1369            set axis [string range $what 1 1]
    13441370            set bool $_settings($what)
    13451371            SendCmd "axis grid $axis $bool"
    13461372        }
    1347         "axisFlyMode" {
     1373        "-axisflymode" {
    13481374            set mode [$itk_component(axismode) value]
    13491375            set mode [$itk_component(axismode) translate $mode]
     
    13511377            SendCmd "axis flymode $mode"
    13521378        }
    1353         "cutplaneEdges" {
     1379        "-cutplaneedges" {
    13541380            set bool $_settings($what)
    13551381            foreach dataset [CurrentDatasets -visible] {
    1356                 SendCmd "cutplane edges $bool $dataset"
    1357             }
    1358         }
    1359         "cutplaneVisible" {
     1382                SendCmd "$_cutplaneCmd edges $bool $dataset"
     1383            }
     1384        }
     1385        "-cutplanesvisible" {
    13601386            set bool $_settings($what)
    13611387            foreach dataset [CurrentDatasets -visible] {
    1362                 SendCmd "cutplane visible $bool $dataset"
    1363             }
    1364         }
    1365         "cutplaneWireframe" {
     1388                SendCmd "$_cutplaneCmd visible $bool $dataset"
     1389            }
     1390        }
     1391        "-cutplanewireframe" {
    13661392            set bool $_settings($what)
    13671393            foreach dataset [CurrentDatasets -visible] {
    1368                 SendCmd "cutplane wireframe $bool $dataset"
    1369             }
    1370         }
    1371         "cutplaneLighting" {
     1394                SendCmd "$_cutplaneCmd wireframe $bool $dataset"
     1395            }
     1396        }
     1397        "-cutplanelighting" {
    13721398            set bool $_settings($what)
    13731399            foreach dataset [CurrentDatasets -visible] {
    1374                 SendCmd "cutplane lighting $bool $dataset"
    1375             }
    1376         }
    1377         "cutplane-opacity" {
     1400                SendCmd "$_cutplaneCmd lighting $bool $dataset"
     1401            }
     1402        }
     1403        "-cutplaneopacity" {
    13781404            set val $_settings($what)
    13791405            set sval [expr { 0.01 * double($val) }]
    13801406            foreach dataset [CurrentDatasets -visible] {
    1381                 SendCmd "cutplane opacity $sval $dataset"
    1382             }
    1383         }
    1384         "cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" {
    1385             set axis [string range $what 9 9]
     1407                SendCmd "$_cutplaneCmd opacity $sval $dataset"
     1408            }
     1409        }
     1410        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
     1411            set axis [string range $what 1 1]
    13861412            set bool $_settings($what)
    13871413            if { $bool } {
     
    13931419            }
    13941420            foreach dataset [CurrentDatasets -visible] {
    1395                 SendCmd "cutplane axis $axis $bool $dataset"
    1396             }
    1397         }
    1398         "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" {
    1399             set axis [string range $what 9 9]
     1421                SendCmd "$_cutplaneCmd axis $axis $bool $dataset"
     1422            }
     1423        }
     1424        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
     1425            set axis [string range $what 1 1]
    14001426            set pos [expr $_settings($what) * 0.01]
    14011427            foreach dataset [CurrentDatasets -visible] {
    1402                 SendCmd "cutplane slice ${axis} ${pos} $dataset"
     1428                SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset"
    14031429            }
    14041430            set _cutplanePending 0
    14051431        }
    1406         "volume-palette" {
     1432        "-volumepalette" {
    14071433            set palette [$itk_component(palette) value]
    14081434            set _settings($what) $palette
     
    14131439            set _legendPending 1
    14141440        }
    1415         "field" {
     1441        "-field" {
    14161442            set label [$itk_component(field) value]
    14171443            set fname [$itk_component(field) translate $label]
     
    14331459            foreach dataset [CurrentDatasets -visible $_first] {
    14341460                #SendCmd "volume colormode $_colorMode ${fname} $dataset"
    1435                 SendCmd "cutplane colormode $_colorMode ${fname} $dataset"
     1461                SendCmd "$_cutplaneCmd colormode $_colorMode ${fname} $dataset"
    14361462            }
    14371463            SendCmd "camera reset"
     
    15171543         $_dataset2style($tag) != $name } {
    15181544        SendCmd "volume colormap $name $tag"
    1519         SendCmd "cutplane colormap $name-opaque $tag"
     1545        SendCmd "$_cutplaneCmd colormap $name-opaque $tag"
    15201546        set _dataset2style($tag) $name
    15211547    }
     
    15311557        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    15321558    }
    1533     if { ![info exists _settings(volume-opacity)] } {
    1534         set _settings(volume-opacity) $style(-opacity)
    1535     }
    1536     set max $_settings(volume-opacity)
     1559    if { ![info exists _settings(-volumeopacity)] } {
     1560        set _settings(-volumeopacity) $style(-opacity)
     1561    }
     1562    set max $_settings(-volumeopacity)
    15371563
    15381564    set opaqueWmap "0.0 1.0 1.0 1.0"
     
    15651591        SendCmd "axis color all $rgb"
    15661592        SendCmd "outline color $rgb"
    1567         SendCmd "cutplane color $rgb"
     1593        SendCmd "$_cutplaneCmd color $rgb"
    15681594        $itk_component(legend) itemconfigure labels -fill $color
    15691595        $itk_component(legend) itemconfigure limits -fill $color
     
    15721598
    15731599itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} {
    1574     set font [option get $itk_component(hull) font Font]
    1575     #set bfont [option get $itk_component(hull) boldFont Font]
     1600    set fg [option get $itk_component(hull) font Font]
     1601    #set bfg [option get $itk_component(hull) boldFont Font]
    15761602
    15771603    set inner [$itk_component(main) insert end \
     
    15821608    checkbutton $inner.axes \
    15831609        -text "Axes" \
    1584         -variable [itcl::scope _settings(axesVisible)] \
    1585         -command [itcl::code $this AdjustSetting axesVisible] \
     1610        -variable [itcl::scope _settings(-axesvisible)] \
     1611        -command [itcl::code $this AdjustSetting -axesvisible] \
    15861612        -font "Arial 9"
    15871613
    15881614    checkbutton $inner.outline \
    15891615        -text "Outline" \
    1590         -variable [itcl::scope _settings(outline)] \
    1591         -command [itcl::code $this AdjustSetting outline] \
     1616        -variable [itcl::scope _settings(-volumeoutline)] \
     1617        -command [itcl::code $this AdjustSetting -volumeoutline] \
    15921618        -font "Arial 9"
    15931619
    15941620    checkbutton $inner.legend \
    15951621        -text "Legend" \
    1596         -variable [itcl::scope _settings(legendVisible)] \
    1597         -command [itcl::code $this AdjustSetting legendVisible] \
     1622        -variable [itcl::scope _settings(-legendvisible)] \
     1623        -command [itcl::code $this AdjustSetting -legendvisible] \
    15981624        -font "Arial 9"
    15991625
    16001626    checkbutton $inner.volume \
    16011627        -text "Volume" \
    1602         -variable [itcl::scope _settings(volumeVisible)] \
    1603         -command [itcl::code $this AdjustSetting volumeVisible] \
     1628        -variable [itcl::scope _settings(-volumevisible)] \
     1629        -command [itcl::code $this AdjustSetting -volumevisible] \
    16041630        -font "Arial 9"
    16051631
     
    16131639        "grey"               "grey"             
    16141640
    1615     $itk_component(background) value $_settings(background)
     1641    $itk_component(background) value $_settings(-background)
    16161642    bind $inner.background <<Value>> \
    1617         [itcl::code $this AdjustSetting background]
     1643        [itcl::code $this AdjustSetting -background]
    16181644
    16191645    blt::table $inner \
     
    16381664    $inner configure -borderwidth 4
    16391665
    1640     checkbutton $inner.volume \
    1641         -text "Show Volume" \
    1642         -variable [itcl::scope _settings(volumeVisible)] \
    1643         -command [itcl::code $this AdjustSetting volumeVisible] \
    1644         -font "Arial 9"
     1666    checkbutton $inner.visibility \
     1667        -text "Visible" \
     1668        -font $font \
     1669        -variable [itcl::scope _settings(-volumevisible)] \
     1670        -command [itcl::code $this AdjustSetting -volumevisible]
    16451671
    16461672    checkbutton $inner.lighting \
    16471673        -text "Enable Lighting" \
    1648         -variable [itcl::scope _settings(volumeLighting)] \
    1649         -command [itcl::code $this AdjustSetting volumeLighting] \
    1650         -font "Arial 9"
    1651 
    1652     label $inner.dim_l -text "Dim" -font "Arial 9"
     1674        -font $font \
     1675        -variable [itcl::scope _settings(-volumelighting)] \
     1676        -command [itcl::code $this AdjustSetting -volumelighting]
     1677
     1678    label $inner.dim_l -text "Dim" -font $font
    16531679    ::scale $inner.material -from 0 -to 100 -orient horizontal \
    1654         -variable [itcl::scope _settings(volume-material)] \
    1655         -width 10 \
    1656         -showvalue off -command [itcl::code $this AdjustSetting volume-material]
    1657     label $inner.bright_l -text "Bright" -font "Arial 9"
    1658 
    1659     label $inner.opacity_l -text "Opacity" -font "Arial 9"
     1680        -variable [itcl::scope _settings(-volumematerial)] \
     1681        -showvalue off -command [itcl::code $this AdjustSetting -volumematerial]
     1682    label $inner.bright_l -text "Bright" -font $font
     1683
     1684    label $inner.opacity_l -text "Opacity" -font $font
    16601685    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1661         -variable [itcl::scope _settings(volume-opacity)] \
    1662         -width 10 \
     1686        -variable [itcl::scope _settings(-volumeopacity)] \
    16631687        -showvalue off \
    1664         -command [itcl::code $this AdjustSetting volume-opacity]
    1665 
    1666     label $inner.quality_l -text "Quality" -font "Arial 9"
     1688        -command [itcl::code $this AdjustSetting -volumeopacity]
     1689
     1690    label $inner.quality_l -text "Quality" -font $font
    16671691    ::scale $inner.quality -from 0 -to 100 -orient horizontal \
    1668         -variable [itcl::scope _settings(volume-quality)] \
    1669         -width 10 \
    1670         -showvalue off -command [itcl::code $this AdjustSetting volume-quality]
    1671 
    1672     itk_component add field_l {
    1673         label $inner.field_l -text "Field" -font "Arial 9"
    1674     } {
    1675         ignore -font
    1676     }
     1692        -variable [itcl::scope _settings(-volumequality)] \
     1693        -showvalue off \
     1694        -command [itcl::code $this AdjustSetting -volumequality]
     1695
     1696    label $inner.field_l -text "Field" -font $font
    16771697    itk_component add field {
    1678         Rappture::Combobox $inner.field -width 10 -editable no
     1698        Rappture::Combobox $inner.field -editable no
    16791699    }
    16801700    bind $inner.field <<Value>> \
    1681         [itcl::code $this AdjustSetting field]
    1682 
    1683     label $inner.palette_l -text "Palette" -font "Arial 9"
     1701        [itcl::code $this AdjustSetting -field]
     1702
     1703    label $inner.palette_l -text "Palette" -font $font
    16841704    itk_component add palette {
    1685         Rappture::Combobox $inner.palette -width 10 -editable no
    1686     }
    1687 
     1705        Rappture::Combobox $inner.palette -editable no
     1706    }
    16881707    $inner.palette choices insert end [GetColormapList]
    16891708    $itk_component(palette) value "BCGYR"
    16901709    bind $inner.palette <<Value>> \
    1691         [itcl::code $this AdjustSetting volume-palette]
     1710        [itcl::code $this AdjustSetting -volumepalette]
    16921711
    16931712    blt::table $inner \
    16941713        0,0 $inner.field_l   -anchor w -pady 2  \
    1695         0,1 $inner.field     -anchor w -pady 2 -cspan 2 \
    1696         1,0 $inner.volume    -anchor w -pady 2 -cspan 4 \
     1714        0,1 $inner.field     -fill x   -pady 2 -cspan 3 \
     1715        1,0 $inner.visibility -anchor w -pady 2 -cspan 4 \
    16971716        2,0 $inner.lighting  -anchor w -pady 2 -cspan 4 \
    16981717        3,0 $inner.dim_l     -anchor e -pady 2 \
    1699         3,1 $inner.material  -fill x   -pady 2 \
    1700         3,2 $inner.bright_l  -anchor w -pady 2 \
    1701         4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \
    1702         5,0 $inner.quality   -fill x   -pady 2 -cspan 2 \
    1703         7,0 $inner.palette_l -anchor w -pady 2  \
    1704         7,1 $inner.palette   -anchor w -pady 2 -cspan 2 \
    1705 
    1706     blt::table configure $inner r* c* -resize none
    1707     blt::table configure $inner r8 -resize expand
     1718        3,1 $inner.material  -fill x   -pady 2 -cspan 2 \
     1719        3,3 $inner.bright_l  -anchor w -pady 2 \
     1720        4,0 $inner.opacity_l -anchor w -pady 2 -cspan 4 \
     1721        5,0 $inner.opacity   -fill x   -pady 2 -cspan 4 \
     1722        6,0 $inner.quality_l -anchor w -pady 2 -cspan 4 \
     1723        7,0 $inner.quality   -fill x   -pady 2 -cspan 4 \
     1724        8,0 $inner.palette_l -anchor w -pady 2  \
     1725        8,1 $inner.palette   -fill x   -pady 2 -cspan 3 \
     1726
     1727    blt::table configure $inner r* c0 c1 c3 -resize none
     1728    blt::table configure $inner r9 c2 -resize expand
    17081729}
    17091730
    17101731itcl::body Rappture::VtkVolumeViewer::BuildAxisTab {} {
    1711     set font [option get $itk_component(hull) font Font]
    1712     #set bfont [option get $itk_component(hull) boldFont Font]
     1732    set fg [option get $itk_component(hull) font Font]
     1733    #set bfg [option get $itk_component(hull) boldFont Font]
    17131734
    17141735    set inner [$itk_component(main) insert end \
    17151736        -title "Axis Settings" \
    1716         -icon [Rappture::icon axis1]]
     1737        -icon [Rappture::icon axis2]]
    17171738    $inner configure -borderwidth 4
    17181739
    17191740    checkbutton $inner.visible \
    1720         -text "Show Axes" \
    1721         -variable [itcl::scope _settings(axesVisible)] \
    1722         -command [itcl::code $this AdjustSetting axesVisible] \
     1741        -text "Axes" \
     1742        -variable [itcl::scope _settings(-axesvisible)] \
     1743        -command [itcl::code $this AdjustSetting -axesvisible] \
    17231744        -font "Arial 9"
    17241745
    17251746    checkbutton $inner.labels \
    1726         -text "Show Axis Labels" \
    1727         -variable [itcl::scope _settings(axisLabels)] \
    1728         -command [itcl::code $this AdjustSetting axisLabels] \
     1747        -text "Axis Labels" \
     1748        -variable [itcl::scope _settings(-axislabels)] \
     1749        -command [itcl::code $this AdjustSetting -axislabels] \
    17291750        -font "Arial 9"
    1730 
    1731     checkbutton $inner.gridx \
    1732         -text "Show X Grid" \
    1733         -variable [itcl::scope _settings(axis-xgrid)] \
    1734         -command [itcl::code $this AdjustSetting axis-xgrid] \
     1751    label $inner.grid_l -text "Grid" -font "Arial 9"
     1752    checkbutton $inner.xgrid \
     1753        -text "X" \
     1754        -variable [itcl::scope _settings(-xgrid)] \
     1755        -command [itcl::code $this AdjustSetting -xgrid] \
    17351756        -font "Arial 9"
    1736     checkbutton $inner.gridy \
    1737         -text "Show Y Grid" \
    1738         -variable [itcl::scope _settings(axis-ygrid)] \
    1739         -command [itcl::code $this AdjustSetting axis-ygrid] \
     1757    checkbutton $inner.ygrid \
     1758        -text "Y" \
     1759        -variable [itcl::scope _settings(-ygrid)] \
     1760        -command [itcl::code $this AdjustSetting -ygrid] \
    17401761        -font "Arial 9"
    1741     checkbutton $inner.gridz \
    1742         -text "Show Z Grid" \
    1743         -variable [itcl::scope _settings(axis-zgrid)] \
    1744         -command [itcl::code $this AdjustSetting axis-zgrid] \
     1762    checkbutton $inner.zgrid \
     1763        -text "Z" \
     1764        -variable [itcl::scope _settings(-zgrid)] \
     1765        -command [itcl::code $this AdjustSetting -zgrid] \
     1766        -font "Arial 9"
     1767    checkbutton $inner.minorticks \
     1768        -text "Minor Ticks" \
     1769        -variable [itcl::scope _settings(-axisminorticks)] \
     1770        -command [itcl::code $this AdjustSetting -axisminorticks] \
    17451771        -font "Arial 9"
    17461772
     
    17551781        "furthest_triad"  "farthest" \
    17561782        "outer_edges"     "outer"         
    1757     $itk_component(axismode) value "static"
    1758     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlyMode]
     1783    $itk_component(axismode) value $_settings(-axisflymode)
     1784    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
    17591785
    17601786    blt::table $inner \
    1761         0,0 $inner.visible -anchor w -cspan 2 \
    1762         1,0 $inner.labels  -anchor w -cspan 2 \
    1763         2,0 $inner.gridx   -anchor w -cspan 2 \
    1764         3,0 $inner.gridy   -anchor w -cspan 2 \
    1765         4,0 $inner.gridz   -anchor w -cspan 2 \
    1766         5,0 $inner.mode_l  -anchor w -cspan 2 -padx { 2 0 } \
    1767         6,0 $inner.mode    -fill x   -cspan 2
     1787        0,0 $inner.visible -anchor w -cspan 4 \
     1788        1,0 $inner.labels  -anchor w -cspan 4 \
     1789        2,0 $inner.minorticks  -anchor w -cspan 4 \
     1790        4,0 $inner.grid_l  -anchor w \
     1791        4,1 $inner.xgrid   -anchor w \
     1792        4,2 $inner.ygrid   -anchor w \
     1793        4,3 $inner.zgrid   -anchor w \
     1794        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
     1795        5,1 $inner.mode    -fill x   -cspan 3
    17681796
    17691797    blt::table configure $inner r* c* -resize none
    1770     blt::table configure $inner r7 c1 -resize expand
     1798    blt::table configure $inner r7 c6 -resize expand
     1799    blt::table configure $inner r3 -height 0.125i
    17711800}
    17721801
     
    17771806    $inner configure -borderwidth 4
    17781807
     1808    label $inner.view_l -text "view" -font "Arial 9"
     1809    set f [frame $inner.view]
     1810    foreach side { front back left right top bottom } {
     1811        button $f.$side  -image [Rappture::icon view$side] \
     1812            -command [itcl::code $this SetOrientation $side]
     1813        Rappture::Tooltip::for $f.$side "Change the view to $side"
     1814        pack $f.$side -side left
     1815    }
     1816    blt::table $inner \
     1817        0,0 $inner.view_l -anchor e -pady 2 \
     1818        0,1 $inner.view -anchor w -pady 2
     1819    blt::table configure $inner r0 -resize none
     1820
     1821    set row 1
    17791822    set labels { qx qy qz qw xpan ypan zoom }
    1780     set row 0
    17811823    foreach tag $labels {
    1782         label $inner.${tag}label -text $tag -font "Arial 9"
     1824        label $inner.${tag}-label -text $tag -font "Arial 9"
    17831825        entry $inner.${tag} -font "Arial 9"  -bg white \
    1784             -textvariable [itcl::scope _view($tag)]
    1785         bind $inner.${tag} <KeyPress-Return> \
    1786             [itcl::code $this camera set ${tag}]
     1826            -textvariable [itcl::scope _view(-$tag)]
     1827        bind $inner.${tag} <Return> \
     1828            [itcl::code $this camera set -${tag}]
     1829        bind $inner.${tag} <KP_Enter> \
     1830            [itcl::code $this camera set -${tag}]
    17871831        blt::table $inner \
    1788             $row,0 $inner.${tag}label -anchor e -pady 2 \
     1832            $row,0 $inner.${tag}-label -anchor e -pady 2 \
    17891833            $row,1 $inner.${tag} -anchor w -pady 2
    17901834        blt::table configure $inner r$row -resize none
     
    17931837    checkbutton $inner.ortho \
    17941838        -text "Orthographic Projection" \
    1795         -variable [itcl::scope _view(ortho)] \
    1796         -command [itcl::code $this camera set ortho] \
     1839        -variable [itcl::scope _view(-ortho)] \
     1840        -command [itcl::code $this camera set -ortho] \
    17971841        -font "Arial 9"
    17981842    blt::table $inner \
     
    18171861    checkbutton $inner.visible \
    18181862        -text "Show Cutplanes" \
    1819         -variable [itcl::scope _settings(cutplaneVisible)] \
    1820         -command [itcl::code $this AdjustSetting cutplaneVisible] \
     1863        -variable [itcl::scope _settings(-cutplanesvisible)] \
     1864        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
    18211865        -font "Arial 9"
    18221866
    18231867    checkbutton $inner.wireframe \
    18241868        -text "Show Wireframe" \
    1825         -variable [itcl::scope _settings(cutplaneWireframe)] \
    1826         -command [itcl::code $this AdjustSetting cutplaneWireframe] \
     1869        -variable [itcl::scope _settings(-cutplanewireframe)] \
     1870        -command [itcl::code $this AdjustSetting -cutplanewireframe] \
    18271871        -font "Arial 9"
    18281872
    18291873    checkbutton $inner.lighting \
    18301874        -text "Enable Lighting" \
    1831         -variable [itcl::scope _settings(cutplaneLighting)] \
    1832         -command [itcl::code $this AdjustSetting cutplaneLighting] \
     1875        -variable [itcl::scope _settings(-cutplanelighting)] \
     1876        -command [itcl::code $this AdjustSetting -cutplanelighting] \
    18331877        -font "Arial 9"
    18341878
    18351879    checkbutton $inner.edges \
    18361880        -text "Show Edges" \
    1837         -variable [itcl::scope _settings(cutplaneEdges)] \
    1838         -command [itcl::code $this AdjustSetting cutplaneEdges] \
     1881        -variable [itcl::scope _settings(-cutplaneedges)] \
     1882        -command [itcl::code $this AdjustSetting -cutplaneedges] \
    18391883        -font "Arial 9"
    18401884
    18411885    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    18421886    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1843         -variable [itcl::scope _settings(cutplane-opacity)] \
     1887        -variable [itcl::scope _settings(-cutplaneopacity)] \
    18441888        -width 10 \
    18451889        -showvalue off \
    1846         -command [itcl::code $this AdjustSetting cutplane-opacity]
    1847     $inner.opacity set $_settings(cutplane-opacity)
     1890        -command [itcl::code $this AdjustSetting -cutplaneopacity]
     1891    $inner.opacity set $_settings(-cutplaneopacity)
    18481892
    18491893    # X-value slicer...
     
    18521896            -onimage [Rappture::icon x-cutplane] \
    18531897            -offimage [Rappture::icon x-cutplane] \
    1854             -command [itcl::code $this AdjustSetting cutplane-xvisible] \
    1855             -variable [itcl::scope _settings(cutplane-xvisible)]
     1898            -command [itcl::code $this AdjustSetting -xcutplanevisible] \
     1899            -variable [itcl::scope _settings(-xcutplanevisible)]
    18561900    }
    18571901    Rappture::Tooltip::for $itk_component(xCutButton) \
     
    18641908            -borderwidth 1 -highlightthickness 0 \
    18651909            -command [itcl::code $this EventuallySetCutplane x] \
    1866             -variable [itcl::scope _settings(cutplane-xposition)]
     1910            -variable [itcl::scope _settings(-xcutplaneposition)]
    18671911    } {
    18681912        usual
     
    18801924            -onimage [Rappture::icon y-cutplane] \
    18811925            -offimage [Rappture::icon y-cutplane] \
    1882             -command [itcl::code $this AdjustSetting cutplane-yvisible] \
    1883             -variable [itcl::scope _settings(cutplane-yvisible)]
     1926            -command [itcl::code $this AdjustSetting -ycutplanevisible] \
     1927            -variable [itcl::scope _settings(-ycutplanevisible)]
    18841928    }
    18851929    Rappture::Tooltip::for $itk_component(yCutButton) \
     
    18921936            -borderwidth 1 -highlightthickness 0 \
    18931937            -command [itcl::code $this EventuallySetCutplane y] \
    1894             -variable [itcl::scope _settings(cutplane-yposition)]
     1938            -variable [itcl::scope _settings(-ycutplaneposition)]
    18951939    } {
    18961940        usual
     
    19081952            -onimage [Rappture::icon z-cutplane] \
    19091953            -offimage [Rappture::icon z-cutplane] \
    1910             -command [itcl::code $this AdjustSetting cutplane-zvisible] \
    1911             -variable [itcl::scope _settings(cutplane-zvisible)]
     1954            -command [itcl::code $this AdjustSetting -zcutplanevisible] \
     1955            -variable [itcl::scope _settings(-zcutplanevisible)]
    19121956    }
    19131957    Rappture::Tooltip::for $itk_component(zCutButton) \
     
    19201964            -borderwidth 1 -highlightthickness 0 \
    19211965            -command [itcl::code $this EventuallySetCutplane z] \
    1922             -variable [itcl::scope _settings(cutplane-zposition)]
     1966            -variable [itcl::scope _settings(-zcutplaneposition)]
    19231967    } {
    19241968        usual
     
    19642008            }
    19652009            switch -- $who {
    1966                 "ortho" {
    1967                     if {$_view(ortho)} {
     2010                "-ortho" {
     2011                    if {$_view(-ortho)} {
    19682012                        SendCmd "camera mode ortho"
    19692013                    } else {
     
    19712015                    }
    19722016                }
    1973                 "xpan" - "ypan" {
     2017                "-xpan" - "-ypan" {
    19742018                    PanCamera
    19752019                }
    1976                 "qx" - "qy" - "qz" - "qw" {
    1977                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2020                "-qx" - "-qy" - "-qz" - "-qw" {
     2021                    set q [ViewToQuaternion]
    19782022                    $_arcball quaternion $q
    19792023                    EventuallyRotate $q
    19802024                }
    1981                 "zoom" {
    1982                     SendCmd "camera zoom $_view(zoom)"
     2025                "-zoom" {
     2026                    SendCmd "camera zoom $_view(-zoom)"
    19832027                }
    19842028            }
     
    20712115    array set settings $style
    20722116    SendCmd "volume add $tag"
    2073     SendCmd "cutplane add $tag"
    2074     SendCmd "cutplane visible 0 $tag"
     2117    SendCmd "$_cutplaneCmd add $tag"
     2118    SendCmd "$_cutplaneCmd visible 0 $tag"
    20752119
    20762120    SendCmd "volume lighting $settings(-lighting) $tag"
    2077     set _settings(volumeLighting) $settings(-lighting)
     2121    set _settings(-volumelighting) $settings(-lighting)
    20782122    SetColormap $dataobj $comp
    20792123    SendCmd "outline add $tag"
     
    20972141itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title vmin vmax size } {
    20982142    set _legendPending 0
    2099     #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size"
    2100     if { [IsConnected] } {
     2143    if { [isconnected] } {
    21012144        set bytes [ReceiveBytes $size]
    21022145        if { ![info exists _image(legend)] } {
     
    21332176        set title $fname
    21342177    }
    2135     if { $_settings(legendVisible) } {
     2178    if { $_settings(-legendvisible) } {
    21362179        set x [expr $w - 2]
    21372180        if { [$c find withtag "legend"] == "" } {
     
    22702313            }
    22712314            set newpos [expr {0.01*$newval}]
    2272             SendCmd "cutplane slice $axis $newpos"
     2315            SendCmd "$_cutplaneCmd slice $axis $newpos"
    22732316        }
    22742317        "tooltip" {
     
    23212364}
    23222365
     2366itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } {
     2367    array set positions {
     2368        front "1 0 0 0"
     2369        back  "0 0 1 0"
     2370        left  "0.707107 0 -0.707107 0"
     2371        right "0.707107 0 0.707107 0"
     2372        top   "0.707107 -0.707107 0 0"
     2373        bottom "0.707107 0.707107 0 0"
     2374    }
     2375    foreach name { -qw -qx -qy -qz } value $positions($side) {
     2376        set _view($name) $value
     2377    }
     2378    set q [ViewToQuaternion]
     2379    $_arcball quaternion $q
     2380    SendCmd "camera orient $q"
     2381    SendCmd "camera reset"
     2382    set _view(-xpan) 0
     2383    set _view(-ypan) 0
     2384    set _view(-zoom) 1.0
     2385}
Note: See TracChangeset for help on using the changeset viewer.