Changeset 5455 for branches/1.3
- Timestamp:
- May 7, 2015, 3:52:28 AM (10 years ago)
- Location:
- branches/1.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
-
branches/1.3/gui/scripts/flowvisviewer.tcl
r5454 r5455 76 76 private method BuildCutplanesTab {} 77 77 private method BuildViewTab {} 78 private method BuildVolumeComponents {} 78 79 private method BuildVolumeTab {} 79 80 private method ComputeTransferFunction { tf } 80 81 private method Connect {} 81 private method Current VolumeIds {{what -all}}82 private method CurrentDatasets {{what -all}} 82 83 private method Disconnect {} 84 private method DoResize {} 83 85 private method DrawLegend { tf } 86 private method EventuallyGoto { nSteps } 87 private method EventuallyRedrawLegend { } 84 88 private method EventuallyResize { w h } 85 private method EventuallyGoto { nSteps}86 private method EventuallyResizeLegend {}89 private method FixLegend {} 90 private method GetDatasetsWithComponent { cname } 87 91 private method GetFlowInfo { widget } 88 92 private method GetMovie { widget width height } … … 101 105 private method ReceiveImage { args } 102 106 private method ReceiveLegend { tf vmin vmax size } 103 private method Resize {}104 private method ResizeLegend {}105 107 private method Rotate {option x y} 106 108 private method SendFlowCmd { dataobj comp nbytes extents } … … 124 126 private variable _dlist "" ;# list of data objects 125 127 private variable _obj2ovride ;# maps dataobj => style override 126 private variable _serverDatasets ;# maps dataobj-component to volume ID127 #in the server128 private variable _serverDatasets ;# contains all the dataobj-component 129 ;# to volumes in the server 128 130 private variable _recvdDatasets ;# list of data objs to send to server 129 131 private variable _dataset2style ;# maps dataobj-component to transfunc 130 132 private variable _style2datasets ;# maps tf back to list of 131 133 ;# dataobj-components using the tf. 132 134 private variable _dataset2flow ;# Maps dataobj-component to a flow. 133 135 … … 138 140 private variable _isomarkers ;# array of isosurface level values 0..1 139 141 private variable _settings 140 private variable _activeTf "" ;# The currently active transfer function142 private variable _activeTf "" ;# Currently active transfer function 141 143 private variable _first "" ;# This is the topmost volume. 144 private variable _volcomponents ;# Maps component name to list of 145 ;# dataobj-component tags 146 private variable _componentsList ;# List of components found 142 147 private variable _nextToken 0 143 148 private variable _icon 0 … … 161 166 # CONSTRUCTOR 162 167 # ---------------------------------------------------------------------- 163 itcl::body Rappture::FlowvisViewer::constructor { hostlist args} {168 itcl::body Rappture::FlowvisViewer::constructor {hostlist args} { 164 169 set _serverType "nanovis" 165 170 166 171 # Draw legend event 167 172 $_dispatcher register !legend 168 $_dispatcher dispatch $this !legend "[itcl::code $this ResizeLegend]; list"169 170 # Send transfer functions event173 $_dispatcher dispatch $this !legend "[itcl::code $this FixLegend]; list" 174 175 # Send transfer functions event 171 176 $_dispatcher register !send_transfunc 172 177 $_dispatcher dispatch $this !send_transfunc \ 173 178 "[itcl::code $this SendTransferFunctions]; list" 174 179 175 # Rebuild event .180 # Rebuild event 176 181 $_dispatcher register !rebuild 177 182 $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list" 178 183 179 # Resize event .184 # Resize event 180 185 $_dispatcher register !resize 181 $_dispatcher dispatch $this !resize "[itcl::code $this Resize]; list"186 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 182 187 183 188 $_dispatcher register !play … … 221 226 array set _settings [subst { 222 227 -arrows 0 223 -axes 0 228 -axesvisible 0 229 -background black 224 230 -colormap BCGYR 225 231 -currenttime 0 226 -cutplanes Visible 0232 -cutplanesvisible 0 227 233 -duration 1:00 228 -grid 229 -isosurface 230 -legend 234 -gridvisible 0 235 -isosurfaceshading 0 236 -legendvisible 1 231 237 -lic 1 232 238 -light 40 … … 234 240 -loop 0 235 241 -opacity 50 236 -outline 242 -outlinevisible 1 237 243 -particles 1 238 244 -play 0 … … 246 252 -thickness 350 247 253 -volume 1 248 -xcutplane 1249 -xcutp osition 0254 -xcutplaneposition 50 255 -xcutplanevisible 1 250 256 -xpan $_view(-xpan) 251 -ycutplane 1252 -ycutp osition 0257 -ycutplaneposition 50 258 -ycutplanevisible 1 253 259 -ypan $_view(-ypan) 254 -zcutplane 1255 -zcutp osition 0260 -zcutplaneposition 50 261 -zcutplanevisible 1 256 262 -zoom $_view(-zoom) 257 263 }] … … 320 326 -onimage [Rappture::icon cutbutton] \ 321 327 -offimage [Rappture::icon cutbutton] \ 322 -variable [itcl::scope _settings(-cutplanes Visible)] \323 -command [itcl::code $this AdjustSetting -cutplanes Visible]328 -variable [itcl::scope _settings(-cutplanesvisible)] \ 329 -command [itcl::code $this AdjustSetting -cutplanesvisible] 324 330 } 325 331 Rappture::Tooltip::for $itk_component(cutplane) \ … … 337 343 } 338 344 339 bind $itk_component(3dview) <Configure> \340 [itcl::code $this EventuallyResize %w %h]341 342 345 # Legend 343 346 set _image(legend) [image create photo] … … 350 353 } 351 354 bind $itk_component(legend) <Configure> \ 352 [itcl::code $this EventuallyRe sizeLegend]355 [itcl::code $this EventuallyRedrawLegend] 353 356 354 357 # Hack around the Tk panewindow. The problem is that the requested … … 361 364 1,0 $itk_component(legend) -fill x 362 365 blt::table configure $itk_component(plotarea) r1 -resize none 366 363 367 # Create flow controls... 364 365 368 itk_component add flowcontrols { 366 369 frame $itk_interior.flowcontrols … … 569 572 $_dispatcher cancel !rebuild 570 573 $_dispatcher cancel !send_transfunc 574 $_dispatcher cancel !resize 571 575 image delete $_image(plot) 572 576 image delete $_image(legend) … … 594 598 } 595 599 array set params $settings 600 596 601 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 597 602 # can't handle -autocolors yet 598 603 set params(-color) black 599 604 } 600 foreach c omp[$dataobj components] {601 set flowobj [$dataobj flowhints $c omp]605 foreach cname [$dataobj components] { 606 set flowobj [$dataobj flowhints $cname] 602 607 if { $flowobj == "" } { 603 puts stderr "no flowhints $dataobj-$c omp"608 puts stderr "no flowhints $dataobj-$cname" 604 609 continue 605 610 } 606 set _dataset2flow($dataobj-$c omp) $flowobj611 set _dataset2flow($dataobj-$cname) $flowobj 607 612 } 608 613 set pos [lsearch -exact $_dlist $dataobj] … … 634 639 # put the dataobj list in order according to -raise options 635 640 set dlist $_dlist 636 foreach obj $dlist {637 if {[info exists _obj2ovride($ obj-raise)] &&638 $_obj2ovride($ obj-raise)} {639 set i [lsearch -exact $dlist $ obj]641 foreach dataobj $dlist { 642 if {[info exists _obj2ovride($dataobj-raise)] && 643 $_obj2ovride($dataobj-raise)} { 644 set i [lsearch -exact $dlist $dataobj] 640 645 if {$i >= 0} { 641 646 set dlist [lreplace $dlist $i $i] 642 lappend dlist $ obj647 lappend dlist $dataobj 643 648 } 644 649 } … … 703 708 foreach tf [array names _style2datasets] { 704 709 set list {} 705 foreach {dataobj c omp} $_style2datasets($tf) break706 if { [info exists _serverDatasets($dataobj-$c omp)] } {707 lappend list $dataobj $c omp710 foreach {dataobj cname} $_style2datasets($tf) break 711 if { [info exists _serverDatasets($dataobj-$cname)] } { 712 lappend list $dataobj $cname 708 713 } 709 714 if { $list == "" } { … … 727 732 # ---------------------------------------------------------------------- 728 733 itcl::body Rappture::FlowvisViewer::scale {args} { 729 foreach val {xmin xmax ymin ymax vmin vmax} { 730 set _limits($val) "" 731 } 732 foreach obj $args { 733 foreach axis {x y v} { 734 foreach { min max } [$obj limits $axis] break 734 array set style { 735 -color BCGYR 736 -levels 6 737 -markers "" 738 -opacity 0.5 739 } 740 array unset _limits 741 array unset _volcomponents 742 foreach dataobj $args { 743 if { ![$dataobj isvalid] } { 744 continue; # Object doesn't contain valid data. 745 } 746 foreach cname [$dataobj components] { 747 if { ![info exists _volcomponents($cname)] } { 748 lappend _componentsList $cname 749 array set style [lindex [$dataobj components -style $cname] 0] 750 set cmap [ColorsToColormap $style(-color)] 751 set _settings($cname-colormap) $style(-color) 752 } 753 lappend _volcomponents($cname) $dataobj-$cname 754 array unset limits 755 array set limits [$dataobj valueLimits $cname] 756 set _limits($cname) $limits(v) 757 } 758 foreach axis {x y z v} { 759 foreach { min max } [$dataobj limits $axis] break 735 760 if {"" != $min && "" != $max} { 736 if { "" == $_limits(${axis}min)} {761 if { ![info exists _limits(${axis}min)] } { 737 762 set _limits(${axis}min) $min 738 763 set _limits(${axis}max) $max 739 } else { 740 if {$min < $_limits(${axis}min)} { 741 set _limits(${axis}min) $min 742 } 743 if {$max > $_limits(${axis}max)} { 744 set _limits(${axis}max) $max 745 } 764 continue 746 765 } 747 } 748 } 749 } 766 if {$min < $_limits(${axis}min)} { 767 set _limits(${axis}min) $min 768 } 769 if {$max > $_limits(${axis}max)} { 770 set _limits(${axis}max) $max 771 } 772 } 773 } 774 } 775 #BuildVolumeComponents 750 776 } 751 777 … … 929 955 set tf $_activeTf 930 956 if { $_first == "" } { 931 puts stderr " no first"957 puts stderr "first not set" 932 958 return 933 959 } 934 960 935 961 # Ensure that the global thickness setting (in the slider 936 # settings widget) is used for the active transfer-function. Update 937 # the values in the _settings varible. 938 939 set value $_settings(-thickness) 962 # settings widget) is used for the active transfer-function. Update 963 # the value in the _settings variable. 964 940 965 # Scale values between 0.00001 and 0.01000 941 set thickness [expr {double($ value) * 0.0001}]966 set thickness [expr {double($_settings(-thickness)) * 0.0001}] 942 967 set _settings($tf-thickness) $thickness 943 968 944 foreach key[array names _dataset2style $_first-*] {945 if { [info exists _dataset2style($ key)] } {946 foreach tf $_dataset2style($ key) {969 foreach tag [array names _dataset2style $_first-*] { 970 if { [info exists _dataset2style($tag)] } { 971 foreach tf $_dataset2style($tag) { 947 972 ComputeTransferFunction $tf 948 973 } 949 974 } 950 975 } 951 EventuallyRe sizeLegend952 } 953 954 # ---------------------------------------------------------------------- 955 # USAGE: ReceiveImage -bytes $size -type $type -token $token976 EventuallyRedrawLegend 977 } 978 979 # ---------------------------------------------------------------------- 980 # USAGE: ReceiveImage -bytes <size> -type <type> -token <token> 956 981 # 957 982 # Invoked automatically whenever the "image" command comes in from … … 1000 1025 -image $_image(legend) -tags colorbar 1001 1026 $c create text $lx $ly -anchor sw \ 1002 -fill $itk_option(-plotforeground) -tags "limits vmin"1027 -fill $itk_option(-plotforeground) -tags "limits labels vmin" 1003 1028 $c create text [expr {$w-$lx}] $ly -anchor se \ 1004 -fill $itk_option(-plotforeground) -tags "limits vmax"1029 -fill $itk_option(-plotforeground) -tags "limits labels vmax" 1005 1030 $c lower colorbar 1006 1031 $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y] … … 1036 1061 return 1037 1062 } 1038 #puts stderr "receive legend $tag $vmin $vmax $size"1039 1063 set bytes [ReceiveBytes $size] 1040 1064 $_image(legend) configure -data $bytes … … 1069 1093 return 1070 1094 } 1095 1071 1096 # Arguments from server are name value pairs. Stuff them in an array. 1072 array set values $args 1073 set tag $values(tag) 1097 array set info $args 1098 1099 set tag $info(tag) 1074 1100 set parts [split $tag -] 1101 1102 # 1103 # Volumes don't exist until we're told about them. 1104 # 1075 1105 set dataobj [lindex $parts 0] 1076 1106 set _serverDatasets($tag) 0 1077 1107 set _limits($tag-min) $values(min); # Minimum value of the volume. 1078 1108 set _limits($tag-max) $values(max); # Maximum value of the volume. 1109 1079 1110 unset _recvdDatasets($tag) 1080 1111 if { [array size _recvdDatasets] == 0 } { … … 1083 1114 } 1084 1115 1085 # 1086 # Rebuild --1087 # 1088 # Called automatically whenever something changes that affects the data1089 # in the widget. Clears any existing data and rebuilds the widget to1090 # display new data.1091 # 1116 # ---------------------------------------------------------------------- 1117 # USAGE: Rebuild 1118 # 1119 # Called automatically whenever something changes that affects the 1120 # data in the widget. Clears any existing data and rebuilds the 1121 # widget to display new data. 1122 # ---------------------------------------------------------------------- 1092 1123 itcl::body Rappture::FlowvisViewer::Rebuild {} { 1093 1124 set w [winfo width $itk_component(3dview)] … … 1117 1148 set _height $h 1118 1149 $_arcball resize $w $h 1119 Resize1150 DoResize 1120 1151 } 1121 1152 1122 1153 set _first "" 1123 1154 foreach dataobj [get] { 1124 foreach c omp[$dataobj components] {1125 set tag $dataobj-$c omp1155 foreach cname [$dataobj components] { 1156 set tag $dataobj-$cname 1126 1157 set isvtk 0 1127 1158 # FIXME: Would like to use the type method of the dataobj … … 1129 1160 if {[catch { 1130 1161 # Send the data as one huge base64-encoded mess -- yuck! 1131 set data [$dataobj blob $c omp]1162 set data [$dataobj blob $cname] 1132 1163 }]} { 1133 set data [$dataobj vtkdata $c omp]1164 set data [$dataobj vtkdata $cname] 1134 1165 set isvtk 1 1135 1166 } … … 1147 1178 SendCmd "clientinfo [list $info]" 1148 1179 } 1149 set extents [$dataobj extents $c omp]1180 set extents [$dataobj extents $cname] 1150 1181 # I have a field. Is a vector field or a volume field? 1151 1182 if { !$isvtk && $extents == 1 } { 1152 1183 SendCmd "volume data follows $nbytes $tag" 1153 1184 } else { 1154 if {[SendFlowCmd $dataobj $c omp$nbytes $extents] < 0} {1185 if {[SendFlowCmd $dataobj $cname $nbytes $extents] < 0} { 1155 1186 continue 1156 1187 } 1157 1188 } 1158 1189 SendData $data 1159 NameTransferFunction $dataobj $c omp1190 NameTransferFunction $dataobj $cname 1160 1191 set _recvdDatasets($tag) 1 1161 1192 } … … 1170 1201 1171 1202 # Reset the camera and other view parameters 1172 InitSettings -light2side \ 1203 InitSettings -axesvisible -gridvisible \ 1204 -opacity -light2side -isosurfaceshading \ 1173 1205 -light \ 1174 -opacity -isosurface -grid -axes -volume -outline \ 1175 -cutplanesVisible -xcutplane -ycutplane -zcutplane 1206 -volume -outlinevisible -cutplanesvisible \ 1207 -xcutplanevisible -ycutplanevisible -zcutplanevisible \ 1208 -xcutplaneposition -ycutplaneposition -zcutplaneposition 1176 1209 1177 1210 # nothing to send -- activate the proper volume … … 1202 1235 1203 1236 foreach dataobj [get] { 1204 foreach c omp[$dataobj components] {1205 NameTransferFunction $dataobj $c omp1237 foreach cname [$dataobj components] { 1238 NameTransferFunction $dataobj $cname 1206 1239 } 1207 1240 } … … 1218 1251 array set _view $location 1219 1252 } 1220 set c omp[lindex [$_first components] 0]1221 set _activeTf [lindex $_dataset2style($_first-$c omp) 0]1253 set cname [lindex [$_first components] 0] 1254 set _activeTf [lindex $_dataset2style($_first-$cname) 0] 1222 1255 } 1223 1256 1224 1257 # sync the state of slicers 1225 set vols [Current VolumeIds -cutplanes]1258 set vols [CurrentDatasets -cutplanes] 1226 1259 foreach axis {x y z} { 1227 set pos [expr {0.01*$_settings(-${axis}cutp osition)}]1260 set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}] 1228 1261 SendCmd "cutplane position $pos $axis $vols" 1229 1262 } 1230 1263 SendCmd "volume data state $_settings(-volume)" 1231 EventuallyRe sizeLegend1264 EventuallyRedrawLegend 1232 1265 1233 1266 # Actually write the commands to the server socket. If it fails, we don't … … 1240 1273 1241 1274 # ---------------------------------------------------------------------- 1242 # USAGE: Current VolumeIds ?-cutplanes?1275 # USAGE: CurrentDatasets ?-cutplanes? 1243 1276 # 1244 1277 # Returns a list of volume server IDs for the current volume being … … 1246 1279 # of IDs if the current data object has multiple components. 1247 1280 # ---------------------------------------------------------------------- 1248 itcl::body Rappture::FlowvisViewer::Current VolumeIds {{what -all}} {1281 itcl::body Rappture::FlowvisViewer::CurrentDatasets {{what -all}} { 1249 1282 return "" 1250 1283 if { $_first == "" } { 1251 1284 return 1252 1285 } 1253 foreach key[array names _serverDatasets *-*] {1254 if {[string match $_first-* $ key]} {1286 foreach tag [array names _serverDatasets *-*] { 1287 if {[string match $_first-* $tag]} { 1255 1288 array set style { 1256 1289 -cutplanes 1 1257 1290 } 1258 foreach {dataobj c omp} [split $key-] break1259 array set style [lindex [$dataobj components -style $c omp] 0]1291 foreach {dataobj cname} [split $tag -] break 1292 array set style [lindex [$dataobj components -style $cname] 0] 1260 1293 if {$what != "-cutplanes" || $style(-cutplanes)} { 1261 lappend rlist $_serverDatasets($ key)1294 lappend rlist $_serverDatasets($tag) 1262 1295 } 1263 1296 } … … 1443 1476 # ---------------------------------------------------------------------- 1444 1477 itcl::body Rappture::FlowvisViewer::AdjustSetting {what {value ""}} { 1478 if {![isconnected]} { 1479 return 1480 } 1445 1481 switch -- $what { 1482 "-axesvisible" { 1483 SendCmd "axis visible $_settings($what)" 1484 } 1485 "-background" { 1486 set bgcolor [$itk_component(background) value] 1487 array set fgcolors { 1488 "black" "white" 1489 "white" "black" 1490 "grey" "black" 1491 } 1492 configure -plotbackground $bgcolor \ 1493 -plotforeground $fgcolors($bgcolor) 1494 if { $_first != "" } { 1495 set comp [lindex [$_first components] 0] 1496 set tag $_first-$comp 1497 DrawLegend $tag 1498 } 1499 } 1446 1500 "-colormap" { 1447 1501 set color [$itk_component(colormap) value] 1448 1502 set _settings($what) $color 1449 1503 #ResetColormap $color 1504 } 1505 "-cutplanesvisible" { 1506 set bool $_settings($what) 1507 set datasets [CurrentDatasets -cutplanes] 1508 set tag [lindex $datasets 0] 1509 SendCmd "cutplane visible $bool $tag" 1510 } 1511 "-gridvisible" { 1512 SendCmd "grid visible $_settings($what)" 1513 } 1514 "-isosurfaceshading" { 1515 if { $_first != "" } { 1516 set comp [lindex [$_first components] 0] 1517 set tag $_first-$comp 1518 set val $_settings($what) 1519 # This flag isn't implemented in the server 1520 #SendCmd "$tag configure -isosurface $val" 1521 } 1522 } 1523 "-legendvisible" { 1524 if { $_settings($what) } { 1525 blt::table $itk_component(plotarea) \ 1526 0,0 $itk_component(3dview) -fill both \ 1527 1,0 $itk_component(legend) -fill x 1528 blt::table configure $itk_component(plotarea) r1 -resize none 1529 } else { 1530 blt::table forget $itk_component(legend) 1531 } 1450 1532 } 1451 1533 "-light" { … … 1476 1558 } 1477 1559 } 1560 "-outlinevisible" { 1561 if { $_first != "" } { 1562 set comp [lindex [$_first components] 0] 1563 set tag $_first-$comp 1564 SendCmd "$tag configure -outline $_settings($what)" 1565 } 1566 } 1478 1567 "-thickness" { 1479 1568 if { $_first != "" && $_activeTf != "" } { … … 1486 1575 } 1487 1576 } 1488 "-outline" {1489 if { $_first != "" } {1490 set comp [lindex [$_first components] 0]1491 set tag $_first-$comp1492 SendCmd "$tag configure -outline $_settings($what)"1493 }1494 }1495 "-isosurface" {1496 if { [isconnected] } {1497 SendCmd "volume shading isosurface $_settings($what)"1498 }1499 }1500 "-grid" {1501 if { [isconnected] } {1502 SendCmd "grid visible $_settings($what)"1503 }1504 }1505 "-axes" {1506 if { [isconnected] } {1507 SendCmd "axis visible $_settings($what)"1508 }1509 }1510 "-legend" {1511 if { $_settings($what) } {1512 blt::table $itk_component(plotarea) \1513 0,0 $itk_component(3dview) -fill both \1514 1,0 $itk_component(legend) -fill x1515 blt::table configure $itk_component(plotarea) r1 -resize none1516 } else {1517 blt::table forget $itk_component(legend)1518 }1519 }1520 1577 "-volume" { 1521 1578 if { $_first != "" } { … … 1525 1582 } 1526 1583 } 1527 "-cutplanesVisible" { 1528 set bool $_settings($what) 1529 set datasets [CurrentVolumeIds -cutplanes] 1584 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" { 1585 set axis [string range $what 1 1] 1586 set pos [expr $_settings($what) * 0.01] 1587 # We only set cutplanes on the first dataset. 1588 set datasets [CurrentDatasets -cutplanes] 1530 1589 set tag [lindex $datasets 0] 1531 SendCmd "cutplane visible $bool$tag"1532 } 1533 "-xcutplane " - "-ycutplane" - "-zcutplane" {1590 SendCmd "cutplane position $pos $axis $tag" 1591 } 1592 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1534 1593 set axis [string range $what 1 1] 1535 1594 set bool $_settings($what) 1536 if { [isconnected] } {1537 set vols [CurrentVolumeIds -cutplanes]1538 SendCmd "cutplane state $bool $axis $vols"1539 }1595 # We only set cutplanes on the first dataset. 1596 set datasets [CurrentDatasets -cutplanes] 1597 set tag [lindex $datasets 0] 1598 SendCmd "cutplane state $bool $axis $tag" 1540 1599 if { $bool } { 1541 1600 $itk_component(${axis}CutScale) configure -state normal \ … … 1553 1612 1554 1613 # ---------------------------------------------------------------------- 1555 # USAGE: ResizeLegend1614 # USAGE: FixLegend 1556 1615 # 1557 1616 # Used internally to update the legend area whenever it changes size … … 1559 1618 # for the current field. 1560 1619 # ---------------------------------------------------------------------- 1561 itcl::body Rappture::FlowvisViewer:: ResizeLegend {} {1620 itcl::body Rappture::FlowvisViewer::FixLegend {} { 1562 1621 set _resizeLegendPending 0 1563 1622 set lineht [font metrics $itk_option(-font) -linespace] … … 1574 1633 #SendCmd "legend $_activeTf $w $h" 1575 1634 SendCmd "$tag legend $w $h" 1576 } else {1577 # Can't do this as this will remove the items associated with the1578 # isomarkers.1579 1580 #$itk_component(legend) delete all1581 1635 } 1582 1636 } … … 1599 1653 array set style [lindex [$dataobj components -style $cname] 0] 1600 1654 set tf "$style(-color):$style(-levels)" 1655 # Some tools erroneously set -opacity to 1 in style, so 1656 # override the requested opacity for now 1657 set style(-opacity) 0.5 1601 1658 set _settings(-opacity) [expr $style(-opacity) * 100] 1602 1659 set _dataset2style($dataobj-$cname) $tf … … 1608 1665 # ComputeTransferFunction -- 1609 1666 # 1610 # Computes and sends the transfer function to the render server. It's1611 # assumed that the volume data limits are known and that the global1612 # transfer-functions slider values have be setup. Both parts are1613 # needed to compute the relative value (location) of the marker, and1614 # the alpha map of the transfer function.1667 # Computes and sends the transfer function to the render server. It's 1668 # assumed that the volume data limits are known and that the global 1669 # transfer-functions slider values have been set up. Both parts are 1670 # needed to compute the relative value (location) of the marker, and 1671 # the alpha map of the transfer function. 1615 1672 # 1616 1673 itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } { … … 1620 1677 -opacity 0.5 1621 1678 } 1622 set dataobj ""; set c omp""1623 foreach {dataobj c omp} $_style2datasets($tf) break1679 set dataobj ""; set cname "" 1680 foreach {dataobj cname} $_style2datasets($tf) break 1624 1681 if { $dataobj == "" } { 1625 1682 return 0 1626 1683 } 1627 array set style [lindex [$dataobj components -style $comp] 0] 1684 array set style [lindex [$dataobj components -style $cname] 0] 1685 # Some tools erroneously set -opacity to 1 in style, so 1686 # override the requested opacity for now 1687 set style(-opacity) 0.5 1628 1688 1629 1689 # We have to parse the style attributes for a volume using this … … 1714 1774 } 1715 1775 SendCmd "transfunc define $tf { $cmap } { $amap }" 1716 return [SendCmd "$dataobj-$c ompconfigure -transferfunction $tf"]1776 return [SendCmd "$dataobj-$cname configure -transferfunction $tf"] 1717 1777 } 1718 1778 … … 1924 1984 $inner configure -borderwidth 4 1925 1985 1926 checkbutton $inner.isosurface \ 1927 -text "Isosurface shading" \ 1928 -variable [itcl::scope _settings(-isosurface)] \ 1929 -command [itcl::code $this AdjustSetting -isosurface] \ 1930 -font "Arial 9" 1931 1986 # General options 1932 1987 checkbutton $inner.axes \ 1933 1988 -text "Axes" \ 1934 -variable [itcl::scope _settings(-axes )] \1935 -command [itcl::code $this AdjustSetting -axes ] \1989 -variable [itcl::scope _settings(-axesvisible)] \ 1990 -command [itcl::code $this AdjustSetting -axesvisible] \ 1936 1991 -font "Arial 9" 1937 1992 1938 1993 checkbutton $inner.grid \ 1939 1994 -text "Grid" \ 1940 -variable [itcl::scope _settings(-grid )] \1941 -command [itcl::code $this AdjustSetting -grid ] \1995 -variable [itcl::scope _settings(-gridvisible)] \ 1996 -command [itcl::code $this AdjustSetting -gridvisible] \ 1942 1997 -font "Arial 9" 1998 1999 checkbutton $inner.legend \ 2000 -text "Legend" \ 2001 -variable [itcl::scope _settings(-legendvisible)] \ 2002 -command [itcl::code $this AdjustSetting -legendvisible] \ 2003 -font "Arial 9" 2004 2005 label $inner.background_l -text "Background" -font "Arial 9" 2006 itk_component add background { 2007 Rappture::Combobox $inner.background -width 10 -editable no 2008 } 2009 $inner.background choices insert end \ 2010 "black" "black" \ 2011 "white" "white" \ 2012 "grey" "grey" 2013 2014 $itk_component(background) value $_settings(-background) 2015 bind $inner.background <<Value>> \ 2016 [itcl::code $this AdjustSetting -background] 2017 2018 # Dataset options 2019 label $inner.flow_l -text "Flow" -font "Arial 9 bold" 1943 2020 1944 2021 checkbutton $inner.outline \ 1945 2022 -text "Outline" \ 1946 -variable [itcl::scope _settings(-outline)] \ 1947 -command [itcl::code $this AdjustSetting -outline] \ 1948 -font "Arial 9" 1949 1950 checkbutton $inner.legend \ 1951 -text "Legend" \ 1952 -variable [itcl::scope _settings(-legend)] \ 1953 -command [itcl::code $this AdjustSetting -legend] \ 2023 -variable [itcl::scope _settings(-outlinevisible)] \ 2024 -command [itcl::code $this AdjustSetting -outlinevisible] \ 1954 2025 -font "Arial 9" 1955 2026 … … 1960 2031 -font "Arial 9" 1961 2032 1962 checkbutton $inner.particles \1963 -text "Particles" \1964 -variable [itcl::scope _settings(-particles)] \1965 -command [itcl::code $this AdjustSetting -particles] \1966 -font "Arial 9"1967 1968 checkbutton $inner.lic \1969 -text "Lic" \1970 -variable [itcl::scope _settings(-lic)] \1971 -command [itcl::code $this AdjustSetting -lic] \1972 -font "Arial 9"1973 1974 2033 frame $inner.frame 1975 2034 1976 2035 blt::table $inner \ 1977 0,0 $inner.axes -cspan 2 -anchor w \ 1978 1,0 $inner.grid -cspan 2 -anchor w \ 1979 2,0 $inner.outline -cspan 2 -anchor w \ 1980 3,0 $inner.volume -cspan 2 -anchor w \ 1981 4,0 $inner.legend -cspan 2 -anchor w 2036 0,0 $inner.axes -cspan 2 -anchor w \ 2037 1,0 $inner.grid -cspan 2 -anchor w \ 2038 2,0 $inner.legend -cspan 2 -anchor w \ 2039 3,0 $inner.background_l -anchor e -pady 2 \ 2040 3,1 $inner.background -fill x \ 2041 4,0 $inner.flow_l -anchor w \ 2042 5,0 $inner.outline -cspan 2 -anchor w \ 2043 6,0 $inner.volume -cspan 2 -anchor w \ 1982 2044 1983 2045 bind $inner <Map> [itcl::code $this GetFlowInfo $inner] 1984 2046 1985 blt::table configure $inner r* -resize none1986 blt::table configure $inner r5-resize expand2047 blt::table configure $inner c* r* -resize none 2048 blt::table configure $inner c2 r7 -resize expand 1987 2049 } 1988 2050 … … 2002 2064 -font "Arial 9" 2003 2065 2004 label $inner.shading -text "Shading:" -font $fg 2066 label $inner.lighting_l \ 2067 -text "Lighting / Material Properties" \ 2068 -font "Arial 9 bold" 2069 2070 checkbutton $inner.isosurface -text "Isosurface shading" -font $fg \ 2071 -variable [itcl::scope _settings(-isosurfaceshading)] \ 2072 -command [itcl::code $this AdjustSetting -isosurfaceshading] 2005 2073 2006 2074 checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \ … … 2015 2083 label $inner.bright -text "Surface" -font $fg 2016 2084 2017 label $inner.clear -text "Clear" -font $fg 2085 # Opacity 2086 label $inner.opacity_l -text "Opacity" -font $fg 2018 2087 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2019 2088 -variable [itcl::scope _settings(-opacity)] \ 2020 2089 -width 10 \ 2021 2090 -showvalue off -command [itcl::code $this AdjustSetting -opacity] 2022 label $inner.opaque -text "Opaque" -font $fg 2023 2091 2092 label $inner.transferfunction_l \ 2093 -text "Transfer Function" -font "Arial 9 bold" 2094 2095 # Tooth thickness 2024 2096 label $inner.thin -text "Thin" -font $fg 2025 2097 ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \ … … 2029 2101 label $inner.thick -text "Thick" -font $fg 2030 2102 2031 label $inner.colormap_l -text "Colormap" -font "Arial 9" 2103 # Colormap 2104 label $inner.colormap_l -text "Colormap" -font $fg 2032 2105 itk_component add colormap { 2033 2106 Rappture::Combobox $inner.colormap -width 10 -editable no … … 2035 2108 2036 2109 $inner.colormap choices insert end [GetColormapList -includeNone] 2037 $itk_component(colormap) value "BCGYR"2038 2110 bind $inner.colormap <<Value>> \ 2039 2111 [itcl::code $this AdjustSetting -colormap] 2112 $itk_component(colormap) value "BCGYR" 2113 set _settings(-colormap) "BCGYR" 2040 2114 2041 2115 blt::table $inner \ 2042 2116 0,0 $inner.vol -cspan 4 -anchor w -pady 2 \ 2043 1,0 $inner. shading-cspan 4 -anchor w -pady {10 2} \2117 1,0 $inner.lighting_l -cspan 4 -anchor w -pady {10 2} \ 2044 2118 2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \ 2045 2119 3,0 $inner.dim -anchor e -pady 2 \ 2046 2120 3,1 $inner.light -cspan 2 -pady 2 -fill x \ 2047 2121 3,3 $inner.bright -anchor w -pady 2 \ 2048 4,0 $inner.clear -anchor e -pady 2 \ 2049 4,1 $inner.opacity -cspan 2 -pady 2 -fill x \ 2050 4,3 $inner.opaque -anchor w -pady 2 \ 2122 4,0 $inner.opacity_l -anchor e -pady 2 \ 2123 4,1 $inner.opacity -cspan 3 -pady 2 -fill x \ 2051 2124 5,0 $inner.thin -anchor e -pady 2 \ 2052 2125 5,1 $inner.thickness -cspan 2 -pady 2 -fill x\ … … 2063 2136 $inner configure -borderwidth 4 2064 2137 2138 checkbutton $inner.visible \ 2139 -text "Show Cutplanes" \ 2140 -variable [itcl::scope _settings(-cutplanesvisible)] \ 2141 -command [itcl::code $this AdjustSetting -cutplanesvisible] \ 2142 -font "Arial 9" 2143 2065 2144 # X-value slicer... 2066 2145 itk_component add xCutButton { … … 2068 2147 -onimage [Rappture::icon x-cutplane] \ 2069 2148 -offimage [Rappture::icon x-cutplane] \ 2070 -command [itcl::code $this AdjustSetting -xcutplane ] \2071 -variable [itcl::scope _settings(-xcutplane )]2149 -command [itcl::code $this AdjustSetting -xcutplanevisible] \ 2150 -variable [itcl::scope _settings(-xcutplanevisible)] 2072 2151 } 2073 2152 Rappture::Tooltip::for $itk_component(xCutButton) \ … … 2080 2159 -borderwidth 1 -highlightthickness 0 \ 2081 2160 -command [itcl::code $this Slice move x] \ 2082 -variable [itcl::scope _settings(-xcutp osition)]2161 -variable [itcl::scope _settings(-xcutplaneposition)] 2083 2162 } { 2084 2163 usual … … 2096 2175 -onimage [Rappture::icon y-cutplane] \ 2097 2176 -offimage [Rappture::icon y-cutplane] \ 2098 -command [itcl::code $this AdjustSetting -ycutplane ] \2099 -variable [itcl::scope _settings(-ycutplane )]2177 -command [itcl::code $this AdjustSetting -ycutplanevisible] \ 2178 -variable [itcl::scope _settings(-ycutplanevisible)] 2100 2179 } 2101 2180 Rappture::Tooltip::for $itk_component(yCutButton) \ … … 2108 2187 -borderwidth 1 -highlightthickness 0 \ 2109 2188 -command [itcl::code $this Slice move y] \ 2110 -variable [itcl::scope _settings(-ycutp osition)]2189 -variable [itcl::scope _settings(-ycutplaneposition)] 2111 2190 } { 2112 2191 usual … … 2124 2203 -onimage [Rappture::icon z-cutplane] \ 2125 2204 -offimage [Rappture::icon z-cutplane] \ 2126 -command [itcl::code $this AdjustSetting -zcutplane ] \2127 -variable [itcl::scope _settings(-zcutplane )]2205 -command [itcl::code $this AdjustSetting -zcutplanevisible] \ 2206 -variable [itcl::scope _settings(-zcutplanevisible)] 2128 2207 } 2129 2208 Rappture::Tooltip::for $itk_component(zCutButton) \ … … 2136 2215 -borderwidth 1 -highlightthickness 0 \ 2137 2216 -command [itcl::code $this Slice move z] \ 2138 -variable [itcl::scope _settings(-zcutp osition)]2217 -variable [itcl::scope _settings(-zcutplaneposition)] 2139 2218 } { 2140 2219 usual … … 2143 2222 $itk_component(zCutScale) set 50 2144 2223 $itk_component(zCutScale) configure -state disabled 2145 #$itk_component(zCutScale) configure -state disabled2146 2224 Rappture::Tooltip::for $itk_component(zCutScale) \ 2147 2225 "@[itcl::code $this SlicerTip z]" 2148 2226 2149 2227 blt::table $inner \ 2150 1,1 $itk_component(xCutButton) \ 2151 1,2 $itk_component(yCutButton) \ 2152 1,3 $itk_component(zCutButton) \ 2153 0,1 $itk_component(xCutScale) \ 2154 0,2 $itk_component(yCutScale) \ 2155 0,3 $itk_component(zCutScale) \ 2156 2157 blt::table configure $inner r0 r1 c* -resize none 2158 blt::table configure $inner r2 c4 -resize expand 2228 0,1 $inner.visible -anchor w -pady 2 -cspan 4 \ 2229 1,1 $itk_component(xCutScale) \ 2230 1,2 $itk_component(yCutScale) \ 2231 1,3 $itk_component(zCutScale) \ 2232 2,1 $itk_component(xCutButton) \ 2233 2,2 $itk_component(yCutButton) \ 2234 2,3 $itk_component(zCutButton) 2235 2236 blt::table configure $inner r0 r1 r2 c* -resize none 2237 blt::table configure $inner r3 c4 -resize expand 2159 2238 blt::table configure $inner c0 -width 2 2160 2239 blt::table configure $inner c1 c2 c3 -padx 2 … … 2217 2296 set inner [frame $w.frame] 2218 2297 blt::table $w \ 2219 5,0 $inner -fill both -cspan 2 -anchor nw2298 7,0 $inner -fill both -cspan 2 -anchor nw 2220 2299 array set hints [$flowobj hints] 2221 2300 checkbutton $inner.showstreams -text "Streams Plane" \ … … 2330 2409 set axis [lindex $args 0] 2331 2410 set newval [lindex $args 1] 2411 2332 2412 set newpos [expr {0.01*$newval}] 2333 2334 # show the current value in the readout 2335 2336 set ids [CurrentVolumeIds -cutplanes] 2337 SendCmd "cutplane position $newpos $axis $ids" 2413 set datasets [CurrentDatasets -cutplanes] 2414 set tag [lindex $datasets 0] 2415 SendCmd "cutplane position $newpos $axis $tag" 2338 2416 } 2339 2417 default { … … 2354 2432 } 2355 2433 2356 itcl::body Rappture::FlowvisViewer:: Resize {} {2434 itcl::body Rappture::FlowvisViewer::DoResize {} { 2357 2435 $_arcball resize $_width $_height 2358 2436 SendCmd "screen size $_width $_height" … … 2370 2448 } 2371 2449 2372 itcl::body Rappture::FlowvisViewer::EventuallyRe sizeLegend {} {2450 itcl::body Rappture::FlowvisViewer::EventuallyRedrawLegend {} { 2373 2451 if { !$_resizeLegendPending } { 2374 2452 $_dispatcher event -after 100 !legend … … 2386 2464 2387 2465 # camera -- 2466 # 2388 2467 itcl::body Rappture::FlowvisViewer::camera {option args} { 2389 2468 switch -- $option { … … 2393 2472 "set" { 2394 2473 set what [lindex $args 0] 2395 set x $_settings($ {this}${what})2474 set x $_settings($what) 2396 2475 set code [catch { string is double $x } result] 2397 2476 if { $code != 0 || !$result } { 2398 set _settings($ {this}${what}) $_view($what)2477 set _settings($what) $_view($what) 2399 2478 return 2400 2479 } 2401 2480 switch -- $what { 2402 2481 "-xpan" - "-ypan" { 2403 set _view($what) $_settings($ {this}${what})2482 set _view($what) $_settings($what) 2404 2483 PanCamera 2405 2484 } 2406 2485 "-qx" - "-qy" - "-qz" - "-qw" { 2407 set _view($what) $_settings($ {this}${what})2486 set _view($what) $_settings($what) 2408 2487 set q [ViewToQuaternion] 2409 2488 $_arcball quaternion $q … … 2411 2490 } 2412 2491 "-zoom" { 2413 set _view($what) $_settings($ {this}${what})2492 set _view($what) $_settings($what) 2414 2493 SendCmd "camera zoom $_view($what)" 2415 2494 } … … 2432 2511 } 2433 2512 SendCmd "if {\[flow exists $tag\]} {flow delete $tag}" 2434 array set info 2513 array set info [$flowobj hints] 2435 2514 set _settings(-volume) $info(volume) 2436 set _settings(-outline ) $info(outline)2515 set _settings(-outlinevisible) $info(outline) 2437 2516 set _settings(-arrows) $info(arrows) 2438 2517 set _settings(-duration) $info(duration) … … 2602 2681 } 2603 2682 2604 itcl::body Rappture::FlowvisViewer::WaitIcon 2683 itcl::body Rappture::FlowvisViewer::WaitIcon { option widget } { 2605 2684 switch -- $option { 2606 2685 "start" { … … 2801 2880 SendCmd "camera orient $q" 2802 2881 SendCmd "camera reset" 2803 set _view(-xpan) 0 .02804 set _view(-ypan) 0 .02882 set _view(-xpan) 0 2883 set _view(-ypan) 0 2805 2884 set _view(-zoom) 1.0 2806 2885 set _settings(-xpan) $_view(-xpan) … … 2808 2887 set _settings(-zoom) $_view(-zoom) 2809 2888 } 2889 2890 # 2891 # BuildVolumeComponents -- 2892 # 2893 # This is called from the "scale" method which is called when a new 2894 # dataset is added or deleted. It repopulates the dropdown menu of 2895 # volume component names. It sets the current component to the first 2896 # component in the list (of components found). Finally, if there is 2897 # only one component, don't display the label or the combobox in the 2898 # volume settings tab. 2899 # 2900 itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} { 2901 $itk_component(volcomponents) choices delete 0 end 2902 foreach name $_componentsList { 2903 $itk_component(volcomponents) choices insert end $name $name 2904 } 2905 set _current [lindex $_componentsList 0] 2906 $itk_component(volcomponents) value $_current 2907 } 2908 2909 # 2910 # GetDatasetsWithComponents -- 2911 # 2912 # Returns a list of all the datasets (known by the combination of their 2913 # data object and component name) that match the given component name. 2914 # For example, this is used where we want to change the settings of 2915 # volumes that have the current component. 2916 # 2917 itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } { 2918 if { ![info exists _volcomponents($cname)] } { 2919 return "" 2920 } 2921 set list "" 2922 foreach tag $_volcomponents($cname) { 2923 if { ![info exists _serverDatasets($tag)] } { 2924 continue 2925 } 2926 lappend list $tag 2927 } 2928 return $list 2929 }
Note: See TracChangeset
for help on using the changeset viewer.