Changeset 4192 for trunk/gui/scripts/vtkvolumeviewer.tcl
- Timestamp:
- Feb 25, 2014, 11:07:30 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkvolumeviewer.tcl
r4188 r4192 81 81 private method SwitchComponent { cname } 82 82 private method RemoveMarker { x y } 83 private method ViewToQuaternion {} { 84 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 85 } 86 private method QuaternionToView { q } { 87 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 88 } 83 89 84 90 private variable _current ""; # Currently selected component … … 207 213 $_dispatcher register !xcutplane 208 214 $_dispatcher dispatch $this !xcutplane \ 209 "[itcl::code $this AdjustSetting cutplanePositionX]; list"215 "[itcl::code $this AdjustSetting -xcutplaneposition]; list" 210 216 211 217 # Y-Cutplane event 212 218 $_dispatcher register !ycutplane 213 219 $_dispatcher dispatch $this !ycutplane \ 214 "[itcl::code $this AdjustSetting cutplanePositionY]; list"220 "[itcl::code $this AdjustSetting -ycutplaneposition]; list" 215 221 216 222 # Z-Cutplane event 217 223 $_dispatcher register !zcutplane 218 224 $_dispatcher dispatch $this !zcutplane \ 219 "[itcl::code $this AdjustSetting cutplanePositionZ]; list"225 "[itcl::code $this AdjustSetting -xcutplaneposition]; list" 220 226 221 227 # … … 228 234 # Initialize the view to some default parameters. 229 235 array set _view { 230 qw 0.853553231 qx -0.353553232 qy 0.353553233 qz 0.146447234 zoom 1.0235 xpan 0236 ypan 0237 ortho 0236 -qw 0.853553 237 -qx -0.353553 238 -qy 0.353553 239 -qz 0.146447 240 -zoom 1.0 241 -xpan 0 242 -ypan 0 243 -ortho 0 238 244 } 239 245 set _arcball [blt::arcball create 100 100] 240 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 241 $_arcball quaternion $q 246 $_arcball quaternion [ViewToQuaternion] 242 247 243 248 array set _settings { 244 axesVisible 1 245 axisGridX 0 246 axisGridY 0 247 axisGridZ 0 248 axisLabels 1 249 background black 250 cutplaneEdges 0 251 cutplaneLighting 1 252 cutplaneOpacity 100 253 cutplanePositionX 50 254 cutplanePositionY 50 255 cutplanePositionZ 50 256 cutplaneVisible 0 257 cutplaneVisibleX 1 258 cutplaneVisibleY 1 259 cutplaneVisibleZ 1 260 cutplaneWireframe 0 261 legendVisible 1 262 outline 0 263 volumeAmbient 40 264 volumeBlendMode composite 265 volumeDiffuse 60 266 volumeLighting 1 267 volumeOpacity 50 268 volumeQuality 80 269 volumeSpecularExponent 90 270 volumeSpecularLevel 30 271 volumeThickness 350 272 volumeVisible 1 249 -background black 250 -axesvisible 1 251 -axislabelsvisible 1 252 -cutplaneedgesvisible 0 253 -cutplanelighting 1 254 -cutplaneopacity 100 255 -cutplanesvisible 0 256 -cutplanewireframe 0 257 -legendvisible 1 258 -volumeambient 40 259 -volumeblendmode composite 260 -volumediffuse 60 261 -volumeedgesvisible 0 262 -volumelighting 1 263 -volumeopacity 50 264 -volumeoutline 0 265 -volumeoutline 0 266 -volumequality 80 267 -volumespecularexponent 90 268 -volumespecularlevel 30 269 -volumethickness 350 270 -volumevisible 1 271 -xcutplaneposition 50 272 -xcutplanevisible 1 273 -xgridvisible 0 274 -xgridvisible 0 275 -ycutplaneposition 50 276 -ycutplanevisible 1 277 -ygridvisible 0 278 -zcutplaneposition 50 279 -zcutplanevisible 1 273 280 } 274 281 … … 349 356 -onimage [Rappture::icon volume-on] \ 350 357 -offimage [Rappture::icon volume-off] \ 351 -variable [itcl::scope _settings( volumeVisible)] \352 -command [itcl::code $this AdjustSetting volumeVisible]358 -variable [itcl::scope _settings(-volumevisible)] \ 359 -command [itcl::code $this AdjustSetting -volumevisible] 353 360 } 354 361 $itk_component(volume) select … … 361 368 -onimage [Rappture::icon cutbutton] \ 362 369 -offimage [Rappture::icon cutbutton] \ 363 -variable [itcl::scope _settings( cutplaneVisible)] \364 -command [itcl::code $this AdjustSetting cutplaneVisible]370 -variable [itcl::scope _settings(-cutplanesvisible)] \ 371 -command [itcl::code $this AdjustSetting -cutplanesvisible] 365 372 } 366 373 Rappture::Tooltip::for $itk_component(cutplane) \ … … 491 498 492 499 itcl::body Rappture::VtkVolumeViewer::DoRotate {} { 493 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 494 SendCmd "camera orient $q" 500 SendCmd "camera orient [ViewToQuaternion]" 495 501 set _rotatePending 0 496 502 } … … 516 522 517 523 itcl::body Rappture::VtkVolumeViewer::EventuallyRotate { q } { 518 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break524 QuaternionToView $q 519 525 if { !$_rotatePending } { 520 526 set _rotatePending 1 … … 684 690 # ---------------------------------------------------------------------- 685 691 itcl::body Rappture::VtkVolumeViewer::scale {args} { 686 array set style {687 -color BCGYR688 -levels 6689 -opacity 1.0690 -markers ""691 }692 692 array unset _limits 693 693 array unset _volcomponents … … 1016 1016 # Reset the camera and other view parameters 1017 1017 # 1018 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1019 $_arcball quaternion $q 1020 if {$_view(ortho)} { 1018 $_arcball quaternion [ViewToQuaternion] 1019 if {$_view(-ortho)} { 1021 1020 SendCmd "camera mode ortho" 1022 1021 } else { … … 1024 1023 } 1025 1024 DoRotate 1026 InitSettings outlinebackground \1027 axisGridX axisGridY axisGridZ axisFlyMode \1028 axesVisible axisLabels1025 InitSettings -volumeoutline -background \ 1026 -xgridvisible -ygridvisible -zgridvisible -axisflymode \ 1027 -axesvisible -axislabelsvisible 1029 1028 PanCamera 1030 1029 } … … 1122 1121 } 1123 1122 1124 InitSettings volumeColormap\1125 volumeAmbient volumeDiffuse volumeSpecularLevel volumeSpecularExponent\1126 volumeBlendMode volumeThickness \1127 volumeOpacity volumeQuality volumeVisible \1128 cutplaneVisible \1129 cutplanePositionX cutplanePositionY cutplanePositionZ\1130 cutplaneVisibleX cutplaneVisibleY cutplaneVisibleZ1123 InitSettings -color \ 1124 -volumeambient -volumediffuse -volumespecularlevel \ 1125 -volumespecularexponent -volumeblendmode -volumethickness \ 1126 -volumeopacity -volumequality -volumevisible \ 1127 -cutplanesvisible \ 1128 -xcutplaneposition -ycutplaneposition -zcutplaneposition \ 1129 -xcutplanevisible -ycutplanevisible -zcutplanevisible 1131 1130 1132 1131 if { $_reset } { 1133 InitSettings volumeLighting1132 InitSettings -volumelighting 1134 1133 SendCmd "camera reset" 1135 SendCmd "camera zoom $_view( zoom)"1134 SendCmd "camera zoom $_view(-zoom)" 1136 1135 RequestLegend 1137 1136 set _reset 0 … … 1200 1199 switch -- $option { 1201 1200 "in" { 1202 set _view( zoom) [expr {$_view(zoom)*1.25}]1203 SendCmd "camera zoom $_view( zoom)"1201 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1202 SendCmd "camera zoom $_view(-zoom)" 1204 1203 } 1205 1204 "out" { 1206 set _view( zoom) [expr {$_view(zoom)*0.8}]1207 SendCmd "camera zoom $_view( zoom)"1205 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1206 SendCmd "camera zoom $_view(-zoom)" 1208 1207 } 1209 1208 "reset" { 1210 1209 array set _view { 1211 qw 0.8535531212 qx -0.3535531213 qy 0.3535531214 qz 0.1464471215 zoom 1.01216 xpan 01217 ypan 01210 -qw 0.853553 1211 -qx -0.353553 1212 -qy 0.353553 1213 -qz 0.146447 1214 -zoom 1.0 1215 -xpan 0 1216 -ypan 0 1218 1217 } 1219 1218 if { $_first != "" } { … … 1223 1222 } 1224 1223 } 1225 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1226 $_arcball quaternion $q 1224 $_arcball quaternion [ViewToQuaternion] 1227 1225 DoRotate 1228 1226 SendCmd "camera reset" … … 1232 1230 1233 1231 itcl::body Rappture::VtkVolumeViewer::PanCamera {} { 1234 set x $_view( xpan)1235 set y $_view( ypan)1232 set x $_view(-xpan) 1233 set y $_view(-ypan) 1236 1234 SendCmd "camera pan $x $y" 1237 1235 } … … 1311 1309 set x [expr $x / double($w)] 1312 1310 set y [expr $y / double($h)] 1313 set _view( xpan) [expr $_view(xpan) + $x]1314 set _view( ypan) [expr $_view(ypan) + $y]1311 set _view(-xpan) [expr $_view(-xpan) + $x] 1312 set _view(-ypan) [expr $_view(-ypan) + $y] 1315 1313 PanCamera 1316 1314 return … … 1334 1332 set _click(x) $x 1335 1333 set _click(y) $y 1336 set _view( xpan) [expr $_view(xpan) - $dx]1337 set _view( ypan) [expr $_view(ypan) - $dy]1334 set _view(-xpan) [expr $_view(-xpan) - $dx] 1335 set _view(-ypan) [expr $_view(-ypan) - $dy] 1338 1336 PanCamera 1339 1337 } … … 1357 1355 itcl::body Rappture::VtkVolumeViewer::InitSettings { args } { 1358 1356 foreach spec $args { 1359 if { [info exists _settings($_first -$spec)] } {1357 if { [info exists _settings($_first${spec})] } { 1360 1358 # Reset global setting with dataobj specific setting 1361 set _settings($spec) $_settings($_first -$spec)1359 set _settings($spec) $_settings($_first${spec}) 1362 1360 } 1363 1361 AdjustSetting $spec … … 1381 1379 } 1382 1380 switch -- $what { 1383 " background" {1381 "-background" { 1384 1382 set bgcolor [$itk_component(background) value] 1383 set _settings(${what}) $bgcolor 1385 1384 array set fgcolors { 1386 1385 "black" "white" … … 1393 1392 DrawLegend 1394 1393 } 1395 " outline" {1396 set bool $_settings( outline)1394 "-volumeoutline" { 1395 set bool $_settings(${what}) 1397 1396 SendCmd "outline visible 0" 1398 1397 foreach tag [GetDatasetsWithComponent $_current] { … … 1400 1399 } 1401 1400 } 1402 "legendVisible" { 1403 set bool $_settings(legendVisible) 1404 set _settings($_current-legendVisible) $bool 1405 } 1406 "volumeVisible" { 1407 set bool $_settings(volumeVisible) 1408 set _settings($_current-volumeVisible) $bool 1401 "-legendvisible" { 1402 set bool $_settings(${what}) 1403 set _settings($_current${what}) $bool 1404 if { $bool } { 1405 blt::table $itk_component(plotarea) \ 1406 1,0 $itk_component(legend) -fill x 1407 } else { 1408 blt::table forget $itk_component(legend) 1409 } 1410 } 1411 "-volumevisible" { 1412 set bool $_settings(${what}) 1413 set _settings($_current${what}) $bool 1409 1414 # Only the data objects in the array _obj2ovride(*-raise) are 1410 1415 # in the working set and can be displayed on screen. The global … … 1429 1434 } 1430 1435 } 1431 " volumeBlendMode" {1436 "-volumeblendmode" { 1432 1437 set val [$itk_component(blendmode) value] 1433 1438 set mode [$itk_component(blendmode) translate $val] 1434 set _settings( volumeBlendMode) $mode1435 set _settings($_current -volumeBlendMode) $mode1439 set _settings(${what}) $mode 1440 set _settings($_current${what}) $mode 1436 1441 foreach tag [GetDatasetsWithComponent $_current] { 1437 1442 SendCmd "volume blendmode $mode $tag" 1438 1443 } 1439 1444 } 1440 " volumeAmbient" {1441 set val $_settings( volumeAmbient)1442 set _settings($_current -volumeAmbient) $val1445 "-volumeambient" { 1446 set val $_settings(${what}) 1447 set _settings($_current${what}) $val 1443 1448 set ambient [expr {0.01*$val}] 1444 1449 foreach tag [GetDatasetsWithComponent $_current] { … … 1446 1451 } 1447 1452 } 1448 " volumeDiffuse" {1449 set val $_settings( volumeDiffuse)1450 set _settings($_current -volumeDiffuse) $val1453 "-volumediffuse" { 1454 set val $_settings(${what}) 1455 set _settings($_current${what}) $val 1451 1456 set diffuse [expr {0.01*$val}] 1452 1457 foreach tag [GetDatasetsWithComponent $_current] { … … 1454 1459 } 1455 1460 } 1456 " volumeSpecularLevel" - "volumeSpecularExponent" {1457 set val $_settings( volumeSpecularLevel)1458 set _settings($_current -volumeSpecularLevel) $val1461 "-volumespecularlevel" - "-volumespecularexponent" { 1462 set val $_settings(${what}) 1463 set _settings($_current${what}) $val 1459 1464 set level [expr {0.01*$val}] 1460 set exp $_settings( volumeSpecularExponent)1465 set exp $_settings(${what}) 1461 1466 foreach tag [GetDatasetsWithComponent $_current] { 1462 1467 SendCmd "volume shading specular $level $exp $tag" 1463 1468 } 1464 1469 } 1465 " volumeLighting" {1466 set bool $_settings( volumeLighting)1467 set _settings($_current -volumeLighting) $bool1470 "-volumelighting" { 1471 set bool $_settings($what) 1472 set _settings($_current{$what}) $bool 1468 1473 foreach tag [GetDatasetsWithComponent $_current] { 1469 1474 SendCmd "volume lighting $bool $tag" 1470 1475 } 1471 1476 } 1472 " volumeOpacity" {1473 set val $_settings( volumeOpacity)1474 set _settings($_current -volumeOpacity) $val1477 "-volumeopacity" { 1478 set val $_settings(${what}) 1479 set _settings($_current${what}) $val 1475 1480 set val [expr {0.01*$val}] 1476 1481 foreach tag [GetDatasetsWithComponent $_current] { … … 1478 1483 } 1479 1484 } 1480 " volumeQuality" {1481 set val $_settings( volumeQuality)1482 set _settings($_current -volumeQuality) $val1485 "-volumequality" { 1486 set val $_settings(${what}) 1487 set _settings($_current${what}) $val 1483 1488 set val [expr {0.01*$val}] 1484 1489 foreach tag [GetDatasetsWithComponent $_current] { … … 1486 1491 } 1487 1492 } 1488 " axesVisible" {1489 set bool $_settings( axesVisible)1493 "-axesvisible" { 1494 set bool $_settings(${what}) 1490 1495 SendCmd "axis visible all $bool" 1491 1496 } 1492 " axisLabels" {1493 set bool $_settings( axisLabels)1497 "-axislabelsvisible" { 1498 set bool $_settings(${what}) 1494 1499 SendCmd "axis labels all $bool" 1495 1500 } 1496 " axisGridX" - "axisGridY" - "axisGridZ" {1497 set axis [string tolower [string range $what end end]]1498 set bool $_settings($ what)1501 "-xgridvisible" - "-ygridvisible" - "-zgridvisible" { 1502 set axis [string tolower [string range $what 1 1 ]] 1503 set bool $_settings(${what}) 1499 1504 SendCmd "axis grid $axis $bool" 1500 1505 } 1501 " axisFlyMode" {1506 "-axisflymode" { 1502 1507 set mode [$itk_component(axismode) value] 1503 1508 set mode [$itk_component(axismode) translate $mode] 1504 set _settings($ what) $mode1509 set _settings(${what}) $mode 1505 1510 SendCmd "axis flymode $mode" 1506 1511 } 1507 " cutplaneEdges" {1508 set bool $_settings($ what)1512 "-cutplaneedgesvisible" { 1513 set bool $_settings(${what}) 1509 1514 foreach dataset [CurrentDatasets -visible] { 1510 1515 if {$_cutplaneCmd != "imgcutplane"} { … … 1513 1518 } 1514 1519 } 1515 " cutplaneWireframe" {1516 set bool $_settings($ what)1520 "-cutplanewireframe" { 1521 set bool $_settings(${what}) 1517 1522 foreach dataset [CurrentDatasets -visible] { 1518 1523 if {$_cutplaneCmd != "imgcutplane"} { … … 1521 1526 } 1522 1527 } 1523 " cutplaneVisible" {1524 set bool $_settings($ what)1528 "-cutplanesvisible" { 1529 set bool $_settings(${what}) 1525 1530 foreach dataset [CurrentDatasets -visible] { 1526 1531 SendCmd "$_cutplaneCmd visible $bool $dataset" 1527 1532 } 1528 1533 } 1529 " cutplaneLighting" {1530 set bool $_settings($ what)1534 "-cutplanelighting" { 1535 set bool $_settings(${what}) 1531 1536 foreach dataset [CurrentDatasets -visible] { 1532 1537 if {$_cutplaneCmd != "imgcutplane"} { … … 1544 1549 } 1545 1550 } 1546 " cutplaneOpacity" {1547 set val $_settings($ what)1551 "-cutplaneopacity" { 1552 set val $_settings(${what}) 1548 1553 set sval [expr { 0.01 * double($val) }] 1549 1554 foreach dataset [CurrentDatasets -visible] { … … 1551 1556 } 1552 1557 } 1553 " cutplaneVisibleX" - "cutplaneVisibleY" - "cutplaneVisibleZ" {1554 set axis [string tolower [string range $what end end]]1555 set bool $_settings($ what)1558 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1559 set axis [string tolower [string range $what 1 1]] 1560 set bool $_settings(${what}) 1556 1561 if { $bool } { 1557 1562 $itk_component(${axis}CutScale) configure -state normal \ … … 1565 1570 } 1566 1571 } 1567 " cutplanePositionX" - "cutplanePositionY" - "cutplanePositionZ" {1568 set axis [string tolower [string range $what end end]]1569 set pos [expr $_settings($ what) * 0.01]1572 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" { 1573 set axis [string tolower [string range $what 1 1]] 1574 set pos [expr $_settings(${what}) * 0.01] 1570 1575 foreach dataset [CurrentDatasets -visible] { 1571 1576 SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset" … … 1573 1578 set _cutplanePending 0 1574 1579 } 1575 " volumeThickness" {1576 set _settings($_current -volumeThickness) $_settings(volumeThickness)1580 "-volumethickness" { 1581 set _settings($_current${what}) $_settings(${what}) 1577 1582 updateTransferFunctions 1578 1583 } 1579 " volumeColormap" {1584 "-color" { 1580 1585 set color [$itk_component(colormap) value] 1581 set _settings( colormap) $color1582 set _settings($_current -colormap) $color1586 set _settings(${what}) $color 1587 set _settings($_current${what}) $color 1583 1588 ResetColormap $_current $color 1584 1589 } 1585 " field" {1590 "-field" { 1586 1591 set label [$itk_component(field) value] 1587 1592 set fname [$itk_component(field) translate $label] 1588 set _settings( field) $fname1593 set _settings(${what}) $fname 1589 1594 if { [info exists _fields($fname)] } { 1590 1595 foreach { label units components } $_fields($fname) break … … 1666 1671 1667 1672 itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} { 1668 foreach { key value } {1669 grid 01670 axes 11671 outline 01672 volume 11673 legend 11674 particles 11675 lic 11676 } {1677 set _settings($this-$key) $value1678 }1679 1673 1680 1674 set fg [option get $itk_component(hull) font Font] … … 1688 1682 checkbutton $inner.axes \ 1689 1683 -text "Axes" \ 1690 -variable [itcl::scope _settings( axesVisible)] \1691 -command [itcl::code $this AdjustSetting axesVisible] \1684 -variable [itcl::scope _settings(-axesvisible)] \ 1685 -command [itcl::code $this AdjustSetting -axesvisible] \ 1692 1686 -font "Arial 9" 1693 1687 1694 1688 checkbutton $inner.outline \ 1695 1689 -text "Outline" \ 1696 -variable [itcl::scope _settings( outline)] \1697 -command [itcl::code $this AdjustSetting outline] \1690 -variable [itcl::scope _settings(-volumeoutline)] \ 1691 -command [itcl::code $this AdjustSetting -volumeoutline] \ 1698 1692 -font "Arial 9" 1699 1693 1700 1694 checkbutton $inner.legend \ 1701 1695 -text "Legend" \ 1702 -variable [itcl::scope _settings( legendVisible)] \1703 -command [itcl::code $this AdjustSetting legendVisible] \1696 -variable [itcl::scope _settings(-legendvisible)] \ 1697 -command [itcl::code $this AdjustSetting -legendvisible] \ 1704 1698 -font "Arial 9" 1705 1699 1706 1700 checkbutton $inner.volume \ 1707 1701 -text "Volume" \ 1708 -variable [itcl::scope _settings( volumeVisible)] \1709 -command [itcl::code $this AdjustSetting volumeVisible] \1702 -variable [itcl::scope _settings(-volumevisible)] \ 1703 -command [itcl::code $this AdjustSetting -volumevisible] \ 1710 1704 -font "Arial 9" 1711 1705 … … 1719 1713 "grey" "grey" 1720 1714 1721 $itk_component(background) value $_settings(background) 1722 bind $inner.background <<Value>> [itcl::code $this AdjustSetting background] 1715 $itk_component(background) value $_settings(-background) 1716 bind $inner.background <<Value>> \ 1717 [itcl::code $this AdjustSetting -background] 1723 1718 1724 1719 blt::table $inner \ … … 1749 1744 $itk_component(volcomponents) value "BCGYR" 1750 1745 bind $inner.volcomponents <<Value>> \ 1751 [itcl::code $this AdjustSetting current]1746 [itcl::code $this AdjustSetting -current] 1752 1747 1753 1748 checkbutton $inner.visibility \ 1754 1749 -text "Visible" \ 1755 1750 -font $font \ 1756 -variable [itcl::scope _settings( volumeVisible)] \1757 -command [itcl::code $this AdjustSetting volumeVisible]1751 -variable [itcl::scope _settings(-volumevisible)] \ 1752 -command [itcl::code $this AdjustSetting -volumevisible] 1758 1753 1759 1754 label $inner.lighting_l \ … … 1764 1759 -text "Enable Lighting" \ 1765 1760 -font $font \ 1766 -variable [itcl::scope _settings( volumeLighting)] \1767 -command [itcl::code $this AdjustSetting volumeLighting]1761 -variable [itcl::scope _settings(-volumelighting)] \ 1762 -command [itcl::code $this AdjustSetting -volumelighting] 1768 1763 1769 1764 label $inner.ambient_l \ … … 1771 1766 -font $font 1772 1767 ::scale $inner.ambient -from 0 -to 100 -orient horizontal \ 1773 -variable [itcl::scope _settings(volumeAmbient)] \ 1774 -showvalue off -command [itcl::code $this AdjustSetting volumeAmbient] \ 1768 -variable [itcl::scope _settings(-volumeambient)] \ 1769 -showvalue off \ 1770 -command [itcl::code $this AdjustSetting -volumeambient] \ 1775 1771 -troughcolor grey92 1776 1772 1777 1773 label $inner.diffuse_l -text "Diffuse" -font $font 1778 1774 ::scale $inner.diffuse -from 0 -to 100 -orient horizontal \ 1779 -variable [itcl::scope _settings(volumeDiffuse)] \ 1780 -showvalue off -command [itcl::code $this AdjustSetting volumeDiffuse] \ 1775 -variable [itcl::scope _settings(-volumediffuse)] \ 1776 -showvalue off \ 1777 -command [itcl::code $this AdjustSetting -volumediffuse] \ 1781 1778 -troughcolor grey92 1782 1779 1783 1780 label $inner.specularLevel_l -text "Specular" -font $font 1784 1781 ::scale $inner.specularLevel -from 0 -to 100 -orient horizontal \ 1785 -variable [itcl::scope _settings(volumeSpecularLevel)] \ 1786 -showvalue off -command [itcl::code $this AdjustSetting volumeSpecularLevel] \ 1782 -variable [itcl::scope _settings(-volumespecularlevel)] \ 1783 -showvalue off \ 1784 -command [itcl::code $this AdjustSetting -volumespecularlevel] \ 1787 1785 -troughcolor grey92 1788 1786 1789 1787 label $inner.specularExponent_l -text "Shininess" -font $font 1790 1788 ::scale $inner.specularExponent -from 10 -to 128 -orient horizontal \ 1791 -variable [itcl::scope _settings(volumeSpecularExponent)] \ 1792 -showvalue off -command [itcl::code $this AdjustSetting volumeSpecularExponent] \ 1789 -variable [itcl::scope _settings(-volumespecularexponent)] \ 1790 -showvalue off \ 1791 -command [itcl::code $this AdjustSetting -volumespecularexponent] \ 1793 1792 -troughcolor grey92 1794 1793 1795 1794 label $inner.opacity_l -text "Opacity" -font $font 1796 1795 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1797 -variable [itcl::scope _settings(volumeOpacity)] \ 1798 -showvalue off -command [itcl::code $this AdjustSetting volumeOpacity] \ 1796 -variable [itcl::scope _settings(-volumeopacity)] \ 1797 -showvalue off \ 1798 -command [itcl::code $this AdjustSetting -volumeopacity] \ 1799 1799 -troughcolor grey92 1800 1800 1801 1801 label $inner.quality_l -text "Quality" -font $font 1802 1802 ::scale $inner.quality -from 0 -to 100 -orient horizontal \ 1803 -variable [itcl::scope _settings(volumeQuality)] \ 1804 -showvalue off -command [itcl::code $this AdjustSetting volumeQuality] \ 1803 -variable [itcl::scope _settings(-volumequality)] \ 1804 -showvalue off \ 1805 -command [itcl::code $this AdjustSetting -volumequality] \ 1805 1806 -troughcolor grey92 1806 1807 … … 1810 1811 } 1811 1812 bind $inner.field <<Value>> \ 1812 [itcl::code $this AdjustSetting field]1813 [itcl::code $this AdjustSetting -field] 1813 1814 1814 1815 label $inner.transferfunction_l \ … … 1817 1818 label $inner.thin -text "Thin" -font $font 1818 1819 ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \ 1819 -variable [itcl::scope _settings(volumeThickness)] \ 1820 -showvalue off -command [itcl::code $this AdjustSetting volumeThickness] \ 1820 -variable [itcl::scope _settings(-volumethickness)] \ 1821 -showvalue off \ 1822 -command [itcl::code $this AdjustSetting -volumethickness] \ 1821 1823 -troughcolor grey92 1822 1824 1823 1825 label $inner.thick -text "Thick" -font $font 1824 $inner.thickness set $_settings( volumeThickness)1826 $inner.thickness set $_settings(-volumethickness) 1825 1827 1826 1828 label $inner.colormap_l -text "Colormap" -font $font … … 1848 1850 $itk_component(colormap) value "BCGYR" 1849 1851 bind $inner.colormap <<Value>> \ 1850 [itcl::code $this AdjustSetting volumeColormap]1852 [itcl::code $this AdjustSetting -color] 1851 1853 1852 1854 label $inner.blendmode_l -text "Blend Mode" -font $font … … 1859 1861 "additive" "Additive" 1860 1862 1861 $itk_component(blendmode) value "[$itk_component(blendmode) label $_settings(volumeBlendMode)]" 1863 $itk_component(blendmode) value \ 1864 "[$itk_component(blendmode) label $_settings(-volumeblendmode)]" 1862 1865 bind $inner.blendmode <<Value>> \ 1863 [itcl::code $this AdjustSetting volumeBlendMode]1866 [itcl::code $this AdjustSetting -volumeblendmode] 1864 1867 1865 1868 blt::table $inner \ … … 1910 1913 checkbutton $inner.visible \ 1911 1914 -text "Show Axes" \ 1912 -variable [itcl::scope _settings( axesVisible)] \1913 -command [itcl::code $this AdjustSetting axesVisible] \1915 -variable [itcl::scope _settings(-axesvisible)] \ 1916 -command [itcl::code $this AdjustSetting -axesvisible] \ 1914 1917 -font "Arial 9" 1915 1918 1916 1919 checkbutton $inner.labels \ 1917 1920 -text "Show Axis Labels" \ 1918 -variable [itcl::scope _settings( axisLabels)] \1919 -command [itcl::code $this AdjustSetting axisLabels] \1921 -variable [itcl::scope _settings(-axislabelsvisiboe)] \ 1922 -command [itcl::code $this AdjustSetting -axislabelsvisible] \ 1920 1923 -font "Arial 9" 1921 1924 1922 1925 checkbutton $inner.gridx \ 1923 1926 -text "Show X Grid" \ 1924 -variable [itcl::scope _settings( axisGridX)] \1925 -command [itcl::code $this AdjustSetting axisGridX] \1927 -variable [itcl::scope _settings(-xgridvisible)] \ 1928 -command [itcl::code $this AdjustSetting -xgridvisible] \ 1926 1929 -font "Arial 9" 1927 1930 checkbutton $inner.gridy \ 1928 1931 -text "Show Y Grid" \ 1929 -variable [itcl::scope _settings( axisGridY)] \1930 -command [itcl::code $this AdjustSetting axisGridY] \1932 -variable [itcl::scope _settings(-ygridvisible)] \ 1933 -command [itcl::code $this AdjustSetting -ygridvisible] \ 1931 1934 -font "Arial 9" 1932 1935 checkbutton $inner.gridz \ 1933 1936 -text "Show Z Grid" \ 1934 -variable [itcl::scope _settings( axisGridZ)] \1935 -command [itcl::code $this AdjustSetting axisGridZ] \1937 -variable [itcl::scope _settings(-zgridvisible)] \ 1938 -command [itcl::code $this AdjustSetting -zgridvisible] \ 1936 1939 -font "Arial 9" 1937 1940 … … 1983 1986 set row 1 1984 1987 1985 set labels { qx qy qz qw xpan ypanzoom }1988 set labels { -qx -qy -qz -qw -xpan -ypan -zoom } 1986 1989 foreach tag $labels { 1987 1990 label $inner.${tag}label -text $tag -font "Arial 9" … … 1998 2001 checkbutton $inner.ortho \ 1999 2002 -text "Orthographic Projection" \ 2000 -variable [itcl::scope _view( ortho)] \2003 -variable [itcl::scope _view(-ortho)] \ 2001 2004 -command [itcl::code $this camera set ortho] \ 2002 2005 -font "Arial 9" … … 2023 2026 checkbutton $inner.visible \ 2024 2027 -text "Show Cutplanes" \ 2025 -variable [itcl::scope _settings( cutplaneVisible)] \2026 -command [itcl::code $this AdjustSetting cutplaneVisible] \2028 -variable [itcl::scope _settings(-cutplanesvisible)] \ 2029 -command [itcl::code $this AdjustSetting -cutplanesvisible] \ 2027 2030 -font "Arial 9" 2028 2031 2029 2032 checkbutton $inner.wireframe \ 2030 2033 -text "Show Wireframe" \ 2031 -variable [itcl::scope _settings( cutplaneWireframe)] \2032 -command [itcl::code $this AdjustSetting cutplaneWireframe] \2034 -variable [itcl::scope _settings(-cutplanewireframe)] \ 2035 -command [itcl::code $this AdjustSetting -cutplanewireframe] \ 2033 2036 -font "Arial 9" 2034 2037 2035 2038 checkbutton $inner.lighting \ 2036 2039 -text "Enable Lighting" \ 2037 -variable [itcl::scope _settings( cutplaneLighting)] \2038 -command [itcl::code $this AdjustSetting cutplaneLighting] \2040 -variable [itcl::scope _settings(-cutplanelighting)] \ 2041 -command [itcl::code $this AdjustSetting -cutplanelighting] \ 2039 2042 -font "Arial 9" 2040 2043 2041 2044 checkbutton $inner.edges \ 2042 2045 -text "Show Edges" \ 2043 -variable [itcl::scope _settings( cutplaneEdges)] \2044 -command [itcl::code $this AdjustSetting cutplaneEdges] \2046 -variable [itcl::scope _settings(-cutplaneedgesvisible)] \ 2047 -command [itcl::code $this AdjustSetting -cutplaneedgesvisible] \ 2045 2048 -font "Arial 9" 2046 2049 2047 2050 label $inner.opacity_l -text "Opacity" -font "Arial 9" 2048 2051 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2049 -variable [itcl::scope _settings( cutplaneOpacity)] \2052 -variable [itcl::scope _settings(-cutplaneopacity)] \ 2050 2053 -width 10 \ 2051 2054 -showvalue off \ 2052 -command [itcl::code $this AdjustSetting cutplaneOpacity]2053 $inner.opacity set $_settings( cutplaneOpacity)2055 -command [itcl::code $this AdjustSetting -cutplaneopacity] 2056 $inner.opacity set $_settings(-cutplaneopacity) 2054 2057 2055 2058 # X-value slicer... … … 2058 2061 -onimage [Rappture::icon x-cutplane] \ 2059 2062 -offimage [Rappture::icon x-cutplane] \ 2060 -command [itcl::code $this AdjustSetting cutplaneVisibleX] \2061 -variable [itcl::scope _settings( cutplaneVisibleX)]2063 -command [itcl::code $this AdjustSetting -xcutplanevisible] \ 2064 -variable [itcl::scope _settings(-xcutplanevisible)] 2062 2065 } 2063 2066 Rappture::Tooltip::for $itk_component(xCutButton) \ … … 2070 2073 -borderwidth 1 -highlightthickness 0 \ 2071 2074 -command [itcl::code $this EventuallySetCutplane x] \ 2072 -variable [itcl::scope _settings( cutplanePositionX)]2075 -variable [itcl::scope _settings(-xcutplaneposition)] 2073 2076 } { 2074 2077 usual … … 2086 2089 -onimage [Rappture::icon y-cutplane] \ 2087 2090 -offimage [Rappture::icon y-cutplane] \ 2088 -command [itcl::code $this AdjustSetting cutplaneVisibleY] \2089 -variable [itcl::scope _settings( cutplaneVisibleY)]2091 -command [itcl::code $this AdjustSetting -ycutplanevisible] \ 2092 -variable [itcl::scope _settings(-ycutplanevisible)] 2090 2093 } 2091 2094 Rappture::Tooltip::for $itk_component(yCutButton) \ … … 2098 2101 -borderwidth 1 -highlightthickness 0 \ 2099 2102 -command [itcl::code $this EventuallySetCutplane y] \ 2100 -variable [itcl::scope _settings( cutplanePositionY)]2103 -variable [itcl::scope _settings(-ycutplaneposition)] 2101 2104 } { 2102 2105 usual … … 2114 2117 -onimage [Rappture::icon z-cutplane] \ 2115 2118 -offimage [Rappture::icon z-cutplane] \ 2116 -command [itcl::code $this AdjustSetting cutplaneVisibleZ] \2117 -variable [itcl::scope _settings( cutplaneVisibleZ)]2119 -command [itcl::code $this AdjustSetting -zcutplanevisible] \ 2120 -variable [itcl::scope _settings(-zcutplanevisible)] 2118 2121 } 2119 2122 Rappture::Tooltip::for $itk_component(zCutButton) \ … … 2126 2129 -borderwidth 1 -highlightthickness 0 \ 2127 2130 -command [itcl::code $this EventuallySetCutplane z] \ 2128 -variable [itcl::scope _settings( cutplanePositionZ)]2131 -variable [itcl::scope _settings(-zcutplaneposition)] 2129 2132 } { 2130 2133 usual … … 2170 2173 } 2171 2174 switch -- $who { 2172 " ortho" {2173 if {$_view( ortho)} {2175 "-ortho" { 2176 if {$_view(-ortho)} { 2174 2177 SendCmd "camera mode ortho" 2175 2178 } else { … … 2177 2180 } 2178 2181 } 2179 " xpan" - "ypan" {2182 "-xpan" - "-ypan" { 2180 2183 PanCamera 2181 2184 } 2182 " qx" - "qy" - "qz" - "qw" {2183 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2185 "-qx" - "-qy" - "-qz" - "-qw" { 2186 set q [ViewToQuaternion] 2184 2187 $_arcball quaternion $q 2185 2188 EventuallyRotate $q 2186 2189 } 2187 " zoom" {2188 SendCmd "camera zoom $_view( zoom)"2190 "-zoom" { 2191 SendCmd "camera zoom $_view(-zoom)" 2189 2192 } 2190 2193 } … … 2259 2262 # Parse style string. 2260 2263 set tag $dataobj-$cname 2261 set style [$dataobj style $cname] 2262 array set settings { 2263 -color \#808080 2264 -edges 0 2265 -edgecolor black 2266 -linewidth 1.0 2267 -opacity 0.4 2268 -wireframe 0 2269 -lighting 1 2270 -visible 1 2264 array set styles { 2265 -color BCGYR 2266 -volumeedgesvisible 0 2267 -volumeedgecolor black 2268 -volumelinewidth 1.0 2269 -volumewireframe 0 2270 -volumelighting 1 2271 -volumevisible 1 2272 -volumeoutline 0 2271 2273 } 2272 2274 if { $dataobj != $_first } { 2273 set s ettings(-opacity) 12274 } 2275 array set s ettings $style2275 set style(-opacity) 1 2276 } 2277 array set styles [$dataobj style $cname] 2276 2278 SendCmd "volume add $tag" 2279 set _settings($cname-volumewireframe) $styles(-volumewireframe) 2280 set _settings($cname-volumeedgesvisible) $styles(-volumeedgesvisible) 2281 set _settings($cname-volumeoutline) $styles(-volumeoutline) 2282 set _settings($cname-volumelighting) $styles(-volumelighting) 2283 set _settings($cname-volumevisible) $styles(-volumevisible) 2284 2285 $itk_component(colormap) value $styles(-color) 2286 2277 2287 SendCmd "$_cutplaneCmd add $tag" 2278 2288 SendCmd "$_cutplaneCmd visible 0 $tag" 2279 SendCmd "volume lighting $settings(-lighting) $tag" 2280 set _settings(volumeLighting) $settings(-lighting) 2289 SendCmd "volume lighting $styles(-volumelighting) $tag" 2281 2290 SetInitialTransferFunction $dataobj $cname 2282 2291 SendCmd "volume colormap $cname $tag" 2283 2292 SendCmd "$_cutplaneCmd colormap $cname-opaque $tag" 2284 2293 SendCmd "outline add $tag" 2285 SendCmd "outline visible 0$tag"2294 SendCmd "outline visible $styles(-volumeoutline) $tag" 2286 2295 } 2287 2296 … … 2387 2396 set title $fname 2388 2397 } 2389 if { $_settings( legendVisible) } {2398 if { $_settings(-legendvisible) } { 2390 2399 set x [expr $w - 2] 2391 2400 if { [$c find withtag "legend"] == "" } { … … 2674 2683 2675 2684 if { ![info exists _parsedFunction($cname)] || ![info exists _cname2transferFunction($cname)] } { 2676 array set style {2685 array set styles { 2677 2686 -color BCGYR 2678 2687 -levels 6 … … 2680 2689 -markers "" 2681 2690 } 2682 2683 2691 # Accumulate the style from all the datasets using it. 2684 2692 foreach tag [GetDatasetsWithComponent $cname] { 2685 2693 foreach {dataobj cname} [split [lindex $tag 0] -] break 2686 array set style [lindex [$dataobj components -style $cname] 0] 2687 } 2688 set cmap [ColorsToColormap $style(-color)] 2694 set option [lindex [$dataobj components -style $cname] 0] 2695 array set styles $option 2696 } 2697 set _settings($cname-color) $styles(-color) 2698 set _settings($cname-volumeopacity) $styles(-opacity) 2699 set cmap [ColorsToColormap $styles(-color)] 2689 2700 set _cname2defaultcolormap($cname) $cmap 2690 set _settings($cname-colormap) $style(-color)2691 2701 if { [info exists _transferFunctionEditors($cname)] } { 2692 2702 eval $_transferFunctionEditors($cname) limits $_limits($cname) 2693 2703 } 2694 if { [info exists style (-markers)] &&2695 [llength $style (-markers)] > 0 } {2696 ParseMarkersOption $cname $style (-markers)2704 if { [info exists styles(-markers)] && 2705 [llength $styles(-markers)] > 0 } { 2706 ParseMarkersOption $cname $styles(-markers) 2697 2707 } else { 2698 ParseLevelsOption $cname $style (-levels)2708 ParseLevelsOption $cname $styles(-levels) 2699 2709 } 2700 2710 } else { … … 2767 2777 bottom "0.707107 0.707107 0 0" 2768 2778 } 2769 foreach name { qw qx qyqz } value $positions($side) {2779 foreach name { -qw -qx -qy -qz } value $positions($side) { 2770 2780 set _view($name) $value 2771 2781 } 2772 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2782 set q [ViewToQuaternion] 2773 2783 $_arcball quaternion $q 2774 2784 SendCmd "camera orient $q" 2775 2785 SendCmd "camera reset" 2776 set _view(xpan) 0 2777 set _view(ypan) 0 2778 set _view(zoom) 1.0 2779 set _settings($this-xpan) $_view(xpan) 2780 set _settings($this-ypan) $_view(ypan) 2781 set _settings($this-zoom) $_view(zoom) 2786 set _view(-xpan) 0 2787 set _view(-ypan) 0 2788 set _view(-zoom) 1.0 2782 2789 } 2783 2790 … … 2792 2799 itcl::body Rappture::VtkVolumeViewer::InitComponentSettings { cname } { 2793 2800 array set _settings [subst { 2794 $cname-color mapdefault2801 $cname-color default 2795 2802 $cname-light2side 1 2796 $cname- outline02797 $cname-volume Ambient 402798 $cname-volume BlendMode composite2799 $cname-volume Diffuse 602800 $cname-volume Lighting 12801 $cname-volume Opacity 502802 $cname-volume Quality 802803 $cname-volume SpecularExponent 902804 $cname-volume SpecularLevel 302805 $cname-volume Thickness 3502806 $cname-volume Visible 12803 $cname-volumeoutline 0 2804 $cname-volumeambient 40 2805 $cname-volumeblendmode composite 2806 $cname-volumediffuse 60 2807 $cname-volumelighting 1 2808 $cname-volumeopacity 50 2809 $cname-volumequality 80 2810 $cname-volumespecularexponent 90 2811 $cname-volumespecularlevel 30 2812 $cname-volumethickness 350 2813 $cname-volumevisible 1 2807 2814 }] 2808 2815 } … … 2816 2823 # 2817 2824 itcl::body Rappture::VtkVolumeViewer::SwitchComponent { cname } { 2818 if { ![info exists _settings(${cname}-volume Ambient)] } {2825 if { ![info exists _settings(${cname}-volumeambient)] } { 2819 2826 InitComponentSettings $cname 2820 2827 } 2821 2828 # _settings variables change widgets, except for colormap 2822 2829 foreach name { 2823 light2side2824 outline2825 volumeAmbient2826 volumeBlendMode2827 volumeDiffuse2828 volumeLighting2829 volumeOpacity2830 volumeQuality2831 volumeSpecularExponent2832 volumeSpecularLevel2833 volumeThickness2834 volumeVisible2830 -volumelight2side 2831 -volumeoutline 2832 -volumeambient 2833 -volumeblendmode 2834 -volumediffuse 2835 -volumelighting 2836 -volumeopacity 2837 -volumequality 2838 -volumespecularexponent 2839 -volumespecularlevel 2840 -volumethickness 2841 -volumevisible 2835 2842 } { 2836 2843 set _settings($name) $_settings(${cname}-${name}) 2837 2844 } 2838 $itk_component(colormap) value $_settings($cname-color map)2845 $itk_component(colormap) value $_settings($cname-color) 2839 2846 set _current $cname; # Reset the current component 2840 2847 } … … 2844 2851 return [list 0.0 0.0 1.0 1.0] 2845 2852 } 2846 if { ![info exists _settings($cname-volume Ambient)] } {2853 if { ![info exists _settings($cname-volumeambient)] } { 2847 2854 InitComponentSettings $cname 2848 2855 } … … 2854 2861 # settings widgets) are used for the active transfer-function. Update 2855 2862 # the values in the _settings varible. 2856 set opacity [expr { double($_settings($cname-volume Opacity)) * 0.01 }]2863 set opacity [expr { double($_settings($cname-volumeopacity)) * 0.01 }] 2857 2864 2858 2865 # Scale values between 0.00001 and 0.01000 2859 set delta [expr {double($_settings($cname-volume Thickness)) * 0.0001}]2866 set delta [expr {double($_settings($cname-volumethickness)) * 0.0001}] 2860 2867 set first [lindex $isovalues 0] 2861 2868 set last [lindex $isovalues end]
Note: See TracChangeset
for help on using the changeset viewer.