Changeset 5224 for branches/1.3
- Timestamp:
- Apr 14, 2015, 9:34:47 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/vtkvolumeviewer.tcl
r5221 r5224 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: vtkvolumeviewer - Vtk volume viewer … … 57 57 public method get {args} 58 58 public method isconnected {} 59 public method parameters {title args} { 60 # do nothing 59 public method parameters {title args} { 60 # do nothing 61 61 } 62 62 public method scale {args} … … 66 66 protected method Disconnect {} 67 67 protected method DoResize {} 68 protected method DoReseed {}69 68 protected method DoRotate {} 70 69 protected method AdjustSetting {what {value ""}} … … 84 83 private method BuildColormap { name colors } 85 84 private method BuildCutplaneTab {} 86 private method BuildDownloadPopup { widget command } 85 private method BuildDownloadPopup { widget command } 87 86 private method BuildVolumeTab {} 88 87 private method DrawLegend {} 89 88 private method Combo { option } 90 private method EnterLegend { x y } 91 private method EventuallyResize { w h } 92 private method EventuallyReseed { numPoints } 93 private method EventuallyRotate { q } 94 private method EventuallySetCutplane { axis args } 95 private method GetImage { args } 96 private method GetVtkData { args } 97 private method IsValidObject { dataobj } 89 private method EnterLegend { x y } 90 private method EventuallyResize { w h } 91 private method EventuallyRotate { q } 92 private method EventuallySetCutplane { axis args } 93 private method GetImage { args } 94 private method GetVtkData { args } 95 private method IsValidObject { dataobj } 98 96 private method LeaveLegend {} 99 private method MotionLegend { x y } 97 private method MotionLegend { x y } 100 98 private method PanCamera {} 101 99 private method RequestLegend {} … … 103 101 private method ChangeColormap { dataobj comp color } 104 102 private method SetLegendTip { x y } 105 private method SetObjectStyle { dataobj comp } 106 private method Slice {option args} 103 private method SetObjectStyle { dataobj comp } 104 private method Slice {option args} 107 105 108 106 private variable _arcball "" … … 110 108 private variable _obj2datasets 111 109 private variable _obj2ovride ; # maps dataobj => style override 112 private variable _datasets ; # contains all the dataobj-component 110 private variable _datasets ; # contains all the dataobj-component 113 111 ; # datasets in the server 114 112 private variable _colormaps ; # contains all the colormaps … … 127 125 private variable _start 0 128 126 private variable _title "" 129 private variable _seeds130 127 131 128 common _downloadPopup; # download options from popup … … 134 131 private variable _height 0 135 132 private variable _resizePending 0 136 private variable _reseedPending 0137 133 private variable _rotatePending 0 138 134 private variable _cutplanePending 0 139 135 private variable _legendPending 0 140 private variable _fields 136 private variable _fields 141 137 private variable _curFldName "" 142 138 private variable _curFldLabel "" … … 163 159 $_dispatcher register !resize 164 160 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 165 166 # Reseed event167 $_dispatcher register !reseed168 $_dispatcher dispatch $this !reseed "[itcl::code $this DoReseed]; list"169 161 170 162 # Rotate event … … 204 196 qy 0.353553 205 197 qz 0.146447 206 zoom 1.0 198 zoom 1.0 207 199 xpan 0 208 200 ypan 0 … … 248 240 itk_component add fieldmenu { 249 241 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 250 -tearoff no 242 -tearoff no 251 243 } { 252 244 usual … … 268 260 269 261 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 270 set _map(cwidth) -1 271 set _map(cheight) -1 262 set _map(cwidth) -1 263 set _map(cheight) -1 272 264 set _map(zoom) 1.0 273 265 set _map(original) "" … … 315 307 -offimage [Rappture::icon volume-off] \ 316 308 -variable [itcl::scope _settings(volumeVisible)] \ 317 -command [itcl::code $this AdjustSetting volumeVisible] 309 -command [itcl::code $this AdjustSetting volumeVisible] 318 310 } 319 311 $itk_component(volume) select … … 327 319 -offimage [Rappture::icon cutbutton] \ 328 320 -variable [itcl::scope _settings(cutplaneVisible)] \ 329 -command [itcl::code $this AdjustSetting cutplaneVisible] 321 -command [itcl::code $this AdjustSetting cutplaneVisible] 330 322 } 331 323 Rappture::Tooltip::for $itk_component(cutplane) \ 332 324 "Show/Hide cutplanes" 333 325 pack $itk_component(cutplane) -padx 2 -pady 2 334 335 326 336 327 if { [catch { … … 342 333 puts stderr errs=$errs 343 334 } 335 344 336 # Legend 345 346 337 set _image(legend) [image create photo] 347 338 itk_component add legend { 348 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 339 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 349 340 } { 350 341 usual … … 353 344 } 354 345 355 # Hack around the Tk panewindow. The problem is that the requested 346 # Hack around the Tk panewindow. The problem is that the requested 356 347 # size of the 3d view isn't set until an image is retrieved from 357 348 # the server. So the panewindow uses the tiny size. … … 359 350 pack forget $itk_component(view) 360 351 blt::table $itk_component(plotarea) \ 361 0,0 $itk_component(view) -fill both -reqwidth $w 352 0,0 $itk_component(view) -fill both -reqwidth $w 362 353 blt::table configure $itk_component(plotarea) c1 -resize none 363 354 … … 445 436 itcl::body Rappture::VtkVolumeViewer::DoRotate {} { 446 437 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 447 SendCmd "camera orient $q" 438 SendCmd "camera orient $q" 448 439 set _rotatePending 0 449 440 } … … 459 450 } 460 451 461 itcl::body Rappture::VtkVolumeViewer::EventuallyReseed { numPoints } {462 set _numSeeds $numPoints463 if { !$_reseedPending } {464 set _reseedPending 1465 $_dispatcher event -after 600 !reseed466 }467 }468 469 452 set rotate_delay 100 470 453 … … 473 456 if { !$_rotatePending } { 474 457 set _rotatePending 1 475 global rotate_delay 458 global rotate_delay 476 459 $_dispatcher event -after $rotate_delay !rotate 477 460 } … … 577 560 continue 578 561 } 579 if {[info exists _obj2ovride($dataobj-raise)] && 562 if {[info exists _obj2ovride($dataobj-raise)] && 580 563 $_obj2ovride($dataobj-raise)} { 581 564 set dlist [linsert $dlist 0 $dataobj] … … 605 588 } 606 589 return $dlist 607 } 590 } 608 591 -image { 609 592 if {[llength $args] != 2} { … … 801 784 $_dispatcher cancel !rebuild 802 785 $_dispatcher cancel !resize 803 $_dispatcher cancel !reseed804 786 $_dispatcher cancel !rotate 805 787 $_dispatcher cancel !xcutplane … … 808 790 $_dispatcher cancel !legend 809 791 # disconnected -- no more data sitting on server 810 array unset _datasets 811 array unset _data 812 array unset _colormaps 813 array unset _seeds 814 array unset _dataset2style 815 array unset _obj2datasets 792 array unset _datasets 793 array unset _data 794 array unset _colormaps 795 array unset _dataset2style 796 array unset _obj2datasets 816 797 } 817 798 … … 842 823 set time [clock seconds] 843 824 set date [clock format $time] 844 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 825 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 845 826 if { $_start > 0 } { 846 827 set finish [clock clicks -milliseconds] … … 917 898 # Turn on buffering of commands to the server. We don't want to 918 899 # be preempted by a server disconnect/reconnect (which automatically 919 # generates a new call to Rebuild). 900 # generates a new call to Rebuild). 920 901 StartBufferingCommands 921 902 … … 1056 1037 itcl::body Rappture::VtkVolumeViewer::CurrentDatasets {args} { 1057 1038 set flag [lindex $args 0] 1058 switch -- $flag { 1039 switch -- $flag { 1059 1040 "-all" { 1060 1041 if { [llength $args] > 1 } { … … 1075 1056 set dlist [get -visible] 1076 1057 } 1077 } 1058 } 1078 1059 default { 1079 1060 set dlist $args … … 1196 1177 foreach tag [CurrentDatasets -visible] { 1197 1178 SendCmd "dataset getscalar pixel $x $y $tag" 1198 } 1179 } 1199 1180 } 1200 1181 … … 1601 1582 1602 1583 itk_component add field_l { 1603 label $inner.field_l -text "Field" -font "Arial 9" 1584 label $inner.field_l -text "Field" -font "Arial 9" 1604 1585 } { 1605 1586 ignore -font … … 1611 1592 [itcl::code $this AdjustSetting field] 1612 1593 1613 label $inner.palette_l -text "Palette" -font "Arial 9" 1594 label $inner.palette_l -text "Palette" -font "Arial 9" 1614 1595 itk_component add palette { 1615 1596 Rappture::Combobox $inner.palette -width 10 -editable no … … 1676 1657 -font "Arial 9" 1677 1658 1678 label $inner.mode_l -text "Mode" -font "Arial 9" 1659 label $inner.mode_l -text "Mode" -font "Arial 9" 1679 1660 1680 1661 itk_component add axismode { … … 1685 1666 "closest_triad" "closest" \ 1686 1667 "furthest_triad" "farthest" \ 1687 "outer_edges" "outer" 1668 "outer_edges" "outer" 1688 1669 $itk_component(axismode) value "static" 1689 1670 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlyMode] … … 1696 1677 4,0 $inner.gridz -anchor w -cspan 2 \ 1697 1678 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1698 6,0 $inner.mode -fill x -cspan 2 1679 6,0 $inner.mode -fill x -cspan 2 1699 1680 1700 1681 blt::table configure $inner r* c* -resize none … … 1741 1722 1742 1723 set fg [option get $itk_component(hull) font Font] 1743 1724 1744 1725 set inner [$itk_component(main) insert end \ 1745 1726 -title "Cutplane Settings" \ 1746 -icon [Rappture::icon cutbutton]] 1727 -icon [Rappture::icon cutbutton]] 1747 1728 1748 1729 $inner configure -borderwidth 4 … … 1882 1863 1883 1864 # 1884 # camera -- 1865 # camera -- 1885 1866 # 1886 1867 itcl::body Rappture::VtkVolumeViewer::camera {option args} { 1887 switch -- $option { 1868 switch -- $option { 1888 1869 "show" { 1889 1870 puts [array get _view] … … 1933 1914 1934 1915 itcl::body Rappture::VtkVolumeViewer::GetImage { args } { 1935 if { [image width $_image(download)] > 0 && 1916 if { [image width $_image(download)] > 0 && 1936 1917 [image height $_image(download)] > 0 } { 1937 1918 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 1946 1927 -title "[Rappture::filexfer::label downloadWord] as..." 1947 1928 set inner [$popup component inner] 1948 label $inner.summary -text "" -anchor w 1929 label $inner.summary -text "" -anchor w 1949 1930 radiobutton $inner.vtk_button -text "VTK data file" \ 1950 1931 -variable [itcl::scope _downloadPopup(format)] \ 1951 1932 -font "Helvetica 9 " \ 1952 -value vtk 1933 -value vtk 1953 1934 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 1954 1935 radiobutton $inner.image_button -text "Image File" \ 1955 1936 -variable [itcl::scope _downloadPopup(format)] \ 1956 -value image 1937 -value image 1957 1938 Rappture::Tooltip::for $inner.image_button \ 1958 1939 "Save as digital image." … … 1975 1956 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 1976 1957 4,1 $inner.cancel -width .9i -fill y \ 1977 4,0 $inner.ok -padx 2 -width .9i -fill y 1958 4,0 $inner.ok -padx 2 -width .9i -fill y 1978 1959 blt::table configure $inner r3 -height 4 1979 1960 blt::table configure $inner r4 -pady 4 … … 1995 1976 -wireframe 0 1996 1977 -lighting 1 1997 -seeds 11998 -seedcolor white1999 1978 -visible 1 2000 1979 } … … 2055 2034 set font "Arial 8" 2056 2035 set lineht [font metrics $font -linespace] 2057 2036 2058 2037 if { [info exists _fields($fname)] } { 2059 2038 foreach { title units } $_fields($fname) break … … 2067 2046 set x [expr $w - 2] 2068 2047 if { [$c find withtag "legend"] == "" } { 2069 set y 2 2048 set y 2 2070 2049 $c create text $x $y \ 2071 2050 -anchor ne \ … … 2142 2121 set font "Arial 8" 2143 2122 set lineht [font metrics $font -linespace] 2144 2123 2145 2124 set imgHeight [image height $_image(legend)] 2146 2125 set coords [$c coords colormap] … … 2165 2144 } 2166 2145 set color [eval format "\#%02x%02x%02x" $pixel] 2167 $_image(swatch) put black -to 0 0 23 23 2168 $_image(swatch) put $color -to 1 1 22 22 2146 $_image(swatch) put black -to 0 0 23 23 2147 $_image(swatch) put $color -to 1 1 22 22 2169 2148 .rappturetooltip configure -icon $_image(swatch) 2170 2149 … … 2177 2156 set value 0.0 2178 2157 } 2179 set tipx [expr $x + 15] 2158 set tipx [expr $x + 15] 2180 2159 set tipy [expr $y - 5] 2181 2160 Rappture::Tooltip::text $c "$title $value" 2182 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2161 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2183 2162 } 2184 2163 … … 2227 2206 # ---------------------------------------------------------------------- 2228 2207 itcl::body Rappture::VtkVolumeViewer::Combo {option} { 2229 set c $itk_component(view) 2208 set c $itk_component(view) 2230 2209 switch -- $option { 2231 2210 post { … … 2240 2219 } 2241 2220 deactivate { 2242 $c itemconfigure title -fill white 2221 $c itemconfigure title -fill white 2243 2222 } 2244 2223 invoke {
Note: See TracChangeset
for help on using the changeset viewer.