- Timestamp:
- Nov 12, 2014, 7:21:51 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkglyphviewer.tcl
r4699 r4707 143 143 private variable _legendPending 0 144 144 private variable _field "" 145 private variable _colorMode "vmag"; 145 private variable _colorMode "vmag"; # Mode of colormap (vmag or scalar) 146 146 private variable _fieldNames {} 147 147 private variable _fields … … 181 181 $_dispatcher register !xcutplane 182 182 $_dispatcher dispatch $this !xcutplane \ 183 "[itcl::code $this AdjustSetting cutplaneXPosition]; list"183 "[itcl::code $this AdjustSetting -cutplanexposition]; list" 184 184 185 185 # Y-Cutplane event 186 186 $_dispatcher register !ycutplane 187 187 $_dispatcher dispatch $this !ycutplane \ 188 "[itcl::code $this AdjustSetting cutplaneYPosition]; list"188 "[itcl::code $this AdjustSetting -cutplaneyposition]; list" 189 189 190 190 # Z-Cutplane event 191 191 $_dispatcher register !zcutplane 192 192 $_dispatcher dispatch $this !zcutplane \ 193 "[itcl::code $this AdjustSetting cutplaneZPosition]; list"193 "[itcl::code $this AdjustSetting -cutplanezposition]; list" 194 194 195 195 # … … 221 221 -axismode "static" 222 222 -background black 223 224 223 -colormap BCGYR 224 -colormapvisible 1 225 225 -cutplaneedges 0 226 226 -cutplanelighting 1 … … 235 235 -cutplanezposition 50 236 236 -cutplanezvisible 1 237 238 -glyphedges 239 -glyphlighting 240 -glyphnormscale 241 -glyphopacity 242 -glyphorient 243 -glyphoutline 244 -glyphscale 245 -glyphscalemode 246 -glyphshape 247 -glyphvisible 248 -glyphwireframe 237 -field "Default" 238 -glyphedges 0 239 -glyphlighting 1 240 -glyphnormscale 1 241 -glyphopacity 100 242 -glyphorient 1 243 -glyphoutline 0 244 -glyphscale 1 245 -glyphscalemode "vmag" 246 -glyphshape "arrow" 247 -glyphvisible 1 248 -glyphwireframe 0 249 249 -legendvisible 1 250 250 -saveglyphopacity 100 251 251 -xgrid 0 252 252 -ygrid 0 253 -zgrid 0 253 -zgrid 0 254 254 }] 255 255 array set _changed { … … 546 546 } 547 547 548 549 548 # ---------------------------------------------------------------------- 550 549 # USAGE: delete ?<dataobj1> <dataobj2> ...? 551 550 # 552 # 553 # 554 # 551 # Clients use this to delete a dataobj from the plot. If no dataobjs 552 # are specified, then all dataobjs are deleted. No data objects are 553 # deleted. They are only removed from the display list. 555 554 # 556 555 # ---------------------------------------------------------------------- … … 802 801 # isconnected -- 803 802 # 804 # 803 # Indicates if we are currently connected to the visualization server. 805 804 # 806 805 itcl::body Rappture::VtkGlyphViewer::isconnected {} { … … 819 818 # Disconnect -- 820 819 # 821 # 822 # 820 # Clients use this method to disconnect from the current rendering 821 # server. 823 822 # 824 823 itcl::body Rappture::VtkGlyphViewer::Disconnect {} { … … 976 975 if { ![info exists _datasets($tag)] } { 977 976 set bytes [$dataobj vtkdata $comp] 978 979 980 981 977 if 0 { 978 set f [open "/tmp/glyph.vtk" "w"] 979 puts $f $bytes 980 close $f 982 981 } 983 982 set length [string length $bytes] … … 1002 1001 # Setting dataset visible enables outline 1003 1002 # and glyphs 1004 1003 SendCmd "dataset visible 1 $tag" 1005 1004 } 1006 1005 } … … 1008 1007 1009 1008 if { $_first != "" } { 1010 1011 1012 1009 $itk_component(field) choices delete 0 end 1010 $itk_component(fieldmenu) delete 0 end 1011 array unset _fields 1013 1012 set _curFldName "" 1014 1013 foreach cname [$_first components] { … … 1039 1038 #-cutplanevisible 1040 1039 if { $_reset } { 1041 1040 # These are settings that rely on a dataset being loaded. 1042 1041 InitSettings \ 1043 1042 -glyphlighting \ 1044 1043 -field \ 1045 1044 -glyphedges -glyphlighting -glyphopacity \ 1046 1045 -glyphwireframe 1047 1046 1048 1047 #-cutplanexposition -cutplaneyposition -cutplanezposition \ 1049 1048 -cutplanexvisible -cutplaneyvisible -cutplanezvisible \ 1050 1049 -cutplanepreinterp 1051 1050 1052 1051 Zoom reset 1053 1052 foreach axis { x y z } { 1054 1053 # Another problem fixed by a <view>. We looking into a data 1055 1054 # object for the name of the axes. This should be global to 1056 1055 # the viewer itself. 1057 1058 1056 set label [$_first hints ${axis}label] 1057 if { $label == "" } { 1059 1058 set label [string toupper $axis] 1060 1061 1062 1059 } 1060 # May be a space in the axis label. 1061 SendCmd [list axis name $axis $label] 1063 1062 } 1064 1063 if { [array size _fields] < 2 } { … … 1167 1166 SendCmd "camera pan $x $y" 1168 1167 } 1169 1170 1168 1171 1169 # ---------------------------------------------------------------------- … … 1299 1297 # AdjustSetting -- 1300 1298 # 1301 # 1302 # 1303 # 1299 # Changes/updates a specific setting in the widget. There are 1300 # usually user-setable option. Commands are sent to the render 1301 # server. 1304 1302 # 1305 1303 itcl::body Rappture::VtkGlyphViewer::AdjustSetting {what {value ""}} { … … 1310 1308 "-background" { 1311 1309 set bgcolor [$itk_component(background) value] 1312 1313 1314 1315 "grey""black"1316 1310 array set fgcolors { 1311 "black" "white" 1312 "white" "black" 1313 "grey" "black" 1314 } 1317 1315 configure -plotbackground $bgcolor \ 1318 1319 1320 1316 -plotforeground $fgcolors($bgcolor) 1317 $itk_component(view) delete "legend" 1318 DrawLegend 1321 1319 } 1322 1320 "-axesvisible" { … … 1383 1381 -troughcolor grey82 1384 1382 } 1385 1383 SendCmd "cutplane axis $axis $bool" 1386 1384 } 1387 1385 "-cutplanexposition" - "-cutplaneyposition" - "-cutplanezposition" { … … 1396 1394 set color [$itk_component(colormap) value] 1397 1395 set _settings($what) $color 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1396 if { $color == "none" } { 1397 if { $_settings(-colormapvisible) } { 1398 SendCmd "glyphs colormode constant {}" 1399 set _settings(-colormapvisible) 0 1400 } 1401 } else { 1402 if { !$_settings(-colormapvisible) } { 1403 SendCmd "glyphs colormode $_colorMode $_curFldName" 1404 set _settings(-colormapvisible) 1 1405 } 1406 SetCurrentColormap $color 1407 } 1410 1408 StopBufferingCommands 1411 1409 EventuallyRequestLegend 1412 1410 } 1413 1411 "-glyphwireframe" { 1414 1412 set bool $_settings($what) 1415 1413 SendCmd "glyphs wireframe $bool" 1416 1414 } 1417 1415 "-glyphvisible" { … … 1430 1428 "Show the glyph" 1431 1429 } 1432 1430 DrawLegend 1433 1431 } 1434 1432 "-glyphlighting" { 1435 1433 set bool $_settings($what) 1436 1434 SendCmd "glyphs lighting $bool" 1437 1435 } 1438 1436 "-glyphedges" { 1439 1437 set bool $_settings($what) 1440 1438 SendCmd "glyphs edges $bool" 1441 1439 } 1442 1440 "-glyphoutline" { … … 1452 1450 set val $_settings($what) 1453 1451 set sval [expr { 0.01 * double($val) }] 1454 1452 SendCmd "glyphs opacity $sval" 1455 1453 } 1456 1454 "-glyphnormscale" { … … 1509 1507 if { !$_settings($what) } { 1510 1508 $itk_component(view) delete legend 1511 1512 1509 } 1510 DrawLegend 1513 1511 } 1514 1512 default { … … 1518 1516 } 1519 1517 1520 1521 1518 # 1522 1519 # RequestLegend -- 1523 1520 # 1524 # 1525 # 1521 # Request a new legend from the server. The size of the legend 1522 # is determined from the height of the canvas. 1526 1523 # 1527 1524 # This should be called when 1528 # 1529 # 1530 # 1531 # 1532 # 1525 # 1. A new current colormap is set. 1526 # 2. Window is resized. 1527 # 3. The limits of the data have changed. (Just need a redraw). 1528 # 4. Number of glyph have changed. (Just need a redraw). 1529 # 5. Legend becomes visible (Just need a redraw). 1533 1530 # 1534 1531 itcl::body Rappture::VtkGlyphViewer::RequestLegend {} { … … 1542 1539 set fname $_curFldName 1543 1540 if { [string match "component*" $fname] } { 1544 1541 set title "" 1545 1542 } else { 1546 1547 1548 1549 1550 1551 1552 1553 1543 if { [info exists _fields($fname)] } { 1544 foreach { title units } $_fields($fname) break 1545 if { $units != "" } { 1546 set title [format "%s (%s)" $title $units] 1547 } 1548 } else { 1549 set title $fname 1550 } 1554 1551 } 1555 1552 # If there's a title too, substract one more line … … 1562 1559 # Set the legend on the first heightmap dataset. 1563 1560 if { $_currentColormap != "" } { 1564 1565 1561 set cmap $_currentColormap 1562 SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0" 1566 1563 } 1567 1564 } … … 1583 1580 if { [isconnected] } { 1584 1581 set rgb [Color2RGB $itk_option(-plotforeground)] 1585 1582 SendCmd "axis color all $rgb" 1586 1583 SendCmd "outline color $rgb" 1587 1584 #SendCmd "cutplane color $rgb" … … 1731 1728 } 1732 1729 bind $inner.field <<Value>> \ 1733 [itcl::code $this AdjustSetting field]1730 [itcl::code $this AdjustSetting -field] 1734 1731 1735 1732 label $inner.colormap_l -text "Colormap" -font "Arial 9" … … 1749 1746 2,0 $inner.gshape_l -anchor w -pady 2 \ 1750 1747 2,1 $inner.gshape -anchor w -pady 2 -fill x \ 1751 1752 1748 3,0 $inner.background_l -anchor w -pady 2 \ 1749 3,1 $inner.background -anchor w -pady 2 -fill x \ 1753 1750 4,0 $inner.scaleMode_l -anchor w -pady 2 \ 1754 1751 4,1 $inner.scaleMode -anchor w -pady 2 -fill x \ … … 1759 1756 8,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \ 1760 1757 9,0 $inner.lighting -anchor w -pady 2 -cspan 2 \ 1761 10,0 $inner.edges 1758 10,0 $inner.edges -anchor w -pady 2 -cspan 2 \ 1762 1759 11,0 $inner.outline -anchor w -pady 2 -cspan 2 \ 1763 1760 12,0 $inner.legend -anchor w -pady 2 \ … … 1826 1823 1827 1824 blt::table $inner \ 1828 0,0 $inner.visible -anchor w -cspan 4 \1829 1,0 $inner.labels -anchor w -cspan 4 \1830 2,0 $inner.minorticks 1831 4,0 $inner.grid_l -anchor w \1832 4,1 $inner.xgrid -anchor w \1833 4,2 $inner.ygrid -anchor w \1834 4,3 $inner.zgrid -anchor w \1835 5,0 $inner.mode_l -anchor w -padx { 2 0 } \1836 5,1 $inner.mode -fill x -cspan 31825 0,0 $inner.visible -anchor w -cspan 4 \ 1826 1,0 $inner.labels -anchor w -cspan 4 \ 1827 2,0 $inner.minorticks -anchor w -cspan 4 \ 1828 4,0 $inner.grid_l -anchor w \ 1829 4,1 $inner.xgrid -anchor w \ 1830 4,2 $inner.ygrid -anchor w \ 1831 4,3 $inner.zgrid -anchor w \ 1832 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1833 5,1 $inner.mode -fill x -cspan 3 1837 1834 1838 1835 blt::table configure $inner r* c* -resize none … … 1840 1837 blt::table configure $inner r3 -height 0.125i 1841 1838 } 1842 1843 1839 1844 1840 itcl::body Rappture::VtkGlyphViewer::BuildCameraTab {} { … … 1955 1951 -command [itcl::code $this EventuallySetCutplane x] \ 1956 1952 -variable [itcl::scope _settings(-cutplanexposition)] \ 1957 1953 -foreground red2 -font "Arial 9 bold" 1958 1954 } { 1959 1955 usual … … 1984 1980 -command [itcl::code $this EventuallySetCutplane y] \ 1985 1981 -variable [itcl::scope _settings(-cutplaneyposition)] \ 1986 1982 -foreground green3 -font "Arial 9 bold" 1987 1983 } { 1988 1984 usual … … 2003 1999 -variable [itcl::scope _settings(-cutplanezvisible)] \ 2004 2000 } { 2005 2006 2001 usual 2002 ignore -foreground 2007 2003 } 2008 2004 Rappture::Tooltip::for $itk_component(zbutton) \ … … 2016 2012 -command [itcl::code $this EventuallySetCutplane z] \ 2017 2013 -variable [itcl::scope _settings(-cutplanezposition)] \ 2018 2014 -foreground blue3 -font "Arial 9 bold" 2019 2015 } { 2020 2016 usual … … 2027 2023 2028 2024 blt::table $inner \ 2029 0,0 $inner.visible -anchor w -pady 2 -cspan 3 \ 2030 1,0 $inner.lighting -anchor w -pady 2 -cspan 3 \ 2031 2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \ 2032 3,0 $inner.edges -anchor w -pady 2 -cspan 3 \ 2033 4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \ 2034 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 2035 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 2036 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 2037 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 2038 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 2039 6,1 $inner.xval -fill y -rspan 4 \ 2040 6,2 $inner.yval -fill y -rspan 4 \ 2041 6,3 $inner.zval -fill y -rspan 4 \ 2042 2025 0,0 $inner.visible -anchor w -pady 2 -cspan 3 \ 2026 1,0 $inner.lighting -anchor w -pady 2 -cspan 3 \ 2027 2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \ 2028 3,0 $inner.edges -anchor w -pady 2 -cspan 3 \ 2029 4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \ 2030 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 2031 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 2032 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 2033 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 2034 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 2035 6,1 $inner.xval -fill y -rspan 4 \ 2036 6,2 $inner.yval -fill y -rspan 4 \ 2037 6,3 $inner.zval -fill y -rspan 4 \ 2043 2038 2044 2039 blt::table configure $inner r* c* -resize none … … 2220 2215 $itk_component(gshape) value $style(-shape) 2221 2216 SendCmd "glyphs edges $style(-edges) $tag" 2217 set _settings(-glyphedges) $style(-edges) 2218 2222 2219 # normscale=1 and gscale=1 are defaults 2223 2220 if {$style(-normscale) != 1} { … … 2230 2227 set _settings(-glyphscale) $style(-gscale) 2231 2228 2232 set _settings(-glyphedges) $style(-edges)2233 2229 if {$style(-colorMode) == "constant" || $style(-colormap) == "none"} { 2234 2230 SendCmd "glyphs colormode constant {} $tag" … … 2314 2310 2315 2311 if { [string match "component*" $fname] } { 2316 2312 set title "" 2317 2313 } else { 2318 2319 2320 2321 2322 2323 2324 2325 2314 if { [info exists _fields($fname)] } { 2315 foreach { title units } $_fields($fname) break 2316 if { $units != "" } { 2317 set title [format "%s (%s)" $title $units] 2318 } 2319 } else { 2320 set title $fname 2321 } 2326 2322 } 2327 2323 # If there's a legend title, increase the offset by the line height. … … 2355 2351 } 2356 2352 2357 2358 2353 # ---------------------------------------------------------------------- 2359 2354 # USAGE: Slice move x|y|z <newval> … … 2389 2384 # ReceiveLegend -- 2390 2385 # 2391 # 2392 # 2393 # 2386 # Invoked automatically whenever the "legend" command comes in from 2387 # the rendering server. Indicates that binary image data with the 2388 # specified <size> will follow. 2394 2389 # 2395 2390 itcl::body Rappture::VtkGlyphViewer::ReceiveLegend { colormap title min max size } { … … 2405 2400 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2406 2401 if { [catch {DrawLegend} errs] != 0 } { 2407 2408 2402 global errorInfo 2403 puts stderr "errs=$errs errorInfo=$errorInfo" 2409 2404 } 2410 2405 } … … 2414 2409 # DrawLegend -- 2415 2410 # 2416 # 2411 # Draws the legend in the own canvas on the right side of the plot area. 2417 2412 # 2418 2413 itcl::body Rappture::VtkGlyphViewer::DrawLegend {} { … … 2425 2420 2426 2421 if { [string match "component*" $fname] } { 2427 2422 set title "" 2428 2423 } else { 2429 2430 2431 2432 2433 2434 2435 2436 2424 if { [info exists _fields($fname)] } { 2425 foreach { title units } $_fields($fname) break 2426 if { $units != "" } { 2427 set title [format "%s (%s)" $title $units] 2428 } 2429 } else { 2430 set title $fname 2431 } 2437 2432 } 2438 2433 set x [expr $w - 2] 2439 2434 if { !$_settings(-legendvisible) } { 2440 2441 2435 $c delete legend 2436 return 2442 2437 } 2443 2438 if { [$c find withtag "legend"] == "" } { 2444 2445 2439 set y 2 2440 # If there's a legend title, create a text item for the title. 2446 2441 $c create text $x $y \ 2447 2448 2449 2442 -anchor ne \ 2443 -fill $itk_option(-plotforeground) -tags "title legend" \ 2444 -font $font 2450 2445 if { $title != "" } { 2451 2446 incr y $lineht 2452 2447 } 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2448 $c create text $x $y \ 2449 -anchor ne \ 2450 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2451 -font $font 2452 incr y $lineht 2453 $c create image $x $y \ 2454 -anchor ne \ 2455 -image $_image(legend) -tags "colormap legend" 2456 $c create rectangle $x $y 1 1 \ 2457 -fill "" -outline "" -tags "sensor legend" 2458 $c create text $x [expr {$h-2}] \ 2459 -anchor se \ 2460 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2461 -font $font 2462 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2463 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2464 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2470 2465 } 2471 2466 set x2 $x … … 2481 2476 if { [info exists _limits($_curFldName)] } { 2482 2477 foreach { vmin vmax } $_limits($_curFldName) break 2483 2484 2478 $c itemconfigure vmin -text [format %g $vmin] 2479 $c itemconfigure vmax -text [format %g $vmax] 2485 2480 } 2486 2481 set y 2 … … 2488 2483 if { $title != "" } { 2489 2484 $c itemconfigure title -text $title 2490 2491 2485 $c coords title $x $y 2486 incr y $lineht 2492 2487 $c raise title 2493 2488 } … … 2531 2526 invoke { 2532 2527 $itk_component(field) value $_curFldLabel 2533 AdjustSetting field2528 AdjustSetting -field 2534 2529 } 2535 2530 default { … … 2555 2550 # BuildColormap -- 2556 2551 # 2557 # 2552 # Build the designated colormap on the server. 2558 2553 # 2559 2554 itcl::body Rappture::VtkGlyphViewer::BuildColormap { name } { … … 2586 2581 set _view(zoom) 1.0 2587 2582 } 2588
Note: See TracChangeset
for help on using the changeset viewer.