- Timestamp:
- Mar 29, 2008, 4:38:06 PM (16 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/isomarker.tcl
r968 r971 53 53 $_canvas delete $this 54 54 } 55 55 public method GetVolume {} { 56 return $_ivol 57 } 56 58 public method GetAbsoluteValue {} { 57 59 return $_value … … 137 139 SetRelativeValue [expr {double($x-10)/($w-20)}] 138 140 $_nvobj OverIsoMarker $this $x 139 foreach { dataobj comp } [$_nvobj GetDataObj $_ivol] break 140 $_nvobj UpdateTransferFunction $dataobj $comp 141 $_nvobj UpdateTransferFunction $_ivol 141 142 } 142 143 end { -
trunk/gui/scripts/nanovisviewer.tcl
r970 r971 75 75 } 76 76 public method isconnected {} 77 public method UpdateTransferFunction { dataobj comp}77 public method UpdateTransferFunction { ivol } 78 78 public method RemoveDuplicateIsoMarker { m x } 79 79 public method OverIsoMarker { m x } … … 87 87 88 88 protected method _ReceiveImage {option size} 89 protected method _ReceiveLegend { ivol vmin vmax size}90 protected method _ReceiveData { args}89 protected method _ReceiveLegend { ivol vmin vmax size } 90 protected method _ReceiveData { args } 91 91 92 92 protected method _rebuild {} … … 102 102 protected method _fixSettings {what {value ""}} 103 103 protected method _fixLegend {} 104 protected method GenTransfuncData {dataobj comp}105 104 106 105 # The following methods are only used by this class. 107 private method _AddIsoMarker { x y } 108 private method _InitIsoMarkers {dataobj comp} 109 private method _HideIsoMarkers {dataobj comp} 110 private method _ShowIsoMarkers {dataobj comp} 111 private method _ParseMarkersOption { tag markers } 112 private method _ParseLevelsOption { tag levels } 106 private method _SetTransfuncData { ivol } 107 private method _AddIsoMarker { ivol x y } 108 private method _InitIsoMarkers { ivol } 109 private method _HideIsoMarkers { ivol } 110 private method _ShowIsoMarkers { ivol } 111 private method _ParseMarkersOption { ivol markers } 112 private method _ParseLevelsOption { ivol levels } 113 113 114 114 private variable _outbuf ;# buffer for outgoing commands … … 117 117 private variable _all_data_objs 118 118 private variable _dims "" ;# dimensionality of data objects 119 private variable _ obj2style ;# maps dataobj=> style settings119 private variable _id2style ;# maps id => style settings 120 120 private variable _obj2ovride ;# maps dataobj => style override 121 121 private variable _obj2id ;# maps dataobj => volume ID in server … … 795 795 foreach key [array names _obj2id *-*] { 796 796 set state [string match $first-* $key] 797 _send "volume state $state $_obj2id($key)" 798 if {[info exists _obj2style($key)]} { 799 _send "volume shading transfunc $_obj2style($key) $_obj2id($key)" 797 set ivol $_obj2id($key) 798 _send "volume state $state $ivol" 799 if {[info exists _id2style($ivol)]} { 800 _send "volume shading transfunc $_id2style($ivol) $ivol" 800 801 } 801 802 } … … 828 829 # and make sure that it's defined on the server. 829 830 # 830 if { ![info exists _isomarkers($dataobj-$comp)] } { 831 _InitIsoMarkers $dataobj $comp 831 set ivol $_obj2id($dataobj-$comp) 832 if { ![info exists _isomarkers($ivol)] } { 833 _InitIsoMarkers $ivol 832 834 } else { 833 _HideIsoMarkers $dataobj $comp 834 } 835 foreach {sname cmap wmap} [GenTransfuncData $dataobj $comp] break 836 set cmdstr [list transfunc define $sname $cmap $wmap] 837 if {![SendBytes $cmdstr] } { 835 _HideIsoMarkers $ivol 836 } 837 if { ![_SetTransfuncData $ivol] } { 838 838 return 839 839 } 840 set _obj2style($dataobj-$comp) $sname841 840 } 842 841 } … … 848 847 foreach key [array names _obj2id *-*] { 849 848 set state [string match $first-* $key] 850 _send "volume state $state $_obj2id($key)" 851 if {[info exists _obj2style($key)]} { 852 _send "volume shading transfunc $_obj2style($key) $_obj2id($key)" 849 set ivol $_obj2id($key) 850 _send "volume state $state $ivol" 851 if {[info exists _id2style($ivol)]} { 852 _send "volume shading transfunc $_id2style($ivol) $ivol" 853 853 } 854 854 } 855 855 set comp [lindex [$dataobj components] 0] 856 _ShowIsoMarkers $ first $comp856 _ShowIsoMarkers $_obj2id($first-$comp) 857 857 # if there are any commands in the buffer, send them now that we're done 858 858 SendBytes $_outbuf … … 892 892 set w [winfo width $c] 893 893 set h [winfo height $c] 894 foreach { dataobj comp } $_id2obj($ivol) break 894 895 if {"" == [$c find withtag transfunc]} { 895 896 $c create image 10 10 -anchor nw \ … … 901 902 $c lower transfunc 902 903 $c bind transfunc <ButtonRelease-1> \ 903 [itcl::code $this _AddIsoMarker %x %y]904 [itcl::code $this _AddIsoMarker $ivol %x %y] 904 905 } 905 906 $c itemconfigure vmin -text $_limits($ivol-min) … … 909 910 $c coords vmax [expr {$w-10}] [expr {$h-8}] 910 911 911 foreach { dataobj comp } $_id2obj($ivol) break 912 _ShowIsoMarkers $dataobj $comp 912 _ShowIsoMarkers $ivol 913 913 } 914 914 } … … 995 995 } 996 996 set comp [lindex [$dataobj components] 0] 997 _ShowIsoMarkers $first $comp 998 UpdateTransferFunction $first $comp 997 set ivol $_obj2id($first-$comp) 998 999 _ShowIsoMarkers $ivol 1000 UpdateTransferFunction $ivol 999 1001 1000 1002 # sync the state of slicers … … 1313 1315 set val [$inner.scales.opacity get] 1314 1316 set sval [expr { 0.01 * double($val) }] 1317 # FIXME: This will change when we can select the current 1318 # volume. 1315 1319 set comp [lindex [$dataobj components] 0] 1316 1320 set tag $dataobj-$comp 1317 1321 set _settings($this-$tag-opacity) $sval 1318 UpdateTransferFunction $ dataobj $comp1322 UpdateTransferFunction $_obj2id($tag) 1319 1323 } 1320 1324 } … … 1328 1332 # Scale values between 0.00001 and 0.01000 1329 1333 set sval [expr {0.0001*double($val)}] 1334 # FIXME: This will change when we can select the current 1335 # volume. 1330 1336 set comp [lindex [$dataobj components] 0] 1331 1337 set tag $dataobj-$comp 1332 1338 set _settings($this-$tag-thickness) $sval 1333 UpdateTransferFunction $ dataobj $comp1339 UpdateTransferFunction $_obj2id($dataobj-$comp) 1334 1340 } 1335 1341 } … … 1374 1380 set ivol "" 1375 1381 1382 # The changes when we can select the current volume. 1376 1383 set dataobj [lindex [get] 0] 1377 1384 if {"" != $dataobj} { … … 1389 1396 1390 1397 # ---------------------------------------------------------------------- 1391 # USAGE: GenTransfuncData <dataobj> <comp>1398 # USAGE: _SetTransfuncData <ivol> 1392 1399 # 1393 1400 # Used internally to compute the colormap and alpha map used to define … … 1395 1402 # Returns: name {v r g b ...} {v w ...} 1396 1403 # ---------------------------------------------------------------------- 1397 itcl::body Rappture::NanovisViewer:: GenTransfuncData {dataobj comp} {1404 itcl::body Rappture::NanovisViewer::_SetTransfuncData { ivol } { 1398 1405 array set style { 1399 1406 -color rainbow … … 1401 1408 -opacity 1.0 1402 1409 } 1410 foreach {dataobj comp} $_id2obj($ivol) break 1403 1411 array set style [lindex [$dataobj components -style $comp] 0] 1404 1412 set sname "$style(-color):$style(-levels):$style(-opacity)" … … 1416 1424 append cmap "1.0 [Color2RGB $color]" 1417 1425 1418 set tag $ dataobj-$comp1419 if { ![info exists _settings($t his-$tag-opacity)] } {1420 set _settings($t his-$tag-opacity) $style(-opacity)1421 } 1422 set max $_settings($t his-$tag-opacity)1426 set tag $this-$ivol 1427 if { ![info exists _settings($tag-opacity)] } { 1428 set _settings($tag-opacity) $style(-opacity) 1429 } 1430 set max $_settings($tag-opacity) 1423 1431 1424 1432 set isovalues {} 1425 foreach m $_isomarkers($ tag) {1433 foreach m $_isomarkers($ivol) { 1426 1434 lappend isovalues [$m GetRelativeValue] 1427 1435 } … … 1431 1439 1432 1440 set delta 0.01 1433 if { [info exists _settings($t his-$tag-thickness)]} {1434 set delta $_settings($t his-$tag-thickness)1441 if { [info exists _settings($tag-thickness)]} { 1442 set delta $_settings($tag-thickness) 1435 1443 } 1436 1444 set first [lindex $isovalues 0] … … 1466 1474 lappend wmap 1.0 0.0 1467 1475 } 1468 return [list $sname $cmap $wmap] 1476 set _id2style($ivol) $sname 1477 return [_send transfunc define $sname $cmap $wmap] 1469 1478 } 1470 1479 … … 1509 1518 } 1510 1519 1511 itcl::body Rappture::NanovisViewer::_HideIsoMarkers {dataobj comp} { 1512 set tag $dataobj-$comp 1513 if { [info exists _isomarkers($tag)] } { 1514 foreach m $_isomarkers($tag) { 1520 itcl::body Rappture::NanovisViewer::_HideIsoMarkers { ivol } { 1521 if { [info exists _isomarkers($ivol)] } { 1522 foreach m $_isomarkers($ivol) { 1515 1523 $m Hide 1516 1524 } … … 1518 1526 } 1519 1527 1520 itcl::body Rappture::NanovisViewer::_ShowIsoMarkers { dataobj comp} {1521 set tag $dataobj-$comp1528 itcl::body Rappture::NanovisViewer::_ShowIsoMarkers { ivol } { 1529 # Clear all markers 1522 1530 foreach dataobj [array names _all_data_objs] { 1523 1531 foreach comp [$dataobj components] { 1524 _HideIsoMarkers $dataobj $comp1532 _HideIsoMarkers _$obj2id($dataobj-$comp) 1525 1533 } 1526 1534 } 1527 if { ![info exists _isomarkers($ tag)] } {1535 if { ![info exists _isomarkers($ivol)] } { 1528 1536 return 1529 1537 } 1530 foreach m $_isomarkers($ tag) {1538 foreach m $_isomarkers($ivol) { 1531 1539 $m Show 1532 1540 } … … 1538 1546 # marker is a relative value from 0.0 to 1.0. 1539 1547 # 1540 itcl::body Rappture::NanovisViewer::_ParseLevelsOption { taglevels } {1548 itcl::body Rappture::NanovisViewer::_ParseLevelsOption { ivol levels } { 1541 1549 set c $itk_component(legend) 1542 set ivol $_obj2id($tag)1543 1550 regsub -all "," $levels " " levels 1544 1551 for {set i 1} { $i <= $levels } {incr i} { … … 1546 1553 set m [IsoMarker \#auto $c $this $ivol] 1547 1554 $m SetRelativeValue $x 1548 lappend _isomarkers($ tag) $m1555 lappend _isomarkers($ivol) $m 1549 1556 } 1550 1557 } … … 1562 1569 # not be seen. 1563 1570 # 1564 itcl::body Rappture::NanovisViewer::_ParseMarkersOption { tag markers} {1571 itcl::body Rappture::NanovisViewer::_ParseMarkersOption { ivol markers } { 1565 1572 set c $itk_component(legend) 1566 1573 regsub -all "," $markers " " markers 1567 set ivol $_obj2id($tag)1568 1574 foreach marker $markers { 1569 1575 set n [scan $marker "%g%s" value suffix] … … 1573 1579 set m [IsoMarker \#auto $c $this $ivol] 1574 1580 $m SetRelativeValue $value 1575 lappend _isomarkers($ tag) $m1581 lappend _isomarkers($ivol) $m 1576 1582 } else { 1577 1583 # ${n} : Set absolute value. 1578 1584 set m [IsoMarker \#auto $c $this $ivol] 1579 1585 $m SetAbsoluteValue $value 1580 lappend _isomarkers($ tag) $m1581 } 1582 } 1583 } 1584 1585 itcl::body Rappture::NanovisViewer::_InitIsoMarkers { dataobj comp} {1586 lappend _isomarkers($ivol) $m 1587 } 1588 } 1589 } 1590 1591 itcl::body Rappture::NanovisViewer::_InitIsoMarkers { ivol } { 1586 1592 array set style { 1587 1593 -levels 6 1588 1594 } 1595 foreach {dataobj comp} $_id2obj($ivol) break 1589 1596 array set style [lindex [$dataobj components -style $comp] 0] 1590 set tag $dataobj-$comp 1597 1591 1598 if { [info exists style(-markers)] } { 1592 _ParseMarkersOption $ tag$style(-markers)1599 _ParseMarkersOption $ivol $style(-markers) 1593 1600 } else { 1594 _ParseLevelsOption $ tag$style(-levels)1601 _ParseLevelsOption $ivol $style(-levels) 1595 1602 } 1596 1603 } … … 1606 1613 # legend. 1607 1614 # ---------------------------------------------------------------------- 1608 itcl::body Rappture::NanovisViewer::UpdateTransferFunction { dataobj comp} {1609 if { "" == $dataobj} {1615 itcl::body Rappture::NanovisViewer::UpdateTransferFunction { ivol } { 1616 if {![info exists _id2style($ivol)]} { 1610 1617 return 1611 1618 } 1612 set tag $dataobj-$comp1613 if {![info exists _obj2style($tag)]} {1614 return1615 }1616 1619 # Compute a transfer function for the current data set. 1617 foreach {sname cmap wmap} [GenTransfuncData $dataobj $comp] break 1618 _send [list transfunc define $_obj2style($tag) $cmap $wmap] 1619 _send [list volume shading transfunc $_obj2style($tag) $_obj2id($tag)] 1620 _SetTransfuncData $ivol 1621 _send [list volume shading transfunc $_id2style($ivol) $ivol] 1620 1622 _fixLegend 1621 1623 } 1622 1624 1623 itcl::body Rappture::NanovisViewer::_AddIsoMarker { x y } { 1624 set dataobj [lindex [get] 0] 1625 if {$dataobj == ""} { 1626 return 0; # No data sets defined 1627 } 1628 set comp [lindex [$dataobj components] 0] 1629 set ivol $_obj2id($dataobj-$comp) 1625 itcl::body Rappture::NanovisViewer::_AddIsoMarker { ivol x y } { 1630 1626 set c $itk_component(legend) 1631 1627 set m [IsoMarker \#auto $c $this $ivol] … … 1633 1629 $m SetRelativeValue [expr {double($x-10)/($w-20)}] 1634 1630 $m Show 1635 lappend _isomarkers($ dataobj) $m1636 UpdateTransferFunction $ dataobj $comp1631 lappend _isomarkers($ivol) $m 1632 UpdateTransferFunction $ivol 1637 1633 return 1 1638 1634 } 1639 1635 1640 1636 itcl::body Rappture::NanovisViewer::RemoveDuplicateIsoMarker { marker x } { 1641 set dataobj [lindex [get] 0] 1642 if {"" == $dataobj} { 1643 return 0 1644 } 1637 set ivol [$marker GetVolume] 1645 1638 set bool 0 1646 set comp [lindex [$dataobj components] 0] 1647 if { [info exists _isomarkers($dataobj)] } { 1639 if { [info exists _isomarkers($ivol)] } { 1648 1640 set list {} 1649 1641 set marker [namespace tail $marker] 1650 foreach m $_isomarkers($ dataobj) {1642 foreach m $_isomarkers($tag) { 1651 1643 set sx [$m GetScreenPosition] 1652 1644 if { $m != $marker } { … … 1661 1653 lappend list $m 1662 1654 } 1663 set _isomarkers($ dataobj) $list1664 UpdateTransferFunction $ dataobj $comp1655 set _isomarkers($ivol) $list 1656 UpdateTransferFunction $ivol 1665 1657 } 1666 1658 return $bool … … 1668 1660 1669 1661 itcl::body Rappture::NanovisViewer::OverIsoMarker { marker x } { 1670 set dataobj [lindex [get] 0] 1671 if {"" == $dataobj} { 1672 return "" 1673 } 1674 if { [info exists _isomarkers($dataobj)] } { 1662 set ivol [$marker GetVolume] 1663 if { [info exists _isomarkers($ivol)] } { 1675 1664 set marker [namespace tail $marker] 1676 foreach m $_isomarkers($ dataobj) {1665 foreach m $_isomarkers($ivol) { 1677 1666 set sx [$m GetScreenPosition] 1678 1667 if { $m != $marker } {
Note: See TracChangeset
for help on using the changeset viewer.