Changeset 3986 for trunk/gui/scripts/vtkvolumeviewer.tcl
- Timestamp:
- Oct 3, 2013, 12:03:17 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkvolumeviewer.tcl
r3984 r3986 64 64 public method updateTransferFunctions {} 65 65 66 private method SetOrientation { side } 67 private method HideAllMarkers {} 68 private method GetColormap { cname color } 69 private method ResetColormap { cname color } 70 private method InitComponentSettings { cname } 71 private method SwitchComponent { cname } 72 private method GetDatasetsWithComponent { cname } 66 private method BuildVolumeComponents {} 73 67 private method ComputeAlphamap { cname } 74 68 private method ComputeTransferFunction { cname } 75 private method SetInitialTransferFunction { dataobj cname } 76 private method SendTransferFunctions {} 69 private method GetColormap { cname color } 70 private method GetDatasetsWithComponent { cname } 71 private method HideAllMarkers {} 72 private method InitComponentSettings { cname } 77 73 private method ParseLevelsOption { cname levels } 78 74 private method ParseMarkersOption { cname markers } 79 private method BuildVolumeComponents {} 75 private method ResetColormap { cname color } 76 private method SendTransferFunctions {} 77 private method SetInitialTransferFunction { dataobj cname } 78 private method SetOrientation { side } 79 private method SwitchComponent { cname } 80 80 81 81 private variable _current ""; # Currently selected component … … 110 110 private method BuildAxisTab {} 111 111 private method BuildCameraTab {} 112 private method BuildColormap { name colors }113 112 private method BuildCutplaneTab {} 114 113 private method BuildDownloadPopup { widget command } … … 129 128 private method PanCamera {} 130 129 private method RequestLegend {} 131 private method SetColormap { dataobj comp }132 private method ChangeColormap { dataobj comp color }133 130 private method SetLegendTip { x y } 134 131 private method SetObjectStyle { dataobj comp } … … 249 246 cutplaneLighting 1 250 247 cutplaneOpacity 100 248 cutplanePositionX 50 249 cutplanePositionY 50 250 cutplanePositionZ 50 251 251 cutplaneVisible 0 252 252 cutplaneVisibleX 1 … … 254 254 cutplaneVisibleZ 1 255 255 cutplaneWireframe 0 256 cutplaneXPosition 50257 cutplaneYPosition 50258 cutplaneZPosition 50259 256 legendVisible 1 260 257 volumeAmbient 40 … … 1369 1366 "volumeVisible" { 1370 1367 set bool $_settings(volumeVisible) 1371 foreach dataset [CurrentDatasets -visible] { 1372 SendCmd "volume visible $bool $dataset" 1368 set _settings($cname-volumeVisible) 1369 foreach tag [GetDatasetsWithComponent $_current] { 1370 SendCmd "volume visible $bool $tag" 1373 1371 } 1374 1372 if { $bool } { … … 1384 1382 set mode [$itk_component(blendmode) translate $val] 1385 1383 set _settings(volumeBlendMode) $mode 1386 foreach dataset [CurrentDatasets -visible] { 1387 SendCmd "volume blendmode $mode $dataset" 1384 set _settings($cname-volumeBlendMode) $mode 1385 foreach tag [GetDatasetsWithComponent $_current] { 1386 SendCmd "volume blendmode $mode $tag" 1388 1387 } 1389 1388 } 1390 1389 "volumeAmbient" { 1391 1390 set val $_settings(volumeAmbient) 1391 set _settings($cname-volumnAmbient) $val 1392 1392 set ambient [expr {0.01*$val}] 1393 foreach dataset [CurrentDatasets -visible] {1394 SendCmd "volume shading ambient $ambient $ dataset"1393 foreach tag [GetDatasetsWithComponent $_current] { 1394 SendCmd "volume shading ambient $ambient $tag" 1395 1395 } 1396 1396 } 1397 1397 "volumeDiffuse" { 1398 1398 set val $_settings(volumeDiffuse) 1399 set _settings($cname-volumeDiffuse) $val 1399 1400 set diffuse [expr {0.01*$val}] 1400 foreach dataset [CurrentDatasets -visible] {1401 SendCmd "volume shading diffuse $diffuse $ dataset"1401 foreach tag [GetDatasetsWithComponent $_current] { 1402 SendCmd "volume shading diffuse $diffuse $tag" 1402 1403 } 1403 1404 } 1404 1405 "volumeSpecularLevel" - "volumeSpecularExponent" { 1405 1406 set val $_settings(volumeSpecularLevel) 1406 set specularLevel [expr {0.01*$val}] 1407 set specularExponent $_settings(volumeSpecularExponent) 1408 foreach dataset [CurrentDatasets -visible] { 1409 SendCmd "volume shading specular $specularLevel $specularExponent $dataset" 1407 set _settings($cname-volumnSpecularLevel) $val 1408 set level [expr {0.01*$val}] 1409 set exp $_settings(volumeSpecularExponent) 1410 foreach tag [GetDatasetsWithComponent $_current] { 1411 SendCmd "volume shading specular $level $exp $tag" 1410 1412 } 1411 1413 } 1412 1414 "volumeLighting" { 1413 1415 set bool $_settings(volumeLighting) 1414 foreach dataset [CurrentDatasets -visible] { 1415 SendCmd "volume lighting $bool $dataset" 1416 set _settings($cname-volumeLighting) $bool 1417 foreach tag [GetDatasetsWithComponent $_current] { 1418 SendCmd "volume lighting $bool $tag" 1416 1419 } 1417 1420 } 1418 1421 "volumeOpacity" { 1419 1422 set val $_settings(volumeOpacity) 1423 set _settings($cname-volumeOpacity) $val 1420 1424 set val [expr {0.01*$val}] 1421 foreach dataset [CurrentDatasets -visible] {1422 SendCmd "volume opacity $val $ dataset"1425 foreach tag [GetDatasetsWithComponent $_current] { 1426 SendCmd "volume opacity $val $tag" 1423 1427 } 1424 1428 } 1425 1429 "volumeQuality" { 1426 1430 set val $_settings(volumeQuality) 1431 set _settings($cname-volumeQuality) $val 1427 1432 set val [expr {0.01*$val}] 1428 foreach dataset [CurrentDatasets -visible] {1429 SendCmd "volume quality $val $ dataset"1433 foreach tag [GetDatasetsWithComponent $_current] { 1434 SendCmd "volume quality $val $tag" 1430 1435 } 1431 1436 } … … 1569 1574 } 1570 1575 } 1571 }1572 1573 #1574 # ChangeColormap --1575 #1576 itcl::body Rappture::VtkVolumeViewer::ChangeColormap {dataobj comp color} {1577 set tag $dataobj-$comp1578 if { ![info exist _style($tag)] } {1579 error "no initial colormap"1580 }1581 array set style $_style($tag)1582 set style(-color) $color1583 set _style($tag) [array get style]1584 SetColormap $dataobj $comp1585 }1586 1587 #1588 # SetColormap --1589 #1590 itcl::body Rappture::VtkVolumeViewer::SetColormap { dataobj comp } {1591 array set style {1592 -color BCGYR1593 -levels 61594 -opacity 1.01595 }1596 set tag $dataobj-$comp1597 if { ![info exists _initialStyle($tag)] } {1598 # Save the initial component style.1599 set _initialStyle($tag) [$dataobj style $comp]1600 }1601 1602 # Override defaults with initial style defined in xml.1603 array set style $_initialStyle($tag)1604 1605 if { ![info exists _style($tag)] } {1606 set _style($tag) [array get style]1607 }1608 # Override initial style with current style.1609 array set style $_style($tag)1610 1611 set name "$style(-color):$style(-levels):$style(-opacity)"1612 if { ![info exists _colormaps($name)] } {1613 BuildColormap $name [array get style]1614 set _colormaps($name) 11615 }1616 if { ![info exists _dataset2style($tag)] ||1617 $_dataset2style($tag) != $name } {1618 SendCmd "volume colormap $name $tag"1619 SendCmd "cutplane colormap $name-opaque $tag"1620 set _dataset2style($tag) $name1621 }1622 }1623 1624 #1625 # BuildColormap --1626 #1627 itcl::body Rappture::VtkVolumeViewer::BuildColormap { name styles } {1628 array set style $styles1629 set cmap [ColorsToColormap $style(-color)]1630 if { [llength $cmap] == 0 } {1631 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"1632 }1633 if { ![info exists _settings(volumeOpacity)] } {1634 set _settings(volumeOpacity) $style(-opacity)1635 }1636 set max $_settings(volumeOpacity)1637 1638 set opaqueWmap "0.0 1.0 1.0 1.0"1639 #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"1640 # Approximate cubic opacity curve1641 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"1642 SendCmd "colormap add $name { $cmap } { $wmap }"1643 SendCmd "colormap add $name-opaque { $cmap } { $opaqueWmap }"1644 1576 } 1645 1577
Note: See TracChangeset
for help on using the changeset viewer.