Changeset 2744 for trunk/gui/scripts/vtkheightmapviewer.tcl
- Timestamp:
- Dec 27, 2011, 2:45:13 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkheightmapviewer.tcl
r2736 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 139 139 private variable _title "" 140 140 141 common _downloadPopup; 141 common _downloadPopup; # download options from popup 142 142 private common _hardcopy 143 143 private variable _width 0 … … 153 153 private variable _fields 154 154 private variable _currentField "" 155 private variable _field 155 private variable _field "" 156 156 private variable _numContours 10 157 157 private variable _colorMode "vmag";# Mode of colormap (vmag or scalar) … … 192 192 $_dispatcher register !xcutplane 193 193 $_dispatcher dispatch $this !xcutplane \ 194 194 "[itcl::code $this AdjustSetting cutplane-xposition]; list" 195 195 196 196 # Y-Cutplane event 197 197 $_dispatcher register !ycutplane 198 198 $_dispatcher dispatch $this !ycutplane \ 199 199 "[itcl::code $this AdjustSetting cutplane-yposition]; list" 200 200 201 201 # Z-Cutplane event 202 202 $_dispatcher register !zcutplane 203 203 $_dispatcher dispatch $this !zcutplane \ 204 204 "[itcl::code $this AdjustSetting cutplane-zposition]; list" 205 205 206 206 # … … 212 212 213 213 array set _outline { 214 215 216 217 218 219 214 id -1 215 afterId -1 216 x1 -1 217 y1 -1 218 x2 -1 219 y2 -1 220 220 } 221 221 # Initialize the view to some default parameters. 222 222 array set _view { 223 qw1224 qx0225 qy0226 qz0227 zoom 228 xpan 229 ypan 230 ortho 223 qw 1 224 qx 0 225 qy 0 226 qz 0 227 zoom 1.0 228 xpan 0 229 ypan 0 230 ortho 1 231 231 } 232 232 set _arcball [blt::arcball create 100 100] … … 238 238 239 239 array set _settings [subst { 240 axis-xgrid 241 axis-ygrid 242 axis-zgrid 243 axis-xcutplane 244 axis-ycutplane 245 axis-zcutplane 246 axis-xposition 247 axis-yposition 248 axis-zposition 249 axis-visible 250 axis-labels1251 cutplane-edges 252 cutplane-xvisible 253 cutplane-yvisible 254 cutplane-zvisible 255 cutplane-xposition 256 cutplane-yposition 257 cutplane-zposition 258 cutplane-visible 259 cutplane-wireframe 260 cutplane-opacity100261 surface-edges 262 surface-lighting 263 surface-opacity 264 surface-visible 265 surface-wireframe 266 surface-numcontours 267 surface-scale 268 legend-visible 240 axis-xgrid 0 241 axis-ygrid 0 242 axis-zgrid 0 243 axis-xcutplane 0 244 axis-ycutplane 0 245 axis-zcutplane 0 246 axis-xposition 0 247 axis-yposition 0 248 axis-zposition 0 249 axis-visible 1 250 axis-labels 1 251 cutplane-edges 0 252 cutplane-xvisible 0 253 cutplane-yvisible 0 254 cutplane-zvisible 0 255 cutplane-xposition 50 256 cutplane-yposition 50 257 cutplane-zposition 50 258 cutplane-visible 1 259 cutplane-wireframe 0 260 cutplane-opacity 100 261 surface-edges 0 262 surface-lighting 1 263 surface-opacity 40 264 surface-visible 1 265 surface-wireframe 0 266 surface-numcontours 10 267 surface-scale 1 268 legend-visible 1 269 269 }] 270 270 … … 279 279 itk_component add fieldmenu { 280 280 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 281 281 -tearoff no 282 282 } { 283 284 283 usual 284 ignore -background -foreground -relief -tearoff 285 285 } 286 286 set c $itk_component(view) … … 344 344 -onimage [Rappture::icon volume-on] \ 345 345 -offimage [Rappture::icon volume-off] \ 346 347 346 -variable [itcl::scope _settings(surface-visible)] \ 347 -command [itcl::code $this AdjustSetting surface-visible] 348 348 } 349 349 $itk_component(surface) select … … 356 356 -onimage [Rappture::icon cutbutton] \ 357 357 -offimage [Rappture::icon cutbutton] \ 358 359 358 -variable [itcl::scope _settings(cutplane-visible)] \ 359 -command [itcl::code $this AdjustSetting cutplane-visible] 360 360 } 361 361 $itk_component(cutplane) select … … 366 366 367 367 if { [catch { 368 369 370 371 368 BuildSurfaceTab 369 BuildCutplaneTab 370 BuildAxisTab 371 BuildCameraTab 372 372 } errs] != 0 } { 373 373 puts stderr errs=$errs 374 374 } 375 375 # Legend … … 469 469 itcl::body Rappture::VtkHeightmapViewer::DoResize {} { 470 470 if { $_width < 2 } { 471 471 set _width 500 472 472 } 473 473 if { $_height < 2 } { 474 474 set _height 500 475 475 } 476 476 set _start [clock clicks -milliseconds] … … 494 494 itcl::body Rappture::VtkHeightmapViewer::DoContour {} { 495 495 foreach dataset [CurrentDatasets -visible] { 496 497 496 foreach {dataobj comp} [split $dataset -] break 497 SendCmd "heightmap numcontours $_numContours $dataset" 498 498 } 499 499 set _contourPending 0 … … 524 524 if { !$_rotatePending } { 525 525 set _rotatePending 1 526 526 global rotate_delay 527 527 $_dispatcher event -after $rotate_delay !rotate 528 528 } … … 552 552 -description "" 553 553 -param "" 554 554 -type "" 555 555 } 556 556 array set params $settings … … 569 569 set pos [lsearch -exact $dataobj $_dlist] 570 570 if {$pos < 0} { 571 571 lappend _dlist $dataobj 572 572 } 573 573 set _obj2ovride($dataobj-color) $params(-color) … … 594 594 foreach dataobj $args { 595 595 set pos [lsearch -exact $_dlist $dataobj] 596 597 continue;# Don't know anything about it.598 599 600 601 602 603 604 605 606 596 if { $pos < 0 } { 597 continue; # Don't know anything about it. 598 } 599 # Remove it from the dataobj list. 600 set _dlist [lreplace $_dlist $pos $pos] 601 SendCmd "dataset visible 0" 602 array unset _obj2ovride $dataobj-* 603 array unset _settings $dataobj-* 604 # Append to the end of the dataobj list. 605 lappend _dlist $dataobj 606 set changed 1 607 607 } 608 608 # If anything changed, then rebuild the plot … … 628 628 set op [lindex $args 0] 629 629 switch -- $op { 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 672 673 674 675 676 677 678 679 680 681 630 "-objects" { 631 # put the dataobj list in order according to -raise options 632 set dlist {} 633 foreach dataobj $_dlist { 634 if { ![IsValidObject $dataobj] } { 635 continue 636 } 637 if {[info exists _obj2ovride($dataobj-raise)] && 638 $_obj2ovride($dataobj-raise)} { 639 set dlist [linsert $dlist 0 $dataobj] 640 } else { 641 lappend dlist $dataobj 642 } 643 } 644 return $dlist 645 } 646 "-visible" { 647 set dlist {} 648 foreach dataobj $_dlist { 649 if { ![IsValidObject $dataobj] } { 650 continue 651 } 652 if { ![info exists _obj2ovride($dataobj-raise)] } { 653 # No setting indicates that the object isn't visible. 654 continue 655 } 656 # Otherwise use the -raise parameter to put the object to 657 # the front of the list. 658 if { $_obj2ovride($dataobj-raise) } { 659 set dlist [linsert $dlist 0 $dataobj] 660 } else { 661 lappend dlist $dataobj 662 } 663 } 664 return $dlist 665 } 666 -image { 667 if {[llength $args] != 2} { 668 error "wrong # args: should be \"get -image view\"" 669 } 670 switch -- [lindex $args end] { 671 view { 672 return $_image(plot) 673 } 674 default { 675 error "bad image name \"[lindex $args end]\": should be view" 676 } 677 } 678 } 679 default { 680 error "bad option \"$op\": should be -objects or -image" 681 } 682 682 } 683 683 } … … 695 695 array unset _limits 696 696 foreach dataobj $args { 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 697 set string [limits $dataobj] 698 if { $string == "" } { 699 continue 700 } 701 array set bounds $string 702 if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} { 703 set _limits(xmin) $bounds(xmin) 704 } 705 if {![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax)} { 706 set _limits(xmax) $bounds(xmax) 707 } 708 709 if {![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin)} { 710 set _limits(ymin) $bounds(ymin) 711 } 712 if {![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax)} { 713 set _limits(ymax) $bounds(ymax) 714 } 715 716 if {![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin)} { 717 set _limits(zmin) $bounds(zmin) 718 } 719 if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} { 720 set _limits(zmax) $bounds(zmax) 721 } 722 722 } 723 723 } … … 755 755 set word [Rappture::filexfer::label downloadWord] 756 756 $inner.summary configure -text "$word $num in the following format:" 757 update idletasks 757 update idletasks ;# Fix initial sizes 758 758 return $popup 759 759 } … … 863 863 } else { 864 864 SendBytes "$string\n" 865 865 StartWaiting 866 866 } 867 867 } … … 899 899 StopWaiting 900 900 if { $info(-type) == "image" } { 901 902 903 904 905 901 if 0 { 902 set f [open "last.ppm" "w"] 903 puts $f $bytes 904 close $f 905 } 906 906 $_image(plot) configure -data $bytes 907 908 907 set time [clock seconds] 908 set date [clock format $time] 909 909 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 910 911 912 913 914 910 if { $_start > 0 } { 911 set finish [clock clicks -milliseconds] 912 #puts stderr "round trip time [expr $finish -$_start] milliseconds" 913 set _start 0 914 } 915 915 } elseif { $info(type) == "print" } { 916 916 set tag $this-print-$info(-token) … … 918 918 } 919 919 if { $_legendPending } { 920 920 RequestLegend 921 921 } 922 922 } … … 931 931 set option [lindex $args 0] 932 932 switch -- $option { 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 933 "scalar" { 934 set option [lindex $args 1] 935 switch -- $option { 936 "world" { 937 foreach { x y z value tag } [lrange $args 2 end] break 938 } 939 "pixel" { 940 foreach { x y value tag } [lrange $args 2 end] break 941 } 942 } 943 } 944 "vector" { 945 set option [lindex $args 1] 946 switch -- $option { 947 "world" { 948 foreach { x y z vx vy vz tag } [lrange $args 2 end] break 949 } 950 "pixel" { 951 foreach { x y vx vy vz tag } [lrange $args 2 end] break 952 } 953 } 954 } 955 "names" { 956 956 foreach { name } [lindex $args 1] { 957 957 #puts stderr "Dataset: $name" 958 958 } 959 960 961 962 959 } 960 default { 961 error "unknown dataset option \"$option\" from server" 962 } 963 963 } 964 964 } … … 976 976 set h [winfo height $itk_component(view)] 977 977 if { $w < 2 || $h < 2 } { 978 979 978 $_dispatcher event -idle !rebuild 979 return 980 980 } 981 981 … … 1004 1004 set _first "" 1005 1005 InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \ 1006 1007 1008 1006 axis-visible axis-labels cutplane-visible \ 1007 cutplane-xposition cutplane-yposition cutplane-zposition \ 1008 cutplane-xvisible cutplane-yvisible cutplane-zvisible 1009 1009 1010 1010 SendCmd "imgflush" … … 1014 1014 set _first "" 1015 1015 foreach dataobj [get -objects] { 1016 1017 1018 1019 1016 if { [info exists _obj2ovride($dataobj-raise)] && $_first == "" } { 1017 set _first $dataobj 1018 } 1019 set _obj2datasets($dataobj) "" 1020 1020 foreach comp [$dataobj components] { 1021 1021 set tag $dataobj-$comp 1022 1022 if { ![info exists _datasets($tag)] } { 1023 1023 set bytes [ConvertToVtkData $dataobj $comp] 1024 1024 puts stderr [GetVtkData] 1025 1025 set length [string length $bytes] 1026 1026 append _outbuf "dataset add $tag data follows $length\n" 1027 1027 append _outbuf $bytes 1028 1028 set _datasets($tag) 1 1029 1030 1031 1032 1033 1034 1035 1036 1029 SetObjectStyle $dataobj $comp 1030 } 1031 lappend _obj2datasets($dataobj) $tag 1032 if { [info exists _obj2ovride($dataobj-raise)] } { 1033 SendCmd "dataset visible 1 $tag" 1034 } else { 1035 SendCmd "dataset visible 0 $tag" 1036 } 1037 1037 } 1038 1038 } … … 1043 1043 } 1044 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 1100 1101 1102 1103 1104 1105 1106 1107 1108 1045 if 0 { 1046 # Tell the server the name of the tool, the version, and dataset 1047 # that we are rendering. Have to do it here because we don't know 1048 # what data objects are using the renderer until be get here. 1049 set args "" 1050 lappend args tool [$_first hints toolId] 1051 lappend args version [$_first hints toolRevision] 1052 lappend args dataset [$_first hints label] 1053 SendCmd "clientinfo $args" 1054 } 1055 1056 foreach axis { x y z } { 1057 set label [$_first hints ${axis}label] 1058 if { $label != "" } { 1059 SendCmd "axis name $axis $label" 1060 } 1061 set units [$_first hints ${axis}units] 1062 if { $units != "" } { 1063 SendCmd "axis units $axis $units" 1064 } 1065 } 1066 array unset _scalarFields 1067 array unset _vectorFields 1068 set _currentField [$_first hints default] 1069 $itk_component(field) choices delete 0 end 1070 $itk_component(fieldmenu) delete 0 end 1071 array unset _fields 1072 foreach { name title units } [$_first hints vectors] { 1073 set _vectorFields($title) $name 1074 $itk_component(field) choices insert end "$name" "$title" 1075 $itk_component(fieldmenu) add radiobutton -label "$title" \ 1076 -value $title -variable [itcl::scope _currentField] \ 1077 -selectcolor red \ 1078 -activebackground black \ 1079 -activeforeground white \ 1080 -font "Arial 8" \ 1081 -command [itcl::code $this Combo invoke] 1082 set _fields($name) [list $title $units] 1083 } 1084 foreach { name title units } [$_first hints scalars] { 1085 set _scalarFields($title) $name 1086 $itk_component(field) choices insert end "$name" "$title" 1087 $itk_component(fieldmenu) add radiobutton -label "$title" \ 1088 -value $title -variable [itcl::scope _currentField] \ 1089 -selectcolor red \ 1090 -activebackground black \ 1091 -activeforeground white \ 1092 -font "Arial 8" \ 1093 -command [itcl::code $this Combo invoke] 1094 set _fields($name) [list $title $units] 1095 } 1096 foreach { name title units } { default Default ??? } { 1097 set _scalarFields($title) $name 1098 $itk_component(field) choices insert end "$name" "$title" 1099 $itk_component(fieldmenu) add radiobutton -label "$title" \ 1100 -value $title -variable [itcl::scope _currentField] \ 1101 -selectcolor red \ 1102 -activebackground black \ 1103 -activeforeground white \ 1104 -font "Arial 8" \ 1105 -command [itcl::code $this Combo invoke] 1106 set _fields($name) [list $title $units] 1107 } 1108 $itk_component(field) value $_currentField 1109 1109 } 1110 1110 … … 1112 1112 1113 1113 if { $_reset } { 1114 1115 1116 1117 1118 1119 1114 InitSettings surface-opacity \ 1115 surface-numcontours surface-lighting \ 1116 surface-palette surface-field \ 1117 surface-edges surface-opacity surface-wireframe 1118 Zoom reset 1119 set _reset 0 1120 1120 } 1121 1121 set _buffering 0; # Turn off buffering. … … 1139 1139 set flag [lindex $args 0] 1140 1140 switch -- $flag { 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 }1160 1161 1162 1141 "-all" { 1142 if { [llength $args] > 1 } { 1143 error "CurrentDatasets: can't specify dataobj after \"-all\"" 1144 } 1145 set dlist [get -objects] 1146 } 1147 "-visible" { 1148 if { [llength $args] > 1 } { 1149 set dlist {} 1150 set args [lrange $args 1 end] 1151 foreach dataobj $args { 1152 if { [info exists _obj2ovride($dataobj-raise)] } { 1153 lappend dlist $dataobj 1154 } 1155 } 1156 } else { 1157 set dlist [get -visible] 1158 } 1159 } 1160 default { 1161 set dlist $args 1162 } 1163 1163 } 1164 1164 set rlist "" 1165 1165 foreach dataobj $dlist { 1166 1167 1168 1169 1170 1171 1166 foreach comp [$dataobj components] { 1167 set tag $dataobj-$comp 1168 if { [info exists _datasets($tag)] && $_datasets($tag) } { 1169 lappend rlist $tag 1170 } 1171 } 1172 1172 } 1173 1173 return $rlist … … 1186 1186 "in" { 1187 1187 set _view(zoom) [expr {$_view(zoom)*1.25}] 1188 1188 SendCmd "camera zoom $_view(zoom)" 1189 1189 } 1190 1190 "out" { 1191 1191 set _view(zoom) [expr {$_view(zoom)*0.8}] 1192 1192 SendCmd "camera zoom $_view(zoom)" 1193 1193 } 1194 1194 "reset" { 1195 1195 array set _view { 1196 qw11197 qx01198 qy01199 qz01196 qw 1 1197 qx 0 1198 qy 0 1199 qz 0 1200 1200 zoom 1.0 1201 1201 xpan 0 … … 1209 1209 } 1210 1210 } 1211 1212 1213 1211 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1212 $_arcball quaternion $q 1213 DoRotate 1214 1214 } 1215 1215 } … … 1255 1255 return 1256 1256 } 1257 1258 1259 1260 1261 1257 if { $dx == 0 && $dy == 0 } { 1258 return 1259 } 1260 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1261 EventuallyRotate $q 1262 1262 set _click(x) $x 1263 1263 set _click(y) $y … … 1291 1291 itcl::body Rappture::VtkHeightmapViewer::Pan {option x y} { 1292 1292 switch -- $option { 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 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1293 "set" { 1294 set w [winfo width $itk_component(view)] 1295 set h [winfo height $itk_component(view)] 1296 set x [expr $x / double($w)] 1297 set y [expr $y / double($h)] 1298 set _view(xpan) [expr $_view(xpan) + $x] 1299 set _view(ypan) [expr $_view(ypan) + $y] 1300 PanCamera 1301 return 1302 } 1303 "click" { 1304 set _click(x) $x 1305 set _click(y) $y 1306 $itk_component(view) configure -cursor hand1 1307 } 1308 "drag" { 1309 if { ![info exists _click(x)] } { 1310 set _click(x) $x 1311 } 1312 if { ![info exists _click(y)] } { 1313 set _click(y) $y 1314 } 1315 set w [winfo width $itk_component(view)] 1316 set h [winfo height $itk_component(view)] 1317 set dx [expr ($_click(x) - $x)/double($w)] 1318 set dy [expr ($_click(y) - $y)/double($h)] 1319 set _click(x) $x 1320 set _click(y) $y 1321 set _view(xpan) [expr $_view(xpan) - $dx] 1322 set _view(ypan) [expr $_view(ypan) - $dy] 1323 PanCamera 1324 } 1325 "release" { 1326 Pan drag $x $y 1327 $itk_component(view) configure -cursor "" 1328 } 1329 default { 1330 error "unknown option \"$option\": should set, click, drag, or release" 1331 } 1332 1332 } 1333 1333 } … … 1342 1342 itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } { 1343 1343 foreach spec $args { 1344 1345 1346 1347 1348 1344 if { [info exists _settings($_first-$spec)] } { 1345 # Reset global setting with dataobj specific setting 1346 set _settings($spec) $_settings($_first-$spec) 1347 } 1348 AdjustSetting $spec 1349 1349 } 1350 1350 } … … 1353 1353 # AdjustSetting -- 1354 1354 # 1355 # 1356 # 1357 # 1355 # Changes/updates a specific setting in the widget. There are 1356 # usually user-setable option. Commands are sent to the render 1357 # server. 1358 1358 # 1359 1359 itcl::body Rappture::VtkHeightmapViewer::AdjustSetting {what {value ""}} { 1360 1360 if { ![isconnected] } { 1361 1361 return 1362 1362 } 1363 1363 switch -- $what { 1364 1364 "surface-opacity" { 1365 1366 1367 1368 1369 1365 set val $_settings(surface-opacity) 1366 set sval [expr { 0.01 * double($val) }] 1367 foreach dataset [CurrentDatasets -visible] { 1368 SendCmd "heightmap opacity $sval $dataset" 1369 } 1370 1370 } 1371 1371 "surface-wireframe" { 1372 1373 1374 1372 set bool $_settings(surface-wireframe) 1373 foreach dataset [CurrentDatasets -visible] { 1374 SendCmd "heightmap wireframe $bool $dataset" 1375 1375 } 1376 1376 } 1377 1377 "surface-visible" { 1378 1379 1380 1381 } 1382 1383 1384 1385 1386 1387 1388 1378 set bool $_settings(surface-visible) 1379 foreach dataset [CurrentDatasets -visible] { 1380 SendCmd "heightmap visible $bool $dataset" 1381 } 1382 if { $bool } { 1383 Rappture::Tooltip::for $itk_component(surface) \ 1384 "Hide the surface" 1385 } else { 1386 Rappture::Tooltip::for $itk_component(surface) \ 1387 "Show the surface" 1388 } 1389 1389 } 1390 1390 "surface-lighting" { 1391 1392 1393 1391 set bool $_settings(surface-lighting) 1392 foreach dataset [CurrentDatasets -visible] { 1393 SendCmd "heightmap lighting $bool $dataset" 1394 1394 } 1395 1395 } 1396 1396 "surface-edges" { 1397 1398 1399 1397 set bool $_settings(surface-edges) 1398 foreach dataset [CurrentDatasets -visible] { 1399 SendCmd "heightmap edges $bool $dataset" 1400 1400 } 1401 1401 } 1402 1402 "axis-visible" { 1403 1404 1403 set bool $_settings(axis-visible) 1404 SendCmd "axis visible all $bool" 1405 1405 } 1406 1406 "axis-labels" { 1407 1408 1407 set bool $_settings(axis-labels) 1408 SendCmd "axis labels all $bool" 1409 1409 } 1410 1410 "axis-xgrid" - "axis-ygrid" - "axis-zgrid" { 1411 1412 1413 1411 set axis [string range $what 5 5] 1412 set bool $_settings($what) 1413 SendCmd "axis grid $axis $bool" 1414 1414 } 1415 1415 "axis-mode" { 1416 1417 1418 1419 1416 set mode [$itk_component(axismode) value] 1417 set mode [$itk_component(axismode) translate $mode] 1418 set _settings($what) $mode 1419 SendCmd "axis flymode $mode" 1420 1420 } 1421 1421 "cutplane-edges" { 1422 1423 1424 1422 set bool $_settings($what) 1423 foreach dataset [CurrentDatasets -visible] { 1424 SendCmd "cutplane edges $bool $dataset" 1425 1425 } 1426 1426 } 1427 1427 "cutplane-visible" { 1428 1429 1430 1428 set bool $_settings($what) 1429 foreach dataset [CurrentDatasets -visible] { 1430 SendCmd "cutplane visible $bool $dataset" 1431 1431 } 1432 1432 } 1433 1433 "cutplane-wireframe" { 1434 1435 1436 1434 set bool $_settings($what) 1435 foreach dataset [CurrentDatasets -visible] { 1436 SendCmd "cutplane wireframe $bool $dataset" 1437 1437 } 1438 1438 } 1439 1439 "cutplane-lighting" { 1440 1441 1442 1440 set bool $_settings($what) 1441 foreach dataset [CurrentDatasets -visible] { 1442 SendCmd "cutplane lighting $bool $dataset" 1443 1443 } 1444 1444 } 1445 1445 "cutplane-opacity" { 1446 1447 1448 1449 1450 1451 } 1452 1453 1454 1446 set val $_settings($what) 1447 set sval [expr { 0.01 * double($val) }] 1448 foreach dataset [CurrentDatasets -visible] { 1449 SendCmd "cutplane opacity $sval $dataset" 1450 } 1451 } 1452 "cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" { 1453 set axis [string range $what 9 9] 1454 set bool $_settings($what) 1455 1455 if { $bool } { 1456 1456 $itk_component(${axis}CutScale) configure -state normal \ … … 1460 1460 -troughcolor grey82 1461 1461 } 1462 1463 1464 1465 1466 1467 1468 1469 1462 SendCmd "cutplane axis $axis $bool" 1463 } 1464 "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" { 1465 set axis [string range $what 9 9] 1466 set pos [expr $_settings($what) * 0.01] 1467 SendCmd "cutplane slice ${axis} ${pos}" 1468 set _cutplanePending 0 1469 } 1470 1470 "surface-numcontours" { 1471 1472 1471 set n $_settings($what) 1472 EventuallyContour $n 1473 1473 } 1474 1474 "surface-visible" { 1475 1476 1477 1478 } 1479 1480 1481 1482 1483 1484 1485 1475 set bool $_settings($what) 1476 foreach dataset [CurrentDatasets -visible] { 1477 SendCmd "surface visible $bool $dataset" 1478 } 1479 if { $bool } { 1480 Rappture::Tooltip::for $itk_component(surface) \ 1481 "Hide the surface" 1482 } else { 1483 Rappture::Tooltip::for $itk_component(surface) \ 1484 "Show the surface" 1485 } 1486 1486 } 1487 1487 "surface-palette" { 1488 1489 1490 1491 1492 1493 } 1494 1488 set palette [$itk_component(palette) value] 1489 set _settings(surface-palette) $palette 1490 foreach dataset [CurrentDatasets -visible $_first] { 1491 foreach {dataobj comp} [split $dataset -] break 1492 ChangeColormap $dataobj $comp $palette 1493 } 1494 set _legendPending 1 1495 1495 } 1496 1496 "surface-opacity" { 1497 1498 1499 1500 1501 1497 set val $_settings(surface-opacity) 1498 set sval [expr { 0.01 * double($val) }] 1499 foreach dataset [CurrentDatasets -visible $_first] { 1500 SendCmd "heightmap opacity $sval $dataset" 1501 } 1502 1502 } 1503 1503 "surface-scale" { 1504 1505 1506 1507 1508 1504 set val $_settings(surface-scale) 1505 set sval [expr { 0.01 * double($val) }] 1506 foreach dataset [CurrentDatasets -visible $_first] { 1507 SendCmd "heightmap scale $sval $sval $sval $dataset" 1508 } 1509 1509 } 1510 1510 "surface-lighting" { 1511 1512 1513 1511 set bool $_settings(surface-lighting) 1512 foreach dataset [CurrentDatasets -visible $_first] { 1513 SendCmd "heightmap lighting $bool $dataset" 1514 1514 } 1515 1515 } 1516 1516 "surface-field" { 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 } 1536 1517 set new [$itk_component(field) value] 1518 set value [$itk_component(field) translate $new] 1519 set _settings(surface-field) $value 1520 if { [info exists _scalarFields($new)] } { 1521 set name $_scalarFields($new) 1522 set _colorMode scalar 1523 set _currentField $new 1524 } elseif { [info exists _vectorFields($new)] } { 1525 set name $_vectorFields($new) 1526 set _colorMode vmag 1527 set _currentField $new 1528 } else { 1529 puts stderr "unknown field \"$new\"" 1530 return 1531 } 1532 foreach dataset [CurrentDatasets -visible] { 1533 puts stderr "cutplane colormode $_colorMode ${name} $dataset" 1534 SendCmd "cutplane colormode $_colorMode ${name} $dataset" 1535 } 1536 set _legendPending 1 1537 1537 } 1538 1538 default { … … 1545 1545 # RequestLegend -- 1546 1546 # 1547 # 1548 # 1549 # 1547 # Request a new legend from the server. The size of the legend 1548 # is determined from the height of the canvas. It will be rotated 1549 # to be vertical when drawn. 1550 1550 # 1551 1551 itcl::body Rappture::VtkHeightmapViewer::RequestLegend {} { … … 1556 1556 set h [expr {$_height - 3 * ($lineht + 2)}] 1557 1557 if { $h < 1} { 1558 1558 return 1559 1559 } 1560 1560 if { [info exists _scalarFields($_currentField)] } { 1561 1561 set name $_scalarFields($_currentField) 1562 1562 } elseif { [info exists _vectorFields($_currentField)] } { 1563 1563 set name $_vectorFields($_currentField) 1564 1564 } else { 1565 1565 return 1566 1566 } 1567 1567 # Set the legend on the first heightmap dataset. 1568 1568 foreach dataset [CurrentDatasets -visible $_first] { 1569 1570 1569 foreach {dataobj comp} [split $dataset -] break 1570 if { [info exists _dataset2style($dataset)] } { 1571 1571 SendCmdNoWait \ 1572 1573 1572 "legend $_dataset2style($dataset) $_colorMode $name {} $w $h 0" 1573 break; 1574 1574 } 1575 1575 } … … 1582 1582 set tag $dataobj-$comp 1583 1583 if { ![info exist _style($tag)] } { 1584 1584 error "no initial colormap" 1585 1585 } 1586 1586 array set style $_style($tag) … … 1601 1601 set tag $dataobj-$comp 1602 1602 if { ![info exists _initialStyle($tag)] } { 1603 1604 1603 # Save the initial component style. 1604 set _initialStyle($tag) [$dataobj style $comp] 1605 1605 } 1606 1606 … … 1609 1609 1610 1610 if { ![info exists _style($tag)] } { 1611 1611 set _style($tag) [array get style] 1612 1612 } 1613 1613 # Override initial style with current style. … … 1616 1616 set name "$style(-color):$style(-levels):$style(-opacity)" 1617 1617 if { ![info exists _colormaps($name)] } { 1618 1619 1618 BuildColormap $name [array get style] 1619 set _colormaps($name) 1 1620 1620 } 1621 1621 if { ![info exists _dataset2style($tag)] || 1622 1623 1624 1625 1622 $_dataset2style($tag) != $name } { 1623 SendCmd "heightmap colormap $name $tag" 1624 SendCmd "cutplane colormap $name $tag" 1625 set _dataset2style($tag) $name 1626 1626 } 1627 1627 } … … 1629 1629 itcl::body Rappture::VtkHeightmapViewer::ColorsToColormap { colors } { 1630 1630 switch -- $colors { 1631 1632 1633 0.00.200 0.200 0.2001634 0.142857142857142850.400 0.400 0.4001635 0.28571428571428570.600 0.600 0.6001636 0.428571428571428550.900 0.900 0.9001637 0.57142857142857140.800 1.000 1.0001638 0.71428571428571430.600 1.000 1.0001639 0.85714285714285710.400 0.900 1.0001640 1.00.000 0.600 0.8001641 1642 1643 1644 1645 0.00.000 0.600 0.8001646 0.142857142857142850.400 0.900 1.0001647 0.28571428571428570.600 1.000 1.0001648 0.428571428571428550.800 1.000 1.0001649 0.57142857142857140.900 0.900 0.9001650 0.71428571428571430.600 0.600 0.6001651 0.85714285714285710.400 0.400 0.4001652 1.00.200 0.200 0.2001653 1654 1655 1656 1657 0.00.900 1.000 1.0001658 0.11111111111111110.800 0.983 1.0001659 0.22222222222222220.700 0.950 1.0001660 0.33333333333333330.600 0.900 1.0001661 0.44444444444444440.500 0.833 1.0001662 0.55555555555555560.400 0.750 1.0001663 0.66666666666666660.300 0.650 1.0001664 0.77777777777777780.200 0.533 1.0001665 0.88888888888888880.100 0.400 1.0001666 1.00.000 0.250 1.0001667 1668 1669 1670 1671 0.00.200 0.100 0.0001672 0.090909090909090910.400 0.187 0.0001673 0.181818181818181820.600 0.379 0.2101674 0.27272727272727270.800 0.608 0.4801675 0.363636363636363650.850 0.688 0.5951676 0.454545454545454530.950 0.855 0.8081677 0.54545454545454540.800 0.993 1.0001678 0.63636363636363640.600 0.973 1.0001679 0.72727272727272730.400 0.940 1.0001680 0.81818181818181820.200 0.893 1.0001681 0.90909090909090910.000 0.667 0.8001682 1.00.000 0.480 0.6001683 1684 1685 1686 1687 0.00.000 0.480 0.6001688 0.090909090909090910.000 0.667 0.8001689 0.181818181818181820.200 0.893 1.0001690 0.27272727272727270.400 0.940 1.0001691 0.363636363636363650.600 0.973 1.0001692 0.454545454545454530.800 0.993 1.0001693 0.54545454545454540.950 0.855 0.8081694 0.63636363636363640.850 0.688 0.5951695 0.72727272727272730.800 0.608 0.4801696 0.81818181818181820.600 0.379 0.2101697 0.90909090909090910.400 0.187 0.0001698 1.00.200 0.100 0.0001699 1700 1701 1702 1703 0.00.000 0.167 1.0001704 0.090909090909090910.100 0.400 1.0001705 0.181818181818181820.200 0.600 1.0001706 0.27272727272727270.400 0.800 1.0001707 0.363636363636363650.600 0.933 1.0001708 0.454545454545454530.800 1.000 1.0001709 0.54545454545454541.000 1.000 0.8001710 0.63636363636363641.000 0.933 0.6001711 0.72727272727272731.000 0.800 0.4001712 0.81818181818181821.000 0.600 0.2001713 0.90909090909090911.000 0.400 0.1001714 1.01.000 0.167 0.0001715 1716 1717 1718 1719 0.01.000 0.167 0.0001720 0.090909090909090911.000 0.400 0.1001721 0.181818181818181821.000 0.600 0.2001722 0.27272727272727271.000 0.800 0.4001723 0.363636363636363651.000 0.933 0.6001724 0.454545454545454531.000 1.000 0.8001725 0.54545454545454540.800 1.000 1.0001726 0.63636363636363640.600 0.933 1.0001727 0.72727272727272730.400 0.800 1.0001728 0.81818181818181820.200 0.600 1.0001729 0.90909090909090910.100 0.400 1.0001730 1.00.000 0.167 1.0001731 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 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1631 "grey-to-blue" { 1632 return { 1633 0.0 0.200 0.200 0.200 1634 0.14285714285714285 0.400 0.400 0.400 1635 0.2857142857142857 0.600 0.600 0.600 1636 0.42857142857142855 0.900 0.900 0.900 1637 0.5714285714285714 0.800 1.000 1.000 1638 0.7142857142857143 0.600 1.000 1.000 1639 0.8571428571428571 0.400 0.900 1.000 1640 1.0 0.000 0.600 0.800 1641 } 1642 } 1643 "blue-to-grey" { 1644 return { 1645 0.0 0.000 0.600 0.800 1646 0.14285714285714285 0.400 0.900 1.000 1647 0.2857142857142857 0.600 1.000 1.000 1648 0.42857142857142855 0.800 1.000 1.000 1649 0.5714285714285714 0.900 0.900 0.900 1650 0.7142857142857143 0.600 0.600 0.600 1651 0.8571428571428571 0.400 0.400 0.400 1652 1.0 0.200 0.200 0.200 1653 } 1654 } 1655 "blue" { 1656 return { 1657 0.0 0.900 1.000 1.000 1658 0.1111111111111111 0.800 0.983 1.000 1659 0.2222222222222222 0.700 0.950 1.000 1660 0.3333333333333333 0.600 0.900 1.000 1661 0.4444444444444444 0.500 0.833 1.000 1662 0.5555555555555556 0.400 0.750 1.000 1663 0.6666666666666666 0.300 0.650 1.000 1664 0.7777777777777778 0.200 0.533 1.000 1665 0.8888888888888888 0.100 0.400 1.000 1666 1.0 0.000 0.250 1.000 1667 } 1668 } 1669 "brown-to-blue" { 1670 return { 1671 0.0 0.200 0.100 0.000 1672 0.09090909090909091 0.400 0.187 0.000 1673 0.18181818181818182 0.600 0.379 0.210 1674 0.2727272727272727 0.800 0.608 0.480 1675 0.36363636363636365 0.850 0.688 0.595 1676 0.45454545454545453 0.950 0.855 0.808 1677 0.5454545454545454 0.800 0.993 1.000 1678 0.6363636363636364 0.600 0.973 1.000 1679 0.7272727272727273 0.400 0.940 1.000 1680 0.8181818181818182 0.200 0.893 1.000 1681 0.9090909090909091 0.000 0.667 0.800 1682 1.0 0.000 0.480 0.600 1683 } 1684 } 1685 "blue-to-brown" { 1686 return { 1687 0.0 0.000 0.480 0.600 1688 0.09090909090909091 0.000 0.667 0.800 1689 0.18181818181818182 0.200 0.893 1.000 1690 0.2727272727272727 0.400 0.940 1.000 1691 0.36363636363636365 0.600 0.973 1.000 1692 0.45454545454545453 0.800 0.993 1.000 1693 0.5454545454545454 0.950 0.855 0.808 1694 0.6363636363636364 0.850 0.688 0.595 1695 0.7272727272727273 0.800 0.608 0.480 1696 0.8181818181818182 0.600 0.379 0.210 1697 0.9090909090909091 0.400 0.187 0.000 1698 1.0 0.200 0.100 0.000 1699 } 1700 } 1701 "blue-to-orange" { 1702 return { 1703 0.0 0.000 0.167 1.000 1704 0.09090909090909091 0.100 0.400 1.000 1705 0.18181818181818182 0.200 0.600 1.000 1706 0.2727272727272727 0.400 0.800 1.000 1707 0.36363636363636365 0.600 0.933 1.000 1708 0.45454545454545453 0.800 1.000 1.000 1709 0.5454545454545454 1.000 1.000 0.800 1710 0.6363636363636364 1.000 0.933 0.600 1711 0.7272727272727273 1.000 0.800 0.400 1712 0.8181818181818182 1.000 0.600 0.200 1713 0.9090909090909091 1.000 0.400 0.100 1714 1.0 1.000 0.167 0.000 1715 } 1716 } 1717 "orange-to-blue" { 1718 return { 1719 0.0 1.000 0.167 0.000 1720 0.09090909090909091 1.000 0.400 0.100 1721 0.18181818181818182 1.000 0.600 0.200 1722 0.2727272727272727 1.000 0.800 0.400 1723 0.36363636363636365 1.000 0.933 0.600 1724 0.45454545454545453 1.000 1.000 0.800 1725 0.5454545454545454 0.800 1.000 1.000 1726 0.6363636363636364 0.600 0.933 1.000 1727 0.7272727272727273 0.400 0.800 1.000 1728 0.8181818181818182 0.200 0.600 1.000 1729 0.9090909090909091 0.100 0.400 1.000 1730 1.0 0.000 0.167 1.000 1731 } 1732 } 1733 "rainbow" { 1734 set clist { 1735 "#EE82EE" 1736 "#4B0082" 1737 "blue" 1738 "#008000" 1739 "yellow" 1740 "#FFA500" 1741 "red" 1742 } 1743 } 1744 "BGYOR" { 1745 set clist { 1746 "blue" 1747 "#008000" 1748 "yellow" 1749 "#FFA500" 1750 "red" 1751 } 1752 } 1753 "ROYGB" { 1754 set clist { 1755 "red" 1756 "#FFA500" 1757 "yellow" 1758 "#008000" 1759 "blue" 1760 } 1761 } 1762 "RYGCB" { 1763 set clist { 1764 "red" 1765 "yellow" 1766 "green" 1767 "cyan" 1768 "blue" 1769 } 1770 } 1771 "BCGYR" { 1772 set clist { 1773 "blue" 1774 "cyan" 1775 "green" 1776 "yellow" 1777 "red" 1778 } 1779 } 1780 "spectral" { 1781 return { 1782 0.0 0.150 0.300 1.000 1783 0.1 0.250 0.630 1.000 1784 0.2 0.450 0.850 1.000 1785 0.3 0.670 0.970 1.000 1786 0.4 0.880 1.000 1.000 1787 0.5 1.000 1.000 0.750 1788 0.6 1.000 0.880 0.600 1789 0.7 1.000 0.680 0.450 1790 0.8 0.970 0.430 0.370 1791 0.9 0.850 0.150 0.196 1792 1.0 0.650 0.000 0.130 1793 } 1794 } 1795 "green-to-magenta" { 1796 return { 1797 0.0 0.000 0.316 0.000 1798 0.06666666666666667 0.000 0.526 0.000 1799 0.13333333333333333 0.000 0.737 0.000 1800 0.2 0.000 0.947 0.000 1801 0.26666666666666666 0.316 1.000 0.316 1802 0.3333333333333333 0.526 1.000 0.526 1803 0.4 0.737 1.000 0.737 1804 0.4666666666666667 1.000 1.000 1.000 1805 0.5333333333333333 1.000 0.947 1.000 1806 0.6 1.000 0.737 1.000 1807 0.6666666666666666 1.000 0.526 1.000 1808 0.7333333333333333 1.000 0.316 1.000 1809 0.8 0.947 0.000 0.947 1810 0.8666666666666667 0.737 0.000 0.737 1811 0.9333333333333333 0.526 0.000 0.526 1812 1.0 0.316 0.000 0.316 1813 } 1814 } 1815 "greyscale" { 1816 return { 1817 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1818 } 1819 } 1820 "nanohub" { 1821 set clist "white yellow green cyan blue magenta" 1822 } 1823 default { 1824 set clist $colors 1825 } 1826 1826 } 1827 1827 set cmap {} … … 1841 1841 set cmap [ColorsToColormap $style(-color)] 1842 1842 if { [llength $cmap] == 0 } { 1843 1843 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1844 1844 } 1845 1845 if { ![info exists _settings(surface-opacity)] } { … … 1877 1877 array unset _limits $dataobj-* 1878 1878 foreach comp [$dataobj components] { 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1879 set tag $dataobj-$comp 1880 if { ![info exists _limits($tag)] } { 1881 set data [$dataobj blob $comp] 1882 set tmpfile file[pid].vtk 1883 set f [open "$tmpfile" "w"] 1884 fconfigure $f -translation binary -encoding binary 1885 puts $f $data 1886 close $f 1887 set reader [vtkDataSetReader $tag-xvtkDataSetReader] 1888 $reader SetFileName $tmpfile 1889 $reader ReadAllScalarsOn 1890 $reader ReadAllVectorsOn 1891 $reader ReadAllFieldsOn 1892 $reader Update 1893 set output [$reader GetOutput] 1894 set _limits($tag) [$output GetBounds] 1895 set pointData [$output GetPointData] 1896 puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]" 1897 puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]" 1898 puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]" 1899 set fieldData [$output GetFieldData] 1900 set pointData [$output GetPointData] 1901 puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]" 1902 for { set i 0 } { $i < [$fieldData GetNumberOfArrays] } { incr i } { 1903 puts stderr [$fieldData GetArrayName $i] 1904 } 1905 puts stderr "point \#arrays=[$pointData GetNumberOfArrays]" 1906 for { set i 0 } { $i < [$pointData GetNumberOfArrays] } { incr i } { 1907 set name [$pointData GetArrayName $i] 1908 if { ![info exists _fields($name)] } { 1909 $itk_component(field) choices insert end "$name" "$name" 1910 set _fields($name) 1 1911 } 1912 } 1913 puts stderr "field \#components=[$fieldData GetNumberOfComponents]" 1914 puts stderr "point \#components=[$pointData GetNumberOfComponents]" 1915 puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]" 1916 puts stderr "point \#tuples=[$pointData GetNumberOfTuples]" 1917 puts stderr "point \#scalars=[$pointData GetScalars]" 1918 puts stderr vectors=[$pointData GetVectors] 1919 rename $output "" 1920 rename $reader "" 1921 file delete $tmpfile 1922 } 1923 1923 foreach { xMin xMax yMin yMax zMin zMax} $_limits($tag) break 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1924 if {![info exists limits(xmin)] || $limits(xmin) > $xMin} { 1925 set limits(xmin) $xMin 1926 } 1927 if {![info exists limits(xmax)] || $limits(xmax) < $xMax} { 1928 set limits(xmax) $xMax 1929 } 1930 if {![info exists limits(ymin)] || $limits(ymin) > $yMin} { 1931 set limits(ymin) $xMin 1932 } 1933 if {![info exists limits(ymax)] || $limits(ymax) < $yMax} { 1934 set limits(ymax) $yMax 1935 } 1936 if {![info exists limits(zmin)] || $limits(zmin) > $zMin} { 1937 set limits(zmin) $zMin 1938 } 1939 if {![info exists limits(zmax)] || $limits(zmax) < $zMax} { 1940 set limits(zmax) $zMax 1941 } 1942 1942 } 1943 1943 return [array get limits] … … 1983 1983 -width 10 \ 1984 1984 -showvalue off \ 1985 1985 -command [itcl::code $this AdjustSetting surface-opacity] 1986 1986 1987 1987 label $inner.numcontours_l -text "Number of contours" -font "Arial 9" … … 1990 1990 -width 10 \ 1991 1991 -showvalue on \ 1992 1992 -command [itcl::code $this AdjustSetting surface-numcontours] 1993 1993 1994 1994 label $inner.scale_l -text "Scale" -font "Arial 9" … … 1997 1997 -width 10 \ 1998 1998 -showvalue off \ 1999 1999 -command [itcl::code $this AdjustSetting surface-scale] 2000 2000 2001 2001 label $inner.field_l -text "Field" -font "Arial 9" 2002 2002 itk_component add field { 2003 2003 Rappture::Combobox $inner.field -width 10 -editable no 2004 2004 } 2005 2005 bind $inner.field <<Value>> \ 2006 2006 [itcl::code $this AdjustSetting surface-field] 2007 2007 2008 2008 label $inner.palette_l -text "Palette" -font "Arial 9" 2009 2009 itk_component add palette { 2010 2010 Rappture::Combobox $inner.palette -width 10 -editable no 2011 2011 } 2012 2012 $inner.palette choices insert end \ 2013 "BCGYR" "BCGYR"\2014 "BGYOR" "BGYOR"\2015 "blue" "blue"\2016 2017 2018 "blue-to-grey" "blue-to-grey"\2019 "green-to-magenta" "green-to-magenta"\2020 "greyscale" "greyscale"\2021 2022 "rainbow" "rainbow"\2023 "spectral" "spectral"\2024 "ROYGB" "ROYGB"\2025 "RYGCB" "RYGCB"\2026 2027 "grey-to-blue" "grey-to-blue"\2028 2013 "BCGYR" "BCGYR" \ 2014 "BGYOR" "BGYOR" \ 2015 "blue" "blue" \ 2016 "blue-to-brown" "blue-to-brown" \ 2017 "blue-to-orange" "blue-to-orange" \ 2018 "blue-to-grey" "blue-to-grey" \ 2019 "green-to-magenta" "green-to-magenta" \ 2020 "greyscale" "greyscale" \ 2021 "nanohub" "nanohub" \ 2022 "rainbow" "rainbow" \ 2023 "spectral" "spectral" \ 2024 "ROYGB" "ROYGB" \ 2025 "RYGCB" "RYGCB" \ 2026 "brown-to-blue" "brown-to-blue" \ 2027 "grey-to-blue" "grey-to-blue" \ 2028 "orange-to-blue" "orange-to-blue" 2029 2029 2030 2030 $itk_component(palette) value "BCGYR" 2031 2031 bind $inner.palette <<Value>> \ 2032 2032 [itcl::code $this AdjustSetting surface-palette] 2033 2033 2034 2034 blt::table $inner \ … … 2092 2092 2093 2093 itk_component add axismode { 2094 2094 Rappture::Combobox $inner.mode -width 10 -editable no 2095 2095 } 2096 2096 $inner.mode choices insert end \ … … 2157 2157 set inner [$itk_component(main) insert end \ 2158 2158 -title "Cutplane Settings" \ 2159 2159 -icon [Rappture::icon cutbutton]] 2160 2160 2161 2161 $inner configure -borderwidth 4 … … 2190 2190 -width 10 \ 2191 2191 -showvalue off \ 2192 2192 -command [itcl::code $this AdjustSetting cutplane-opacity] 2193 2193 $inner.opacity set $_settings(cutplane-opacity) 2194 2194 … … 2275 2275 2276 2276 blt::table $inner \ 2277 0,0 $inner.visible 2278 1,0 $inner.lighting 2279 2,0 $inner.wireframe 2280 3,0 $inner.edges 2281 4,0 $inner.opacity_l 2282 5,0 $inner.opacity 2277 0,0 $inner.visible -anchor w -pady 2 -cspan 4 \ 2278 1,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 2279 2,0 $inner.wireframe -anchor w -pady 2 -cspan 4 \ 2280 3,0 $inner.edges -anchor w -pady 2 -cspan 4 \ 2281 4,0 $inner.opacity_l -anchor w -pady 2 -cspan 3 \ 2282 5,0 $inner.opacity -fill x -pady 2 -cspan 3 \ 2283 2283 6,0 $itk_component(xCutButton) -anchor e -padx 2 -pady 2 \ 2284 2284 7,0 $itk_component(xCutScale) -fill y \ … … 2322 2322 "qx" - "qy" - "qz" - "qw" { 2323 2323 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 2324 2325 2324 $_arcball quaternion $q 2325 EventuallyRotate $q 2326 2326 } 2327 2327 "zoom" { … … 2357 2357 foreach comp [$dataobj components] { 2358 2358 set tag $dataobj-$comp 2359 2360 2361 2359 set contents [ConvertToVtkData $dataobj $comp] 2360 #set contents [$dataobj vtkdata $comp] 2361 append bytes "$contents\n\n" 2362 2362 } 2363 2363 } … … 2367 2367 itcl::body Rappture::VtkHeightmapViewer::GetImage { args } { 2368 2368 if { [image width $_image(download)] > 0 && 2369 2370 2371 2372 2369 [image height $_image(download)] > 0 } { 2370 set bytes [$_image(download) data -format "jpeg -quality 100"] 2371 set bytes [Rappture::encoding::decode -as b64 $bytes] 2372 return [list .jpg $bytes] 2373 2373 } 2374 2374 return "" … … 2392 2392 2393 2393 button $inner.ok -text "Save" \ 2394 2394 -highlightthickness 0 -pady 2 -padx 3 \ 2395 2395 -command $command \ 2396 2397 2396 -compound left \ 2397 -image [Rappture::icon download] 2398 2398 2399 2399 button $inner.cancel -text "Cancel" \ 2400 2401 2402 2403 2400 -highlightthickness 0 -pady 2 -padx 3 \ 2401 -command [list $popup deactivate] \ 2402 -compound left \ 2403 -image [Rappture::icon cancel] 2404 2404 2405 2405 blt::table $inner \ … … 2421 2421 set style [$dataobj style $comp] 2422 2422 array set settings { 2423 2424 2425 2426 2427 2428 2429 2430 2423 -color \#808080 2424 -edges 0 2425 -edgecolor black 2426 -linewidth 1.0 2427 -opacity 0.4 2428 -wireframe 0 2429 -lighting 1 2430 -visible 1 2431 2431 } 2432 2432 if { $dataobj != $_first } { 2433 2433 set settings(-opacity) 1 2434 2434 } 2435 2435 array set settings $style … … 2443 2443 #SendCmd "cutplane visible $tag" 2444 2444 foreach axis { x y z } { 2445 2446 2445 #SendCmd "cutplane slice $axis 1.0 $tag" 2446 #SendCmd "cutplane axis $axis 0 $tag" 2447 2447 } 2448 2448 … … 2463 2463 itcl::body Rappture::VtkHeightmapViewer::IsValidObject { dataobj } { 2464 2464 if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} { 2465 2465 return 0 2466 2466 } 2467 2467 return 1 … … 2489 2489 $_image(legend) configure -data $bytes 2490 2490 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2491 2492 2493 2491 if { [catch {DrawLegend $_title} errs] != 0 } { 2492 puts stderr errs=$errs 2493 } 2494 2494 } 2495 2495 } … … 2498 2498 # DrawLegend -- 2499 2499 # 2500 # 2501 # 2500 # Draws the legend in it's own canvas which resides to the right 2501 # of the contour plot area. 2502 2502 # 2503 2503 itcl::body Rappture::VtkHeightmapViewer::DrawLegend { name } { … … 2509 2509 2510 2510 if { [info exists _fields($name)] } { 2511 2512 2513 2514 2511 foreach { title units } $_fields($name) break 2512 if { $units != "" } { 2513 set title [format "%s (%s)" $title $units] 2514 } 2515 2515 } else { 2516 2516 set title $name 2517 2517 } 2518 2518 if { $_settings(legend-visible) } { 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2519 set x [expr $w - 2] 2520 if { [$c find withtag "legend"] == "" } { 2521 set y 2 2522 $c create text $x $y \ 2523 -anchor ne \ 2524 -fill $itk_option(-plotforeground) -tags "title legend" \ 2525 -font $font 2526 incr y $lineht 2527 $c create text $x $y \ 2528 -anchor ne \ 2529 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2530 -font $font 2531 incr y $lineht 2532 $c create image $x $y \ 2533 -anchor ne \ 2534 -image $_image(legend) -tags "colormap legend" 2535 $c create text $x [expr {$h-2}] \ 2536 -anchor se \ 2537 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2538 -font $font 2539 #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y] 2540 $c bind colormap <Leave> [itcl::code $this LeaveLegend] 2541 $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y] 2542 } 2543 $c bind title <ButtonPress> [itcl::code $this Combo post] 2544 $c bind title <Enter> [itcl::code $this Combo activate] 2545 $c bind title <Leave> [itcl::code $this Combo deactivate] 2546 # Reset the item coordinates according the current size of the plot. 2547 $c itemconfigure title -text $title 2548 if { $_limits(vmin) != "" } { 2549 $c itemconfigure vmin -text [format %g $_limits(vmin)] 2550 } 2551 if { $_limits(vmax) != "" } { 2552 $c itemconfigure vmax -text [format %g $_limits(vmax)] 2553 } 2554 set y 2 2555 $c coords title $x $y 2556 incr y $lineht 2557 $c coords vmax $x $y 2558 incr y $lineht 2559 $c coords colormap $x $y 2560 $c coords vmin $x [expr {$h - 2}] 2561 2561 } 2562 2562 } … … 2602 2602 2603 2603 if { [info exists _fields($_title)] } { 2604 2605 2606 2607 2604 foreach { title units } $_fields($_title) break 2605 if { $units != "" } { 2606 set title [format "%s (%s)" $title $units] 2607 } 2608 2608 } else { 2609 2609 set title $_title 2610 2610 } 2611 2611 # Make a swatch of the selected color 2612 2612 if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } { 2613 2614 2613 #puts stderr "out of range: $imgY" 2614 return 2615 2615 } 2616 2616 if { ![info exists _image(swatch)] } { 2617 2617 set _image(swatch) [image create photo -width 24 -height 24] 2618 2618 } 2619 2619 set color [eval format "\#%02x%02x%02x" $pixel] … … 2624 2624 # Compute the value of the point 2625 2625 if { [info exists _limits(vmax)] && [info exists _limits(vmin)] } { 2626 2627 2626 set t [expr 1.0 - (double($imgY) / double($imgHeight-1))] 2627 set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)] 2628 2628 } else { 2629 2629 set value 0.0 2630 2630 } 2631 2631 set tipx [expr $x + 15] … … 2656 2656 SendCmd "cutplane slice $axis $newpos" 2657 2657 } 2658 2659 2660 2661 2662 2658 "tooltip" { 2659 set axis [lindex $args 0] 2660 set val [$itk_component(${axis}CutScale) get] 2661 return "Move the [string toupper $axis] cut plane.\nCurrently: $axis = $val%" 2662 } 2663 2663 default { 2664 2664 error "bad option \"$option\": should be axis, move, or tooltip" … … 2683 2683 switch -- $option { 2684 2684 post { 2685 2686 2687 2688 2689 2690 2685 foreach { x1 y1 x2 y2 } [$c bbox title] break 2686 set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]] 2687 set x [expr $x1 + [winfo rootx $itk_component(view)]] 2688 set y [expr $y2 + [winfo rooty $itk_component(view)]] 2689 puts stderr "combo x=$x y=$y" 2690 tk_popup $itk_component(fieldmenu) $x $y 2691 2691 } 2692 2692 activate { 2693 2693 $c itemconfigure title -fill red 2694 2694 } 2695 2695 deactivate { 2696 2697 } 2698 2699 2700 2701 2696 $c itemconfigure title -fill white 2697 } 2698 invoke { 2699 $itk_component(field) value $_currentField 2700 AdjustSetting surface-field 2701 } 2702 2702 default { 2703 2703 error "bad option \"$option\": should be post, unpost, select"
Note: See TracChangeset
for help on using the changeset viewer.