Changeset 878 for trunk/gui/scripts
- Timestamp:
- Feb 12, 2008, 11:46:17 AM (17 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/historesult.tcl
r858 r878 674 674 } else { 675 675 set r [blt::vector expr {max($xv) - min($xv)}] 676 set z [expr {$r / ([$xv length]-1) }]676 set z [expr {$r / ([$xv length]-1) * 0.8}] 677 677 foreach x [$xv range 0 end] y [$yv range 0 end] { 678 678 set elem "elem[incr count]" -
trunk/gui/scripts/nanovisviewer.tcl
r783 r878 17 17 18 18 option add *NanovisViewer.width 4i widgetDefault 19 option add *NanovisViewer*cursor crosshair widgetDefault 19 20 option add *NanovisViewer.height 4i widgetDefault 20 21 option add *NanovisViewer.foreground black widgetDefault … … 43 44 public method delete {args} 44 45 public method scale {args} 46 public method getLimits {} { 47 return [list $_limits(vmin) $_limits(vmax)] 48 } 45 49 public method download {option args} 46 50 public method parameters {title args} { # do nothing } 47 48 51 public method connect {{hostlist ""}} 49 52 public method disconnect {} … … 53 56 protected method _send_text {string} 54 57 protected method _send_dataobjs {} 58 protected method _send_transfuncs {} 55 59 protected method _send_echo {channel {data ""}} 56 60 protected method _receive {} 57 61 protected method _receive_image {option size} 58 62 protected method _receive_legend {ivol vmin vmax size} 63 protected method _receive_data {args} 59 64 protected method _receive_echo {channel {data ""}} 60 65 … … 66 71 protected method _slicertip {axis} 67 72 protected method _probe {option args} 73 protected method _marker {index option args} 68 74 69 75 protected method _state {comp} … … 72 78 protected method _serverDown {} 73 79 protected method _getTransfuncData {dataobj comp} 80 public method update_transfer_function {} 81 public method remove_duplicate_isomarker { m x } 82 public method _addIsoMarker { x y } 83 protected method _initIsoMarkers {dataobj comp} 74 84 protected method _color2rgb {color} 75 85 protected method _euler2xyz {theta phi psi} … … 88 98 private variable _obj2ovride ;# maps dataobj => style override 89 99 private variable _obj2id ;# maps dataobj => volume ID in server 100 private variable _id2obj ;# maps dataobj => volume ID in server 90 101 private variable _sendobjs "" ;# list of data objs to send to server 102 private variable _sendobjs2 "" ;# list of data objs to send to server 103 private variable _receiveids ;# list of data objs to send to server 104 private variable _opacity 91 105 92 106 private variable _click ;# info used for _move operations 93 107 private variable _limits ;# autoscale min/max for all axes 94 108 private variable _view ;# view params for 3D view 109 110 private variable _isomarkers ;# array of isosurface level values 0..1 111 private common _isosurface ;# indicates to use isosurface shading 95 112 } 96 113 … … 98 115 keep -background -foreground -cursor -font 99 116 keep -plotbackground -plotforeground 117 } 118 119 itcl::class Rappture::NanovisViewer::IsoMarker { 120 private variable _value ""; # Absolute value of marker. 121 private variable _label "" 122 private variable _tick "" 123 private variable _canvas "" 124 private variable _nvobj "" 125 private common _normal_icon "" 126 private common _active_icon "" 127 128 constructor {c obj args} { 129 set _canvas $c 130 set _nvobj $obj 131 132 if { $_normal_icon == "" } { 133 set normal_icon_data { 134 R0lGODlhBwATAOcxAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N 135 DQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8f 136 HyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDEx 137 MTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkND 138 Q0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVV 139 VVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdn 140 Z2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5 141 eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouL 142 i4yMjI2NjY6Ojo+Pj5CQkJGRkZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2d 143 nZ6enp+fn6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+v 144 r7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+vr+/v8DAwMHB 145 wcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zMzM3Nzc7Ozs/Pz9DQ0NHR0dLS0tPT 146 09TU1NXV1dbW1tfX19jY2NnZ2dra2tvb29zc3N3d3d7e3t/f3+Dg4OHh4eLi4uPj4+Tk5OXl 147 5ebm5ufn5+jo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09PX19fb29vf3 148 9/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAP8A 149 LAAAAAAHABMAAAg2AP8JHEiwoMGDCBFmW0gw259sDR9GhDjQIUWBFidiXPhwYTZTpv6AXBjy 150 j0iSJk9+BDnSo8uAADs= 151 } 152 set active_icon_data { 153 R0lGODlhBwATAOcxAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N 154 DQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8f 155 HyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDEx 156 MTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkND 157 Q0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVV 158 VVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdn 159 Z2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5 160 eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouL 161 i4yMjI2NjY6Ojo+Pj5CQkJGRkZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2d 162 nZ6enp+fn6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+v 163 r7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+vr+/v8DAwMHB 164 wcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zMzM3Nzc7Ozs/Pz9DQ0NHR0dLS0tPT 165 09TU1NXV1dbW1tfX19jY2NnZ2dra2tvb29zc3N3d3d7e3t/f3+Dg4OHh4eLi4uPj4+Tk5OXl 166 5ebm5ufn5+jo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09PX19fb29vf3 167 9/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAP8A 168 LAAAAAAHABMAAAg2AP8JHEiwoMGDCBFmW0gwG4BsDR9GhDjQIUWBFidiXPhwYbY/fwCAXBgS 169 gEiSJk9+BDnSo8uAADs= 170 } 171 set _normal_icon [image create photo -data $normal_icon_data] 172 set _active_icon [image create photo -data $active_icon_data] 173 } 174 set w [winfo width $_canvas] 175 set h [winfo height $_canvas] 176 set _tick [$c create image 0 $h \ 177 -image $_normal_icon -anchor s \ 178 -tags "$this $obj"] 179 set _label [$c create text 0 $h \ 180 -anchor n -fill white -font "Helvetica 6" \ 181 -tags "$this $obj" -state hidden] 182 $c bind $_tick <Enter> [itcl::code $this handle_event "enter"] 183 $c bind $_tick <Leave> [itcl::code $this handle_event "leave"] 184 $c bind $_tick <B1-Motion> \ 185 [itcl::code $this handle_event "update" %x %y] 186 $c bind $_tick <ButtonRelease-1> \ 187 [itcl::code $this handle_event "end" %x %y] 188 } 189 destructor { 190 $_canvas delete $this 191 } 192 193 public method get_relative_value {} { 194 foreach {min max} [$_nvobj getLimits] break 195 return [expr {($_value-$min)/($max - $min)}] 196 } 197 public method get_screen_position { } { 198 set x [get_relative_value] 199 if { $x < 0.0 } { 200 set x 0.0 201 } elseif { $x > 1.0 } { 202 set x 1.0 203 } 204 set low 10 205 set w [winfo width $_canvas] 206 set high [expr {$w - 10}] 207 set x [expr {round($x*($high - $low) + $low)}] 208 return $x 209 } 210 public method set_absolute_value { x } { 211 set _value $x 212 213 set w [winfo width $_canvas] 214 set h [winfo height $_canvas] 215 set y0 10 216 set y1 [expr {$y0+22-1}] 217 $_canvas itemconfigure $_label -text [format %.4g $_value] 218 set screen_pos [get_screen_position] 219 $_canvas coords $_tick $screen_pos [expr $y1+3] 220 $_canvas coords $_label $screen_pos [expr {$y1+5}] 221 } 222 public method set_relative_value { x } { 223 foreach {min max} [$_nvobj getLimits] break 224 set r [expr $max - $min] 225 set_absolute_value [expr {($x * $r) + $min}] 226 } 227 public method handle_event { option args } { 228 switch -- $option { 229 enter { 230 $_canvas itemconfigure $_label -state normal 231 $_canvas itemconfigure $_tick -image $_active_icon 232 $_canvas raise $_tick 233 } 234 leave { 235 $_canvas itemconfigure $_label -state hidden 236 $_canvas itemconfigure $_tick -image $_normal_icon 237 } 238 start { 239 $_canvas raise $_tick 240 } 241 update { 242 set w [winfo width $_canvas] 243 set x [lindex $args 0] 244 set_relative_value [expr {double($x-10)/($w-20)}] 245 $_nvobj update_transfer_function 246 } 247 end { 248 set x [lindex $args 0] 249 if { ![$_nvobj remove_duplicate_isomarker $this $x]} { 250 eval handle_event update $args 251 } 252 } 253 default { 254 error "bad option \"$option\": should be start, update, end" 255 } 256 } 257 } 100 258 } 101 259 … … 122 280 $_parser alias image [itcl::code $this _receive_image] 123 281 $_parser alias legend [itcl::code $this _receive_legend] 282 $_parser alias data [itcl::code $this _receive_data] 124 283 125 284 # … … 137 296 set _view(zfocus) 0 138 297 set _obj2id(count) 0 298 set _id2obj(count) 0 139 299 140 300 itk_component add controls { … … 372 532 $inner.scales.transp set 50 373 533 534 label $inner.scales.zerol -text "Transparent" -font $fg 535 grid $inner.scales.zerol -row 2 -column 0 -sticky e 536 ::scale $inner.scales.opacity -from 0 -to 100 -orient horizontal \ 537 -showvalue off -command [itcl::code $this _fixSettings opacity] 538 grid $inner.scales.opacity -row 2 -column 1 -sticky ew 539 label $inner.scales.onel -text "Opaque" -font $fg 540 grid $inner.scales.onel -row 2 -column 2 -sticky w 541 $inner.scales.opacity set 50 542 543 set ::Rappture::NanovisViewer::_isosurface($this) 1 544 ::checkbutton $inner.scales.isosurface \ 545 -text "Isosurface shading" \ 546 -variable ::Rappture::NanovisViewer::_isosurface($this) \ 547 -command [itcl::code $this _fixSettings isosurface] 548 grid $inner.scales.isosurface -row 3 -column 0 -columnspan 2 -sticky w 549 550 374 551 # 375 552 # RENDERING AREA … … 425 602 itcl::body Rappture::NanovisViewer::destructor {} { 426 603 set _sendobjs "" ;# stop any send in progress 604 set _sendobjs2 "" ;# stop any send in progress 427 605 after cancel [itcl::code $this _send_dataobjs] 428 606 after cancel [itcl::code $this _rebuild] … … 720 898 # disconnected -- no more data sitting on server 721 899 catch {unset _obj2id} 900 array unset _id2obj 722 901 set _obj2id(count) 0 902 set _id2obj(count) 0 723 903 set _sendobjs "" 904 set _sendobjs2 "" 724 905 } 725 906 … … 839 1020 puts $_sid "" 840 1021 841 set _obj2id($dataobj-$comp)$_obj2id(count)1022 set volId $_obj2id(count) 842 1023 incr _obj2id(count) 843 1024 1025 set _id2obj($volId) [list $dataobj $comp] 1026 set _obj2id($dataobj-$comp) $volId 1027 set _receiveids($volId) 1 1028 } 1029 } 1030 set _sendobjs "" 1031 blt::busy release $itk_component(hull) 1032 1033 # activate the proper volume 1034 set first [lindex [get] 0] 1035 if {"" != $first} { 1036 set axis [$first hints updir] 1037 if {"" != $axis} { 1038 _send up $axis 1039 } 1040 } 1041 1042 # sync the state of slicers 1043 set vols [_currentVolumeIds -cutplanes] 1044 foreach axis {x y z} { 1045 eval _send cutplane state [_state ${axis}slice] $axis $vols 1046 set pos [expr {0.01*[$itk_component(${axis}slicer) get]}] 1047 eval _send cutplane position $pos $axis $vols 1048 } 1049 eval _send volume data state [_state volume] $vols 1050 1051 # if there are any commands in the buffer, send them now that we're done 1052 _send_echo >>line $_buffer(out) 1053 if {[catch {puts $_sid $_buffer(out)} err]} { 1054 disconnect 1055 $_dispatcher event -after 750 !serverDown 1056 } 1057 set _buffer(out) "" 1058 1059 # $_dispatcher event -idle !legend 1060 } 1061 1062 # ---------------------------------------------------------------------- 1063 # USAGE: _send_transfuncs 1064 # ---------------------------------------------------------------------- 1065 itcl::body Rappture::NanovisViewer::_send_transfuncs {} { 1066 blt::busy hold $itk_component(hull); update idletasks 1067 foreach dataobj $_sendobjs2 { 1068 foreach comp [$dataobj components] { 844 1069 # 845 1070 # Determine the transfer function needed for this volume 846 1071 # and make sure that it's defined on the server. 847 1072 # 1073 _initIsoMarkers $dataobj $comp 848 1074 foreach {sname cmap wmap} [_getTransfuncData $dataobj $comp] break 849 850 1075 set cmdstr [list transfunc define $sname $cmap $wmap] 851 1076 _send_echo >>line $cmdstr … … 855 1080 return 856 1081 } 857 858 1082 set _obj2style($dataobj-$comp) $sname 859 1083 } 860 1084 } 861 set _sendobjs ""1085 set _sendobjs2 "" 862 1086 blt::busy release $itk_component(hull) 863 1087 864 1088 # activate the proper volume 865 1089 set first [lindex [get] 0] 866 if {"" != $first} {867 set axis [$first hints updir]868 if {"" != $axis} {869 _send up $axis870 }871 }872 873 1090 foreach key [array names _obj2id *-*] { 874 1091 set state [string match $first-* $key] … … 878 1095 } 879 1096 } 880 881 # sync the state of slicers882 set vols [_currentVolumeIds -cutplanes]883 foreach axis {x y z} {884 eval _send cutplane state [_state ${axis}slice] $axis $vols885 set pos [expr {0.01*[$itk_component(${axis}slicer) get]}]886 eval _send cutplane position $pos $axis $vols887 }888 eval _send volume data state [_state volume] $vols889 890 1097 # if there are any commands in the buffer, send them now that we're done 891 1098 _send_echo >>line $_buffer(out) … … 895 1102 } 896 1103 set _buffer(out) "" 897 898 1104 $_dispatcher event -idle !legend 899 1105 } … … 976 1182 $c create image 10 10 -anchor nw \ 977 1183 -image $_image(legend) -tags transfunc 978 979 $c bind transfunc <ButtonPress-1> \980 [itcl::code $this _probe start %x %y]981 $c bind transfunc <B1-Motion> \982 [itcl::code $this _probe update %x %y]983 $c bind transfunc <ButtonRelease-1> \984 [itcl::code $this _probe end %x %y]985 986 1184 $c create text 10 [expr {$h-8}] -anchor sw \ 987 1185 -fill $itk_option(-plotforeground) -tags vmin 988 1186 $c create text [expr {$w-10}] [expr {$h-8}] -anchor se \ 989 1187 -fill $itk_option(-plotforeground) -tags vmax 990 } 991 1188 $c lower transfunc 1189 $c bind transfunc <ButtonRelease-1> \ 1190 [itcl::code $this _addIsoMarker %x %y] 1191 } 992 1192 $c itemconfigure vmin -text $vmin 993 1193 $c coords vmin 10 [expr {$h-8}] … … 995 1195 $c itemconfigure vmax -text $vmax 996 1196 $c coords vmax [expr {$w-10}] [expr {$h-8}] 1197 } 1198 } 1199 1200 # ---------------------------------------------------------------------- 1201 # USAGE: _receive_data <volume> <vmin> <vmax> 1202 # 1203 # Invoked automatically whenever the "legend" command comes in from 1204 # the rendering server. Indicates that binary image data with the 1205 # specified <size> will follow. 1206 # ---------------------------------------------------------------------- 1207 itcl::body Rappture::NanovisViewer::_receive_data { args } { 1208 if {"" != $_sid} { 1209 array set info $args 1210 set volume $info(id) 1211 foreach { dataobj comp } $_id2obj($volume) break 1212 set _limits(vmin-$dataobj-$comp) $info(min) 1213 set _limits(vmax-$dataobj-$comp) $info(max) 1214 set _limits(vmin) $info(vmin) 1215 set _limits(vmax) $info(vmax) 1216 lappend _sendobjs2 $dataobj 1217 unset _receiveids($info(id)) 1218 if { [array size _receiveids] == 0 } { 1219 after idle [itcl::code $this _send_transfuncs] 1220 } 997 1221 } 998 1222 } … … 1076 1300 eval _send camera angle [_euler2xyz $_view(theta) $_view(phi) $_view(psi)] 1077 1301 _send camera zoom $_view(zoom) 1078 #_fixSettings light 1079 #_fixSettings transp 1302 1303 _fixSettings light 1304 _fixSettings transp 1305 _fixSettings isosurface 1080 1306 1081 1307 if {"" == $itk_option(-plotoutline)} { … … 1429 1655 } 1430 1656 } 1657 opacity { 1658 if {[isconnected]} { 1659 set dataobj [lindex [get] 0] 1660 if {$dataobj != 0} { 1661 set val [$inner.scales.opacity get] 1662 set sval [expr {0.01*double($val)}] 1663 set _opacity($dataobj) $sval 1664 update_transfer_function 1665 } 1666 } 1667 } 1668 isosurface { 1669 if {[isconnected]} { 1670 set val $Rappture::NanovisViewer::_isosurface($this) 1671 _send "volume" "shading" "isosurface" $val 1672 } 1673 } 1431 1674 default { 1432 1675 error "don't know how to fix $what" … … 1487 1730 -color rainbow 1488 1731 -levels 6 1489 -opacity 0.51732 -opacity 1.0 1490 1733 } 1491 1734 array set style [lindex [$dataobj components -style $comp] 0] … … 1498 1741 set cmap "0.0 [_color2rgb white] " 1499 1742 for {set i 0} {$i < [llength $clist]} {incr i} { 1500 set x val[expr {double($i+1)/([llength $clist]+1)}]1743 set x [expr {double($i+1)/([llength $clist]+1)}] 1501 1744 set color [lindex $clist $i] 1502 append cmap "$x val[_color2rgb $color] "1745 append cmap "$x [_color2rgb $color] " 1503 1746 } 1504 1747 append cmap "1.0 [_color2rgb $color]" 1505 1748 1506 1749 set max $style(-opacity) 1507 set levels $style(-levels) 1508 if {[string is int $levels]} { 1509 set wmap "0.0 0.0 " 1510 set delta [expr {0.125/($levels+1)}] 1511 for {set i 1} {$i <= $levels} {incr i} { 1512 # add spikes in the middle 1513 set xval [expr {double($i)/($levels+1)}] 1514 append wmap "[expr {$xval-$delta-0.01}] 0.0 [expr {$xval-$delta}] $max [expr {$xval+$delta}] $max [expr {$xval+$delta+0.01}] 0.0 " 1515 } 1516 append wmap "1.0 0.0 " 1517 } else { 1518 set wmap "0.0 0.0 " 1519 set delta 0.05 1520 foreach xval [split $levels ,] { 1521 append wmap "[expr {$xval-$delta}] 0.0 $xval $max [expr {$xval+$delta}] 0.0 " 1522 } 1523 append wmap "1.0 0.0 " 1524 } 1525 1750 if { [info exists _opacity($dataobj)] } { 1751 set max $_opacity($dataobj) 1752 } 1753 set key $dataobj 1754 set isovalues {} 1755 foreach m $_isomarkers($key) { 1756 lappend isovalues [$m get_relative_value] 1757 } 1758 1759 # Sort the isovalues 1760 set isovalues [lsort -real $isovalues] 1761 1762 set delta 0.0005 1763 set first [lindex $isovalues 0] 1764 set last [lindex $isovalues end] 1765 set wmap "" 1766 if { $first == "" || $first != 0.0 } { 1767 lappend wmap 0.0 0.0 1768 } 1769 foreach x $isovalues { 1770 set x1 [expr {$x-$delta-0.001}] 1771 set x2 [expr {$x-$delta}] 1772 set x3 [expr {$x+$delta}] 1773 set x4 [expr {$x+$delta+0.001}] 1774 if { $x1 < 0.0 } { 1775 set x1 0.0 1776 } 1777 if { $x2 < 0.0 } { 1778 set x2 0.0 1779 } 1780 if { $x3 > 1.0 } { 1781 set x3 1.0 1782 } 1783 if { $x4 > 1.0 } { 1784 set x4 1.0 1785 } 1786 # add spikes in the middle 1787 lappend wmap $x1 0.0 1788 lappend wmap $x2 $max 1789 lappend wmap $x3 $max 1790 lappend wmap $x4 0.0 1791 } 1792 if { $last == "" || $last != 1.0 } { 1793 lappend wmap 1.0 0.0 1794 } 1526 1795 return [list $sname $cmap $wmap] 1527 1796 } … … 1587 1856 } 1588 1857 } 1858 1859 itcl::body Rappture::NanovisViewer::_initIsoMarkers {dataobj comp} { 1860 if { [info exists _isomarkers($dataobj)] } { 1861 return 1862 } 1863 array set style { 1864 -levels 6 1865 } 1866 array set style [lindex [$dataobj components -style $comp] 0] 1867 set levels $style(-levels) 1868 set c $itk_component(legend) 1869 if { [llength $levels] == 1 && [string is int $levels] } { 1870 for {set i 1} {$i <= $levels} {incr i} { 1871 set x [expr {double($i)/($levels+1)}] 1872 set m [IsoMarker \#auto $c $this] 1873 $m set_relative_value $x 1874 lappend _isomarkers($dataobj) $m 1875 } 1876 } else { 1877 regsub -all "," $levels " " levels 1878 foreach level $levels { 1879 set n [scan $level "%g%s" x unit] 1880 set m [IsoMarker \#auto $c $this] 1881 lappend _isomarkers($dataobj) $m 1882 if { $n == 2 && $unit == "%" } { 1883 set x [expr {$x * 0.01}] 1884 $m set_relative_value $x 1885 } else { 1886 $m set_absolute_value $x 1887 } 1888 } 1889 } 1890 } 1891 1892 # ---------------------------------------------------------------------- 1893 # USAGE: _marker start <x> <y> 1894 # USAGE: _marker update <x> <y> 1895 # USAGE: _marker end <x> <y> 1896 # 1897 # Used internally to handle the various marker operations performed 1898 # when the user clicks and drags on the legend area. The marker changes the 1899 # transfer function to highlight the area being selected in the 1900 # legend. 1901 # ---------------------------------------------------------------------- 1902 itcl::body Rappture::NanovisViewer::update_transfer_function {} { 1903 set dataobj [lindex [get] 0] 1904 if {"" == $dataobj} { 1905 return 1906 } 1907 set comp [lindex [$dataobj components] 0] 1908 set key $dataobj-$comp 1909 if {![info exists _obj2style($key)]} { 1910 return 1911 } 1912 # compute a transfer function for the probe value 1913 foreach {sname cmap wmap} [_getTransfuncData $dataobj $comp] break 1914 _send transfunc define $_obj2style($key) $cmap $wmap 1915 _send volume shading transfunc $_obj2style($key) $_obj2id($key) 1916 _fixLegend 1917 } 1918 1919 itcl::body Rappture::NanovisViewer::_addIsoMarker { x y } { 1920 set dataobj [lindex [get] 0] 1921 if {"" == $dataobj} { 1922 return 0 1923 } 1924 set key $dataobj 1925 set c $itk_component(legend) 1926 set m [IsoMarker \#auto $c $this] 1927 set w [winfo width $c] 1928 $m set_relative_value [expr {double($x-10)/($w-20)}] 1929 lappend _isomarkers($key) $m 1930 update_transfer_function 1931 return 1 1932 } 1933 1934 itcl::body Rappture::NanovisViewer::remove_duplicate_isomarker { marker x } { 1935 set dataobj [lindex [get] 0] 1936 if {"" == $dataobj} { 1937 return 0 1938 } 1939 set key $dataobj 1940 set list {} 1941 set bool 1 1942 set marker [namespace tail $marker] 1943 foreach m $_isomarkers($key) { 1944 set sx [$m get_screen_position] 1945 if { $m != $marker } { 1946 if { $x >= ($sx-3) && $x <= ($sx+3) } { 1947 $marker set_relative_value [$m get_relative_value] 1948 itcl::delete object $m 1949 set bool 0 1950 continue 1951 } 1952 } 1953 lappend list $m 1954 } 1955 set _isomarkers($key) $list 1956 update_transfer_function 1957 return $bool 1958 }
Note: See TracChangeset
for help on using the changeset viewer.