Changeset 5115 for branches/1.3/gui/scripts/nanovisviewer.tcl
- Timestamp:
- Mar 9, 2015 8:04:58 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/nanovisviewer.tcl
r5110 r5115 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 3 3 # ---------------------------------------------------------------------- … … 20 20 # 21 21 # FIXME: 22 # Need to Add DX readers this client to examine the data before 22 # Need to Add DX readers this client to examine the data before 23 23 # it's sent to the server. This will eliminate 90% of the insanity in 24 # computing the limits of all the volumes. I can rip out all the 24 # computing the limits of all the volumes. I can rip out all the 25 25 # "receive data" "send transfer function" event crap. 26 26 # … … 30 30 # when a new volume is drawn (using the default transfer function) and 31 31 # then when the correct transfer function has been sent and linked to 32 # the volume. 32 # the volume. 33 33 # 34 34 option add *NanovisViewer.width 4i widgetDefault … … 77 77 public method limits { tf } 78 78 public method overmarker { m x } 79 public method parameters {title args} { 80 # do nothing 79 public method parameters {title args} { 80 # do nothing 81 81 } 82 82 public method rmdupmarker { m x } … … 110 110 private method ResetColormap { color } 111 111 private method ComputeTransferFunc { tf } 112 private method EventuallyResize { w h } 113 private method EventuallyResizeLegend { } 112 private method EventuallyResize { w h } 113 private method EventuallyResizeLegend { } 114 114 private method NameTransferFunc { dataobj comp } 115 115 private method PanCamera {} … … 125 125 private variable _allDataObjs 126 126 private variable _obj2ovride ;# maps dataobj => style override 127 private variable _serverDatasets ;# contains all the dataobj-component 127 private variable _serverDatasets ;# contains all the dataobj-component 128 128 ;# to volumes in the server 129 private variable _serverTfs ;# contains all the transfer functions 129 private variable _serverTfs ;# contains all the transfer functions 130 130 ;# in the server. 131 131 private variable _recvdDatasets ;# list of data objs to send to server 132 132 private variable _dataset2style ;# maps dataobj-component to transfunc 133 private variable _style2datasets ;# maps tf back to list of 134 # dataobj-components using the tf.135 136 private variable _reset 1 ; # Connection to server has been reset133 private variable _style2datasets ;# maps tf back to list of 134 # dataobj-components using the tf. 135 136 private variable _reset 1 ;# Connection to server has been reset 137 137 private variable _click ;# info used for rotate operations 138 138 private variable _limits ;# autoscale min/max for all axes 139 139 private variable _view ;# view params for 3D view 140 private variable _isomarkers 140 private variable _isomarkers ;# array of isosurface level values 0..1 141 141 private variable _settings 142 142 # Array of transfer functions in server. If 0 the transfer has been … … 146 146 private variable _first "" ;# This is the topmost volume. 147 147 148 # This149 # indicates which isomarkers and transfer150 # function to use when changing markers,151 # opacity, or thickness.152 148 common _downloadPopup ;# download options from popup 153 149 private common _hardcopy … … 216 212 $this-qy $_view(qy) 217 213 $this-qz $_view(qz) 218 $this-zoom $_view(zoom) 214 $this-zoom $_view(zoom) 219 215 $this-xpan $_view(xpan) 220 216 $this-ypan $_view(ypan) … … 292 288 BuildCameraTab 293 289 } errs] != 0 } { 294 290 global errorInfo 295 291 puts stderr "errs=$errs errorInfo=$errorInfo" 296 292 } … … 309 305 [itcl::code $this EventuallyResizeLegend] 310 306 311 # Hack around the Tk panewindow. The problem is that the requested 307 # Hack around the Tk panewindow. The problem is that the requested 312 308 # size of the 3d view isn't set until an image is retrieved from 313 309 # the server. So the panewindow uses the tiny size. … … 316 312 blt::table $itk_component(plotarea) \ 317 313 0,0 $itk_component(3dview) -fill both -reqwidth $w \ 318 1,0 $itk_component(legend) -fill x 314 1,0 $itk_component(legend) -fill x 319 315 blt::table configure $itk_component(plotarea) r1 -resize none 320 316 … … 573 569 # to the BLT picture image it won't be necessary to decode the 574 570 # image data. 575 if { [image width $_image(plot)] > 0 && 571 if { [image width $_image(plot)] > 0 && 576 572 [image height $_image(plot)] > 0 } { 577 573 set bytes [$_image(plot) data -format "jpeg -quality 100"] … … 599 595 return 0 600 596 } 601 set _reset 1 597 set _reset 1 602 598 set result [VisViewer::Connect $_hosts] 603 599 if { $result } { … … 680 676 foreach tag [CurrentDatasets] { 681 677 if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } { 682 # The volume hasn't reached the server yet. How did we get 678 # The volume hasn't reached the server yet. How did we get 683 679 # here? 684 680 puts stderr "Don't have $tag in _serverDatasets" … … 694 690 ComputeTransferFunc $tf 695 691 # FIXME: Need to the send information as to what transfer functions 696 # to update so that we only update the transfer function 697 # as necessary. Right now, all transfer functions are 692 # to update so that we only update the transfer function 693 # as necessary. Right now, all transfer functions are 698 694 # updated. This makes moving the isomarker slider chunky. 699 695 if { ![info exists _activeTfs($tf)] || !$_activeTfs($tf) } { … … 722 718 ReceiveEcho <<line "<read $info(-bytes) bytes" 723 719 if { $info(-type) == "image" } { 724 ReceiveEcho "for [image width $_image(plot)]x[image height $_image(plot)] image>" 720 ReceiveEcho "for [image width $_image(plot)]x[image height $_image(plot)] image>" 725 721 $_image(plot) configure -data $bytes 726 722 } elseif { $info(-type) == "print" } { … … 735 731 # The procedure is the response from the render server to each "legend" 736 732 # command. The server sends back a "legend" command invoked our 737 # the slave interpreter. The purpose is to collect data of the image 733 # the slave interpreter. The purpose is to collect data of the image 738 734 # representing the legend in the canvas. In addition, the isomarkers 739 735 # of the active transfer function are displayed. 740 736 # 741 737 # I don't know is this is the right place to display the isomarkers. 742 # I don't know all the different paths used to draw the plot. There's 738 # I don't know all the different paths used to draw the plot. There's 743 739 # "Rebuild", "add", etc. 744 740 # … … 873 869 # Turn on buffering of commands to the server. We don't want to 874 870 # be preempted by a server disconnect/reconnect (which automatically 875 # generates a new call to Rebuild). 871 # generates a new call to Rebuild). 876 872 StartBufferingCommands 877 873 … … 932 928 set _first [lindex [get] 0] 933 929 if { $_reset } { 934 935 936 930 # 931 # Reset the camera and other view parameters 932 # 937 933 set _settings($this-qw) $_view(qw) 938 934 set _settings($this-qx) $_view(qx) 939 935 set _settings($this-qy) $_view(qy) 940 936 set _settings($this-qz) $_view(qz) 941 942 943 937 set _settings($this-xpan) $_view(xpan) 938 set _settings($this-ypan) $_view(ypan) 939 set _settings($this-zoom) $_view(zoom) 944 940 945 941 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] … … 947 943 SendCmd "camera orient $q" 948 944 SendCmd "camera reset" 949 950 951 InitSettings light2side light transp isosurface grid axes 952 945 PanCamera 946 SendCmd "camera zoom $_view(zoom)" 947 InitSettings light2side light transp isosurface grid axes 948 953 949 foreach axis {x y z} { 954 950 # Turn off cutplanes for all volumes 955 951 SendCmd "cutplane state 0 $axis" 956 952 } 957 958 959 960 961 962 963 964 965 966 953 if {"" != $_first} { 954 set axis [$_first hints updir] 955 if { "" != $axis } { 956 SendCmd "up $axis" 957 } 958 set location [$_first hints camera] 959 if { $location != "" } { 960 array set _view $location 961 } 962 } 967 963 } 968 964 # Outline seems to need to be reset every update. … … 971 967 SendCmd "volume state 0" 972 968 if {"" != $_first} { 973 set datasets [array names _serverDatasets $_first-*] 969 set datasets [array names _serverDatasets $_first-*] 974 970 if { $datasets != "" } { 975 971 SendCmd "volume state 1 $datasets" … … 1264 1260 blt::table $itk_component(plotarea) \ 1265 1261 0,0 $itk_component(3dview) -fill both \ 1266 1,0 $itk_component(legend) -fill x 1262 1,0 $itk_component(legend) -fill x 1267 1263 blt::table configure $itk_component(plotarea) r1 -resize none 1268 1264 } else { … … 1271 1267 } 1272 1268 "volume" { 1273 set datasets [CurrentDatasets -cutplanes] 1269 set datasets [CurrentDatasets -cutplanes] 1274 1270 SendCmd "volume data state $_settings($this-volume) $datasets" 1275 1271 } … … 1277 1273 set axis [string range $what 0 0] 1278 1274 set bool $_settings($this-$what) 1279 set datasets [CurrentDatasets -cutplanes] 1275 set datasets [CurrentDatasets -cutplanes] 1280 1276 set tag [lindex $datasets 0] 1281 1277 SendCmd "cutplane state $bool $axis $tag" … … 1314 1310 # Can't do this as this will remove the items associated with the 1315 1311 # isomarkers. 1316 1312 1317 1313 #$itk_component(legend) delete all 1318 1314 } … … 1376 1372 # reference. 1377 1373 # 1378 # FIXME: The current way we generate transfer-function names completely 1379 # ignores the -markers option. The problem is that we are forced 1380 # to compute the name from an increasing complex set of values: 1374 # FIXME: The current way we generate transfer-function names completely 1375 # ignores the -markers option. The problem is that we are forced 1376 # to compute the name from an increasing complex set of values: 1381 1377 # color, levels, marker, opacity. I think the cow's out of the 1382 1378 # barn on this one. … … 1506 1502 set m [Rappture::IsoMarker \#auto $c $this $tf] 1507 1503 $m relval $x 1508 lappend _isomarkers($tf) $m 1504 lappend _isomarkers($tf) $m 1509 1505 } 1510 1506 } else { … … 1512 1508 set m [Rappture::IsoMarker \#auto $c $this $tf] 1513 1509 $m relval $x 1514 lappend _isomarkers($tf) $m 1510 lappend _isomarkers($tf) $m 1515 1511 } 1516 1512 } … … 1519 1515 # 1520 1516 # The -markers option takes a list of zero or more values (the values 1521 # may be separated either by spaces or commas) that have the following 1517 # may be separated either by spaces or commas) that have the following 1522 1518 # format: 1523 1519 # … … 1535 1531 set n [scan $marker "%g%s" value suffix] 1536 1532 if { $n == 2 && $suffix == "%" } { 1537 # ${n}% : Set relative value. 1533 # ${n}% : Set relative value. 1538 1534 set value [expr {$value * 0.01}] 1539 1535 set m [Rappture::IsoMarker \#auto $c $this $tf] … … 1550 1546 1551 1547 # ---------------------------------------------------------------------- 1552 # USAGE: UndateTransferFuncs 1548 # USAGE: UndateTransferFuncs 1553 1549 # ---------------------------------------------------------------------- 1554 1550 itcl::body Rappture::NanovisViewer::updatetransferfuncs {} { … … 1634 1630 if { $min != "" } { 1635 1631 set _limits(min) $min 1636 } 1632 } 1637 1633 if { $max != "" } { 1638 1634 set _limits(max) $max … … 1705 1701 2,0 $inner.outline -cspan 2 -anchor w \ 1706 1702 3,0 $inner.volume -cspan 2 -anchor w \ 1707 4,0 $inner.legend -cspan 2 -anchor w 1703 4,0 $inner.legend -cspan 2 -anchor w 1708 1704 1709 1705 if 0 { … … 1770 1766 label $inner.thick -text "Thick" -font $fg 1771 1767 1772 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1768 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1773 1769 itk_component add colormap { 1774 1770 Rappture::Combobox $inner.colormap -width 10 -editable no … … 1792 1788 "grey-to-blue" "grey-to-blue" \ 1793 1789 "orange-to-blue" "orange-to-blue" \ 1794 "none""none"1790 "none" "none" 1795 1791 1796 1792 $itk_component(colormap) value "BCGYR" … … 1909 1905 0,1 $itk_component(xCutScale) \ 1910 1906 0,2 $itk_component(yCutScale) \ 1911 0,3 $itk_component(zCutScale) 1907 0,3 $itk_component(zCutScale) 1912 1908 1913 1909 blt::table configure $inner r0 r1 c* -resize none … … 2024 2020 } 2025 2021 2026 # camera -- 2022 # camera -- 2027 2023 # 2028 2024 itcl::body Rappture::NanovisViewer::camera {option args} { 2029 switch -- $option { 2025 switch -- $option { 2030 2026 "show" { 2031 2027 puts [array get _view] … … 2101 2097 -font "Arial 9" 2102 2098 Rappture::Tooltip::for $inner.vol$row $info(description) 2103 blt::table $inner $row,0 $inner.vol$row -anchor w 2099 blt::table $inner $row,0 $inner.vol$row -anchor w 2104 2100 if { !$_settings($this-volume-$name) } { 2105 2101 $inner.vol$row select 2106 } 2102 } 2107 2103 incr row 2108 2104 } … … 2110 2106 blt::table configure $inner r$row -resize expand 2111 2107 blt::table configure $inner c3 -resize expand 2112 event generate [winfo parent [winfo parent $w]] <Configure> 2108 event generate [winfo parent [winfo parent $w]] <Configure> 2113 2109 } 2114 2110 … … 2118 2114 } 2119 2115 2120 itcl::body Rappture::NanovisViewer::SetOrientation { side } { 2116 itcl::body Rappture::NanovisViewer::SetOrientation { side } { 2121 2117 array set positions { 2122 2118 front "1 0 0 0" … … 2129 2125 foreach name { qw qx qy qz } value $positions($side) { 2130 2126 set _view($name) $value 2131 } 2127 } 2132 2128 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2133 2129 $_arcball quaternion $q 2134 SendCmd "camera orient $q" 2130 SendCmd "camera orient $q" 2135 2131 SendCmd "camera reset" 2136 2132 set _view(xpan) 0
Note: See TracChangeset
for help on using the changeset viewer.