Changeset 968 for trunk/gui/scripts
- Timestamp:
- Mar 28, 2008 1:48:13 PM (16 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/isomarker.tcl
r966 r968 22 22 private variable _canvas "" 23 23 private variable _nvobj ""; # Parent nanovis object. 24 private variable _ivol ""; # Id of volume that this marker is 25 # associated with. 24 26 private variable _active_motion 0 25 27 private variable _active_press 0 … … 27 29 private common _activeIcon [Rappture::icon nvlegendmark2] 28 30 29 constructor {c obj args} {31 constructor {c obj ivol args} { 30 32 set _canvas $c 31 33 set _nvobj $obj 32 34 set _ivol $ivol 33 35 set w [winfo width $_canvas] 34 36 set h [winfo height $_canvas] … … 56 58 } 57 59 public method GetRelativeValue {} { 58 array set limits [$_nvobj get_limits] 59 if { $limits(vmax) == $limits(vmin) } { 60 set limits(vmin) 0.0 61 set limits(vmax) 1.0 60 array set limits [$_nvobj GetLimits $_ivol] 61 if { $limits(max) == $limits(min) } { 62 if { $limits(max) == 0.0 } { 63 set limits(min) 0.0 64 set limits(max) 1.0 65 } else { 66 set limits(max) [expr $limits(min) + 1.0] 67 } 62 68 } 63 return [expr {($_value-$limits( vmin))/($limits(vmax) - $limits(vmin))}]69 return [expr {($_value-$limits(min))/($limits(max) - $limits(min))}] 64 70 } 65 71 public method Activate { bool } { … … 102 108 } 103 109 public method SetRelativeValue { x } { 104 array set limits [$_nvobj get_limits]105 if { $limits( vmax) == $limits(vmin) } {106 set limits( vmin) 0.0107 set limits( vmax) 1.0110 array set limits [$_nvobj GetLimits $_ivol] 111 if { $limits(max) == $limits(min) } { 112 set limits(min) 0.0 113 set limits(max) 1.0 108 114 } 109 set r [expr $limits( vmax) - $limits(vmin)]110 SetAbsoluteValue [expr {($x * $r) + $limits( vmin)}]115 set r [expr $limits(max) - $limits(min)] 116 SetAbsoluteValue [expr {($x * $r) + $limits(min)}] 111 117 } 112 118 public method HandleEvent { option args } { … … 131 137 SetRelativeValue [expr {double($x-10)/($w-20)}] 132 138 $_nvobj OverIsoMarker $this $x 133 $_nvobj UpdateTransferFunction 139 foreach { dataobj comp } [$_nvobj GetDataObj $_ivol] break 140 $_nvobj UpdateTransferFunction $dataobj $comp 134 141 } 135 142 end { -
trunk/gui/scripts/nanovisviewer.tcl
r966 r968 57 57 public method delete {args} 58 58 public method scale {args} 59 public method get_limits { { option ""} } { 60 return [array get _limits] 59 public method GetDataObj { ivol } { 60 if { ![info exists _id2obj($ivol)] } { 61 return "" 62 } 63 return $_id2obj($ivol) 64 } 65 public method GetLimits { {ivol ""} } { 66 if { $ivol != "" } { 67 set _limits(min) $_limits($ivol-min) 68 set _limits(max) $_limits($ivol-max) 69 } 70 return [array get _limits] 61 71 } 62 72 public method download {option args} … … 65 75 } 66 76 public method isconnected {} 67 public method UpdateTransferFunction { }77 public method UpdateTransferFunction { dataobj comp } 68 78 public method RemoveDuplicateIsoMarker { m x } 69 79 public method OverIsoMarker { m x } … … 76 86 protected method _send_transfuncs {} 77 87 78 protected method _ receive_image {option size}79 protected method _ receive_legend {ivol vmin vmax size}80 protected method _ receive_data {args}88 protected method _ReceiveImage {option size} 89 protected method _ReceiveLegend {ivol vmin vmax size} 90 protected method _ReceiveData {args} 81 91 82 92 protected method _rebuild {} … … 97 107 private method _AddIsoMarker { x y } 98 108 private method _InitIsoMarkers {dataobj comp} 99 private method _HideIsoMarkers {dataobj }100 private method _ShowIsoMarkers {dataobj }101 private method _ParseMarkersOption { dataobj markers}102 private method _ParseLevelsOption { dataobj markers}109 private method _HideIsoMarkers {dataobj comp} 110 private method _ShowIsoMarkers {dataobj comp} 111 private method _ParseMarkersOption { tag markers } 112 private method _ParseLevelsOption { tag levels } 103 113 104 114 private variable _outbuf ;# buffer for outgoing commands … … 114 124 private variable _sendobjs2 "" ;# list of data objs to send to server 115 125 private variable _receiveids ;# list of data objs to send to server 116 private variable _opacity117 private variable _thickness118 126 119 127 private variable _click ;# info used for _move operations … … 155 163 # Populate parser with commands handle incoming requests 156 164 # 157 $_parser alias image [itcl::code $this _ receive_image]158 $_parser alias legend [itcl::code $this _ receive_legend]159 $_parser alias data [itcl::code $this _ receive_data]165 $_parser alias image [itcl::code $this _ReceiveImage] 166 $_parser alias legend [itcl::code $this _ReceiveLegend] 167 $_parser alias data [itcl::code $this _ReceiveData] 160 168 161 169 # Initialize the view to some default parameters. … … 785 793 } 786 794 } 795 foreach key [array names _obj2id *-*] { 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)" 800 } 801 } 787 802 788 803 # sync the state of slicers … … 813 828 # and make sure that it's defined on the server. 814 829 # 815 if { ![info exists _isomarkers($dataobj )] } {830 if { ![info exists _isomarkers($dataobj-$comp)] } { 816 831 _InitIsoMarkers $dataobj $comp 817 832 } else { 818 _HideIsoMarkers $dataobj 833 _HideIsoMarkers $dataobj $comp 819 834 } 820 835 foreach {sname cmap wmap} [GenTransfuncData $dataobj $comp] break … … 838 853 } 839 854 } 840 _ShowIsoMarkers $first 855 set comp [lindex [$dataobj components] 0] 856 _ShowIsoMarkers $first $comp 841 857 # if there are any commands in the buffer, send them now that we're done 842 858 SendBytes $_outbuf … … 846 862 847 863 # ---------------------------------------------------------------------- 848 # USAGE: _ receive_image -bytes <size>864 # USAGE: _ReceiveImage -bytes <size> 849 865 # 850 866 # Invoked automatically whenever the "image" command comes in from … … 852 868 # specified <size> will follow. 853 869 # ---------------------------------------------------------------------- 854 itcl::body Rappture::NanovisViewer::_ receive_image {option size} {870 itcl::body Rappture::NanovisViewer::_ReceiveImage {option size} { 855 871 if { [isconnected] } { 856 872 set bytes [ReceiveBytes $size] … … 861 877 862 878 # ---------------------------------------------------------------------- 863 # USAGE: _ receive_legend <volume> <vmin> <vmax> <size>879 # USAGE: _ReceiveLegend <volume> <vmin> <vmax> <size> 864 880 # 865 881 # Invoked automatically whenever the "legend" command comes in from … … 867 883 # specified <size> will follow. 868 884 # ---------------------------------------------------------------------- 869 itcl::body Rappture::NanovisViewer::_ receive_legend { ivol vmin vmax size } {885 itcl::body Rappture::NanovisViewer::_ReceiveLegend { ivol vmin vmax size } { 870 886 if { [isconnected] } { 871 887 set bytes [ReceiveBytes $size] … … 887 903 [itcl::code $this _AddIsoMarker %x %y] 888 904 } 889 $c itemconfigure vmin -text $ vmin905 $c itemconfigure vmin -text $_limits($ivol-min) 890 906 $c coords vmin 10 [expr {$h-8}] 891 907 892 $c itemconfigure vmax -text $vmax908 $c itemconfigure vmax -text $_limits($ivol-max) 893 909 $c coords vmax [expr {$w-10}] [expr {$h-8}] 894 set first [lindex [get] 0] 895 _ShowIsoMarkers $first 896 } 897 } 898 899 # ---------------------------------------------------------------------- 900 # USAGE: _receive_data <volume> <vmin> <vmax> 910 911 foreach { dataobj comp } $_id2obj($ivol) break 912 _ShowIsoMarkers $dataobj $comp 913 } 914 } 915 916 # ---------------------------------------------------------------------- 917 # USAGE: _ReceiveData <volume> <vmin> <vmax> 901 918 # 902 919 # Invoked automatically whenever the "legend" command comes in from … … 904 921 # specified <size> will follow. 905 922 # ---------------------------------------------------------------------- 906 itcl::body Rappture::NanovisViewer::_ receive_data { args } {923 itcl::body Rappture::NanovisViewer::_ReceiveData { args } { 907 924 if { [isconnected] } { 908 925 array set info $args 909 926 set volume $info(id) 927 set _limits($volume-min) $info(min) 928 set _limits($volume-max) $info(max) 910 929 foreach { dataobj comp } $_id2obj($volume) break 911 930 912 931 if { ![info exists _limits($dataobj-vmin)] } { 913 932 set _limits($dataobj-vmin) $info(min) … … 944 963 } 945 964 946 # 947 # Find any new data that needs to be sent to the server. 948 # Queue this up on the _sendobjs list, and send it out 949 # a little at a time. Do this first, before we rebuild 950 # the rest. 951 # 965 # Find any new data that needs to be sent to the server. Queue this up on 966 # the _sendobjs list, and send it out a little at a time. Do this first, 967 # before we rebuild the rest. 952 968 foreach dataobj [get] { 953 969 set comp [lindex [$dataobj components] 0] … … 974 990 } 975 991 } 976 _ShowIsoMarkers $first 977 UpdateTransferFunction 992 foreach key [array names _obj2id *-*] { 993 set state [string match $first-* $key] 994 _send "volume state $state $_obj2id($key)" 995 } 996 set comp [lindex [$dataobj components] 0] 997 _ShowIsoMarkers $first $comp 998 UpdateTransferFunction $first $comp 978 999 979 1000 # sync the state of slicers … … 1003 1024 _fixSettings outline 1004 1025 1005 if {"" == $itk_option(-plotoutline)} { 1006 _send "volume outline state off" 1007 } else { 1008 _send "volume outline state on" 1009 set rgb [Color2RGB $itk_option(-plotoutline)] 1010 _send "volume outline color $rgb" 1011 } 1026 1027 # if {"" == $itk_option(-plotoutline)} { 1028 # _send "volume outline state off" 1029 # } else { 1030 # _send "volume outline state on" 1031 # set rgb [Color2RGB $itk_option(-plotoutline)] 1032 # _send "volume outline color $rgb" 1033 # } 1012 1034 _send "volume axis label x \"\"" 1013 1035 _send "volume axis label y \"\"" … … 1278 1300 } 1279 1301 } 1280 1281 1302 transp { 1282 1303 if {[isconnected]} { … … 1291 1312 if {$dataobj != 0} { 1292 1313 set val [$inner.scales.opacity get] 1293 set sval [expr {0.01*double($val)}] 1294 set _opacity($dataobj) $sval 1295 UpdateTransferFunction 1314 set sval [expr { 0.01 * double($val) }] 1315 set comp [lindex [$dataobj components] 0] 1316 set tag $dataobj-$comp 1317 set _settings($this-$tag-opacity) $sval 1318 UpdateTransferFunction $dataobj $comp 1296 1319 } 1297 1320 } 1298 1321 } 1322 1299 1323 thickness { 1300 1324 if {[isconnected]} { … … 1304 1328 # Scale values between 0.00001 and 0.01000 1305 1329 set sval [expr {0.0001*double($val)}] 1306 set _thickness($dataobj) $sval 1307 UpdateTransferFunction 1330 set comp [lindex [$dataobj components] 0] 1331 set tag $dataobj-$comp 1332 set _settings($this-$tag-thickness) $sval 1333 UpdateTransferFunction $dataobj $comp 1308 1334 } 1309 1335 } … … 1390 1416 append cmap "1.0 [Color2RGB $color]" 1391 1417 1392 set max $style(-opacity) 1393 if { [info exists _opacity($dataobj)] } { 1394 set max $_opacity($dataobj) 1395 } 1396 set key $dataobj 1418 set tag $dataobj-$comp 1419 if { ![info exists _settings($this-$tag-opacity)] } { 1420 set _settings($this-$tag-opacity) $style(-opacity) 1421 } 1422 set max $_settings($this-$tag-opacity) 1423 1397 1424 set isovalues {} 1398 foreach m $_isomarkers($ key) {1425 foreach m $_isomarkers($tag) { 1399 1426 lappend isovalues [$m GetRelativeValue] 1400 1427 } … … 1404 1431 1405 1432 set delta 0.01 1406 if { [info exists _ thickness($dataobj)]} {1407 set delta $_ thickness($dataobj)1433 if { [info exists _settings($this-$tag-thickness)]} { 1434 set delta $_settings($this-$tag-thickness) 1408 1435 } 1409 1436 set first [lindex $isovalues 0] … … 1482 1509 } 1483 1510 1484 itcl::body Rappture::NanovisViewer::_HideIsoMarkers {dataobj} { 1485 if { [info exists _isomarkers($dataobj)] } { 1486 foreach m $_isomarkers($dataobj) { 1511 itcl::body Rappture::NanovisViewer::_HideIsoMarkers {dataobj comp} { 1512 set tag $dataobj-$comp 1513 if { [info exists _isomarkers($tag)] } { 1514 foreach m $_isomarkers($tag) { 1487 1515 $m Hide 1488 1516 } … … 1490 1518 } 1491 1519 1492 itcl::body Rappture::NanovisViewer::_ShowIsoMarkers {dataobj} { 1493 foreach obj [array names _all_data_objs] { 1494 _HideIsoMarkers $obj 1495 } 1496 if { ![info exists _isomarkers($dataobj)] } { 1520 itcl::body Rappture::NanovisViewer::_ShowIsoMarkers {dataobj comp} { 1521 set tag $dataobj-$comp 1522 foreach dataobj [array names _all_data_objs] { 1523 foreach comp [$dataobj components] { 1524 _HideIsoMarkers $dataobj $comp 1525 } 1526 } 1527 if { ![info exists _isomarkers($tag)] } { 1497 1528 return 1498 1529 } 1499 foreach m $_isomarkers($ dataobj) {1530 foreach m $_isomarkers($tag) { 1500 1531 $m Show 1501 1532 } … … 1507 1538 # marker is a relative value from 0.0 to 1.0. 1508 1539 # 1509 itcl::body Rappture::NanovisViewer::_ParseLevelsOption { dataobj levels} {1540 itcl::body Rappture::NanovisViewer::_ParseLevelsOption { tag levels } { 1510 1541 set c $itk_component(legend) 1542 set ivol $_obj2id($tag) 1511 1543 regsub -all "," $levels " " levels 1512 1544 for {set i 1} { $i <= $levels } {incr i} { 1513 1545 set x [expr {double($i)/($levels+1)}] 1514 set m [IsoMarker \#auto $c $this ]1546 set m [IsoMarker \#auto $c $this $ivol] 1515 1547 $m SetRelativeValue $x 1516 lappend _isomarkers($ dataobj) $m1548 lappend _isomarkers($tag) $m 1517 1549 } 1518 1550 } … … 1530 1562 # not be seen. 1531 1563 # 1532 itcl::body Rappture::NanovisViewer::_ParseMarkersOption { dataobjmarkers} {1564 itcl::body Rappture::NanovisViewer::_ParseMarkersOption {tag markers} { 1533 1565 set c $itk_component(legend) 1534 1566 regsub -all "," $markers " " markers 1567 set ivol $_obj2id($tag) 1535 1568 foreach marker $markers { 1536 1569 set n [scan $marker "%g%s" value suffix] … … 1538 1571 # ${n}% : Set relative value. 1539 1572 set value [expr {$value * 0.01}] 1540 set m [IsoMarker \#auto $c $this ]1573 set m [IsoMarker \#auto $c $this $ivol] 1541 1574 $m SetRelativeValue $value 1542 lappend _isomarkers($ dataobj) $m1575 lappend _isomarkers($tag) $m 1543 1576 } else { 1544 1577 # ${n} : Set absolute value. 1545 set m [IsoMarker \#auto $c $this ]1578 set m [IsoMarker \#auto $c $this $ivol] 1546 1579 $m SetAbsoluteValue $value 1547 lappend _isomarkers($ dataobj) $m1580 lappend _isomarkers($tag) $m 1548 1581 } 1549 1582 } … … 1555 1588 } 1556 1589 array set style [lindex [$dataobj components -style $comp] 0] 1590 set tag $dataobj-$comp 1557 1591 if { [info exists style(-markers)] } { 1558 _ParseMarkersOption $ dataobj$style(-markers)1592 _ParseMarkersOption $tag $style(-markers) 1559 1593 } else { 1560 _ParseLevelsOption $ dataobj$style(-levels)1594 _ParseLevelsOption $tag $style(-levels) 1561 1595 } 1562 1596 } … … 1572 1606 # legend. 1573 1607 # ---------------------------------------------------------------------- 1574 itcl::body Rappture::NanovisViewer::UpdateTransferFunction {} { 1575 set dataobj [lindex [get] 0] 1608 itcl::body Rappture::NanovisViewer::UpdateTransferFunction { dataobj comp } { 1576 1609 if {"" == $dataobj} { 1577 1610 return 1578 1611 } 1579 set comp [lindex [$dataobj components] 0] 1580 set key $dataobj-$comp 1581 if {![info exists _obj2style($key)]} { 1612 set tag $dataobj-$comp 1613 if {![info exists _obj2style($tag)]} { 1582 1614 return 1583 1615 } 1584 1616 # Compute a transfer function for the current data set. 1585 1617 foreach {sname cmap wmap} [GenTransfuncData $dataobj $comp] break 1586 _send [list transfunc define $_obj2style($ key) $cmap $wmap]1587 _send [list volume shading transfunc $_obj2style($ key) $_obj2id($key)]1618 _send [list transfunc define $_obj2style($tag) $cmap $wmap] 1619 _send [list volume shading transfunc $_obj2style($tag) $_obj2id($tag)] 1588 1620 _fixLegend 1589 1621 } … … 1594 1626 return 0; # No data sets defined 1595 1627 } 1628 set comp [lindex [$dataobj components] 0] 1629 set ivol $_obj2id($dataobj-$comp) 1596 1630 set c $itk_component(legend) 1597 set m [IsoMarker \#auto $c $this ]1631 set m [IsoMarker \#auto $c $this $ivol] 1598 1632 set w [winfo width $c] 1599 1633 $m SetRelativeValue [expr {double($x-10)/($w-20)}]
Note: See TracChangeset
for help on using the changeset viewer.