- Timestamp:
- Mar 27, 2008, 4:06:22 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/nanovisviewer.tcl
r935 r965 65 65 } 66 66 public method isconnected {} 67 public method UpdateTransferFunction {} 68 public method RemoveDuplicateIsoMarker { m x } 69 public method OverIsoMarker { m x } 67 70 68 71 protected method Connect {} 69 72 protected method Disconnect {} 73 70 74 protected method _send {string} 71 75 protected method _send_dataobjs {} … … 89 93 protected method _fixLegend {} 90 94 protected method GenTransfuncData {dataobj comp} 91 public method UpdateTransferFunction {} 92 public method RemoveDuplicateIsoMarker { m x } 93 public method OverIsoMarker { m x } 94 private method AddIsoMarker { x y } 95 private method InitIsoMarkers {dataobj comp} 96 private method HideIsoMarkers {dataobj} 97 private method ShowIsoMarkers {dataobj} 95 96 # The following methods are only used by this class. 97 private method _AddIsoMarker { x y } 98 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} 98 103 99 104 private variable _outbuf ;# buffer for outgoing commands … … 117 122 118 123 private variable _isomarkers ;# array of isosurface level values 0..1 119 private common _settings124 private common _settings 120 125 } 121 126 … … 413 418 $inner.scales.thickness set 500 414 419 415 set ::Rappture::NanovisViewer::_settings($this-isosurface) 1420 set ::Rappture::NanovisViewer::_settings($this-isosurface) 0 416 421 ::checkbutton $inner.scales.isosurface \ 417 422 -text "Isosurface shading" \ … … 809 814 # 810 815 if { ![info exists _isomarkers($dataobj)] } { 811 InitIsoMarkers $dataobj $comp816 _InitIsoMarkers $dataobj $comp 812 817 } else { 813 HideIsoMarkers $dataobj818 _HideIsoMarkers $dataobj 814 819 } 815 820 foreach {sname cmap wmap} [GenTransfuncData $dataobj $comp] break … … 833 838 } 834 839 } 835 ShowIsoMarkers $first840 _ShowIsoMarkers $first 836 841 # if there are any commands in the buffer, send them now that we're done 837 842 SendBytes $_outbuf … … 863 868 # ---------------------------------------------------------------------- 864 869 itcl::body Rappture::NanovisViewer::_receive_legend { ivol vmin vmax size } { 870 puts stderr "called _receive_legend $ivol $vmin $vmax $size" 865 871 if { [isconnected] } { 866 872 set bytes [ReceiveBytes $size] … … 880 886 $c lower transfunc 881 887 $c bind transfunc <ButtonRelease-1> \ 882 [itcl::code $this AddIsoMarker %x %y]888 [itcl::code $this _AddIsoMarker %x %y] 883 889 } 884 890 $c itemconfigure vmin -text $vmin … … 888 894 $c coords vmax [expr {$w-10}] [expr {$h-8}] 889 895 set first [lindex [get] 0] 890 ShowIsoMarkers $first896 _ShowIsoMarkers $first 891 897 } 892 898 } … … 900 906 # ---------------------------------------------------------------------- 901 907 itcl::body Rappture::NanovisViewer::_receive_data { args } { 908 puts stderr "called _receive_data $args" 902 909 if { [isconnected] } { 903 910 array set info $args … … 912 919 set _limits($dataobj-vmin) $info(min) 913 920 } 914 if { $_limits($dataobj-vmax) >$info(max) } {921 if { $_limits($dataobj-vmax) < $info(max) } { 915 922 set _limits($dataobj-vmax) $info(max) 916 923 } … … 923 930 $_dispatcher event -idle !send_transfuncs 924 931 } 932 puts stderr "compute limits are " 933 parray _limits 925 934 } 926 935 } … … 969 978 } 970 979 } 971 ShowIsoMarkers $first980 _ShowIsoMarkers $first 972 981 UpdateTransferFunction 973 982 … … 1477 1486 } 1478 1487 1479 itcl::body Rappture::NanovisViewer:: HideIsoMarkers {dataobj} {1488 itcl::body Rappture::NanovisViewer::_HideIsoMarkers {dataobj} { 1480 1489 if { [info exists _isomarkers($dataobj)] } { 1481 1490 foreach m $_isomarkers($dataobj) { … … 1485 1494 } 1486 1495 1487 itcl::body Rappture::NanovisViewer:: ShowIsoMarkers {dataobj} {1496 itcl::body Rappture::NanovisViewer::_ShowIsoMarkers {dataobj} { 1488 1497 foreach obj [array names _all_data_objs] { 1489 HideIsoMarkers $obj1498 _HideIsoMarkers $obj 1490 1499 } 1491 1500 if { ![info exists _isomarkers($dataobj)] } { … … 1497 1506 } 1498 1507 1499 itcl::body Rappture::NanovisViewer::InitIsoMarkers {dataobj comp} { 1500 array set style { 1501 -levels 6x 1502 } 1503 array set style [lindex [$dataobj components -style $comp] 0] 1504 set levels $style(-levels) 1508 # 1509 # The -levels option takes a single value that represents the number 1510 # of evenly distributed markers based on the current data range. Each 1511 # marker is a relative value from 0.0 to 1.0. 1512 # 1513 itcl::body Rappture::NanovisViewer::_ParseLevelsOption {dataobj levels} { 1505 1514 set c $itk_component(legend) 1506 1515 regsub -all "," $levels " " levels 1507 foreach level $levels { 1508 set n [scan $level "%g%s" value suffix] 1516 for {set i 1} { $i <= $levels } {incr i} { 1517 set x [expr {double($i)/($nLevels+1)}] 1518 set m [IsoMarker \#auto $c $this] 1519 $m SetRelativeValue $x 1520 lappend _isomarkers($dataobj) $m 1521 } 1522 } 1523 1524 # 1525 # The -markers option takes a list of zero or more values (the values 1526 # may be separated either by spaces or commas) that have the following 1527 # format: 1528 # 1529 # N% Percent of current total data range. Converted to 1530 # to a relative value between 0.0 and 1.0. 1531 # N Absolute value of marker. If the marker is outside of 1532 # the current range, it will be displayed on the outer 1533 # edge of the legends, but it range it represents will 1534 # not be seen. 1535 # 1536 itcl::body Rappture::NanovisViewer::_ParseMarkersOption {dataobj markers} { 1537 set c $itk_component(legend) 1538 regsub -all "," $markers " " markers 1539 foreach marker $markers { 1540 set n [scan $marker "%g%s" value suffix] 1509 1541 if { $n == 2 && $suffix == "%" } { 1510 1542 # ${n}% : Set relative value. … … 1513 1545 $m SetRelativeValue $value 1514 1546 lappend _isomarkers($dataobj) $m 1515 } elseif { $n == 2 && $suffix == "x" } {1516 # ${n}x : Set equal number of levels1517 if { $value != round($value) } {1518 error "\# of levels \"$value\" must be an interger"1519 }1520 set nLevels [expr round($value)]1521 for {set i 1} {$i <= $nLevels} {incr i} {1522 set x [expr {double($i)/($nLevels+1)}]1523 set m [IsoMarker \#auto $c $this]1524 $m SetRelativeValue $x1525 lappend _isomarkers($dataobj) $m1526 }1527 1547 } else { 1528 1548 # ${n} : Set absolute value. … … 1534 1554 } 1535 1555 1556 itcl::body Rappture::NanovisViewer::_InitIsoMarkers {dataobj comp} { 1557 array set style { 1558 -levels 6 1559 } 1560 array set style [lindex [$dataobj components -style $comp] 0] 1561 if { [info exists style(-markers)] } { 1562 _ParseMarkersOption $dataobj $style(-markers) 1563 } else { 1564 _ParseLevelsOption $dataobj $style(-levels) 1565 } 1566 } 1567 1536 1568 # ---------------------------------------------------------------------- 1537 1569 # USAGE: _marker start <x> <y> … … 1561 1593 } 1562 1594 1563 itcl::body Rappture::NanovisViewer:: AddIsoMarker { x y } {1595 itcl::body Rappture::NanovisViewer::_AddIsoMarker { x y } { 1564 1596 set dataobj [lindex [get] 0] 1565 1597 if {$dataobj == ""} {
Note: See TracChangeset
for help on using the changeset viewer.