- Timestamp:
- Feb 11, 2015, 3:05:26 PM (10 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkimageviewer.tcl
r4769 r5006 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: vtkimageviewer - Vtk image viewer … … 58 58 public method get {args} 59 59 public method isconnected {} 60 public method parameters {title args} { 61 # do nothing 60 public method parameters {title args} { 61 # do nothing 62 62 } 63 63 public method scale {args} … … 69 69 private method BuildColormap { name } 70 70 private method BuildImageTab {} 71 private method BuildDownloadPopup { widget command } 71 private method BuildDownloadPopup { widget command } 72 72 private method Combo { option } 73 73 private method Connect {} … … 77 77 private method DoRotate {} 78 78 private method DrawLegend {} 79 private method EnterLegend { x y } 80 private method EventuallyRequestLegend {} 81 private method EventuallyResize { w h } 79 private method EnterLegend { x y } 80 private method EventuallyRequestLegend {} 81 private method EventuallyResize { w h } 82 82 private method EventuallyRotate { q } 83 private method GetImage { args } 84 private method GetVtkData { args } 83 private method GetImage { args } 84 private method GetVtkData { args } 85 85 private method InitSettings { args } 86 private method IsValidObject { dataobj } 86 private method IsValidObject { dataobj } 87 87 private method LeaveLegend {} 88 private method MotionLegend { x y } 88 private method MotionLegend { x y } 89 89 private method Pan {option x y} 90 90 private method PanCamera {} 91 91 private method Pick {x y} 92 private method QuaternionToView { q } { 92 private method QuaternionToView { q } { 93 93 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 94 94 } … … 101 101 private method SetCurrentColormap { color } 102 102 private method SetLegendTip { x y } 103 private method SetObjectStyle { dataobj comp } 103 private method SetObjectStyle { dataobj comp } 104 104 private method SetOrientation { side } 105 private method ViewToQuaternion {} { 105 private method ViewToQuaternion {} { 106 106 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 107 107 } … … 112 112 private variable _obj2datasets 113 113 private variable _obj2ovride ; # maps dataobj => style override 114 private variable _datasets ; # contains all the dataobj-component 114 private variable _datasets ; # contains all the dataobj-component 115 115 ; # datasets in the server 116 116 private variable _colormaps ; # contains all the colormaps … … 128 128 129 129 private variable _click ; # info used for rotate operations 130 private variable _limits ; # Holds overall limits for all dataobjs 130 private variable _limits ; # Holds overall limits for all dataobjs 131 131 # using the viewer. 132 132 private variable _view ; # view params for 3D view … … 153 153 private variable _rotatePending 0 154 154 private variable _legendPending 0 155 private variable _fieldNames {} 156 private variable _fields 155 private variable _fieldNames {} 156 private variable _fields 157 157 private variable _curFldName "" 158 158 private variable _curFldLabel "" … … 243 243 } { 244 244 usual 245 ignore -highlightthickness -borderwidth -background 245 ignore -highlightthickness -borderwidth -background 246 246 } 247 247 … … 249 249 menu $itk_component(plotarea).menu \ 250 250 -relief flat \ 251 -tearoff no 251 -tearoff no 252 252 } { 253 253 usual … … 269 269 270 270 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 271 set _map(cwidth) -1 272 set _map(cheight) -1 271 set _map(cwidth) -1 272 set _map(cheight) -1 273 273 set _map(zoom) 1.0 274 274 set _map(original) "" … … 338 338 BuildCameraTab 339 339 } errs] != 0 } { 340 340 global errorInfo 341 341 puts stderr "errs=$errs errorInfo=$errorInfo" 342 342 } 343 343 344 # Hack around the Tk panewindow. The problem is that the requested 344 # Hack around the Tk panewindow. The problem is that the requested 345 345 # size of the 3d view isn't set until an image is retrieved from 346 346 # the server. So the panewindow uses the tiny size. … … 348 348 pack forget $itk_component(view) 349 349 blt::table $itk_component(plotarea) \ 350 0,0 $itk_component(view) -fill both -reqwidth $w 350 0,0 $itk_component(view) -fill both -reqwidth $w 351 351 blt::table configure $itk_component(plotarea) c1 -resize none 352 352 … … 432 432 433 433 itcl::body Rappture::VtkImageViewer::DoRotate {} { 434 SendCmd "camera orient [ViewToQuaternion]" 434 SendCmd "camera orient [ViewToQuaternion]" 435 435 set _rotatePending 0 436 436 } … … 459 459 if { !$_rotatePending } { 460 460 set _rotatePending 1 461 global rotate_delay 461 global rotate_delay 462 462 $_dispatcher event -after $rotate_delay !rotate 463 463 } … … 558 558 continue 559 559 } 560 if {[info exists _obj2ovride($dataobj-raise)] && 560 if {[info exists _obj2ovride($dataobj-raise)] && 561 561 $_obj2ovride($dataobj-raise)} { 562 562 set dlist [linsert $dlist 0 $dataobj] … … 586 586 } 587 587 return $dlist 588 } 588 } 589 589 -image { 590 590 if {[llength $args] != 2} { … … 606 606 } 607 607 608 # 608 # 609 609 # scale -- 610 610 # 611 611 # This gets called either incrementally as new simulations are 612 612 # added or all at once as a sequence of images. 613 # This accounts for all objects--even those not showing on the 614 # screen. Because of this, the limits are appropriate for all 613 # This accounts for all objects--even those not showing on the 614 # screen. Because of this, the limits are appropriate for all 615 615 # objects as the user scans through data in the ResultSet viewer. 616 616 # … … 804 804 $_dispatcher cancel !legend 805 805 # disconnected -- no more data sitting on server 806 array unset _datasets 807 array unset _data 808 array unset _colormaps 809 array unset _obj2datasets 806 array unset _datasets 807 array unset _data 808 array unset _colormaps 809 array unset _obj2datasets 810 810 global readyForNextFrame 811 811 set readyForNextFrame 1 … … 839 839 set time [clock seconds] 840 840 set date [clock format $time] 841 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 841 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 842 842 if { $_start > 0 } { 843 843 set finish [clock clicks -milliseconds] … … 910 910 # Turn on buffering of commands to the server. We don't want to 911 911 # be preempted by a server disconnect/reconnect (which automatically 912 # generates a new call to Rebuild). 912 # generates a new call to Rebuild). 913 913 StartBufferingCommands 914 914 915 915 if { $_width != $w || $_height != $h || $_reset } { 916 917 918 919 920 921 922 916 set _width $w 917 set _height $h 918 $_arcball resize $w $h 919 DoResize 920 if { $_settings(-stretchtofit) } { 921 AdjustSetting -stretchToFit 922 } 923 923 } 924 924 if { $_reset } { 925 926 927 925 # 926 # Reset the camera and other view parameters 927 # 928 928 InitSettings -view3d -background 929 929 930 931 930 SendCmd "axis lrot z 90" 931 $_arcball quaternion [ViewToQuaternion] 932 932 if {$_settings(-view3d) } { 933 933 if { $_view(-ortho)} { … … 938 938 DoRotate 939 939 SendCmd "camera reset" 940 941 940 } 941 PanCamera 942 942 StopBufferingCommands 943 943 SendCmd "imgflush" … … 957 957 if { ![info exists _datasets($tag)] } { 958 958 set bytes [$dataobj vtkdata $comp] 959 if 0 { 959 if 0 { 960 960 set f [open /tmp/vtkimage.vtk "w"] 961 961 fconfigure $f -translation binary -encoding binary 962 962 puts -nonewline $f $bytes 963 963 close $f 964 964 } 965 965 set length [string length $bytes] 966 966 if { $_reportClientInfo } { … … 990 990 } 991 991 if { $_first != "" } { 992 993 994 992 $itk_component(field) choices delete 0 end 993 $itk_component(fieldmenu) delete 0 end 994 array unset _fields 995 995 set _curFldName "" 996 996 foreach cname [$_first components] { … … 1021 1021 1022 1022 if { $_reset } { 1023 1023 SendCmd "axis tickpos outside" 1024 1024 #SendCmd "axis lformat all %g" 1025 1026 1025 1026 foreach axis { x y z } { 1027 1027 set label [$_first hints ${axis}label] 1028 1029 1030 1031 1032 1033 1034 1028 if { $label == "" } { 1029 set label [string toupper $axis] 1030 } 1031 # May be a space in the axis label. 1032 SendCmd [list axis name $axis $label] 1033 1034 if {$axis == "z" && [$_first hints ${axis}units] == ""} { 1035 1035 if {$_curFldName != ""} { 1036 1036 set units [lindex $_fields($_curFldName) 1] 1037 1037 } 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1038 } else { 1039 set units [$_first hints ${axis}units] 1040 } 1041 if { $units != "" } { 1042 # May be a space in the axis units. 1043 SendCmd [list axis units $axis $units] 1044 } 1045 } 1046 # 1047 # Reset the camera and other view parameters 1048 # 1049 $_arcball quaternion [ViewToQuaternion] 1050 1050 if {$_settings(-view3d) } { 1051 1051 if { $_view(-ortho)} { … … 1057 1057 SendCmd "camera reset" 1058 1058 } 1059 1060 1059 PanCamera 1060 InitSettings -xgrid -ygrid -zgrid \ 1061 1061 -axisvisible -axislabels -field -view3d 1062 1062 if { [array size _fields] < 2 } { … … 1067 1067 } 1068 1068 global readyForNextFrame 1069 set readyForNextFrame 0; 1069 set readyForNextFrame 0; # Don't advance to the next frame 1070 1070 1071 1071 # Actually write the commands to the server socket. If it fails, we don't … … 1085 1085 itcl::body Rappture::VtkImageViewer::CurrentDatasets {args} { 1086 1086 set flag [lindex $args 0] 1087 switch -- $flag { 1087 switch -- $flag { 1088 1088 "-all" { 1089 1089 if { [llength $args] > 1 } { … … 1104 1104 set dlist [get -visible] 1105 1105 } 1106 } 1106 } 1107 1107 default { 1108 1108 set dlist $args … … 1226 1226 foreach tag [CurrentDatasets -visible] { 1227 1227 SendCmd "dataset getscalar pixel $x $y $tag" 1228 } 1228 } 1229 1229 } 1230 1230 … … 1330 1330 "-background" { 1331 1331 set bg [$itk_component(background) value] 1332 1333 1334 1335 "grey""black"1336 1332 array set fgcolors { 1333 "black" "white" 1334 "white" "black" 1335 "grey" "black" 1336 } 1337 1337 set fg $fgcolors($bg) 1338 1338 configure -plotbackground $bg -plotforeground $fg 1339 1339 $itk_component(view) delete "legend" 1340 1340 SendCmd "screen bgcolor [Color2RGB $bg]" 1341 1341 SendCmd "outline color [Color2RGB $fg]" 1342 1342 SendCmd "axis color all [Color2RGB $fg]" 1343 1343 DrawLegend 1344 1344 } 1345 1345 "-backingcolor" { 1346 1346 set color [$itk_component(backingcolor) value] 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1347 if { $color == "none" } { 1348 if { $_settings(-backingvisible) } { 1349 SendCmd "image backing 0" 1350 set _settings(-backingvisible) 0 1351 } 1352 } else { 1353 if { !$_settings(-backingvisible) } { 1354 SendCmd "image backing 1" 1355 set _settings(-backingvisible) 1 1356 } 1357 SendCmd "image color [Color2RGB $color]" 1358 } 1359 1359 } 1360 1360 "-backingvisible" { 1361 1361 set bool $_settings($what) 1362 1362 SendCmd "image backing $bool" 1363 1363 } … … 1372 1372 } 1373 1373 StopBufferingCommands 1374 1374 EventuallyRequestLegend 1375 1375 } 1376 1376 "-colormapdiscrete" { … … 1410 1410 } 1411 1411 "-view3d" { 1412 1412 set bool $_settings($what) 1413 1413 set c $itk_component(view) 1414 1414 StartBufferingCommands … … 1420 1420 } 1421 1421 AdjustSetting -opacity 1422 1423 1424 1422 if { $bool } { 1423 $itk_component(opacity) configure -state normal 1424 $itk_component(opacity_l) configure -state normal 1425 1425 if {$_view(-ortho)} { 1426 1426 SendCmd "camera mode ortho" … … 1429 1429 } 1430 1430 SendCmd "camera aspect native" 1431 1432 1433 1431 } else { 1432 $itk_component(opacity) configure -state disabled 1433 $itk_component(opacity_l) configure -state disabled 1434 1434 SendCmd "camera mode image" 1435 1435 if {$_settings(-stretchtofit)} { … … 1440 1440 set q [ViewToQuaternion] 1441 1441 $_arcball quaternion $q 1442 SendCmd "camera orient $q" 1442 SendCmd "camera orient $q" 1443 1443 } else { 1444 1444 bind $c <ButtonPress-1> {} … … 1447 1447 } 1448 1448 SendCmd "camera reset" 1449 # Fix the mouse bindings for rotation/panning and the 1449 # Fix the mouse bindings for rotation/panning and the 1450 1450 # camera mode. Ideally we'd create a bindtag for these. 1451 1451 if { $bool } { … … 1470 1470 "-legendvisible" { 1471 1471 if { !$_settings($what) } { 1472 1473 1474 1472 $itk_component(view) delete legend 1473 } 1474 DrawLegend 1475 1475 } 1476 1476 "-opacity" { 1477 1477 set _changed($what) 1 1478 1478 if { $_settings(-view3d) } { 1479 1479 set _settings(-saveopacity) $_settings($what) 1480 1480 set val [expr $_settings($what) * 0.01] 1481 1481 SendCmd "image opacity $val" 1482 1482 } else { 1483 1483 SendCmd "image opacity 1.0" 1484 1484 } 1485 1485 } … … 1487 1487 set bool $_settings($what) 1488 1488 SendCmd "outline visible $bool" 1489 1489 } 1490 1490 "-stretchtofit" { 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1491 set bool $_settings($what) 1492 if { $bool } { 1493 if { $_settings(-view3d) } { 1494 SendCmd "camera aspect native" 1495 } else { 1496 SendCmd "camera aspect window" 1497 } 1498 } else { 1499 SendCmd "camera aspect native" 1500 } 1501 } 1502 1502 "-xgrid" - "-ygrid" - "-zgrid" { 1503 1503 set axis [string tolower [string range $what 1 1]] … … 1505 1505 SendCmd "axis grid $axis $bool" 1506 1506 } 1507 1507 default { 1508 1508 error "don't know how to fix $what" 1509 1509 } … … 1515 1515 # 1516 1516 # Request a new legend from the server. The size of the legend 1517 # is determined from the height of the canvas. 1517 # is determined from the height of the canvas. 1518 1518 # 1519 1519 # This should be called when 1520 # 1521 # 1522 # 1523 # 1524 # 1520 # 1. A new current colormap is set. 1521 # 2. Window is resized. 1522 # 3. The limits of the data have changed. (Just need a redraw). 1523 # 4. Number of isolines have changed. (Just need a redraw). 1524 # 5. Legend becomes visible (Just need a redraw). 1525 1525 # 1526 1526 itcl::body Rappture::VtkImageViewer::RequestLegend {} { … … 1529 1529 set w 12 1530 1530 set lineht [font metrics $font -linespace] 1531 # color ramp height = (canvas height) - (min and max value lines) - 2 1531 # color ramp height = (canvas height) - (min and max value lines) - 2 1532 1532 set h [expr {$_height - 2 * ($lineht + 2)}] 1533 1533 set _legendHeight $h … … 1535 1535 set fname $_curFldName 1536 1536 if { [string match "component*" $fname] } { 1537 1537 set title "" 1538 1538 } else { 1539 1540 1541 1542 1543 1544 1545 1546 1539 if { [info exists _fields($fname)] } { 1540 foreach { title units } $_fields($fname) break 1541 if { $units != "" } { 1542 set title [format "%s (%s)" $title $units] 1543 } 1544 } else { 1545 set title $fname 1546 } 1547 1547 } 1548 1548 # If there's a title too, substract one more line 1549 1549 if { $title != "" } { 1550 incr h -$lineht 1550 incr h -$lineht 1551 1551 } 1552 1552 if { $h < 1 } { … … 1555 1555 # Set the legend on the first image dataset. 1556 1556 if { $_currentColormap != "" && $_currentColormap != "none" } { 1557 1557 #SendCmd "legend $_currentColormap scalar $_curFldName {} $w $h 0" 1558 1558 SendCmd "legend2 $_currentColormap $w $h" 1559 1559 } … … 1566 1566 # Keep track of the colormaps that we build. 1567 1567 if { $name != "none" && ![info exists _colormaps($name)] } { 1568 BuildColormap $name 1568 BuildColormap $name 1569 1569 set _colormaps($name) 1 1570 1570 } … … 1593 1593 itcl::configbody Rappture::VtkImageViewer::mode { 1594 1594 switch -- $itk_option(-mode) { 1595 1596 1597 1598 1599 1600 } 1601 1602 1603 1595 "volume" { 1596 set _settings(-view3d) 1 1597 } 1598 "vtkimage" { 1599 set _settings(-view3d) 0 1600 } 1601 default { 1602 error "unknown mode settings \"$itk_option(-mode)\"" 1603 } 1604 1604 } 1605 1605 if { !$_reset } { … … 1617 1617 SendCmd "screen bgcolor $rgb" 1618 1618 } 1619 1619 $itk_component(view) configure -background $itk_option(-plotbackground) 1620 1620 } 1621 1621 } … … 1675 1675 1676 1676 itk_component add field_l { 1677 label $inner.field_l -text "Field" -font "Arial 9" 1677 label $inner.field_l -text "Field" -font "Arial 9" 1678 1678 } { 1679 1679 ignore -font … … 1685 1685 [itcl::code $this AdjustSetting -field] 1686 1686 1687 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1687 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1688 1688 itk_component add colormap { 1689 1689 Rappture::Combobox $inner.colormap -width 10 -editable no … … 1695 1695 [itcl::code $this AdjustSetting -colormap] 1696 1696 1697 label $inner.backingcolor_l -text "Backing Color" -font "Arial 9" 1697 label $inner.backingcolor_l -text "Backing Color" -font "Arial 9" 1698 1698 itk_component add backingcolor { 1699 1699 Rappture::Combobox $inner.backingcolor -width 10 -editable no … … 1709 1709 "red" "red" \ 1710 1710 "white" "white" \ 1711 "none""none"1711 "none" "none" 1712 1712 1713 1713 $itk_component(backingcolor) value $_settings(-backingcolor) 1714 1714 bind $inner.backingcolor <<Value>> \ 1715 1716 1717 label $inner.background_l -text "Background Color" -font "Arial 9" 1715 [itcl::code $this AdjustSetting -backingcolor] 1716 1717 label $inner.background_l -text "Background Color" -font "Arial 9" 1718 1718 itk_component add background { 1719 1719 Rappture::Combobox $inner.background -width 10 -editable no … … 1722 1722 "black" "black" \ 1723 1723 "white" "white" \ 1724 "grey" "grey" 1724 "grey" "grey" 1725 1725 1726 1726 $itk_component(background) value "white" … … 1773 1773 2,0 $inner.backingcolor_l -anchor w -pady 2 \ 1774 1774 2,1 $inner.backingcolor -anchor w -pady 2 -fill x \ 1775 1776 1775 3,0 $inner.background_l -anchor w -pady 2 \ 1776 3,1 $inner.background -anchor w -pady 2 -fill x \ 1777 1777 4,0 $inner.backing -anchor w -pady 2 -cspan 2 \ 1778 1778 5,0 $inner.stretch -anchor w -pady 2 -cspan 2 \ … … 1787 1787 16,1 $inner.window -fill x -pady 2 \ 1788 1788 17,0 $inner.level_l -anchor w -pady 2 \ 1789 17,1 $inner.level -fill x -pady 2 1789 17,1 $inner.level -fill x -pady 2 1790 1790 1791 1791 blt::table configure $inner r* c* -resize none … … 1813 1813 -command [itcl::code $this AdjustSetting -axislabels] \ 1814 1814 -font "Arial 9" 1815 label $inner.grid_l -text "Grid" -font "Arial 9" 1815 label $inner.grid_l -text "Grid" -font "Arial 9" 1816 1816 checkbutton $inner.xgrid \ 1817 1817 -text "X" \ … … 1835 1835 -font "Arial 9" 1836 1836 1837 label $inner.mode_l -text "Mode" -font "Arial 9" 1837 label $inner.mode_l -text "Mode" -font "Arial 9" 1838 1838 1839 1839 itk_component add axisflymode { … … 1844 1844 "closest_triad" "closest" \ 1845 1845 "furthest_triad" "farthest" \ 1846 "outer_edges" "outer" 1846 "outer_edges" "outer" 1847 1847 $itk_component(axisflymode) value $_settings(-axisflymode) 1848 1848 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode] … … 1852 1852 1,0 $inner.labels -anchor w -cspan 4 \ 1853 1853 2,0 $inner.minorticks -anchor w -cspan 4 \ 1854 1854 4,0 $inner.grid_l -anchor w \ 1855 1855 4,1 $inner.xgrid -anchor w \ 1856 1856 4,2 $inner.ygrid -anchor w \ 1857 1857 4,3 $inner.zgrid -anchor w \ 1858 1858 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1859 5,1 $inner.mode -fill x -cspan 3 1859 5,1 $inner.mode -fill x -cspan 3 1860 1860 1861 1861 blt::table configure $inner r* c* -resize none … … 1916 1916 1917 1917 # 1918 # camera -- 1918 # camera -- 1919 1919 # 1920 1920 itcl::body Rappture::VtkImageViewer::camera {option args} { 1921 switch -- $option { 1921 switch -- $option { 1922 1922 "show" { 1923 1923 puts [array get _view] … … 1967 1967 1968 1968 itcl::body Rappture::VtkImageViewer::GetImage { args } { 1969 if { [image width $_image(download)] > 0 && 1969 if { [image width $_image(download)] > 0 && 1970 1970 [image height $_image(download)] > 0 } { 1971 1971 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 1980 1980 -title "[Rappture::filexfer::label downloadWord] as..." 1981 1981 set inner [$popup component inner] 1982 label $inner.summary -text "" -anchor w 1982 label $inner.summary -text "" -anchor w 1983 1983 radiobutton $inner.vtk_button -text "VTK data file" \ 1984 1984 -variable [itcl::scope _downloadPopup(format)] \ 1985 1985 -font "Arial 9 " \ 1986 -value vtk 1986 -value vtk 1987 1987 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 1988 1988 radiobutton $inner.image_button -text "Image File" \ 1989 1989 -variable [itcl::scope _downloadPopup(format)] \ 1990 1990 -font "Arial 9 " \ 1991 -value image 1991 -value image 1992 1992 Rappture::Tooltip::for $inner.image_button \ 1993 1993 "Save as digital image." … … 2010 2010 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 2011 2011 4,1 $inner.cancel -width .9i -fill y \ 2012 4,0 $inner.ok -padx 2 -width .9i -fill y 2012 4,0 $inner.ok -padx 2 -width .9i -fill y 2013 2013 blt::table configure $inner r3 -height 4 2014 2014 blt::table configure $inner r4 -pady 4 … … 2021 2021 # SetObjectStyle -- 2022 2022 # 2023 # Set the style of the image/contour object. This gets calls 2023 # Set the style of the image/contour object. This gets calls 2024 2024 # for each dataset once as it is loaded. It can overridden by 2025 2025 # the user controls. … … 2063 2063 SendCmd "outline visible $_settings(-outline) $tag" 2064 2064 SendCmd "image add $tag" 2065 SetCurrentColormap $style(-color) 2065 SetCurrentColormap $style(-color) 2066 2066 set color [$itk_component(backingcolor) value] 2067 2067 SendCmd "image color [Color2RGB $color] $tag" … … 2094 2094 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2095 2095 if { [catch {DrawLegend} errs] != 0 } { 2096 2097 2096 global errorInfo 2097 puts stderr "errs=$errs errorInfo=$errorInfo" 2098 2098 } 2099 2099 } … … 2112 2112 set font "Arial 8" 2113 2113 set lineht [font metrics $font -linespace] 2114 2114 2115 2115 if { [string match "component*" $fname] } { 2116 2116 set title "" 2117 2117 } else { 2118 2119 2120 2121 2122 2123 2124 2125 2118 if { [info exists _fields($fname)] } { 2119 foreach { title units } $_fields($fname) break 2120 if { $units != "" } { 2121 set title [format "%s (%s)" $title $units] 2122 } 2123 } else { 2124 set title $fname 2125 } 2126 2126 } 2127 2127 set x [expr $w - 2] 2128 2128 if { !$_settings(-legendvisible) } { 2129 2130 2131 } 2129 $c delete legend 2130 return 2131 } 2132 2132 if { [$c find withtag "legend"] == "" } { 2133 set y 2 2134 2133 set y 2 2134 # If there's a legend title, create a text item for the title. 2135 2135 $c create text $x $y \ 2136 2136 -anchor ne \ … … 2140 2140 incr y $lineht 2141 2141 } 2142 2142 $c create text $x $y \ 2143 2143 -anchor ne \ 2144 2144 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2145 2145 -font $font 2146 2146 incr y $lineht 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2147 $c create image $x $y \ 2148 -anchor ne \ 2149 -image $_image(legend) -tags "colormap legend" 2150 $c create rectangle $x $y 1 1 \ 2151 -fill "" -outline "" -tags "sensor legend" 2152 $c create text $x [expr {$h-2}] \ 2153 -anchor se \ 2154 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2155 -font $font 2156 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2157 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2158 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2159 2159 } 2160 2160 … … 2170 2170 if { [info exists _limits($_curFldName)] } { 2171 2171 foreach { vmin vmax } $_limits($_curFldName) break 2172 2173 2172 $c itemconfigure vmin -text [format %g $vmin] 2173 $c itemconfigure vmax -text [format %g $vmax] 2174 2174 } 2175 2175 set y 2 … … 2177 2177 if { $title != "" } { 2178 2178 $c itemconfigure title -text $title 2179 2180 2179 $c coords title $x $y 2180 incr y $lineht 2181 2181 } 2182 2182 $c coords vmax $x $y … … 2226 2226 set font "Arial 8" 2227 2227 set lineht [font metrics $font -linespace] 2228 2228 2229 2229 set ih [image height $_image(legend)] 2230 2230 # Subtract off the offset of the color ramp from the top of the canvas … … 2232 2232 2233 2233 if { [string match "component*" $fname] } { 2234 2234 set title "" 2235 2235 } else { 2236 2237 2238 2239 2240 2241 2242 2243 2236 if { [info exists _fields($fname)] } { 2237 foreach { title units } $_fields($fname) break 2238 if { $units != "" } { 2239 set title [format "%s (%s)" $title $units] 2240 } 2241 } else { 2242 set title $fname 2243 } 2244 2244 } 2245 2245 # If there's a legend title, increase the offset by the line height. … … 2257 2257 } 2258 2258 set color [eval format "\#%02x%02x%02x" $pixel] 2259 $_image(swatch) put black -to 0 0 23 23 2260 $_image(swatch) put $color -to 1 1 22 22 2259 $_image(swatch) put black -to 0 0 23 23 2260 $_image(swatch) put $color -to 1 1 22 22 2261 2261 2262 2262 # Compute the value of the point … … 2268 2268 set value 0.0 2269 2269 } 2270 set tipx [expr $x + 15] 2270 set tipx [expr $x + 15] 2271 2271 set tipy [expr $y - 5] 2272 2272 .rappturetooltip configure -icon $_image(swatch) … … 2276 2276 Rappture::Tooltip::text $c [format "$title %g" $value] 2277 2277 } 2278 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2278 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2279 2279 } 2280 2280 … … 2291 2291 # ---------------------------------------------------------------------- 2292 2292 itcl::body Rappture::VtkImageViewer::Combo {option} { 2293 set c $itk_component(view) 2293 set c $itk_component(view) 2294 2294 switch -- $option { 2295 2295 post { … … 2304 2304 } 2305 2305 deactivate { 2306 $c itemconfigure title -fill $itk_option(-plotforeground) 2306 $c itemconfigure title -fill $itk_option(-plotforeground) 2307 2307 } 2308 2308 invoke { … … 2316 2316 } 2317 2317 2318 itcl::body Rappture::VtkImageViewer::SetOrientation { side } { 2318 itcl::body Rappture::VtkImageViewer::SetOrientation { side } { 2319 2319 array set positions { 2320 2320 front "0.707107 0.707107 0 0" … … 2327 2327 foreach name { -qw -qx -qy -qz } value $positions($side) { 2328 2328 set _view($name) $value 2329 } 2329 } 2330 2330 set q [ViewToQuaternion] 2331 2331 $_arcball quaternion $q -
trunk/gui/scripts/vtkmeshviewer.tcl
r4771 r5006 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: vtkmeshviewer - Vtk mesh viewer … … 58 58 public method isconnected {} 59 59 public method limits { dataobj } 60 public method parameters {title args} { 61 # do nothing 60 public method parameters {title args} { 61 # do nothing 62 62 } 63 63 public method scale {args} … … 67 67 private method BuildAxisTab {} 68 68 private method BuildCameraTab {} 69 private method BuildDownloadPopup { widget command } 69 private method BuildDownloadPopup { widget command } 70 70 private method BuildPolydataTab {} 71 71 private method Connect {} … … 74 74 private method DoResize {} 75 75 private method DoRotate {} 76 private method EventuallyResize { w h } 77 private method EventuallyRotate { q } 78 private method EventuallySetPolydataOpacity {} 79 private method GetImage { args } 80 private method GetVtkData { args } 76 private method EventuallyResize { w h } 77 private method EventuallyRotate { q } 78 private method EventuallySetPolydataOpacity {} 79 private method GetImage { args } 80 private method GetVtkData { args } 81 81 private method InitSettings { args } 82 private method IsValidObject { dataobj } 82 private method IsValidObject { dataobj } 83 83 private method Pan {option x y} 84 84 private method PanCamera {} 85 85 private method Pick {x y} 86 private method QuaternionToView { q } { 86 private method QuaternionToView { q } { 87 87 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 88 88 } … … 91 91 private method ReceiveImage { args } 92 92 private method Rotate {option x y} 93 private method SetObjectStyle { dataobj } 93 private method SetObjectStyle { dataobj } 94 94 private method SetOrientation { side } 95 95 private method SetPolydataOpacity {} 96 private method ViewToQuaternion {} { 96 private method ViewToQuaternion {} { 97 97 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 98 98 } … … 100 100 101 101 private variable _arcball "" 102 private variable _dlist ""; 102 private variable _dlist ""; # list of data objects 103 103 private variable _obj2datasets 104 private variable _obj2ovride; 105 private variable _datasets; # contains all the dataobj-component106 107 private variable _dataset2style; 108 private variable _style2datasets; # maps tf back to list of109 104 private variable _obj2ovride; # maps dataobj => style override 105 private variable _datasets; # contains all the dataobj-component 106 # datasets in the server 107 private variable _dataset2style; # maps dataobj-component to transfunc 108 private variable _style2datasets; # maps tf back to list of 109 # dataobj-components using the tf. 110 110 private variable _click; # info used for rotate operations 111 111 private variable _limits; # autoscale min/max for all axes … … 200 200 array set _widget { 201 201 -polydataopacity 100 202 } 202 } 203 203 itk_component add view { 204 204 canvas $itk_component(plotarea).view \ … … 211 211 itk_component add fieldmenu { 212 212 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 213 -tearoff no 213 -tearoff no 214 214 } { 215 215 usual … … 232 232 233 233 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 234 set _map(cwidth) -1 235 set _map(cheight) -1 234 set _map(cwidth) -1 235 set _map(cheight) -1 236 236 set _map(zoom) 1.0 237 237 set _map(original) "" … … 279 279 BuildCameraTab 280 280 281 # Hack around the Tk panewindow. The problem is that the requested 281 # Hack around the Tk panewindow. The problem is that the requested 282 282 # size of the 3d view isn't set until an image is retrieved from 283 283 # the server. So the panewindow uses the tiny size. … … 285 285 pack forget $itk_component(view) 286 286 blt::table $itk_component(plotarea) \ 287 0,0 $itk_component(view) -fill both -reqwidth $w 287 0,0 $itk_component(view) -fill both -reqwidth $w 288 288 blt::table configure $itk_component(plotarea) c1 -resize none 289 289 … … 372 372 373 373 itcl::body Rappture::VtkMeshViewer::DoRotate {} { 374 SendCmd "camera orient [ViewToQuaternion]" 374 SendCmd "camera orient [ViewToQuaternion]" 375 375 set _rotatePending 0 376 376 } … … 497 497 continue 498 498 } 499 if {[info exists _obj2ovride($dataobj-raise)] && 499 if {[info exists _obj2ovride($dataobj-raise)] && 500 500 $_obj2ovride($dataobj-raise)} { 501 501 set dlist [linsert $dlist 0 $dataobj] … … 525 525 } 526 526 return $dlist 527 } 527 } 528 528 -image { 529 529 if {[llength $args] != 2} { … … 814 814 # Turn on buffering of commands to the server. We don't want to 815 815 # be preempted by a server disconnect/reconnect (which automatically 816 # generates a new call to Rebuild). 816 # generates a new call to Rebuild). 817 817 StartBufferingCommands 818 818 … … 897 897 InitSettings -polydataedges -polydatalighting -polydataopacity \ 898 898 -polydatavisible -polydatawireframe 899 899 900 900 #SendCmd "axis lformat all %g" 901 901 … … 933 933 itcl::body Rappture::VtkMeshViewer::CurrentDatasets {args} { 934 934 set flag [lindex $args 0] 935 switch -- $flag { 935 switch -- $flag { 936 936 "-all" { 937 937 if { [llength $args] > 1 } { … … 952 952 set dlist [get -visible] 953 953 } 954 } 954 } 955 955 default { 956 956 set dlist $args … … 1068 1068 foreach tag [CurrentDatasets -visible] { 1069 1069 SendCmd "dataset getscalar pixel $x $y $tag" 1070 } 1070 } 1071 1071 } 1072 1072 … … 1245 1245 set f [open "$tmpfile" "w"] 1246 1246 fconfigure $f -translation binary -encoding binary 1247 puts $f $data 1247 puts $f $data 1248 1248 close $f 1249 1249 set reader [vtkDataSetReader $tag-xvtkDataSetReader] … … 1293 1293 -variable [itcl::scope _settings(-polydatavisible)] \ 1294 1294 -command [itcl::code $this AdjustSetting -polydatavisible] \ 1295 -font "Arial 9" -anchor w 1295 -font "Arial 9" -anchor w 1296 1296 1297 1297 checkbutton $inner.outline \ … … 1299 1299 -variable [itcl::scope _settings(-outline)] \ 1300 1300 -command [itcl::code $this AdjustSetting -outline] \ 1301 -font "Arial 9" -anchor w 1301 -font "Arial 9" -anchor w 1302 1302 1303 1303 checkbutton $inner.wireframe \ … … 1305 1305 -variable [itcl::scope _settings(-polydatawireframe)] \ 1306 1306 -command [itcl::code $this AdjustSetting -polydatawireframe] \ 1307 -font "Arial 9" -anchor w 1307 -font "Arial 9" -anchor w 1308 1308 1309 1309 checkbutton $inner.lighting \ … … 1320 1320 1321 1321 itk_component add field_l { 1322 label $inner.field_l -text "Field" -font "Arial 9" 1322 label $inner.field_l -text "Field" -font "Arial 9" 1323 1323 } { 1324 1324 ignore -font … … 1330 1330 [itcl::code $this AdjustSetting -field] 1331 1331 1332 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 1332 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 1333 1333 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1334 1334 -variable [itcl::scope _widget(-polydataopacity)] \ … … 1345 1345 4,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 1346 1346 5,0 $inner.opacity_l -anchor w -pady 2 \ 1347 5,1 $inner.opacity -fill x -pady 2 1347 5,1 $inner.opacity -fill x -pady 2 1348 1348 1349 1349 blt::table configure $inner r* c* -resize none … … 1372 1372 -command [itcl::code $this AdjustSetting -axislabels] \ 1373 1373 -font "Arial 9" 1374 label $inner.grid_l -text "Grid" -font "Arial 9" 1374 label $inner.grid_l -text "Grid" -font "Arial 9" 1375 1375 checkbutton $inner.xgrid \ 1376 1376 -text "X" \ … … 1394 1394 -font "Arial 9" 1395 1395 1396 label $inner.mode_l -text "Mode" -font "Arial 9" 1396 label $inner.mode_l -text "Mode" -font "Arial 9" 1397 1397 1398 1398 itk_component add axismode { … … 1403 1403 "closest_triad" "closest" \ 1404 1404 "furthest_triad" "farthest" \ 1405 "outer_edges" "outer" 1405 "outer_edges" "outer" 1406 1406 $itk_component(axismode) value "static" 1407 1407 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] … … 1475 1475 1476 1476 # 1477 # camera -- 1477 # camera -- 1478 1478 # 1479 1479 itcl::body Rappture::VtkMeshViewer::camera {option args} { 1480 switch -- $option { 1480 switch -- $option { 1481 1481 "show" { 1482 1482 puts [array get _view] … … 1523 1523 1524 1524 itcl::body Rappture::VtkMeshViewer::GetImage { args } { 1525 if { [image width $_image(download)] > 0 && 1525 if { [image width $_image(download)] > 0 && 1526 1526 [image height $_image(download)] > 0 } { 1527 1527 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 1536 1536 -title "[Rappture::filexfer::label downloadWord] as..." 1537 1537 set inner [$popup component inner] 1538 label $inner.summary -text "" -anchor w 1538 label $inner.summary -text "" -anchor w 1539 1539 radiobutton $inner.vtk_button -text "VTK data file" \ 1540 1540 -variable [itcl::scope _downloadPopup(format)] \ 1541 1541 -font "Helvetica 9 " \ 1542 -value vtk 1542 -value vtk 1543 1543 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 1544 1544 radiobutton $inner.image_button -text "Image File" \ 1545 1545 -variable [itcl::scope _downloadPopup(format)] \ 1546 -value image 1546 -value image 1547 1547 Rappture::Tooltip::for $inner.image_button \ 1548 1548 "Save as digital image." … … 1565 1565 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 1566 1566 4,1 $inner.cancel -width .9i -fill y \ 1567 4,0 $inner.ok -padx 2 -width .9i -fill y 1567 4,0 $inner.ok -padx 2 -width .9i -fill y 1568 1568 blt::table configure $inner r3 -height 4 1569 1569 blt::table configure $inner r4 -pady 4 … … 1634 1634 } 1635 1635 1636 itcl::body Rappture::VtkMeshViewer::SetOrientation { side } { 1636 itcl::body Rappture::VtkMeshViewer::SetOrientation { side } { 1637 1637 array set positions { 1638 1638 front "1 0 0 0" … … 1645 1645 foreach name { -qw -qx -qy -qz } value $positions($side) { 1646 1646 set _view($name) $value 1647 } 1647 } 1648 1648 set q [ViewToQuaternion] 1649 1649 $_arcball quaternion $q -
trunk/gui/scripts/vtkstreamlinesviewer.tcl
r4942 r5006 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: vtkstreamlinesviewer - Vtk streamlines object viewer … … 57 57 public method get {args} 58 58 public method isconnected {} 59 public method parameters {title args} { 60 # do nothing 59 public method parameters {title args} { 60 # do nothing 61 61 } 62 62 public method scale {args} … … 68 68 private method BuildColormap { name colors } 69 69 private method BuildCutplaneTab {} 70 private method BuildDownloadPopup { widget command } 70 private method BuildDownloadPopup { widget command } 71 71 private method BuildStreamsTab {} 72 72 private method BuildVolumeTab {} … … 79 79 private method DoReseed {} 80 80 private method DoRotate {} 81 private method EnterLegend { x y } 82 private method EventuallyResize { w h } 83 private method EventuallyReseed { numPoints } 84 private method EventuallyRotate { q } 85 private method EventuallySetCutplane { axis args } 86 private method GetImage { args } 87 private method GetVtkData { args } 81 private method EnterLegend { x y } 82 private method EventuallyResize { w h } 83 private method EventuallyReseed { numPoints } 84 private method EventuallyRotate { q } 85 private method EventuallySetCutplane { axis args } 86 private method GetImage { args } 87 private method GetVtkData { args } 88 88 private method InitSettings { args } 89 private method IsValidObject { dataobj } 89 private method IsValidObject { dataobj } 90 90 private method LeaveLegend {} 91 private method MotionLegend { x y } 91 private method MotionLegend { x y } 92 92 private method Pan {option x y} 93 93 private method PanCamera {} 94 94 private method Pick {x y} 95 private method QuaternionToView { q } { 95 private method QuaternionToView { q } { 96 96 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 97 97 } … … 105 105 private method ChangeColormap { dataobj comp color } 106 106 private method SetLegendTip { x y } 107 private method SetObjectStyle { dataobj comp } 108 private method Slice {option args} 107 private method SetObjectStyle { dataobj comp } 108 private method Slice {option args} 109 109 private method SetOrientation { side } 110 private method ViewToQuaternion {} { 110 private method ViewToQuaternion {} { 111 111 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 112 112 } … … 118 118 private variable _obj2datasets 119 119 private variable _obj2ovride ; # maps dataobj => style override 120 private variable _datasets ; # contains all the dataobj-component 120 private variable _datasets ; # contains all the dataobj-component 121 121 ; # datasets in the server 122 122 private variable _colormaps ; # contains all the colormaps … … 147 147 private variable _cutplanePending 0 148 148 private variable _legendPending 0 149 private variable _vectorFields 150 private variable _scalarFields 151 private variable _fields 149 private variable _vectorFields 150 private variable _scalarFields 151 private variable _fields 152 152 private variable _curFldName "" 153 153 private variable _curFldLabel "" … … 271 271 itk_component add fieldmenu { 272 272 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 273 -tearoff no 273 -tearoff no 274 274 } { 275 275 usual … … 291 291 292 292 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 293 set _map(cwidth) -1 294 set _map(cheight) -1 293 set _map(cwidth) -1 294 set _map(cheight) -1 295 295 set _map(zoom) 1.0 296 296 set _map(original) "" … … 338 338 -offimage [Rappture::icon volume-off] \ 339 339 -variable [itcl::scope _settings(-volumevisible)] \ 340 -command [itcl::code $this AdjustSetting -volumevisible] 340 -command [itcl::code $this AdjustSetting -volumevisible] 341 341 } 342 342 $itk_component(volume) select … … 362 362 -offimage [Rappture::icon cutbutton] \ 363 363 -variable [itcl::scope _settings(-cutplanevisible)] \ 364 -command [itcl::code $this AdjustSetting -cutplanevisible] 364 -command [itcl::code $this AdjustSetting -cutplanevisible] 365 365 } 366 366 Rappture::Tooltip::for $itk_component(cutplane) \ … … 382 382 set _image(legend) [image create photo] 383 383 itk_component add legend { 384 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 384 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 385 385 } { 386 386 usual … … 389 389 } 390 390 391 # Hack around the Tk panewindow. The problem is that the requested 391 # Hack around the Tk panewindow. The problem is that the requested 392 392 # size of the 3d view isn't set until an image is retrieved from 393 393 # the server. So the panewindow uses the tiny size. … … 395 395 pack forget $itk_component(view) 396 396 blt::table $itk_component(plotarea) \ 397 0,0 $itk_component(view) -fill both -reqwidth $w 397 0,0 $itk_component(view) -fill both -reqwidth $w 398 398 blt::table configure $itk_component(plotarea) c1 -resize none 399 399 … … 480 480 481 481 itcl::body Rappture::VtkStreamlinesViewer::DoRotate {} { 482 SendCmd "camera orient [ViewToQuaternion]" 482 SendCmd "camera orient [ViewToQuaternion]" 483 483 set _rotatePending 0 484 484 } … … 517 517 if { !$_rotatePending } { 518 518 set _rotatePending 1 519 global rotate_delay 519 global rotate_delay 520 520 $_dispatcher event -after $rotate_delay !rotate 521 521 } … … 621 621 continue 622 622 } 623 if {[info exists _obj2ovride($dataobj-raise)] && 623 if {[info exists _obj2ovride($dataobj-raise)] && 624 624 $_obj2ovride($dataobj-raise)} { 625 625 set dlist [linsert $dlist 0 $dataobj] … … 649 649 } 650 650 return $dlist 651 } 651 } 652 652 -image { 653 653 if {[llength $args] != 2} { … … 791 791 set info {} 792 792 set user "???" 793 793 if { [info exists env(USER)] } { 794 794 set user $env(USER) 795 795 } 796 796 set session "???" 797 797 if { [info exists env(SESSION)] } { 798 798 set session $env(SESSION) 799 799 } 800 800 lappend info "version" "$Rappture::version" 801 801 lappend info "build" "$Rappture::build" … … 851 851 $_dispatcher cancel !legend 852 852 # disconnected -- no more data sitting on server 853 array unset _datasets 854 array unset _data 855 array unset _colormaps 856 array unset _seeds 857 array unset _dataset2style 858 array unset _obj2datasets 853 array unset _datasets 854 array unset _data 855 array unset _colormaps 856 array unset _seeds 857 array unset _dataset2style 858 array unset _obj2datasets 859 859 } 860 860 … … 884 884 set time [clock seconds] 885 885 set date [clock format $time] 886 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 886 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" 887 887 if { $_start > 0 } { 888 888 set finish [clock clicks -milliseconds] … … 964 964 set _first "" 965 965 if { $_reset } { 966 967 968 969 970 971 966 set _width $w 967 set _height $h 968 $_arcball resize $w $h 969 DoResize 970 InitSettings -xgrid -ygrid -zgrid -axismode \ 971 -axesvisible -axislabelsvisible -axisminorticks 972 972 # This "imgflush" is to force an image returned before vtkvis starts 973 973 # reading a (big) dataset. This will display an empty plot with axes … … 988 988 set bytes [$dataobj vtkdata $comp] 989 989 set length [string length $bytes] 990 if 0 { 990 if 0 { 991 991 set f [open /tmp/vtkstreamlines.vtk "w"] 992 992 fconfigure $f -translation binary -encoding binary 993 993 puts -nonewline $f $bytes 994 994 close $f 995 995 } 996 996 if { $_reportClientInfo } { 997 997 set info {} … … 1032 1032 } 1033 1033 } 1034 1035 1036 1034 $itk_component(field) choices delete 0 end 1035 $itk_component(fieldmenu) delete 0 end 1036 array unset _fields 1037 1037 set _curFldName "" 1038 1038 foreach cname [$_first components] { … … 1068 1068 -volumevisible -volumeedges -volumelighting -volumeopacity \ 1069 1069 -volumewireframe \ 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1070 -cutplanevisible \ 1071 -cutplanexposition -cutplaneyposition -cutplanezposition \ 1072 -cutplanexvisible -cutplaneyvisible -cutplanezvisible 1073 1074 # Reset the camera and other view parameters 1075 $_arcball quaternion [ViewToQuaternion] 1076 if {$_view(-ortho)} { 1077 SendCmd "camera mode ortho" 1078 } else { 1079 SendCmd "camera mode persp" 1080 } 1081 DoRotate 1082 PanCamera 1083 1083 Zoom reset 1084 1084 SendCmd "camera reset" … … 1101 1101 itcl::body Rappture::VtkStreamlinesViewer::CurrentDatasets {args} { 1102 1102 set flag [lindex $args 0] 1103 switch -- $flag { 1103 switch -- $flag { 1104 1104 "-all" { 1105 1105 if { [llength $args] > 1 } { … … 1120 1120 set dlist [get -visible] 1121 1121 } 1122 } 1122 } 1123 1123 default { 1124 1124 set dlist $args … … 1239 1239 foreach tag [CurrentDatasets -visible] { 1240 1240 SendCmdNoWait "dataset getscalar pixel $x $y $tag" 1241 } 1241 } 1242 1242 } 1243 1243 … … 1666 1666 2,0 $inner.edges -anchor w -pady 2 -cspan 3 \ 1667 1667 3,0 $inner.opacity_l -anchor w -pady 2 \ 1668 3,1 $inner.opacity -fill x -pady 2 1668 3,1 $inner.opacity -fill x -pady 2 1669 1669 1670 1670 blt::table configure $inner r* c* -resize none … … 1687 1687 -command [itcl::code $this AdjustSetting -streamlinesvisible] \ 1688 1688 -font "Arial 9" 1689 1689 1690 1690 checkbutton $inner.lighting \ 1691 1691 -text "Enable Lighting" \ … … 1700 1700 -font "Arial 9" 1701 1701 1702 label $inner.mode_l -text "Mode" -font "Arial 9" 1702 label $inner.mode_l -text "Mode" -font "Arial 9" 1703 1703 itk_component add streammode { 1704 1704 Rappture::Combobox $inner.mode -width 10 -editable no … … 1707 1707 "lines" "lines" \ 1708 1708 "ribbons" "ribbons" \ 1709 "tubes" "tubes" 1709 "tubes" "tubes" 1710 1710 $itk_component(streammode) value $_settings(-streamlinesmode) 1711 1711 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -streamlinesmode] … … 1732 1732 -command [itcl::code $this AdjustSetting -streamlinesscale] 1733 1733 1734 label $inner.field_l -text "Color by" -font "Arial 9" 1734 label $inner.field_l -text "Color by" -font "Arial 9" 1735 1735 itk_component add field { 1736 1736 Rappture::Combobox $inner.field -width 10 -editable no … … 1739 1739 [itcl::code $this AdjustSetting -field] 1740 1740 1741 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1741 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1742 1742 itk_component add colormap { 1743 1743 Rappture::Combobox $inner.colormap -width 10 -editable no … … 1788 1788 -command [itcl::code $this AdjustSetting -axislabelsvisible] \ 1789 1789 -font "Arial 9" 1790 label $inner.grid_l -text "Grid" -font "Arial 9" 1790 label $inner.grid_l -text "Grid" -font "Arial 9" 1791 1791 checkbutton $inner.xgrid \ 1792 1792 -text "X" \ … … 1810 1810 -font "Arial 9" 1811 1811 1812 label $inner.mode_l -text "Mode" -font "Arial 9" 1812 label $inner.mode_l -text "Mode" -font "Arial 9" 1813 1813 1814 1814 itk_component add axismode { … … 1819 1819 "closest_triad" "closest" \ 1820 1820 "furthest_triad" "farthest" \ 1821 "outer_edges" "outer" 1821 "outer_edges" "outer" 1822 1822 $itk_component(axismode) value $_settings(-axismode) 1823 1823 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] … … 1893 1893 1894 1894 set fg [option get $itk_component(hull) font Font] 1895 1895 1896 1896 set inner [$itk_component(main) insert end \ 1897 1897 -title "Cutplane Settings" \ 1898 -icon [Rappture::icon cutbutton]] 1898 -icon [Rappture::icon cutbutton]] 1899 1899 1900 1900 $inner configure -borderwidth 4 … … 1950 1950 -command [itcl::code $this EventuallySetCutplane x] \ 1951 1951 -variable [itcl::scope _settings(-cutplanexposition)] \ 1952 1952 -foreground red3 -font "Arial 9 bold" 1953 1953 } { 1954 1954 usual … … 1979 1979 -command [itcl::code $this EventuallySetCutplane y] \ 1980 1980 -variable [itcl::scope _settings(-cutplaneyposition)] \ 1981 1981 -foreground green3 -font "Arial 9 bold" 1982 1982 } { 1983 1983 usual … … 2008 2008 -command [itcl::code $this EventuallySetCutplane z] \ 2009 2009 -variable [itcl::scope _settings(-cutplanezposition)] \ 2010 2010 -foreground blue3 -font "Arial 9 bold" 2011 2011 } { 2012 2012 usual … … 2024 2024 3,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 2025 2025 3,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 2026 2026 4,0 $itk_component(xCutButton) -anchor w -padx 2 -pady 2 \ 2027 2027 5,0 $itk_component(yCutButton) -anchor w -padx 2 -pady 2 \ 2028 2028 6,0 $itk_component(zCutButton) -anchor w -padx 2 -pady 2 \ … … 2036 2036 2037 2037 # 2038 # camera -- 2038 # camera -- 2039 2039 # 2040 2040 itcl::body Rappture::VtkStreamlinesViewer::camera {option args} { 2041 switch -- $option { 2041 switch -- $option { 2042 2042 "show" { 2043 2043 puts [array get _view] … … 2087 2087 2088 2088 itcl::body Rappture::VtkStreamlinesViewer::GetImage { args } { 2089 if { [image width $_image(download)] > 0 && 2089 if { [image width $_image(download)] > 0 && 2090 2090 [image height $_image(download)] > 0 } { 2091 2091 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 2100 2100 -title "[Rappture::filexfer::label downloadWord] as..." 2101 2101 set inner [$popup component inner] 2102 label $inner.summary -text "" -anchor w 2102 label $inner.summary -text "" -anchor w 2103 2103 radiobutton $inner.vtk_button -text "VTK data file" \ 2104 2104 -variable [itcl::scope _downloadPopup(format)] \ 2105 2105 -font "Helvetica 9 " \ 2106 -value vtk 2106 -value vtk 2107 2107 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 2108 2108 radiobutton $inner.image_button -text "Image File" \ 2109 2109 -variable [itcl::scope _downloadPopup(format)] \ 2110 -value image 2110 -value image 2111 2111 Rappture::Tooltip::for $inner.image_button \ 2112 2112 "Save as digital image." … … 2129 2129 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 2130 2130 4,1 $inner.cancel -width .9i -fill y \ 2131 4,0 $inner.ok -padx 2 -width .9i -fill y 2131 4,0 $inner.ok -padx 2 -width .9i -fill y 2132 2132 blt::table configure $inner r3 -height 4 2133 2133 blt::table configure $inner r4 -pady 4 … … 2196 2196 set _legendPending 0 2197 2197 set _title $title 2198 regsub {\(mag\)} $title "" _title 2198 regsub {\(mag\)} $title "" _title 2199 2199 if { [IsConnected] } { 2200 2200 set bytes [ReceiveBytes $size] … … 2223 2223 set font "Arial 8" 2224 2224 set lineht [font metrics $font -linespace] 2225 2225 2226 2226 if { [info exists _fields($fname)] } { 2227 2227 foreach { title units } $_fields($fname) break … … 2235 2235 set x [expr $w - 2] 2236 2236 if { [$c find withtag "legend"] == "" } { 2237 set y 2 2237 set y 2 2238 2238 $c create text $x $y \ 2239 2239 -anchor ne \ … … 2310 2310 set font "Arial 8" 2311 2311 set lineht [font metrics $font -linespace] 2312 2312 2313 2313 set imgHeight [image height $_image(legend)] 2314 2314 set coords [$c coords colormap] … … 2333 2333 } 2334 2334 set color [eval format "\#%02x%02x%02x" $pixel] 2335 $_image(swatch) put black -to 0 0 23 23 2336 $_image(swatch) put $color -to 1 1 22 22 2335 $_image(swatch) put black -to 0 0 23 23 2336 $_image(swatch) put $color -to 1 1 22 22 2337 2337 .rappturetooltip configure -icon $_image(swatch) 2338 2338 … … 2345 2345 set value 0.0 2346 2346 } 2347 set tipx [expr $x + 15] 2347 set tipx [expr $x + 15] 2348 2348 set tipy [expr $y - 5] 2349 2349 Rappture::Tooltip::text $c "$title $value" 2350 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2350 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 2351 2351 } 2352 2352 … … 2393 2393 # ---------------------------------------------------------------------- 2394 2394 itcl::body Rappture::VtkStreamlinesViewer::Combo {option} { 2395 set c $itk_component(view) 2395 set c $itk_component(view) 2396 2396 switch -- $option { 2397 2397 post { … … 2406 2406 } 2407 2407 deactivate { 2408 $c itemconfigure title -fill white 2408 $c itemconfigure title -fill white 2409 2409 } 2410 2410 invoke { … … 2418 2418 } 2419 2419 2420 itcl::body Rappture::VtkStreamlinesViewer::SetOrientation { side } { 2420 itcl::body Rappture::VtkStreamlinesViewer::SetOrientation { side } { 2421 2421 array set positions { 2422 2422 front "1 0 0 0" … … 2429 2429 foreach name { -qw -qx -qy -qz } value $positions($side) { 2430 2430 set _view($name) $value 2431 } 2431 } 2432 2432 set q [ViewToQuaternion] 2433 2433 $_arcball quaternion $q 2434 SendCmd "camera orient $q" 2434 SendCmd "camera orient $q" 2435 2435 SendCmd "camera reset" 2436 2436 set _view(-xpan) 0 -
trunk/gui/scripts/vtksurfaceviewer.tcl
r4767 r5006 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: vtksurfaceviewer - Vtk 3D boundary surface viewer … … 57 57 public method get {args} 58 58 public method isconnected {} 59 public method parameters {title args} { 60 # do nothing 59 public method parameters {title args} { 60 # do nothing 61 61 } 62 62 public method scale {args} … … 67 67 private method BuildCameraTab {} 68 68 private method BuildColormap { name } 69 private method BuildDownloadPopup { widget command } 69 private method BuildDownloadPopup { widget command } 70 70 private method BuildSurfaceTab {} 71 71 private method Combo { option } … … 76 76 private method DoRotate {} 77 77 private method DrawLegend {} 78 private method EnterLegend { x y } 79 private method EventuallyRequestLegend {} 80 private method EventuallyResize { w h } 81 private method EventuallyRotate { q } 82 private method GetImage { args } 83 private method GetVtkData { args } 78 private method EnterLegend { x y } 79 private method EventuallyRequestLegend {} 80 private method EventuallyResize { w h } 81 private method EventuallyRotate { q } 82 private method GetImage { args } 83 private method GetVtkData { args } 84 84 private method InitSettings { args } 85 private method IsValidObject { dataobj } 85 private method IsValidObject { dataobj } 86 86 private method LeaveLegend {} 87 private method MotionLegend { x y } 87 private method MotionLegend { x y } 88 88 private method Pan {option x y} 89 89 private method PanCamera {} 90 90 private method Pick {x y} 91 private method QuaternionToView { q } { 91 private method QuaternionToView { q } { 92 92 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 93 93 } … … 103 103 private method SetOrientation { side } 104 104 private method UpdateContourList {} 105 private method ViewToQuaternion {} { 105 private method ViewToQuaternion {} { 106 106 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 107 107 } … … 113 113 private variable _obj2datasets 114 114 private variable _obj2ovride ; # maps dataobj => style override 115 private variable _datasets ; # contains all the dataobj-component 115 private variable _datasets ; # contains all the dataobj-component 116 116 ; # datasets in the server 117 117 private variable _colormaps ; # contains all the colormaps … … 148 148 private variable _legendPending 0 149 149 private variable _field "" 150 private variable _colorMode "scalar"; 151 private variable _fieldNames {} 152 private variable _fields 150 private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar) 151 private variable _fieldNames {} 152 private variable _fields 153 153 private variable _curFldName "" 154 154 private variable _curFldLabel "" … … 243 243 itk_component add fieldmenu { 244 244 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 245 -tearoff 0 245 -tearoff 0 246 246 } { 247 247 usual … … 263 263 264 264 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 265 set _map(cwidth) -1 266 set _map(cheight) -1 265 set _map(cwidth) -1 266 set _map(cheight) -1 267 267 set _map(zoom) 1.0 268 268 set _map(original) "" … … 311 311 -offimage [Rappture::icon volume-off] \ 312 312 -variable [itcl::scope _settings(-surfacevisible)] \ 313 -command [itcl::code $this AdjustSetting -surfacevisible] 313 -command [itcl::code $this AdjustSetting -surfacevisible] 314 314 } 315 315 $itk_component(surface) select … … 329 329 set _image(legend) [image create photo] 330 330 itk_component add legend { 331 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 331 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 332 332 } { 333 333 usual … … 336 336 } 337 337 338 # Hack around the Tk panewindow. The problem is that the requested 338 # Hack around the Tk panewindow. The problem is that the requested 339 339 # size of the 3d view isn't set until an image is retrieved from 340 340 # the server. So the panewindow uses the tiny size. … … 342 342 pack forget $itk_component(view) 343 343 blt::table $itk_component(plotarea) \ 344 0,0 $itk_component(view) -fill both -reqwidth $w 344 0,0 $itk_component(view) -fill both -reqwidth $w 345 345 blt::table configure $itk_component(plotarea) c1 -resize none 346 346 … … 429 429 430 430 itcl::body Rappture::VtkSurfaceViewer::DoRotate {} { 431 SendCmd "camera orient [ViewToQuaternion]" 431 SendCmd "camera orient [ViewToQuaternion]" 432 432 set _rotatePending 0 433 433 } … … 456 456 if { !$_rotatePending } { 457 457 set _rotatePending 1 458 global rotate_delay 458 global rotate_delay 459 459 $_dispatcher event -after $rotate_delay !rotate 460 460 } … … 555 555 continue 556 556 } 557 if {[info exists _obj2ovride($dataobj-raise)] && 557 if {[info exists _obj2ovride($dataobj-raise)] && 558 558 $_obj2ovride($dataobj-raise)} { 559 559 set dlist [linsert $dlist 0 $dataobj] … … 583 583 } 584 584 return $dlist 585 } 585 } 586 586 -image { 587 587 if {[llength $args] != 2} { … … 819 819 #set w [image width $_image(plot)] 820 820 #set h [image height $_image(plot)] 821 #puts stderr "$date: received image ${w}x${h} image" 821 #puts stderr "$date: received image ${w}x${h} image" 822 822 if { $_start > 0 } { 823 823 set finish [clock clicks -milliseconds] … … 890 890 # Turn on buffering of commands to the server. We don't want to 891 891 # be preempted by a server disconnect/reconnect (which automatically 892 # generates a new call to Rebuild). 892 # generates a new call to Rebuild). 893 893 StartBufferingCommands 894 894 … … 960 960 961 961 if { $_first != "" } { 962 963 964 962 $itk_component(field) choices delete 0 end 963 $itk_component(fieldmenu) delete 0 end 964 array unset _fields 965 965 set _curFldName "" 966 966 foreach cname [$_first components] { … … 990 990 InitSettings -isolinesvisible -surfacevisible -outline 991 991 if { $_reset } { 992 992 # These are settings that rely on a dataset being loaded. 993 993 InitSettings \ 994 994 -surfacelighting \ 995 995 -field \ 996 996 -surfaceedges -surfacelighting -surfaceopacity \ 997 997 -surfacewireframe \ 998 998 -numcontours 999 999 1000 1000 Zoom reset 1001 1001 foreach axis { x y z } { 1002 1002 # Another problem fixed by a <view>. We looking into a data 1003 1003 # object for the name of the axes. This should be global to 1004 1004 # the viewer itself. 1005 1006 1005 set label [$_first hints ${axis}label] 1006 if { $label == "" } { 1007 1007 set label [string toupper $axis] 1008 1009 1010 1008 } 1009 # May be a space in the axis label. 1010 SendCmd [list axis name $axis $label] 1011 1011 } 1012 1012 if { [array size _fields] < 2 } { … … 1032 1032 itcl::body Rappture::VtkSurfaceViewer::CurrentDatasets {args} { 1033 1033 set flag [lindex $args 0] 1034 switch -- $flag { 1034 switch -- $flag { 1035 1035 "-all" { 1036 1036 if { [llength $args] > 1 } { … … 1051 1051 set dlist [get -visible] 1052 1052 } 1053 } 1053 } 1054 1054 default { 1055 1055 set dlist $args … … 1170 1170 foreach tag [CurrentDatasets -visible] { 1171 1171 SendCmd "dataset getscalar pixel $x $y $tag" 1172 } 1172 } 1173 1173 } 1174 1174 … … 1274 1274 "-background" { 1275 1275 set bgcolor [$itk_component(background) value] 1276 1277 1278 1279 "grey""black"1280 1276 array set fgcolors { 1277 "black" "white" 1278 "white" "black" 1279 "grey" "black" 1280 } 1281 1281 configure -plotbackground $bgcolor \ 1282 1283 1284 1282 -plotforeground $fgcolors($bgcolor) 1283 $itk_component(view) delete "legend" 1284 DrawLegend 1285 1285 } 1286 1286 "-colormap" { … … 1289 1289 set color [$itk_component(colormap) value] 1290 1290 set _settings($what) $color 1291 1292 1293 1291 if { $color == "none" } { 1292 if { $_settings(-colormapvisible) } { 1293 SendCmd "contour2d colormode constant {}" 1294 1294 SendCmd "polydata colormode constant {}" 1295 1296 1297 1298 1299 1295 set _settings(-colormapvisible) 0 1296 } 1297 } else { 1298 if { !$_settings(-colormapvisible) } { 1299 #SendCmd "contour2d colormode $_colorMode $_curFldName" 1300 1300 SendCmd "polydata colormode $_colorMode $_curFldName" 1301 1302 1303 1301 set _settings(-colormapvisible) 1 1302 } 1303 SetCurrentColormap $color 1304 1304 if {$_settings(-colormapdiscrete)} { 1305 1305 set numColors [expr $_settings(-numcontours) + 1] 1306 1306 SendCmd "colormap res $numColors $color" 1307 1307 } 1308 1308 } 1309 1309 StopBufferingCommands 1310 1310 EventuallyRequestLegend 1311 1311 } 1312 1312 "-colormapdiscrete" { … … 1357 1357 "-isolinecolor" { 1358 1358 set color [$itk_component(isolineColor) value] 1359 1359 set _settings($what) $color 1360 1360 SendCmd "contour2d linecolor [Color2RGB $color]" 1361 1361 DrawLegend 1362 1362 } 1363 1363 "-isolinesvisible" { 1364 1364 set bool $_settings($what) 1365 1366 1365 SendCmd "contour2d visible $bool" 1366 DrawLegend 1367 1367 } 1368 1368 "-legendvisible" { 1369 1369 if { !$_settings($what) } { 1370 1370 $itk_component(view) delete legend 1371 1372 1371 } 1372 DrawLegend 1373 1373 } 1374 1374 "-numcontours" { … … 1388 1388 "-outline" { 1389 1389 set bool $_settings($what) 1390 1390 SendCmd "outline visible $bool" 1391 1391 } 1392 1392 "-surfaceedges" { 1393 1393 set bool $_settings($what) 1394 1394 SendCmd "polydata edges $bool" 1395 1395 } 1396 1396 "-surfacelighting" { 1397 1397 set bool $_settings($what) 1398 1398 SendCmd "polydata lighting $bool" 1399 1399 } 1400 1400 "-surfaceopacity" { 1401 1401 set val $_settings($what) 1402 1402 set sval [expr { 0.01 * double($val) }] 1403 1403 SendCmd "polydata opacity $sval" 1404 1404 } 1405 1405 "-surfacevisible" { 1406 1406 set bool $_settings($what) 1407 1407 SendCmd "polydata visible $bool" 1408 1408 if { $bool } { 1409 1409 Rappture::Tooltip::for $itk_component(surface) \ … … 1413 1413 "Show the surface" 1414 1414 } 1415 1415 DrawLegend 1416 1416 } 1417 1417 "-surfacewireframe" { 1418 1418 set bool $_settings($what) 1419 1419 SendCmd "polydata wireframe $bool" 1420 1420 } 1421 1421 "-xgrid" - "-ygrid" - "-zgrid" { … … 1434 1434 # 1435 1435 # Request a new legend from the server. The size of the legend 1436 # is determined from the height of the canvas. 1436 # is determined from the height of the canvas. 1437 1437 # 1438 1438 # This should be called when 1439 # 1440 # 1441 # 1442 # 1443 # 1439 # 1. A new current colormap is set. 1440 # 2. Window is resized. 1441 # 3. The limits of the data have changed. (Just need a redraw). 1442 # 4. Number of isolines have changed. (Just need a redraw). 1443 # 5. Legend becomes visible (Just need a redraw). 1444 1444 # 1445 1445 itcl::body Rappture::VtkSurfaceViewer::RequestLegend {} { … … 1457 1457 } 1458 1458 if { [string match "component*" $fname] } { 1459 1459 set title "" 1460 1460 } else { 1461 1462 1463 1464 1465 1466 1467 1468 1461 if { [info exists _fields($fname)] } { 1462 foreach { title units } $_fields($fname) break 1463 if { $units != "" } { 1464 set title [format "%s (%s)" $title $units] 1465 } 1466 } else { 1467 set title $fname 1468 } 1469 1469 } 1470 1470 # If there's a title too, subtract one more line 1471 1471 if { $title != "" } { 1472 incr h -$lineht 1472 incr h -$lineht 1473 1473 } 1474 1474 # Set the legend on the first heightmap dataset. 1475 1475 if { $_currentColormap != "" } { 1476 1477 1476 set cmap $_currentColormap 1477 SendCmdNoWait "legend $cmap scalar $_curFldName {} $w $h 0" 1478 1478 } 1479 1479 } … … 1495 1495 if { [isconnected] } { 1496 1496 set rgb [Color2RGB $itk_option(-plotforeground)] 1497 1497 SendCmd "axis color all $rgb" 1498 1498 SendCmd "outline color $rgb" 1499 1499 } … … 1558 1558 -font "Arial 9" 1559 1559 1560 label $inner.linecolor_l -text "Isolines" -font "Arial 9" 1560 label $inner.linecolor_l -text "Isolines" -font "Arial 9" 1561 1561 itk_component add isolineColor { 1562 1562 Rappture::Combobox $inner.linecolor -width 10 -editable 0 … … 1572 1572 "red" "red" \ 1573 1573 "white" "white" \ 1574 "none""none"1574 "none" "none" 1575 1575 1576 1576 $itk_component(isolineColor) value "white" 1577 1577 bind $inner.linecolor <<Value>> \ 1578 1579 1580 label $inner.background_l -text "Background" -font "Arial 9" 1578 [itcl::code $this AdjustSetting -isolinecolor] 1579 1580 label $inner.background_l -text "Background" -font "Arial 9" 1581 1581 itk_component add background { 1582 1582 Rappture::Combobox $inner.background -width 10 -editable 0 … … 1585 1585 "black" "black" \ 1586 1586 "white" "white" \ 1587 "grey" "grey" 1587 "grey" "grey" 1588 1588 1589 1589 $itk_component(background) value $_settings(-background) … … 1599 1599 1600 1600 itk_component add field_l { 1601 label $inner.field_l -text "Field" -font "Arial 9" 1601 label $inner.field_l -text "Field" -font "Arial 9" 1602 1602 } { 1603 1603 ignore -font … … 1609 1609 [itcl::code $this AdjustSetting -field] 1610 1610 1611 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1611 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1612 1612 itk_component add colormap { 1613 1613 Rappture::Combobox $inner.colormap -width 10 -editable 0 … … 1635 1635 2,0 $inner.linecolor_l -anchor w -pady 2 \ 1636 1636 2,1 $inner.linecolor -anchor w -pady 2 -fill x \ 1637 1638 1637 3,0 $inner.background_l -anchor w -pady 2 \ 1638 3,1 $inner.background -anchor w -pady 2 -fill x \ 1639 1639 4,0 $inner.numcontours_l -anchor w -pady 2 \ 1640 1640 4,1 $inner.numcontours -anchor w -pady 2 \ … … 1674 1674 -command [itcl::code $this AdjustSetting -axislabels] \ 1675 1675 -font "Arial 9" 1676 label $inner.grid_l -text "Grid" -font "Arial 9" 1676 label $inner.grid_l -text "Grid" -font "Arial 9" 1677 1677 checkbutton $inner.xgrid \ 1678 1678 -text "X" \ … … 1696 1696 -font "Arial 9" 1697 1697 1698 label $inner.mode_l -text "Mode" -font "Arial 9" 1698 label $inner.mode_l -text "Mode" -font "Arial 9" 1699 1699 1700 1700 itk_component add axisMode { … … 1705 1705 "closest_triad" "closest" \ 1706 1706 "furthest_triad" "farthest" \ 1707 "outer_edges" "outer" 1707 "outer_edges" "outer" 1708 1708 $itk_component(axisMode) value $_settings(-axismode) 1709 1709 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] … … 1777 1777 1778 1778 # 1779 # camera -- 1779 # camera -- 1780 1780 # 1781 1781 itcl::body Rappture::VtkSurfaceViewer::camera {option args} { 1782 switch -- $option { 1782 switch -- $option { 1783 1783 "show" { 1784 1784 puts [array get _view] … … 1828 1828 1829 1829 itcl::body Rappture::VtkSurfaceViewer::GetImage { args } { 1830 if { [image width $_image(download)] > 0 && 1830 if { [image width $_image(download)] > 0 && 1831 1831 [image height $_image(download)] > 0 } { 1832 1832 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 1841 1841 -title "[Rappture::filexfer::label downloadWord] as..." 1842 1842 set inner [$popup component inner] 1843 label $inner.summary -text "" -anchor w 1843 label $inner.summary -text "" -anchor w 1844 1844 radiobutton $inner.vtk_button -text "VTK data file" \ 1845 1845 -variable [itcl::scope _downloadPopup(format)] \ 1846 1846 -font "Arial 9 " \ 1847 -value vtk 1847 -value vtk 1848 1848 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 1849 1849 radiobutton $inner.image_button -text "Image File" \ 1850 1850 -variable [itcl::scope _downloadPopup(format)] \ 1851 1851 -font "Arial 9 " \ 1852 -value image 1852 -value image 1853 1853 Rappture::Tooltip::for $inner.image_button \ 1854 1854 "Save as digital image." … … 1871 1871 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 1872 1872 4,1 $inner.cancel -width .9i -fill y \ 1873 4,0 $inner.ok -padx 2 -width .9i -fill y 1873 4,0 $inner.ok -padx 2 -width .9i -fill y 1874 1874 blt::table configure $inner r3 -height 4 1875 1875 blt::table configure $inner r4 -pady 4 … … 1932 1932 set _settings(-isolinesvisible) $style(-isolinesvisible) 1933 1933 set _settings(-surfacevisible) $style(-surfacevisible) 1934 1934 1935 1935 SendCmd "outline add $tag" 1936 1936 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" … … 1948 1948 SendCmd "polydata opacity $style(-opacity) $tag" 1949 1949 set _settings(-surfaceopacity) [expr $style(-opacity) * 100.0] 1950 SetCurrentColormap $style(-color) 1950 SetCurrentColormap $style(-color) 1951 1951 SendCmd "polydata wireframe $style(-wireframe) $tag" 1952 1952 set _settings(-surfacewireframe) $style(-wireframe) … … 2003 2003 set font "Arial 8" 2004 2004 set lineht [font metrics $font -linespace] 2005 2005 2006 2006 set ih [image height $_image(legend)] 2007 2007 set iy [expr $y - ($lineht + 2)] 2008 2008 2009 2009 if { [string match "component*" $fname] } { 2010 2010 set title "" 2011 2011 } else { 2012 2013 2014 2015 2016 2017 2018 2019 2012 if { [info exists _fields($fname)] } { 2013 foreach { title units } $_fields($fname) break 2014 if { $units != "" } { 2015 set title [format "%s (%s)" $title $units] 2016 } 2017 } else { 2018 set title $fname 2019 } 2020 2020 } 2021 2021 # If there's a legend title, increase the offset by the line height. … … 2031 2031 } 2032 2032 set color [eval format "\#%02x%02x%02x" $pixel] 2033 $_image(swatch) put black -to 0 0 23 23 2034 $_image(swatch) put $color -to 1 1 22 22 2033 $_image(swatch) put black -to 0 0 23 23 2034 $_image(swatch) put $color -to 1 1 22 22 2035 2035 .rappturetooltip configure -icon $_image(swatch) 2036 2036 … … 2043 2043 set value 0.0 2044 2044 } 2045 set tx [expr $x + 15] 2045 set tx [expr $x + 15] 2046 2046 set ty [expr $y - 5] 2047 2047 if { [info exists _isolines($y)] } { … … 2050 2050 Rappture::Tooltip::text $c [format "$title %g" $value] 2051 2051 } 2052 Rappture::Tooltip::tooltip show $c +$tx,+$ty 2053 } 2054 2055 # 2056 # ReceiveLegend -- 2057 # 2058 # 2059 # 2060 # 2052 Rappture::Tooltip::tooltip show $c +$tx,+$ty 2053 } 2054 2055 # 2056 # ReceiveLegend -- 2057 # 2058 # Invoked automatically whenever the "legend" command comes in from 2059 # the rendering server. Indicates that binary image data with the 2060 # specified <size> will follow. 2061 2061 # 2062 2062 itcl::body Rappture::VtkSurfaceViewer::ReceiveLegend { colormap title min max size } { 2063 2063 #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size" 2064 2064 set _title $title 2065 regsub {\(mag\)} $title "" _title 2065 regsub {\(mag\)} $title "" _title 2066 2066 if { [IsConnected] } { 2067 2067 set bytes [ReceiveBytes $size] … … 2072 2072 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2073 2073 if { [catch {DrawLegend} errs] != 0 } { 2074 2075 2074 global errorInfo 2075 puts stderr "errs=$errs errorInfo=$errorInfo" 2076 2076 } 2077 2077 } … … 2092 2092 2093 2093 if { [string match "component*" $fname] } { 2094 2094 set title "" 2095 2095 } else { 2096 2097 2098 2099 2100 2101 2102 2103 2096 if { [info exists _fields($fname)] } { 2097 foreach { title units } $_fields($fname) break 2098 if { $units != "" } { 2099 set title [format "%s (%s)" $title $units] 2100 } 2101 } else { 2102 set title $fname 2103 } 2104 2104 } 2105 2105 set x [expr $w - 2] 2106 2106 if { !$_settings(-legendvisible) } { 2107 2108 2109 } 2107 $c delete legend 2108 return 2109 } 2110 2110 if { [$c find withtag "legend"] == "" } { 2111 set y 2 2112 2111 set y 2 2112 # If there's a legend title, create a text item for the title. 2113 2113 $c create text $x $y \ 2114 2115 2116 -font $font 2114 -anchor ne \ 2115 -fill $itk_option(-plotforeground) -tags "title legend" \ 2116 -font $font 2117 2117 if { $title != "" } { 2118 2118 incr y $lineht 2119 2119 } 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2120 $c create text $x $y \ 2121 -anchor ne \ 2122 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2123 -font $font 2124 incr y $lineht 2125 $c create image $x $y \ 2126 -anchor ne \ 2127 -image $_image(legend) -tags "colormap legend" 2128 $c create rectangle $x $y 1 1 \ 2129 -fill "" -outline "" -tags "sensor legend" 2130 $c create text $x [expr {$h-2}] \ 2131 -anchor se \ 2132 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2133 -font $font 2134 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2135 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2136 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2137 2137 } 2138 2138 $c delete isoline … … 2153 2153 } 2154 2154 set tags "isoline legend" 2155 2156 2157 2158 2155 set offset [expr 2 + $lineht] 2156 if { $title != "" } { 2157 incr offset $lineht 2158 } 2159 2159 foreach value $_contourList { 2160 2160 set norm [expr 1.0 - (($value - $vmin) / $range)] … … 2175 2175 if { [info exists _limits($_curFldName)] } { 2176 2176 foreach { vmin vmax } $_limits($_curFldName) break 2177 2178 2177 $c itemconfigure vmin -text [format %g $vmin] 2178 $c itemconfigure vmax -text [format %g $vmax] 2179 2179 } 2180 2180 set y 2 … … 2182 2182 if { $title != "" } { 2183 2183 $c itemconfigure title -text $title 2184 2185 2184 $c coords title $x $y 2185 incr y $lineht 2186 2186 $c raise title 2187 2187 } … … 2206 2206 # ---------------------------------------------------------------------- 2207 2207 itcl::body Rappture::VtkSurfaceViewer::Combo {option} { 2208 set c $itk_component(view) 2208 set c $itk_component(view) 2209 2209 switch -- $option { 2210 2210 post { … … 2221 2221 } 2222 2222 deactivate { 2223 $c itemconfigure title -fill $itk_option(-plotforeground) 2223 $c itemconfigure title -fill $itk_option(-plotforeground) 2224 2224 } 2225 2225 invoke { … … 2239 2239 # Keep track of the colormaps that we build. 2240 2240 if { ![info exists _colormaps($name)] } { 2241 BuildColormap $name 2241 BuildColormap $name 2242 2242 set _colormaps($name) 1 2243 2243 } … … 2261 2261 } 2262 2262 2263 itcl::body Rappture::VtkSurfaceViewer::SetOrientation { side } { 2263 itcl::body Rappture::VtkSurfaceViewer::SetOrientation { side } { 2264 2264 array set positions { 2265 2265 front "1 0 0 0" … … 2282 2282 } 2283 2283 2284 itcl::body Rappture::VtkSurfaceViewer::UpdateContourList {} { 2284 itcl::body Rappture::VtkSurfaceViewer::UpdateContourList {} { 2285 2285 if { ![info exists _limits($_curFldName)] } { 2286 2286 return -
trunk/gui/scripts/vtkviewer.tcl
r4773 r5006 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: vtkviewer - Vtk drawing object viewer … … 58 58 public method isconnected {} 59 59 public method limits { dataobj } 60 public method parameters {title args} { 61 # do nothing 60 public method parameters {title args} { 61 # do nothing 62 62 } 63 63 public method scale {args} … … 69 69 private method BuildColormap { name styles } 70 70 private method BuildCutawayTab {} 71 private method BuildDownloadPopup { widget command } 71 private method BuildDownloadPopup { widget command } 72 72 private method BuildGlyphsTab {} 73 73 private method BuildMoleculeTab {} … … 80 80 private method DoRotate {} 81 81 private method DrawLegend {} 82 private method EnterLegend { x y } 83 private method EventuallyResize { w h } 84 private method EventuallyRotate { q } 85 private method EventuallySetAtomScale { args } 86 private method EventuallySetBondScale { args } 87 private method EventuallySetGlyphsOpacity { args } 88 private method EventuallySetMoleculeOpacity { args } 89 private method EventuallySetMoleculeQuality { args } 90 private method EventuallySetPolydataOpacity { args } 91 private method GetImage { args } 92 private method GetVtkData { args } 82 private method EnterLegend { x y } 83 private method EventuallyResize { w h } 84 private method EventuallyRotate { q } 85 private method EventuallySetAtomScale { args } 86 private method EventuallySetBondScale { args } 87 private method EventuallySetGlyphsOpacity { args } 88 private method EventuallySetMoleculeOpacity { args } 89 private method EventuallySetMoleculeQuality { args } 90 private method EventuallySetPolydataOpacity { args } 91 private method GetImage { args } 92 private method GetVtkData { args } 93 93 private method InitSettings { args } 94 private method IsValidObject { dataobj } 94 private method IsValidObject { dataobj } 95 95 private method LeaveLegend {} 96 private method MotionLegend { x y } 96 private method MotionLegend { x y } 97 97 private method Pan {option x y} 98 98 private method PanCamera {} 99 99 private method Pick {x y} 100 private method QuaternionToView { q } { 100 private method QuaternionToView { q } { 101 101 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 102 102 } … … 114 114 private method SetMoleculeOpacity {} 115 115 private method SetMoleculeQuality {} 116 private method SetObjectStyle { dataobj comp } 116 private method SetObjectStyle { dataobj comp } 117 117 private method SetOpacity { dataset } 118 118 private method SetOrientation { side } 119 119 private method SetPolydataOpacity {} 120 private method Slice {option args} 121 private method ViewToQuaternion {} { 120 private method Slice {option args} 121 private method ViewToQuaternion {} { 122 122 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 123 123 } … … 125 125 126 126 private variable _arcball "" 127 private variable _dlist ""; 127 private variable _dlist ""; # list of data objects 128 128 private variable _obj2datasets 129 private variable _obj2ovride; 130 private variable _datasets; # contains all the dataobj-component131 132 private variable _colormaps; 133 134 private variable _dataset2style; 135 private variable _style2datasets; # maps tf back to list of136 129 private variable _obj2ovride; # maps dataobj => style override 130 private variable _datasets; # contains all the dataobj-component 131 # datasets in the server 132 private variable _colormaps; # contains all the colormaps 133 # in the server. 134 private variable _dataset2style; # maps dataobj-component to transfunc 135 private variable _style2datasets; # maps tf back to list of 136 # dataobj-components using the tf. 137 137 private variable _click; # info used for rotate operations 138 138 private variable _limits; # autoscale min/max for all axes … … 319 319 320 320 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 321 set _map(cwidth) -1 322 set _map(cheight) -1 321 set _map(cwidth) -1 322 set _map(cheight) -1 323 323 set _map(zoom) 1.0 324 324 set _map(original) "" … … 373 373 set _image(legend) [image create photo] 374 374 itk_component add legend { 375 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 375 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 376 376 } { 377 377 usual … … 380 380 } 381 381 382 # Hack around the Tk panewindow. The problem is that the requested 382 # Hack around the Tk panewindow. The problem is that the requested 383 383 # size of the 3d view isn't set until an image is retrieved from 384 384 # the server. So the panewindow uses the tiny size. … … 386 386 pack forget $itk_component(view) 387 387 blt::table $itk_component(plotarea) \ 388 0,0 $itk_component(view) -fill both -reqwidth $w 388 0,0 $itk_component(view) -fill both -reqwidth $w 389 389 blt::table configure $itk_component(plotarea) c1 -resize none 390 390 … … 473 473 474 474 itcl::body Rappture::VtkViewer::DoRotate {} { 475 SendCmd "camera orient [ViewToQuaternion]" 475 SendCmd "camera orient [ViewToQuaternion]" 476 476 set _rotatePending 0 477 477 } … … 674 674 continue 675 675 } 676 if {[info exists _obj2ovride($dataobj-raise)] && 676 if {[info exists _obj2ovride($dataobj-raise)] && 677 677 $_obj2ovride($dataobj-raise)} { 678 678 set dlist [linsert $dlist 0 $dataobj] … … 702 702 } 703 703 return $dlist 704 } 704 } 705 705 -image { 706 706 if {[llength $args] != 2} { … … 925 925 # disconnected -- no more data sitting on server 926 926 set _outbuf "" 927 array unset _datasets 928 array unset _data 929 array unset _colormaps 927 array unset _datasets 928 array unset _data 929 array unset _colormaps 930 930 global readyForNextFrame 931 931 set readyForNextFrame 1 … … 1029 1029 # Turn on buffering of commands to the server. We don't want to 1030 1030 # be preempted by a server disconnect/reconnect (which automatically 1031 # generates a new call to Rebuild). 1031 # generates a new call to Rebuild). 1032 1032 StartBufferingCommands 1033 1033 … … 1123 1123 if { $_haveGlyphs } { 1124 1124 InitSettings glyphs-edges glyphs-lighting glyphs-opacity \ 1125 glyphs-visible glyphs-wireframe 1125 glyphs-visible glyphs-wireframe 1126 1126 } 1127 1127 if { $_havePolydata } { 1128 1128 InitSettings polydata-edges polydata-lighting polydata-opacity \ 1129 polydata-visible polydata-wireframe 1129 polydata-visible polydata-wireframe 1130 1130 } 1131 1131 if { $_haveMolecules } { … … 1147 1147 1148 1148 if { $_haveMolecules } { 1149 #InitSettings molecule-representation 1149 #InitSettings molecule-representation 1150 1150 } 1151 1151 set _reset 0 … … 1170 1170 itcl::body Rappture::VtkViewer::CurrentDatasets {args} { 1171 1171 set flag [lindex $args 0] 1172 switch -- $flag { 1172 switch -- $flag { 1173 1173 "-all" { 1174 1174 if { [llength $args] > 1 } { … … 1189 1189 set dlist [get -visible] 1190 1190 } 1191 } 1191 } 1192 1192 default { 1193 1193 set dlist $args … … 1308 1308 foreach tag [CurrentDatasets -visible] { 1309 1309 SendCmd "dataset getscalar pixel $x $y $tag" 1310 } 1310 } 1311 1311 } 1312 1312 … … 1754 1754 } 1755 1755 } 1756 "axis-xposition" - "axis-yposition" - "axis-zposition" - 1756 "axis-xposition" - "axis-yposition" - "axis-zposition" - 1757 1757 "axis-xdirection" - "axis-ydirection" - "axis-zdirection" { 1758 1758 set axis [string range $what 5 5] … … 1912 1912 set f [open "$tmpfile" "w"] 1913 1913 fconfigure $f -translation binary -encoding binary 1914 puts $f $data 1914 puts $f $data 1915 1915 close $f 1916 1916 set reader [vtkDataSetReader $tag-xvtkDataSetReader] … … 2006 2006 -variable [itcl::scope _settings(glyphs-visible)] \ 2007 2007 -command [itcl::code $this AdjustSetting glyphs-visible] \ 2008 -font "Arial 9" -anchor w 2008 -font "Arial 9" -anchor w 2009 2009 2010 2010 checkbutton $inner.outline \ … … 2012 2012 -variable [itcl::scope _settings(glyphs-outline)] \ 2013 2013 -command [itcl::code $this AdjustSetting glyphs-outline] \ 2014 -font "Arial 9" -anchor w 2014 -font "Arial 9" -anchor w 2015 2015 2016 2016 checkbutton $inner.wireframe \ … … 2018 2018 -variable [itcl::scope _settings(glyphs-wireframe)] \ 2019 2019 -command [itcl::code $this AdjustSetting glyphs-wireframe] \ 2020 -font "Arial 9" -anchor w 2020 -font "Arial 9" -anchor w 2021 2021 2022 2022 checkbutton $inner.lighting \ … … 2032 2032 -font "Arial 9" -anchor w 2033 2033 2034 label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w 2034 label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w 2035 2035 itk_component add glyphspalette { 2036 2036 Rappture::Combobox $inner.palette -width 10 -editable no … … 2041 2041 [itcl::code $this AdjustSetting glyphs-palette] 2042 2042 2043 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 2043 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 2044 2044 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2045 2045 -variable [itcl::scope _settings(glyphs-opacity)] \ … … 2058 2058 5,1 $inner.opacity -fill x -pady 2 \ 2059 2059 6,0 $inner.palette_l -anchor w -pady 2 \ 2060 6,1 $inner.palette -fill x -pady 2 2060 6,1 $inner.palette -fill x -pady 2 2061 2061 2062 2062 blt::table configure $inner r* c* -resize none … … 2078 2078 -variable [itcl::scope _settings(polydata-visible)] \ 2079 2079 -command [itcl::code $this AdjustSetting polydata-visible] \ 2080 -font "Arial 9" -anchor w 2080 -font "Arial 9" -anchor w 2081 2081 2082 2082 checkbutton $inner.outline \ … … 2084 2084 -variable [itcl::scope _settings(polydata-outline)] \ 2085 2085 -command [itcl::code $this AdjustSetting polydata-outline] \ 2086 -font "Arial 9" -anchor w 2086 -font "Arial 9" -anchor w 2087 2087 2088 2088 checkbutton $inner.wireframe \ … … 2090 2090 -variable [itcl::scope _settings(polydata-wireframe)] \ 2091 2091 -command [itcl::code $this AdjustSetting polydata-wireframe] \ 2092 -font "Arial 9" -anchor w 2092 -font "Arial 9" -anchor w 2093 2093 2094 2094 checkbutton $inner.lighting \ … … 2104 2104 -font "Arial 9" -anchor w 2105 2105 2106 label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w 2106 label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w 2107 2107 itk_component add meshpalette { 2108 2108 Rappture::Combobox $inner.palette -width 10 -editable no … … 2113 2113 [itcl::code $this AdjustSetting polydata-palette] 2114 2114 2115 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 2115 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 2116 2116 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2117 2117 -variable [itcl::scope _settings(polydata-opacity)] \ … … 2130 2130 5,1 $inner.opacity -fill x -pady 2 \ 2131 2131 6,0 $inner.palette_l -anchor w -pady 2 \ 2132 6,1 $inner.palette -fill x -pady 2 2132 6,1 $inner.palette -fill x -pady 2 2133 2133 2134 2134 blt::table configure $inner r* c* -resize none … … 2157 2157 -command [itcl::code $this AdjustSetting axis-labels] \ 2158 2158 -font "Arial 9" 2159 label $inner.grid_l -text "Grid" -font "Arial 9" 2159 label $inner.grid_l -text "Grid" -font "Arial 9" 2160 2160 checkbutton $inner.xgrid \ 2161 2161 -text "X" \ … … 2179 2179 -font "Arial 9" 2180 2180 2181 label $inner.mode_l -text "Mode" -font "Arial 9" 2181 label $inner.mode_l -text "Mode" -font "Arial 9" 2182 2182 2183 2183 itk_component add axismode { … … 2188 2188 "closest_triad" "closest" \ 2189 2189 "furthest_triad" "farthest" \ 2190 "outer_edges" "outer" 2190 "outer_edges" "outer" 2191 2191 $itk_component(axismode) value "static" 2192 2192 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode] … … 2262 2262 2263 2263 set fg [option get $itk_component(hull) font Font] 2264 2264 2265 2265 set inner [$itk_component(main) insert end \ 2266 2266 -title "Cutaway Along Axis" \ 2267 -icon [Rappture::icon cutbutton]] 2267 -icon [Rappture::icon cutbutton]] 2268 2268 2269 2269 $inner configure -borderwidth 4 … … 2305 2305 -variable [itcl::scope _axis(xdirection)] 2306 2306 } 2307 set _axis(xdirection) -1 2307 set _axis(xdirection) -1 2308 2308 Rappture::Tooltip::for $itk_component(xDirButton) \ 2309 2309 "Toggle the direction of the X-axis cutaway" … … 2347 2347 Rappture::Tooltip::for $itk_component(yDirButton) \ 2348 2348 "Toggle the direction of the Y-axis cutaway" 2349 set _axis(ydirection) -1 2349 set _axis(ydirection) -1 2350 2350 2351 2351 # Z-value slicer... … … 2384 2384 -variable [itcl::scope _axis(zdirection)] 2385 2385 } 2386 set _axis(zdirection) -1 2386 set _axis(zdirection) -1 2387 2387 Rappture::Tooltip::for $itk_component(zDirButton) \ 2388 2388 "Toggle the direction of the Z-axis cutaway" … … 2452 2452 $inner.rep choices insert end \ 2453 2453 "ballandstick" "Ball and Stick" \ 2454 "spheres" 2455 "sticks" "Sticks"\2456 "rods" 2457 "wireframe" "Wireframe" 2458 "spacefilling" "Space Filling" 2454 "spheres" "Spheres" \ 2455 "sticks" "Sticks" \ 2456 "rods" "Rods" \ 2457 "wireframe" "Wireframe" \ 2458 "spacefilling" "Space Filling" 2459 2459 2460 2460 bind $inner.rep <<Value>> \ … … 2469 2469 } 2470 2470 $inner.rscale choices insert end \ 2471 "atomic" 2472 "covalent" 2473 "van_der_waals" "VDW"\2474 "none" 2471 "atomic" "Atomic" \ 2472 "covalent" "Covalent" \ 2473 "van_der_waals" "VDW" \ 2474 "none" "Constant" 2475 2475 2476 2476 bind $inner.rscale <<Value>> \ … … 2478 2478 $inner.rscale value "Covalent" 2479 2479 2480 label $inner.palette_l -text "Palette" -font "Arial 9" 2480 label $inner.palette_l -text "Palette" -font "Arial 9" 2481 2481 itk_component add moleculepalette { 2482 2482 Rappture::Combobox $inner.palette -width 10 -editable no … … 2543 2543 16,0 $inner.quality_l -anchor w -pady {3 0} \ 2544 2544 17,0 $inner.quality -fill x -padx 2 2545 2545 2546 2546 blt::table configure $inner r* -resize none 2547 2547 blt::table configure $inner r18 -resize expand … … 2549 2549 2550 2550 # 2551 # camera -- 2551 # camera -- 2552 2552 # 2553 2553 itcl::body Rappture::VtkViewer::camera {option args} { 2554 switch -- $option { 2554 switch -- $option { 2555 2555 "show" { 2556 2556 puts [array get _view] … … 2600 2600 2601 2601 itcl::body Rappture::VtkViewer::GetImage { args } { 2602 if { [image width $_image(download)] > 0 && 2602 if { [image width $_image(download)] > 0 && 2603 2603 [image height $_image(download)] > 0 } { 2604 2604 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 2613 2613 -title "[Rappture::filexfer::label downloadWord] as..." 2614 2614 set inner [$popup component inner] 2615 label $inner.summary -text "" -anchor w 2615 label $inner.summary -text "" -anchor w 2616 2616 radiobutton $inner.vtk_button -text "VTK data file" \ 2617 2617 -variable [itcl::scope _downloadPopup(format)] \ 2618 2618 -font "Helvetica 9 " \ 2619 -value vtk 2619 -value vtk 2620 2620 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 2621 2621 radiobutton $inner.image_button -text "Image File" \ 2622 2622 -variable [itcl::scope _downloadPopup(format)] \ 2623 -value image 2623 -value image 2624 2624 Rappture::Tooltip::for $inner.image_button \ 2625 2625 "Save as digital image." … … 2642 2642 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 2643 2643 4,1 $inner.cancel -width .9i -fill y \ 2644 4,0 $inner.ok -padx 2 -width .9i -fill y 2644 4,0 $inner.ok -padx 2 -width .9i -fill y 2645 2645 blt::table configure $inner r3 -height 4 2646 2646 blt::table configure $inner r4 -pady 4 … … 2919 2919 set font "Arial 8" 2920 2920 set lineht [font metrics $font -linespace] 2921 2921 2922 2922 if { $_settings(legend) } { 2923 2923 set x [expr $w - 2] … … 2984 2984 set font "Arial 8" 2985 2985 set lineht [font metrics $font -linespace] 2986 2986 2987 2987 set imgHeight [image height $_image(legend)] 2988 2988 set coords [$c coords colormap] … … 2998 2998 } 2999 2999 set color [eval format "\#%02x%02x%02x" $pixel] 3000 $_image(swatch) put black -to 0 0 23 23 3001 $_image(swatch) put $color -to 1 1 22 22 3000 $_image(swatch) put black -to 0 0 23 23 3001 $_image(swatch) put $color -to 1 1 22 22 3002 3002 .rappturetooltip configure -icon $_image(swatch) 3003 3003 … … 3005 3005 set t [expr 1.0 - (double($imgY) / double($imgHeight-1))] 3006 3006 set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)] 3007 set tipx [expr $x + 15] 3007 set tipx [expr $x + 15] 3008 3008 set tipy [expr $y - 5] 3009 3009 Rappture::Tooltip::text $c "$_title $value" 3010 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 3010 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy 3011 3011 } 3012 3012 … … 3041 3041 } 3042 3042 3043 itcl::body Rappture::VtkViewer::SetOrientation { side } { 3043 itcl::body Rappture::VtkViewer::SetOrientation { side } { 3044 3044 array set positions { 3045 3045 front "1 0 0 0" … … 3052 3052 foreach name { -qw -qx -qy -qz } value $positions($side) { 3053 3053 set _view($name) $value 3054 } 3054 } 3055 3055 set q [ViewToQuaternion] 3056 3056 $_arcball quaternion $q … … 3062 3062 } 3063 3063 3064 itcl::body Rappture::VtkViewer::SetOpacity { dataset } { 3064 itcl::body Rappture::VtkViewer::SetOpacity { dataset } { 3065 3065 foreach {dataobj comp} [split $dataset -] break 3066 3066 set type [$dataobj type $comp]
Note: See TracChangeset
for help on using the changeset viewer.