Changeset 5679 for branches/uq/gui/scripts/vtkvolumeviewer.tcl
- Timestamp:
- Jun 9, 2015 1:55:08 PM (9 years ago)
- Location:
- branches/uq
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uq
- Property svn:mergeinfo changed
-
branches/uq/gui/scripts/vtkvolumeviewer.tcl
r5121 r5679 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 # ---------------------------------------------------------------------- 4 # COMPONENT: VtkVolumeViewer - Vtk volume viewer 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 # ---------------------------------------------------------------------- 3 # COMPONENT: vtkvolumeviewer - Vtk volume viewer 5 4 # 6 5 # It connects to the Vtk server running on a rendering farm, … … 8 7 # ====================================================================== 9 8 # AUTHOR: Michael McLennan, Purdue University 10 # Copyright (c) 2004-201 2HUBzero Foundation, LLC9 # Copyright (c) 2004-2014 HUBzero Foundation, LLC 11 10 # 12 11 # See the file "license.terms" for information on usage and … … 58 57 public method get {args} 59 58 public method isconnected {} 60 public method parameters {title args} { 61 # do nothing 59 public method parameters {title args} { 60 # do nothing 62 61 } 63 62 public method scale {args} 64 63 65 protected method Connect {} 66 protected method CurrentDatasets {args} 67 protected method Disconnect {} 68 protected method DoResize {} 69 protected method DoReseed {} 70 protected method DoRotate {} 71 protected method AdjustSetting {what {value ""}} 72 protected method InitSettings { args } 73 protected method Pan {option x y} 74 protected method Pick {x y} 75 protected method Rebuild {} 76 protected method ReceiveDataset { args } 77 protected method ReceiveImage { args } 78 protected method ReceiveLegend { colormap title vmin vmax size } 79 protected method Rotate {option x y} 80 protected method Zoom {option} 64 private method GetDatasetsWithComponent { cname } 65 66 private variable _volcomponents ; # Array of components found 67 private variable _componentsList ; # List of component names 81 68 82 69 # The following methods are only used by this class. 70 private method AdjustSetting {what {value ""}} 83 71 private method BuildAxisTab {} 84 72 private method BuildCameraTab {} 85 73 private method BuildColormap { name colors } 86 74 private method BuildCutplaneTab {} 87 private method BuildDownloadPopup { widget command } 75 private method BuildDownloadPopup { widget command } 76 private method BuildViewTab {} 88 77 private method BuildVolumeTab {} 78 private method ChangeColormap { dataobj comp color } 79 private method Combo { option } 80 private method Connect {} 81 private method CurrentDatasets {args} 82 private method Disconnect {} 83 private method DoResize {} 84 private method DoRotate {} 89 85 private method DrawLegend {} 90 private method Combo { option}91 private method E nterLegend { x y }92 private method EventuallyRe size { w h }93 private method EventuallyR eseed { numPoints }94 private method Eventually Rotate { q }95 private method EventuallySetCutplane { axis args }96 private method Get Image { args }97 private method GetVtkData { args }98 private method IsValidObject { dataobj } 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 private method InitSettings { args } 94 private method IsValidObject { dataobj } 99 95 private method LeaveLegend {} 100 private method MotionLegend { x y } 96 private method MotionLegend { x y } 97 private method Pan {option x y} 101 98 private method PanCamera {} 99 private method Pick {x y} 100 private method QuaternionToView { q } { 101 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 102 } 103 private method Rebuild {} 104 private method ReceiveDataset { args } 105 private method ReceiveImage { args } 106 private method ReceiveLegend { colormap title vmin vmax size } 102 107 private method RequestLegend {} 108 private method Rotate {option x y} 103 109 private method SetColormap { dataobj comp } 104 private method ChangeColormap { dataobj comp color }105 110 private method SetLegendTip { x y } 106 private method SetObjectStyle { dataobj comp } 107 private method Slice {option args} 111 private method SetObjectStyle { dataobj comp } 112 private method SetOrientation { side } 113 private method Slice {option args} 114 private method ViewToQuaternion {} { 115 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 116 } 117 private method Zoom {option} 108 118 109 119 private variable _arcball "" 110 private variable _dlist "" ; # list of data objects 111 private variable _obj2datasets 112 private variable _obj2ovride ; # maps dataobj => style override 113 private variable _datasets ; # contains all the dataobj-component 114 ; # datasets in the server 115 private variable _colormaps ; # contains all the colormaps 116 ; # in the server. 117 private variable _dataset2style ;# maps dataobj-component to transfunc 118 119 private variable _click ; # info used for rotate operations 120 private variable _limits ; # autoscale min/max for all axes 121 private variable _view ; # view params for 3D view 120 private variable _dlist ""; # list of data objects 121 private variable _obj2ovride; # maps dataobj => style override 122 private variable _datasets; # contains all the dataobj-component 123 # datasets in the server 124 private variable _colormaps; # contains all the colormaps 125 # in the server. 126 private variable _dataset2style; # maps dataobj-component to transfunc 127 128 private variable _click; # info used for rotate operations 129 private variable _limits; # autoscale min/max for all axes 130 private variable _view; # view params for 3D view 122 131 private variable _settings 123 132 private variable _style; # Array of current component styles. 124 133 private variable _initialStyle; # Array of initial component styles. 125 private variable _reset 1; # indicates if camera needs to be reset 126 # to starting position. 127 128 private variable _first "" ; # This is the topmost dataset. 134 private variable _reset 1; # Connection to server has been reset. 135 136 private variable _first ""; # This is the topmost dataset. 129 137 private variable _start 0 130 138 private variable _title "" 131 private variable _seeds 132 133 common _downloadPopup; # download options from popup 134 private common _hardcopy 139 135 140 private variable _width 0 136 141 private variable _height 0 137 142 private variable _resizePending 0 138 private variable _reseedPending 0139 143 private variable _rotatePending 0 140 144 private variable _cutplanePending 0 141 145 private variable _legendPending 0 142 private variable _fields 146 private variable _fields 143 147 private variable _curFldName "" 144 148 private variable _curFldLabel "" 145 private variable _colorMode "vmag";# Mode of colormap (vmag or scalar) 149 private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar) 150 private variable _cutplaneCmd "imgcutplane" 151 private variable _allowMultiComponent 0 152 153 private common _downloadPopup; # download options from popup 154 private common _hardcopy 146 155 } 147 156 … … 155 164 # ---------------------------------------------------------------------- 156 165 itcl::body Rappture::VtkVolumeViewer::constructor {hostlist args} { 157 package require vtk158 166 set _serverType "vtkvis" 167 168 EnableWaitDialog 900 159 169 160 170 # Rebuild event … … 166 176 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 167 177 168 # Reseed event169 $_dispatcher register !reseed170 $_dispatcher dispatch $this !reseed "[itcl::code $this DoReseed]; list"171 172 178 # Rotate event 173 179 $_dispatcher register !rotate … … 181 187 $_dispatcher register !xcutplane 182 188 $_dispatcher dispatch $this !xcutplane \ 183 "[itcl::code $this AdjustSetting cutplane-xposition]; list"189 "[itcl::code $this AdjustSetting -xcutplaneposition]; list" 184 190 185 191 # Y-Cutplane event 186 192 $_dispatcher register !ycutplane 187 193 $_dispatcher dispatch $this !ycutplane \ 188 "[itcl::code $this AdjustSetting cutplane-yposition]; list"194 "[itcl::code $this AdjustSetting -ycutplaneposition]; list" 189 195 190 196 # Z-Cutplane event 191 197 $_dispatcher register !zcutplane 192 198 $_dispatcher dispatch $this !zcutplane \ 193 "[itcl::code $this AdjustSetting cutplane-zposition]; list"199 "[itcl::code $this AdjustSetting -zcutplaneposition]; list" 194 200 195 201 # … … 202 208 # Initialize the view to some default parameters. 203 209 array set _view { 204 qw 0.853553205 qx -0.353553206 qy0.353553207 qz 0.146447208 zoom 1.0209 xpan 0210 ypan 0211 ortho0210 -ortho 0 211 -qw 0.853553 212 -qx -0.353553 213 -qy 0.353553 214 -qz 0.146447 215 -xpan 0 216 -ypan 0 217 -zoom 1.0 212 218 } 213 219 set _arcball [blt::arcball create 100 100] 214 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 215 $_arcball quaternion $q 220 $_arcball quaternion [ViewToQuaternion] 216 221 217 222 array set _settings { 218 axis-xgrid 0 219 axis-ygrid 0 220 axis-zgrid 0 221 axesVisible 1 222 axisLabels 1 223 cutplaneEdges 0 224 cutplane-xvisible 1 225 cutplane-yvisible 1 226 cutplane-zvisible 1 227 cutplane-xposition 50 228 cutplane-yposition 50 229 cutplane-zposition 50 230 cutplaneVisible 0 231 cutplaneLighting 1 232 cutplaneWireframe 0 233 cutplane-opacity 100 234 volumeLighting 1 235 volume-material 80 236 volume-opacity 40 237 volume-quality 50 238 volumeVisible 1 239 legendVisible 1 223 -axesvisible 1 224 -axisflymode static 225 -axislabels 1 226 -axisminorticks 1 227 -background black 228 -color BCGYR 229 -cutplanelighting 1 230 -cutplaneopacity 100 231 -cutplanesvisible 0 232 -legendvisible 1 233 -volumelighting 1 234 -volumematerial 80 235 -volumeopacity 50 236 -volumeoutline 0 237 -volumequality 80 238 -volumevisible 1 239 -xcutplaneposition 50 240 -xcutplanevisible 1 241 -xgrid 0 242 -ycutplaneposition 50 243 -ycutplanevisible 1 244 -ygrid 0 245 -zcutplaneposition 50 246 -zcutplanevisible 1 247 -zgrid 0 240 248 } 241 249 … … 250 258 itk_component add fieldmenu { 251 259 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 252 -tearoff no 260 -tearoff no 253 261 } { 254 262 usual … … 270 278 271 279 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 272 set _map(cwidth) -1 273 set _map(cheight) -1 280 set _map(cwidth) -1 281 set _map(cheight) -1 274 282 set _map(zoom) 1.0 275 283 set _map(original) "" … … 316 324 -onimage [Rappture::icon volume-on] \ 317 325 -offimage [Rappture::icon volume-off] \ 318 -variable [itcl::scope _settings( volumeVisible)] \319 -command [itcl::code $this AdjustSetting volumeVisible]326 -variable [itcl::scope _settings(-volumevisible)] \ 327 -command [itcl::code $this AdjustSetting -volumevisible] 320 328 } 321 329 $itk_component(volume) select … … 328 336 -onimage [Rappture::icon cutbutton] \ 329 337 -offimage [Rappture::icon cutbutton] \ 330 -variable [itcl::scope _settings( cutplaneVisible)] \331 -command [itcl::code $this AdjustSetting cutplaneVisible]338 -variable [itcl::scope _settings(-cutplanesvisible)] \ 339 -command [itcl::code $this AdjustSetting -cutplanesvisible] 332 340 } 333 341 Rappture::Tooltip::for $itk_component(cutplane) \ … … 335 343 pack $itk_component(cutplane) -padx 2 -pady 2 336 344 337 338 345 if { [catch { 346 BuildViewTab 339 347 BuildVolumeTab 340 348 BuildCutplaneTab … … 344 352 puts stderr errs=$errs 345 353 } 354 346 355 # Legend 347 348 356 set _image(legend) [image create photo] 349 357 itk_component add legend { 350 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 358 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 351 359 } { 352 360 usual … … 355 363 } 356 364 357 # Hack around the Tk panewindow. The problem is that the requested 365 # Hack around the Tk panewindow. The problem is that the requested 358 366 # size of the 3d view isn't set until an image is retrieved from 359 367 # the server. So the panewindow uses the tiny size. … … 361 369 pack forget $itk_component(view) 362 370 blt::table $itk_component(plotarea) \ 363 0,0 $itk_component(view) -fill both -reqwidth $w 371 0,0 $itk_component(view) -fill both -reqwidth $w 364 372 blt::table configure $itk_component(plotarea) c1 -resize none 365 373 … … 371 379 bind $itk_component(view) <ButtonRelease-1> \ 372 380 [itcl::code $this Rotate release %x %y] 373 bind $itk_component(view) <Configure> \ 374 [itcl::code $this EventuallyResize %w %h] 375 376 if 0 { 377 bind $itk_component(view) <Configure> \ 378 [itcl::code $this EventuallyResize %w %h] 379 } 381 380 382 # Bindings for panning via mouse 381 383 bind $itk_component(view) <ButtonPress-2> \ … … 447 449 SendCmd "screen size $_width $_height" 448 450 449 set _legendPending 1451 EventuallyRequestLegend 450 452 set _resizePending 0 451 453 } 452 454 453 455 itcl::body Rappture::VtkVolumeViewer::DoRotate {} { 454 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 455 SendCmd "camera orient $q" 456 SendCmd "camera orient [ViewToQuaternion]" 456 457 set _rotatePending 0 457 458 } … … 467 468 } 468 469 469 itcl::body Rappture::VtkVolumeViewer::EventuallyReseed { numPoints } { 470 set _numSeeds $numPoints 471 if { !$_reseedPending } { 472 set _reseedPending 1 473 $_dispatcher event -after 600 !reseed 470 itcl::body Rappture::VtkVolumeViewer::EventuallyRequestLegend {} { 471 if { !$_legendPending } { 472 set _legendPending 1 473 $_dispatcher event -idle !legend 474 474 } 475 475 } … … 478 478 479 479 itcl::body Rappture::VtkVolumeViewer::EventuallyRotate { q } { 480 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break480 QuaternionToView $q 481 481 if { !$_rotatePending } { 482 482 set _rotatePending 1 483 global rotate_delay 483 global rotate_delay 484 484 $_dispatcher event -after $rotate_delay !rotate 485 485 } … … 501 501 # ---------------------------------------------------------------------- 502 502 itcl::body Rappture::VtkVolumeViewer::add {dataobj {settings ""}} { 503 if { ![IsValidObject $dataobj] } { 504 return; # Ignore invalid objects. 505 } 503 506 array set params { 504 507 -color auto … … 585 588 continue 586 589 } 587 if {[info exists _obj2ovride($dataobj-raise)] && 590 if {[info exists _obj2ovride($dataobj-raise)] && 588 591 $_obj2ovride($dataobj-raise)} { 589 592 set dlist [linsert $dlist 0 $dataobj] … … 613 616 } 614 617 return $dlist 615 } 618 } 616 619 -image { 617 620 if {[llength $args] != 2} { … … 643 646 # ---------------------------------------------------------------------- 644 647 itcl::body Rappture::VtkVolumeViewer::scale {args} { 648 array unset _limits 649 array unset _volcomponents 650 set _componentsList "" 651 645 652 foreach dataobj $args { 653 if { ![$dataobj isvalid] } { 654 continue; # Object doesn't contain valid data. 655 } 656 # Determine limits for each axis. 646 657 foreach axis { x y z } { 647 658 set lim [$dataobj limits $axis] … … 660 671 set _limits($axis) [list $amin $amax] 661 672 } 673 # Determine limits for each field. 662 674 foreach { fname lim } [$dataobj fieldlimits] { 663 675 if { ![info exists _limits($fname)] } { … … 674 686 } 675 687 set _limits($fname) [list $fmin $fmax] 688 } 689 # Get limits for each component. 690 foreach cname [$dataobj components] { 691 if { ![info exists _volcomponents($cname)] } { 692 lappend _componentsList $cname 693 } 694 lappend _volcomponents($cname) $dataobj-$cname 695 array unset limits 696 array set limits [$dataobj valueLimits $cname] 697 if { ![info exists _limits($cname)] } { 698 set _limits($cname) $limits(v) 699 continue 700 } 701 foreach {min max} $limits(v) break 702 foreach {vmin vmax} $_limits($cname) break 703 if { $vmin > $min } { 704 set vmin $min 705 } 706 if { $vmax < $max } { 707 set vmax $max 708 } 709 set _limits($cname) [list $vmin $vmax] 676 710 } 677 711 } … … 746 780 return 0 747 781 } 782 set _reset 1 748 783 set result [VisViewer::Connect $_hosts] 749 784 if { $result } { 750 785 if { $_reportClientInfo } { 751 786 # Tell the server the viewer, hub, user and session. 752 # Do this immediately on connect before buff ing any commands787 # Do this immediately on connect before buffering any commands 753 788 global env 754 789 … … 794 829 itcl::body Rappture::VtkVolumeViewer::disconnect {} { 795 830 Disconnect 796 set _reset 1797 831 } 798 832 … … 808 842 $_dispatcher cancel !rebuild 809 843 $_dispatcher cancel !resize 810 $_dispatcher cancel !reseed811 844 $_dispatcher cancel !rotate 812 845 $_dispatcher cancel !xcutplane … … 815 848 $_dispatcher cancel !legend 816 849 # disconnected -- no more data sitting on server 817 set _outbuf "" 818 array unset _datasets 819 array unset _data 820 array unset _colormaps 821 array unset _seeds 822 array unset _dataset2style 823 array unset _obj2datasets 850 array unset _datasets 851 array unset _colormaps 852 array unset _dataset2style 853 854 set _resizePending 0 855 set _rotatePending 0 856 set _cutplanePending 0 857 set _legendPending 0 824 858 } 825 859 … … 842 876 if { $info(-type) == "image" } { 843 877 if 0 { 844 set f [open "last.ppm" "w"] 845 puts $f $bytes 878 set f [open "last.ppm" "w"] 879 fconfigure $f -encoding binary 880 puts -nonewline $f $bytes 846 881 close $f 847 882 } 848 883 $_image(plot) configure -data $bytes 849 set time [clock seconds] 850 set date [clock format $time] 851 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 884 #puts stderr "[clock format [clock seconds]]: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 852 885 if { $_start > 0 } { 853 886 set finish [clock clicks -milliseconds] … … 858 891 set tag $this-print-$info(-token) 859 892 set _hardcopy($tag) $bytes 860 }861 if { $_legendPending } {862 RequestLegend863 893 } 864 894 } … … 917 947 set h [winfo height $itk_component(view)] 918 948 if { $w < 2 || $h < 2 } { 949 update 919 950 $_dispatcher event -idle !rebuild 920 951 return … … 923 954 # Turn on buffering of commands to the server. We don't want to 924 955 # be preempted by a server disconnect/reconnect (which automatically 925 # generates a new call to Rebuild). 956 # generates a new call to Rebuild). 926 957 StartBufferingCommands 927 958 928 set _legendPending 1 929 930 if { $_reset } { 959 if { $_width != $w || $_height != $h || $_reset } { 931 960 set _width $w 932 961 set _height $h 933 962 $_arcball resize $w $h 934 963 DoResize 964 } 965 if { $_reset } { 935 966 # 936 967 # Reset the camera and other view parameters 937 968 # 938 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 939 $_arcball quaternion $q 940 if {$_view(ortho)} { 969 $_arcball quaternion [ViewToQuaternion] 970 if {$_view(-ortho)} { 941 971 SendCmd "camera mode ortho" 942 972 } else { … … 944 974 } 945 975 DoRotate 946 InitSettings axis-xgrid axis-ygrid axis-zgrid axisFlyMode \947 axesVisible axisLabels948 976 PanCamera 977 set _first "" 978 InitSettings -background \ 979 -xgrid -ygrid -zgrid -axisflymode \ 980 -axesvisible -axislabels -axisminorticks 981 StopBufferingCommands 982 SendCmd "imgflush" 983 StartBufferingCommands 949 984 } 950 985 set _first "" 951 986 952 SendCmd "imgflush" 953 set _first "" 954 987 # No volumes are active (i.e. in the working set of displayed volumes). 988 # A volume is always invisible if it's not in the working set. A 989 # volume in the working set may be visible/invisible depending upon the 990 # global visibility value. 955 991 SendCmd "dataset visible 0" 956 992 foreach dataobj [get -objects] { … … 958 994 set _first $dataobj 959 995 } 960 set _obj2datasets($dataobj) ""961 996 foreach comp [$dataobj components] { 962 997 set tag $dataobj-$comp 963 998 if { ![info exists _datasets($tag)] } { 964 999 set bytes [$dataobj vtkdata $comp] 1000 if 0 { 1001 set f [open /tmp/vtkvolume.vtk "w"] 1002 fconfigure $f -translation binary -encoding binary 1003 puts -nonewline $f $bytes 1004 close $f 1005 } 965 1006 set length [string length $bytes] 966 1007 if { $_reportClientInfo } { … … 974 1015 lappend info "dataset_size" $length 975 1016 lappend info "dataset_tag" $tag 976 SendCmd [list "clientinfo" $info]977 } 978 append _outbuf "dataset add $tag data follows $length\n"979 append _outbuf$bytes1017 SendCmd "clientinfo [list $info]" 1018 } 1019 SendCmd "dataset add $tag data follows $length" 1020 SendData $bytes 980 1021 set _datasets($tag) 1 981 1022 SetObjectStyle $dataobj $comp 982 1023 } 983 lappend _obj2datasets($dataobj) $tag984 1024 if { [info exists _obj2ovride($dataobj-raise)] } { 985 SendCmd " datasetvisible 1 $tag"1025 SendCmd "volume visible 1 $tag" 986 1026 } 987 1027 break … … 997 1037 set label [$_first hints ${axis}label] 998 1038 if { $label != "" } { 999 SendCmd "axis name $axis $label"1039 SendCmd [list axis name $axis $label] 1000 1040 } 1001 1041 set units [$_first hints ${axis}units] 1002 1042 if { $units != "" } { 1003 SendCmd "axis units $axis $units"1004 } 1005 } 1006 1007 1008 1043 SendCmd [list axis units $axis $units] 1044 } 1045 } 1046 $itk_component(field) choices delete 0 end 1047 $itk_component(fieldmenu) delete 0 end 1048 array unset _fields 1009 1049 set _curFldName "" 1010 1050 foreach cname [$_first components] { … … 1016 1056 [$_first fieldinfo $fname] break 1017 1057 # Only scalar fields are valid 1018 if {$ components == 1} {1058 if {$_allowMultiComponent || $components == 1} { 1019 1059 $itk_component(field) choices insert end "$fname" "$label" 1020 1060 $itk_component(fieldmenu) add radiobutton -label "$label" \ … … 1036 1076 } 1037 1077 1038 InitSettings volume-palette volume-material volume-quality volumeVisible \ 1039 cutplaneVisible \ 1040 cutplane-xposition cutplane-yposition cutplane-zposition \ 1041 cutplane-xvisible cutplane-yvisible cutplane-zvisible 1078 InitSettings -color \ 1079 -volumevisible \ 1080 -volumematerial \ 1081 -volumelighting -volumeopacity -volumequality -volumeoutline \ 1082 -cutplanesvisible \ 1083 -xcutplaneposition -ycutplaneposition -zcutplaneposition \ 1084 -xcutplanevisible -ycutplanevisible -zcutplanevisible 1042 1085 1043 1086 if { $_reset } { 1044 InitSettings volumeLighting 1045 Zoom reset 1087 SendCmd "camera reset" 1088 SendCmd "camera zoom $_view(-zoom)" 1089 RequestLegend 1046 1090 set _reset 0 1047 1091 } … … 1062 1106 itcl::body Rappture::VtkVolumeViewer::CurrentDatasets {args} { 1063 1107 set flag [lindex $args 0] 1064 switch -- $flag { 1108 switch -- $flag { 1065 1109 "-all" { 1066 1110 if { [llength $args] > 1 } { … … 1081 1125 set dlist [get -visible] 1082 1126 } 1083 } 1127 } 1084 1128 default { 1085 1129 set dlist $args … … 1109 1153 switch -- $option { 1110 1154 "in" { 1111 set _view( zoom) [expr {$_view(zoom)*1.25}]1112 SendCmd "camera zoom $_view( zoom)"1155 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1156 SendCmd "camera zoom $_view(-zoom)" 1113 1157 } 1114 1158 "out" { 1115 set _view( zoom) [expr {$_view(zoom)*0.8}]1116 SendCmd "camera zoom $_view( zoom)"1159 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1160 SendCmd "camera zoom $_view(-zoom)" 1117 1161 } 1118 1162 "reset" { 1119 1163 array set _view { 1120 qw 0.8535531121 qx -0.3535531122 qy 0.3535531123 qz 0.1464471124 zoom 1.01125 xpan01126 ypan01164 -qw 0.853553 1165 -qx -0.353553 1166 -qy 0.353553 1167 -qz 0.146447 1168 -xpan 0 1169 -ypan 0 1170 -zoom 1.0 1127 1171 } 1128 1172 if { $_first != "" } { … … 1132 1176 } 1133 1177 } 1134 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1135 $_arcball quaternion $q 1178 $_arcball quaternion [ViewToQuaternion] 1136 1179 DoRotate 1137 1180 SendCmd "camera reset" … … 1141 1184 1142 1185 itcl::body Rappture::VtkVolumeViewer::PanCamera {} { 1143 set x $_view( xpan)1144 set y $_view( ypan)1186 set x $_view(-xpan) 1187 set y $_view(-ypan) 1145 1188 SendCmd "camera pan $x $y" 1146 1189 } 1147 1148 1190 1149 1191 # ---------------------------------------------------------------------- … … 1202 1244 foreach tag [CurrentDatasets -visible] { 1203 1245 SendCmd "dataset getscalar pixel $x $y $tag" 1204 } 1246 } 1205 1247 } 1206 1248 … … 1220 1262 set x [expr $x / double($w)] 1221 1263 set y [expr $y / double($h)] 1222 set _view( xpan) [expr $_view(xpan) + $x]1223 set _view( ypan) [expr $_view(ypan) + $y]1264 set _view(-xpan) [expr $_view(-xpan) + $x] 1265 set _view(-ypan) [expr $_view(-ypan) + $y] 1224 1266 PanCamera 1225 1267 return … … 1243 1285 set _click(x) $x 1244 1286 set _click(y) $y 1245 set _view( xpan) [expr $_view(xpan) - $dx]1246 set _view( ypan) [expr $_view(ypan) - $dy]1287 set _view(-xpan) [expr $_view(-xpan) - $dx] 1288 set _view(-ypan) [expr $_view(-ypan) - $dy] 1247 1289 PanCamera 1248 1290 } … … 1266 1308 itcl::body Rappture::VtkVolumeViewer::InitSettings { args } { 1267 1309 foreach spec $args { 1268 if { [info exists _settings($_first -$spec)] } {1310 if { [info exists _settings($_first${spec})] } { 1269 1311 # Reset global setting with dataobj specific setting 1270 set _settings($spec) $_settings($_first -$spec)1312 set _settings($spec) $_settings($_first${spec}) 1271 1313 } 1272 1314 AdjustSetting $spec … … 1286 1328 } 1287 1329 switch -- $what { 1288 "volumeVisible" { 1289 set bool $_settings(volumeVisible) 1290 foreach dataset [CurrentDatasets -visible] { 1291 SendCmd "volume visible $bool $dataset" 1330 "-background" { 1331 set bgcolor [$itk_component(background) value] 1332 set _settings($what) $bgcolor 1333 array set fgcolors { 1334 "black" "white" 1335 "white" "black" 1336 "grey" "black" 1337 } 1338 configure -plotbackground $bgcolor \ 1339 -plotforeground $fgcolors($bgcolor) 1340 $itk_component(view) delete "legend" 1341 DrawLegend 1342 } 1343 "-volumeoutline" { 1344 set bool $_settings($what) 1345 SendCmd "outline visible 0" 1346 foreach tag [CurrentDatasets -visible] { 1347 SendCmd "outline visible $bool $tag" 1348 } 1349 } 1350 "-legendvisible" { 1351 DrawLegend 1352 } 1353 "-volumevisible" { 1354 set bool $_settings($what) 1355 foreach tag [CurrentDatasets -visible] { 1356 SendCmd "volume visible $bool $tag" 1292 1357 } 1293 1358 if { $bool } { … … 1299 1364 } 1300 1365 } 1301 " volume-material" {1302 set val $_settings( volume-material)1366 "-volumematerial" { 1367 set val $_settings($what) 1303 1368 set diffuse [expr {0.01*$val}] 1304 1369 set specular [expr {0.01*$val}] 1305 1370 #set power [expr {sqrt(160*$val+1.0)}] 1306 1371 set power [expr {$val+1.0}] 1307 foreach dataset[CurrentDatasets -visible] {1308 SendCmd "volume shading diffuse $diffuse $ dataset"1309 SendCmd "volume shading specular $specular $power $ dataset"1310 } 1311 } 1312 " volumeLighting" {1313 set bool $_settings( volumeLighting)1314 foreach dataset[CurrentDatasets -visible] {1315 SendCmd "volume lighting $bool $ dataset"1316 } 1317 } 1318 " volume-quality" {1319 set val $_settings( volume-quality)1372 foreach tag [CurrentDatasets -visible] { 1373 SendCmd "volume shading diffuse $diffuse $tag" 1374 SendCmd "volume shading specular $specular $power $tag" 1375 } 1376 } 1377 "-volumelighting" { 1378 set bool $_settings($what) 1379 foreach tag [CurrentDatasets -visible] { 1380 SendCmd "volume lighting $bool $tag" 1381 } 1382 } 1383 "-volumeopacity" { 1384 set val $_settings($what) 1320 1385 set val [expr {0.01*$val}] 1321 foreach dataset [CurrentDatasets -visible] { 1322 SendCmd "volume quality $val $dataset" 1323 } 1324 } 1325 "axesVisible" { 1326 set bool $_settings(axesVisible) 1386 foreach tag [CurrentDatasets -visible] { 1387 SendCmd "volume opacity $val $tag" 1388 } 1389 } 1390 "-volumequality" { 1391 set val $_settings($what) 1392 set val [expr {0.01*$val}] 1393 foreach tag [CurrentDatasets -visible] { 1394 SendCmd "volume quality $val $tag" 1395 } 1396 } 1397 "-axesvisible" { 1398 set bool $_settings($what) 1327 1399 SendCmd "axis visible all $bool" 1328 1400 } 1329 " axisLabels" {1330 set bool $_settings( axisLabels)1401 "-axislabels" { 1402 set bool $_settings($what) 1331 1403 SendCmd "axis labels all $bool" 1332 1404 } 1333 "axis-xgrid" - "axis-ygrid" - "axis-zgrid" { 1334 set axis [string range $what 5 5] 1405 "-axisminorticks" { 1406 set bool $_settings($what) 1407 SendCmd "axis minticks all $bool" 1408 } 1409 "-xgrid" - "-ygrid" - "-zgrid" { 1410 set axis [string range $what 1 1] 1335 1411 set bool $_settings($what) 1336 1412 SendCmd "axis grid $axis $bool" 1337 1413 } 1338 " axisFlyMode" {1414 "-axisflymode" { 1339 1415 set mode [$itk_component(axismode) value] 1340 1416 set mode [$itk_component(axismode) translate $mode] … … 1342 1418 SendCmd "axis flymode $mode" 1343 1419 } 1344 " cutplaneEdges" {1420 "-cutplanesvisible" { 1345 1421 set bool $_settings($what) 1346 1422 foreach dataset [CurrentDatasets -visible] { 1347 SendCmd " cutplane edges$bool $dataset"1348 } 1349 } 1350 " cutplaneVisible" {1423 SendCmd "$_cutplaneCmd visible $bool $dataset" 1424 } 1425 } 1426 "-cutplanelighting" { 1351 1427 set bool $_settings($what) 1352 1428 foreach dataset [CurrentDatasets -visible] { 1353 SendCmd "cutplane visible $bool $dataset" 1354 } 1355 } 1356 "cutplaneWireframe" { 1357 set bool $_settings($what) 1358 foreach dataset [CurrentDatasets -visible] { 1359 SendCmd "cutplane wireframe $bool $dataset" 1360 } 1361 } 1362 "cutplaneLighting" { 1363 set bool $_settings($what) 1364 foreach dataset [CurrentDatasets -visible] { 1365 SendCmd "cutplane lighting $bool $dataset" 1366 } 1367 } 1368 "cutplane-opacity" { 1429 if {$_cutplaneCmd != "imgcutplane"} { 1430 SendCmd "$_cutplaneCmd lighting $bool $dataset" 1431 } else { 1432 if {$bool} { 1433 set ambient 0.0 1434 set diffuse 1.0 1435 } else { 1436 set ambient 1.0 1437 set diffuse 0.0 1438 } 1439 SendCmd "imgcutplane material $ambient $diffuse $dataset" 1440 } 1441 } 1442 } 1443 "-cutplaneopacity" { 1369 1444 set val $_settings($what) 1370 1445 set sval [expr { 0.01 * double($val) }] 1371 1446 foreach dataset [CurrentDatasets -visible] { 1372 SendCmd " cutplaneopacity $sval $dataset"1373 } 1374 } 1375 " cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" {1376 set axis [string range $what 9 9]1447 SendCmd "$_cutplaneCmd opacity $sval $dataset" 1448 } 1449 } 1450 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1451 set axis [string range $what 1 1] 1377 1452 set bool $_settings($what) 1378 1453 if { $bool } { … … 1384 1459 } 1385 1460 foreach dataset [CurrentDatasets -visible] { 1386 SendCmd " cutplaneaxis $axis $bool $dataset"1387 } 1388 } 1389 " cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" {1390 set axis [string range $what 9 9]1461 SendCmd "$_cutplaneCmd axis $axis $bool $dataset" 1462 } 1463 } 1464 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" { 1465 set axis [string range $what 1 1] 1391 1466 set pos [expr $_settings($what) * 0.01] 1392 1467 foreach dataset [CurrentDatasets -visible] { 1393 SendCmd " cutplaneslice ${axis} ${pos} $dataset"1468 SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset" 1394 1469 } 1395 1470 set _cutplanePending 0 1396 1471 } 1397 " volume-palette" {1398 set palette [$itk_component(palette) value]1399 set _settings( volume-palette) $palette1472 "-color" { 1473 set color [$itk_component(colormap) value] 1474 set _settings($what) $color 1400 1475 foreach dataset [CurrentDatasets -visible $_first] { 1401 1476 foreach {dataobj comp} [split $dataset -] break 1402 ChangeColormap $dataobj $comp $palette 1403 } 1404 set _legendPending 1 1405 } 1406 "volume-palette" { 1407 set palette [$itk_component(palette) value] 1408 set _settings(volume-palette) $palette 1409 foreach dataset [CurrentDatasets -visible $_first] { 1410 foreach {dataobj comp} [split $dataset -] break 1411 ChangeColormap $dataobj $comp $palette 1412 } 1413 set _legendPending 1 1414 } 1415 "field" { 1477 ChangeColormap $dataobj $comp $color 1478 } 1479 EventuallyRequestLegend 1480 } 1481 "-field" { 1416 1482 set label [$itk_component(field) value] 1417 1483 set fname [$itk_component(field) translate $label] 1418 set _settings( field) $fname1484 set _settings($what) $fname 1419 1485 if { [info exists _fields($fname)] } { 1420 1486 foreach { label units components } $_fields($fname) break 1421 if { $components > 1 } {1487 if { !$_allowMultiComponent && $components > 1 } { 1422 1488 puts stderr "Can't use a vector field in a volume" 1423 1489 return 1424 1490 } else { 1425 set _colorMode scalar 1491 if { $components > 1 } { 1492 set _colorMode vmag 1493 } else { 1494 set _colorMode scalar 1495 } 1426 1496 } 1427 1497 set _curFldName $fname … … 1432 1502 } 1433 1503 foreach dataset [CurrentDatasets -visible $_first] { 1434 #SendCmd " volume colormode $_colorMode ${fname}$dataset"1435 SendCmd " cutplane colormode $_colorMode ${fname}$dataset"1504 #SendCmd "$_cutplaneCmd colormode $_colorMode $_curFldName $dataset" 1505 SendCmd "dataset scalar $_curFldName $dataset" 1436 1506 } 1437 1507 SendCmd "camera reset" … … 1448 1518 # 1449 1519 # Request a new legend from the server. The size of the legend 1450 # is determined from the height of the canvas. It will be rotated 1451 # to be vertical when drawn. 1520 # is determined from the height of the canvas. 1452 1521 # 1453 1522 itcl::body Rappture::VtkVolumeViewer::RequestLegend {} { 1523 set _legendPending 0 1454 1524 set font "Arial 8" 1455 1525 set lineht [font metrics $font -linespace] 1456 set c $itk_component(legend)1457 1526 set w 12 1458 1527 set h [expr {$_height - 3 * ($lineht + 2)}] 1459 if { $h < 1 } {1528 if { $h < 1 } { 1460 1529 return 1461 1530 } … … 1464 1533 foreach {dataobj comp} [split $dataset -] break 1465 1534 if { [info exists _dataset2style($dataset)] } { 1466 SendCmdNoWait \1467 "legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0"1535 #SendCmd "legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0" 1536 SendCmd "legend2 $_dataset2style($dataset) $w $h" 1468 1537 break; 1469 1538 } … … 1492 1561 -color BCGYR 1493 1562 -levels 6 1494 -opacity 1.01495 1563 } 1496 1564 set tag $dataobj-$comp … … 1509 1577 array set style $_style($tag) 1510 1578 1511 set name "$style(-color):$style(-levels) :$style(-opacity)"1579 set name "$style(-color):$style(-levels)" 1512 1580 if { ![info exists _colormaps($name)] } { 1513 1581 BuildColormap $name [array get style] … … 1517 1585 $_dataset2style($tag) != $name } { 1518 1586 SendCmd "volume colormap $name $tag" 1519 SendCmd " cutplanecolormap $name-opaque $tag"1587 SendCmd "$_cutplaneCmd colormap $name-opaque $tag" 1520 1588 set _dataset2style($tag) $name 1521 1589 } … … 1531 1599 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1532 1600 } 1533 if { ![info exists _settings(volume-opacity)] } { 1534 set _settings(volume-opacity) $style(-opacity) 1535 } 1536 set max $_settings(volume-opacity) 1537 1538 set opaqueWmap "0.0 1.0 1.0 1.0" 1539 #set wmap "0.0 0.0 0.1 0.0 0.2 0.8 0.98 0.8 0.99 0.0 1.0 0.0" 1601 set max 1.0 1602 1603 set opaqueAmap "0.0 1.0 1.0 1.0" 1604 #set amap "0.0 0.0 0.1 0.0 0.2 0.8 0.98 0.8 0.99 0.0 1.0 0.0" 1540 1605 # Approximate cubic opacity curve 1541 set wmap "0.0 0.0 0.1 0.001 0.2 0.008 0.3 0.027 0.4 0.064 0.5 0.125 0.6 0.216 0.7 0.343 0.8 0.512 0.9 0.729 1.0 1.0"1542 SendCmd "colormap add $name { $cmap } { $ wmap }"1543 SendCmd "colormap add $name-opaque { $cmap } { $opaque Wmap }"1606 set amap "0.0 0.0 0.1 0.001 0.2 0.008 0.3 0.027 0.4 0.064 0.5 0.125 0.6 0.216 0.7 0.343 0.8 0.512 0.9 0.729 1.0 1.0" 1607 SendCmd "colormap add $name { $cmap } { $amap }" 1608 SendCmd "colormap add $name-opaque { $cmap } { $opaqueAmap }" 1544 1609 } 1545 1610 … … 1549 1614 itcl::configbody Rappture::VtkVolumeViewer::plotbackground { 1550 1615 if { [isconnected] } { 1551 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break 1552 SendCmd "screen bgcolor $r $g $b" 1616 set color $itk_option(-plotbackground) 1617 set rgb [Color2RGB $color] 1618 SendCmd "screen bgcolor $rgb" 1619 $itk_component(legend) configure -background $color 1553 1620 } 1554 1621 } … … 1559 1626 itcl::configbody Rappture::VtkVolumeViewer::plotforeground { 1560 1627 if { [isconnected] } { 1561 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break 1562 #fix this! 1563 #SendCmd "color background $r $g $b" 1564 } 1628 set color $itk_option(-plotforeground) 1629 set rgb [Color2RGB $color] 1630 SendCmd "axis color all $rgb" 1631 SendCmd "outline color $rgb" 1632 SendCmd "$_cutplaneCmd color $rgb" 1633 $itk_component(legend) itemconfigure labels -fill $color 1634 $itk_component(legend) itemconfigure limits -fill $color 1635 } 1636 } 1637 1638 itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} { 1639 set font [option get $itk_component(hull) font Font] 1640 1641 set inner [$itk_component(main) insert end \ 1642 -title "View Settings" \ 1643 -icon [Rappture::icon wrench]] 1644 $inner configure -borderwidth 4 1645 1646 checkbutton $inner.axes \ 1647 -text "Axes" \ 1648 -variable [itcl::scope _settings(-axesvisible)] \ 1649 -command [itcl::code $this AdjustSetting -axesvisible] \ 1650 -font $font 1651 1652 checkbutton $inner.outline \ 1653 -text "Outline" \ 1654 -variable [itcl::scope _settings(-volumeoutline)] \ 1655 -command [itcl::code $this AdjustSetting -volumeoutline] \ 1656 -font $font 1657 1658 checkbutton $inner.legend \ 1659 -text "Legend" \ 1660 -variable [itcl::scope _settings(-legendvisible)] \ 1661 -command [itcl::code $this AdjustSetting -legendvisible] \ 1662 -font $font 1663 1664 checkbutton $inner.volume \ 1665 -text "Volume" \ 1666 -variable [itcl::scope _settings(-volumevisible)] \ 1667 -command [itcl::code $this AdjustSetting -volumevisible] \ 1668 -font $font 1669 1670 label $inner.background_l -text "Background" -font $font 1671 itk_component add background { 1672 Rappture::Combobox $inner.background -width 10 -editable no 1673 } 1674 $inner.background choices insert end \ 1675 "black" "black" \ 1676 "white" "white" \ 1677 "grey" "grey" 1678 1679 $itk_component(background) value $_settings(-background) 1680 bind $inner.background <<Value>> \ 1681 [itcl::code $this AdjustSetting -background] 1682 1683 blt::table $inner \ 1684 0,0 $inner.axes -cspan 2 -anchor w \ 1685 1,0 $inner.outline -cspan 2 -anchor w \ 1686 2,0 $inner.volume -cspan 2 -anchor w \ 1687 3,0 $inner.legend -cspan 2 -anchor w \ 1688 4,0 $inner.background_l -anchor e -pady 2 \ 1689 4,1 $inner.background -fill x 1690 1691 blt::table configure $inner r* -resize none 1692 blt::table configure $inner r5 -resize expand 1565 1693 } 1566 1694 1567 1695 itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} { 1568 1569 set fg [option get $itk_component(hull) font Font]1570 #set bfg [option get $itk_component(hull) boldFont Font]1696 set font [option get $itk_component(hull) font Font] 1697 #set bfont [option get $itk_component(hull) boldFont Font] 1698 set bfont "Arial 9 bold" 1571 1699 1572 1700 set inner [$itk_component(main) insert end \ … … 1575 1703 $inner configure -borderwidth 4 1576 1704 1577 checkbutton $inner.v olume\1578 -text " Show Volume" \1579 - variable [itcl::scope _settings(volumeVisible)]\1580 - command [itcl::code $this AdjustSetting volumeVisible] \1581 - font "Arial 9"1705 checkbutton $inner.visibility \ 1706 -text "Visible" \ 1707 -font $font \ 1708 -variable [itcl::scope _settings(-volumevisible)] \ 1709 -command [itcl::code $this AdjustSetting -volumevisible] 1582 1710 1583 1711 checkbutton $inner.lighting \ 1584 1712 -text "Enable Lighting" \ 1585 - variable [itcl::scope _settings(volumeLighting)]\1586 - command [itcl::code $this AdjustSetting volumeLighting] \1587 - font "Arial 9"1588 1589 label $inner.dim_l -text "Dim" -font "Arial 9"1713 -font $font \ 1714 -variable [itcl::scope _settings(-volumelighting)] \ 1715 -command [itcl::code $this AdjustSetting -volumelighting] 1716 1717 label $inner.dim_l -text "Dim" -font $font 1590 1718 ::scale $inner.material -from 0 -to 100 -orient horizontal \ 1591 -variable [itcl::scope _settings( volume-material)] \1592 - width 10\1593 - showvalue off -command [itcl::code $this AdjustSetting volume-material]1594 label $inner.bright_l -text "Bright" -font "Arial 9"1595 1596 label $inner.opacity_l -text "Opacity" -font "Arial 9"1719 -variable [itcl::scope _settings(-volumematerial)] \ 1720 -showvalue off \ 1721 -command [itcl::code $this AdjustSetting -volumematerial] 1722 label $inner.bright_l -text "Bright" -font $font 1723 1724 label $inner.opacity_l -text "Opacity" -font $font 1597 1725 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1598 -variable [itcl::scope _settings(volume-opacity)] \ 1599 -width 10 \ 1726 -variable [itcl::scope _settings(-volumeopacity)] \ 1600 1727 -showvalue off \ 1601 -command [itcl::code $this AdjustSetting volume-opacity]1602 1603 label $inner.quality_l -text "Quality" -font "Arial 9"1728 -command [itcl::code $this AdjustSetting -volumeopacity] 1729 1730 label $inner.quality_l -text "Quality" -font $font 1604 1731 ::scale $inner.quality -from 0 -to 100 -orient horizontal \ 1605 -variable [itcl::scope _settings(volume-quality)] \ 1606 -width 10 \ 1607 -showvalue off -command [itcl::code $this AdjustSetting volume-quality] 1608 1609 itk_component add field_l { 1610 label $inner.field_l -text "Field" -font "Arial 9" 1611 } { 1612 ignore -font 1613 } 1732 -variable [itcl::scope _settings(-volumequality)] \ 1733 -showvalue off \ 1734 -command [itcl::code $this AdjustSetting -volumequality] 1735 1736 label $inner.field_l -text "Field" -font $font 1614 1737 itk_component add field { 1615 Rappture::Combobox $inner.field - width 10 -editable no1738 Rappture::Combobox $inner.field -editable no 1616 1739 } 1617 1740 bind $inner.field <<Value>> \ 1618 [itcl::code $this AdjustSetting field] 1619 1620 label $inner.palette_l -text "Palette" -font "Arial 9" 1621 itk_component add palette { 1622 Rappture::Combobox $inner.palette -width 10 -editable no 1623 } 1624 $inner.palette choices insert end \ 1625 "BCGYR" "BCGYR" \ 1626 "BGYOR" "BGYOR" \ 1627 "blue" "blue" \ 1628 "blue-to-brown" "blue-to-brown" \ 1629 "blue-to-orange" "blue-to-orange" \ 1630 "blue-to-grey" "blue-to-grey" \ 1631 "green-to-magenta" "green-to-magenta" \ 1632 "greyscale" "greyscale" \ 1633 "nanohub" "nanohub" \ 1634 "rainbow" "rainbow" \ 1635 "spectral" "spectral" \ 1636 "ROYGB" "ROYGB" \ 1637 "RYGCB" "RYGCB" \ 1638 "brown-to-blue" "brown-to-blue" \ 1639 "grey-to-blue" "grey-to-blue" \ 1640 "orange-to-blue" "orange-to-blue" 1641 1642 $itk_component(palette) value "BCGYR" 1643 bind $inner.palette <<Value>> \ 1644 [itcl::code $this AdjustSetting volume-palette] 1741 [itcl::code $this AdjustSetting -field] 1742 1743 label $inner.colormap_l -text "Colormap" -font $font 1744 itk_component add colormap { 1745 Rappture::Combobox $inner.colormap -editable no 1746 } 1747 $inner.colormap choices insert end [GetColormapList] 1748 bind $inner.colormap <<Value>> \ 1749 [itcl::code $this AdjustSetting -color] 1750 $itk_component(colormap) value $_settings(-color) 1645 1751 1646 1752 blt::table $inner \ 1647 0,0 $inner.field_l -anchor w -pady 2 \ 1648 0,1 $inner.field -anchor w -pady 2 -cspan 2 \ 1649 1,0 $inner.volume -anchor w -pady 2 -cspan 4 \ 1650 2,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 1651 3,0 $inner.dim_l -anchor e -pady 2 \ 1652 3,1 $inner.material -fill x -pady 2 \ 1653 3,2 $inner.bright_l -anchor w -pady 2 \ 1654 4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \ 1655 5,0 $inner.quality -fill x -pady 2 -cspan 2 \ 1656 7,0 $inner.palette_l -anchor w -pady 2 \ 1657 7,1 $inner.palette -anchor w -pady 2 -cspan 2 \ 1658 1659 blt::table configure $inner r* c* -resize none 1660 blt::table configure $inner r8 -resize expand 1753 0,0 $inner.field_l -anchor w -pady 2 \ 1754 0,1 $inner.field -fill x -pady 2 -cspan 3 \ 1755 1,0 $inner.visibility -anchor w -pady 2 -cspan 4 \ 1756 2,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 1757 3,0 $inner.dim_l -anchor e -pady 2 \ 1758 3,1 $inner.material -fill x -pady 2 -cspan 2 \ 1759 3,3 $inner.bright_l -anchor w -pady 2 \ 1760 4,0 $inner.opacity_l -anchor w -pady 2 -cspan 4 \ 1761 5,0 $inner.opacity -fill x -pady 2 -cspan 4 \ 1762 6,0 $inner.quality_l -anchor w -pady 2 -cspan 4 \ 1763 7,0 $inner.quality -fill x -pady 2 -cspan 4 \ 1764 8,0 $inner.colormap_l -anchor w -pady 2 \ 1765 8,1 $inner.colormap -fill x -pady 2 -cspan 3 1766 1767 blt::table configure $inner r* c0 c1 c3 -resize none 1768 blt::table configure $inner r9 c2 -resize expand 1661 1769 } 1662 1770 1663 1771 itcl::body Rappture::VtkVolumeViewer::BuildAxisTab {} { 1664 1665 set fg [option get $itk_component(hull) font Font] 1666 #set bfg [option get $itk_component(hull) boldFont Font] 1772 set font [option get $itk_component(hull) font Font] 1667 1773 1668 1774 set inner [$itk_component(main) insert end \ 1669 1775 -title "Axis Settings" \ 1670 -icon [Rappture::icon axis 1]]1776 -icon [Rappture::icon axis2]] 1671 1777 $inner configure -borderwidth 4 1672 1778 1673 1779 checkbutton $inner.visible \ 1674 -text " ShowAxes" \1675 -variable [itcl::scope _settings( axesVisible)] \1676 -command [itcl::code $this AdjustSetting axesVisible] \1677 -font "Arial 9"1780 -text "Axes" \ 1781 -variable [itcl::scope _settings(-axesvisible)] \ 1782 -command [itcl::code $this AdjustSetting -axesvisible] \ 1783 -font $font 1678 1784 1679 1785 checkbutton $inner.labels \ 1680 -text "Show Axis Labels" \ 1681 -variable [itcl::scope _settings(axisLabels)] \ 1682 -command [itcl::code $this AdjustSetting axisLabels] \ 1683 -font "Arial 9" 1684 1685 checkbutton $inner.gridx \ 1686 -text "Show X Grid" \ 1687 -variable [itcl::scope _settings(axis-xgrid)] \ 1688 -command [itcl::code $this AdjustSetting axis-xgrid] \ 1689 -font "Arial 9" 1690 checkbutton $inner.gridy \ 1691 -text "Show Y Grid" \ 1692 -variable [itcl::scope _settings(axis-ygrid)] \ 1693 -command [itcl::code $this AdjustSetting axis-ygrid] \ 1694 -font "Arial 9" 1695 checkbutton $inner.gridz \ 1696 -text "Show Z Grid" \ 1697 -variable [itcl::scope _settings(axis-zgrid)] \ 1698 -command [itcl::code $this AdjustSetting axis-zgrid] \ 1699 -font "Arial 9" 1700 1701 label $inner.mode_l -text "Mode" -font "Arial 9" 1786 -text "Axis Labels" \ 1787 -variable [itcl::scope _settings(-axislabels)] \ 1788 -command [itcl::code $this AdjustSetting -axislabels] \ 1789 -font $font 1790 label $inner.grid_l -text "Grid" -font $font 1791 checkbutton $inner.xgrid \ 1792 -text "X" \ 1793 -variable [itcl::scope _settings(-xgrid)] \ 1794 -command [itcl::code $this AdjustSetting -xgrid] \ 1795 -font $font 1796 checkbutton $inner.ygrid \ 1797 -text "Y" \ 1798 -variable [itcl::scope _settings(-ygrid)] \ 1799 -command [itcl::code $this AdjustSetting -ygrid] \ 1800 -font $font 1801 checkbutton $inner.zgrid \ 1802 -text "Z" \ 1803 -variable [itcl::scope _settings(-zgrid)] \ 1804 -command [itcl::code $this AdjustSetting -zgrid] \ 1805 -font $font 1806 checkbutton $inner.minorticks \ 1807 -text "Minor Ticks" \ 1808 -variable [itcl::scope _settings(-axisminorticks)] \ 1809 -command [itcl::code $this AdjustSetting -axisminorticks] \ 1810 -font $font 1811 1812 label $inner.mode_l -text "Mode" -font $font 1702 1813 1703 1814 itk_component add axismode { … … 1707 1818 "static_triad" "static" \ 1708 1819 "closest_triad" "closest" \ 1709 "furthest_triad" "f urthest" \1710 "outer_edges" "outer" 1711 $itk_component(axismode) value "static"1712 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlyMode]1820 "furthest_triad" "farthest" \ 1821 "outer_edges" "outer" 1822 $itk_component(axismode) value $_settings(-axisflymode) 1823 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode] 1713 1824 1714 1825 blt::table $inner \ 1715 0,0 $inner.visible -anchor w -cspan 2 \ 1716 1,0 $inner.labels -anchor w -cspan 2 \ 1717 2,0 $inner.gridx -anchor w -cspan 2 \ 1718 3,0 $inner.gridy -anchor w -cspan 2 \ 1719 4,0 $inner.gridz -anchor w -cspan 2 \ 1720 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1721 6,0 $inner.mode -fill x -cspan 2 1826 0,0 $inner.visible -anchor w -cspan 4 \ 1827 1,0 $inner.labels -anchor w -cspan 4 \ 1828 2,0 $inner.minorticks -anchor w -cspan 4 \ 1829 4,0 $inner.grid_l -anchor w \ 1830 4,1 $inner.xgrid -anchor w \ 1831 4,2 $inner.ygrid -anchor w \ 1832 4,3 $inner.zgrid -anchor w \ 1833 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1834 5,1 $inner.mode -fill x -cspan 3 1722 1835 1723 1836 blt::table configure $inner r* c* -resize none 1724 blt::table configure $inner r7 c 1-resize expand1725 } 1726 1837 blt::table configure $inner r7 c6 -resize expand 1838 blt::table configure $inner r3 -height 0.125i 1839 } 1727 1840 1728 1841 itcl::body Rappture::VtkVolumeViewer::BuildCameraTab {} { 1842 set font [option get $itk_component(hull) font Font] 1729 1843 set inner [$itk_component(main) insert end \ 1730 1844 -title "Camera Settings" \ … … 1732 1846 $inner configure -borderwidth 4 1733 1847 1848 label $inner.view_l -text "view" -font $font 1849 set f [frame $inner.view] 1850 foreach side { front back left right top bottom } { 1851 button $f.$side -image [Rappture::icon view$side] \ 1852 -command [itcl::code $this SetOrientation $side] 1853 Rappture::Tooltip::for $f.$side "Change the view to $side" 1854 pack $f.$side -side left 1855 } 1856 blt::table $inner \ 1857 0,0 $inner.view_l -anchor e -pady 2 \ 1858 0,1 $inner.view -anchor w -pady 2 1859 blt::table configure $inner r0 -resize none 1860 1861 set row 1 1734 1862 set labels { qx qy qz qw xpan ypan zoom } 1735 set row 01736 1863 foreach tag $labels { 1737 label $inner.${tag}label -text $tag -font "Arial 9" 1738 entry $inner.${tag} -font "Arial 9" -bg white \ 1739 -textvariable [itcl::scope _view($tag)] 1740 bind $inner.${tag} <KeyPress-Return> \ 1741 [itcl::code $this camera set ${tag}] 1864 label $inner.${tag}label -text $tag -font $font 1865 entry $inner.${tag} -font $font -bg white \ 1866 -textvariable [itcl::scope _view(-$tag)] 1867 bind $inner.${tag} <Return> \ 1868 [itcl::code $this camera set -${tag}] 1869 bind $inner.${tag} <KP_Enter> \ 1870 [itcl::code $this camera set -${tag}] 1742 1871 blt::table $inner \ 1743 1872 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1748 1877 checkbutton $inner.ortho \ 1749 1878 -text "Orthographic Projection" \ 1750 -variable [itcl::scope _view( ortho)] \1751 -command [itcl::code $this camera set ortho] \1752 -font "Arial 9"1879 -variable [itcl::scope _view(-ortho)] \ 1880 -command [itcl::code $this camera set -ortho] \ 1881 -font $font 1753 1882 blt::table $inner \ 1754 1883 $row,0 $inner.ortho -cspan 2 -anchor w -pady 2 … … 1762 1891 1763 1892 itcl::body Rappture::VtkVolumeViewer::BuildCutplaneTab {} { 1764 1765 set fg [option get $itk_component(hull) font Font] 1766 1893 set font [option get $itk_component(hull) font Font] 1894 1767 1895 set inner [$itk_component(main) insert end \ 1768 1896 -title "Cutplane Settings" \ 1769 -icon [Rappture::icon cutbutton]] 1897 -icon [Rappture::icon cutbutton]] 1770 1898 1771 1899 $inner configure -borderwidth 4 … … 1773 1901 checkbutton $inner.visible \ 1774 1902 -text "Show Cutplanes" \ 1775 -variable [itcl::scope _settings(cutplaneVisible)] \ 1776 -command [itcl::code $this AdjustSetting cutplaneVisible] \ 1777 -font "Arial 9" 1778 1779 checkbutton $inner.wireframe \ 1780 -text "Show Wireframe" \ 1781 -variable [itcl::scope _settings(cutplaneWireframe)] \ 1782 -command [itcl::code $this AdjustSetting cutplaneWireframe] \ 1783 -font "Arial 9" 1903 -variable [itcl::scope _settings(-cutplanesvisible)] \ 1904 -command [itcl::code $this AdjustSetting -cutplanesvisible] \ 1905 -font $font 1784 1906 1785 1907 checkbutton $inner.lighting \ 1786 1908 -text "Enable Lighting" \ 1787 -variable [itcl::scope _settings(cutplaneLighting)] \ 1788 -command [itcl::code $this AdjustSetting cutplaneLighting] \ 1789 -font "Arial 9" 1790 1791 checkbutton $inner.edges \ 1792 -text "Show Edges" \ 1793 -variable [itcl::scope _settings(cutplaneEdges)] \ 1794 -command [itcl::code $this AdjustSetting cutplaneEdges] \ 1795 -font "Arial 9" 1796 1797 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1909 -variable [itcl::scope _settings(-cutplanelighting)] \ 1910 -command [itcl::code $this AdjustSetting -cutplanelighting] \ 1911 -font $font 1912 1913 label $inner.opacity_l -text "Opacity" -font $font 1798 1914 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1799 -variable [itcl::scope _settings( cutplane-opacity)] \1915 -variable [itcl::scope _settings(-cutplaneopacity)] \ 1800 1916 -width 10 \ 1801 1917 -showvalue off \ 1802 -command [itcl::code $this AdjustSetting cutplane-opacity]1803 $inner.opacity set $_settings( cutplane-opacity)1918 -command [itcl::code $this AdjustSetting -cutplaneopacity] 1919 $inner.opacity set $_settings(-cutplaneopacity) 1804 1920 1805 1921 # X-value slicer... … … 1808 1924 -onimage [Rappture::icon x-cutplane] \ 1809 1925 -offimage [Rappture::icon x-cutplane] \ 1810 -command [itcl::code $this AdjustSetting cutplane-xvisible] \1811 -variable [itcl::scope _settings( cutplane-xvisible)]1926 -command [itcl::code $this AdjustSetting -xcutplanevisible] \ 1927 -variable [itcl::scope _settings(-xcutplanevisible)] 1812 1928 } 1813 1929 Rappture::Tooltip::for $itk_component(xCutButton) \ … … 1820 1936 -borderwidth 1 -highlightthickness 0 \ 1821 1937 -command [itcl::code $this EventuallySetCutplane x] \ 1822 -variable [itcl::scope _settings( cutplane-xposition)]1938 -variable [itcl::scope _settings(-xcutplaneposition)] 1823 1939 } { 1824 1940 usual … … 1836 1952 -onimage [Rappture::icon y-cutplane] \ 1837 1953 -offimage [Rappture::icon y-cutplane] \ 1838 -command [itcl::code $this AdjustSetting cutplane-yvisible] \1839 -variable [itcl::scope _settings( cutplane-yvisible)]1954 -command [itcl::code $this AdjustSetting -ycutplanevisible] \ 1955 -variable [itcl::scope _settings(-ycutplanevisible)] 1840 1956 } 1841 1957 Rappture::Tooltip::for $itk_component(yCutButton) \ … … 1848 1964 -borderwidth 1 -highlightthickness 0 \ 1849 1965 -command [itcl::code $this EventuallySetCutplane y] \ 1850 -variable [itcl::scope _settings( cutplane-yposition)]1966 -variable [itcl::scope _settings(-ycutplaneposition)] 1851 1967 } { 1852 1968 usual … … 1864 1980 -onimage [Rappture::icon z-cutplane] \ 1865 1981 -offimage [Rappture::icon z-cutplane] \ 1866 -command [itcl::code $this AdjustSetting cutplane-zvisible] \1867 -variable [itcl::scope _settings( cutplane-zvisible)]1982 -command [itcl::code $this AdjustSetting -zcutplanevisible] \ 1983 -variable [itcl::scope _settings(-zcutplanevisible)] 1868 1984 } 1869 1985 Rappture::Tooltip::for $itk_component(zCutButton) \ … … 1876 1992 -borderwidth 1 -highlightthickness 0 \ 1877 1993 -command [itcl::code $this EventuallySetCutplane z] \ 1878 -variable [itcl::scope _settings( cutplane-zposition)]1994 -variable [itcl::scope _settings(-zcutplaneposition)] 1879 1995 } { 1880 1996 usual … … 1889 2005 0,0 $inner.visible -anchor w -pady 2 -cspan 4 \ 1890 2006 1,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 1891 2,0 $inner.wireframe -anchor w -pady 2 -cspan 4 \ 1892 3,0 $inner.edges -anchor w -pady 2 -cspan 4 \ 1893 4,0 $inner.opacity_l -anchor w -pady 2 -cspan 3 \ 1894 5,0 $inner.opacity -fill x -pady 2 -cspan 3 \ 1895 6,0 $itk_component(xCutButton) -anchor e -padx 2 -pady 2 \ 1896 7,0 $itk_component(xCutScale) -fill y \ 1897 6,1 $itk_component(yCutButton) -anchor e -padx 2 -pady 2 \ 1898 7,1 $itk_component(yCutScale) -fill y \ 1899 6,2 $itk_component(zCutButton) -anchor e -padx 2 -pady 2 \ 1900 7,2 $itk_component(zCutScale) -fill y \ 2007 2,0 $inner.opacity_l -anchor w -pady 2 -cspan 3 \ 2008 3,0 $inner.opacity -fill x -pady 2 -cspan 3 \ 2009 4,0 $itk_component(xCutButton) -anchor e -padx 2 -pady 2 \ 2010 5,0 $itk_component(xCutScale) -fill y \ 2011 4,1 $itk_component(yCutButton) -anchor e -padx 2 -pady 2 \ 2012 5,1 $itk_component(yCutScale) -fill y \ 2013 4,2 $itk_component(zCutButton) -anchor e -padx 2 -pady 2 \ 2014 5,2 $itk_component(zCutScale) -fill y 1901 2015 1902 2016 blt::table configure $inner r* c* -resize none 1903 blt::table configure $inner r 7c3 -resize expand1904 } 1905 1906 # 1907 # camera -- 2017 blt::table configure $inner r5 c3 -resize expand 2018 } 2019 2020 # 2021 # camera -- 1908 2022 # 1909 2023 itcl::body Rappture::VtkVolumeViewer::camera {option args} { 1910 switch -- $option { 2024 switch -- $option { 1911 2025 "show" { 1912 2026 puts [array get _view] 1913 2027 } 1914 2028 "set" { 1915 set wh o[lindex $args 0]1916 set x $_view($wh o)2029 set what [lindex $args 0] 2030 set x $_view($what) 1917 2031 set code [catch { string is double $x } result] 1918 2032 if { $code != 0 || !$result } { 1919 2033 return 1920 2034 } 1921 switch -- $wh o{1922 " ortho" {1923 if {$_view( ortho)} {2035 switch -- $what { 2036 "-ortho" { 2037 if {$_view($what)} { 1924 2038 SendCmd "camera mode ortho" 1925 2039 } else { … … 1927 2041 } 1928 2042 } 1929 " xpan" - "ypan" {2043 "-xpan" - "-ypan" { 1930 2044 PanCamera 1931 2045 } 1932 " qx" - "qy" - "qz" - "qw" {1933 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2046 "-qx" - "-qy" - "-qz" - "-qw" { 2047 set q [ViewToQuaternion] 1934 2048 $_arcball quaternion $q 1935 2049 EventuallyRotate $q 1936 2050 } 1937 " zoom" {1938 SendCmd "camera zoom $_view( zoom)"2051 "-zoom" { 2052 SendCmd "camera zoom $_view($what)" 1939 2053 } 1940 2054 } … … 1956 2070 1957 2071 itcl::body Rappture::VtkVolumeViewer::GetImage { args } { 1958 if { [image width $_image(download)] > 0 && 2072 if { [image width $_image(download)] > 0 && 1959 2073 [image height $_image(download)] > 0 } { 1960 2074 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 1969 2083 -title "[Rappture::filexfer::label downloadWord] as..." 1970 2084 set inner [$popup component inner] 1971 label $inner.summary -text "" -anchor w 2085 label $inner.summary -text "" -anchor w 1972 2086 radiobutton $inner.vtk_button -text "VTK data file" \ 1973 2087 -variable [itcl::scope _downloadPopup(format)] \ 1974 2088 -font "Helvetica 9 " \ 1975 -value vtk 2089 -value vtk 1976 2090 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 1977 2091 radiobutton $inner.image_button -text "Image File" \ 1978 2092 -variable [itcl::scope _downloadPopup(format)] \ 1979 -value image 2093 -value image 1980 2094 Rappture::Tooltip::for $inner.image_button \ 1981 2095 "Save as digital image." … … 1998 2112 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 1999 2113 4,1 $inner.cancel -width .9i -fill y \ 2000 4,0 $inner.ok -padx 2 -width .9i -fill y 2114 4,0 $inner.ok -padx 2 -width .9i -fill y 2001 2115 blt::table configure $inner r3 -height 4 2002 2116 blt::table configure $inner r4 -pady 4 … … 2006 2120 } 2007 2121 2008 itcl::body Rappture::VtkVolumeViewer::SetObjectStyle { dataobj c omp} {2122 itcl::body Rappture::VtkVolumeViewer::SetObjectStyle { dataobj cname } { 2009 2123 # Parse style string. 2010 set tag $dataobj-$comp 2011 set style [$dataobj style $comp] 2012 array set settings { 2013 -color \#808080 2014 -edges 0 2015 -edgecolor black 2016 -linewidth 1.0 2017 -opacity 0.4 2018 -wireframe 0 2019 -lighting 1 2020 -seeds 1 2021 -seedcolor white 2022 -visible 1 2023 } 2024 if { $dataobj != $_first } { 2025 set settings(-opacity) 1 2026 } 2027 array set settings $style 2124 set tag $dataobj-$cname 2125 array set style { 2126 -color BCGYR 2127 -lighting 1 2128 -opacity 0.5 2129 -outline 0 2130 -visible 1 2131 } 2132 array set style [$dataobj style $cname] 2133 set _settings(-volumelighting) $style(-lighting) 2134 set _settings(-volumeopacity) [expr $style(-opacity) * 100.0] 2135 set _settings(-volumeoutline) $style(-outline) 2136 set _settings(-volumevisible) $style(-visible) 2137 2138 $itk_component(colormap) value $style(-color) 2139 2140 SendCmd "outline add $tag" 2141 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 2142 SendCmd "outline visible $style(-outline) $tag" 2143 2144 SendCmd "$_cutplaneCmd add $tag" 2145 SendCmd "$_cutplaneCmd color [Color2RGB $itk_option(-plotforeground)] $tag" 2146 SendCmd "$_cutplaneCmd visible 0 $tag" 2147 2028 2148 SendCmd "volume add $tag" 2029 SendCmd "cutplane add $tag" 2030 SendCmd "cutplane visible 0 $tag" 2031 2032 SendCmd "volume lighting $settings(-lighting) $tag" 2033 set _settings(volumeLighting) $settings(-lighting) 2034 SetColormap $dataobj $comp 2149 SendCmd "volume lighting $style(-lighting) $tag" 2150 SendCmd "volume opacity $style(-opacity) $tag" 2151 SendCmd "volume visible $style(-visible) $tag" 2152 SetColormap $dataobj $cname 2035 2153 } 2036 2154 … … 2050 2168 # ---------------------------------------------------------------------- 2051 2169 itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title vmin vmax size } { 2052 set _legendPending 0 2053 #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size" 2054 if { [IsConnected] } { 2170 if { [isconnected] } { 2055 2171 set bytes [ReceiveBytes $size] 2056 2172 if { ![info exists _image(legend)] } { … … 2068 2184 # DrawLegend -- 2069 2185 # 2070 # Draws the legend in it's own canvas which resides to the right 2071 # of the contour plot area. 2072 # 2073 itcl::body Rappture::VtkVolumeViewer::DrawLegend { } { 2186 itcl::body Rappture::VtkVolumeViewer::DrawLegend {} { 2074 2187 set fname $_curFldName 2075 2188 set c $itk_component(view) … … 2078 2191 set font "Arial 8" 2079 2192 set lineht [font metrics $font -linespace] 2080 2193 2194 if { !$_settings(-legendvisible) } { 2195 $c delete legend 2196 return 2197 } 2198 2081 2199 if { [info exists _fields($fname)] } { 2082 2200 foreach { title units } $_fields($fname) break … … 2087 2205 set title $fname 2088 2206 } 2089 if { $_settings(legendVisible) } { 2090 set x [expr $w - 2] 2091 if { [$c find withtag "legend"] == "" } { 2092 set y 2 2093 $c create text $x $y \ 2094 -anchor ne \ 2095 -fill $itk_option(-plotforeground) -tags "title legend" \ 2096 -font $font 2097 incr y $lineht 2098 $c create text $x $y \ 2099 -anchor ne \ 2100 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2101 -font $font 2102 incr y $lineht 2103 $c create image $x $y \ 2104 -anchor ne \ 2105 -image $_image(legend) -tags "colormap legend" 2106 $c create text $x [expr {$h-2}] \ 2107 -anchor se \ 2108 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2109 -font $font 2110 #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y] 2111 $c bind colormap <Leave> [itcl::code $this LeaveLegend] 2112 $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y] 2113 } 2114 $c bind title <ButtonPress> [itcl::code $this Combo post] 2115 $c bind title <Enter> [itcl::code $this Combo activate] 2116 $c bind title <Leave> [itcl::code $this Combo deactivate] 2117 # Reset the item coordinates according the current size of the plot. 2118 $c itemconfigure title -text $title 2119 if { [info exists _limits($_curFldName)] } { 2120 foreach { vmin vmax } $_limits($_curFldName) break 2121 $c itemconfigure vmin -text [format %g $vmin] 2122 $c itemconfigure vmax -text [format %g $vmax] 2123 } 2207 2208 set x [expr $w - 2] 2209 if { [$c find withtag "legend"] == "" } { 2124 2210 set y 2 2125 $c coords title $x $y 2211 $c create text $x $y \ 2212 -anchor ne \ 2213 -fill $itk_option(-plotforeground) -tags "title legend" \ 2214 -font $font 2126 2215 incr y $lineht 2127 $c coords vmax $x $y 2216 $c create text $x $y \ 2217 -anchor ne \ 2218 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2219 -font $font 2128 2220 incr y $lineht 2129 $c coords colormap $x $y 2130 $c coords vmin $x [expr {$h - 2}] 2131 } 2221 $c create image $x $y \ 2222 -anchor ne \ 2223 -image $_image(legend) -tags "colormap legend" 2224 $c create text $x [expr {$h-2}] \ 2225 -anchor se \ 2226 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2227 -font $font 2228 #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y] 2229 $c bind colormap <Leave> [itcl::code $this LeaveLegend] 2230 $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y] 2231 } 2232 $c bind title <ButtonPress> [itcl::code $this Combo post] 2233 $c bind title <Enter> [itcl::code $this Combo activate] 2234 $c bind title <Leave> [itcl::code $this Combo deactivate] 2235 # Reset the item coordinates according the current size of the plot. 2236 $c itemconfigure title -text $title 2237 if { [info exists _limits($_curFldName)] } { 2238 foreach { vmin vmax } $_limits($_curFldName) break 2239 $c itemconfigure vmin -text [format %g $vmin] 2240 $c itemconfigure vmax -text [format %g $vmax] 2241 } 2242 set y 2 2243 $c coords title $x $y 2244 incr y $lineht 2245 $c coords vmax $x $y 2246 incr y $lineht 2247 $c coords colormap $x $y 2248 $c coords vmin $x [expr {$h - 2}] 2132 2249 } 2133 2250 … … 2165 2282 set font "Arial 8" 2166 2283 set lineht [font metrics $font -linespace] 2167 2284 2168 2285 set imgHeight [image height $_image(legend)] 2169 2286 set coords [$c coords colormap] … … 2188 2305 } 2189 2306 set color [eval format "\#%02x%02x%02x" $pixel] 2190 $_image(swatch) put black -to 0 0 23 23 2191 $_image(swatch) put $color -to 1 1 22 22 2307 $_image(swatch) put black -to 0 0 23 23 2308 $_image(swatch) put $color -to 1 1 22 22 2192 2309 .rappturetooltip configure -icon $_image(swatch) 2193 2310 … … 2200 2317 set value 0.0 2201 2318 } 2202 set tipx [expr $x + 15] 2319 set tipx [expr $x + 15] 2203 2320 set tipy [expr $y - 5] 2204 2321 Rappture::Tooltip::text $c "$title $value" 2205 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2206 } 2207 2322 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2323 } 2208 2324 2209 2325 # ---------------------------------------------------------------------- … … 2224 2340 } 2225 2341 set newpos [expr {0.01*$newval}] 2226 SendCmd " cutplaneslice $axis $newpos"2342 SendCmd "$_cutplaneCmd slice $axis $newpos" 2227 2343 } 2228 2344 "tooltip" { … … 2236 2352 } 2237 2353 } 2238 2239 2354 2240 2355 # ---------------------------------------------------------------------- … … 2250 2365 # ---------------------------------------------------------------------- 2251 2366 itcl::body Rappture::VtkVolumeViewer::Combo {option} { 2252 set c $itk_component(view) 2367 set c $itk_component(view) 2253 2368 switch -- $option { 2254 2369 post { … … 2263 2378 } 2264 2379 deactivate { 2265 $c itemconfigure title -fill white2380 $c itemconfigure title -fill $itk_option(-plotforeground) 2266 2381 } 2267 2382 invoke { 2268 $itk_component(field) value _curFldLabel2269 AdjustSetting field2383 $itk_component(field) value $_curFldLabel 2384 AdjustSetting -field 2270 2385 } 2271 2386 default { … … 2275 2390 } 2276 2391 2392 itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } { 2393 array set positions { 2394 front "1 0 0 0" 2395 back "0 0 1 0" 2396 left "0.707107 0 -0.707107 0" 2397 right "0.707107 0 0.707107 0" 2398 top "0.707107 -0.707107 0 0" 2399 bottom "0.707107 0.707107 0 0" 2400 } 2401 foreach name { -qw -qx -qy -qz } value $positions($side) { 2402 set _view($name) $value 2403 } 2404 set q [ViewToQuaternion] 2405 $_arcball quaternion $q 2406 SendCmd "camera orient $q" 2407 SendCmd "camera reset" 2408 set _view(-xpan) 0 2409 set _view(-ypan) 0 2410 set _view(-zoom) 1.0 2411 } 2412 2413 # 2414 # GetDatasetsWithComponent -- 2415 # 2416 # Returns a list of all the datasets (known by the combination of 2417 # their data object and component name) that match the given 2418 # component name. For example, this is used where we want to change 2419 # the settings of volumes that have the current component. 2420 # 2421 itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } { 2422 if { ![info exists _volcomponents($cname)] } { 2423 return "" 2424 } 2425 return $_volcomponents($cname) 2426 }
Note: See TracChangeset
for help on using the changeset viewer.