Changeset 972 for trunk/gui/scripts/nanovisviewer.tcl
- Timestamp:
- Mar 29, 2008, 10:31:47 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/nanovisviewer.tcl
r971 r972 57 57 public method delete {args} 58 58 public method scale {args} 59 public method GetDataObj { ivol } {60 if { ![info exists _id2obj($ivol)] } {61 return ""62 }63 return $_id2obj($ivol)64 }65 59 public method GetLimits { {ivol ""} } { 66 60 if { $ivol != "" } { … … 84 78 protected method _send {string} 85 79 protected method _send_dataobjs {} 86 protected method _send_transfunc s{}80 protected method _send_transfunc {} 87 81 88 82 protected method _ReceiveImage {option size} … … 104 98 105 99 # The following methods are only used by this class. 106 private method _ SetTransfuncData{ ivol }100 private method _DefineTransferFunction { ivol } 107 101 private method _AddIsoMarker { ivol x y } 108 102 private method _InitIsoMarkers { ivol } … … 130 124 131 125 private variable _isomarkers ;# array of isosurface level values 0..1 126 private variable _styles 132 127 private common _settings 128 private variable _currentVolId "" 133 129 } 134 130 … … 151 147 "[itcl::code $this _send_dataobjs]; list" 152 148 # Send transfer functions event 153 $_dispatcher register !send_transfunc s154 $_dispatcher dispatch $this !send_transfunc s\155 "[itcl::code $this _send_transfunc s]; list"149 $_dispatcher register !send_transfunc 150 $_dispatcher dispatch $this !send_transfunc \ 151 "[itcl::code $this _send_transfunc]; list" 156 152 # Rebuild event 157 153 $_dispatcher register !rebuild … … 493 489 $_dispatcher cancel !rebuild 494 490 $_dispatcher cancel !send_dataobjs 495 $_dispatcher cancel !send_transfunc s491 $_dispatcher cancel !send_transfunc 496 492 image delete $_image(plot) 497 493 image delete $_image(legend) … … 765 761 # send the data as one huge base64-encoded mess -- yuck! 766 762 set data [$dataobj values $comp] 767 768 # tell the engine to expect some data769 763 set nbytes [string length $data] 770 764 if { ![SendBytes "volume data follows $nbytes"] } { … … 774 768 return 775 769 } 776 set volId$_obj2id(count)770 set ivol $_obj2id(count) 777 771 incr _obj2id(count) 778 772 779 set _id2obj($volId) [list $dataobj $comp] 780 set _obj2id($dataobj-$comp) $volId 781 set _receiveids($volId) 1 773 set _id2obj($ivol) [list $dataobj $comp] 774 set _obj2id($dataobj-$comp) $ivol 775 set _receiveids($ivol) 1 776 782 777 } 783 778 } … … 819 814 820 815 # ---------------------------------------------------------------------- 821 # USAGE: _send_transfuncs 822 # ---------------------------------------------------------------------- 823 itcl::body Rappture::NanovisViewer::_send_transfuncs {} { 824 blt::busy hold $itk_component(hull); update idletasks 825 foreach dataobj $_sendobjs2 { 826 foreach comp [$dataobj components] { 827 # 828 # Determine the transfer function needed for this volume 829 # and make sure that it's defined on the server. 830 # 831 set ivol $_obj2id($dataobj-$comp) 832 if { ![info exists _isomarkers($ivol)] } { 833 _InitIsoMarkers $ivol 834 } else { 835 _HideIsoMarkers $ivol 836 } 837 if { ![_SetTransfuncData $ivol] } { 838 return 839 } 840 } 841 } 842 set _sendobjs2 "" 843 blt::busy release $itk_component(hull) 844 845 # activate the proper volume 846 set first [lindex [get] 0] 847 foreach key [array names _obj2id *-*] { 848 set state [string match $first-* $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 } 854 } 855 set comp [lindex [$dataobj components] 0] 856 _ShowIsoMarkers $_obj2id($first-$comp) 857 # if there are any commands in the buffer, send them now that we're done 858 SendBytes $_outbuf 859 set _outbuf "" 816 # USAGE: _send_transfunc 817 # ---------------------------------------------------------------------- 818 itcl::body Rappture::NanovisViewer::_send_transfunc {} { 819 if { ![_DefineTransferFunction $_currentVolId] } { 820 return 821 } 822 _fixLegend 860 823 $_dispatcher event -idle !legend 861 824 } … … 924 887 if { [isconnected] } { 925 888 array set info $args 926 set volume$info(id)927 set _limits($ volume-min) $info(min)928 set _limits($ volume-max) $info(max)929 foreach { dataobj comp } $_id2obj($ volume) break889 set ivol $info(id) 890 set _limits($ivol-min) $info(min) 891 set _limits($ivol-max) $info(max) 892 foreach { dataobj comp } $_id2obj($ivol) break 930 893 931 894 if { ![info exists _limits($dataobj-vmin)] } { … … 944 907 lappend _sendobjs2 $dataobj 945 908 unset _receiveids($info(id)) 946 if { [array size _receiveids] == 0 } { 947 $_dispatcher event -idle !send_transfuncs 948 } 909 910 if { ![info exists _isomarkers($ivol)] } { 911 _InitIsoMarkers $ivol 912 } else { 913 _HideIsoMarkers $ivol 914 } 915 # We can update the transfer function now that we know the data limits. 916 if { ![_DefineTransferFunction $ivol] } { 917 return 918 } 919 _fixLegend 949 920 } 950 921 } … … 982 953 set h [winfo height $itk_component(3dview)] 983 954 _send "screen $w $h" 984 # nothing to send -- activate the proper volume955 # nothing to send -- activate the proper ivol 985 956 set first [lindex [get] 0] 986 957 if {"" != $first} { … … 998 969 999 970 _ShowIsoMarkers $ivol 971 972 if { [info exists _settings($this-$ivol-opacity)] } { 973 set inner [$itk_component(controls).panel component inner] 974 set sval $_settings($this-$ivol-opacity) 975 set sval [expr {round($sval * 100)}] 976 $inner.scales.opacity set $sval 977 } 978 if { [info exists _settings($this-$ivol-thickness)] } { 979 set inner [$itk_component(controls).panel component inner] 980 set sval $_settings($this-$ivol-thickness) 981 set sval [expr {round($sval * 10000.0)}] 982 $inner.scales.thickness set $sval 983 } 1000 984 UpdateTransferFunction $ivol 1001 985 … … 1223 1207 1224 1208 # show the current value in the readout 1225 #puts "readout: $axis = $newval"1209 #puts "readout: $axis = $newval" 1226 1210 1227 1211 set ids [_currentVolumeIds -cutplanes] … … 1313 1297 set dataobj [lindex [get] 0] 1314 1298 if {$dataobj != 0} { 1315 1316 1299 set val [$inner.scales.opacity get] 1300 set sval [expr { 0.01 * double($val) }] 1317 1301 # FIXME: This will change when we can select the current 1318 1302 # volume. 1319 1303 set comp [lindex [$dataobj components] 0] 1320 1304 set tag $dataobj-$comp 1321 set _settings($this-$tag-opacity) $sval 1322 UpdateTransferFunction $_obj2id($tag) 1305 if { [info exists _obj2id($tag)] } { 1306 set ivol $_obj2id($tag) 1307 set _settings($this-$ivol-opacity) $sval 1308 UpdateTransferFunction $ivol 1309 } 1323 1310 } 1324 1311 } … … 1336 1323 set comp [lindex [$dataobj components] 0] 1337 1324 set tag $dataobj-$comp 1338 set _settings($this-$tag-thickness) $sval 1339 UpdateTransferFunction $_obj2id($dataobj-$comp) 1325 if { [info exists _obj2id($tag)] } { 1326 set ivol $_obj2id($tag) 1327 set _settings($this-$ivol-thickness) $sval 1328 UpdateTransferFunction $ivol 1329 } 1340 1330 } 1341 1331 } … … 1379 1369 set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] 1380 1370 set ivol "" 1381 1382 # The changes when we can select the current volume. 1383 set dataobj [lindex [get] 0] 1384 if {"" != $dataobj} { 1385 set comp [lindex [$dataobj components] 0] 1386 if {[info exists _obj2id($dataobj-$comp)]} { 1387 set ivol $_obj2id($dataobj-$comp) 1388 1371 if { $ivol == "" } { 1372 set dataobj [lindex [get] 0] 1373 if {"" != $dataobj} { 1374 set comp [lindex [$dataobj components] 0] 1375 if {[info exists _obj2id($dataobj-$comp)]} { 1376 set ivol $_obj2id($dataobj-$comp) 1377 } 1378 } 1389 1379 } 1390 1380 if {$w > 0 && $h > 0 && "" != $ivol} { … … 1396 1386 1397 1387 # ---------------------------------------------------------------------- 1398 # USAGE: _ SetTransfuncData<ivol>1388 # USAGE: _DefineTransferFunction <ivol> 1399 1389 # 1400 1390 # Used internally to compute the colormap and alpha map used to define … … 1402 1392 # Returns: name {v r g b ...} {v w ...} 1403 1393 # ---------------------------------------------------------------------- 1404 itcl::body Rappture::NanovisViewer::_ SetTransfuncData{ ivol } {1394 itcl::body Rappture::NanovisViewer::_DefineTransferFunction { ivol } { 1405 1395 array set style { 1406 1396 -color rainbow … … 1411 1401 array set style [lindex [$dataobj components -style $comp] 0] 1412 1402 set sname "$style(-color):$style(-levels):$style(-opacity)" 1413 1414 1403 if {$style(-color) == "rainbow"} { 1415 1404 set style(-color) "white:yellow:green:cyan:blue:magenta" … … 1438 1427 set isovalues [lsort -real $isovalues] 1439 1428 1440 set delta 0.01 1441 if { [info exists _settings($tag-thickness)]} { 1442 set delta $_settings($tag-thickness) 1443 } 1429 if { ![info exists _settings($tag-thickness)]} { 1430 set _settings($tag-thickness) 0.05 1431 } 1432 set delta $_settings($tag-thickness) 1433 1444 1434 set first [lindex $isovalues 0] 1445 1435 set last [lindex $isovalues end] … … 1475 1465 } 1476 1466 set _id2style($ivol) $sname 1477 return [_send transfunc define $sname $cmap $wmap] 1467 set _styles($sname) 1 1468 set cmds [subst { 1469 transfunc define $sname { $cmap } { $wmap } 1470 volume shading transfunc $sname $ivol 1471 }] 1472 return [SendBytes $cmds] 1478 1473 } 1479 1474 … … 1530 1525 foreach dataobj [array names _all_data_objs] { 1531 1526 foreach comp [$dataobj components] { 1532 _HideIsoMarkers _$obj2id($dataobj-$comp)1527 _HideIsoMarkers $_obj2id($dataobj-$comp) 1533 1528 } 1534 1529 } … … 1549 1544 set c $itk_component(legend) 1550 1545 regsub -all "," $levels " " levels 1551 for {set i 1} { $i <= $levels } {incr i} { 1552 set x [expr {double($i)/($levels+1)}] 1553 set m [IsoMarker \#auto $c $this $ivol] 1554 $m SetRelativeValue $x 1555 lappend _isomarkers($ivol) $m 1546 if {[string is int $levels]} { 1547 for {set i 1} { $i <= $levels } {incr i} { 1548 set x [expr {double($i)/($levels+1)}] 1549 set m [IsoMarker \#auto $c $this $ivol] 1550 $m SetRelativeValue $x 1551 lappend _isomarkers($ivol) $m 1552 } 1553 } else { 1554 foreach x $levels { 1555 set m [IsoMarker \#auto $c $this $ivol] 1556 $m SetRelativeValue $x 1557 lappend _isomarkers($ivol) $m 1558 } 1556 1559 } 1557 1560 } … … 1593 1596 -levels 6 1594 1597 } 1598 set _isomarkers($ivol) "" 1595 1599 foreach {dataobj comp} $_id2obj($ivol) break 1596 1600 array set style [lindex [$dataobj components -style $comp] 0] 1597 1598 1601 if { [info exists style(-markers)] } { 1599 1602 _ParseMarkersOption $ivol $style(-markers) … … 1617 1620 return 1618 1621 } 1619 # Compute a transfer function for the current data set. 1620 _SetTransfuncData $ivol 1621 _send [list volume shading transfunc $_id2style($ivol) $ivol] 1622 _fixLegend 1622 set _currentVolId $ivol 1623 $_dispatcher event -idle !send_transfunc 1623 1624 } 1624 1625 … … 1640 1641 set list {} 1641 1642 set marker [namespace tail $marker] 1642 foreach m $_isomarkers($ tag) {1643 foreach m $_isomarkers($ivol) { 1643 1644 set sx [$m GetScreenPosition] 1644 1645 if { $m != $marker } {
Note: See TracChangeset
for help on using the changeset viewer.