Changeset 2744 for trunk/gui/scripts/vtkvolumeviewer.tcl
- Timestamp:
- Dec 27, 2011 2:45:13 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkvolumeviewer.tcl
r2730 r2744 114 114 115 115 private variable _arcball "" 116 private variable _outbuf ; 117 118 private variable _dlist "" ; 116 private variable _outbuf ; # buffer for outgoing commands 117 118 private variable _dlist "" ; # list of data objects 119 119 private variable _obj2datasets 120 private variable _obj2ovride ; 121 private variable _datasets ; 122 ; 123 private variable _colormaps ; 124 ; 120 private variable _obj2ovride ; # maps dataobj => style override 121 private variable _datasets ; # contains all the dataobj-component 122 ; # datasets in the server 123 private variable _colormaps ; # contains all the colormaps 124 ; # in the server. 125 125 private variable _dataset2style ;# maps dataobj-component to transfunc 126 126 127 private variable _click ; 128 private variable _limits ; 129 private variable _view ; 127 private variable _click ; # info used for rotate operations 128 private variable _limits ; # autoscale min/max for all axes 129 private variable _view ; # view params for 3D view 130 130 private variable _settings 131 private variable _style; 132 private variable _initialStyle; 133 private variable _reset 1; 134 135 136 private variable _first "" ; 131 private variable _style; # Array of current component styles. 132 private variable _initialStyle; # Array of initial component styles. 133 private variable _reset 1; # indicates if camera needs to be reset 134 # to starting position. 135 136 private variable _first "" ; # This is the topmost dataset. 137 137 private variable _start 0 138 138 private variable _buffering 0 … … 140 140 private variable _seeds 141 141 142 common _downloadPopup; 142 common _downloadPopup; # download options from popup 143 143 private common _hardcopy 144 144 private variable _width 0 … … 154 154 private variable _fields 155 155 private variable _currentField "" 156 private variable _field 156 private variable _field "" 157 157 private variable _numSeeds 200 158 158 private variable _colorMode "vmag";# Mode of colormap (vmag or scalar) … … 193 193 $_dispatcher register !xcutplane 194 194 $_dispatcher dispatch $this !xcutplane \ 195 195 "[itcl::code $this AdjustSetting cutplane-xposition]; list" 196 196 197 197 # Y-Cutplane event 198 198 $_dispatcher register !ycutplane 199 199 $_dispatcher dispatch $this !ycutplane \ 200 200 "[itcl::code $this AdjustSetting cutplane-yposition]; list" 201 201 202 202 # Z-Cutplane event 203 203 $_dispatcher register !zcutplane 204 204 $_dispatcher dispatch $this !zcutplane \ 205 205 "[itcl::code $this AdjustSetting cutplane-zposition]; list" 206 206 207 207 # … … 213 213 214 214 array set _outline { 215 216 217 218 219 220 215 id -1 216 afterId -1 217 x1 -1 218 y1 -1 219 x2 -1 220 y2 -1 221 221 } 222 222 # Initialize the view to some default parameters. 223 223 array set _view { 224 qw1225 qx0226 qy0227 qz0228 zoom 229 xpan 230 ypan 231 ortho 224 qw 1 225 qx 0 226 qy 0 227 qz 0 228 zoom 1.0 229 xpan 0 230 ypan 0 231 ortho 0 232 232 } 233 233 set _arcball [blt::arcball create 100 100] … … 239 239 240 240 array set _settings [subst { 241 axis-xgrid 242 axis-ygrid 243 axis-zgrid 244 axis-xcutplane 245 axis-ycutplane 246 axis-zcutplane 247 axis-xposition 248 axis-yposition 249 axis-zposition 250 axis-visible 251 axis-labels1252 cutplane-edges 253 cutplane-xvisible 254 cutplane-yvisible 255 cutplane-zvisible 256 cutplane-xposition 257 cutplane-yposition 258 cutplane-zposition 259 cutplane-visible 260 cutplane-wireframe 261 cutplane-opacity100262 volume-lighting 263 volume-opacity 264 volume-visible 265 volume-wireframe 266 legend-visible 241 axis-xgrid 0 242 axis-ygrid 0 243 axis-zgrid 0 244 axis-xcutplane 0 245 axis-ycutplane 0 246 axis-zcutplane 0 247 axis-xposition 0 248 axis-yposition 0 249 axis-zposition 0 250 axis-visible 1 251 axis-labels 1 252 cutplane-edges 0 253 cutplane-xvisible 0 254 cutplane-yvisible 0 255 cutplane-zvisible 0 256 cutplane-xposition 50 257 cutplane-yposition 50 258 cutplane-zposition 50 259 cutplane-visible 1 260 cutplane-wireframe 0 261 cutplane-opacity 100 262 volume-lighting 1 263 volume-opacity 40 264 volume-visible 1 265 volume-wireframe 0 266 legend-visible 1 267 267 }] 268 268 … … 277 277 itk_component add fieldmenu { 278 278 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 279 279 -tearoff no 280 280 } { 281 282 281 usual 282 ignore -background -foreground -relief -tearoff 283 283 } 284 284 set c $itk_component(view) … … 342 342 -onimage [Rappture::icon volume-on] \ 343 343 -offimage [Rappture::icon volume-off] \ 344 345 344 -variable [itcl::scope _settings(volume-visible)] \ 345 -command [itcl::code $this AdjustSetting volume-visible] 346 346 } 347 347 $itk_component(volume) select … … 354 354 -onimage [Rappture::icon cutbutton] \ 355 355 -offimage [Rappture::icon cutbutton] \ 356 357 356 -variable [itcl::scope _settings(cutplane-visible)] \ 357 -command [itcl::code $this AdjustSetting cutplane-visible] 358 358 } 359 359 $itk_component(cutplane) select … … 364 364 365 365 if { [catch { 366 367 368 369 366 BuildVolumeTab 367 BuildCutplaneTab 368 BuildAxisTab 369 BuildCameraTab 370 370 } errs] != 0 } { 371 371 puts stderr errs=$errs 372 372 } 373 373 # Legend … … 467 467 itcl::body Rappture::VtkVolumeViewer::DoResize {} { 468 468 if { $_width < 2 } { 469 469 set _width 500 470 470 } 471 471 if { $_height < 2 } { 472 472 set _height 500 473 473 } 474 474 set _start [clock clicks -milliseconds] … … 514 514 if { !$_rotatePending } { 515 515 set _rotatePending 1 516 516 global rotate_delay 517 517 $_dispatcher event -after $rotate_delay !rotate 518 518 } … … 542 542 -description "" 543 543 -param "" 544 544 -type "" 545 545 } 546 546 array set params $settings … … 559 559 set pos [lsearch -exact $dataobj $_dlist] 560 560 if {$pos < 0} { 561 561 lappend _dlist $dataobj 562 562 } 563 563 set _obj2ovride($dataobj-color) $params(-color) … … 584 584 foreach dataobj $args { 585 585 set pos [lsearch -exact $_dlist $dataobj] 586 587 continue;# Don't know anything about it.588 589 590 591 592 593 594 595 596 586 if { $pos < 0 } { 587 continue; # Don't know anything about it. 588 } 589 # Remove it from the dataobj list. 590 set _dlist [lreplace $_dlist $pos $pos] 591 SendCmd "dataset visible 0" 592 array unset _obj2ovride $dataobj-* 593 array unset _settings $dataobj-* 594 # Append to the end of the dataobj list. 595 lappend _dlist $dataobj 596 set changed 1 597 597 } 598 598 # If anything changed, then rebuild the plot … … 618 618 set op [lindex $args 0] 619 619 switch -- $op { 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 }656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 620 "-objects" { 621 # put the dataobj list in order according to -raise options 622 set dlist {} 623 foreach dataobj $_dlist { 624 if { ![IsValidObject $dataobj] } { 625 continue 626 } 627 if {[info exists _obj2ovride($dataobj-raise)] && 628 $_obj2ovride($dataobj-raise)} { 629 set dlist [linsert $dlist 0 $dataobj] 630 } else { 631 lappend dlist $dataobj 632 } 633 } 634 return $dlist 635 } 636 "-visible" { 637 set dlist {} 638 foreach dataobj $_dlist { 639 if { ![IsValidObject $dataobj] } { 640 continue 641 } 642 if { ![info exists _obj2ovride($dataobj-raise)] } { 643 # No setting indicates that the object isn't visible. 644 continue 645 } 646 # Otherwise use the -raise parameter to put the object to 647 # the front of the list. 648 if { $_obj2ovride($dataobj-raise) } { 649 set dlist [linsert $dlist 0 $dataobj] 650 } else { 651 lappend dlist $dataobj 652 } 653 } 654 return $dlist 655 } 656 -image { 657 if {[llength $args] != 2} { 658 error "wrong # args: should be \"get -image view\"" 659 } 660 switch -- [lindex $args end] { 661 view { 662 return $_image(plot) 663 } 664 default { 665 error "bad image name \"[lindex $args end]\": should be view" 666 } 667 } 668 } 669 default { 670 error "bad option \"$op\": should be -objects or -image" 671 } 672 672 } 673 673 } … … 685 685 array unset _limits 686 686 foreach dataobj $args { 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 687 set string [limits $dataobj] 688 if { $string == "" } { 689 continue 690 } 691 array set bounds $string 692 if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} { 693 set _limits(xmin) $bounds(xmin) 694 } 695 if {![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax)} { 696 set _limits(xmax) $bounds(xmax) 697 } 698 699 if {![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin)} { 700 set _limits(ymin) $bounds(ymin) 701 } 702 if {![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax)} { 703 set _limits(ymax) $bounds(ymax) 704 } 705 706 if {![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin)} { 707 set _limits(zmin) $bounds(zmin) 708 } 709 if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} { 710 set _limits(zmax) $bounds(zmax) 711 } 712 712 } 713 713 } … … 745 745 set word [Rappture::filexfer::label downloadWord] 746 746 $inner.summary configure -text "$word $num in the following format:" 747 update idletasks 747 update idletasks ;# Fix initial sizes 748 748 return $popup 749 749 } … … 854 854 } else { 855 855 SendBytes "$string\n" 856 856 StartWaiting 857 857 } 858 858 } … … 890 890 StopWaiting 891 891 if { $info(-type) == "image" } { 892 893 894 895 896 892 if 0 { 893 set f [open "last.ppm" "w"] 894 puts $f $bytes 895 close $f 896 } 897 897 $_image(plot) configure -data $bytes 898 899 898 set time [clock seconds] 899 set date [clock format $time] 900 900 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 901 902 903 904 905 901 if { $_start > 0 } { 902 set finish [clock clicks -milliseconds] 903 #puts stderr "round trip time [expr $finish -$_start] milliseconds" 904 set _start 0 905 } 906 906 } elseif { $info(type) == "print" } { 907 907 set tag $this-print-$info(-token) … … 909 909 } 910 910 if { $_legendPending } { 911 911 RequestLegend 912 912 } 913 913 } … … 922 922 set option [lindex $args 0] 923 923 switch -- $option { 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 924 "scalar" { 925 set option [lindex $args 1] 926 switch -- $option { 927 "world" { 928 foreach { x y z value tag } [lrange $args 2 end] break 929 } 930 "pixel" { 931 foreach { x y value tag } [lrange $args 2 end] break 932 } 933 } 934 } 935 "vector" { 936 set option [lindex $args 1] 937 switch -- $option { 938 "world" { 939 foreach { x y z vx vy vz tag } [lrange $args 2 end] break 940 } 941 "pixel" { 942 foreach { x y vx vy vz tag } [lrange $args 2 end] break 943 } 944 } 945 } 946 "names" { 947 947 foreach { name } [lindex $args 1] { 948 948 #puts stderr "Dataset: $name" 949 949 } 950 951 952 953 950 } 951 default { 952 error "unknown dataset option \"$option\" from server" 953 } 954 954 } 955 955 } … … 967 967 set h [winfo height $itk_component(view)] 968 968 if { $w < 2 || $h < 2 } { 969 970 969 $_dispatcher event -idle !rebuild 970 return 971 971 } 972 972 … … 994 994 set _first "" 995 995 InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \ 996 997 998 996 axis-visible axis-labels cutplane-visible \ 997 cutplane-xposition cutplane-yposition cutplane-zposition \ 998 cutplane-xvisible cutplane-yvisible cutplane-zvisible 999 999 1000 1000 SendCmd "imgflush" … … 1005 1005 1006 1006 foreach dataobj [get -objects] { 1007 1008 1009 1010 1007 if { [info exists _obj2ovride($dataobj-raise)] && $_first == "" } { 1008 set _first $dataobj 1009 } 1010 set _obj2datasets($dataobj) "" 1011 1011 foreach comp [$dataobj components] { 1012 1012 set tag $dataobj-$comp … … 1017 1017 append _outbuf $bytes 1018 1018 set _datasets($tag) 1 1019 1020 1021 1022 1023 1024 1025 1026 1027 1019 SetObjectStyle $dataobj $comp 1020 } 1021 lappend _obj2datasets($dataobj) $tag 1022 if { [info exists _obj2ovride($dataobj-raise)] } { 1023 SendCmd "dataset visible 1 $tag" 1024 } else { 1025 SendCmd "dataset visible 0 $tag" 1026 } 1027 break 1028 1028 } 1029 1029 } … … 1034 1034 } 1035 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1036 if 0 { 1037 # Tell the server the name of the tool, the version, and dataset 1038 # that we are rendering. Have to do it here because we don't know 1039 # what data objects are using the renderer until be get here. 1040 set args "" 1041 lappend args tool [$_first hints toolId] 1042 lappend args version [$_first hints toolRevision] 1043 lappend args dataset [$_first hints label] 1044 SendCmd "clientinfo $args" 1045 } 1046 1047 foreach axis { x y z } { 1048 set label [$_first hints ${axis}label] 1049 if { $label != "" } { 1050 SendCmd "axis name $axis $label" 1051 } 1052 set units [$_first hints ${axis}units] 1053 if { $units != "" } { 1054 SendCmd "axis units $axis $units" 1055 } 1056 } 1057 array unset _scalarFields 1058 array unset _vectorFields 1059 set _currentField [$_first hints default] 1060 $itk_component(field) choices delete 0 end 1061 $itk_component(fieldmenu) delete 0 end 1062 array unset _fields 1063 foreach { name title units } [$_first hints vectors] { 1064 set _vectorFields($title) $name 1065 $itk_component(field) choices insert end "$name" "$title" 1066 $itk_component(fieldmenu) add radiobutton -label "$title" \ 1067 -value $title -variable [itcl::scope _currentField] \ 1068 -selectcolor red \ 1069 -activebackground black \ 1070 -activeforeground white \ 1071 -font "Arial 8" \ 1072 -command [itcl::code $this Combo invoke] 1073 set _fields($name) [list $title $units] 1074 } 1075 foreach { name title units } [$_first hints scalars] { 1076 set _scalarFields($title) $name 1077 $itk_component(field) choices insert end "$name" "$title" 1078 $itk_component(fieldmenu) add radiobutton -label "$title" \ 1079 -value $title -variable [itcl::scope _currentField] \ 1080 -selectcolor red \ 1081 -activebackground black \ 1082 -activeforeground white \ 1083 -font "Arial 8" \ 1084 -command [itcl::code $this Combo invoke] 1085 set _fields($name) [list $title $units] 1086 } 1087 foreach { name title units } { default Default ??? } { 1088 set _scalarFields($title) $name 1089 $itk_component(field) choices insert end "$name" "$title" 1090 $itk_component(fieldmenu) add radiobutton -label "$title" \ 1091 -value $title -variable [itcl::scope _currentField] \ 1092 -selectcolor red \ 1093 -activebackground black \ 1094 -activeforeground white \ 1095 -font "Arial 8" \ 1096 -command [itcl::code $this Combo invoke] 1097 set _fields($name) [list $title $units] 1098 } 1099 $itk_component(field) value $_currentField 1100 1100 } 1101 1101 … … 1103 1103 1104 1104 if { $_reset } { 1105 1106 1107 1105 InitSettings volume-lighting 1106 Zoom reset 1107 set _reset 0 1108 1108 } 1109 1109 set _buffering 0; # Turn off buffering. … … 1127 1127 set flag [lindex $args 0] 1128 1128 switch -- $flag { 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 }1148 1149 1150 1129 "-all" { 1130 if { [llength $args] > 1 } { 1131 error "CurrentDatasets: can't specify dataobj after \"-all\"" 1132 } 1133 set dlist [get -objects] 1134 } 1135 "-visible" { 1136 if { [llength $args] > 1 } { 1137 set dlist {} 1138 set args [lrange $args 1 end] 1139 foreach dataobj $args { 1140 if { [info exists _obj2ovride($dataobj-raise)] } { 1141 lappend dlist $dataobj 1142 } 1143 } 1144 } else { 1145 set dlist [get -visible] 1146 } 1147 } 1148 default { 1149 set dlist $args 1150 } 1151 1151 } 1152 1152 set rlist "" 1153 1153 foreach dataobj $dlist { 1154 1155 1156 1157 1158 1159 1154 foreach comp [$dataobj components] { 1155 set tag $dataobj-$comp 1156 if { [info exists _datasets($tag)] && $_datasets($tag) } { 1157 lappend rlist $tag 1158 } 1159 } 1160 1160 } 1161 1161 return $rlist … … 1174 1174 "in" { 1175 1175 set _view(zoom) [expr {$_view(zoom)*1.25}] 1176 1176 SendCmd "camera zoom $_view(zoom)" 1177 1177 } 1178 1178 "out" { 1179 1179 set _view(zoom) [expr {$_view(zoom)*0.8}] 1180 1180 SendCmd "camera zoom $_view(zoom)" 1181 1181 } 1182 1182 "reset" { 1183 1183 array set _view { 1184 qw11185 qx01186 qy01187 qz01184 qw 1 1185 qx 0 1186 qy 0 1187 qz 0 1188 1188 zoom 1.0 1189 1189 xpan 0 … … 1197 1197 } 1198 1198 } 1199 1200 1201 1199 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1200 $_arcball quaternion $q 1201 DoRotate 1202 1202 } 1203 1203 } … … 1243 1243 return 1244 1244 } 1245 1246 1247 1248 1249 1245 if { $dx == 0 && $dy == 0 } { 1246 return 1247 } 1248 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1249 EventuallyRotate $q 1250 1250 set _click(x) $x 1251 1251 set _click(y) $y … … 1279 1279 itcl::body Rappture::VtkVolumeViewer::Pan {option x y} { 1280 1280 switch -- $option { 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1281 "set" { 1282 set w [winfo width $itk_component(view)] 1283 set h [winfo height $itk_component(view)] 1284 set x [expr $x / double($w)] 1285 set y [expr $y / double($h)] 1286 set _view(xpan) [expr $_view(xpan) + $x] 1287 set _view(ypan) [expr $_view(ypan) + $y] 1288 PanCamera 1289 return 1290 } 1291 "click" { 1292 set _click(x) $x 1293 set _click(y) $y 1294 $itk_component(view) configure -cursor hand1 1295 } 1296 "drag" { 1297 if { ![info exists _click(x)] } { 1298 set _click(x) $x 1299 } 1300 if { ![info exists _click(y)] } { 1301 set _click(y) $y 1302 } 1303 set w [winfo width $itk_component(view)] 1304 set h [winfo height $itk_component(view)] 1305 set dx [expr ($_click(x) - $x)/double($w)] 1306 set dy [expr ($_click(y) - $y)/double($h)] 1307 set _click(x) $x 1308 set _click(y) $y 1309 set _view(xpan) [expr $_view(xpan) - $dx] 1310 set _view(ypan) [expr $_view(ypan) - $dy] 1311 PanCamera 1312 } 1313 "release" { 1314 Pan drag $x $y 1315 $itk_component(view) configure -cursor "" 1316 } 1317 default { 1318 error "unknown option \"$option\": should set, click, drag, or release" 1319 } 1320 1320 } 1321 1321 } … … 1330 1330 itcl::body Rappture::VtkVolumeViewer::InitSettings { args } { 1331 1331 foreach spec $args { 1332 1333 1334 1335 1336 1332 if { [info exists _settings($_first-$spec)] } { 1333 # Reset global setting with dataobj specific setting 1334 set _settings($spec) $_settings($_first-$spec) 1335 } 1336 AdjustSetting $spec 1337 1337 } 1338 1338 } … … 1341 1341 # AdjustSetting -- 1342 1342 # 1343 # 1344 # 1345 # 1343 # Changes/updates a specific setting in the widget. There are 1344 # usually user-setable option. Commands are sent to the render 1345 # server. 1346 1346 # 1347 1347 itcl::body Rappture::VtkVolumeViewer::AdjustSetting {what {value ""}} { 1348 1348 if { ![isconnected] } { 1349 1349 return 1350 1350 } 1351 1351 switch -- $what { 1352 1352 "volume-visible" { 1353 1354 1355 1356 } 1357 1358 1359 1360 1361 1362 1363 1353 set bool $_settings(volume-visible) 1354 foreach dataset [CurrentDatasets -visible] { 1355 SendCmd "volume visible $bool $dataset" 1356 } 1357 if { $bool } { 1358 Rappture::Tooltip::for $itk_component(volume) \ 1359 "Hide the volume" 1360 } else { 1361 Rappture::Tooltip::for $itk_component(volume) \ 1362 "Show the volume" 1363 } 1364 1364 } 1365 1365 "volume-lighting" { 1366 1367 1368 1366 set bool $_settings(volume-lighting) 1367 foreach dataset [CurrentDatasets -visible] { 1368 SendCmd "volume lighting $bool $dataset" 1369 1369 } 1370 1370 } 1371 1371 "axis-visible" { 1372 1373 1372 set bool $_settings(axis-visible) 1373 SendCmd "axis visible all $bool" 1374 1374 } 1375 1375 "axis-labels" { 1376 1377 1376 set bool $_settings(axis-labels) 1377 SendCmd "axis labels all $bool" 1378 1378 } 1379 1379 "axis-xgrid" - "axis-ygrid" - "axis-zgrid" { 1380 1381 1382 1380 set axis [string range $what 5 5] 1381 set bool $_settings($what) 1382 SendCmd "axis grid $axis $bool" 1383 1383 } 1384 1384 "axis-mode" { 1385 1386 1387 1388 1385 set mode [$itk_component(axismode) value] 1386 set mode [$itk_component(axismode) translate $mode] 1387 set _settings($what) $mode 1388 SendCmd "axis flymode $mode" 1389 1389 } 1390 1390 "cutplane-edges" { 1391 1392 1393 1391 set bool $_settings($what) 1392 foreach dataset [CurrentDatasets -visible] { 1393 SendCmd "cutplane edges $bool $dataset" 1394 1394 } 1395 1395 } 1396 1396 "cutplane-visible" { 1397 1398 1399 1397 set bool $_settings($what) 1398 foreach dataset [CurrentDatasets -visible] { 1399 SendCmd "cutplane visible $bool $dataset" 1400 1400 } 1401 1401 } 1402 1402 "cutplane-wireframe" { 1403 1404 1405 1403 set bool $_settings($what) 1404 foreach dataset [CurrentDatasets -visible] { 1405 SendCmd "cutplane wireframe $bool $dataset" 1406 1406 } 1407 1407 } 1408 1408 "cutplane-lighting" { 1409 1410 1411 1409 set bool $_settings($what) 1410 foreach dataset [CurrentDatasets -visible] { 1411 SendCmd "cutplane lighting $bool $dataset" 1412 1412 } 1413 1413 } 1414 1414 "cutplane-opacity" { 1415 1416 1417 1418 1419 1420 } 1421 1422 1423 1415 set val $_settings($what) 1416 set sval [expr { 0.01 * double($val) }] 1417 foreach dataset [CurrentDatasets -visible] { 1418 SendCmd "cutplane opacity $sval $dataset" 1419 } 1420 } 1421 "cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" { 1422 set axis [string range $what 9 9] 1423 set bool $_settings($what) 1424 1424 if { $bool } { 1425 1425 $itk_component(${axis}CutScale) configure -state normal \ … … 1429 1429 -troughcolor grey82 1430 1430 } 1431 1432 1433 1434 1435 1436 1437 1438 1431 SendCmd "cutplane axis $axis $bool" 1432 } 1433 "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" { 1434 set axis [string range $what 9 9] 1435 set pos [expr $_settings($what) * 0.01] 1436 SendCmd "cutplane slice ${axis} ${pos}" 1437 set _cutplanePending 0 1438 } 1439 1439 "volume-palette" { 1440 1441 1442 1443 1444 1445 } 1446 1440 set palette [$itk_component(palette) value] 1441 set _settings(volume-palette) $palette 1442 foreach dataset [CurrentDatasets -visible $_first] { 1443 foreach {dataobj comp} [split $dataset -] break 1444 ChangeColormap $dataobj $comp $palette 1445 } 1446 set _legendPending 1 1447 1447 } 1448 1448 "volume-palette" { 1449 1450 1451 1452 1453 1454 } 1455 1449 set palette [$itk_component(palette) value] 1450 set _settings(volume-palette) $palette 1451 foreach dataset [CurrentDatasets -visible $_first] { 1452 foreach {dataobj comp} [split $dataset -] break 1453 ChangeColormap $dataobj $comp $palette 1454 } 1455 set _legendPending 1 1456 1456 } 1457 1457 "volume-field" { 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 } 1479 1458 set new [$itk_component(field) value] 1459 set value [$itk_component(field) translate $new] 1460 set _settings(volume-field) $value 1461 if { [info exists _scalarFields($new)] } { 1462 set name $_scalarFields($new) 1463 set _colorMode scalar 1464 set _currentField $new 1465 } elseif { [info exists _vectorFields($new)] } { 1466 set name $_vectorFields($new) 1467 set _colorMode vmag 1468 set _currentField $new 1469 } else { 1470 puts stderr "unknown field \"$new\"" 1471 return 1472 } 1473 foreach dataset [CurrentDatasets -visible] { 1474 #puts stderr "volume colormode $_colorMode ${name} $dataset" 1475 puts stderr "cutplane colormode $_colorMode ${name} $dataset" 1476 #SendCmd "volume colormode $_colorMode ${name} $dataset" 1477 SendCmd "cutplane colormode $_colorMode ${name} $dataset" 1478 } 1479 set _legendPending 1 1480 1480 } 1481 1481 default { … … 1488 1488 # RequestLegend -- 1489 1489 # 1490 # 1491 # 1492 # 1490 # Request a new legend from the server. The size of the legend 1491 # is determined from the height of the canvas. It will be rotated 1492 # to be vertical when drawn. 1493 1493 # 1494 1494 itcl::body Rappture::VtkVolumeViewer::RequestLegend {} { … … 1499 1499 set h [expr {$_height - 3 * ($lineht + 2)}] 1500 1500 if { $h < 1} { 1501 1501 return 1502 1502 } 1503 1503 if { [info exists _scalarFields($_currentField)] } { 1504 1504 set name $_scalarFields($_currentField) 1505 1505 } elseif { [info exists _vectorFields($_currentField)] } { 1506 1506 set name $_vectorFields($_currentField) 1507 1507 } else { 1508 1508 return 1509 1509 } 1510 1510 # Set the legend on the first volume dataset. 1511 1511 foreach dataset [CurrentDatasets -visible $_first] { 1512 1513 1512 foreach {dataobj comp} [split $dataset -] break 1513 if { [info exists _dataset2style($dataset)] } { 1514 1514 SendCmdNoWait \ 1515 1516 1515 "legend $_dataset2style($dataset) $_colorMode $name {} $w $h 0" 1516 break; 1517 1517 } 1518 1518 } … … 1525 1525 set tag $dataobj-$comp 1526 1526 if { ![info exist _style($tag)] } { 1527 1527 error "no initial colormap" 1528 1528 } 1529 1529 array set style $_style($tag) … … 1544 1544 set tag $dataobj-$comp 1545 1545 if { ![info exists _initialStyle($tag)] } { 1546 1547 1546 # Save the initial component style. 1547 set _initialStyle($tag) [$dataobj style $comp] 1548 1548 } 1549 1549 … … 1552 1552 1553 1553 if { ![info exists _style($tag)] } { 1554 1554 set _style($tag) [array get style] 1555 1555 } 1556 1556 # Override initial style with current style. … … 1559 1559 set name "$style(-color):$style(-levels):$style(-opacity)" 1560 1560 if { ![info exists _colormaps($name)] } { 1561 1562 1561 BuildColormap $name [array get style] 1562 set _colormaps($name) 1 1563 1563 } 1564 1564 if { ![info exists _dataset2style($tag)] || 1565 1566 1567 1568 1565 $_dataset2style($tag) != $name } { 1566 SendCmd "volume colormap $name $tag" 1567 SendCmd "cutplane colormap $name $tag" 1568 set _dataset2style($tag) $name 1569 1569 } 1570 1570 } … … 1573 1573 puts stderr colors=$colors 1574 1574 switch -- $colors { 1575 1576 1577 0.00.200 0.200 0.2001578 0.142857142857142850.400 0.400 0.4001579 0.28571428571428570.600 0.600 0.6001580 0.428571428571428550.900 0.900 0.9001581 0.57142857142857140.800 1.000 1.0001582 0.71428571428571430.600 1.000 1.0001583 0.85714285714285710.400 0.900 1.0001584 1.00.000 0.600 0.8001585 1586 1587 1588 1589 0.00.000 0.600 0.8001590 0.142857142857142850.400 0.900 1.0001591 0.28571428571428570.600 1.000 1.0001592 0.428571428571428550.800 1.000 1.0001593 0.57142857142857140.900 0.900 0.9001594 0.71428571428571430.600 0.600 0.6001595 0.85714285714285710.400 0.400 0.4001596 1.00.200 0.200 0.2001597 1598 1599 1600 1601 0.00.900 1.000 1.0001602 0.11111111111111110.800 0.983 1.0001603 0.22222222222222220.700 0.950 1.0001604 0.33333333333333330.600 0.900 1.0001605 0.44444444444444440.500 0.833 1.0001606 0.55555555555555560.400 0.750 1.0001607 0.66666666666666660.300 0.650 1.0001608 0.77777777777777780.200 0.533 1.0001609 0.88888888888888880.100 0.400 1.0001610 1.00.000 0.250 1.0001611 1612 1613 1614 1615 0.00.200 0.100 0.0001616 0.090909090909090910.400 0.187 0.0001617 0.181818181818181820.600 0.379 0.2101618 0.27272727272727270.800 0.608 0.4801619 0.363636363636363650.850 0.688 0.5951620 0.454545454545454530.950 0.855 0.8081621 0.54545454545454540.800 0.993 1.0001622 0.63636363636363640.600 0.973 1.0001623 0.72727272727272730.400 0.940 1.0001624 0.81818181818181820.200 0.893 1.0001625 0.90909090909090910.000 0.667 0.8001626 1.00.000 0.480 0.6001627 1628 1629 1630 1631 0.00.000 0.480 0.6001632 0.090909090909090910.000 0.667 0.8001633 0.181818181818181820.200 0.893 1.0001634 0.27272727272727270.400 0.940 1.0001635 0.363636363636363650.600 0.973 1.0001636 0.454545454545454530.800 0.993 1.0001637 0.54545454545454540.950 0.855 0.8081638 0.63636363636363640.850 0.688 0.5951639 0.72727272727272730.800 0.608 0.4801640 0.81818181818181820.600 0.379 0.2101641 0.90909090909090910.400 0.187 0.0001642 1.00.200 0.100 0.0001643 1644 1645 1646 1647 0.00.000 0.167 1.0001648 0.090909090909090910.100 0.400 1.0001649 0.181818181818181820.200 0.600 1.0001650 0.27272727272727270.400 0.800 1.0001651 0.363636363636363650.600 0.933 1.0001652 0.454545454545454530.800 1.000 1.0001653 0.54545454545454541.000 1.000 0.8001654 0.63636363636363641.000 0.933 0.6001655 0.72727272727272731.000 0.800 0.4001656 0.81818181818181821.000 0.600 0.2001657 0.90909090909090911.000 0.400 0.1001658 1.01.000 0.167 0.0001659 1660 1661 1662 1663 0.01.000 0.167 0.0001664 0.090909090909090911.000 0.400 0.1001665 0.181818181818181821.000 0.600 0.2001666 0.27272727272727271.000 0.800 0.4001667 0.363636363636363651.000 0.933 0.6001668 0.454545454545454531.000 1.000 0.8001669 0.54545454545454540.800 1.000 1.0001670 0.63636363636363640.600 0.933 1.0001671 0.72727272727272730.400 0.800 1.0001672 0.81818181818181820.200 0.600 1.0001673 0.90909090909090910.100 0.400 1.0001674 1.00.000 0.167 1.0001675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1575 "grey-to-blue" { 1576 return { 1577 0.0 0.200 0.200 0.200 1578 0.14285714285714285 0.400 0.400 0.400 1579 0.2857142857142857 0.600 0.600 0.600 1580 0.42857142857142855 0.900 0.900 0.900 1581 0.5714285714285714 0.800 1.000 1.000 1582 0.7142857142857143 0.600 1.000 1.000 1583 0.8571428571428571 0.400 0.900 1.000 1584 1.0 0.000 0.600 0.800 1585 } 1586 } 1587 "blue-to-grey" { 1588 return { 1589 0.0 0.000 0.600 0.800 1590 0.14285714285714285 0.400 0.900 1.000 1591 0.2857142857142857 0.600 1.000 1.000 1592 0.42857142857142855 0.800 1.000 1.000 1593 0.5714285714285714 0.900 0.900 0.900 1594 0.7142857142857143 0.600 0.600 0.600 1595 0.8571428571428571 0.400 0.400 0.400 1596 1.0 0.200 0.200 0.200 1597 } 1598 } 1599 "blue" { 1600 return { 1601 0.0 0.900 1.000 1.000 1602 0.1111111111111111 0.800 0.983 1.000 1603 0.2222222222222222 0.700 0.950 1.000 1604 0.3333333333333333 0.600 0.900 1.000 1605 0.4444444444444444 0.500 0.833 1.000 1606 0.5555555555555556 0.400 0.750 1.000 1607 0.6666666666666666 0.300 0.650 1.000 1608 0.7777777777777778 0.200 0.533 1.000 1609 0.8888888888888888 0.100 0.400 1.000 1610 1.0 0.000 0.250 1.000 1611 } 1612 } 1613 "brown-to-blue" { 1614 return { 1615 0.0 0.200 0.100 0.000 1616 0.09090909090909091 0.400 0.187 0.000 1617 0.18181818181818182 0.600 0.379 0.210 1618 0.2727272727272727 0.800 0.608 0.480 1619 0.36363636363636365 0.850 0.688 0.595 1620 0.45454545454545453 0.950 0.855 0.808 1621 0.5454545454545454 0.800 0.993 1.000 1622 0.6363636363636364 0.600 0.973 1.000 1623 0.7272727272727273 0.400 0.940 1.000 1624 0.8181818181818182 0.200 0.893 1.000 1625 0.9090909090909091 0.000 0.667 0.800 1626 1.0 0.000 0.480 0.600 1627 } 1628 } 1629 "blue-to-brown" { 1630 return { 1631 0.0 0.000 0.480 0.600 1632 0.09090909090909091 0.000 0.667 0.800 1633 0.18181818181818182 0.200 0.893 1.000 1634 0.2727272727272727 0.400 0.940 1.000 1635 0.36363636363636365 0.600 0.973 1.000 1636 0.45454545454545453 0.800 0.993 1.000 1637 0.5454545454545454 0.950 0.855 0.808 1638 0.6363636363636364 0.850 0.688 0.595 1639 0.7272727272727273 0.800 0.608 0.480 1640 0.8181818181818182 0.600 0.379 0.210 1641 0.9090909090909091 0.400 0.187 0.000 1642 1.0 0.200 0.100 0.000 1643 } 1644 } 1645 "blue-to-orange" { 1646 return { 1647 0.0 0.000 0.167 1.000 1648 0.09090909090909091 0.100 0.400 1.000 1649 0.18181818181818182 0.200 0.600 1.000 1650 0.2727272727272727 0.400 0.800 1.000 1651 0.36363636363636365 0.600 0.933 1.000 1652 0.45454545454545453 0.800 1.000 1.000 1653 0.5454545454545454 1.000 1.000 0.800 1654 0.6363636363636364 1.000 0.933 0.600 1655 0.7272727272727273 1.000 0.800 0.400 1656 0.8181818181818182 1.000 0.600 0.200 1657 0.9090909090909091 1.000 0.400 0.100 1658 1.0 1.000 0.167 0.000 1659 } 1660 } 1661 "orange-to-blue" { 1662 return { 1663 0.0 1.000 0.167 0.000 1664 0.09090909090909091 1.000 0.400 0.100 1665 0.18181818181818182 1.000 0.600 0.200 1666 0.2727272727272727 1.000 0.800 0.400 1667 0.36363636363636365 1.000 0.933 0.600 1668 0.45454545454545453 1.000 1.000 0.800 1669 0.5454545454545454 0.800 1.000 1.000 1670 0.6363636363636364 0.600 0.933 1.000 1671 0.7272727272727273 0.400 0.800 1.000 1672 0.8181818181818182 0.200 0.600 1.000 1673 0.9090909090909091 0.100 0.400 1.000 1674 1.0 0.000 0.167 1.000 1675 } 1676 } 1677 "rainbow" { 1678 set clist { 1679 "#EE82EE" 1680 "#4B0082" 1681 "blue" 1682 "#008000" 1683 "yellow" 1684 "#FFA500" 1685 "red" 1686 } 1687 } 1688 "BGYOR" { 1689 set clist { 1690 "blue" 1691 "#008000" 1692 "yellow" 1693 "#FFA500" 1694 "red" 1695 } 1696 } 1697 "ROYGB" { 1698 set clist { 1699 "red" 1700 "#FFA500" 1701 "yellow" 1702 "#008000" 1703 "blue" 1704 } 1705 } 1706 "RYGCB" { 1707 set clist { 1708 "red" 1709 "yellow" 1710 "green" 1711 "cyan" 1712 "blue" 1713 } 1714 } 1715 "BCGYR" { 1716 set clist { 1717 "blue" 1718 "cyan" 1719 "green" 1720 "yellow" 1721 "red" 1722 } 1723 } 1724 "spectral" { 1725 return { 1726 0.0 0.150 0.300 1.000 1727 0.1 0.250 0.630 1.000 1728 0.2 0.450 0.850 1.000 1729 0.3 0.670 0.970 1.000 1730 0.4 0.880 1.000 1.000 1731 0.5 1.000 1.000 0.750 1732 0.6 1.000 0.880 0.600 1733 0.7 1.000 0.680 0.450 1734 0.8 0.970 0.430 0.370 1735 0.9 0.850 0.150 0.196 1736 1.0 0.650 0.000 0.130 1737 } 1738 } 1739 "green-to-magenta" { 1740 return { 1741 0.0 0.000 0.316 0.000 1742 0.06666666666666667 0.000 0.526 0.000 1743 0.13333333333333333 0.000 0.737 0.000 1744 0.2 0.000 0.947 0.000 1745 0.26666666666666666 0.316 1.000 0.316 1746 0.3333333333333333 0.526 1.000 0.526 1747 0.4 0.737 1.000 0.737 1748 0.4666666666666667 1.000 1.000 1.000 1749 0.5333333333333333 1.000 0.947 1.000 1750 0.6 1.000 0.737 1.000 1751 0.6666666666666666 1.000 0.526 1.000 1752 0.7333333333333333 1.000 0.316 1.000 1753 0.8 0.947 0.000 0.947 1754 0.8666666666666667 0.737 0.000 0.737 1755 0.9333333333333333 0.526 0.000 0.526 1756 1.0 0.316 0.000 0.316 1757 } 1758 } 1759 "greyscale" { 1760 return { 1761 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1762 } 1763 } 1764 "nanohub" { 1765 set clist "white yellow green cyan blue magenta" 1766 } 1767 default { 1768 set clist [split $colors :] 1769 } 1770 1770 } 1771 1771 set cmap {} … … 1775 1775 append cmap "1.0 [Color2RGB $colors] " 1776 1776 } else { 1777 1778 1779 1780 1781 1777 for {set i 0} {$i < [llength $clist]} {incr i} { 1778 set x [expr {double($i)/([llength $clist]-1)}] 1779 set color [lindex $clist $i] 1780 append cmap "$x [Color2RGB $color] " 1781 } 1782 1782 } 1783 1783 return $cmap … … 1791 1791 set cmap [ColorsToColormap $style(-color)] 1792 1792 if { [llength $cmap] == 0 } { 1793 1793 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1794 1794 } 1795 1795 if { ![info exists _settings(volume-opacity)] } { … … 1828 1828 array unset _limits $dataobj-* 1829 1829 foreach comp [$dataobj components] { 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1830 set tag $dataobj-$comp 1831 if { ![info exists _limits($tag)] } { 1832 set data [$dataobj blob $comp] 1833 set tmpfile file[pid].vtk 1834 set f [open "$tmpfile" "w"] 1835 fconfigure $f -translation binary -encoding binary 1836 puts $f $data 1837 close $f 1838 set reader [vtkDataSetReader $tag-xvtkDataSetReader] 1839 $reader SetFileName $tmpfile 1840 $reader ReadAllScalarsOn 1841 $reader ReadAllVectorsOn 1842 $reader ReadAllFieldsOn 1843 $reader Update 1844 set output [$reader GetOutput] 1845 set _limits($tag) [$output GetBounds] 1846 set pointData [$output GetPointData] 1847 puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]" 1848 puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]" 1849 puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]" 1850 set fieldData [$output GetFieldData] 1851 set pointData [$output GetPointData] 1852 puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]" 1853 for { set i 0 } { $i < [$fieldData GetNumberOfArrays] } { incr i } { 1854 puts stderr [$fieldData GetArrayName $i] 1855 } 1856 puts stderr "point \#arrays=[$pointData GetNumberOfArrays]" 1857 for { set i 0 } { $i < [$pointData GetNumberOfArrays] } { incr i } { 1858 set name [$pointData GetArrayName $i] 1859 if { ![info exists _fields($name)] } { 1860 $itk_component(field) choices insert end "$name" "$name" 1861 set _fields($name) 1 1862 } 1863 } 1864 puts stderr "field \#components=[$fieldData GetNumberOfComponents]" 1865 puts stderr "point \#components=[$pointData GetNumberOfComponents]" 1866 puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]" 1867 puts stderr "point \#tuples=[$pointData GetNumberOfTuples]" 1868 puts stderr "point \#scalars=[$pointData GetScalars]" 1869 puts stderr vectors=[$pointData GetVectors] 1870 rename $output "" 1871 rename $reader "" 1872 file delete $tmpfile 1873 } 1874 1874 foreach { xMin xMax yMin yMax zMin zMax} $_limits($tag) break 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1875 if {![info exists limits(xmin)] || $limits(xmin) > $xMin} { 1876 set limits(xmin) $xMin 1877 } 1878 if {![info exists limits(xmax)] || $limits(xmax) < $xMax} { 1879 set limits(xmax) $xMax 1880 } 1881 if {![info exists limits(ymin)] || $limits(ymin) > $yMin} { 1882 set limits(ymin) $xMin 1883 } 1884 if {![info exists limits(ymax)] || $limits(ymax) < $yMax} { 1885 set limits(ymax) $yMax 1886 } 1887 if {![info exists limits(zmin)] || $limits(zmin) > $zMin} { 1888 set limits(zmin) $zMin 1889 } 1890 if {![info exists limits(zmax)] || $limits(zmax) < $zMax} { 1891 set limits(zmax) $zMax 1892 } 1893 1893 } 1894 1894 return [array get limits] … … 1922 1922 -width 10 \ 1923 1923 -showvalue off \ 1924 1924 -command [itcl::code $this AdjustSetting volume-opacity] 1925 1925 1926 1926 label $inner.field_l -text "Field" -font "Arial 9" 1927 1927 itk_component add field { 1928 1928 Rappture::Combobox $inner.field -width 10 -editable no 1929 1929 } 1930 1930 bind $inner.field <<Value>> \ 1931 1931 [itcl::code $this AdjustSetting volume-field] 1932 1932 1933 1933 label $inner.palette_l -text "Palette" -font "Arial 9" 1934 1934 itk_component add palette { 1935 1935 Rappture::Combobox $inner.palette -width 10 -editable no 1936 1936 } 1937 1937 $inner.palette choices insert end \ 1938 "BCGYR" "BCGYR"\1939 "BGYOR" "BGYOR"\1940 "blue" "blue"\1941 1942 1943 "blue-to-grey" "blue-to-grey"\1944 "green-to-magenta" "green-to-magenta"\1945 "greyscale" "greyscale"\1946 1947 "rainbow" "rainbow"\1948 "spectral" "spectral"\1949 "ROYGB" "ROYGB"\1950 "RYGCB" "RYGCB"\1951 1952 "grey-to-blue" "grey-to-blue"\1953 1938 "BCGYR" "BCGYR" \ 1939 "BGYOR" "BGYOR" \ 1940 "blue" "blue" \ 1941 "blue-to-brown" "blue-to-brown" \ 1942 "blue-to-orange" "blue-to-orange" \ 1943 "blue-to-grey" "blue-to-grey" \ 1944 "green-to-magenta" "green-to-magenta" \ 1945 "greyscale" "greyscale" \ 1946 "nanohub" "nanohub" \ 1947 "rainbow" "rainbow" \ 1948 "spectral" "spectral" \ 1949 "ROYGB" "ROYGB" \ 1950 "RYGCB" "RYGCB" \ 1951 "brown-to-blue" "brown-to-blue" \ 1952 "grey-to-blue" "grey-to-blue" \ 1953 "orange-to-blue" "orange-to-blue" 1954 1954 1955 1955 $itk_component(palette) value "nanohub" 1956 1956 bind $inner.palette <<Value>> \ 1957 1957 [itcl::code $this AdjustSetting volume-palette] 1958 1958 1959 1959 blt::table $inner \ … … 2010 2010 2011 2011 itk_component add axismode { 2012 2012 Rappture::Combobox $inner.mode -width 10 -editable no 2013 2013 } 2014 2014 $inner.mode choices insert end \ … … 2075 2075 set inner [$itk_component(main) insert end \ 2076 2076 -title "Cutplane Settings" \ 2077 2077 -icon [Rappture::icon cutbutton]] 2078 2078 2079 2079 $inner configure -borderwidth 4 … … 2108 2108 -width 10 \ 2109 2109 -showvalue off \ 2110 2110 -command [itcl::code $this AdjustSetting cutplane-opacity] 2111 2111 $inner.opacity set $_settings(cutplane-opacity) 2112 2112 … … 2193 2193 2194 2194 blt::table $inner \ 2195 0,0 $inner.visible 2196 1,0 $inner.lighting 2197 2,0 $inner.wireframe 2198 3,0 $inner.edges 2199 4,0 $inner.opacity_l 2200 5,0 $inner.opacity 2195 0,0 $inner.visible -anchor w -pady 2 -cspan 4 \ 2196 1,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 2197 2,0 $inner.wireframe -anchor w -pady 2 -cspan 4 \ 2198 3,0 $inner.edges -anchor w -pady 2 -cspan 4 \ 2199 4,0 $inner.opacity_l -anchor w -pady 2 -cspan 3 \ 2200 5,0 $inner.opacity -fill x -pady 2 -cspan 3 \ 2201 2201 6,0 $itk_component(xCutButton) -anchor e -padx 2 -pady 2 \ 2202 2202 7,0 $itk_component(xCutScale) -fill y \ … … 2240 2240 "qx" - "qy" - "qz" - "qw" { 2241 2241 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2242 2243 2242 $_arcball quaternion $q 2243 EventuallyRotate $q 2244 2244 } 2245 2245 "zoom" { … … 2275 2275 foreach comp [$dataobj components] { 2276 2276 set tag $dataobj-$comp 2277 2278 2279 2277 #set contents [ConvertToVtkData $dataobj $comp] 2278 set contents [$dataobj blob $comp] 2279 append bytes "$contents\n\n" 2280 2280 } 2281 2281 } … … 2285 2285 itcl::body Rappture::VtkVolumeViewer::GetImage { args } { 2286 2286 if { [image width $_image(download)] > 0 && 2287 2288 2289 2290 2287 [image height $_image(download)] > 0 } { 2288 set bytes [$_image(download) data -format "jpeg -quality 100"] 2289 set bytes [Rappture::encoding::decode -as b64 $bytes] 2290 return [list .jpg $bytes] 2291 2291 } 2292 2292 return "" … … 2310 2310 2311 2311 button $inner.ok -text "Save" \ 2312 2312 -highlightthickness 0 -pady 2 -padx 3 \ 2313 2313 -command $command \ 2314 2315 2314 -compound left \ 2315 -image [Rappture::icon download] 2316 2316 2317 2317 button $inner.cancel -text "Cancel" \ 2318 2319 2320 2321 2318 -highlightthickness 0 -pady 2 -padx 3 \ 2319 -command [list $popup deactivate] \ 2320 -compound left \ 2321 -image [Rappture::icon cancel] 2322 2322 2323 2323 blt::table $inner \ … … 2339 2339 set style [$dataobj style $comp] 2340 2340 array set settings { 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2341 -color \#808080 2342 -edges 0 2343 -edgecolor black 2344 -linewidth 1.0 2345 -opacity 0.4 2346 -wireframe 0 2347 -lighting 1 2348 -seeds 1 2349 -seedcolor white 2350 -visible 1 2351 2351 } 2352 2352 if { $dataobj != $_first } { 2353 2353 set settings(-opacity) 1 2354 2354 } 2355 2355 array set settings $style … … 2363 2363 #SendCmd "cutplane visible $tag" 2364 2364 foreach axis { x y z } { 2365 2366 2365 SendCmd "cutplane slice $axis 1.0 $tag" 2366 SendCmd "cutplane axis $axis 0 $tag" 2367 2367 } 2368 2368 … … 2374 2374 itcl::body Rappture::VtkVolumeViewer::IsValidObject { dataobj } { 2375 2375 if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} { 2376 2376 return 0 2377 2377 } 2378 2378 return 1 … … 2400 2400 $_image(legend) configure -data $bytes 2401 2401 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2402 2403 2404 2402 if { [catch {DrawLegend $_title} errs] != 0 } { 2403 puts stderr errs=$errs 2404 } 2405 2405 } 2406 2406 } … … 2409 2409 # DrawLegend -- 2410 2410 # 2411 # 2412 # 2411 # Draws the legend in it's own canvas which resides to the right 2412 # of the contour plot area. 2413 2413 # 2414 2414 itcl::body Rappture::VtkVolumeViewer::DrawLegend { name } { … … 2420 2420 2421 2421 if { [info exists _fields($name)] } { 2422 2423 2424 2425 2422 foreach { title units } $_fields($name) break 2423 if { $units != "" } { 2424 set title [format "%s (%s)" $title $units] 2425 } 2426 2426 } else { 2427 2427 set title $name 2428 2428 } 2429 2429 if { $_settings(legend-visible) } { 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2430 set x [expr $w - 2] 2431 if { [$c find withtag "legend"] == "" } { 2432 set y 2 2433 $c create text $x $y \ 2434 -anchor ne \ 2435 -fill $itk_option(-plotforeground) -tags "title legend" \ 2436 -font $font 2437 incr y $lineht 2438 $c create text $x $y \ 2439 -anchor ne \ 2440 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2441 -font $font 2442 incr y $lineht 2443 $c create image $x $y \ 2444 -anchor ne \ 2445 -image $_image(legend) -tags "colormap legend" 2446 $c create text $x [expr {$h-2}] \ 2447 -anchor se \ 2448 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2449 -font $font 2450 #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y] 2451 $c bind colormap <Leave> [itcl::code $this LeaveLegend] 2452 $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y] 2453 } 2454 $c bind title <ButtonPress> [itcl::code $this Combo post] 2455 $c bind title <Enter> [itcl::code $this Combo activate] 2456 $c bind title <Leave> [itcl::code $this Combo deactivate] 2457 # Reset the item coordinates according the current size of the plot. 2458 $c itemconfigure title -text $title 2459 if { $_limits(vmin) != "" } { 2460 $c itemconfigure vmin -text [format %g $_limits(vmin)] 2461 } 2462 if { $_limits(vmax) != "" } { 2463 $c itemconfigure vmax -text [format %g $_limits(vmax)] 2464 } 2465 set y 2 2466 $c coords title $x $y 2467 incr y $lineht 2468 $c coords vmax $x $y 2469 incr y $lineht 2470 $c coords colormap $x $y 2471 $c coords vmin $x [expr {$h - 2}] 2472 2472 } 2473 2473 } … … 2513 2513 2514 2514 if { [info exists _fields($_title)] } { 2515 2516 2517 2518 2515 foreach { title units } $_fields($_title) break 2516 if { $units != "" } { 2517 set title [format "%s (%s)" $title $units] 2518 } 2519 2519 } else { 2520 2520 set title $_title 2521 2521 } 2522 2522 # Make a swatch of the selected color 2523 2523 if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } { 2524 2525 2524 #puts stderr "out of range: $imgY" 2525 return 2526 2526 } 2527 2527 if { ![info exists _image(swatch)] } { 2528 2528 set _image(swatch) [image create photo -width 24 -height 24] 2529 2529 } 2530 2530 set color [eval format "\#%02x%02x%02x" $pixel] … … 2535 2535 # Compute the value of the point 2536 2536 if { [info exists _limits(vmax)] && [info exists _limits(vmin)] } { 2537 2538 2537 set t [expr 1.0 - (double($imgY) / double($imgHeight-1))] 2538 set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)] 2539 2539 } else { 2540 2540 set value 0.0 2541 2541 } 2542 2542 set tipx [expr $x + 15] … … 2567 2567 SendCmd "cutplane slice $axis $newpos" 2568 2568 } 2569 2570 2571 2572 2573 2569 "tooltip" { 2570 set axis [lindex $args 0] 2571 set val [$itk_component(${axis}CutScale) get] 2572 return "Move the [string toupper $axis] cut plane.\nCurrently: $axis = $val%" 2573 } 2574 2574 default { 2575 2575 error "bad option \"$option\": should be axis, move, or tooltip" … … 2594 2594 switch -- $option { 2595 2595 post { 2596 2597 2598 2599 2600 2601 2596 foreach { x1 y1 x2 y2 } [$c bbox title] break 2597 set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]] 2598 set x [expr $x1 + [winfo rootx $itk_component(view)]] 2599 set y [expr $y2 + [winfo rooty $itk_component(view)]] 2600 puts stderr "combo x=$x y=$y" 2601 tk_popup $itk_component(fieldmenu) $x $y 2602 2602 } 2603 2603 activate { 2604 2604 $c itemconfigure title -fill red 2605 2605 } 2606 2606 deactivate { 2607 2608 } 2609 2610 2611 2612 2607 $c itemconfigure title -fill white 2608 } 2609 invoke { 2610 $itk_component(field) value $_currentField 2611 AdjustSetting volume-field 2612 } 2613 2613 default { 2614 2614 error "bad option \"$option\": should be post, unpost, select"
Note: See TracChangeset
for help on using the changeset viewer.