Changeset 5226
- Timestamp:
- Apr 14, 2015, 9:51:55 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4/gui/scripts/vtkvolumeviewer.tcl
r5206 r5226 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} 63 63 64 private method GetDatasetsWithComponent { cname } 65 66 private variable _volcomponents ; # Array of components found 64 private method GetDatasetsWithComponent { cname } 65 66 private variable _volcomponents ; # Array of components found 67 67 private variable _componentsList ; # List of component names 68 68 … … 73 73 private method BuildColormap { name colors } 74 74 private method BuildCutplaneTab {} 75 private method BuildDownloadPopup { widget command } 75 private method BuildDownloadPopup { widget command } 76 76 private method BuildViewTab {} 77 77 private method BuildVolumeTab {} … … 84 84 private method DoResize {} 85 85 private method DoRotate {} 86 private method EnterLegend { x y } 87 private method EventuallyResize { w h } 88 private method EventuallyRequestLegend {} 89 private method EventuallyRotate { q } 90 private method EventuallySetCutplane { axis args } 91 private method GetImage { args } 92 private method GetVtkData { args } 86 private method EnterLegend { x y } 87 private method EventuallyResize { w h } 88 private method EventuallyRequestLegend {} 89 private method EventuallyRotate { q } 90 private method EventuallySetCutplane { axis args } 91 private method GetImage { args } 92 private method GetVtkData { args } 93 93 private method InitSettings { args } 94 private method IsValidObject { dataobj } 94 private method IsValidObject { dataobj } 95 95 private method LeaveLegend {} 96 96 private method MotionLegend { x y } … … 98 98 private method PanCamera {} 99 99 private method Pick {x y} 100 private method QuaternionToView { q } { 100 private method QuaternionToView { q } { 101 101 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 102 102 } … … 109 109 private method Rotate {option x y} 110 110 private method SetLegendTip { x y } 111 private method SetObjectStyle { dataobj comp } 111 private method SetObjectStyle { dataobj comp } 112 112 private method SetOrientation { side } 113 private method Slice {option args} 114 private method ViewToQuaternion {} { 113 private method Slice {option args} 114 private method ViewToQuaternion {} { 115 115 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 116 116 } … … 120 120 private variable _dlist "" ; # list of data objects 121 121 private variable _obj2ovride ; # maps dataobj => style override 122 private variable _datasets ; # contains all the dataobj-component 122 private variable _datasets ; # contains all the dataobj-component 123 123 ; # datasets in the server 124 124 private variable _colormaps ; # contains all the colormaps … … 146 146 private variable _cutplanePending 0 147 147 private variable _legendPending 0 148 private variable _fields 148 private variable _fields 149 149 private variable _curFldName "" 150 150 private variable _curFldLabel "" … … 215 215 -xpan 0 216 216 -ypan 0 217 -zoom 1.0 217 -zoom 1.0 218 218 } 219 219 set _arcball [blt::arcball create 100 100] … … 258 258 itk_component add fieldmenu { 259 259 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 260 -tearoff no 260 -tearoff no 261 261 } { 262 262 usual … … 278 278 279 279 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 280 set _map(cwidth) -1 281 set _map(cheight) -1 280 set _map(cwidth) -1 281 set _map(cheight) -1 282 282 set _map(zoom) 1.0 283 283 set _map(original) "" … … 325 325 -offimage [Rappture::icon volume-off] \ 326 326 -variable [itcl::scope _settings(-volumevisible)] \ 327 -command [itcl::code $this AdjustSetting -volumevisible] 327 -command [itcl::code $this AdjustSetting -volumevisible] 328 328 } 329 329 $itk_component(volume) select … … 337 337 -offimage [Rappture::icon cutbutton] \ 338 338 -variable [itcl::scope _settings(-cutplanesvisible)] \ 339 -command [itcl::code $this AdjustSetting -cutplanesvisible] 339 -command [itcl::code $this AdjustSetting -cutplanesvisible] 340 340 } 341 341 Rappture::Tooltip::for $itk_component(cutplane) \ … … 357 357 set _image(legend) [image create photo] 358 358 itk_component add legend { 359 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 359 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 360 360 } { 361 361 usual … … 364 364 } 365 365 366 # Hack around the Tk panewindow. The problem is that the requested 366 # Hack around the Tk panewindow. The problem is that the requested 367 367 # size of the 3d view isn't set until an image is retrieved from 368 368 # the server. So the panewindow uses the tiny size. … … 370 370 pack forget $itk_component(view) 371 371 blt::table $itk_component(plotarea) \ 372 0,0 $itk_component(view) -fill both -reqwidth $w 372 0,0 $itk_component(view) -fill both -reqwidth $w 373 373 blt::table configure $itk_component(plotarea) c1 -resize none 374 374 … … 455 455 456 456 itcl::body Rappture::VtkVolumeViewer::DoRotate {} { 457 SendCmd "camera orient [ViewToQuaternion]" 457 SendCmd "camera orient [ViewToQuaternion]" 458 458 set _rotatePending 0 459 459 } … … 482 482 if { !$_rotatePending } { 483 483 set _rotatePending 1 484 global rotate_delay 484 global rotate_delay 485 485 $_dispatcher event -after $rotate_delay !rotate 486 486 } … … 589 589 continue 590 590 } 591 if {[info exists _obj2ovride($dataobj-raise)] && 591 if {[info exists _obj2ovride($dataobj-raise)] && 592 592 $_obj2ovride($dataobj-raise)} { 593 593 set dlist [linsert $dlist 0 $dataobj] … … 617 617 } 618 618 return $dlist 619 } 619 } 620 620 -image { 621 621 if {[llength $args] != 2} { … … 850 850 $_dispatcher cancel !legend 851 851 # disconnected -- no more data sitting on server 852 array unset _datasets 853 array unset _colormaps 854 array unset _dataset2style 852 array unset _datasets 853 array unset _colormaps 854 array unset _dataset2style 855 855 856 856 set _resizePending 0 … … 959 959 # Turn on buffering of commands to the server. We don't want to 960 960 # be preempted by a server disconnect/reconnect (which automatically 961 # generates a new call to Rebuild). 961 # generates a new call to Rebuild). 962 962 StartBufferingCommands 963 963 … … 1001 1001 if { ![info exists _datasets($tag)] } { 1002 1002 set bytes [$dataobj vtkdata $comp] 1003 if 0 { 1003 if 0 { 1004 1004 set f [open /tmp/vtkvolume.vtk "w"] 1005 1005 fconfigure $f -translation binary -encoding binary … … 1106 1106 itcl::body Rappture::VtkVolumeViewer::CurrentDatasets {args} { 1107 1107 set flag [lindex $args 0] 1108 switch -- $flag { 1108 switch -- $flag { 1109 1109 "-all" { 1110 1110 if { [llength $args] > 1 } { … … 1125 1125 set dlist [get -visible] 1126 1126 } 1127 } 1127 } 1128 1128 default { 1129 1129 set dlist $args … … 1244 1244 foreach tag [CurrentDatasets -visible] { 1245 1245 SendCmd "dataset getscalar pixel $x $y $tag" 1246 } 1246 } 1247 1247 } 1248 1248 … … 1632 1632 SendCmd "outline color $rgb" 1633 1633 SendCmd "$_cutplaneCmd color $rgb" 1634 $itk_component(legend) itemconfigure labels -fill $color 1635 $itk_component(legend) itemconfigure limits -fill $color 1634 $itk_component(legend) itemconfigure labels -fill $color 1635 $itk_component(legend) itemconfigure limits -fill $color 1636 1636 } 1637 1637 } … … 1670 1670 -font "Arial 9" 1671 1671 1672 label $inner.background_l -text "Background" -font "Arial 9" 1672 label $inner.background_l -text "Background" -font "Arial 9" 1673 1673 itk_component add background { 1674 1674 Rappture::Combobox $inner.background -width 10 -editable no … … 1677 1677 "black" "black" \ 1678 1678 "white" "white" \ 1679 "grey" "grey" 1679 "grey" "grey" 1680 1680 1681 1681 $itk_component(background) value $_settings(-background) … … 1811 1811 -font "Arial 9" 1812 1812 1813 label $inner.mode_l -text "Mode" -font "Arial 9" 1813 label $inner.mode_l -text "Mode" -font "Arial 9" 1814 1814 1815 1815 itk_component add axismode { … … 1820 1820 "closest_triad" "closest" \ 1821 1821 "furthest_triad" "farthest" \ 1822 "outer_edges" "outer" 1822 "outer_edges" "outer" 1823 1823 $itk_component(axismode) value $_settings(-axisflymode) 1824 1824 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode] … … 1892 1892 itcl::body Rappture::VtkVolumeViewer::BuildCutplaneTab {} { 1893 1893 set font [option get $itk_component(hull) font Font] 1894 1894 1895 1895 set inner [$itk_component(main) insert end \ 1896 1896 -title "Cutplane Settings" \ 1897 -icon [Rappture::icon cutbutton]] 1897 -icon [Rappture::icon cutbutton]] 1898 1898 1899 1899 $inner configure -borderwidth 4 … … 2019 2019 2020 2020 # 2021 # camera -- 2021 # camera -- 2022 2022 # 2023 2023 itcl::body Rappture::VtkVolumeViewer::camera {option args} { 2024 switch -- $option { 2024 switch -- $option { 2025 2025 "show" { 2026 2026 puts [array get _view] … … 2070 2070 2071 2071 itcl::body Rappture::VtkVolumeViewer::GetImage { args } { 2072 if { [image width $_image(download)] > 0 && 2072 if { [image width $_image(download)] > 0 && 2073 2073 [image height $_image(download)] > 0 } { 2074 2074 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 2083 2083 -title "[Rappture::filexfer::label downloadWord] as..." 2084 2084 set inner [$popup component inner] 2085 label $inner.summary -text "" -anchor w 2085 label $inner.summary -text "" -anchor w 2086 2086 radiobutton $inner.vtk_button -text "VTK data file" \ 2087 2087 -variable [itcl::scope _downloadPopup(format)] \ 2088 2088 -font "Helvetica 9 " \ 2089 -value vtk 2089 -value vtk 2090 2090 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 2091 2091 radiobutton $inner.image_button -text "Image File" \ 2092 2092 -variable [itcl::scope _downloadPopup(format)] \ 2093 -value image 2093 -value image 2094 2094 Rappture::Tooltip::for $inner.image_button \ 2095 2095 "Save as digital image." … … 2112 2112 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 2113 2113 4,1 $inner.cancel -width .9i -fill y \ 2114 4,0 $inner.ok -padx 2 -width .9i -fill y 2114 4,0 $inner.ok -padx 2 -width .9i -fill y 2115 2115 blt::table configure $inner r3 -height 4 2116 2116 blt::table configure $inner r4 -pady 4 … … 2192 2192 set font "Arial 8" 2193 2193 set lineht [font metrics $font -linespace] 2194 2194 2195 2195 if { [info exists _fields($fname)] } { 2196 2196 foreach { title units } $_fields($fname) break … … 2204 2204 set x [expr $w - 2] 2205 2205 if { [$c find withtag "legend"] == "" } { 2206 set y 2 2206 set y 2 2207 2207 $c create text $x $y \ 2208 2208 -anchor ne \ … … 2279 2279 set font "Arial 8" 2280 2280 set lineht [font metrics $font -linespace] 2281 2281 2282 2282 set imgHeight [image height $_image(legend)] 2283 2283 set coords [$c coords colormap] … … 2302 2302 } 2303 2303 set color [eval format "\#%02x%02x%02x" $pixel] 2304 $_image(swatch) put black -to 0 0 23 23 2305 $_image(swatch) put $color -to 1 1 22 22 2304 $_image(swatch) put black -to 0 0 23 23 2305 $_image(swatch) put $color -to 1 1 22 22 2306 2306 .rappturetooltip configure -icon $_image(swatch) 2307 2307 … … 2314 2314 set value 0.0 2315 2315 } 2316 set tipx [expr $x + 15] 2316 set tipx [expr $x + 15] 2317 2317 set tipy [expr $y - 5] 2318 2318 Rappture::Tooltip::text $c "$title $value" 2319 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2319 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2320 2320 } 2321 2321 … … 2363 2363 # ---------------------------------------------------------------------- 2364 2364 itcl::body Rappture::VtkVolumeViewer::Combo {option} { 2365 set c $itk_component(view) 2365 set c $itk_component(view) 2366 2366 switch -- $option { 2367 2367 post { … … 2376 2376 } 2377 2377 deactivate { 2378 $c itemconfigure title -fill $itk_option(-plotforeground) 2378 $c itemconfigure title -fill $itk_option(-plotforeground) 2379 2379 } 2380 2380 invoke { … … 2388 2388 } 2389 2389 2390 itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } { 2390 itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } { 2391 2391 array set positions { 2392 2392 front "1 0 0 0" … … 2399 2399 foreach name { -qw -qx -qy -qz } value $positions($side) { 2400 2400 set _view($name) $value 2401 } 2401 } 2402 2402 set q [ViewToQuaternion] 2403 2403 $_arcball quaternion $q 2404 SendCmd "camera orient $q" 2404 SendCmd "camera orient $q" 2405 2405 SendCmd "camera reset" 2406 2406 set _view(-xpan) 0 … … 2413 2413 # 2414 2414 # Returns a list of all the datasets (known by the combination of 2415 # their data object and component name) that match the given 2416 # component name. For example, this is used where we want to change 2415 # their data object and component name) that match the given 2416 # component name. For example, this is used where we want to change 2417 2417 # the settings of volumes that have the current component. 2418 2418 # 2419 itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } { 2419 itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } { 2420 2420 if { ![info exists _volcomponents($cname)] } { 2421 2421 return ""
Note: See TracChangeset
for help on using the changeset viewer.