Changeset 885 for trunk/gui/scripts/nanovisviewer.tcl
- Timestamp:
- Feb 14, 2008, 9:43:54 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/nanovisviewer.tcl
r879 r885 44 44 public method delete {args} 45 45 public method scale {args} 46 public method getLimits { { option "-current"} } { 47 if { $option == "-current" } { 48 set dataobj [lindex [get] 0] 49 return [list $_limits($dataobj-vmin) $_limits($dataobj-vmax)] 50 } 51 return [list $_limits(vmin) $_limits(vmax)] 46 public method getLimits { { option ""} } { 47 return [array get _limits] 52 48 } 53 49 public method download {option args} … … 84 80 public method update_transfer_function {} 85 81 public method remove_duplicate_isomarker { m x } 82 public method over_isomarker { m x } 86 83 public method _addIsoMarker { x y } 87 84 protected method _initIsoMarkers {dataobj comp} … … 110 107 private variable _receiveids ;# list of data objs to send to server 111 108 private variable _opacity 109 private variable _thickness 112 110 113 111 private variable _click ;# info used for _move operations … … 130 128 private variable _canvas "" 131 129 private variable _nvobj "" 132 private common _normal_icon "" 133 private common _active_icon "" 130 private common _normalIcon "" 131 private common _activeIcon "" 132 private variable _active_motion 0 133 private variable _active_press 0 134 134 135 135 constructor {c obj args} { … … 137 137 set _nvobj $obj 138 138 139 if { $_normal _icon == "" } {139 if { $_normalIcon == "" } { 140 140 set normal_icon_data { 141 141 R0lGODlhBwATAOcxAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N … … 176 176 gEiSJk9+BDnSo8uAADs= 177 177 } 178 set _normal _icon [image create photo -data $normal_icon_data]179 set _active _icon [image create photo -data $active_icon_data]178 set _normalIcon [image create photo -data $normal_icon_data] 179 set _activeIcon [image create photo -data $active_icon_data] 180 180 } 181 181 set w [winfo width $_canvas] 182 182 set h [winfo height $_canvas] 183 183 set _tick [$c create image 0 $h \ 184 -image $_normal _icon -anchor s \184 -image $_normalIcon -anchor s \ 185 185 -tags "$this $obj" -state hidden] 186 186 set _label [$c create text 0 $h \ … … 189 189 $c bind $_tick <Enter> [itcl::code $this handle_event "enter"] 190 190 $c bind $_tick <Leave> [itcl::code $this handle_event "leave"] 191 $c bind $_tick <ButtonPress-1> \ 192 [itcl::code $this handle_event "start" %x %y] 191 193 $c bind $_tick <B1-Motion> \ 192 194 [itcl::code $this handle_event "update" %x %y] … … 199 201 200 202 public method get_relative_value {} { 201 foreach {min max} [$_nvobj getLimits -current] break 202 return [expr {($_value-$min)/($max - $min)}] 203 array set limits [$_nvobj getLimits] 204 return [expr {($_value-$limits(vmin))/($limits(vmax) - $limits(vmin))}] 205 } 206 public method activate { bool } { 207 if { $bool || $_active_press || $_active_motion } { 208 $_canvas itemconfigure $_label -state normal 209 $_canvas itemconfigure $_tick -image $_activeIcon 210 } else { 211 $_canvas itemconfigure $_label -state hidden 212 $_canvas itemconfigure $_tick -image $_normalIcon 213 } 203 214 } 204 215 public method show {} { … … 232 243 } 233 244 public method set_relative_value { x } { 234 foreach {min max} [$_nvobj getLimits -current] break235 set r [expr $ max - $min]236 set_absolute_value [expr {($x * $r) + $ min}]245 array set limits [$_nvobj getLimits] 246 set r [expr $limits(vmax) - $limits(vmin)] 247 set_absolute_value [expr {($x * $r) + $limits(vmin)}] 237 248 } 238 249 public method handle_event { option args } { 250 puts stderr "option=$option" 239 251 switch -- $option { 240 252 enter { 241 $_canvas itemconfigure $_label -state normal242 $_canvas itemconfigure $_tick -image $_active_icon253 set _active_motion 1 254 activate yes 243 255 $_canvas raise $_tick 244 256 } 245 257 leave { 246 $_canvas itemconfigure $_label -state hidden247 $_canvas itemconfigure $_tick -image $_normal_icon258 set _active_motion 0 259 activate no 248 260 } 249 261 start { 250 262 $_canvas raise $_tick 263 set _active_press 1 264 activate yes 251 265 } 252 266 update { … … 254 268 set x [lindex $args 0] 255 269 set_relative_value [expr {double($x-10)/($w-20)}] 270 $_nvobj over_isomarker $this $x 256 271 $_nvobj update_transfer_function 257 272 } … … 261 276 eval handle_event update $args 262 277 } 278 set _active_press 0 279 activate no 263 280 } 264 281 default { … … 308 325 set _obj2id(count) 0 309 326 set _id2obj(count) 0 327 set _limits(vmin) 0.0 328 set _limits(vmax) 1.0 310 329 311 330 itk_component add controls { … … 543 562 $inner.scales.transp set 50 544 563 545 label $inner.scales.zerol -text " Transparent" -font $fg564 label $inner.scales.zerol -text "Clear" -font $fg 546 565 grid $inner.scales.zerol -row 2 -column 0 -sticky e 547 566 ::scale $inner.scales.opacity -from 0 -to 100 -orient horizontal \ … … 550 569 label $inner.scales.onel -text "Opaque" -font $fg 551 570 grid $inner.scales.onel -row 2 -column 2 -sticky w 552 $inner.scales.opacity set 50 571 $inner.scales.opacity set 100 572 573 label $inner.scales.thinl -text "Thin" -font $fg 574 grid $inner.scales.thinl -row 3 -column 0 -sticky e 575 ::scale $inner.scales.thickness -from 0 -to 1000 -orient horizontal \ 576 -showvalue off -command [itcl::code $this _fixSettings thickness] 577 grid $inner.scales.thickness -row 3 -column 1 -sticky ew 578 label $inner.scales.thickl -text "Thick" -font $fg 579 grid $inner.scales.thickl -row 3 -column 2 -sticky w 580 $inner.scales.thickness set 500 553 581 554 582 set ::Rappture::NanovisViewer::_isosurface($this) 1 … … 557 585 -variable ::Rappture::NanovisViewer::_isosurface($this) \ 558 586 -command [itcl::code $this _fixSettings isosurface] 559 grid $inner.scales.isosurface -row 3-column 0 -columnspan 2 -sticky w587 grid $inner.scales.isosurface -row 4 -column 0 -columnspan 2 -sticky w 560 588 561 589 … … 1083 1111 # and make sure that it's defined on the server. 1084 1112 # 1085 _initIsoMarkers $dataobj $comp 1113 if { ![info exists _isomarkers($dataobj)] } { 1114 _initIsoMarkers $dataobj $comp 1115 } else { 1116 _hideIsoMarkers $dataObj 1117 } 1086 1118 foreach {sname cmap wmap} [_genTransfuncData $dataobj $comp] break 1087 1119 set cmdstr [list transfunc define $sname $cmap $wmap] … … 1322 1354 _fixSettings transp 1323 1355 _fixSettings isosurface 1356 _fixSettings opacity 1357 _fixSettings thickness 1324 1358 1325 1359 if {"" == $itk_option(-plotoutline)} { … … 1612 1646 } 1613 1647 } 1648 thickness { 1649 if {[isconnected]} { 1650 set dataobj [lindex [get] 0] 1651 if {$dataobj != 0} { 1652 set val [$inner.scales.opacity get] 1653 # Scale values between 0.00001 and 0.01000 1654 set sval [expr {0.00001*double($val)}] 1655 set _thickness($dataobj) $sval 1656 update_transfer_function 1657 } 1658 } 1659 } 1614 1660 isosurface { 1615 1661 if {[isconnected]} { … … 1707 1753 1708 1754 set delta 0.0005 1755 if { [info exists _thickness($dataobj)]} { 1756 set delta $_thickness($dataobj) 1757 } 1709 1758 set first [lindex $isovalues 0] 1710 1759 set last [lindex $isovalues end] … … 1714 1763 } 1715 1764 foreach x $isovalues { 1716 set x1 [expr {$x-$delta -0.001}]1765 set x1 [expr {$x-$delta}] 1717 1766 set x2 [expr {$x-$delta}] 1718 1767 set x3 [expr {$x+$delta}] 1719 set x4 [expr {$x+$delta +0.001}]1768 set x4 [expr {$x+$delta}] 1720 1769 if { $x1 < 0.0 } { 1721 1770 set x1 0.0 … … 1824 1873 1825 1874 itcl::body Rappture::NanovisViewer::_initIsoMarkers {dataobj comp} { 1826 if { [info exists _isomarkers($dataobj)] } {1827 _hideIsoMarkers $dataObj1828 return1829 }1830 1875 array set style { 1831 -levels 6 1876 -levels 6x 1832 1877 } 1833 1878 array set style [lindex [$dataobj components -style $comp] 0] 1834 1879 set levels $style(-levels) 1835 1880 set c $itk_component(legend) 1836 if { [llength $levels] == 1 && [string is int $levels] } { 1837 for {set i 1} {$i <= $levels} {incr i} { 1838 set x [expr {double($i)/($levels+1)}] 1881 regsub -all "," $levels " " levels 1882 foreach level $levels { 1883 set n [scan $level "%g%s" value suffix] 1884 if { $n == 2 && $suffix == "%" } { 1885 # ${n}% : Set relative value. 1886 set value [expr {$value * 0.01}] 1839 1887 set m [IsoMarker \#auto $c $this] 1840 $m set_relative_value $x 1841 lappend _isomarkers($dataobj) $m 1888 $m set_relative_value $value 1889 lappend _isomarkers($dataobj) $m 1890 } elseif { $n == 2 && $suffix == "x" } { 1891 # ${n}x : Set equal number of levels 1892 if { $value != round($value) } { 1893 error "\# of levels \"$value\" must be an interger" 1894 } 1895 set nLevels [expr round($value)] 1896 for {set i 1} {$i <= $nLevels} {incr i} { 1897 set x [expr {double($i)/($nLevels+1)}] 1898 set m [IsoMarker \#auto $c $this] 1899 $m set_relative_value $x 1900 lappend _isomarkers($dataobj) $m 1901 } 1902 } else { 1903 # ${n} : Set absolute value. 1904 set m [IsoMarker \#auto $c $this] 1905 $m set_absolute_value $value 1906 lappend _isomarkers($dataobj) $m 1842 1907 } 1843 } else {1844 regsub -all "," $levels " " levels1845 foreach level $levels {1846 set n [scan $level "%g%s" x unit]1847 set m [IsoMarker \#auto $c $this]1848 lappend _isomarkers($dataobj) $m1849 if { $n == 2 && $unit == "%" } {1850 set x [expr {$x * 0.01}]1851 $m set_relative_value $x1852 } else {1853 $m set_absolute_value $x1854 }1855 }1856 1908 } 1857 1909 } … … 1904 1956 return 0 1905 1957 } 1906 set bool 11958 set bool 0 1907 1959 if { [info exists _isomarkers($dataobj)] } { 1908 1960 set list {} … … 1914 1966 $marker set_relative_value [$m get_relative_value] 1915 1967 itcl::delete object $m 1916 set bool 0 1968 bell 1969 set bool 1 1917 1970 continue 1918 1971 } … … 1925 1978 return $bool 1926 1979 } 1980 1981 itcl::body Rappture::NanovisViewer::over_isomarker { marker x } { 1982 set dataobj [lindex [get] 0] 1983 if {"" == $dataobj} { 1984 return "" 1985 } 1986 if { [info exists _isomarkers($dataobj)] } { 1987 set marker [namespace tail $marker] 1988 foreach m $_isomarkers($dataobj) { 1989 set sx [$m get_screen_position] 1990 if { $m != $marker } { 1991 set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }] 1992 $m activate $bool 1993 } 1994 } 1995 } 1996 return "" 1997 }
Note: See TracChangeset
for help on using the changeset viewer.