Changeset 5242 for branches/1.3/gui/scripts/vtkvolumeviewer.tcl
- Timestamp:
- Apr 15, 2015, 3:33:50 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/vtkvolumeviewer.tcl
r5241 r5242 69 69 private method BuildCutplaneTab {} 70 70 private method BuildDownloadPopup { widget command } 71 private method BuildViewTab {} 71 72 private method BuildVolumeTab {} 72 73 private method ChangeColormap { dataobj comp color } … … 92 93 private method Pick {x y} 93 94 private method QuaternionToView { q } { 94 foreach { _view( qw) _view(qx) _view(qy) _view(qz) } $q break95 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 95 96 } 96 97 private method Rebuild {} … … 103 104 private method SetLegendTip { x y } 104 105 private method SetObjectStyle { dataobj comp } 106 private method SetOrientation { side } 105 107 private method Slice {option args} 106 108 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)] 108 110 } 109 111 private method Zoom {option} … … 201 203 # Initialize the view to some default parameters. 202 204 array set _view { 203 qw 0.853553204 qx -0.353553205 qy0.353553206 qz 0.146447207 zoom 1.0208 xpan 0209 ypan 0210 ortho0205 -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 211 213 } 212 214 set _arcball [blt::arcball create 100 100] … … 333 335 334 336 if { [catch { 337 BuildViewTab 335 338 BuildVolumeTab 336 339 BuildCutplaneTab … … 809 812 array unset _dataset2style 810 813 array unset _obj2datasets 814 815 set _resizePending 0 816 set _rotatePending 0 817 set _cutplanePending 0 818 set _legendPending 0 811 819 } 812 820 … … 926 934 # 927 935 $_arcball quaternion [ViewToQuaternion] 928 if {$_view( ortho)} {936 if {$_view(-ortho)} { 929 937 SendCmd "camera mode ortho" 930 938 } else { … … 1035 1043 } 1036 1044 1037 InitSettings volume-palette volume-material volume-quality volumeVisible \ 1045 InitSettings volume-palette \ 1046 volume-material \ 1047 volumeLighting volume-opacity volume-quality volumeVisible \ 1038 1048 cutplaneVisible \ 1039 1049 cutplane-xposition cutplane-yposition cutplane-zposition \ … … 1041 1051 1042 1052 if { $_reset } { 1043 InitSettings volumeLighting1044 1053 Zoom reset 1045 1054 set _reset 0 … … 1108 1117 switch -- $option { 1109 1118 "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)" 1112 1121 } 1113 1122 "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)" 1116 1125 } 1117 1126 "reset" { 1118 1127 array set _view { 1119 qw 0.8535531120 qx -0.3535531121 qy 0.3535531122 qz 0.1464471123 zoom 1.01124 xpan01125 ypan01128 -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 1126 1135 } 1127 1136 if { $_first != "" } { … … 1139 1148 1140 1149 itcl::body Rappture::VtkVolumeViewer::PanCamera {} { 1141 set x $_view( xpan)1142 set y $_view( ypan)1150 set x $_view(-xpan) 1151 set y $_view(-ypan) 1143 1152 SendCmd "camera pan $x $y" 1144 1153 } 1145 1146 1154 1147 1155 # ---------------------------------------------------------------------- … … 1218 1226 set x [expr $x / double($w)] 1219 1227 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] 1222 1230 PanCamera 1223 1231 return … … 1241 1249 set _click(x) $x 1242 1250 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] 1245 1253 PanCamera 1246 1254 } … … 1286 1294 "volumeVisible" { 1287 1295 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" 1290 1298 } 1291 1299 if { $bool } { … … 1303 1311 #set power [expr {sqrt(160*$val+1.0)}] 1304 1312 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" 1308 1316 } 1309 1317 } 1310 1318 "volumeLighting" { 1311 1319 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" 1314 1329 } 1315 1330 } … … 1317 1332 set val $_settings($what) 1318 1333 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" 1321 1336 } 1322 1337 } … … 1487 1502 -color BCGYR 1488 1503 -levels 6 1489 -opacity 1.01490 1504 } 1491 1505 set tag $dataobj-$comp … … 1504 1518 array set style $_style($tag) 1505 1519 1506 set name "$style(-color):$style(-levels) :$style(-opacity)"1520 set name "$style(-color):$style(-levels)" 1507 1521 if { ![info exists _colormaps($name)] } { 1508 1522 BuildColormap $name [array get style] … … 1526 1540 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1527 1541 } 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" 1535 1546 # 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 } { $opaque Wmap }"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 }" 1539 1550 } 1540 1551 … … 1560 1571 } 1561 1572 1573 itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} { 1574 set font [option get $itk_component(hull) font Font] 1575 } 1576 1562 1577 itcl::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] 1566 1580 1567 1581 set inner [$itk_component(main) insert end \ … … 1571 1585 1572 1586 checkbutton $inner.volume \ 1573 -text "Show Volume" \ 1587 -text "Visible" \ 1588 -font $font \ 1574 1589 -variable [itcl::scope _settings(volumeVisible)] \ 1575 -command [itcl::code $this AdjustSetting volumeVisible] \ 1576 -font "Arial 9" 1590 -command [itcl::code $this AdjustSetting volumeVisible] 1577 1591 1578 1592 checkbutton $inner.lighting \ 1579 1593 -text "Enable Lighting" \ 1594 -font $font \ 1580 1595 -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 1585 1599 ::scale $inner.material -from 0 -to 100 -orient horizontal \ 1586 1600 -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 1592 1606 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1593 1607 -variable [itcl::scope _settings(volume-opacity)] \ 1594 -width 10 \1595 1608 -showvalue off \ 1596 1609 -command [itcl::code $this AdjustSetting volume-opacity] 1597 1610 1598 label $inner.quality_l -text "Quality" -font "Arial 9"1611 label $inner.quality_l -text "Quality" -font $font 1599 1612 ::scale $inner.quality -from 0 -to 100 -orient horizontal \ 1600 1613 -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 1609 1618 itk_component add field { 1610 Rappture::Combobox $inner.field - width 10 -editable no1619 Rappture::Combobox $inner.field -editable no 1611 1620 } 1612 1621 bind $inner.field <<Value>> \ 1613 1622 [itcl::code $this AdjustSetting field] 1614 1623 1615 label $inner.palette_l -text "Palette" -font "Arial 9"1624 label $inner.palette_l -text "Palette" -font $font 1616 1625 itk_component add palette { 1617 Rappture::Combobox $inner.palette - width 10 -editable no1626 Rappture::Combobox $inner.palette -editable no 1618 1627 } 1619 1628 $inner.palette choices insert end [GetColormapList] 1620 1621 $itk_component(palette) value "BCGYR"1622 1629 bind $inner.palette <<Value>> \ 1623 1630 [itcl::code $this AdjustSetting volume-palette] 1631 $itk_component(palette) value "BCGYR" 1624 1632 1625 1633 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 \ 1628 1636 1,0 $inner.volume -anchor w -pady 2 -cspan 4 \ 1629 1637 2,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 1630 1638 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 \ 1632 1640 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 1640 1650 } 1641 1651 … … 1711 1721 } 1712 1722 1713 1714 1723 itcl::body Rappture::VtkVolumeViewer::BuildCameraTab {} { 1715 1724 set inner [$itk_component(main) insert end \ … … 1718 1727 $inner configure -borderwidth 4 1719 1728 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 1720 1743 set labels { qx qy qz qw xpan ypan zoom } 1721 set row 01722 1744 foreach tag $labels { 1723 1745 label $inner.${tag}label -text $tag -font "Arial 9" 1724 1746 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}] 1728 1752 blt::table $inner \ 1729 1753 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1734 1758 checkbutton $inner.ortho \ 1735 1759 -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] \ 1738 1762 -font "Arial 9" 1739 1763 blt::table $inner \ … … 1748 1772 1749 1773 itcl::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] 1752 1775 1753 1776 set inner [$itk_component(main) insert end \ … … 1870 1893 5,1 $itk_component(yCutScale) -fill y \ 1871 1894 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 1873 1896 1874 1897 blt::table configure $inner r* c* -resize none … … 1892 1915 } 1893 1916 switch -- $who { 1894 " ortho" {1895 if {$_view( ortho)} {1917 "-ortho" { 1918 if {$_view(-ortho)} { 1896 1919 SendCmd "camera mode ortho" 1897 1920 } else { … … 1899 1922 } 1900 1923 } 1901 " xpan" - "ypan" {1924 "-xpan" - "-ypan" { 1902 1925 PanCamera 1903 1926 } 1904 " qx" - "qy" - "qz" - "qw" {1927 "-qx" - "-qy" - "-qz" - "-qw" { 1905 1928 set q [ViewToQuaternion] 1906 1929 $_arcball quaternion $q 1907 1930 EventuallyRotate $q 1908 1931 } 1909 " zoom" {1910 SendCmd "camera zoom $_view( zoom)"1932 "-zoom" { 1933 SendCmd "camera zoom $_view(-zoom)" 1911 1934 } 1912 1935 } … … 2243 2266 } 2244 2267 2268 itcl::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.