Changeset 5121 for branches/uq/gui/scripts/vtkvolumeviewer.tcl
- Timestamp:
- Mar 11, 2015 10:26:15 AM (9 years ago)
- Location:
- branches/uq
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uq
- Property svn:mergeinfo changed
-
branches/uq/gui/scripts/vtkvolumeviewer.tcl
r4797 r5121 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 # ---------------------------------------------------------------------- 3 # COMPONENT: vtkvolumeviewer - Vtk volume viewer 2 3 # ---------------------------------------------------------------------- 4 # COMPONENT: VtkVolumeViewer - Vtk volume viewer 4 5 # 5 6 # It connects to the Vtk server running on a rendering farm, … … 7 8 # ====================================================================== 8 9 # AUTHOR: Michael McLennan, Purdue University 9 # Copyright (c) 2004-201 4HUBzero Foundation, LLC10 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 11 # 11 12 # See the file "license.terms" for information on usage and … … 66 67 protected method Disconnect {} 67 68 protected method DoResize {} 69 protected method DoReseed {} 68 70 protected method DoRotate {} 69 71 protected method AdjustSetting {what {value ""}} … … 84 86 private method BuildCutplaneTab {} 85 87 private method BuildDownloadPopup { widget command } 86 private method BuildViewTab {}87 88 private method BuildVolumeTab {} 88 89 private method DrawLegend {} … … 90 91 private method EnterLegend { x y } 91 92 private method EventuallyResize { w h } 93 private method EventuallyReseed { numPoints } 92 94 private method EventuallyRotate { q } 93 95 private method EventuallySetCutplane { axis args } … … 127 129 private variable _start 0 128 130 private variable _title "" 131 private variable _seeds 129 132 130 133 common _downloadPopup; # download options from popup … … 133 136 private variable _height 0 134 137 private variable _resizePending 0 138 private variable _reseedPending 0 135 139 private variable _rotatePending 0 136 140 private variable _cutplanePending 0 … … 154 158 set _serverType "vtkvis" 155 159 156 EnableWaitDialog 900157 158 160 # Rebuild event 159 161 $_dispatcher register !rebuild … … 163 165 $_dispatcher register !resize 164 166 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 167 168 # Reseed event 169 $_dispatcher register !reseed 170 $_dispatcher dispatch $this !reseed "[itcl::code $this DoReseed]; list" 165 171 166 172 # Rotate event … … 215 221 axesVisible 1 216 222 axisLabels 1 217 background black218 223 cutplaneEdges 0 219 224 cutplane-xvisible 1 … … 227 232 cutplaneWireframe 0 228 233 cutplane-opacity 100 229 legendVisible 1230 outline 0231 234 volumeLighting 1 232 235 volume-material 80 … … 334 337 335 338 if { [catch { 336 BuildViewTab337 339 BuildVolumeTab 338 340 BuildCutplaneTab … … 342 344 puts stderr errs=$errs 343 345 } 344 345 346 # Legend 347 346 348 set _image(legend) [image create photo] 347 349 itk_component add legend { … … 372 374 [itcl::code $this EventuallyResize %w %h] 373 375 376 if 0 { 377 bind $itk_component(view) <Configure> \ 378 [itcl::code $this EventuallyResize %w %h] 379 } 374 380 # Bindings for panning via mouse 375 381 bind $itk_component(view) <ButtonPress-2> \ … … 461 467 } 462 468 469 itcl::body Rappture::VtkVolumeViewer::EventuallyReseed { numPoints } { 470 set _numSeeds $numPoints 471 if { !$_reseedPending } { 472 set _reseedPending 1 473 $_dispatcher event -after 600 !reseed 474 } 475 } 476 463 477 set rotate_delay 100 464 478 … … 487 501 # ---------------------------------------------------------------------- 488 502 itcl::body Rappture::VtkVolumeViewer::add {dataobj {settings ""}} { 489 if { ![IsValidObject $dataobj] } {490 return; # Ignore invalid objects.491 }492 503 array set params { 493 504 -color auto … … 739 750 if { $_reportClientInfo } { 740 751 # Tell the server the viewer, hub, user and session. 741 # Do this immediately on connect before buff ering any commands752 # Do this immediately on connect before buffing any commands 742 753 global env 743 754 … … 797 808 $_dispatcher cancel !rebuild 798 809 $_dispatcher cancel !resize 810 $_dispatcher cancel !reseed 799 811 $_dispatcher cancel !rotate 800 812 $_dispatcher cancel !xcutplane … … 807 819 array unset _data 808 820 array unset _colormaps 821 array unset _seeds 809 822 array unset _dataset2style 810 823 array unset _obj2datasets … … 834 847 } 835 848 $_image(plot) configure -data $bytes 836 #puts stderr "[clock format [clock seconds]]: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 849 set time [clock seconds] 850 set date [clock format $time] 851 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 837 852 if { $_start > 0 } { 838 853 set finish [clock clicks -milliseconds] … … 913 928 set _legendPending 1 914 929 915 if { $_ width != $w || $_height != $h || $_reset } {930 if { $_reset } { 916 931 set _width $w 917 932 set _height $h 918 933 $_arcball resize $w $h 919 934 DoResize 920 }921 if { $_reset } {922 935 # 923 936 # Reset the camera and other view parameters … … 931 944 } 932 945 DoRotate 933 InitSettings outline background \ 934 axis-xgrid axis-ygrid axis-zgrid axisFlyMode \ 946 InitSettings axis-xgrid axis-ygrid axis-zgrid axisFlyMode \ 935 947 axesVisible axisLabels 936 948 PanCamera 937 949 } 950 set _first "" 938 951 939 952 SendCmd "imgflush" … … 953 966 if { $_reportClientInfo } { 954 967 set info {} 955 lappend info "tool_id" [$dataobj hints toolId] 956 lappend info "tool_name" [$dataobj hints toolName] 957 lappend info "tool_version" [$dataobj hints toolRevision] 958 lappend info "tool_title" [$dataobj hints toolTitle] 968 lappend info "tool_id" [$dataobj hints toolid] 969 lappend info "tool_name" [$dataobj hints toolname] 970 lappend info "tool_title" [$dataobj hints tooltitle] 971 lappend info "tool_command" [$dataobj hints toolcommand] 972 lappend info "tool_revision" [$dataobj hints toolrevision] 959 973 lappend info "dataset_label" [$dataobj hints label] 960 974 lappend info "dataset_size" $length … … 969 983 lappend _obj2datasets($dataobj) $tag 970 984 if { [info exists _obj2ovride($dataobj-raise)] } { 971 SendCmd " volumevisible 1 $tag"985 SendCmd "dataset visible 1 $tag" 972 986 } 973 987 break … … 983 997 set label [$_first hints ${axis}label] 984 998 if { $label != "" } { 985 SendCmd [list axis name $axis $label]999 SendCmd "axis name $axis $label" 986 1000 } 987 1001 set units [$_first hints ${axis}units] 988 1002 if { $units != "" } { 989 SendCmd [list axis units $axis $units]1003 SendCmd "axis units $axis $units" 990 1004 } 991 1005 } … … 1272 1286 } 1273 1287 switch -- $what { 1274 "background" {1275 set bgcolor [$itk_component(background) value]1276 array set fgcolors {1277 "black" "white"1278 "white" "black"1279 "grey" "black"1280 }1281 configure -plotbackground $bgcolor \1282 -plotforeground $fgcolors($bgcolor)1283 $itk_component(view) delete "legend"1284 DrawLegend1285 }1286 "outline" {1287 set bool $_settings($what)1288 SendCmd "outline visible 0"1289 foreach tag [CurrentDatasets -visible] {1290 SendCmd "outline visible $bool $tag"1291 }1292 }1293 "legendVisible" {1294 set bool $_settings($what)1295 set _settings($_current-$what) $bool1296 }1297 1288 "volumeVisible" { 1298 set bool $_settings( $what)1289 set bool $_settings(volumeVisible) 1299 1290 foreach dataset [CurrentDatasets -visible] { 1300 1291 SendCmd "volume visible $bool $dataset" … … 1309 1300 } 1310 1301 "volume-material" { 1311 set val $_settings( $what)1302 set val $_settings(volume-material) 1312 1303 set diffuse [expr {0.01*$val}] 1313 1304 set specular [expr {0.01*$val}] … … 1320 1311 } 1321 1312 "volumeLighting" { 1322 set bool $_settings( $what)1313 set bool $_settings(volumeLighting) 1323 1314 foreach dataset [CurrentDatasets -visible] { 1324 1315 SendCmd "volume lighting $bool $dataset" … … 1326 1317 } 1327 1318 "volume-quality" { 1328 set val $_settings( $what)1319 set val $_settings(volume-quality) 1329 1320 set val [expr {0.01*$val}] 1330 1321 foreach dataset [CurrentDatasets -visible] { … … 1333 1324 } 1334 1325 "axesVisible" { 1335 set bool $_settings( $what)1326 set bool $_settings(axesVisible) 1336 1327 SendCmd "axis visible all $bool" 1337 1328 } 1338 1329 "axisLabels" { 1339 set bool $_settings( $what)1330 set bool $_settings(axisLabels) 1340 1331 SendCmd "axis labels all $bool" 1341 1332 } … … 1406 1397 "volume-palette" { 1407 1398 set palette [$itk_component(palette) value] 1408 set _settings( $what) $palette1399 set _settings(volume-palette) $palette 1409 1400 foreach dataset [CurrentDatasets -visible $_first] { 1410 1401 foreach {dataobj comp} [split $dataset -] break … … 1413 1404 set _legendPending 1 1414 1405 } 1406 "volume-palette" { 1407 set palette [$itk_component(palette) value] 1408 set _settings(volume-palette) $palette 1409 foreach dataset [CurrentDatasets -visible $_first] { 1410 foreach {dataobj comp} [split $dataset -] break 1411 ChangeColormap $dataobj $comp $palette 1412 } 1413 set _legendPending 1 1414 } 1415 1415 "field" { 1416 1416 set label [$itk_component(field) value] 1417 1417 set fname [$itk_component(field) translate $label] 1418 set _settings( $what) $fname1418 set _settings(field) $fname 1419 1419 if { [info exists _fields($fname)] } { 1420 1420 foreach { label units components } $_fields($fname) break … … 1549 1549 itcl::configbody Rappture::VtkVolumeViewer::plotbackground { 1550 1550 if { [isconnected] } { 1551 set color $itk_option(-plotbackground) 1552 set rgb [Color2RGB $color] 1553 SendCmd "screen bgcolor $rgb" 1554 $itk_component(legend) configure -background $color 1551 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break 1552 SendCmd "screen bgcolor $r $g $b" 1555 1553 } 1556 1554 } … … 1561 1559 itcl::configbody Rappture::VtkVolumeViewer::plotforeground { 1562 1560 if { [isconnected] } { 1563 set color $itk_option(-plotforeground) 1564 set rgb [Color2RGB $color] 1565 SendCmd "axis color all $rgb" 1566 SendCmd "outline color $rgb" 1567 SendCmd "cutplane color $rgb" 1568 $itk_component(legend) itemconfigure labels -fill $color 1569 $itk_component(legend) itemconfigure limits -fill $color 1570 } 1571 } 1572 1573 itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} { 1574 set font [option get $itk_component(hull) font Font] 1575 #set bfont [option get $itk_component(hull) boldFont Font] 1576 1577 set inner [$itk_component(main) insert end \ 1578 -title "View Settings" \ 1579 -icon [Rappture::icon wrench]] 1580 $inner configure -borderwidth 4 1581 1582 checkbutton $inner.axes \ 1583 -text "Axes" \ 1584 -variable [itcl::scope _settings(axesVisible)] \ 1585 -command [itcl::code $this AdjustSetting axesVisible] \ 1586 -font "Arial 9" 1587 1588 checkbutton $inner.outline \ 1589 -text "Outline" \ 1590 -variable [itcl::scope _settings(outline)] \ 1591 -command [itcl::code $this AdjustSetting outline] \ 1592 -font "Arial 9" 1593 1594 checkbutton $inner.legend \ 1595 -text "Legend" \ 1596 -variable [itcl::scope _settings(legendVisible)] \ 1597 -command [itcl::code $this AdjustSetting legendVisible] \ 1598 -font "Arial 9" 1599 1600 checkbutton $inner.volume \ 1601 -text "Volume" \ 1602 -variable [itcl::scope _settings(volumeVisible)] \ 1603 -command [itcl::code $this AdjustSetting volumeVisible] \ 1604 -font "Arial 9" 1605 1606 label $inner.background_l -text "Background" -font "Arial 9" 1607 itk_component add background { 1608 Rappture::Combobox $inner.background -width 10 -editable no 1609 } 1610 $inner.background choices insert end \ 1611 "black" "black" \ 1612 "white" "white" \ 1613 "grey" "grey" 1614 1615 $itk_component(background) value $_settings(background) 1616 bind $inner.background <<Value>> \ 1617 [itcl::code $this AdjustSetting background] 1618 1619 blt::table $inner \ 1620 0,0 $inner.axes -cspan 2 -anchor w \ 1621 1,0 $inner.outline -cspan 2 -anchor w \ 1622 2,0 $inner.volume -cspan 2 -anchor w \ 1623 3,0 $inner.legend -cspan 2 -anchor w \ 1624 4,0 $inner.background_l -anchor e -pady 2 \ 1625 4,1 $inner.background -fill x \ 1626 1627 blt::table configure $inner r* -resize none 1628 blt::table configure $inner r5 -resize expand 1561 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break 1562 #fix this! 1563 #SendCmd "color background $r $g $b" 1564 } 1629 1565 } 1630 1566 1631 1567 itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} { 1632 set font [option get $itk_component(hull) font Font] 1633 #set bfont [option get $itk_component(hull) boldFont Font] 1568 1569 set fg [option get $itk_component(hull) font Font] 1570 #set bfg [option get $itk_component(hull) boldFont Font] 1634 1571 1635 1572 set inner [$itk_component(main) insert end \ … … 1685 1622 Rappture::Combobox $inner.palette -width 10 -editable no 1686 1623 } 1687 1688 $inner.palette choices insert end [GetColormapList] 1624 $inner.palette choices insert end \ 1625 "BCGYR" "BCGYR" \ 1626 "BGYOR" "BGYOR" \ 1627 "blue" "blue" \ 1628 "blue-to-brown" "blue-to-brown" \ 1629 "blue-to-orange" "blue-to-orange" \ 1630 "blue-to-grey" "blue-to-grey" \ 1631 "green-to-magenta" "green-to-magenta" \ 1632 "greyscale" "greyscale" \ 1633 "nanohub" "nanohub" \ 1634 "rainbow" "rainbow" \ 1635 "spectral" "spectral" \ 1636 "ROYGB" "ROYGB" \ 1637 "RYGCB" "RYGCB" \ 1638 "brown-to-blue" "brown-to-blue" \ 1639 "grey-to-blue" "grey-to-blue" \ 1640 "orange-to-blue" "orange-to-blue" 1641 1689 1642 $itk_component(palette) value "BCGYR" 1690 1643 bind $inner.palette <<Value>> \ … … 1709 1662 1710 1663 itcl::body Rappture::VtkVolumeViewer::BuildAxisTab {} { 1711 set font [option get $itk_component(hull) font Font] 1712 #set bfont [option get $itk_component(hull) boldFont Font] 1664 1665 set fg [option get $itk_component(hull) font Font] 1666 #set bfg [option get $itk_component(hull) boldFont Font] 1713 1667 1714 1668 set inner [$itk_component(main) insert end \ … … 1753 1707 "static_triad" "static" \ 1754 1708 "closest_triad" "closest" \ 1755 "furthest_triad" "f arthest" \1709 "furthest_triad" "furthest" \ 1756 1710 "outer_edges" "outer" 1757 1711 $itk_component(axismode) value "static" … … 1770 1724 blt::table configure $inner r7 c1 -resize expand 1771 1725 } 1726 1772 1727 1773 1728 itcl::body Rappture::VtkVolumeViewer::BuildCameraTab {} { … … 1807 1762 1808 1763 itcl::body Rappture::VtkVolumeViewer::BuildCutplaneTab {} { 1809 set font [option get $itk_component(hull) font Font] 1764 1765 set fg [option get $itk_component(hull) font Font] 1810 1766 1811 1767 set inner [$itk_component(main) insert end \ … … 2077 2033 set _settings(volumeLighting) $settings(-lighting) 2078 2034 SetColormap $dataobj $comp 2079 SendCmd "outline add $tag"2080 SendCmd "outline visible 0 $tag"2081 2035 } 2082 2036
Note: See TracChangeset
for help on using the changeset viewer.