Changeset 5451 for branches/1.4/gui/scripts
- Timestamp:
- May 6, 2015, 8:22:12 PM (9 years ago)
- Location:
- branches/1.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4
-
branches/1.4/gui/scripts/flowvisviewer.tcl
r5449 r5451 80 80 private method ComputeTransferFunction { tf } 81 81 private method Connect {} 82 private method Current VolumeIds {{what -all}}82 private method CurrentDatasets {{what -all}} 83 83 private method Disconnect {} 84 private method DoResize {} 84 85 private method DrawLegend { tf } 86 private method EventuallyGoto { nSteps } 87 private method EventuallyRedrawLegend { } 85 88 private method EventuallyResize { w h } 86 private method EventuallyGoto { nSteps } 87 private method EventuallyResizeLegend { } 89 private method FixLegend {} 88 90 private method GetDatasetsWithComponent { cname } 89 91 private method GetFlowInfo { widget } … … 103 105 private method ReceiveImage { args } 104 106 private method ReceiveLegend { tf vmin vmax size } 105 private method Resize {}106 private method ResizeLegend {}107 107 private method Rotate {option x y} 108 108 private method SendFlowCmd { dataobj comp nbytes extents } … … 126 126 private variable _dlist "" ;# list of data objects 127 127 private variable _obj2ovride ;# maps dataobj => style override 128 private variable _serverDatasets ;# maps dataobj-component to volume ID129 #in the server128 private variable _serverDatasets ;# contains all the dataobj-component 129 ;# to volumes in the server 130 130 private variable _recvdDatasets ;# list of data objs to send to server 131 131 private variable _dataset2style ;# maps dataobj-component to transfunc 132 132 private variable _style2datasets ;# maps tf back to list of 133 133 ;# dataobj-components using the tf. 134 134 private variable _dataset2flow ;# Maps dataobj-component to a flow. 135 135 … … 140 140 private variable _isomarkers ;# array of isosurface level values 0..1 141 141 private variable _settings 142 private variable _activeTf "" ;# The currently active transfer function142 private variable _activeTf "" ;# Currently active transfer function 143 143 private variable _first "" ;# This is the topmost volume. 144 private variable _volcomponents ;# Array of components found 145 private variable _componentsList ;# Array of components found 144 private variable _volcomponents ;# Maps component name to list of 145 ;# dataobj-component tags 146 private variable _componentsList ;# List of components found 146 147 private variable _nextToken 0 147 148 private variable _icon 0 … … 165 166 # CONSTRUCTOR 166 167 # ---------------------------------------------------------------------- 167 itcl::body Rappture::FlowvisViewer::constructor { hostlist args} {168 itcl::body Rappture::FlowvisViewer::constructor {hostlist args} { 168 169 set _serverType "nanovis" 169 170 170 171 # Draw legend event 171 172 $_dispatcher register !legend 172 $_dispatcher dispatch $this !legend "[itcl::code $this ResizeLegend]; list"173 174 # Send transfer functions event173 $_dispatcher dispatch $this !legend "[itcl::code $this FixLegend]; list" 174 175 # Send transfer functions event 175 176 $_dispatcher register !send_transfunc 176 177 $_dispatcher dispatch $this !send_transfunc \ 177 178 "[itcl::code $this SendTransferFunctions]; list" 178 179 179 # Rebuild event .180 # Rebuild event 180 181 $_dispatcher register !rebuild 181 182 $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list" 182 183 183 # Resize event .184 # Resize event 184 185 $_dispatcher register !resize 185 $_dispatcher dispatch $this !resize "[itcl::code $this Resize]; list"186 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 186 187 187 188 $_dispatcher register !play … … 224 225 array set _settings [subst { 225 226 -arrows 0 226 -axes 0 227 -axesvisible 0 228 -background black 227 229 -colormap BCGYR 228 230 -currenttime 0 229 -cutplanes Visible 0231 -cutplanesvisible 0 230 232 -duration 1:00 231 -grid 232 -isosurface 233 -legend 233 -gridvisible 0 234 -isosurfaceshading 0 235 -legendvisible 1 234 236 -lic 1 235 237 -light 40 … … 237 239 -loop 0 238 240 -opacity 50 239 -outline 241 -outlinevisible 1 240 242 -particles 1 241 243 -play 0 … … 249 251 -thickness 350 250 252 -volume 1 251 -xcutplane 1252 -xcutp osition 0253 -xcutplaneposition 50 254 -xcutplanevisible 1 253 255 -xpan $_view(-xpan) 254 -ycutplane 1255 -ycutp osition 0256 -ycutplaneposition 50 257 -ycutplanevisible 1 256 258 -ypan $_view(-ypan) 257 -zcutplane 1258 -zcutp osition 0259 -zcutplaneposition 50 260 -zcutplanevisible 1 259 261 -zoom $_view(-zoom) 260 262 }] … … 323 325 -onimage [Rappture::icon cutbutton] \ 324 326 -offimage [Rappture::icon cutbutton] \ 325 -variable [itcl::scope _settings(-cutplanes Visible)] \326 -command [itcl::code $this AdjustSetting -cutplanes Visible]327 -variable [itcl::scope _settings(-cutplanesvisible)] \ 328 -command [itcl::code $this AdjustSetting -cutplanesvisible] 327 329 } 328 330 Rappture::Tooltip::for $itk_component(cutplane) \ … … 340 342 } 341 343 342 bind $itk_component(3dview) <Configure> \343 [itcl::code $this EventuallyResize %w %h]344 345 344 # Legend 346 345 set _image(legend) [image create photo] … … 353 352 } 354 353 bind $itk_component(legend) <Configure> \ 355 [itcl::code $this EventuallyRe sizeLegend]354 [itcl::code $this EventuallyRedrawLegend] 356 355 357 356 # Hack around the Tk panewindow. The problem is that the requested … … 364 363 1,0 $itk_component(legend) -fill x 365 364 blt::table configure $itk_component(plotarea) r1 -resize none 365 366 366 # Create flow controls... 367 368 367 itk_component add flowcontrols { 369 368 frame $itk_interior.flowcontrols … … 572 571 $_dispatcher cancel !rebuild 573 572 $_dispatcher cancel !send_transfunc 573 $_dispatcher cancel !resize 574 574 image delete $_image(plot) 575 575 image delete $_image(legend) … … 597 597 } 598 598 array set params $settings 599 599 600 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 600 601 # can't handle -autocolors yet 601 602 set params(-color) black 602 603 } 603 foreach c omp[$dataobj components] {604 set flowobj [$dataobj flowhints $c omp]604 foreach cname [$dataobj components] { 605 set flowobj [$dataobj flowhints $cname] 605 606 if { $flowobj == "" } { 606 puts stderr "no flowhints $dataobj-$c omp"607 puts stderr "no flowhints $dataobj-$cname" 607 608 continue 608 609 } 609 set _dataset2flow($dataobj-$c omp) $flowobj610 set _dataset2flow($dataobj-$cname) $flowobj 610 611 } 611 612 set pos [lsearch -exact $_dlist $dataobj] … … 637 638 # put the dataobj list in order according to -raise options 638 639 set dlist $_dlist 639 foreach obj $dlist {640 if {[info exists _obj2ovride($ obj-raise)] &&641 $_obj2ovride($ obj-raise)} {642 set i [lsearch -exact $dlist $ obj]640 foreach dataobj $dlist { 641 if {[info exists _obj2ovride($dataobj-raise)] && 642 $_obj2ovride($dataobj-raise)} { 643 set i [lsearch -exact $dlist $dataobj] 643 644 if {$i >= 0} { 644 645 set dlist [lreplace $dlist $i $i] 645 lappend dlist $ obj646 lappend dlist $dataobj 646 647 } 647 648 } … … 690 691 set pos [lsearch -exact $_dlist $dataobj] 691 692 if { $pos >= 0 } { 692 foreach comp [$dataobj components] {693 array unset _limits $dataobj-$comp-*694 }695 693 set _dlist [lreplace $_dlist $pos $pos] 694 array unset _limits $dataobj-* 696 695 array unset _obj2ovride $dataobj-* 697 696 array unset _dataset2flow $dataobj-* … … 706 705 foreach tf [array names _style2datasets] { 707 706 set list {} 708 foreach {dataobj c omp} $_style2datasets($tf) break709 if { [info exists _serverDatasets($dataobj-$c omp)] } {710 lappend list $dataobj $c omp707 foreach {dataobj cname} $_style2datasets($tf) break 708 if { [info exists _serverDatasets($dataobj-$cname)] } { 709 lappend list $dataobj $cname 711 710 } 712 711 if { $list == "" } { … … 731 730 itcl::body Rappture::FlowvisViewer::scale {args} { 732 731 array set style { 733 -color BCGYR 734 -levels 6 735 -markers "" 736 -opacity 0.5 732 -color BCGYR 733 -levels 6 734 -markers "" 737 735 } 738 736 array unset _limits … … 954 952 set tf $_activeTf 955 953 if { $_first == "" } { 956 puts stderr " no first"954 puts stderr "first not set" 957 955 return 958 956 } 959 957 960 958 # Ensure that the global thickness setting (in the slider 961 # settings widget) is used for the active transfer-function. Update 962 # the values in the _settings varible. 963 964 set value $_settings(-thickness) 959 # settings widget) is used for the active transfer-function. Update 960 # the value in the _settings variable. 961 965 962 # Scale values between 0.00001 and 0.01000 966 set thickness [expr {double($ value) * 0.0001}]963 set thickness [expr {double($_settings(-thickness)) * 0.0001}] 967 964 set _settings($tf-thickness) $thickness 968 965 969 foreach key[array names _dataset2style $_first-*] {970 if { [info exists _dataset2style($ key)] } {971 foreach tf $_dataset2style($ key) {966 foreach tag [array names _dataset2style $_first-*] { 967 if { [info exists _dataset2style($tag)] } { 968 foreach tf $_dataset2style($tag) { 972 969 ComputeTransferFunction $tf 973 970 } 974 971 } 975 972 } 976 EventuallyRe sizeLegend977 } 978 979 # ---------------------------------------------------------------------- 980 # USAGE: ReceiveImage -bytes $size -type $type -token $token973 EventuallyRedrawLegend 974 } 975 976 # ---------------------------------------------------------------------- 977 # USAGE: ReceiveImage -bytes <size> -type <type> -token <token> 981 978 # 982 979 # Invoked automatically whenever the "image" command comes in from … … 1025 1022 -image $_image(legend) -tags colorbar 1026 1023 $c create text $lx $ly -anchor sw \ 1027 -fill $itk_option(-plotforeground) -tags "limits vmin"1024 -fill $itk_option(-plotforeground) -tags "limits labels vmin" 1028 1025 $c create text [expr {$w-$lx}] $ly -anchor se \ 1029 -fill $itk_option(-plotforeground) -tags "limits vmax"1026 -fill $itk_option(-plotforeground) -tags "limits labels vmax" 1030 1027 $c lower colorbar 1031 1028 $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y] … … 1034 1031 # Display the markers used by the current transfer function. 1035 1032 set tf $_dataset2style($tag) 1036 foreach { vmin vmax} [limits $tf] break1037 $c itemconfigure vmin -text [format %g $ vmin]1033 foreach {min max} [limits $tf] break 1034 $c itemconfigure vmin -text [format %g $min] 1038 1035 $c coords vmin $lx $ly 1039 1036 1040 $c itemconfigure vmax -text [format %g $ vmax]1037 $c itemconfigure vmax -text [format %g $max] 1041 1038 $c coords vmax [expr {$w-$lx}] $ly 1042 1039 … … 1061 1058 return 1062 1059 } 1063 #puts stderr "receive legend $tag $vmin $vmax $size"1064 1060 set bytes [ReceiveBytes $size] 1065 1061 $_image(legend) configure -data $bytes … … 1094 1090 return 1095 1091 } 1092 1096 1093 # Arguments from server are name value pairs. Stuff them in an array. 1097 array set values $args 1098 set tag $values(tag) 1094 array set info $args 1095 1096 set tag $info(tag) 1099 1097 set parts [split $tag -] 1098 1099 # 1100 # Volumes don't exist until we're told about them. 1101 # 1100 1102 set dataobj [lindex $parts 0] 1101 1103 set _serverDatasets($tag) 0 1102 set _limits($tag) [list $values(min) $values(max)] 1104 set _limits($tag) [list $info(min) $info(max)] 1105 1103 1106 unset _recvdDatasets($tag) 1104 1107 if { [array size _recvdDatasets] == 0 } { … … 1107 1110 } 1108 1111 1109 # 1110 # Rebuild --1111 # 1112 # Called automatically whenever something changes that affects the data1113 # in the widget. Clears any existing data and rebuilds the widget to1114 # display new data.1115 # 1112 # ---------------------------------------------------------------------- 1113 # USAGE: Rebuild 1114 # 1115 # Called automatically whenever something changes that affects the 1116 # data in the widget. Clears any existing data and rebuilds the 1117 # widget to display new data. 1118 # ---------------------------------------------------------------------- 1116 1119 itcl::body Rappture::FlowvisViewer::Rebuild {} { 1117 1120 set w [winfo width $itk_component(3dview)] … … 1141 1144 set _height $h 1142 1145 $_arcball resize $w $h 1143 Resize1146 DoResize 1144 1147 } 1145 1148 1146 1149 set _first "" 1147 1150 foreach dataobj [get] { 1148 foreach c omp[$dataobj components] {1149 set tag $dataobj-$c omp1151 foreach cname [$dataobj components] { 1152 set tag $dataobj-$cname 1150 1153 set isvtk 0 1151 1154 # FIXME: Would like to use the type method of the dataobj … … 1153 1156 if {[catch { 1154 1157 # Send the data as one huge base64-encoded mess -- yuck! 1155 set data [$dataobj blob $c omp]1158 set data [$dataobj blob $cname] 1156 1159 }]} { 1157 set data [$dataobj vtkdata $c omp]1160 set data [$dataobj vtkdata $cname] 1158 1161 set isvtk 1 1159 1162 } … … 1171 1174 SendCmd "clientinfo [list $info]" 1172 1175 } 1173 set extents [$dataobj extents $c omp]1176 set extents [$dataobj extents $cname] 1174 1177 # I have a field. Is a vector field or a volume field? 1175 1178 if { !$isvtk && $extents == 1 } { 1176 1179 SendCmd "volume data follows $nbytes $tag" 1177 1180 } else { 1178 if {[SendFlowCmd $dataobj $c omp$nbytes $extents] < 0} {1181 if {[SendFlowCmd $dataobj $cname $nbytes $extents] < 0} { 1179 1182 continue 1180 1183 } 1181 1184 } 1182 1185 SendData $data 1183 NameTransferFunction $dataobj $c omp1186 NameTransferFunction $dataobj $cname 1184 1187 set _recvdDatasets($tag) 1 1185 1188 } … … 1194 1197 1195 1198 # Reset the camera and other view parameters 1196 InitSettings -light2side -light \ 1197 -opacity -isosurface -grid -axes -volume -outline \ 1198 -cutplanesVisible -xcutplane -ycutplane -zcutplane 1199 InitSettings -axesvisible -gridvisible \ 1200 -opacity -light2side -isosurfaceshading \ 1201 -light \ 1202 -volume -outlinevisible -cutplanesvisible \ 1203 -xcutplanevisible -ycutplanevisible -zcutplanevisible \ 1204 -xcutplaneposition -ycutplaneposition -zcutplaneposition 1199 1205 1200 1206 # nothing to send -- activate the proper volume … … 1225 1231 1226 1232 foreach dataobj [get] { 1227 foreach c omp[$dataobj components] {1228 NameTransferFunction $dataobj $c omp1233 foreach cname [$dataobj components] { 1234 NameTransferFunction $dataobj $cname 1229 1235 } 1230 1236 } … … 1241 1247 array set _view $location 1242 1248 } 1243 set c omp[lindex [$_first components] 0]1244 set _activeTf [lindex $_dataset2style($_first-$c omp) 0]1249 set cname [lindex [$_first components] 0] 1250 set _activeTf [lindex $_dataset2style($_first-$cname) 0] 1245 1251 } 1246 1252 1247 1253 # sync the state of slicers 1248 set vols [Current VolumeIds -cutplanes]1254 set vols [CurrentDatasets -cutplanes] 1249 1255 foreach axis {x y z} { 1250 set pos [expr {0.01*$_settings(-${axis}cutp osition)}]1256 set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}] 1251 1257 SendCmd "cutplane position $pos $axis $vols" 1252 1258 } 1253 1259 SendCmd "volume data state $_settings(-volume)" 1254 EventuallyRe sizeLegend1260 EventuallyRedrawLegend 1255 1261 1256 1262 # Actually write the commands to the server socket. If it fails, we don't … … 1263 1269 1264 1270 # ---------------------------------------------------------------------- 1265 # USAGE: Current VolumeIds ?-cutplanes?1271 # USAGE: CurrentDatasets ?-cutplanes? 1266 1272 # 1267 1273 # Returns a list of volume server IDs for the current volume being … … 1269 1275 # of IDs if the current data object has multiple components. 1270 1276 # ---------------------------------------------------------------------- 1271 itcl::body Rappture::FlowvisViewer::Current VolumeIds {{what -all}} {1277 itcl::body Rappture::FlowvisViewer::CurrentDatasets {{what -all}} { 1272 1278 return "" 1273 1279 if { $_first == "" } { 1274 1280 return 1275 1281 } 1276 foreach key[array names _serverDatasets *-*] {1277 if {[string match $_first-* $ key]} {1282 foreach tag [array names _serverDatasets *-*] { 1283 if {[string match $_first-* $tag]} { 1278 1284 array set style { 1279 1285 -cutplanes 1 1280 1286 } 1281 foreach {dataobj c omp} [split $key-] break1282 array set style [lindex [$dataobj components -style $c omp] 0]1287 foreach {dataobj cname} [split $tag -] break 1288 array set style [lindex [$dataobj components -style $cname] 0] 1283 1289 if {$what != "-cutplanes" || $style(-cutplanes)} { 1284 lappend rlist $_serverDatasets($ key)1290 lappend rlist $_serverDatasets($tag) 1285 1291 } 1286 1292 } … … 1466 1472 # ---------------------------------------------------------------------- 1467 1473 itcl::body Rappture::FlowvisViewer::AdjustSetting {what {value ""}} { 1474 if {![isconnected]} { 1475 return 1476 } 1468 1477 switch -- $what { 1478 "-axesvisible" { 1479 SendCmd "axis visible $_settings($what)" 1480 } 1481 "-background" { 1482 set bgcolor [$itk_component(background) value] 1483 array set fgcolors { 1484 "black" "white" 1485 "white" "black" 1486 "grey" "black" 1487 } 1488 configure -plotbackground $bgcolor \ 1489 -plotforeground $fgcolors($bgcolor) 1490 if { $_first != "" } { 1491 set comp [lindex [$_first components] 0] 1492 set tag $_first-$comp 1493 DrawLegend $tag 1494 } 1495 } 1469 1496 "-colormap" { 1470 1497 set color [$itk_component(colormap) value] 1471 1498 set _settings($what) $color 1472 1499 #ResetColormap $color 1500 } 1501 "-cutplanesvisible" { 1502 set bool $_settings($what) 1503 set datasets [CurrentDatasets -cutplanes] 1504 set tag [lindex $datasets 0] 1505 SendCmd "cutplane visible $bool $tag" 1506 } 1507 "-gridvisible" { 1508 SendCmd "grid visible $_settings($what)" 1509 } 1510 "-isosurfaceshading" { 1511 if { $_first != "" } { 1512 set comp [lindex [$_first components] 0] 1513 set tag $_first-$comp 1514 set val $_settings($what) 1515 # This flag isn't implemented in the server 1516 #SendCmd "$tag configure -isosurface $val" 1517 } 1518 } 1519 "-legendvisible" { 1520 if { $_settings($what) } { 1521 blt::table $itk_component(plotarea) \ 1522 0,0 $itk_component(3dview) -fill both \ 1523 1,0 $itk_component(legend) -fill x 1524 blt::table configure $itk_component(plotarea) r1 -resize none 1525 } else { 1526 blt::table forget $itk_component(legend) 1527 } 1473 1528 } 1474 1529 "-light" { … … 1499 1554 } 1500 1555 } 1556 "-outlinevisible" { 1557 if { $_first != "" } { 1558 set comp [lindex [$_first components] 0] 1559 set tag $_first-$comp 1560 SendCmd "$tag configure -outline $_settings($what)" 1561 } 1562 } 1501 1563 "-thickness" { 1502 1564 if { $_first != "" && $_activeTf != "" } { … … 1509 1571 } 1510 1572 } 1511 "-outline" {1512 if { $_first != "" } {1513 set comp [lindex [$_first components] 0]1514 set tag $_first-$comp1515 SendCmd "$tag configure -outline $_settings($what)"1516 }1517 }1518 "-isosurface" {1519 if { [isconnected] } {1520 SendCmd "volume shading isosurface $_settings($what)"1521 }1522 }1523 "-grid" {1524 if { [isconnected] } {1525 SendCmd "grid visible $_settings($what)"1526 }1527 }1528 "-axes" {1529 if { [isconnected] } {1530 SendCmd "axis visible $_settings($what)"1531 }1532 }1533 "-legend" {1534 if { $_settings($what) } {1535 blt::table $itk_component(plotarea) \1536 0,0 $itk_component(3dview) -fill both \1537 1,0 $itk_component(legend) -fill x1538 blt::table configure $itk_component(plotarea) r1 -resize none1539 } else {1540 blt::table forget $itk_component(legend)1541 }1542 }1543 1573 "-volume" { 1544 1574 if { $_first != "" } { … … 1548 1578 } 1549 1579 } 1550 "-cutplanesVisible" { 1551 set bool $_settings($what) 1552 set datasets [CurrentVolumeIds -cutplanes] 1580 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" { 1581 set axis [string range $what 1 1] 1582 set pos [expr $_settings($what) * 0.01] 1583 # We only set cutplanes on the first dataset. 1584 set datasets [CurrentDatasets -cutplanes] 1553 1585 set tag [lindex $datasets 0] 1554 SendCmd "cutplane visible $bool$tag"1555 } 1556 "-xcutplane " - "-ycutplane" - "-zcutplane" {1586 SendCmd "cutplane position $pos $axis $tag" 1587 } 1588 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1557 1589 set axis [string range $what 1 1] 1558 1590 set bool $_settings($what) 1559 if { [isconnected] } {1560 set vols [CurrentVolumeIds -cutplanes]1561 SendCmd "cutplane state $bool $axis $vols"1562 }1591 # We only set cutplanes on the first dataset. 1592 set datasets [CurrentDatasets -cutplanes] 1593 set tag [lindex $datasets 0] 1594 SendCmd "cutplane state $bool $axis $tag" 1563 1595 if { $bool } { 1564 1596 $itk_component(${axis}CutScale) configure -state normal \ … … 1576 1608 1577 1609 # ---------------------------------------------------------------------- 1578 # USAGE: ResizeLegend1610 # USAGE: FixLegend 1579 1611 # 1580 1612 # Used internally to update the legend area whenever it changes size … … 1582 1614 # for the current field. 1583 1615 # ---------------------------------------------------------------------- 1584 itcl::body Rappture::FlowvisViewer:: ResizeLegend {} {1616 itcl::body Rappture::FlowvisViewer::FixLegend {} { 1585 1617 set _resizeLegendPending 0 1586 1618 set lineht [font metrics $itk_option(-font) -linespace] … … 1597 1629 #SendCmd "legend $_activeTf $w $h" 1598 1630 SendCmd "$tag legend $w $h" 1599 } else {1600 # Can't do this as this will remove the items associated with the1601 # isomarkers.1602 1603 #$itk_component(legend) delete all1604 1631 } 1605 1632 } … … 1621 1648 } 1622 1649 array set style [lindex [$dataobj components -style $cname] 0] 1650 # Some tools erroneously set -opacity to 1 in style, so 1651 # override the requested opacity for now 1652 set style(-opacity) 0.5 1623 1653 set _settings(-opacity) [expr $style(-opacity) * 100] 1624 1654 set _dataset2style($dataobj-$cname) $cname … … 1630 1660 # ComputeTransferFunction -- 1631 1661 # 1632 # Computes and sends the transfer function to the render server. It's1633 # assumed that the volume data limits are known and that the global1634 # transfer-functions slider values have be setup. Both parts are1635 # needed to compute the relative value (location) of the marker, and1636 # the alpha map of the transfer function.1662 # Computes and sends the transfer function to the render server. It's 1663 # assumed that the volume data limits are known and that the global 1664 # transfer-functions slider values have been set up. Both parts are 1665 # needed to compute the relative value (location) of the marker, and 1666 # the alpha map of the transfer function. 1637 1667 # 1638 1668 itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } { … … 1642 1672 -opacity 0.5 1643 1673 } 1644 set dataobj ""; set c omp""1645 foreach {dataobj c omp} $_style2datasets($tf) break1674 set dataobj ""; set cname "" 1675 foreach {dataobj cname} $_style2datasets($tf) break 1646 1676 if { $dataobj == "" } { 1647 1677 return 0 1648 1678 } 1649 array set style [lindex [$dataobj components -style $comp] 0] 1679 array set style [lindex [$dataobj components -style $cname] 0] 1680 # Some tools erroneously set -opacity to 1 in style, so 1681 # override the requested opacity for now 1682 set style(-opacity) 0.5 1650 1683 1651 1684 # We have to parse the style attributes for a volume using this … … 1736 1769 } 1737 1770 SendCmd "transfunc define $tf { $cmap } { $amap }" 1738 return [SendCmd "$dataobj-$c ompconfigure -transferfunction $tf"]1771 return [SendCmd "$dataobj-$cname configure -transferfunction $tf"] 1739 1772 } 1740 1773 … … 1943 1976 $inner configure -borderwidth 4 1944 1977 1945 checkbutton $inner.isosurface \ 1946 -text "Isosurface shading" \ 1947 -variable [itcl::scope _settings(-isosurface)] \ 1948 -command [itcl::code $this AdjustSetting -isosurface] \ 1949 -font "Arial 9" 1950 1978 # General options 1951 1979 checkbutton $inner.axes \ 1952 1980 -text "Axes" \ 1953 -variable [itcl::scope _settings(-axes )] \1954 -command [itcl::code $this AdjustSetting -axes ] \1981 -variable [itcl::scope _settings(-axesvisible)] \ 1982 -command [itcl::code $this AdjustSetting -axesvisible] \ 1955 1983 -font "Arial 9" 1956 1984 1957 1985 checkbutton $inner.grid \ 1958 1986 -text "Grid" \ 1959 -variable [itcl::scope _settings(-grid )] \1960 -command [itcl::code $this AdjustSetting -grid ] \1987 -variable [itcl::scope _settings(-gridvisible)] \ 1988 -command [itcl::code $this AdjustSetting -gridvisible] \ 1961 1989 -font "Arial 9" 1990 1991 checkbutton $inner.legend \ 1992 -text "Legend" \ 1993 -variable [itcl::scope _settings(-legendvisible)] \ 1994 -command [itcl::code $this AdjustSetting -legendvisible] \ 1995 -font "Arial 9" 1996 1997 label $inner.background_l -text "Background" -font "Arial 9" 1998 itk_component add background { 1999 Rappture::Combobox $inner.background -width 10 -editable no 2000 } 2001 $inner.background choices insert end \ 2002 "black" "black" \ 2003 "white" "white" \ 2004 "grey" "grey" 2005 2006 $itk_component(background) value $_settings(-background) 2007 bind $inner.background <<Value>> \ 2008 [itcl::code $this AdjustSetting -background] 2009 2010 # Dataset options 2011 label $inner.flow_l -text "Flow" -font "Arial 9 bold" 1962 2012 1963 2013 checkbutton $inner.outline \ 1964 2014 -text "Outline" \ 1965 -variable [itcl::scope _settings(-outline)] \ 1966 -command [itcl::code $this AdjustSetting -outline] \ 1967 -font "Arial 9" 1968 1969 checkbutton $inner.legend \ 1970 -text "Legend" \ 1971 -variable [itcl::scope _settings(-legend)] \ 1972 -command [itcl::code $this AdjustSetting -legend] \ 2015 -variable [itcl::scope _settings(-outlinevisible)] \ 2016 -command [itcl::code $this AdjustSetting -outlinevisible] \ 1973 2017 -font "Arial 9" 1974 2018 … … 1979 2023 -font "Arial 9" 1980 2024 1981 checkbutton $inner.particles \1982 -text "Particles" \1983 -variable [itcl::scope _settings(-particles)] \1984 -command [itcl::code $this AdjustSetting -particles] \1985 -font "Arial 9"1986 1987 checkbutton $inner.lic \1988 -text "Lic" \1989 -variable [itcl::scope _settings(-lic)] \1990 -command [itcl::code $this AdjustSetting -lic] \1991 -font "Arial 9"1992 1993 2025 frame $inner.frame 1994 2026 1995 2027 blt::table $inner \ 1996 0,0 $inner.axes -cspan 2 -anchor w \ 1997 1,0 $inner.grid -cspan 2 -anchor w \ 1998 2,0 $inner.outline -cspan 2 -anchor w \ 1999 3,0 $inner.volume -cspan 2 -anchor w \ 2000 4,0 $inner.legend -cspan 2 -anchor w 2028 0,0 $inner.axes -cspan 2 -anchor w \ 2029 1,0 $inner.grid -cspan 2 -anchor w \ 2030 2,0 $inner.legend -cspan 2 -anchor w \ 2031 3,0 $inner.background_l -anchor e -pady 2 \ 2032 3,1 $inner.background -fill x \ 2033 4,0 $inner.flow_l -anchor w \ 2034 5,0 $inner.outline -cspan 2 -anchor w \ 2035 6,0 $inner.volume -cspan 2 -anchor w \ 2001 2036 2002 2037 bind $inner <Map> [itcl::code $this GetFlowInfo $inner] 2003 2038 2004 blt::table configure $inner r* -resize none2005 blt::table configure $inner r5-resize expand2039 blt::table configure $inner c* r* -resize none 2040 blt::table configure $inner c2 r7 -resize expand 2006 2041 } 2007 2042 … … 2021 2056 -font "Arial 9" 2022 2057 2023 label $inner.shading -text "Shading:" -font $fg 2058 label $inner.lighting_l \ 2059 -text "Lighting / Material Properties" \ 2060 -font "Arial 9 bold" 2061 2062 checkbutton $inner.isosurface -text "Isosurface shading" -font $fg \ 2063 -variable [itcl::scope _settings(-isosurfaceshading)] \ 2064 -command [itcl::code $this AdjustSetting -isosurfaceshading] 2024 2065 2025 2066 checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \ … … 2034 2075 label $inner.bright -text "Surface" -font $fg 2035 2076 2036 label $inner.clear -text "Clear" -font $fg 2077 # Opacity 2078 label $inner.opacity_l -text "Opacity" -font $fg 2037 2079 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2038 2080 -variable [itcl::scope _settings(-opacity)] \ 2039 2081 -width 10 \ 2040 2082 -showvalue off -command [itcl::code $this AdjustSetting -opacity] 2041 label $inner.opaque -text "Opaque" -font $fg 2042 2083 2084 label $inner.transferfunction_l \ 2085 -text "Transfer Function" -font "Arial 9 bold" 2086 2087 # Tooth thickness 2043 2088 label $inner.thin -text "Thin" -font $fg 2044 2089 ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \ … … 2048 2093 label $inner.thick -text "Thick" -font $fg 2049 2094 2050 label $inner.colormap_l -text "Colormap" -font "Arial 9" 2095 # Colormap 2096 label $inner.colormap_l -text "Colormap" -font $fg 2051 2097 itk_component add colormap { 2052 2098 Rappture::Combobox $inner.colormap -width 10 -editable no … … 2054 2100 2055 2101 $inner.colormap choices insert end [GetColormapList -includeNone] 2056 $itk_component(colormap) value "BCGYR"2057 2102 bind $inner.colormap <<Value>> \ 2058 2103 [itcl::code $this AdjustSetting -colormap] 2104 $itk_component(colormap) value "BCGYR" 2105 set _settings(-colormap) "BCGYR" 2059 2106 2060 2107 blt::table $inner \ 2061 2108 0,0 $inner.vol -cspan 4 -anchor w -pady 2 \ 2062 1,0 $inner. shading-cspan 4 -anchor w -pady {10 2} \2109 1,0 $inner.lighting_l -cspan 4 -anchor w -pady {10 2} \ 2063 2110 2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \ 2064 2111 3,0 $inner.dim -anchor e -pady 2 \ 2065 2112 3,1 $inner.light -cspan 2 -pady 2 -fill x \ 2066 2113 3,3 $inner.bright -anchor w -pady 2 \ 2067 4,0 $inner.clear -anchor e -pady 2 \ 2068 4,1 $inner.opacity -cspan 2 -pady 2 -fill x \ 2069 4,3 $inner.opaque -anchor w -pady 2 \ 2114 4,0 $inner.opacity_l -anchor e -pady 2 \ 2115 4,1 $inner.opacity -cspan 3 -pady 2 -fill x \ 2070 2116 5,0 $inner.thin -anchor e -pady 2 \ 2071 5,1 $inner.thickness -cspan 2 -pady 2 -fill x \2117 5,1 $inner.thickness -cspan 2 -pady 2 -fill x \ 2072 2118 5,3 $inner.thick -anchor w -pady 2 2073 2119 … … 2082 2128 $inner configure -borderwidth 4 2083 2129 2130 checkbutton $inner.visible \ 2131 -text "Show Cutplanes" \ 2132 -variable [itcl::scope _settings(-cutplanesvisible)] \ 2133 -command [itcl::code $this AdjustSetting -cutplanesvisible] \ 2134 -font "Arial 9" 2135 2084 2136 # X-value slicer... 2085 2137 itk_component add xCutButton { … … 2087 2139 -onimage [Rappture::icon x-cutplane] \ 2088 2140 -offimage [Rappture::icon x-cutplane] \ 2089 -command [itcl::code $this AdjustSetting -xcutplane ] \2090 -variable [itcl::scope _settings(-xcutplane )]2141 -command [itcl::code $this AdjustSetting -xcutplanevisible] \ 2142 -variable [itcl::scope _settings(-xcutplanevisible)] 2091 2143 } 2092 2144 Rappture::Tooltip::for $itk_component(xCutButton) \ … … 2099 2151 -borderwidth 1 -highlightthickness 0 \ 2100 2152 -command [itcl::code $this Slice move x] \ 2101 -variable [itcl::scope _settings(-xcutp osition)]2153 -variable [itcl::scope _settings(-xcutplaneposition)] 2102 2154 } { 2103 2155 usual … … 2115 2167 -onimage [Rappture::icon y-cutplane] \ 2116 2168 -offimage [Rappture::icon y-cutplane] \ 2117 -command [itcl::code $this AdjustSetting -ycutplane ] \2118 -variable [itcl::scope _settings(-ycutplane )]2169 -command [itcl::code $this AdjustSetting -ycutplanevisible] \ 2170 -variable [itcl::scope _settings(-ycutplanevisible)] 2119 2171 } 2120 2172 Rappture::Tooltip::for $itk_component(yCutButton) \ … … 2127 2179 -borderwidth 1 -highlightthickness 0 \ 2128 2180 -command [itcl::code $this Slice move y] \ 2129 -variable [itcl::scope _settings(-ycutp osition)]2181 -variable [itcl::scope _settings(-ycutplaneposition)] 2130 2182 } { 2131 2183 usual … … 2143 2195 -onimage [Rappture::icon z-cutplane] \ 2144 2196 -offimage [Rappture::icon z-cutplane] \ 2145 -command [itcl::code $this AdjustSetting -zcutplane ] \2146 -variable [itcl::scope _settings(-zcutplane )]2197 -command [itcl::code $this AdjustSetting -zcutplanevisible] \ 2198 -variable [itcl::scope _settings(-zcutplanevisible)] 2147 2199 } 2148 2200 Rappture::Tooltip::for $itk_component(zCutButton) \ … … 2155 2207 -borderwidth 1 -highlightthickness 0 \ 2156 2208 -command [itcl::code $this Slice move z] \ 2157 -variable [itcl::scope _settings(-zcutp osition)]2209 -variable [itcl::scope _settings(-zcutplaneposition)] 2158 2210 } { 2159 2211 usual … … 2162 2214 $itk_component(zCutScale) set 50 2163 2215 $itk_component(zCutScale) configure -state disabled 2164 #$itk_component(zCutScale) configure -state disabled2165 2216 Rappture::Tooltip::for $itk_component(zCutScale) \ 2166 2217 "@[itcl::code $this SlicerTip z]" 2167 2218 2168 2219 blt::table $inner \ 2169 1,1 $itk_component(xCutButton) \ 2170 1,2 $itk_component(yCutButton) \ 2171 1,3 $itk_component(zCutButton) \ 2172 0,1 $itk_component(xCutScale) \ 2173 0,2 $itk_component(yCutScale) \ 2174 0,3 $itk_component(zCutScale) \ 2175 2176 blt::table configure $inner r0 r1 c* -resize none 2177 blt::table configure $inner r2 c4 -resize expand 2220 0,1 $inner.visible -anchor w -pady 2 -cspan 4 \ 2221 1,1 $itk_component(xCutScale) \ 2222 1,2 $itk_component(yCutScale) \ 2223 1,3 $itk_component(zCutScale) \ 2224 2,1 $itk_component(xCutButton) \ 2225 2,2 $itk_component(yCutButton) \ 2226 2,3 $itk_component(zCutButton) 2227 2228 blt::table configure $inner r0 r1 r2 c* -resize none 2229 blt::table configure $inner r3 c4 -resize expand 2178 2230 blt::table configure $inner c0 -width 2 2179 2231 blt::table configure $inner c1 c2 c3 -padx 2 … … 2236 2288 set inner [frame $w.frame] 2237 2289 blt::table $w \ 2238 5,0 $inner -fill both -cspan 2 -anchor nw2290 7,0 $inner -fill both -cspan 2 -anchor nw 2239 2291 array set hints [$flowobj hints] 2240 2292 checkbutton $inner.showstreams -text "Streams Plane" \ … … 2349 2401 set axis [lindex $args 0] 2350 2402 set newval [lindex $args 1] 2403 2351 2404 set newpos [expr {0.01*$newval}] 2352 2353 # show the current value in the readout 2354 2355 set ids [CurrentVolumeIds -cutplanes] 2356 SendCmd "cutplane position $newpos $axis $ids" 2405 set datasets [CurrentDatasets -cutplanes] 2406 set tag [lindex $datasets 0] 2407 SendCmd "cutplane position $newpos $axis $tag" 2357 2408 } 2358 2409 default { … … 2373 2424 } 2374 2425 2375 itcl::body Rappture::FlowvisViewer:: Resize {} {2426 itcl::body Rappture::FlowvisViewer::DoResize {} { 2376 2427 $_arcball resize $_width $_height 2377 2428 SendCmd "screen size $_width $_height" … … 2389 2440 } 2390 2441 2391 itcl::body Rappture::FlowvisViewer::EventuallyRe sizeLegend {} {2442 itcl::body Rappture::FlowvisViewer::EventuallyRedrawLegend {} { 2392 2443 if { !$_resizeLegendPending } { 2393 2444 $_dispatcher event -after 100 !legend … … 2405 2456 2406 2457 # camera -- 2458 # 2407 2459 itcl::body Rappture::FlowvisViewer::camera {option args} { 2408 2460 switch -- $option { … … 2412 2464 "set" { 2413 2465 set what [lindex $args 0] 2414 set x $_settings($ {this}${what})2466 set x $_settings($what) 2415 2467 set code [catch { string is double $x } result] 2416 2468 if { $code != 0 || !$result } { 2417 set _settings($ {this}${what}) $_view($what)2469 set _settings($what) $_view($what) 2418 2470 return 2419 2471 } 2420 2472 switch -- $what { 2421 2473 "-xpan" - "-ypan" { 2422 set _view($what) $_settings($ {this}${what})2474 set _view($what) $_settings($what) 2423 2475 PanCamera 2424 2476 } 2425 2477 "-qx" - "-qy" - "-qz" - "-qw" { 2426 set _view($what) $_settings($ {this}${what})2478 set _view($what) $_settings($what) 2427 2479 set q [ViewToQuaternion] 2428 2480 $_arcball quaternion $q … … 2430 2482 } 2431 2483 "-zoom" { 2432 set _view($what) $_settings($ {this}${what})2484 set _view($what) $_settings($what) 2433 2485 SendCmd "camera zoom $_view($what)" 2434 2486 } … … 2451 2503 } 2452 2504 SendCmd "if {\[flow exists $tag\]} {flow delete $tag}" 2453 array set info 2505 array set info [$flowobj hints] 2454 2506 set _settings(-volume) $info(volume) 2455 set _settings(-outline ) $info(outline)2507 set _settings(-outlinevisible) $info(outline) 2456 2508 set _settings(-arrows) $info(arrows) 2457 2509 set _settings(-duration) $info(duration) … … 2621 2673 } 2622 2674 2623 itcl::body Rappture::FlowvisViewer::WaitIcon 2675 itcl::body Rappture::FlowvisViewer::WaitIcon { option widget } { 2624 2676 switch -- $option { 2625 2677 "start" { … … 2820 2872 SendCmd "camera orient $q" 2821 2873 SendCmd "camera reset" 2822 set _view(-xpan) 0 .02823 set _view(-ypan) 0 .02874 set _view(-xpan) 0 2875 set _view(-ypan) 0 2824 2876 set _view(-zoom) 1.0 2825 2877 set _settings(-xpan) $_view(-xpan) … … 2828 2880 } 2829 2881 2830 # Reset global settings from dataset's settings. 2882 # 2883 # BuildVolumeComponents -- 2884 # 2885 # This is called from the "scale" method which is called when a new 2886 # dataset is added or deleted. It repopulates the dropdown menu of 2887 # volume component names. It sets the current component to the first 2888 # component in the list (of components found). Finally, if there is 2889 # only one component, don't display the label or the combobox in the 2890 # volume settings tab. 2891 # 2831 2892 itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} { 2832 2893 $itk_component(volcomponents) choices delete 0 end … … 2838 2899 } 2839 2900 2840 # Reset global settings from dataset's settings. 2901 # 2902 # GetDatasetsWithComponents -- 2903 # 2904 # Returns a list of all the datasets (known by the combination of their 2905 # data object and component name) that match the given component name. 2906 # For example, this is used where we want to change the settings of 2907 # volumes that have the current component. 2908 # 2841 2909 itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } { 2842 2910 if { ![info exists _volcomponents($cname)] } {
Note: See TracChangeset
for help on using the changeset viewer.