Changeset 5121 for branches/uq/gui/scripts/vtkimageviewer.tcl
- Timestamp:
- Mar 11, 2015, 10:26:15 AM (10 years ago)
- Location:
- branches/uq
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uq
- Property svn:mergeinfo changed
-
branches/uq/gui/scripts/vtkimageviewer.tcl
r4798 r5121 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: vtkimageviewer - Vtk image viewer … … 58 58 public method get {args} 59 59 public method isconnected {} 60 public method limits3 { dataobj } 61 public method parameters {title args} { 62 # do nothing 60 public method parameters {title args} { 61 # do nothing 63 62 } 64 63 public method scale {args} 65 64 66 protected method Connect {}67 protected method CurrentDatasets {args}68 protected method Disconnect {}69 protected method DoResize {}70 protected method DoRotate {}71 protected method AdjustSetting {what {value ""}}72 protected method AdjustMode {}73 protected method InitSettings { args }74 protected method Pan {option x y}75 protected method Pick {x y}76 protected method Rebuild {}77 protected method ReceiveDataset { args }78 protected method ReceiveImage { args }79 protected method ReceiveLegend { colormap title min max size }80 protected method Rotate {option x y}81 protected method Zoom {option}82 83 65 # The following methods are only used by this class. 66 private method AdjustSetting {what {value ""}} 84 67 private method BuildAxisTab {} 85 68 private method BuildCameraTab {} 86 69 private method BuildColormap { name } 87 70 private method BuildImageTab {} 88 private method BuildDownloadPopup { widget command } 71 private method BuildDownloadPopup { widget command } 89 72 private method Combo { option } 73 private method Connect {} 74 private method CurrentDatasets {args} 75 private method Disconnect {} 76 private method DoResize {} 77 private method DoRotate {} 90 78 private method DrawLegend {} 91 private method EnterLegend { x y } 92 private method EventuallyRequestLegend {} 93 private method EventuallyResize { w h } 94 private method EventuallyRotate { q } 95 private method GetImage { args } 96 private method GetVtkData { args } 97 private method IsValidObject { dataobj } 79 private method EnterLegend { x y } 80 private method EventuallyRequestLegend {} 81 private method EventuallyResize { w h } 82 private method EventuallyRotate { q } 83 private method GetImage { args } 84 private method GetVtkData { args } 85 private method InitSettings { args } 86 private method IsValidObject { dataobj } 98 87 private method LeaveLegend {} 99 private method MotionLegend { x y } 88 private method MotionLegend { x y } 89 private method Pan {option x y} 100 90 private method PanCamera {} 91 private method Pick {x y} 92 private method QuaternionToView { q } { 93 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 94 } 95 private method Rebuild {} 96 private method ReceiveDataset { args } 97 private method ReceiveImage { args } 98 private method ReceiveLegend { colormap title min max size } 101 99 private method RequestLegend {} 100 private method Rotate {option x y} 102 101 private method SetCurrentColormap { color } 103 102 private method SetLegendTip { x y } 104 private method SetObjectStyle { dataobj comp } 103 private method SetObjectStyle { dataobj comp } 105 104 private method SetOrientation { side } 105 private method ViewToQuaternion {} { 106 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 107 } 108 private method Zoom {option} 106 109 107 110 private variable _arcball "" … … 109 112 private variable _obj2datasets 110 113 private variable _obj2ovride ; # maps dataobj => style override 111 private variable _datasets ; # contains all the dataobj-component 114 private variable _datasets ; # contains all the dataobj-component 112 115 ; # datasets in the server 113 116 private variable _colormaps ; # contains all the colormaps … … 125 128 126 129 private variable _click ; # info used for rotate operations 127 private variable _limits ; # Holds overall limits for all dataobjs 130 private variable _limits ; # Holds overall limits for all dataobjs 128 131 # using the viewer. 129 132 private variable _view ; # view params for 3D view … … 150 153 private variable _rotatePending 0 151 154 private variable _legendPending 0 152 private variable _fieldNames {} 153 private variable _fields 155 private variable _fieldNames {} 156 private variable _fields 154 157 private variable _curFldName "" 155 158 private variable _curFldLabel "" … … 197 200 # Initialize the view to some default parameters. 198 201 array set _view { 199 qw 0.36200 qx 0.25201 qy 0.50202 qz 0.70203 zoom 1.0204 xpan0205 ypan0206 ortho0202 -ortho 0 203 -qw 0.36 204 -qx 0.25 205 -qy 0.50 206 -qz 0.70 207 -xpan 0 208 -ypan 0 209 -zoom 1.0 207 210 } 208 211 set _arcball [blt::arcball create 100 100] 209 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 210 $_arcball quaternion $q 212 $_arcball quaternion [ViewToQuaternion] 211 213 212 214 array set _settings { 213 axisFlymode"static"214 axisLabels1215 axisMinorTicks1216 axisVisible1217 axisXGrid 0218 axisYGrid 0219 axisZGrid0220 backingColor white221 backingVisible 1222 colormapDiscrete 0223 field "Default"224 legendVisible0225 level 127.5226 numColors 256227 opacity 100228 outline0229 saveOpacity 100230 stretchToFit0231 view3D0232 window 255.0215 -axisflymode "static" 216 -axislabels 1 217 -axisminorticks 1 218 -axisvisible 1 219 -backingcolor white 220 -backingvisible 1 221 -colormapdiscrete 0 222 -field "Default" 223 -legendvisible 0 224 -level 127.5 225 -numcolors 256 226 -opacity 100 227 -outline 0 228 -saveopacity 100 229 -stretchtofit 0 230 -view3d 0 231 -window 255.0 232 -xgrid 0 233 -ygrid 0 234 -zgrid 0 233 235 } 234 236 array set _changed { 235 opacity0236 colormap0237 -colormap 0 238 -opacity 0 237 239 } 238 240 itk_component add view { … … 241 243 } { 242 244 usual 243 ignore -highlightthickness -borderwidth -background 245 ignore -highlightthickness -borderwidth -background 244 246 } 245 247 … … 247 249 menu $itk_component(plotarea).menu \ 248 250 -relief flat \ 249 -tearoff no 251 -tearoff no 250 252 } { 251 253 usual … … 267 269 268 270 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 269 set _map(cwidth) -1 270 set _map(cheight) -1 271 set _map(cwidth) -1 272 set _map(cheight) -1 271 273 set _map(zoom) 1.0 272 274 set _map(original) "" … … 313 315 -onimage [Rappture::icon surface] \ 314 316 -offimage [Rappture::icon surface] \ 315 -variable [itcl::scope _settings( view3D)] \316 -command [itcl::code $this AdjustSetting view3D] \317 -variable [itcl::scope _settings(-view3d)] \ 318 -command [itcl::code $this AdjustSetting -view3d] \ 317 319 } 318 320 Rappture::Tooltip::for $itk_component(mode) \ … … 324 326 -onimage [Rappture::icon stretchtofit] \ 325 327 -offimage [Rappture::icon stretchtofit] \ 326 -variable [itcl::scope _settings( stretchToFit)] \327 -command [itcl::code $this AdjustSetting stretchToFit] \328 -variable [itcl::scope _settings(-stretchtofit)] \ 329 -command [itcl::code $this AdjustSetting -stretchtofit] \ 328 330 } 329 331 Rappture::Tooltip::for $itk_component(stretchtofit) \ … … 336 338 BuildCameraTab 337 339 } errs] != 0 } { 338 340 global errorInfo 339 341 puts stderr "errs=$errs errorInfo=$errorInfo" 340 342 } 341 343 342 # Hack around the Tk panewindow. The problem is that the requested 344 # Hack around the Tk panewindow. The problem is that the requested 343 345 # size of the 3d view isn't set until an image is retrieved from 344 346 # the server. So the panewindow uses the tiny size. … … 346 348 pack forget $itk_component(view) 347 349 blt::table $itk_component(plotarea) \ 348 0,0 $itk_component(view) -fill both -reqwidth $w 350 0,0 $itk_component(view) -fill both -reqwidth $w 349 351 blt::table configure $itk_component(plotarea) c1 -resize none 350 352 … … 430 432 431 433 itcl::body Rappture::VtkImageViewer::DoRotate {} { 432 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 433 SendCmd "camera orient $q" 434 SendCmd "camera orient [ViewToQuaternion]" 434 435 set _rotatePending 0 435 436 } … … 455 456 456 457 itcl::body Rappture::VtkImageViewer::EventuallyRotate { q } { 457 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break458 QuaternionToView $q 458 459 if { !$_rotatePending } { 459 460 set _rotatePending 1 460 global rotate_delay 461 global rotate_delay 461 462 $_dispatcher event -after $rotate_delay !rotate 462 463 } … … 557 558 continue 558 559 } 559 if {[info exists _obj2ovride($dataobj-raise)] && 560 if {[info exists _obj2ovride($dataobj-raise)] && 560 561 $_obj2ovride($dataobj-raise)} { 561 562 set dlist [linsert $dlist 0 $dataobj] … … 585 586 } 586 587 return $dlist 587 } 588 } 588 589 -image { 589 590 if {[llength $args] != 2} { … … 605 606 } 606 607 607 # 608 # 608 609 # scale -- 609 610 # 610 611 # This gets called either incrementally as new simulations are 611 612 # added or all at once as a sequence of images. 612 # This accounts for all objects--even those not showing on the 613 # screen. Because of this, the limits are appropriate for all 613 # This accounts for all objects--even those not showing on the 614 # screen. Because of this, the limits are appropriate for all 614 615 # objects as the user scans through data in the ResultSet viewer. 615 616 # … … 654 655 } 655 656 if { [array size found] > 1 } { 656 set _settings( stretchToFit) 1657 set _settings(-stretchtofit) 1 657 658 } else { 658 659 # Check if the range of the x and y axes requires that we stretch … … 663 664 if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) || 664 665 ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } { 665 set _settings( stretchToFit) 1666 set _settings(-stretchtofit) 1 666 667 } 667 668 } … … 803 804 $_dispatcher cancel !legend 804 805 # disconnected -- no more data sitting on server 805 array unset _datasets 806 array unset _data 807 array unset _colormaps 808 array unset _obj2datasets 806 array unset _datasets 807 array unset _data 808 array unset _colormaps 809 array unset _obj2datasets 809 810 global readyForNextFrame 810 811 set readyForNextFrame 1 … … 830 831 if { $info(-type) == "image" } { 831 832 if 0 { 832 set f [open "last.ppm" "w"] 833 puts $f $bytes 833 set f [open "last.ppm" "w"] 834 fconfigure $f -encoding binary 835 puts -nonewline $f $bytes 834 836 close $f 835 837 } … … 837 839 set time [clock seconds] 838 840 set date [clock format $time] 839 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 841 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 840 842 if { $_start > 0 } { 841 843 set finish [clock clicks -milliseconds] … … 908 910 # Turn on buffering of commands to the server. We don't want to 909 911 # be preempted by a server disconnect/reconnect (which automatically 910 # generates a new call to Rebuild). 912 # generates a new call to Rebuild). 911 913 StartBufferingCommands 912 914 913 915 if { $_width != $w || $_height != $h || $_reset } { 914 915 916 917 918 if { $_settings(stretchToFit) } {919 AdjustSettingstretchToFit920 916 set _width $w 917 set _height $h 918 $_arcball resize $w $h 919 DoResize 920 if { $_settings(-stretchtofit) } { 921 AdjustSetting -stretchToFit 922 } 921 923 } 922 924 if { $_reset } { 923 # 924 # Reset the camera and other view parameters 925 # 926 InitSettings view3D background 927 928 # Let's see how this goes. I think it's preferable to overloading the 929 # axis title with the exponent. 930 SendCmd "axis exp 0 0 0 1" 931 932 SendCmd "axis lrot z 90" 933 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 934 $_arcball quaternion $q 935 if {$_settings(view3D) } { 936 if { $_view(ortho)} { 925 # 926 # Reset the camera and other view parameters 927 # 928 InitSettings -view3d -background 929 930 SendCmd "axis lrot z 90" 931 $_arcball quaternion [ViewToQuaternion] 932 if {$_settings(-view3d) } { 933 if { $_view(-ortho)} { 937 934 SendCmd "camera mode ortho" 938 935 } else { … … 941 938 DoRotate 942 939 SendCmd "camera reset" 943 944 940 } 941 PanCamera 945 942 StopBufferingCommands 946 943 SendCmd "imgflush" … … 960 957 if { ![info exists _datasets($tag)] } { 961 958 set bytes [$dataobj vtkdata $comp] 962 if 0 { 959 if 0 { 963 960 set f [open /tmp/vtkimage.vtk "w"] 964 puts $f $bytes 961 fconfigure $f -translation binary -encoding binary 962 puts -nonewline $f $bytes 965 963 close $f 966 964 } 967 965 set length [string length $bytes] 968 966 if { $_reportClientInfo } { 969 967 set info {} 970 lappend info "tool_id" [$dataobj hints toolId] 971 lappend info "tool_name" [$dataobj hints toolName] 972 lappend info "tool_version" [$dataobj hints toolRevision] 973 lappend info "tool_title" [$dataobj hints toolTitle] 968 lappend info "tool_id" [$dataobj hints toolid] 969 lappend info "tool_name" [$dataobj hints toolname] 970 lappend info "tool_title" [$dataobj hints tooltitle] 971 lappend info "tool_command" [$dataobj hints toolcommand] 972 lappend info "tool_revision" [$dataobj hints toolrevision] 974 973 lappend info "dataset_label" [$dataobj hints label] 975 974 lappend info "dataset_size" $length 976 975 lappend info "dataset_tag" $tag 977 SendCmd [list "clientinfo" $info]976 SendCmd "clientinfo [list $info]" 978 977 } 979 978 SendCmd "dataset add $tag data follows $length" … … 991 990 } 992 991 if { $_first != "" } { 993 994 995 992 $itk_component(field) choices delete 0 end 993 $itk_component(fieldmenu) delete 0 end 994 array unset _fields 996 995 set _curFldName "" 997 996 foreach cname [$_first components] { … … 1019 1018 $itk_component(field) value $_curFldLabel 1020 1019 } 1021 InitSettings stretchToFitoutline1020 InitSettings -stretchtofit -outline 1022 1021 1023 1022 if { $_reset } { 1024 1023 SendCmd "axis tickpos outside" 1025 1024 #SendCmd "axis lformat all %g" 1026 1027 1025 1026 foreach axis { x y z } { 1028 1027 set label [$_first hints ${axis}label] 1029 if { $label == "" } { 1030 set label [string toupper $axis] 1031 } 1032 # May be a space in the axis label. 1033 SendCmd [list axis name $axis $label] 1034 1035 if {$axis == "z" && [$_first hints ${axis}units] == ""} { 1036 set units [lindex $_fields($_curFldName) 1] 1037 } else { 1038 set units [$_first hints ${axis}units] 1039 } 1040 if { $units != "" } { 1041 # May be a space in the axis units. 1042 SendCmd [list axis units $axis $units] 1043 } 1044 } 1045 # 1046 # Reset the camera and other view parameters 1047 # 1048 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1049 $_arcball quaternion $q 1050 if {$_settings(view3D) } { 1051 if { $_view(ortho)} { 1028 if { $label == "" } { 1029 set label [string toupper $axis] 1030 } 1031 # May be a space in the axis label. 1032 SendCmd [list axis name $axis $label] 1033 1034 if {$axis == "z" && [$_first hints ${axis}units] == ""} { 1035 if {$_curFldName != ""} { 1036 set units [lindex $_fields($_curFldName) 1] 1037 } 1038 } else { 1039 set units [$_first hints ${axis}units] 1040 } 1041 if { $units != "" } { 1042 # May be a space in the axis units. 1043 SendCmd [list axis units $axis $units] 1044 } 1045 } 1046 # 1047 # Reset the camera and other view parameters 1048 # 1049 $_arcball quaternion [ViewToQuaternion] 1050 if {$_settings(-view3d) } { 1051 if { $_view(-ortho)} { 1052 1052 SendCmd "camera mode ortho" 1053 1053 } else { … … 1057 1057 SendCmd "camera reset" 1058 1058 } 1059 1060 InitSettings axisXGrid axisYGrid axisZGrid \1061 axisVisible axisLabels field view3D 1059 PanCamera 1060 InitSettings -xgrid -ygrid -zgrid \ 1061 -axisvisible -axislabels -field -view3d 1062 1062 if { [array size _fields] < 2 } { 1063 catch { 1064 blt::table forget $itk_component(field) $itk_component(field_l) 1065 } 1063 catch {blt::table forget $itk_component(field) $itk_component(field_l)} 1066 1064 } 1067 1065 RequestLegend … … 1069 1067 } 1070 1068 global readyForNextFrame 1071 set readyForNextFrame 0; 1069 set readyForNextFrame 0; # Don't advance to the next frame 1072 1070 1073 1071 # Actually write the commands to the server socket. If it fails, we don't … … 1087 1085 itcl::body Rappture::VtkImageViewer::CurrentDatasets {args} { 1088 1086 set flag [lindex $args 0] 1089 switch -- $flag { 1087 switch -- $flag { 1090 1088 "-all" { 1091 1089 if { [llength $args] > 1 } { … … 1106 1104 set dlist [get -visible] 1107 1105 } 1108 } 1106 } 1109 1107 default { 1110 1108 set dlist $args … … 1134 1132 switch -- $option { 1135 1133 "in" { 1136 set _view( zoom) [expr {$_view(zoom)*1.25}]1137 SendCmd "camera zoom $_view( zoom)"1134 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1135 SendCmd "camera zoom $_view(-zoom)" 1138 1136 } 1139 1137 "out" { 1140 set _view( zoom) [expr {$_view(zoom)*0.8}]1141 SendCmd "camera zoom $_view( zoom)"1138 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1139 SendCmd "camera zoom $_view(-zoom)" 1142 1140 } 1143 1141 "reset" { 1144 1142 array set _view { 1145 qw 0.361146 qx 0.251147 qy 0.501148 qz 0.701149 zoom 1.01150 xpan 01151 ypan 01143 -qw 0.36 1144 -qx 0.25 1145 -qy 0.50 1146 -qz 0.70 1147 -xpan 0 1148 -ypan 0 1149 -zoom 1.0 1152 1150 } 1153 1151 if { $_first != "" } { … … 1157 1155 } 1158 1156 } 1159 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1160 $_arcball quaternion $q 1161 if {$_settings(view3D) } { 1157 $_arcball quaternion [ViewToQuaternion] 1158 if {$_settings(-view3d) } { 1162 1159 DoRotate 1163 1160 } … … 1168 1165 1169 1166 itcl::body Rappture::VtkImageViewer::PanCamera {} { 1170 set x $_view( xpan)1171 set y $_view( ypan)1167 set x $_view(-xpan) 1168 set y $_view(-ypan) 1172 1169 SendCmd "camera pan $x $y" 1173 1170 } … … 1229 1226 foreach tag [CurrentDatasets -visible] { 1230 1227 SendCmd "dataset getscalar pixel $x $y $tag" 1231 } 1228 } 1232 1229 } 1233 1230 … … 1247 1244 set x [expr $x / double($w)] 1248 1245 set y [expr $y / double($h)] 1249 set _view( xpan) [expr $_view(xpan) + $x]1250 set _view( ypan) [expr $_view(ypan) + $y]1246 set _view(-xpan) [expr $_view(-xpan) + $x] 1247 set _view(-ypan) [expr $_view(-ypan) + $y] 1251 1248 PanCamera 1252 1249 return … … 1270 1267 set _click(x) $x 1271 1268 set _click(y) $y 1272 set _view( xpan) [expr $_view(xpan) - $dx]1273 set _view( ypan) [expr $_view(ypan) - $dy]1269 set _view(-xpan) [expr $_view(-xpan) - $dx] 1270 set _view(-ypan) [expr $_view(-ypan) - $dy] 1274 1271 PanCamera 1275 1272 } … … 1293 1290 itcl::body Rappture::VtkImageViewer::InitSettings { args } { 1294 1291 foreach spec $args { 1295 if { [info exists _settings($_first -$spec)] } {1292 if { [info exists _settings($_first${spec})] } { 1296 1293 # Reset global setting with dataobj specific setting 1297 set _settings($spec) $_settings($_first -$spec)1294 set _settings($spec) $_settings($_first${spec}) 1298 1295 } 1299 1296 AdjustSetting $spec … … 1313 1310 } 1314 1311 switch -- $what { 1315 " axisFlymode" {1312 "-axisflymode" { 1316 1313 set mode [$itk_component(axisflymode) value] 1317 1314 set mode [$itk_component(axisflymode) translate $mode] … … 1319 1316 SendCmd "axis flymode $mode" 1320 1317 } 1321 " axisLabels" {1318 "-axislabels" { 1322 1319 set bool $_settings($what) 1323 1320 SendCmd "axis labels all $bool" 1324 1321 } 1325 " axisMinorTicks" {1322 "-axisminorticks" { 1326 1323 set bool $_settings($what) 1327 1324 SendCmd "axis minticks all $bool" 1328 1325 } 1329 " axisVisible" {1326 "-axisvisible" { 1330 1327 set bool $_settings($what) 1331 1328 SendCmd "axis visible all $bool" 1332 1329 } 1333 "axisXGrid" - "axisYGrid" - "axisZGrid" { 1334 set axis [string tolower [string range $what 4 4]] 1335 set bool $_settings($what) 1336 SendCmd "axis grid $axis $bool" 1337 } 1338 "background" { 1330 "-background" { 1339 1331 set bg [$itk_component(background) value] 1340 1341 1342 1343 "grey""black"1344 1332 array set fgcolors { 1333 "black" "white" 1334 "white" "black" 1335 "grey" "black" 1336 } 1345 1337 set fg $fgcolors($bg) 1346 1338 configure -plotbackground $bg -plotforeground $fg 1347 1339 $itk_component(view) delete "legend" 1348 1340 SendCmd "screen bgcolor [Color2RGB $bg]" 1349 1341 SendCmd "outline color [Color2RGB $fg]" 1350 1342 SendCmd "axis color all [Color2RGB $fg]" 1351 1352 } 1353 " backingColor" {1343 DrawLegend 1344 } 1345 "-backingcolor" { 1354 1346 set color [$itk_component(backingcolor) value] 1355 1356 if { $_settings(backingVisible) } {1357 1358 set _settings(backingVisible) 01359 1360 1361 if { !$_settings(backingVisible) } {1362 1363 set _settings(backingVisible) 11364 1365 1366 1367 } 1368 " backingVisible" {1369 1347 if { $color == "none" } { 1348 if { $_settings(-backingvisible) } { 1349 SendCmd "image backing 0" 1350 set _settings(-backingvisible) 0 1351 } 1352 } else { 1353 if { !$_settings(-backingvisible) } { 1354 SendCmd "image backing 1" 1355 set _settings(-backingvisible) 1 1356 } 1357 SendCmd "image color [Color2RGB $color]" 1358 } 1359 } 1360 "-backingvisible" { 1361 set bool $_settings($what) 1370 1362 SendCmd "image backing $bool" 1371 1363 } 1372 " colormap" {1364 "-colormap" { 1373 1365 set _changed($what) 1 1374 1366 StartBufferingCommands … … 1376 1368 set _settings($what) $color 1377 1369 SetCurrentColormap $color 1378 if {$_settings( colormapDiscrete)} {1379 SendCmd "colormap res $_settings( numColors) $color"1370 if {$_settings(-colormapdiscrete)} { 1371 SendCmd "colormap res $_settings(-numcolors) $color" 1380 1372 } 1381 1373 StopBufferingCommands 1382 1383 } 1384 " colormapDiscrete" {1374 EventuallyRequestLegend 1375 } 1376 "-colormapdiscrete" { 1385 1377 set bool $_settings($what) 1386 1378 StartBufferingCommands 1387 1379 if {$bool} { 1388 SendCmd "colormap res $_settings( numColors)"1380 SendCmd "colormap res $_settings(-numcolors)" 1389 1381 } else { 1390 1382 SendCmd "colormap res default" … … 1393 1385 EventuallyRequestLegend 1394 1386 } 1395 " field" {1387 "-field" { 1396 1388 set label [$itk_component(field) value] 1397 1389 set fname [$itk_component(field) translate $label] … … 1417 1409 DrawLegend 1418 1410 } 1419 " view3D" {1420 1411 "-view3d" { 1412 set bool $_settings($what) 1421 1413 set c $itk_component(view) 1422 1414 StartBufferingCommands 1423 1415 # Fix image scale: 0 for contours, 1 for images. 1424 1416 if { $bool } { 1425 set _settings( opacity) $_settings(saveOpacity)1417 set _settings(-opacity) $_settings(-saveopacity) 1426 1418 } else { 1427 set _settings( opacity) 1001428 } 1429 AdjustSetting opacity1430 1431 1432 1433 if {$_view( ortho)} {1419 set _settings(-opacity) 100 1420 } 1421 AdjustSetting -opacity 1422 if { $bool } { 1423 $itk_component(opacity) configure -state normal 1424 $itk_component(opacity_l) configure -state normal 1425 if {$_view(-ortho)} { 1434 1426 SendCmd "camera mode ortho" 1435 1427 } else { … … 1437 1429 } 1438 1430 SendCmd "camera aspect native" 1439 1440 1441 1431 } else { 1432 $itk_component(opacity) configure -state disabled 1433 $itk_component(opacity_l) configure -state disabled 1442 1434 SendCmd "camera mode image" 1443 if {$_settings( stretchToFit)} {1435 if {$_settings(-stretchtofit)} { 1444 1436 SendCmd "camera aspect window" 1445 1437 } 1446 1438 } 1447 1439 if { $bool } { 1448 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1440 set q [ViewToQuaternion] 1449 1441 $_arcball quaternion $q 1450 SendCmd "camera orient $q" 1442 SendCmd "camera orient $q" 1451 1443 } else { 1452 1444 bind $c <ButtonPress-1> {} … … 1455 1447 } 1456 1448 SendCmd "camera reset" 1457 # Fix the mouse bindings for rotation/panning and the 1449 # Fix the mouse bindings for rotation/panning and the 1458 1450 # camera mode. Ideally we'd create a bindtag for these. 1459 1451 if { $bool } { … … 1468 1460 StopBufferingCommands 1469 1461 } 1470 " window" {1462 "-window" { 1471 1463 set val $_settings($what) 1472 1464 SendCmd "image window $val" 1473 1465 } 1474 " level" {1466 "-level" { 1475 1467 set val $_settings($what) 1476 1468 SendCmd "image level $val" 1477 1469 } 1478 " legendVisible" {1470 "-legendvisible" { 1479 1471 if { !$_settings($what) } { 1480 1481 1482 1483 } 1484 " opacity" {1472 $itk_component(view) delete legend 1473 } 1474 DrawLegend 1475 } 1476 "-opacity" { 1485 1477 set _changed($what) 1 1486 if { $_settings(view3D) } {1487 set _settings( saveOpacity) $_settings($what)1478 if { $_settings(-view3d) } { 1479 set _settings(-saveopacity) $_settings($what) 1488 1480 set val [expr $_settings($what) * 0.01] 1489 1481 SendCmd "image opacity $val" 1490 1482 } else { 1491 1492 } 1493 } 1494 " outline" {1483 SendCmd "image opacity 1.0" 1484 } 1485 } 1486 "-outline" { 1495 1487 set bool $_settings($what) 1496 1488 SendCmd "outline visible $bool" 1497 } 1498 "stretchToFit" { 1499 set bool $_settings($what) 1500 if { $bool } { 1501 if { $_settings(view3D) } { 1502 SendCmd "camera aspect native" 1503 } else { 1504 SendCmd "camera aspect window" 1505 } 1506 } else { 1507 SendCmd "camera aspect native" 1508 } 1509 } 1510 default { 1489 } 1490 "-stretchtofit" { 1491 set bool $_settings($what) 1492 if { $bool } { 1493 if { $_settings(-view3d) } { 1494 SendCmd "camera aspect native" 1495 } else { 1496 SendCmd "camera aspect window" 1497 } 1498 } else { 1499 SendCmd "camera aspect native" 1500 } 1501 } 1502 "-xgrid" - "-ygrid" - "-zgrid" { 1503 set axis [string tolower [string range $what 1 1]] 1504 set bool $_settings($what) 1505 SendCmd "axis grid $axis $bool" 1506 } 1507 default { 1511 1508 error "don't know how to fix $what" 1512 1509 } … … 1518 1515 # 1519 1516 # Request a new legend from the server. The size of the legend 1520 # is determined from the height of the canvas. 1517 # is determined from the height of the canvas. 1521 1518 # 1522 1519 # This should be called when 1523 # 1524 # 1525 # 1526 # 1527 # 1520 # 1. A new current colormap is set. 1521 # 2. Window is resized. 1522 # 3. The limits of the data have changed. (Just need a redraw). 1523 # 4. Number of isolines have changed. (Just need a redraw). 1524 # 5. Legend becomes visible (Just need a redraw). 1528 1525 # 1529 1526 itcl::body Rappture::VtkImageViewer::RequestLegend {} { … … 1532 1529 set w 12 1533 1530 set lineht [font metrics $font -linespace] 1534 # color ramp height = (canvas height) - (min and max value lines) - 2 1531 # color ramp height = (canvas height) - (min and max value lines) - 2 1535 1532 set h [expr {$_height - 2 * ($lineht + 2)}] 1536 1533 set _legendHeight $h … … 1538 1535 set fname $_curFldName 1539 1536 if { [string match "component*" $fname] } { 1540 1537 set title "" 1541 1538 } else { 1542 1543 1544 1545 1546 1547 1548 1549 1539 if { [info exists _fields($fname)] } { 1540 foreach { title units } $_fields($fname) break 1541 if { $units != "" } { 1542 set title [format "%s (%s)" $title $units] 1543 } 1544 } else { 1545 set title $fname 1546 } 1550 1547 } 1551 1548 # If there's a title too, substract one more line 1552 1549 if { $title != "" } { 1553 incr h -$lineht 1550 incr h -$lineht 1554 1551 } 1555 1552 if { $h < 1 } { … … 1558 1555 # Set the legend on the first image dataset. 1559 1556 if { $_currentColormap != "" && $_currentColormap != "none" } { 1560 SendCmd "legend $_currentColormap scalar $_curFldName {} $w $h 0" 1557 #SendCmd "legend $_currentColormap scalar $_curFldName {} $w $h 0" 1558 SendCmd "legend2 $_currentColormap $w $h" 1561 1559 } 1562 1560 } … … 1568 1566 # Keep track of the colormaps that we build. 1569 1567 if { $name != "none" && ![info exists _colormaps($name)] } { 1570 BuildColormap $name 1568 BuildColormap $name 1571 1569 set _colormaps($name) 1 1572 1570 } … … 1595 1593 itcl::configbody Rappture::VtkImageViewer::mode { 1596 1594 switch -- $itk_option(-mode) { 1597 1598 set _settings(view3D) 11599 1600 1601 set _settings(view3D) 01602 } 1603 1604 1605 1595 "volume" { 1596 set _settings(-view3d) 1 1597 } 1598 "vtkimage" { 1599 set _settings(-view3d) 0 1600 } 1601 default { 1602 error "unknown mode settings \"$itk_option(-mode)\"" 1603 } 1606 1604 } 1607 1605 if { !$_reset } { 1608 AdjustSetting view3D1606 AdjustSetting -view3d 1609 1607 } 1610 1608 } … … 1619 1617 SendCmd "screen bgcolor $rgb" 1620 1618 } 1621 1619 $itk_component(view) configure -background $itk_option(-plotbackground) 1622 1620 } 1623 1621 } … … 1630 1628 set rgb [Color2RGB $itk_option(-plotforeground)] 1631 1629 if { !$_reset } { 1630 SendCmd "axis color all $rgb" 1632 1631 SendCmd "outline color $rgb" 1633 SendCmd "axis color all $rgb" 1634 } 1635 } 1636 } 1637 1638 itcl::body Rappture::VtkImageViewer::limits3 { dataobj } { 1639 lappend limits x [$dataobj limits x] 1640 lappend limits y [$dataobj limits y] 1641 if { [catch { $dataobj limits $_curFldName } vlim] != 0 } { 1642 set vlim [$dataobj limits v] 1643 } 1644 lappend limits v $vlim 1645 return $limits 1632 } 1633 } 1646 1634 } 1647 1635 … … 1658 1646 checkbutton $inner.legend \ 1659 1647 -text "Legend" \ 1660 -variable [itcl::scope _settings( legendVisible)] \1661 -command [itcl::code $this AdjustSetting legendVisible] \1648 -variable [itcl::scope _settings(-legendvisible)] \ 1649 -command [itcl::code $this AdjustSetting -legendvisible] \ 1662 1650 -font "Arial 9" 1663 1651 1664 1652 checkbutton $inner.outline \ 1665 1653 -text "Outline" \ 1666 -variable [itcl::scope _settings( outline)] \1667 -command [itcl::code $this AdjustSetting outline] \1654 -variable [itcl::scope _settings(-outline)] \ 1655 -command [itcl::code $this AdjustSetting -outline] \ 1668 1656 -font "Arial 9" 1669 1657 1670 1658 checkbutton $inner.backing \ 1671 1659 -text "Backing" \ 1672 -variable [itcl::scope _settings( backingVisible)] \1673 -command [itcl::code $this AdjustSetting backingVisible] \1660 -variable [itcl::scope _settings(-backingvisible)] \ 1661 -command [itcl::code $this AdjustSetting -backingvisible] \ 1674 1662 -font "Arial 9" 1675 1663 1676 1664 checkbutton $inner.stretch \ 1677 1665 -text "Stretch to fit" \ 1678 -variable [itcl::scope _settings( stretchToFit)] \1679 -command [itcl::code $this AdjustSetting stretchToFit] \1666 -variable [itcl::scope _settings(-stretchtofit)] \ 1667 -command [itcl::code $this AdjustSetting -stretchtofit] \ 1680 1668 -font "Arial 9" 1681 1669 1682 1670 checkbutton $inner.colormapDiscrete \ 1683 1671 -text "Discrete Colormap" \ 1684 -variable [itcl::scope _settings( colormapDiscrete)] \1685 -command [itcl::code $this AdjustSetting colormapDiscrete] \1672 -variable [itcl::scope _settings(-colormapdiscrete)] \ 1673 -command [itcl::code $this AdjustSetting -colormapdiscrete] \ 1686 1674 -font "Arial 9" 1687 1675 1688 1676 itk_component add field_l { 1689 label $inner.field_l -text "Field" -font "Arial 9" 1677 label $inner.field_l -text "Field" -font "Arial 9" 1690 1678 } { 1691 1679 ignore -font … … 1695 1683 } 1696 1684 bind $inner.field <<Value>> \ 1697 [itcl::code $this AdjustSetting field]1698 1699 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1685 [itcl::code $this AdjustSetting -field] 1686 1687 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1700 1688 itk_component add colormap { 1701 1689 Rappture::Combobox $inner.colormap -width 10 -editable no … … 1705 1693 $itk_component(colormap) value "BCGYR" 1706 1694 bind $inner.colormap <<Value>> \ 1707 [itcl::code $this AdjustSetting colormap]1708 1709 label $inner.backingcolor_l -text "Backing Color" -font "Arial 9" 1695 [itcl::code $this AdjustSetting -colormap] 1696 1697 label $inner.backingcolor_l -text "Backing Color" -font "Arial 9" 1710 1698 itk_component add backingcolor { 1711 1699 Rappture::Combobox $inner.backingcolor -width 10 -editable no … … 1721 1709 "red" "red" \ 1722 1710 "white" "white" \ 1723 "none""none"1724 1725 $itk_component(backingcolor) value "white"1711 "none" "none" 1712 1713 $itk_component(backingcolor) value $_settings(-backingcolor) 1726 1714 bind $inner.backingcolor <<Value>> \ 1727 [itcl::code $this AdjustSetting backingColor]1728 1729 label $inner.background_l -text "Background Color" -font "Arial 9" 1715 [itcl::code $this AdjustSetting -backingcolor] 1716 1717 label $inner.background_l -text "Background Color" -font "Arial 9" 1730 1718 itk_component add background { 1731 1719 Rappture::Combobox $inner.background -width 10 -editable no … … 1734 1722 "black" "black" \ 1735 1723 "white" "white" \ 1736 "grey" "grey" 1724 "grey" "grey" 1737 1725 1738 1726 $itk_component(background) value "white" 1739 bind $inner.background <<Value>> [itcl::code $this AdjustSetting background] 1727 bind $inner.background <<Value>> \ 1728 [itcl::code $this AdjustSetting -background] 1740 1729 1741 1730 itk_component add opacity_l { … … 1746 1735 itk_component add opacity { 1747 1736 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1748 -variable [itcl::scope _settings( opacity)] \1737 -variable [itcl::scope _settings(-opacity)] \ 1749 1738 -showvalue off \ 1750 -command [itcl::code $this AdjustSetting opacity]1739 -command [itcl::code $this AdjustSetting -opacity] 1751 1740 } 1752 1741 … … 1758 1747 itk_component add window { 1759 1748 ::scale $inner.window -from 0 -to 255 -orient horizontal \ 1760 -variable [itcl::scope _settings( window)] \1749 -variable [itcl::scope _settings(-window)] \ 1761 1750 -showvalue off \ 1762 -command [itcl::code $this AdjustSetting window]1751 -command [itcl::code $this AdjustSetting -window] 1763 1752 } 1764 1753 itk_component add level_l { … … 1769 1758 itk_component add level { 1770 1759 ::scale $inner.level -from 0 -to 255 -orient horizontal \ 1771 -variable [itcl::scope _settings( level)] \1760 -variable [itcl::scope _settings(-level)] \ 1772 1761 -showvalue off \ 1773 -command [itcl::code $this AdjustSetting level]1762 -command [itcl::code $this AdjustSetting -level] 1774 1763 } 1775 1764 … … 1784 1773 2,0 $inner.backingcolor_l -anchor w -pady 2 \ 1785 1774 2,1 $inner.backingcolor -anchor w -pady 2 -fill x \ 1786 1787 1775 3,0 $inner.background_l -anchor w -pady 2 \ 1776 3,1 $inner.background -anchor w -pady 2 -fill x \ 1788 1777 4,0 $inner.backing -anchor w -pady 2 -cspan 2 \ 1789 1778 5,0 $inner.stretch -anchor w -pady 2 -cspan 2 \ … … 1798 1787 16,1 $inner.window -fill x -pady 2 \ 1799 1788 17,0 $inner.level_l -anchor w -pady 2 \ 1800 17,1 $inner.level -fill x -pady 2 1789 17,1 $inner.level -fill x -pady 2 1801 1790 1802 1791 blt::table configure $inner r* c* -resize none … … 1816 1805 checkbutton $inner.visible \ 1817 1806 -text "Axes" \ 1818 -variable [itcl::scope _settings( axisVisible)] \1819 -command [itcl::code $this AdjustSetting axisVisible] \1807 -variable [itcl::scope _settings(-axisvisible)] \ 1808 -command [itcl::code $this AdjustSetting -axisvisible] \ 1820 1809 -font "Arial 9" 1821 1810 checkbutton $inner.labels \ 1822 1811 -text "Axis Labels" \ 1823 -variable [itcl::scope _settings( axisLabels)] \1824 -command [itcl::code $this AdjustSetting axisLabels] \1812 -variable [itcl::scope _settings(-axislabels)] \ 1813 -command [itcl::code $this AdjustSetting -axislabels] \ 1825 1814 -font "Arial 9" 1826 label $inner.grid_l -text "Grid" -font "Arial 9" 1815 label $inner.grid_l -text "Grid" -font "Arial 9" 1827 1816 checkbutton $inner.xgrid \ 1828 1817 -text "X" \ 1829 -variable [itcl::scope _settings( axisXGrid)] \1830 -command [itcl::code $this AdjustSetting axisXGrid] \1818 -variable [itcl::scope _settings(-xgrid)] \ 1819 -command [itcl::code $this AdjustSetting -xgrid] \ 1831 1820 -font "Arial 9" 1832 1821 checkbutton $inner.ygrid \ 1833 1822 -text "Y" \ 1834 -variable [itcl::scope _settings( axisYGrid)] \1835 -command [itcl::code $this AdjustSetting axisYGrid] \1823 -variable [itcl::scope _settings(-ygrid)] \ 1824 -command [itcl::code $this AdjustSetting -ygrid] \ 1836 1825 -font "Arial 9" 1837 1826 checkbutton $inner.zgrid \ 1838 1827 -text "Z" \ 1839 -variable [itcl::scope _settings( axisZGrid)] \1840 -command [itcl::code $this AdjustSetting axisZGrid] \1828 -variable [itcl::scope _settings(-zgrid)] \ 1829 -command [itcl::code $this AdjustSetting -zgrid] \ 1841 1830 -font "Arial 9" 1842 1831 checkbutton $inner.minorticks \ 1843 1832 -text "Minor Ticks" \ 1844 -variable [itcl::scope _settings( axisMinorTicks)] \1845 -command [itcl::code $this AdjustSetting axisMinorTicks] \1833 -variable [itcl::scope _settings(-axisminorticks)] \ 1834 -command [itcl::code $this AdjustSetting -axisminorticks] \ 1846 1835 -font "Arial 9" 1847 1836 1848 label $inner.mode_l -text "Mode" -font "Arial 9" 1837 label $inner.mode_l -text "Mode" -font "Arial 9" 1849 1838 1850 1839 itk_component add axisflymode { … … 1855 1844 "closest_triad" "closest" \ 1856 1845 "furthest_triad" "farthest" \ 1857 "outer_edges" "outer" 1858 $itk_component(axisflymode) value "static"1859 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlymode]1846 "outer_edges" "outer" 1847 $itk_component(axisflymode) value $_settings(-axisflymode) 1848 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode] 1860 1849 1861 1850 blt::table $inner \ … … 1863 1852 1,0 $inner.labels -anchor w -cspan 4 \ 1864 1853 2,0 $inner.minorticks -anchor w -cspan 4 \ 1865 1854 4,0 $inner.grid_l -anchor w \ 1866 1855 4,1 $inner.xgrid -anchor w \ 1867 1856 4,2 $inner.ygrid -anchor w \ 1868 1857 4,3 $inner.zgrid -anchor w \ 1869 1858 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1870 5,1 $inner.mode -fill x -cspan 3 1859 5,1 $inner.mode -fill x -cspan 3 1871 1860 1872 1861 blt::table configure $inner r* c* -resize none … … 1874 1863 blt::table configure $inner r3 -height 0.125i 1875 1864 } 1876 1877 1865 1878 1866 itcl::body Rappture::VtkImageViewer::BuildCameraTab {} { … … 1894 1882 0,0 $inner.view_l -anchor e -pady 2 \ 1895 1883 0,1 $inner.view -anchor w -pady 2 1884 blt::table configure $inner r0 -resize none 1896 1885 1897 1886 set labels { qx qy qz qw xpan ypan zoom } … … 1900 1889 label $inner.${tag}label -text $tag -font "Arial 9" 1901 1890 entry $inner.${tag} -font "Arial 9" -bg white \ 1902 -textvariable [itcl::scope _view( $tag)]1891 -textvariable [itcl::scope _view(-$tag)] 1903 1892 bind $inner.${tag} <Return> \ 1904 [itcl::code $this camera set ${tag}]1893 [itcl::code $this camera set -${tag}] 1905 1894 bind $inner.${tag} <KP_Enter> \ 1906 [itcl::code $this camera set ${tag}]1895 [itcl::code $this camera set -${tag}] 1907 1896 blt::table $inner \ 1908 1897 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1913 1902 checkbutton $inner.ortho \ 1914 1903 -text "Orthographic Projection" \ 1915 -variable [itcl::scope _view( ortho)] \1916 -command [itcl::code $this camera set ortho] \1904 -variable [itcl::scope _view(-ortho)] \ 1905 -command [itcl::code $this camera set -ortho] \ 1917 1906 -font "Arial 9" 1918 1907 blt::table $inner \ … … 1921 1910 incr row 1922 1911 1923 blt::table configure $inner c* r*-resize none1912 blt::table configure $inner c* -resize none 1924 1913 blt::table configure $inner c2 -resize expand 1925 1914 blt::table configure $inner r$row -resize expand … … 1927 1916 1928 1917 # 1929 # camera -- 1918 # camera -- 1930 1919 # 1931 1920 itcl::body Rappture::VtkImageViewer::camera {option args} { 1932 switch -- $option { 1921 switch -- $option { 1933 1922 "show" { 1934 1923 puts [array get _view] 1935 1924 } 1936 1925 "set" { 1937 set wh o[lindex $args 0]1938 set x $_view($wh o)1926 set what [lindex $args 0] 1927 set x $_view($what) 1939 1928 set code [catch { string is double $x } result] 1940 1929 if { $code != 0 || !$result } { 1941 1930 return 1942 1931 } 1943 switch -- $wh o{1944 " ortho" {1945 if {$_view( ortho)} {1932 switch -- $what { 1933 "-ortho" { 1934 if {$_view($what)} { 1946 1935 SendCmd "camera mode ortho" 1947 1936 } else { … … 1949 1938 } 1950 1939 } 1951 " xpan" - "ypan" {1940 "-xpan" - "-ypan" { 1952 1941 PanCamera 1953 1942 } 1954 " qx" - "qy" - "qz" - "qw" {1955 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1943 "-qx" - "-qy" - "-qz" - "-qw" { 1944 set q [ViewToQuaternion] 1956 1945 $_arcball quaternion $q 1957 1946 EventuallyRotate $q 1958 1947 } 1959 " zoom" {1960 SendCmd "camera zoom $_view( zoom)"1948 "-zoom" { 1949 SendCmd "camera zoom $_view($what)" 1961 1950 } 1962 1951 } … … 1978 1967 1979 1968 itcl::body Rappture::VtkImageViewer::GetImage { args } { 1980 if { [image width $_image(download)] > 0 && 1969 if { [image width $_image(download)] > 0 && 1981 1970 [image height $_image(download)] > 0 } { 1982 1971 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 1991 1980 -title "[Rappture::filexfer::label downloadWord] as..." 1992 1981 set inner [$popup component inner] 1993 label $inner.summary -text "" -anchor w 1982 label $inner.summary -text "" -anchor w 1994 1983 radiobutton $inner.vtk_button -text "VTK data file" \ 1995 1984 -variable [itcl::scope _downloadPopup(format)] \ 1996 1985 -font "Arial 9 " \ 1997 -value vtk 1986 -value vtk 1998 1987 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 1999 1988 radiobutton $inner.image_button -text "Image File" \ 2000 1989 -variable [itcl::scope _downloadPopup(format)] \ 2001 1990 -font "Arial 9 " \ 2002 -value image 1991 -value image 2003 1992 Rappture::Tooltip::for $inner.image_button \ 2004 1993 "Save as digital image." … … 2021 2010 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 2022 2011 4,1 $inner.cancel -width .9i -fill y \ 2023 4,0 $inner.ok -padx 2 -width .9i -fill y 2012 4,0 $inner.ok -padx 2 -width .9i -fill y 2024 2013 blt::table configure $inner r3 -height 4 2025 2014 blt::table configure $inner r4 -pady 4 … … 2032 2021 # SetObjectStyle -- 2033 2022 # 2034 # Set the style of the image/contour object. This gets calls 2023 # Set the style of the image/contour object. This gets calls 2035 2024 # for each dataset once as it is loaded. It can overridden by 2036 2025 # the user controls. … … 2057 2046 # the code to handle aberrant cases. 2058 2047 2059 if { $_changed( opacity) } {2060 set style(-opacity) [expr $_settings( opacity) * 0.01]2061 } 2062 if { $_changed( colormap) } {2063 set style(-color) $_settings( colormap)2048 if { $_changed(-opacity) } { 2049 set style(-opacity) [expr $_settings(-opacity) * 0.01] 2050 } 2051 if { $_changed(-colormap) } { 2052 set style(-color) $_settings(-colormap) 2064 2053 } 2065 2054 if { $_currentColormap == "" } { … … 2067 2056 } 2068 2057 if { [info exists style(-stretchtofit)] } { 2069 set _settings( stretchToFit) $style(-stretchtofit)2070 AdjustSetting stretchToFit2058 set _settings(-stretchtofit) $style(-stretchtofit) 2059 AdjustSetting -stretchToFit 2071 2060 } 2072 2061 SendCmd "outline add $tag" 2073 2062 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 2074 SendCmd "outline visible $_settings( outline) $tag"2063 SendCmd "outline visible $_settings(-outline) $tag" 2075 2064 SendCmd "image add $tag" 2076 SetCurrentColormap $style(-color) 2065 SetCurrentColormap $style(-color) 2077 2066 set color [$itk_component(backingcolor) value] 2078 2067 SendCmd "image color [Color2RGB $color] $tag" 2079 2068 SendCmd "image opacity $style(-opacity) $tag" 2080 set _settings( opacity) [expr $style(-opacity) * 100.0]2069 set _settings(-opacity) [expr $style(-opacity) * 100.0] 2081 2070 } 2082 2071 … … 2105 2094 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2106 2095 if { [catch {DrawLegend} errs] != 0 } { 2107 2108 2096 global errorInfo 2097 puts stderr "errs=$errs errorInfo=$errorInfo" 2109 2098 } 2110 2099 } … … 2123 2112 set font "Arial 8" 2124 2113 set lineht [font metrics $font -linespace] 2125 2114 2126 2115 if { [string match "component*" $fname] } { 2127 2116 set title "" 2128 2117 } else { 2129 2130 2131 2132 2133 2134 2135 2136 2118 if { [info exists _fields($fname)] } { 2119 foreach { title units } $_fields($fname) break 2120 if { $units != "" } { 2121 set title [format "%s (%s)" $title $units] 2122 } 2123 } else { 2124 set title $fname 2125 } 2137 2126 } 2138 2127 set x [expr $w - 2] 2139 if { !$_settings( legendVisible) } {2140 2141 2142 } 2128 if { !$_settings(-legendvisible) } { 2129 $c delete legend 2130 return 2131 } 2143 2132 if { [$c find withtag "legend"] == "" } { 2144 set y 2 2145 2133 set y 2 2134 # If there's a legend title, create a text item for the title. 2146 2135 $c create text $x $y \ 2147 2148 2149 -font $font 2136 -anchor ne \ 2137 -fill $itk_option(-plotforeground) -tags "title legend" \ 2138 -font $font 2150 2139 if { $title != "" } { 2151 2140 incr y $lineht 2152 2141 } 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2142 $c create text $x $y \ 2143 -anchor ne \ 2144 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2145 -font $font 2146 incr y $lineht 2147 $c create image $x $y \ 2148 -anchor ne \ 2149 -image $_image(legend) -tags "colormap legend" 2150 $c create rectangle $x $y 1 1 \ 2151 -fill "" -outline "" -tags "sensor legend" 2152 $c create text $x [expr {$h-2}] \ 2153 -anchor se \ 2154 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2155 -font $font 2156 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2157 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2158 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2170 2159 } 2171 2160 … … 2181 2170 if { [info exists _limits($_curFldName)] } { 2182 2171 foreach { vmin vmax } $_limits($_curFldName) break 2183 2184 2172 $c itemconfigure vmin -text [format %g $vmin] 2173 $c itemconfigure vmax -text [format %g $vmax] 2185 2174 } 2186 2175 set y 2 … … 2188 2177 if { $title != "" } { 2189 2178 $c itemconfigure title -text $title 2190 2191 2179 $c coords title $x $y 2180 incr y $lineht 2192 2181 } 2193 2182 $c coords vmax $x $y … … 2237 2226 set font "Arial 8" 2238 2227 set lineht [font metrics $font -linespace] 2239 2228 2240 2229 set ih [image height $_image(legend)] 2241 2230 # Subtract off the offset of the color ramp from the top of the canvas … … 2243 2232 2244 2233 if { [string match "component*" $fname] } { 2245 2234 set title "" 2246 2235 } else { 2247 2248 2249 2250 2251 2252 2253 2254 2236 if { [info exists _fields($fname)] } { 2237 foreach { title units } $_fields($fname) break 2238 if { $units != "" } { 2239 set title [format "%s (%s)" $title $units] 2240 } 2241 } else { 2242 set title $fname 2243 } 2255 2244 } 2256 2245 # If there's a legend title, increase the offset by the line height. … … 2268 2257 } 2269 2258 set color [eval format "\#%02x%02x%02x" $pixel] 2270 $_image(swatch) put black -to 0 0 23 23 2271 $_image(swatch) put $color -to 1 1 22 22 2259 $_image(swatch) put black -to 0 0 23 23 2260 $_image(swatch) put $color -to 1 1 22 22 2272 2261 2273 2262 # Compute the value of the point … … 2279 2268 set value 0.0 2280 2269 } 2281 set tipx [expr $x + 15] 2270 set tipx [expr $x + 15] 2282 2271 set tipy [expr $y - 5] 2283 2272 .rappturetooltip configure -icon $_image(swatch) … … 2287 2276 Rappture::Tooltip::text $c [format "$title %g" $value] 2288 2277 } 2289 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2278 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2290 2279 } 2291 2280 … … 2302 2291 # ---------------------------------------------------------------------- 2303 2292 itcl::body Rappture::VtkImageViewer::Combo {option} { 2304 set c $itk_component(view) 2293 set c $itk_component(view) 2305 2294 switch -- $option { 2306 2295 post { … … 2315 2304 } 2316 2305 deactivate { 2317 $c itemconfigure title -fill $itk_option(-plotforeground) 2306 $c itemconfigure title -fill $itk_option(-plotforeground) 2318 2307 } 2319 2308 invoke { 2320 2309 $itk_component(field) value $_curFldLabel 2321 AdjustSetting field2310 AdjustSetting -field 2322 2311 } 2323 2312 default { … … 2327 2316 } 2328 2317 2329 itcl::body Rappture::VtkImageViewer::SetOrientation { side } { 2318 itcl::body Rappture::VtkImageViewer::SetOrientation { side } { 2330 2319 array set positions { 2331 2320 front "0.707107 0.707107 0 0" … … 2336 2325 bottom "0 1 0 0" 2337 2326 } 2338 foreach name { qw qx qyqz } value $positions($side) {2327 foreach name { -qw -qx -qy -qz } value $positions($side) { 2339 2328 set _view($name) $value 2340 } 2341 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2329 } 2330 set q [ViewToQuaternion] 2342 2331 $_arcball quaternion $q 2343 2332 SendCmd "camera orient $q" 2344 2333 SendCmd "camera reset" 2345 set _view( xpan) 02346 set _view( ypan) 02347 set _view( zoom) 1.02348 } 2334 set _view(-xpan) 0 2335 set _view(-ypan) 0 2336 set _view(-zoom) 1.0 2337 }
Note: See TracChangeset
for help on using the changeset viewer.