Changeset 5115
- Timestamp:
- Mar 9, 2015 8:04:58 PM (6 years ago)
- Location:
- branches/1.3/gui/scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/flowvisviewer.tcl
r5110 r5115 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: flowvisviewer - 3D flow rendering … … 65 65 public method limits { tf } 66 66 public method overmarker { m x } 67 public method parameters {title args} { 68 # do nothing 67 public method parameters {title args} { 68 # do nothing 69 69 } 70 70 public method rmdupmarker { m x } … … 105 105 private method BuildVolumeTab {} 106 106 private method ComputeTransferFunc { tf } 107 private method EventuallyResize { w h } 108 private method EventuallyGoto { nSteps } 109 private method EventuallyResizeLegend { } 107 private method EventuallyResize { w h } 108 private method EventuallyGoto { nSteps } 109 private method EventuallyResizeLegend { } 110 110 private method FlowCmd { dataobj comp nbytes extents } 111 111 private method GetMovie { widget width height } … … 116 116 private method ParseMarkersOption { tf markers } 117 117 private method WaitIcon { option widget } 118 private method str2millisecs { value } 119 private method millisecs2str { value } 118 private method str2millisecs { value } 119 private method millisecs2str { value } 120 120 private method GetFlowInfo { widget } 121 private method particles { tag name } 122 private method box { tag name } 123 private method streams { tag name } 124 private method arrows { tag name } 121 private method particles { tag name } 122 private method box { tag name } 123 private method streams { tag name } 124 private method arrows { tag name } 125 125 private method SetOrientation { side } 126 126 … … 129 129 private variable _allDataObjs 130 130 private variable _obj2ovride ;# maps dataobj => style override 131 private variable _serverObjs ;# maps dataobj-component to volume ID 131 private variable _serverObjs ;# maps dataobj-component to volume ID 132 132 # in the server 133 133 private variable _sendobjs "" ;# list of data objs to send to server 134 private variable _recvObjs ;# list of data objs to send to server134 private variable _recvObjs ;# list of data objs to send to server 135 135 private variable _obj2style ;# maps dataobj-component to transfunc 136 private variable _style2objs ;# maps tf back to list of 136 private variable _style2objs ;# maps tf back to list of 137 137 # dataobj-components using the tf. 138 private variable _obj2flow; 139 140 private variable _reset 1 ; # Connection to server has been reset138 private variable _obj2flow; # Maps dataobj-component to a flow. 139 140 private variable _reset 1 ;# Connection to server has been reset 141 141 private variable _click ;# info used for rotate operations 142 142 private variable _limits ;# autoscale min/max for all axes 143 143 private variable _view ;# view params for 3D view 144 private variable _isomarkers 144 private variable _isomarkers ;# array of isosurface level values 0..1 145 145 private common _settings 146 146 private variable _activeTf "" ;# The currently active transfer function. … … 149 149 private variable _icon 0 150 150 private variable _flow 151 # This152 # indicates which isomarkers and transfer153 # function to use when changing markers,154 # opacity, or thickness.155 151 private common _downloadPopup ;# download options from popup 156 152 … … 198 194 $_dispatcher register !play 199 195 $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list" 200 196 201 197 # Draw legend event 202 198 $_dispatcher register !goto … … 241 237 $this-qy $_view(qy) 242 238 $this-qz $_view(qz) 243 $this-zoom $_view(zoom) 239 $this-zoom $_view(zoom) 244 240 $this-xpan $_view(xpan) 245 241 $this-ypan $_view(ypan) … … 345 341 [itcl::code $this EventuallyResizeLegend] 346 342 347 # Hack around the Tk panewindow. The problem is that the requested 343 # Hack around the Tk panewindow. The problem is that the requested 348 344 # size of the 3d view isn't set until an image is retrieved from 349 345 # the server. So the panewindow uses the tiny size. … … 353 349 0,0 $itk_component(3dview) -fill both -reqwidth $w \ 354 350 1,0 $itk_component(legend) -fill x 355 blt::table configure $itk_component(plotarea) r1 -resize none 351 blt::table configure $itk_component(plotarea) r1 -resize none 356 352 # Create flow controls... 357 353 358 354 itk_component add flowcontrols { 359 frame $itk_interior.flowcontrols 355 frame $itk_interior.flowcontrols 360 356 } { 361 357 usual … … 404 400 -offimage [Rappture::icon flow-play] \ 405 401 -variable [itcl::scope _settings($this-play)] \ 406 -command [itcl::code $this flow toggle] 402 -command [itcl::code $this flow toggle] 407 403 } 408 404 set fg [option get $itk_component(hull) font Font] … … 456 452 } { 457 453 usual 458 ignore -highlightthickness 454 ignore -highlightthickness 459 455 rename -background -controlbackground controlBackground Background 460 456 } … … 465 461 } { 466 462 usual 467 ignore -highlightthickness 463 ignore -highlightthickness 468 464 rename -background -controlbackground controlBackground Background 469 465 } … … 475 471 } { 476 472 usual 477 ignore -highlightthickness 473 ignore -highlightthickness 478 474 rename -background -controlbackground controlBackground Background 479 475 } … … 492 488 0,4 $itk_component(dial) -fill x -padx {2 0 } \ 493 489 0,5 $itk_component(duration) -padx { 0 0} \ 494 0,7 $itk_component(speed) -padx {2 3} 495 496 # 0,6 $itk_component(speedlabel) -padx {2 0} 490 0,7 $itk_component(speed) -padx {2 3} 491 492 # 0,6 $itk_component(speedlabel) -padx {2 0} 497 493 blt::table configure $itk_component(flowcontrols) c* -resize none 498 494 blt::table configure $itk_component(flowcontrols) c4 -resize both … … 696 692 # If anything changed, then rebuild the plot 697 693 if {$changed} { 698 # Repair the reverse lookup 694 # Repair the reverse lookup 699 695 foreach tf [array names _style2objs] { 700 696 set list {} … … 853 849 return 0 854 850 } 855 set _reset 1 851 set _reset 1 856 852 set result [VisViewer::Connect $_hosts] 857 853 if { $result } { … … 863 859 set info {} 864 860 set user "???" 865 861 if { [info exists env(USER)] } { 866 862 set user $env(USER) 867 863 } 868 864 set session "???" 869 865 if { [info exists env(SESSION)] } { 870 866 set session $env(SESSION) 871 867 } 872 868 lappend info "version" "$Rappture::version" 873 869 lappend info "build" "$Rappture::build" … … 961 957 # Turn on buffering of commands to the server. We don't want to 962 958 # be preempted by a server disconnect/reconnect (which automatically 963 # generates a new call to Rebuild). 959 # generates a new call to Rebuild). 964 960 StartBufferingCommands 965 961 … … 1057 1053 $_image(plot) configure -data $bytes 1058 1054 #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]" 1059 } 1055 } 1060 1056 "print" { 1061 1057 set tag $this-$info(-token) 1062 1058 set _hardcopy($tag) $bytes 1063 } 1059 } 1064 1060 "movie" { 1065 1061 set tag $this-$info(-token) … … 1077 1073 # The procedure is the response from the render server to each "legend" 1078 1074 # command. The server sends back a "legend" command invoked our 1079 # the slave interpreter. The purpose is to collect data of the image 1075 # the slave interpreter. The purpose is to collect data of the image 1080 1076 # representing the legend in the canvas. In addition, the isomarkers 1081 1077 # of the active transfer function are displayed. 1082 1078 # 1083 1079 # I don't know is this is the right place to display the isomarkers. 1084 # I don't know all the different paths used to draw the plot. There's 1080 # I don't know all the different paths used to draw the plot. There's 1085 1081 # "Rebuild", "add", etc. 1086 1082 # … … 1174 1170 # Called automatically whenever something changes that affects the data 1175 1171 # in the widget. Clears any existing data and rebuilds the widget to 1176 # display new data. 1172 # display new data. 1177 1173 # 1178 1174 itcl::body Rappture::FlowvisViewer::Rebuild {} { … … 1187 1183 # Turn on buffering of commands to the server. We don't want to 1188 1184 # be preempted by a server disconnect/reconnect (which automatically 1189 # generates a new call to Rebuild). 1185 # generates a new call to Rebuild). 1190 1186 StartBufferingCommands 1191 1187 … … 1247 1243 # Reset the camera and other view parameters 1248 1244 InitSettings light2side light transp isosurface grid axes volume outline 1249 1245 1250 1246 # nothing to send -- activate the proper volume 1251 1247 if {"" != $_first} { … … 1531 1527 record { 1532 1528 if { [$itk_component(rewind) cget -relief] != "sunken" } { 1533 $itk_component(rewind) configure -relief sunken 1534 $itk_component(stop) configure -relief raised 1535 $itk_component(play) configure -relief raised 1529 $itk_component(rewind) configure -relief sunken 1530 $itk_component(stop) configure -relief raised 1531 $itk_component(play) configure -relief raised 1536 1532 set inner $itk_component(settingsFrame) 1537 1533 set frames [$inner.framecnt value] … … 1543 1539 stop { 1544 1540 if { [$itk_component(stop) cget -relief] != "sunken" } { 1545 $itk_component(rewind) configure -relief raised 1546 $itk_component(stop) configure -relief sunken 1547 $itk_component(play) configure -relief raised 1541 $itk_component(rewind) configure -relief raised 1542 $itk_component(stop) configure -relief sunken 1543 $itk_component(play) configure -relief raised 1548 1544 _pause 1549 1545 set cmds "flow reset" … … 1554 1550 if { [$itk_component(play) cget -relief] != "sunken" } { 1555 1551 $itk_component(rewind) configure -relief raised 1556 $itk_component(stop) configure -relief raised 1552 $itk_component(stop) configure -relief raised 1557 1553 $itk_component(play) configure \ 1558 1554 -image [Rappture::icon flow-pause] \ 1559 -relief sunken 1555 -relief sunken 1560 1556 bind $itk_component(play) <ButtonPress> \ 1561 1557 [itcl::code $this _pause] … … 1597 1593 $itk_component(play) configure \ 1598 1594 -image [Rappture::icon flow-start] \ 1599 -relief raised 1595 -relief raised 1600 1596 bind $itk_component(play) <ButtonPress> \ 1601 1597 [itcl::code $this Flow movie play toggle] … … 1625 1621 switch -- $what { 1626 1622 colormap { 1627 set color [$itk_component(colormap) value] 1628 set _settings(colormap) $color 1629 #ResetColormap $color 1623 set color [$itk_component(colormap) value] 1624 set _settings(colormap) $color 1625 #ResetColormap $color 1630 1626 } 1631 1627 light { … … 1701 1697 blt::table $itk_component(plotarea) \ 1702 1698 0,0 $itk_component(3dview) -fill both \ 1703 1,0 $itk_component(legend) -fill x 1699 1,0 $itk_component(legend) -fill x 1704 1700 blt::table configure $itk_component(plotarea) r1 -resize none 1705 1701 } else { … … 1718 1714 set bool $_settings($this-$what) 1719 1715 if { [isconnected] } { 1720 set vols [CurrentVolumeIds -cutplanes] 1716 set vols [CurrentVolumeIds -cutplanes] 1721 1717 SendCmd "cutplane state $bool $axis $vols" 1722 1718 } … … 1830 1826 # reference. 1831 1827 # 1832 # FIXME: The current way we generate transfer-function names completely 1833 # ignores the -markers option. The problem is that we are forced 1834 # to compute the name from an increasing complex set of values: 1828 # FIXME: The current way we generate transfer-function names completely 1829 # ignores the -markers option. The problem is that we are forced 1830 # to compute the name from an increasing complex set of values: 1835 1831 # color, levels, marker, opacity. I think the cow's out of the 1836 1832 # barn on this one. … … 1857 1853 } 1858 1854 set max 1.0 ;#$_settings($tag-opacity) 1859 1855 1860 1856 set isovalues {} 1861 1857 foreach m $_isomarkers($tf) { … … 1967 1963 set m [Rappture::IsoMarker \#auto $c $this $tf] 1968 1964 $m relval $x 1969 lappend _isomarkers($tf) $m 1965 lappend _isomarkers($tf) $m 1970 1966 } 1971 1967 } else { … … 1973 1969 set m [Rappture::IsoMarker \#auto $c $this $tf] 1974 1970 $m relval $x 1975 lappend _isomarkers($tf) $m 1971 lappend _isomarkers($tf) $m 1976 1972 } 1977 1973 } … … 1980 1976 # 1981 1977 # The -markers option takes a list of zero or more values (the values 1982 # may be separated either by spaces or commas) that have the following 1978 # may be separated either by spaces or commas) that have the following 1983 1979 # format: 1984 1980 # … … 1996 1992 set n [scan $marker "%g%s" value suffix] 1997 1993 if { $n == 2 && $suffix == "%" } { 1998 # ${n}% : Set relative value. 1994 # ${n}% : Set relative value. 1999 1995 set value [expr {$value * 0.01}] 2000 1996 set m [Rappture::IsoMarker \#auto $c $this $tf] … … 2011 2007 2012 2008 # ---------------------------------------------------------------------- 2013 # USAGE: UndateTransferFuncs 2009 # USAGE: UndateTransferFuncs 2014 2010 # ---------------------------------------------------------------------- 2015 2011 itcl::body Rappture::FlowvisViewer::updatetransferfuncs {} { … … 2021 2017 error "active transfer function isn't set" 2022 2018 } 2023 set tf $_activeTf 2019 set tf $_activeTf 2024 2020 set c $itk_component(legend) 2025 2021 set m [Rappture::IsoMarker \#auto $c $this $tf] … … 2098 2094 if { $min != "" } { 2099 2095 set _limits(vmin) $min 2100 } 2096 } 2101 2097 if { $max != "" } { 2102 2098 set _limits(vmax) $max … … 2182 2178 2,0 $inner.outline -cspan 2 -anchor w \ 2183 2179 3,0 $inner.volume -cspan 2 -anchor w \ 2184 4,0 $inner.legend -cspan 2 -anchor w 2180 4,0 $inner.legend -cspan 2 -anchor w 2185 2181 2186 2182 bind $inner <Map> [itcl::code $this GetFlowInfo $inner] … … 2249 2245 label $inner.thick -text "Thick" -font $fg 2250 2246 2251 label $inner.colormap_l -text "Colormap" -font "Arial 9" 2247 label $inner.colormap_l -text "Colormap" -font "Arial 9" 2252 2248 itk_component add colormap { 2253 2249 Rappture::Combobox $inner.colormap -width 10 -editable no … … 2271 2267 "grey-to-blue" "grey-to-blue" \ 2272 2268 "orange-to-blue" "orange-to-blue" \ 2273 "none""none"2269 "none" "none" 2274 2270 2275 2271 $itk_component(colormap) value "BCGYR" … … 2402 2398 $inner configure -borderwidth 4 2403 2399 2404 label $inner.view_l -text "view" -font "Arial 9" 2405 set f [frame $inner.view] 2406 foreach side { front back left right top bottom } { 2400 label $inner.view_l -text "view" -font "Arial 9" 2401 set f [frame $inner.view] 2402 foreach side { front back left right top bottom } { 2407 2403 button $f.$side -image [Rappture::icon view$side] \ 2408 -command [itcl::code $this SetOrientation $side] 2409 Rappture::Tooltip::for $f.$side "Change the view to $side" 2410 pack $f.$side -side left 2404 -command [itcl::code $this SetOrientation $side] 2405 Rappture::Tooltip::for $f.$side "Change the view to $side" 2406 pack $f.$side -side left 2411 2407 } 2412 2408 2413 2409 blt::table $inner \ 2414 2410 0,0 $inner.view_l -anchor e -pady 2 \ 2415 0,1 $inner.view -anchor w -pady 2 2416 2417 set row 1 2411 0,1 $inner.view -anchor w -pady 2 2412 2413 set row 1 2418 2414 set labels { qw qx qy qz xpan ypan zoom } 2419 2415 foreach tag $labels { … … 2467 2463 blt::table $inner \ 2468 2464 1,0 $inner.showstreams -anchor w \ 2469 2,0 $inner.showarrows -anchor w 2465 2,0 $inner.showarrows -anchor w 2470 2466 blt::table configure $inner c0 c1 -resize none 2471 2467 blt::table configure $inner c2 -resize expand … … 2490 2486 -font "Arial 9" 2491 2487 Rappture::Tooltip::for $inner.part$row $info(description) 2492 blt::table $inner $row,0 $inner.part$row -anchor w 2488 blt::table $inner $row,0 $inner.part$row -anchor w 2493 2489 if { !$_settings($this-particles-$name) } { 2494 2490 $inner.part$row select 2495 } 2491 } 2496 2492 incr row 2497 2493 } … … 2517 2513 if { !$_settings($this-box-$name) } { 2518 2514 $inner.box$row select 2519 } 2515 } 2520 2516 incr row 2521 2517 } … … 2523 2519 blt::table configure $inner r$row -resize expand 2524 2520 blt::table configure $inner c3 -resize expand 2525 event generate [winfo parent [winfo parent $w]] <Configure> 2521 event generate [winfo parent [winfo parent $w]] <Configure> 2526 2522 } 2527 2523 … … 2620 2616 } 2621 2617 2622 # camera -- 2618 # camera -- 2623 2619 itcl::body Rappture::FlowvisViewer::camera {option args} { 2624 switch -- $option { 2620 switch -- $option { 2625 2621 "show" { 2626 2622 puts [array get _view] … … 2707 2703 append cmd " -corner1 {$info(corner1)} " 2708 2704 append cmd " -corner2 {$info(corner2)}\n" 2709 } 2705 } 2710 2706 append cmd "$tag data follows $nbytes $extents\n" 2711 2707 return $cmd … … 2775 2771 "stop" { 2776 2772 if { $_flow(state) } { 2777 flow off 2773 flow off 2778 2774 flow reset 2779 2775 } … … 2781 2777 "pause" { 2782 2778 if { $_flow(state) } { 2783 flow off 2779 flow off 2784 2780 } 2785 2781 } … … 2794 2790 set _settings($this-step) 1 2795 2791 SendCmd "flow reset" 2796 } 2792 } 2797 2793 flow next 2798 2794 } … … 2801 2797 if { $_settings($this-play) } { 2802 2798 flow play 2803 } else { 2799 } else { 2804 2800 flow pause 2805 2801 } … … 2826 2822 } 2827 2823 $_dispatcher event -after $_flow(delay) !play 2828 } 2824 } 2829 2825 default { 2830 2826 error "bad option \"$option\": should be play, stop, toggle, or reset." … … 2877 2873 1,0 $inner.please -anchor w \ 2878 2874 1,1 $inner.icon -anchor e \ 2879 2,0 $inner.cancel -cspan 2 2880 blt::table configure $inner r0 -pady 4 2881 blt::table configure $inner r2 -pady 4 2875 2,0 $inner.cancel -cspan 2 2876 blt::table configure $inner r0 -pady 4 2877 blt::table configure $inner r2 -pady 4 2882 2878 bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke] 2883 2879 } else { … … 2895 2891 update idletasks 2896 2892 update 2897 # We wait here for either 2898 # 1) the png to be delivered or 2899 # 2) timeout or 2893 # We wait here for either 2894 # 1) the png to be delivered or 2895 # 2) timeout or 2900 2896 # 3) user cancels the operation. 2901 2897 tkwait variable $var … … 2936 2932 1,0 $inner.please -anchor w \ 2937 2933 1,1 $inner.icon -anchor e \ 2938 2,0 $inner.cancel -cspan 2 2939 blt::table configure $inner r0 -pady 4 2940 blt::table configure $inner r2 -pady 4 2934 2,0 $inner.cancel -cspan 2 2935 blt::table configure $inner r0 -pady 4 2936 blt::table configure $inner r2 -pady 4 2941 2937 bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke] 2942 2938 } else { 2943 2939 set inner [$popup component inner] 2944 2940 } 2945 update 2941 update 2946 2942 # Timeout is set to 10 minutes. 2947 2943 $_dispatcher event -after 600000 !movietimeout … … 2949 2945 grab set $inner 2950 2946 focus $inner.cancel 2951 2947 2952 2948 flow duration 2953 2949 flow speed … … 2961 2957 set start [clock seconds] 2962 2958 SendCmd "flow video $token -width $w -height $h -numframes $nframes " 2963 2959 2964 2960 $popup activate $widget below 2965 update idletasks 2961 update idletasks 2966 2962 update 2967 2963 # We wait here until 2968 # 1. the movie is delivered or 2969 # 2. we've timed out or 2964 # 1. the movie is delivered or 2965 # 2. we've timed out or 2970 2966 # 3. the user has canceled the operation.b 2971 2967 tkwait variable $var … … 2982 2978 2983 2979 # This will both cancel the movie generation (if it hasn't already 2984 # completed) and reset the flow. 2980 # completed) and reset the flow. 2985 2981 SendCmd "flow reset" 2986 2982 if { $_hardcopy($this-$token) != "" } { … … 3016 3012 } 3017 3013 3018 itcl::body Rappture::FlowvisViewer::SetOrientation { side } { 3019 array set positions { 3020 front "1 0 0 0" 3021 back "0 0 1 0" 3022 left "0.707107 0 -0.707107 0" 3023 right "0.707107 0 0.707107 0" 3024 top "0.707107 -0.707107 0 0" 3025 bottom "0.707107 0.707107 0 0" 3026 } 3027 foreach name { qw qx qy qz } value $positions($side) { 3014 itcl::body Rappture::FlowvisViewer::SetOrientation { side } { 3015 array set positions { 3016 front "1 0 0 0" 3017 back "0 0 1 0" 3018 left "0.707107 0 -0.707107 0" 3019 right "0.707107 0 0.707107 0" 3020 top "0.707107 -0.707107 0 0" 3021 bottom "0.707107 0.707107 0 0" 3022 } 3023 foreach name { qw qx qy qz } value $positions($side) { 3028 3024 set _view($name) $value 3029 } 3025 } 3030 3026 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 3031 3027 $_arcball quaternion $q 3032 SendCmd "camera orient $q" 3028 SendCmd "camera orient $q" 3033 3029 SendCmd "camera reset" 3034 3030 set _view(xpan) 0.0 -
branches/1.3/gui/scripts/isomarker.tcl
r4848 r5115 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 3 3 # ---------------------------------------------------------------------- … … 24 24 private variable _canvas "" 25 25 private variable _nvobj ""; # Parent nanovis object. 26 private variable _tf ""; # Transfer function that this marker is 26 private variable _tf ""; # Transfer function that this marker is 27 27 # associated with. 28 28 private variable _activeMotion 0 … … 31 31 private common _activeIcon [Rappture::icon nvlegendmark2] 32 32 33 constructor {c obj tf args} { 33 constructor {c obj tf args} { 34 34 set _canvas $c 35 35 set _nvobj $obj … … 52 52 [itcl::code $this HandleEvent "end" %x %y] 53 53 } 54 destructor { 54 destructor { 55 55 $_canvas delete $this 56 56 } … … 76 76 } 77 77 } 78 public method screenpos { } { 78 public method screenpos { } { 79 79 set x [relval] 80 80 if { $x < 0.0 } { 81 81 set x 0.0 82 82 } elseif { $x > 1.0 } { 83 set x 1.0 83 set x 1.0 84 84 } 85 set low 10 85 set low 10 86 86 set w [winfo width $_canvas] 87 87 set high [expr {$w - 10}] … … 102 102 public method relval { {x "-get"} } { 103 103 if { $x == "-get" } { 104 array set limits [$_nvobj limits $_tf] 104 array set limits [$_nvobj limits $_tf] 105 105 if { $limits(vmax) == $limits(vmin) } { 106 106 if { $limits(vmax) == 0.0 } { … … 113 113 return [expr {($_value-$limits(vmin))/ 114 114 ($limits(vmax) - $limits(vmin))}] 115 } 116 array set limits [$_nvobj limits $_tf] 115 } 116 array set limits [$_nvobj limits $_tf] 117 117 if { $limits(vmax) == $limits(vmin) } { 118 118 set limits(vmin) 0.0 … … 121 121 if { [catch {expr $limits(vmax) - $limits(vmin)} r] != 0 } { 122 122 return 0.0 123 } 123 } 124 124 absval [expr {($x * $r) + $limits(vmin)}] 125 125 } … … 136 136 } 137 137 start { 138 $_canvas raise $_tick 138 $_canvas raise $_tick 139 139 set _activePress 1 140 140 activate yes -
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.