Changeset 5018 for branches/1.4/gui
- Timestamp:
- Feb 13, 2015 2:58:57 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4/gui/scripts/vtkisosurfaceviewer.tcl
r4969 r5018 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: vtkisosurfaceviewer - Vtk 3D contour 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 } 69 69 private method BuildCutplaneTab {} 70 private method BuildDownloadPopup { widget command } 70 private method BuildDownloadPopup { widget command } 71 71 private method BuildIsosurfaceTab {} 72 72 private method Combo { option } … … 78 78 private method DoRotate {} 79 79 private method DrawLegend {} 80 private method EnterLegend { x y } 81 private method EventuallyChangeContourLevels {} 82 private method EventuallyRequestLegend {} 83 private method EventuallyResize { w h } 84 private method EventuallyRotate { q } 85 private method EventuallySetCutplane { axis args } 80 private method EnterLegend { x y } 81 private method EventuallyChangeContourLevels {} 82 private method EventuallyRequestLegend {} 83 private method EventuallyResize { w h } 84 private method EventuallyRotate { q } 85 private method EventuallySetCutplane { axis args } 86 86 private method GenerateContourList {} 87 private method GetImage { args } 88 private method GetVtkData { args } 87 private method GetImage { args } 88 private method GetVtkData { args } 89 89 private method InitSettings { args } 90 private method IsValidObject { dataobj } 90 private method IsValidObject { dataobj } 91 91 private method LeaveLegend {} 92 private method MotionLegend { x y } 92 private method MotionLegend { x y } 93 93 private method Pan {option x y} 94 94 private method PanCamera {} 95 95 private method Pick {x y} 96 private method QuaternionToView { q } { 96 private method QuaternionToView { q } { 97 97 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 98 98 } … … 109 109 private method SetOrientation { side } 110 110 private method Slice {option args} 111 private method ViewToQuaternion {} { 111 private method ViewToQuaternion {} { 112 112 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 113 113 } … … 119 119 private variable _obj2datasets 120 120 private variable _obj2ovride ; # maps dataobj => style override 121 private variable _datasets ; # contains all the dataobj-component 121 private variable _datasets ; # contains all the dataobj-component 122 122 ; # datasets in the server 123 123 private variable _colormaps ; # contains all the colormaps … … 157 157 private variable _legendPending 0 158 158 private variable _field "" 159 private variable _colorMode "scalar"; 160 private variable _fieldNames {} 161 private variable _fields 159 private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar) 160 private variable _fieldNames {} 161 private variable _fields 162 162 private variable _curFldName "" 163 163 private variable _curFldLabel "" … … 294 294 itk_component add fieldmenu { 295 295 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 296 -tearoff 0 296 -tearoff 0 297 297 } { 298 298 usual … … 314 314 315 315 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 316 set _map(cwidth) -1 317 set _map(cheight) -1 316 set _map(cwidth) -1 317 set _map(cheight) -1 318 318 set _map(zoom) 1.0 319 319 set _map(original) "" … … 362 362 -offimage [Rappture::icon volume-off] \ 363 363 -variable [itcl::scope _settings(-isosurfacevisible)] \ 364 -command [itcl::code $this AdjustSetting -isosurfacevisible] 364 -command [itcl::code $this AdjustSetting -isosurfacevisible] 365 365 } 366 366 $itk_component(contour) select … … 374 374 -offimage [Rappture::icon cutbutton] \ 375 375 -variable [itcl::scope _settings(-cutplanesvisible)] \ 376 -command [itcl::code $this AdjustSetting -cutplanesvisible] 376 -command [itcl::code $this AdjustSetting -cutplanesvisible] 377 377 } 378 378 Rappture::Tooltip::for $itk_component(cutplane) \ … … 393 393 set _image(legend) [image create photo] 394 394 itk_component add legend { 395 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 395 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 396 396 } { 397 397 usual … … 400 400 } 401 401 402 # Hack around the Tk panewindow. The problem is that the requested 402 # Hack around the Tk panewindow. The problem is that the requested 403 403 # size of the 3d view isn't set until an image is retrieved from 404 404 # the server. So the panewindow uses the tiny size. … … 406 406 pack forget $itk_component(view) 407 407 blt::table $itk_component(plotarea) \ 408 0,0 $itk_component(view) -fill both -reqwidth $w 408 0,0 $itk_component(view) -fill both -reqwidth $w 409 409 blt::table configure $itk_component(plotarea) c1 -resize none 410 410 … … 501 501 502 502 itcl::body Rappture::VtkIsosurfaceViewer::DoRotate {} { 503 SendCmd "camera orient [ViewToQuaternion]" 503 SendCmd "camera orient [ViewToQuaternion]" 504 504 set _rotatePending 0 505 505 } … … 528 528 if { !$_rotatePending } { 529 529 set _rotatePending 1 530 global rotate_delay 530 global rotate_delay 531 531 $_dispatcher event -after $rotate_delay !rotate 532 532 } … … 545 545 if { !$_contourList(updatePending) } { 546 546 set _contourList(updatePending) 1 547 global rotate_delay 547 global rotate_delay 548 548 $_dispatcher event -after $rotate_delay !contours 549 549 } … … 644 644 continue 645 645 } 646 if {[info exists _obj2ovride($dataobj-raise)] && 646 if {[info exists _obj2ovride($dataobj-raise)] && 647 647 $_obj2ovride($dataobj-raise)} { 648 648 set dlist [linsert $dlist 0 $dataobj] … … 672 672 } 673 673 return $dlist 674 } 674 } 675 675 -image { 676 676 if {[llength $args] != 2} { … … 911 911 #set w [image width $_image(plot)] 912 912 #set h [image height $_image(plot)] 913 #puts stderr "$date: received image ${w}x${h} image" 913 #puts stderr "$date: received image ${w}x${h} image" 914 914 if { $_start > 0 } { 915 915 set finish [clock clicks -milliseconds] … … 982 982 # Turn on buffering of commands to the server. We don't want to 983 983 # be preempted by a server disconnect/reconnect (which automatically 984 # generates a new call to Rebuild). 984 # generates a new call to Rebuild). 985 985 StartBufferingCommands 986 986 … … 1044 1044 lappend _obj2datasets($dataobj) $tag 1045 1045 if { [info exists _obj2ovride($dataobj-raise)] } { 1046 1046 SendCmd "contour3d visible 1 $tag" 1047 1047 } 1048 1048 } … … 1051 1051 InitSettings -cutplanesvisible -isosurfacevisible -outline 1052 1052 if { $_reset } { 1053 1053 # These are settings that rely on a dataset being loaded. 1054 1054 InitSettings \ 1055 1055 -isosurfacelighting \ … … 1057 1057 -isosurfacevisible \ 1058 1058 -isosurfaceedges -isosurfacelighting -isosurfaceopacity \ 1059 1059 -isosurfacewireframe \ 1060 1060 -cutplanesvisible \ 1061 1062 1061 -xcutplaneposition -ycutplaneposition -zcutplaneposition \ 1062 -xcutplanevisible -ycutplanevisible -zcutplanevisible \ 1063 1063 -cutplanepreinterp -numcontours 1064 1064 1065 1065 Zoom reset 1066 1066 foreach axis { x y z } { 1067 1067 # Another problem fixed by a <view>. We looking into a data 1068 1068 # object for the name of the axes. This should be global to 1069 1069 # the viewer itself. 1070 1071 1070 set label [$_first hints ${axis}label] 1071 if { $label == "" } { 1072 1072 set label [string toupper $axis] 1073 1073 } 1074 1074 # May be a space in the axis label 1075 1075 SendCmd [list axis name $axis $label] 1076 1076 } 1077 1077 if { [array size _fields] < 2 } { … … 1100 1100 itcl::body Rappture::VtkIsosurfaceViewer::CurrentDatasets {args} { 1101 1101 set flag [lindex $args 0] 1102 switch -- $flag { 1102 switch -- $flag { 1103 1103 "-all" { 1104 1104 if { [llength $args] > 1 } { … … 1119 1119 set dlist [get -visible] 1120 1120 } 1121 } 1121 } 1122 1122 default { 1123 1123 set dlist $args … … 1238 1238 foreach tag [CurrentDatasets -visible] { 1239 1239 SendCmd "dataset getscalar pixel $x $y $tag" 1240 } 1240 } 1241 1241 } 1242 1242 … … 1342 1342 "-background" { 1343 1343 set bgcolor [$itk_component(background) value] 1344 1345 1346 1347 "grey""black"1348 1344 array set fgcolors { 1345 "black" "white" 1346 "white" "black" 1347 "grey" "black" 1348 } 1349 1349 configure -plotbackground $bgcolor \ 1350 1351 1352 1350 -plotforeground $fgcolors($bgcolor) 1351 $itk_component(view) delete "legend" 1352 DrawLegend 1353 1353 } 1354 1354 "-cutplaneedges" { … … 1370 1370 "-cutplanesvisible" { 1371 1371 set bool $_settings($what) 1372 1372 SendCmd "cutplane visible 0" 1373 1373 if { $bool } { 1374 1374 foreach tag [CurrentDatasets -visible] { … … 1393 1393 set color [$itk_component(colormap) value] 1394 1394 set _settings($what) $color 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1395 if { $color == "none" } { 1396 if { $_settings(-colormapvisible) } { 1397 SendCmd "contour3d colormode constant {}" 1398 set _settings(-colormapvisible) 0 1399 } 1400 } else { 1401 if { !$_settings(-colormapvisible) } { 1402 SendCmd "contour3d colormode $_colorMode $_curFldName" 1403 set _settings(-colormapvisible) 1 1404 } 1405 SetCurrentColormap $color 1406 } 1407 1407 StopBufferingCommands 1408 1408 EventuallyRequestLegend 1409 1409 } 1410 1410 "-field" { … … 1439 1439 "-isolinecolor" { 1440 1440 set color [$itk_component(isolineColor) value] 1441 1442 1441 set _settings($what) $color 1442 DrawLegend 1443 1443 } 1444 1444 "-isosurfaceedges" { 1445 1445 set bool $_settings($what) 1446 1446 SendCmd "contour3d edges $bool" 1447 1447 } 1448 1448 "-isosurfacelighting" { 1449 1449 set bool $_settings($what) 1450 1450 SendCmd "contour3d lighting $bool" 1451 1451 } 1452 1452 "-isosurfaceopacity" { 1453 1453 set _settings($what) [expr $_widget($what) * 0.01] 1454 1454 SendCmd "contour3d opacity $_settings($what)" 1455 1455 } 1456 1456 "-isosurfacevisible" { 1457 1457 set bool $_settings($what) 1458 1458 SendCmd "contour3d visible 0" 1459 1459 if { $bool } { 1460 1460 foreach tag [CurrentDatasets -visible] { … … 1472 1472 "-isosurfacewireframe" { 1473 1473 set bool $_settings($what) 1474 1474 SendCmd "contour3d wireframe $bool" 1475 1475 } 1476 1476 "-legendvisible" { 1477 1477 if { !$_settings($what) } { 1478 1478 $itk_component(view) delete legend 1479 1480 1479 } 1480 DrawLegend 1481 1481 } 1482 1482 "-numcontours" { … … 1497 1497 "-outline" { 1498 1498 set bool $_settings($what) 1499 1499 SendCmd "outline visible 0" 1500 1500 if { $bool } { 1501 1501 foreach tag [CurrentDatasets -visible] { … … 1514 1514 -troughcolor grey82 1515 1515 } 1516 1516 SendCmd "cutplane axis $axis $bool" 1517 1517 } 1518 1518 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" { … … 1537 1537 # 1538 1538 # Request a new legend from the server. The size of the legend 1539 # is determined from the height of the canvas. 1539 # is determined from the height of the canvas. 1540 1540 # 1541 1541 # This should be called when 1542 # 1543 # 1544 # 1545 # 1546 # 1542 # 1. A new current colormap is set. 1543 # 2. Window is resized. 1544 # 3. The limits of the data have changed. (Just need a redraw). 1545 # 4. Number of isolines have changed. (Just need a redraw). 1546 # 5. Legend becomes visible (Just need a redraw). 1547 1547 # 1548 1548 itcl::body Rappture::VtkIsosurfaceViewer::RequestLegend {} { … … 1560 1560 } 1561 1561 if { [string match "component*" $fname] } { 1562 1562 set title "" 1563 1563 } else { 1564 1565 1566 1567 1568 1569 1570 1571 1564 if { [info exists _fields($fname)] } { 1565 foreach { title units } $_fields($fname) break 1566 if { $units != "" } { 1567 set title [format "%s (%s)" $title $units] 1568 } 1569 } else { 1570 set title $fname 1571 } 1572 1572 } 1573 1573 # If there's a title too, subtract one more line 1574 1574 if { $title != "" } { 1575 incr h -$lineht 1575 incr h -$lineht 1576 1576 } 1577 1577 # Set the legend on the first heightmap dataset. 1578 1578 if { $_currentColormap != "" } { 1579 1580 1579 set cmap $_currentColormap 1580 SendCmdNoWait "legend $cmap scalar $_curFldName {} $w $h 0" 1581 1581 } 1582 1582 } … … 1598 1598 if { [isconnected] } { 1599 1599 set rgb [Color2RGB $itk_option(-plotforeground)] 1600 1600 SendCmd "axis color all $rgb" 1601 1601 SendCmd "outline color $rgb" 1602 1602 SendCmd "cutplane color $rgb" … … 1650 1650 -font "Arial 9" 1651 1651 1652 label $inner.linecolor_l -text "Isolines" -font "Arial 9" 1652 label $inner.linecolor_l -text "Isolines" -font "Arial 9" 1653 1653 itk_component add isolineColor { 1654 1654 Rappture::Combobox $inner.linecolor -width 10 -editable 0 … … 1664 1664 "red" "red" \ 1665 1665 "white" "white" \ 1666 "none""none"1666 "none" "none" 1667 1667 1668 1668 $itk_component(isolineColor) value "white" 1669 1669 bind $inner.linecolor <<Value>> \ 1670 1671 1672 label $inner.background_l -text "Background" -font "Arial 9" 1670 [itcl::code $this AdjustSetting -isolinecolor] 1671 1672 label $inner.background_l -text "Background" -font "Arial 9" 1673 1673 itk_component add background { 1674 1674 Rappture::Combobox $inner.background -width 10 -editable 0 … … 1677 1677 "black" "black" \ 1678 1678 "white" "white" \ 1679 "grey" "grey" 1679 "grey" "grey" 1680 1680 1681 1681 $itk_component(background) value $_settings(-background) … … 1692 1692 1693 1693 itk_component add field_l { 1694 label $inner.field_l -text "Field" -font "Arial 9" 1694 label $inner.field_l -text "Field" -font "Arial 9" 1695 1695 } { 1696 1696 ignore -font … … 1702 1702 [itcl::code $this AdjustSetting -field] 1703 1703 1704 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1704 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1705 1705 itk_component add colormap { 1706 1706 Rappture::Combobox $inner.colormap -width 10 -editable 0 … … 1728 1728 2,0 $inner.linecolor_l -anchor w -pady 2 \ 1729 1729 2,1 $inner.linecolor -anchor w -pady 2 -fill x \ 1730 1731 1730 3,0 $inner.background_l -anchor w -pady 2 \ 1731 3,1 $inner.background -anchor w -pady 2 -fill x \ 1732 1732 4,0 $inner.numcontours_l -anchor w -pady 2 \ 1733 1733 4,1 $inner.numcontours -anchor w -pady 2 \ … … 1765 1765 -command [itcl::code $this AdjustSetting -axislabels] \ 1766 1766 -font "Arial 9" 1767 label $inner.grid_l -text "Grid" -font "Arial 9" 1767 label $inner.grid_l -text "Grid" -font "Arial 9" 1768 1768 checkbutton $inner.xgrid \ 1769 1769 -text "X" \ … … 1787 1787 -font "Arial 9" 1788 1788 1789 label $inner.mode_l -text "Mode" -font "Arial 9" 1789 label $inner.mode_l -text "Mode" -font "Arial 9" 1790 1790 1791 1791 itk_component add axisMode { … … 1796 1796 "closest_triad" "closest" \ 1797 1797 "furthest_triad" "farthest" \ 1798 "outer_edges" "outer" 1798 "outer_edges" "outer" 1799 1799 $itk_component(axisMode) value $_settings(-axismode) 1800 1800 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] … … 1871 1871 1872 1872 set fg [option get $itk_component(hull) font Font] 1873 1873 1874 1874 set inner [$itk_component(main) insert end \ 1875 1875 -title "Cutplane Settings" \ 1876 -icon [Rappture::icon cutbutton]] 1876 -icon [Rappture::icon cutbutton]] 1877 1877 1878 1878 $inner configure -borderwidth 4 … … 1933 1933 -command [itcl::code $this EventuallySetCutplane x] \ 1934 1934 -variable [itcl::scope _settings(-xcutplaneposition)] \ 1935 1935 -foreground red2 -font "Arial 9 bold" 1936 1936 } { 1937 1937 usual … … 1962 1962 -command [itcl::code $this EventuallySetCutplane y] \ 1963 1963 -variable [itcl::scope _settings(-ycutplaneposition)] \ 1964 1964 -foreground green3 -font "Arial 9 bold" 1965 1965 } { 1966 1966 usual … … 1981 1981 -variable [itcl::scope _settings(-zcutplanevisible)] \ 1982 1982 } { 1983 1984 1983 usual 1984 ignore -foreground 1985 1985 } 1986 1986 Rappture::Tooltip::for $itk_component(zbutton) \ … … 1994 1994 -command [itcl::code $this EventuallySetCutplane z] \ 1995 1995 -variable [itcl::scope _settings(-zcutplaneposition)] \ 1996 1996 -foreground blue3 -font "Arial 9 bold" 1997 1997 } { 1998 1998 usual … … 2012 2012 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 2013 2013 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 2014 6,0 $inner.xbutton 2015 7,0 $inner.ybutton 2016 8,0 $inner.zbutton 2017 6,1 $inner.xval 2018 6,2 $inner.yval 2019 6,3 $inner.zval 2014 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 2015 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 2016 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 2017 6,1 $inner.xval -fill y -rspan 4 \ 2018 6,2 $inner.yval -fill y -rspan 4 \ 2019 6,3 $inner.zval -fill y -rspan 4 \ 2020 2020 2021 2021 … … 2025 2025 2026 2026 # 2027 # camera -- 2027 # camera -- 2028 2028 # 2029 2029 itcl::body Rappture::VtkIsosurfaceViewer::camera {option args} { 2030 switch -- $option { 2030 switch -- $option { 2031 2031 "show" { 2032 2032 puts [array get _view] … … 2076 2076 2077 2077 itcl::body Rappture::VtkIsosurfaceViewer::GetImage { args } { 2078 if { [image width $_image(download)] > 0 && 2078 if { [image width $_image(download)] > 0 && 2079 2079 [image height $_image(download)] > 0 } { 2080 2080 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 2089 2089 -title "[Rappture::filexfer::label downloadWord] as..." 2090 2090 set inner [$popup component inner] 2091 label $inner.summary -text "" -anchor w 2091 label $inner.summary -text "" -anchor w 2092 2092 radiobutton $inner.vtk_button -text "VTK data file" \ 2093 2093 -variable [itcl::scope _downloadPopup(format)] \ 2094 2094 -font "Arial 9 " \ 2095 -value vtk 2095 -value vtk 2096 2096 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 2097 2097 radiobutton $inner.image_button -text "Image File" \ 2098 2098 -variable [itcl::scope _downloadPopup(format)] \ 2099 2099 -font "Arial 9 " \ 2100 -value image 2100 -value image 2101 2101 Rappture::Tooltip::for $inner.image_button \ 2102 2102 "Save as digital image." … … 2119 2119 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 2120 2120 4,1 $inner.cancel -width .9i -fill y \ 2121 4,0 $inner.ok -padx 2 -width .9i -fill y 2121 4,0 $inner.ok -padx 2 -width .9i -fill y 2122 2122 blt::table configure $inner r3 -height 4 2123 2123 blt::table configure $inner r4 -pady 4 … … 2132 2132 array set style { 2133 2133 -color BCGYR 2134 -cutplanesvisible 0 2134 -cutplanesvisible 0 2135 2135 -edgecolor black 2136 2136 -edges 0 … … 2184 2184 set _contourList(numLevels) $style(-levels) 2185 2185 } 2186 EventuallyChangeContourLevels 2186 EventuallyChangeContourLevels 2187 2187 } 2188 2188 set _settings(-isosurfacevisible) $style(-isosurfacevisible) … … 2194 2194 set _settings(-ycutplaneposition) $style(-ycutplaneposition) 2195 2195 set _settings(-zcutplaneposition) $style(-zcutplaneposition) 2196 2196 2197 2197 SendCmd "cutplane add $tag" 2198 2198 SendCmd "cutplane color [Color2RGB $itk_option(-plotforeground)] $tag" … … 2209 2209 SendCmd "outline visible $style(-outline) $tag" 2210 2210 set _settings(-outline) $style(-outline) 2211 2211 2212 2212 GenerateContourList 2213 2213 SendCmd [list contour3d add contourlist $_contourList(values) $tag] … … 2222 2222 SendCmd "contour3d opacity $style(-opacity) $tag" 2223 2223 set _settings(-isosurfaceopacity) $style(-opacity) 2224 SetCurrentColormap $style(-color) 2224 SetCurrentColormap $style(-color) 2225 2225 SendCmd "contour3d wireframe $style(-wireframe) $tag" 2226 2226 set _settings(-isosurfacewireframe) $style(-wireframe) … … 2273 2273 set font "Arial 8" 2274 2274 set lineht [font metrics $font -linespace] 2275 2275 2276 2276 set ih [image height $_image(legend)] 2277 2277 set iy [expr $y - ($lineht + 2)] 2278 2278 2279 2279 if { [string match "component*" $fname] } { 2280 2280 set title "" 2281 2281 } else { 2282 2283 2284 2285 2286 2287 2288 2289 2282 if { [info exists _fields($fname)] } { 2283 foreach { title units } $_fields($fname) break 2284 if { $units != "" } { 2285 set title [format "%s (%s)" $title $units] 2286 } 2287 } else { 2288 set title $fname 2289 } 2290 2290 } 2291 2291 # If there's a legend title, increase the offset by the line height. … … 2301 2301 } 2302 2302 set color [eval format "\#%02x%02x%02x" $pixel] 2303 $_image(swatch) put black -to 0 0 23 23 2304 $_image(swatch) put $color -to 1 1 22 22 2303 $_image(swatch) put black -to 0 0 23 23 2304 $_image(swatch) put $color -to 1 1 22 22 2305 2305 .rappturetooltip configure -icon $_image(swatch) 2306 2306 … … 2313 2313 set value 0.0 2314 2314 } 2315 set tx [expr $x + 15] 2315 set tx [expr $x + 15] 2316 2316 set ty [expr $y - 5] 2317 2317 if { [info exists _isolines($y)] } { … … 2320 2320 Rappture::Tooltip::text $c [format "$title %g" $value] 2321 2321 } 2322 Rappture::Tooltip::tooltip show $c +$tx,+$ty 2322 Rappture::Tooltip::tooltip show $c +$tx,+$ty 2323 2323 } 2324 2324 … … 2354 2354 2355 2355 # 2356 # ReceiveLegend -- 2357 # 2358 # 2359 # 2360 # 2356 # ReceiveLegend -- 2357 # 2358 # Invoked automatically whenever the "legend" command comes in from 2359 # the rendering server. Indicates that binary image data with the 2360 # specified <size> will follow. 2361 2361 # 2362 2362 itcl::body Rappture::VtkIsosurfaceViewer::ReceiveLegend { colormap title min max size } { 2363 2363 #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size" 2364 2364 set _title $title 2365 regsub {\(mag\)} $title "" _title 2365 regsub {\(mag\)} $title "" _title 2366 2366 if { [IsConnected] } { 2367 2367 set bytes [ReceiveBytes $size] … … 2372 2372 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2373 2373 if { [catch {DrawLegend} errs] != 0 } { 2374 2375 2374 global errorInfo 2375 puts stderr "errs=$errs errorInfo=$errorInfo" 2376 2376 } 2377 2377 } … … 2392 2392 2393 2393 if { [string match "component*" $fname] } { 2394 2394 set title "" 2395 2395 } else { 2396 2397 2398 2399 2400 2401 2402 2403 2396 if { [info exists _fields($fname)] } { 2397 foreach { title units } $_fields($fname) break 2398 if { $units != "" } { 2399 set title [format "%s (%s)" $title $units] 2400 } 2401 } else { 2402 set title $fname 2403 } 2404 2404 } 2405 2405 set x [expr $w - 2] 2406 2406 if { !$_settings(-legendvisible) } { 2407 2408 2409 } 2407 $c delete legend 2408 return 2409 } 2410 2410 if { [$c find withtag "legend"] == "" } { 2411 set y 2 2412 2411 set y 2 2412 # If there's a legend title, create a text item for the title. 2413 2413 $c create text $x $y \ 2414 2415 2416 -font $font 2414 -anchor ne \ 2415 -fill $itk_option(-plotforeground) -tags "title legend" \ 2416 -font $font 2417 2417 if { $title != "" } { 2418 2418 incr y $lineht 2419 2419 } 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2420 $c create text $x $y \ 2421 -anchor ne \ 2422 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2423 -font $font 2424 incr y $lineht 2425 $c create image $x $y \ 2426 -anchor ne \ 2427 -image $_image(legend) -tags "colormap legend" 2428 $c create rectangle $x $y 1 1 \ 2429 -fill "" -outline "" -tags "sensor legend" 2430 $c create text $x [expr {$h-2}] \ 2431 -anchor se \ 2432 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2433 -font $font 2434 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2435 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2436 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2437 2437 } 2438 2438 $c delete isoline … … 2453 2453 } 2454 2454 set tags "isoline legend" 2455 2456 2457 2458 2455 set offset [expr 2 + $lineht] 2456 if { $title != "" } { 2457 incr offset $lineht 2458 } 2459 2459 foreach value $_contourList(values) { 2460 2460 set norm [expr 1.0 - (($value - $vmin) / $range)] … … 2475 2475 if { [info exists _limits($_curFldName)] } { 2476 2476 foreach { vmin vmax } $_limits($_curFldName) break 2477 2478 2477 $c itemconfigure vmin -text [format %g $vmin] 2478 $c itemconfigure vmax -text [format %g $vmax] 2479 2479 } 2480 2480 set y 2 … … 2482 2482 if { $title != "" } { 2483 2483 $c itemconfigure title -text $title 2484 2485 2484 $c coords title $x $y 2485 incr y $lineht 2486 2486 $c raise title 2487 2487 } … … 2506 2506 # ---------------------------------------------------------------------- 2507 2507 itcl::body Rappture::VtkIsosurfaceViewer::Combo {option} { 2508 set c $itk_component(view) 2508 set c $itk_component(view) 2509 2509 switch -- $option { 2510 2510 post { … … 2521 2521 } 2522 2522 deactivate { 2523 $c itemconfigure title -fill $itk_option(-plotforeground) 2523 $c itemconfigure title -fill $itk_option(-plotforeground) 2524 2524 } 2525 2525 invoke { … … 2539 2539 # Keep track of the colormaps that we build. 2540 2540 if { ![info exists _colormaps($name)] } { 2541 BuildColormap $name 2541 BuildColormap $name 2542 2542 set _colormaps($name) 1 2543 2543 } … … 2561 2561 } 2562 2562 2563 itcl::body Rappture::VtkIsosurfaceViewer::SetOrientation { side } { 2563 itcl::body Rappture::VtkIsosurfaceViewer::SetOrientation { side } { 2564 2564 array set positions { 2565 2565 front "1 0 0 0" … … 2582 2582 } 2583 2583 2584 itcl::body Rappture::VtkIsosurfaceViewer::GenerateContourList {} { 2584 itcl::body Rappture::VtkIsosurfaceViewer::GenerateContourList {} { 2585 2585 if { ![info exists _limits($_curFldName)] } { 2586 2586 puts stderr "no _curFldName" … … 2605 2605 } 2606 2606 2607 itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentFieldName { dataobj } { 2607 itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentFieldName { dataobj } { 2608 2608 set _first $dataobj 2609 2609 $itk_component(field) choices delete 0 end
Note: See TracChangeset
for help on using the changeset viewer.