Changeset 5242


Ignore:
Timestamp:
Apr 15, 2015 3:33:50 AM (9 years ago)
Author:
ldelgass
Message:

syncing up with 1.4 branch version of vtkvolume

File:
1 edited

Legend:

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

    r5241 r5242  
    6969    private method BuildCutplaneTab {}
    7070    private method BuildDownloadPopup { widget command }
     71    private method BuildViewTab {}
    7172    private method BuildVolumeTab {}
    7273    private method ChangeColormap { dataobj comp color }
     
    9293    private method Pick {x y}
    9394    private method QuaternionToView { q } {
    94         foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     95        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    9596    }
    9697    private method Rebuild {}
     
    103104    private method SetLegendTip { x y }
    104105    private method SetObjectStyle { dataobj comp }
     106    private method SetOrientation { side }
    105107    private method Slice {option args}
    106108    private method ViewToQuaternion {} {
    107         return [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     109        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    108110    }
    109111    private method Zoom {option}
     
    201203    # Initialize the view to some default parameters.
    202204    array set _view {
    203         qw              0.853553
    204         qx              -0.353553
    205         qy              0.353553
    206         qz              0.146447
    207         zoom            1.0
    208         xpan            0
    209         ypan            0
    210         ortho           0
     205        -ortho           0
     206        -qw              0.853553
     207        -qx              -0.353553
     208        -qy              0.353553
     209        -qz              0.146447
     210        -xpan            0
     211        -ypan            0
     212        -zoom            1.0
    211213    }
    212214    set _arcball [blt::arcball create 100 100]
     
    333335
    334336    if { [catch {
     337        BuildViewTab
    335338        BuildVolumeTab
    336339        BuildCutplaneTab
     
    809812    array unset _dataset2style
    810813    array unset _obj2datasets
     814
     815    set _resizePending 0
     816    set _rotatePending 0
     817    set _cutplanePending 0
     818    set _legendPending 0
    811819}
    812820
     
    926934        #
    927935        $_arcball quaternion [ViewToQuaternion]
    928         if {$_view(ortho)} {
     936        if {$_view(-ortho)} {
    929937            SendCmd "camera mode ortho"
    930938        } else {
     
    10351043    }
    10361044
    1037     InitSettings volume-palette volume-material volume-quality volumeVisible \
     1045    InitSettings volume-palette \
     1046        volume-material \
     1047        volumeLighting volume-opacity volume-quality volumeVisible \
    10381048        cutplaneVisible \
    10391049        cutplane-xposition cutplane-yposition cutplane-zposition \
     
    10411051
    10421052    if { $_reset } {
    1043         InitSettings volumeLighting
    10441053        Zoom reset
    10451054        set _reset 0
     
    11081117    switch -- $option {
    11091118        "in" {
    1110             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1111             SendCmd "camera zoom $_view(zoom)"
     1119            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1120            SendCmd "camera zoom $_view(-zoom)"
    11121121        }
    11131122        "out" {
    1114             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1115             SendCmd "camera zoom $_view(zoom)"
     1123            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1124            SendCmd "camera zoom $_view(-zoom)"
    11161125        }
    11171126        "reset" {
    11181127            array set _view {
    1119                 qw      0.853553
    1120                 qx      -0.353553
    1121                 qy      0.353553
    1122                 qz      0.146447
    1123                 zoom    1.0
    1124                 xpan   0
    1125                 ypan   0
     1128                -qw      0.853553
     1129                -qx      -0.353553
     1130                -qy      0.353553
     1131                -qz      0.146447
     1132                -xpan    0
     1133                -ypan    0
     1134                -zoom    1.0
    11261135            }
    11271136            if { $_first != "" } {
     
    11391148
    11401149itcl::body Rappture::VtkVolumeViewer::PanCamera {} {
    1141     set x $_view(xpan)
    1142     set y $_view(ypan)
     1150    set x $_view(-xpan)
     1151    set y $_view(-ypan)
    11431152    SendCmd "camera pan $x $y"
    11441153}
    1145 
    11461154
    11471155# ----------------------------------------------------------------------
     
    12181226            set x [expr $x / double($w)]
    12191227            set y [expr $y / double($h)]
    1220             set _view(xpan) [expr $_view(xpan) + $x]
    1221             set _view(ypan) [expr $_view(ypan) + $y]
     1228            set _view(-xpan) [expr $_view(-xpan) + $x]
     1229            set _view(-ypan) [expr $_view(-ypan) + $y]
    12221230            PanCamera
    12231231            return
     
    12411249            set _click(x) $x
    12421250            set _click(y) $y
    1243             set _view(xpan) [expr $_view(xpan) - $dx]
    1244             set _view(ypan) [expr $_view(ypan) - $dy]
     1251            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1252            set _view(-ypan) [expr $_view(-ypan) - $dy]
    12451253            PanCamera
    12461254        }
     
    12861294        "volumeVisible" {
    12871295            set bool $_settings($what)
    1288             foreach dataset [CurrentDatasets -visible] {
    1289                 SendCmd "volume visible $bool $dataset"
     1296            foreach tag [CurrentDatasets -visible] {
     1297                SendCmd "volume visible $bool $tag"
    12901298            }
    12911299            if { $bool } {
     
    13031311            #set power [expr {sqrt(160*$val+1.0)}]
    13041312            set power [expr {$val+1.0}]
    1305             foreach dataset [CurrentDatasets -visible] {
    1306                 SendCmd "volume shading diffuse $diffuse $dataset"
    1307                 SendCmd "volume shading specular $specular $power $dataset"
     1313            foreach tag [CurrentDatasets -visible] {
     1314                SendCmd "volume shading diffuse $diffuse $tag"
     1315                SendCmd "volume shading specular $specular $power $tag"
    13081316            }
    13091317        }
    13101318        "volumeLighting" {
    13111319            set bool $_settings($what)
    1312             foreach dataset [CurrentDatasets -visible] {
    1313                 SendCmd "volume lighting $bool $dataset"
     1320            foreach tag [CurrentDatasets -visible] {
     1321                SendCmd "volume lighting $bool $tag"
     1322            }
     1323        }
     1324        "volume-opacity" {
     1325            set val $_settings($what)
     1326            set val [expr {0.01*$val}]
     1327            foreach tag [CurrentDatasets -visible] {
     1328                SendCmd "volume opacity $val $tag"
    13141329            }
    13151330        }
     
    13171332            set val $_settings($what)
    13181333            set val [expr {0.01*$val}]
    1319             foreach dataset [CurrentDatasets -visible] {
    1320                 SendCmd "volume quality $val $dataset"
     1334            foreach tag [CurrentDatasets -visible] {
     1335                SendCmd "volume quality $val $tag"
    13211336            }
    13221337        }
     
    14871502        -color BCGYR
    14881503        -levels 6
    1489         -opacity 1.0
    14901504    }
    14911505    set tag $dataobj-$comp
     
    15041518    array set style $_style($tag)
    15051519
    1506     set name "$style(-color):$style(-levels):$style(-opacity)"
     1520    set name "$style(-color):$style(-levels)"
    15071521    if { ![info exists _colormaps($name)] } {
    15081522        BuildColormap $name [array get style]
     
    15261540        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    15271541    }
    1528     if { ![info exists _settings(volume-opacity)] } {
    1529         set _settings(volume-opacity) $style(-opacity)
    1530     }
    1531     set max $_settings(volume-opacity)
    1532 
    1533     set opaqueWmap "0.0 1.0 1.0 1.0"
    1534     #set wmap "0.0 0.0 0.1 0.0 0.2 0.8 0.98 0.8 0.99 0.0 1.0 0.0"
     1542    set max 1.0
     1543
     1544    set opaqueAmap "0.0 1.0 1.0 1.0"
     1545    #set amap "0.0 0.0 0.1 0.0 0.2 0.8 0.98 0.8 0.99 0.0 1.0 0.0"
    15351546    # Approximate cubic opacity curve
    1536     set wmap "0.0 0.0 0.1 0.001 0.2 0.008 0.3 0.027 0.4 0.064 0.5 0.125 0.6 0.216 0.7 0.343 0.8 0.512 0.9 0.729 1.0 1.0"
    1537     SendCmd "colormap add $name { $cmap } { $wmap }"
    1538     SendCmd "colormap add $name-opaque { $cmap } { $opaqueWmap }"
     1547    set amap "0.0 0.0 0.1 0.001 0.2 0.008 0.3 0.027 0.4 0.064 0.5 0.125 0.6 0.216 0.7 0.343 0.8 0.512 0.9 0.729 1.0 1.0"
     1548    SendCmd "colormap add $name { $cmap } { $amap }"
     1549    SendCmd "colormap add $name-opaque { $cmap } { $opaqueAmap }"
    15391550}
    15401551
     
    15601571}
    15611572
     1573itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} {
     1574    set font [option get $itk_component(hull) font Font]
     1575}
     1576
    15621577itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} {
    1563 
    1564     set fg [option get $itk_component(hull) font Font]
    1565     #set bfg [option get $itk_component(hull) boldFont Font]
     1578    set font [option get $itk_component(hull) font Font]
     1579    #set bfont [option get $itk_component(hull) boldFont Font]
    15661580
    15671581    set inner [$itk_component(main) insert end \
     
    15711585
    15721586    checkbutton $inner.volume \
    1573         -text "Show Volume" \
     1587        -text "Visible" \
     1588        -font $font \
    15741589        -variable [itcl::scope _settings(volumeVisible)] \
    1575         -command [itcl::code $this AdjustSetting volumeVisible] \
    1576         -font "Arial 9"
     1590        -command [itcl::code $this AdjustSetting volumeVisible]
    15771591
    15781592    checkbutton $inner.lighting \
    15791593        -text "Enable Lighting" \
     1594        -font $font \
    15801595        -variable [itcl::scope _settings(volumeLighting)] \
    1581         -command [itcl::code $this AdjustSetting volumeLighting] \
    1582         -font "Arial 9"
    1583 
    1584     label $inner.dim_l -text "Dim" -font "Arial 9"
     1596        -command [itcl::code $this AdjustSetting volumeLighting]
     1597
     1598    label $inner.dim_l -text "Dim" -font $font
    15851599    ::scale $inner.material -from 0 -to 100 -orient horizontal \
    15861600        -variable [itcl::scope _settings(volume-material)] \
    1587         -width 10 \
    1588         -showvalue off -command [itcl::code $this AdjustSetting volume-material]
    1589     label $inner.bright_l -text "Bright" -font "Arial 9"
    1590 
    1591     label $inner.opacity_l -text "Opacity" -font "Arial 9"
     1601        -showvalue off \
     1602        -command [itcl::code $this AdjustSetting volume-material]
     1603    label $inner.bright_l -text "Bright" -font $font
     1604
     1605    label $inner.opacity_l -text "Opacity" -font $font
    15921606    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    15931607        -variable [itcl::scope _settings(volume-opacity)] \
    1594         -width 10 \
    15951608        -showvalue off \
    15961609        -command [itcl::code $this AdjustSetting volume-opacity]
    15971610
    1598     label $inner.quality_l -text "Quality" -font "Arial 9"
     1611    label $inner.quality_l -text "Quality" -font $font
    15991612    ::scale $inner.quality -from 0 -to 100 -orient horizontal \
    16001613        -variable [itcl::scope _settings(volume-quality)] \
    1601         -width 10 \
    1602         -showvalue off -command [itcl::code $this AdjustSetting volume-quality]
    1603 
    1604     itk_component add field_l {
    1605         label $inner.field_l -text "Field" -font "Arial 9"
    1606     } {
    1607         ignore -font
    1608     }
     1614        -showvalue off \
     1615        -command [itcl::code $this AdjustSetting volume-quality]
     1616
     1617    label $inner.field_l -text "Field" -font $font
    16091618    itk_component add field {
    1610         Rappture::Combobox $inner.field -width 10 -editable no
     1619        Rappture::Combobox $inner.field -editable no
    16111620    }
    16121621    bind $inner.field <<Value>> \
    16131622        [itcl::code $this AdjustSetting field]
    16141623
    1615     label $inner.palette_l -text "Palette" -font "Arial 9"
     1624    label $inner.palette_l -text "Palette" -font $font
    16161625    itk_component add palette {
    1617         Rappture::Combobox $inner.palette -width 10 -editable no
     1626        Rappture::Combobox $inner.palette -editable no
    16181627    }
    16191628    $inner.palette choices insert end [GetColormapList]
    1620 
    1621     $itk_component(palette) value "BCGYR"
    16221629    bind $inner.palette <<Value>> \
    16231630        [itcl::code $this AdjustSetting volume-palette]
     1631    $itk_component(palette) value "BCGYR"
    16241632
    16251633    blt::table $inner \
    1626         0,0 $inner.field_l   -anchor w -pady 2  \
    1627         0,1 $inner.field     -anchor w -pady 2 -cspan 2 \
     1634        0,0 $inner.field_l   -anchor w -pady 2 \
     1635        0,1 $inner.field     -fill x   -pady 2 -cspan 3 \
    16281636        1,0 $inner.volume    -anchor w -pady 2 -cspan 4 \
    16291637        2,0 $inner.lighting  -anchor w -pady 2 -cspan 4 \
    16301638        3,0 $inner.dim_l     -anchor e -pady 2 \
    1631         3,1 $inner.material  -fill x   -pady 2 \
     1639        3,1 $inner.material  -fill x   -pady 2 -cspan 2 \
    16321640        3,2 $inner.bright_l  -anchor w -pady 2 \
    1633         4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \
    1634         5,0 $inner.quality   -fill x   -pady 2 -cspan 2 \
    1635         7,0 $inner.palette_l -anchor w -pady 2  \
    1636         7,1 $inner.palette   -anchor w -pady 2 -cspan 2 \
    1637 
    1638     blt::table configure $inner r* c* -resize none
    1639     blt::table configure $inner r8 -resize expand
     1641        4,0 $inner.opacity_l -anchor w -pady 2 -cspan 4 \
     1642        5,0 $inner.opacity   -fill x   -pady 2 -cspan 4 \
     1643        6,0 $inner.quality_l -anchor w -pady 2 -cspan 4 \
     1644        7,0 $inner.quality   -fill x   -pady 2 -cspan 4 \
     1645        8,0 $inner.palette_l -anchor w -pady 2 \
     1646        8,1 $inner.palette   -fill x   -pady 2 -cspan 3
     1647
     1648    blt::table configure $inner r* c0 c1 c3 -resize none
     1649    blt::table configure $inner r9 c2 -resize expand
    16401650}
    16411651
     
    17111721}
    17121722
    1713 
    17141723itcl::body Rappture::VtkVolumeViewer::BuildCameraTab {} {
    17151724    set inner [$itk_component(main) insert end \
     
    17181727    $inner configure -borderwidth 4
    17191728
     1729    label $inner.view_l -text "view" -font "Arial 9"
     1730    set f [frame $inner.view]
     1731    foreach side { front back left right top bottom } {
     1732        button $f.$side  -image [Rappture::icon view$side] \
     1733            -command [itcl::code $this SetOrientation $side]
     1734        Rappture::Tooltip::for $f.$side "Change the view to $side"
     1735        pack $f.$side -side left
     1736    }
     1737    blt::table $inner \
     1738        0,0 $inner.view_l -anchor e -pady 2 \
     1739        0,1 $inner.view -anchor w -pady 2
     1740    blt::table configure $inner r0 -resize none
     1741
     1742    set row 1
    17201743    set labels { qx qy qz qw xpan ypan zoom }
    1721     set row 0
    17221744    foreach tag $labels {
    17231745        label $inner.${tag}label -text $tag -font "Arial 9"
    17241746        entry $inner.${tag} -font "Arial 9"  -bg white \
    1725             -textvariable [itcl::scope _view($tag)]
    1726         bind $inner.${tag} <KeyPress-Return> \
    1727             [itcl::code $this camera set ${tag}]
     1747            -textvariable [itcl::scope _view(-$tag)]
     1748        bind $inner.${tag} <Return> \
     1749            [itcl::code $this camera set -${tag}]
     1750        bind $inner.${tag} <KP_Enter> \
     1751            [itcl::code $this camera set -${tag}]
    17281752        blt::table $inner \
    17291753            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    17341758    checkbutton $inner.ortho \
    17351759        -text "Orthographic Projection" \
    1736         -variable [itcl::scope _view(ortho)] \
    1737         -command [itcl::code $this camera set ortho] \
     1760        -variable [itcl::scope _view(-ortho)] \
     1761        -command [itcl::code $this camera set -ortho] \
    17381762        -font "Arial 9"
    17391763    blt::table $inner \
     
    17481772
    17491773itcl::body Rappture::VtkVolumeViewer::BuildCutplaneTab {} {
    1750 
    1751     set fg [option get $itk_component(hull) font Font]
     1774    set font [option get $itk_component(hull) font Font]
    17521775
    17531776    set inner [$itk_component(main) insert end \
     
    18701893        5,1 $itk_component(yCutScale)   -fill y \
    18711894        4,2 $itk_component(zCutButton)  -anchor e -padx 2 -pady 2 \
    1872         5,2 $itk_component(zCutScale)   -fill y \
     1895        5,2 $itk_component(zCutScale)   -fill y
    18731896
    18741897    blt::table configure $inner r* c* -resize none
     
    18921915            }
    18931916            switch -- $who {
    1894                 "ortho" {
    1895                     if {$_view(ortho)} {
     1917                "-ortho" {
     1918                    if {$_view(-ortho)} {
    18961919                        SendCmd "camera mode ortho"
    18971920                    } else {
     
    18991922                    }
    19001923                }
    1901                 "xpan" - "ypan" {
     1924                "-xpan" - "-ypan" {
    19021925                    PanCamera
    19031926                }
    1904                 "qx" - "qy" - "qz" - "qw" {
     1927                "-qx" - "-qy" - "-qz" - "-qw" {
    19051928                    set q [ViewToQuaternion]
    19061929                    $_arcball quaternion $q
    19071930                    EventuallyRotate $q
    19081931                }
    1909                 "zoom" {
    1910                     SendCmd "camera zoom $_view(zoom)"
     1932                "-zoom" {
     1933                    SendCmd "camera zoom $_view(-zoom)"
    19111934                }
    19121935            }
     
    22432266}
    22442267
     2268itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } {
     2269    array set positions {
     2270        front "1 0 0 0"
     2271        back  "0 0 1 0"
     2272        left  "0.707107 0 -0.707107 0"
     2273        right "0.707107 0 0.707107 0"
     2274        top   "0.707107 -0.707107 0 0"
     2275        bottom "0.707107 0.707107 0 0"
     2276    }
     2277    foreach name { -qw -qx -qy -qz } value $positions($side) {
     2278        set _view($name) $value
     2279    }
     2280    set q [ViewToQuaternion]
     2281    $_arcball quaternion $q
     2282    SendCmd "camera orient $q"
     2283    SendCmd "camera reset"
     2284    set _view(-xpan) 0
     2285    set _view(-ypan) 0
     2286    set _view(-zoom) 1.0
     2287}
Note: See TracChangeset for help on using the changeset viewer.