Changeset 6212 for branches/1.6/gui/scripts/vtkglyphviewer.tcl
- Timestamp:
- Mar 28, 2016, 6:30:14 AM (9 years ago)
- Location:
- branches/1.6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.6
- Property svn:mergeinfo changed
/trunk merged: 5664,6173,6175,6181,6202-6203
- Property svn:mergeinfo changed
-
branches/1.6/gui/scripts/vtkglyphviewer.tcl
r6155 r6212 70 70 private method BuildDownloadPopup { widget command } 71 71 private method BuildGlyphTab {} 72 private method Combo { option }73 72 private method Connect {} 74 73 private method CurrentDatasets {args} … … 87 86 private method IsValidObject { dataobj } 88 87 private method LeaveLegend {} 88 private method LegendTitleAction { option } 89 89 private method MotionLegend { x y } 90 90 private method Pan {option x y} … … 105 105 private method SetObjectStyle { dataobj comp } 106 106 private method SetOrientation { side } 107 private method SetupKeyboardBindings {} 108 private method SetupMousePanningBindings {} 109 private method SetupMouseRotationBindings {} 110 private method SetupMouseZoomBindings {} 107 111 private method Slice {option args} 108 112 private method ViewToQuaternion {} { … … 133 137 private variable _start 0 134 138 private variable _title "" 139 private variable _widget 135 140 private variable _width 0 136 141 private variable _height 0 … … 225 230 -cutplaneedges 0 226 231 -cutplanelighting 1 227 -cutplaneopacity 1 00232 -cutplaneopacity 1.0 228 233 -cutplanepreinterp 1 229 234 -cutplanesvisible 0 … … 233 238 -glyphlighting 1 234 239 -glyphnormscale 1 235 -glyphopacity 1 00240 -glyphopacity 1.0 236 241 -glyphorient 1 237 242 -glyphscale 1 238 243 -glyphscalemode "vmag" 239 244 -glyphshape "arrow" 240 -glyph visible1245 -glyphsvisible 1 241 246 -glyphwireframe 0 242 247 -legendvisible 1 243 248 -outline 0 244 -saveglyphopacity 100245 249 -xcutplaneposition 50 246 250 -xcutplanevisible 1 … … 255 259 array set _changed { 256 260 -colormap 0 261 -cutplaneedges 0 262 -cutplanelighting 0 263 -cutplaneopacity 0 264 -cutplanepreinterp 0 265 -cutplanesvisible 0 266 -cutplanewireframe 0 267 -glyphedges 0 268 -glyphlighting 0 269 -glyphnormscale 0 257 270 -glyphopacity 0 271 -glyphorient 0 272 -glyphscale 0 273 -glyphscalemode 0 274 -glyphshape 0 275 -glyphsvisible 0 276 -glyphwireframe 0 277 -outline 0 278 -xcutplaneposition 0 279 -xcutplanevisible 0 280 -ycutplaneposition 0 281 -ycutplanevisible 0 282 -zcutplaneposition 0 283 -zcutplanevisible 0 284 } 285 array set _widget { 286 -cutplaneopacity 100 287 -glyphopacity 100 258 288 } 259 289 … … 273 303 ignore -background -foreground -relief -tearoff 274 304 } 305 275 306 set c $itk_component(view) 276 307 bind $c <Configure> [itcl::code $this EventuallyResize %w %h] 277 bind $c <4> [itcl::code $this Zoom in 0.25]278 bind $c <5> [itcl::code $this Zoom out 0.25]279 bind $c <KeyPress-Left> [list %W xview scroll 10 units]280 bind $c <KeyPress-Right> [list %W xview scroll -10 units]281 bind $c <KeyPress-Up> [list %W yview scroll 10 units]282 bind $c <KeyPress-Down> [list %W yview scroll -10 units]283 bind $c <Enter> "focus %W"284 308 bind $c <Control-F1> [itcl::code $this ToggleConsole] 285 309 … … 335 359 -onimage [Rappture::icon volume-on] \ 336 360 -offimage [Rappture::icon volume-off] \ 337 -variable [itcl::scope _settings(-glyph visible)] \338 -command [itcl::code $this AdjustSetting -glyph visible]361 -variable [itcl::scope _settings(-glyphsvisible)] \ 362 -command [itcl::code $this AdjustSetting -glyphsvisible] 339 363 } 340 364 $itk_component(glyphs) select … … 384 408 blt::table configure $itk_component(plotarea) c1 -resize none 385 409 410 SetupMouseRotationBindings 411 SetupMousePanningBindings 412 SetupMouseZoomBindings 413 SetupKeyboardBindings 414 415 #bind $itk_component(view) <ButtonRelease-3> \ 416 # [itcl::code $this Pick %x %y] 417 418 set _image(download) [image create photo] 419 420 eval itk_initialize $args 421 422 Connect 423 } 424 425 # ---------------------------------------------------------------------- 426 # DESTRUCTOR 427 # ---------------------------------------------------------------------- 428 itcl::body Rappture::VtkGlyphViewer::destructor {} { 429 Disconnect 430 image delete $_image(plot) 431 image delete $_image(download) 432 catch { blt::arcball destroy $_arcball } 433 } 434 435 itcl::body Rappture::VtkGlyphViewer::SetupMouseRotationBindings {} { 386 436 # Bindings for rotation via mouse 387 437 bind $itk_component(view) <ButtonPress-1> \ … … 391 441 bind $itk_component(view) <ButtonRelease-1> \ 392 442 [itcl::code $this Rotate release %x %y] 393 443 } 444 445 itcl::body Rappture::VtkGlyphViewer::SetupMousePanningBindings {} { 394 446 # Bindings for panning via mouse 395 447 bind $itk_component(view) <ButtonPress-2> \ … … 399 451 bind $itk_component(view) <ButtonRelease-2> \ 400 452 [itcl::code $this Pan release %x %y] 401 402 #bind $itk_component(view) <ButtonRelease-3> \ 403 # [itcl::code $this Pick %x %y] 404 453 } 454 455 itcl::body Rappture::VtkGlyphViewer::SetupMouseZoomBindings {} { 456 if {[string equal "x11" [tk windowingsystem]]} { 457 # Bindings for zoom via mouse 458 bind $itk_component(view) <4> [itcl::code $this Zoom out] 459 bind $itk_component(view) <5> [itcl::code $this Zoom in] 460 } 461 } 462 463 itcl::body Rappture::VtkGlyphViewer::SetupKeyboardBindings {} { 405 464 # Bindings for panning via keyboard 406 465 bind $itk_component(view) <KeyPress-Left> \ … … 428 487 429 488 bind $itk_component(view) <Enter> "focus $itk_component(view)" 430 431 if {[string equal "x11" [tk windowingsystem]]} {432 # Bindings for zoom via mouse433 bind $itk_component(view) <4> [itcl::code $this Zoom out]434 bind $itk_component(view) <5> [itcl::code $this Zoom in]435 }436 437 set _image(download) [image create photo]438 439 eval itk_initialize $args440 441 Connect442 }443 444 # ----------------------------------------------------------------------445 # DESTRUCTOR446 # ----------------------------------------------------------------------447 itcl::body Rappture::VtkGlyphViewer::destructor {} {448 Disconnect449 image delete $_image(plot)450 image delete $_image(download)451 catch { blt::arcball destroy $_arcball }452 489 } 453 490 … … 999 1036 } 1000 1037 1001 InitSettings -glyph visible -outline1038 InitSettings -glyphsvisible -outline 1002 1039 #-cutplanesvisible 1003 1040 if { $_reset } { … … 1321 1358 } 1322 1359 "-cutplaneedges" { 1360 set _changed($what) 1 1323 1361 set bool $_settings($what) 1324 1362 SendCmd "cutplane edges $bool" 1325 1363 } 1326 1364 "-cutplanelighting" { 1365 set _changed($what) 1 1327 1366 set bool $_settings($what) 1328 1367 SendCmd "cutplane lighting $bool" 1329 1368 } 1330 1369 "-cutplaneopacity" { 1331 set val $_settings($what)1332 set sval [expr { 0.01 * double($val) }]1333 SendCmd "cutplane opacity $ sval"1370 set _changed($what) 1 1371 set _settings($what) [expr $_widget($what) * 0.01] 1372 SendCmd "cutplane opacity $_settings($what)" 1334 1373 } 1335 1374 "-cutplanepreinterp" { 1375 set _changed($what) 1 1336 1376 set bool $_settings($what) 1337 1377 SendCmd "cutplane preinterp $bool" 1338 1378 } 1339 1379 "-cutplanesvisible" { 1380 set _changed($what) 1 1340 1381 set bool $_settings($what) 1341 1382 SendCmd "cutplane visible 0" … … 1354 1395 } 1355 1396 "-cutplanewireframe" { 1397 set _changed($what) 1 1356 1398 set bool $_settings($what) 1357 1399 SendCmd "cutplane wireframe $bool" … … 1384 1426 } 1385 1427 "-glyphedges" { 1428 set _changed($what) 1 1386 1429 set bool $_settings($what) 1387 1430 SendCmd "glyphs edges $bool" 1388 1431 } 1389 1432 "-glyphlighting" { 1433 set _changed($what) 1 1390 1434 set bool $_settings($what) 1391 1435 SendCmd "glyphs lighting $bool" 1392 1436 } 1393 1437 "-glyphnormscale" { 1438 set _changed($what) 1 1394 1439 set bool $_settings($what) 1395 1440 SendCmd "glyphs normscale $bool" 1396 1441 } 1397 1442 "-glyphopacity" { 1398 set val $_settings($what)1399 set sval [expr { 0.01 * double($val) }]1400 SendCmd "glyphs opacity $ sval"1443 set _changed($what) 1 1444 set _settings($what) [expr $_widget($what) * 0.01] 1445 SendCmd "glyphs opacity $_settings($what)" 1401 1446 } 1402 1447 "-glyphorient" { 1448 set _changed($what) 1 1403 1449 set bool $_settings($what) 1404 1450 SendCmd "glyphs gorient $bool {}" 1405 1451 } 1406 1452 "-glyphscale" { 1453 set _changed($what) 1 1407 1454 set val $_settings($what) 1408 1455 if { [string is double $val] } { … … 1411 1458 } 1412 1459 "-glyphscalemode" { 1460 set _changed($what) 1 1413 1461 set label [$itk_component(scaleMode) value] 1414 1462 set mode [$itk_component(scaleMode) translate $label] … … 1417 1465 } 1418 1466 "-glyphshape" { 1467 set _changed($what) 1 1419 1468 set label [$itk_component(gshape) value] 1420 1469 set shape [$itk_component(gshape) translate $label] … … 1422 1471 SendCmd "glyphs shape $shape" 1423 1472 } 1424 "-glyphvisible" { 1473 "-glyphsvisible" { 1474 set _changed($what) 1 1425 1475 set bool $_settings($what) 1426 1476 SendCmd "glyphs visible 0" … … 1429 1479 SendCmd "glyphs visible $bool $tag" 1430 1480 } 1431 }1432 if { $bool } {1433 1481 Rappture::Tooltip::for $itk_component(glyphs) \ 1434 1482 "Hide the glyphs" … … 1440 1488 } 1441 1489 "-glyphwireframe" { 1490 set _changed($what) 1 1442 1491 set bool $_settings($what) 1443 1492 SendCmd "glyphs wireframe $bool" … … 1458 1507 } 1459 1508 "-outline" { 1509 set _changed($what) 1 1460 1510 set bool $_settings($what) 1461 1511 SendCmd "outline visible 0" … … 1467 1517 } 1468 1518 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1519 set _changed($what) 1 1469 1520 set axis [string tolower [string range $what 1 1]] 1470 1521 set bool $_settings($what) … … 1479 1530 } 1480 1531 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" { 1532 set _changed($what) 1 1481 1533 set axis [string tolower [string range $what 1 1]] 1482 1534 set pos [expr $_settings($what) * 0.01] … … 1582 1634 checkbutton $inner.glyphs \ 1583 1635 -text "Glyphs" \ 1584 -variable [itcl::scope _settings(-glyph visible)] \1585 -command [itcl::code $this AdjustSetting -glyph visible] \1636 -variable [itcl::scope _settings(-glyphsvisible)] \ 1637 -command [itcl::code $this AdjustSetting -glyphsvisible] \ 1586 1638 -font "Arial 9" 1587 1639 … … 1678 1730 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1679 1731 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1680 -variable [itcl::scope _ settings(-glyphopacity)] \1732 -variable [itcl::scope _widget(-glyphopacity)] \ 1681 1733 -width 10 \ 1682 1734 -showvalue off \ 1683 1735 -command [itcl::code $this AdjustSetting -glyphopacity] 1736 $inner.opacity set [expr $_settings(-glyphopacity) * 100.0] 1684 1737 1685 1738 label $inner.gscale_l -text "Scale factor" -font "Arial 9" … … 1720 1773 } 1721 1774 1722 $inner.colormap choices insert end [GetColormapList ]1775 $inner.colormap choices insert end [GetColormapList -includeNone] 1723 1776 $itk_component(colormap) value "BCGYR" 1724 1777 bind $inner.colormap <<Value>> \ … … 1917 1970 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1918 1971 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1919 -variable [itcl::scope _ settings(-cutplaneopacity)] \1972 -variable [itcl::scope _widget(-cutplaneopacity)] \ 1920 1973 -width 10 \ 1921 1974 -showvalue off \ 1922 1975 -command [itcl::code $this AdjustSetting -cutplaneopacity] 1923 $inner.opacity set $_settings(-cutplaneopacity)1976 $inner.opacity set [expr $_settings(-cutplaneopacity) * 100.0] 1924 1977 1925 1978 # X-value slicer... … … 2134 2187 2135 2188 itcl::body Rappture::VtkGlyphViewer::SetObjectStyle { dataobj comp } { 2189 DebugTrace "Enter" 2136 2190 # Parse style string. 2137 2191 set tag $dataobj-$comp 2138 2192 array set style { 2139 -color BCGYR 2140 -edgecolor black 2141 -edges 0 2142 -gscale 1 2143 -lighting 1 2144 -linewidth 1.0 2145 -normscale 1 2146 -opacity 1.0 2147 -orientglyphs 1 2148 -outline 0 2149 -ptsize 1.0 2150 -quality 1 2151 -scalemode vmag 2152 -shape arrow 2153 -wireframe 0 2154 } 2193 -color BCGYR 2194 -constcolor white 2195 -colormode vmag 2196 -cutplaneedges 0 2197 -cutplanelighting 1 2198 -cutplaneopacity 1.0 2199 -cutplanepreinterp 1 2200 -cutplanesvisible 0 2201 -cutplanewireframe 0 2202 -edgecolor black 2203 -edges 0 2204 -glyphsvisible 1 2205 -gscale 1 2206 -lighting 1 2207 -linewidth 1.0 2208 -normscale 1 2209 -opacity 1.0 2210 -orientglyphs 1 2211 -outline 0 2212 -ptsize 1.0 2213 -quality 1 2214 -scalemode vmag 2215 -shape arrow 2216 -wireframe 0 2217 -xcutplaneposition 50 2218 -xcutplanevisible 1 2219 -ycutplaneposition 50 2220 -ycutplanevisible 1 2221 -zcutplaneposition 50 2222 -zcutplanevisible 1 2223 } 2224 set style(-constcolor) $itk_option(-plotforeground) 2155 2225 set numComponents [$dataobj numComponents $comp] 2156 2226 if {$numComponents == 3} { … … 2158 2228 set style(-orientglyphs) 1 2159 2229 set style(-scalemode) "vmag" 2230 set style(-colormode) "vmag" 2160 2231 } else { 2161 2232 set style(-shape) "sphere" 2162 2233 set style(-orientglyphs) 0 2163 2234 set style(-scalemode) "scalar" 2235 set style(-colormode) "scalar" 2164 2236 } 2165 2237 array set style [$dataobj style $comp] … … 2184 2256 # the code to handle aberrant cases. 2185 2257 2258 if { $_changed(-glyphedges) } { 2259 set style(-edges) $_settings(-glyphedges) 2260 } 2261 if { $_changed(-glyphlighting) } { 2262 set style(-lighting) $_settings(-glyphlighting) 2263 } 2264 if { $_changed(-glyphnormscale) } { 2265 set style(-normscale) $_settings(-glyphnormscale) 2266 } 2186 2267 if { $_changed(-glyphopacity) } { 2187 set style(-opacity) [expr $_settings(-glyphopacity) * 0.01] 2268 set style(-opacity) $_settings(-glyphopacity) 2269 } 2270 if { $_changed(-glyphorient) } { 2271 set style(-orientglyphs) $_settings(-glyphorient) 2272 } 2273 if { $_changed(-glyphscale) } { 2274 set style(-gscale) $_settings(-glyphscale) 2275 } 2276 if { $_changed(-glyphwireframe) } { 2277 set style(-wireframe) $_settings(-glyphwireframe) 2188 2278 } 2189 2279 if { $_changed(-colormap) } { … … 2192 2282 if { $_currentColormap == "" } { 2193 2283 $itk_component(colormap) value $style(-color) 2284 } 2285 foreach setting {-outline -glyphsvisible -cutplanesvisible \ 2286 -xcutplanevisible -ycutplanevisible -zcutplanevisible \ 2287 -xcutplaneposition -ycutplaneposition -zcutplaneposition \ 2288 -cutplaneedges -cutplanelighting -cutplaneopacity \ 2289 -cutplanepreinterp -cutplanewireframe} { 2290 if {$_changed($setting)} { 2291 # User-modified UI setting overrides style 2292 set style($setting) $_settings($setting) 2293 } else { 2294 # Set UI control to style setting (tool provided or default) 2295 set _settings($setting) $style($setting) 2296 } 2194 2297 } 2195 2298 … … 2197 2300 SendCmd "cutplane add $tag" 2198 2301 SendCmd "cutplane visible 0 $tag" 2302 foreach axis {x y z} { 2303 set pos [expr $style(-${axis}cutplaneposition) * 0.01] 2304 set visible $style(-${axis}cutplanevisible) 2305 SendCmd "cutplane slice $axis $pos $tag" 2306 SendCmd "cutplane axis $axis $visible $tag" 2307 } 2308 SendCmd "cutplane edges $style(-cutplaneedges) $tag" 2309 SendCmd "cutplane lighting $style(-cutplanelighting) $tag" 2310 SendCmd "cutplane opacity $style(-cutplaneopacity) $tag" 2311 set _widget(-cutplaneopacity) [expr $style(-cutplaneopacity) * 100] 2312 SendCmd "cutplane preinterp $style(-cutplanepreinterp) $tag" 2313 SendCmd "cutplane wireframe $style(-cutplanewireframe) $tag" 2314 SendCmd "cutplane visible $style(-cutplanesvisible) $tag" 2199 2315 } 2200 2316 2201 2317 SendCmd "outline add $tag" 2202 SendCmd "outline color [Color2RGB $ itk_option(-plotforeground)] $tag"2318 SendCmd "outline color [Color2RGB $style(-constcolor)] $tag" 2203 2319 SendCmd "outline visible $style(-outline) $tag" 2204 set _settings(-outline) $style(-outline)2205 2320 2206 2321 SendCmd "glyphs add $style(-shape) $tag" 2207 2322 set _settings(-glyphshape) $style(-shape) 2208 2323 $itk_component(gshape) value $style(-shape) 2324 SendCmd "glyphs visible $style(-glyphsvisible) $tag" 2209 2325 SendCmd "glyphs edges $style(-edges) $tag" 2210 2326 set _settings(-glyphedges) $style(-edges) … … 2220 2336 set _settings(-glyphscale) $style(-gscale) 2221 2337 2338 if {$style(-colormode) == "constant" || $style(-color) == "none"} { 2339 SendCmd "glyphs colormode constant {} $tag" 2340 set _settings(-colormapvisible) 0 2341 set _settings(-colormap) "none" 2342 } else { 2343 SendCmd "glyphs colormode $style(-colormode) $_curFldName $tag" 2344 set _settings(-colormapvisible) 1 2345 set _settings(-colormap) $style(-color) 2346 SetCurrentColormap $style(-color) 2347 } 2348 $itk_component(colormap) value $_settings(-colormap) 2349 set _colorMode $style(-colormode) 2350 2222 2351 # constant color only used if colormode set to constant 2223 SendCmd "glyphs color [Color2RGB $ itk_option(-plotforeground)] $tag"2352 SendCmd "glyphs color [Color2RGB $style(-constcolor)] $tag" 2224 2353 # Omitting field name for gorient and smode commands 2225 2354 # defaults to active scalars or vectors depending on mode … … 2236 2365 SendCmd "glyphs ptsize $style(-ptsize) $tag" 2237 2366 SendCmd "glyphs opacity $style(-opacity) $tag" 2238 set _settings(-glyphopacity) [expr $style(-opacity) * 100.0]2239 SetCurrentColormap $style(-color)2367 set _settings(-glyphopacity) $style(-opacity) 2368 set _widget(-glyphopacity) [expr $style(-opacity) * 100.0] 2240 2369 SendCmd "glyphs wireframe $style(-wireframe) $tag" 2241 2370 set _settings(-glyphwireframe) $style(-wireframe) … … 2452 2581 set x1 [expr $x2 - ($iw*12)/10] 2453 2582 2454 $c bind title <ButtonPress> [itcl::code $this Combopost]2455 $c bind title <Enter> [itcl::code $this Combo activate]2456 $c bind title <Leave> [itcl::code $this Combo deactivate]2583 $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post] 2584 $c bind title <Enter> [itcl::code $this LegendTitleAction enter] 2585 $c bind title <Leave> [itcl::code $this LegendTitleAction leave] 2457 2586 # Reset the item coordinates according the current size of the plot. 2458 2587 $c itemconfigure title -text $title … … 2479 2608 2480 2609 # ---------------------------------------------------------------------- 2481 # USAGE: _dropdown post 2482 # USAGE: _dropdown unpost 2483 # USAGE: _dropdown select 2484 # 2485 # Used internally to handle the dropdown list for this combobox. The 2486 # post/unpost options are invoked when the list is posted or unposted 2487 # to manage the relief of the controlling button. The select option 2488 # is invoked whenever there is a selection from the list, to assign 2489 # the value back to the gauge. 2490 # ---------------------------------------------------------------------- 2491 itcl::body Rappture::VtkGlyphViewer::Combo {option} { 2610 # USAGE: LegendTitleAction post 2611 # USAGE: LegendTitleAction enter 2612 # USAGE: LegendTitleAction leave 2613 # USAGE: LegendTitleAction save 2614 # 2615 # Used internally to handle the dropdown list for the fields menu combobox. 2616 # The post option is invoked when the field title is pressed to launch the 2617 # dropdown. The enter option is invoked when the user mouses over the field 2618 # title. The leave option is invoked when the user moves the mouse away 2619 # from the field title. The save option is invoked whenever there is a 2620 # selection from the list, to alert the visualization server. 2621 # ---------------------------------------------------------------------- 2622 itcl::body Rappture::VtkGlyphViewer::LegendTitleAction {option} { 2492 2623 set c $itk_component(view) 2493 2624 switch -- $option { … … 2501 2632 tk_popup $itk_component(fieldmenu) $x $y 2502 2633 } 2503 activate{2634 enter { 2504 2635 $c itemconfigure title -fill red 2505 2636 } 2506 deactivate {2637 leave { 2507 2638 $c itemconfigure title -fill $itk_option(-plotforeground) 2508 2639 } 2509 invoke {2640 save { 2510 2641 $itk_component(field) value $_curFldLabel 2511 2642 AdjustSetting -field 2512 2643 } 2513 2644 default { 2514 error "bad option \"$option\": should be post, unpost, select"2645 error "bad option \"$option\": should be post, enter, leave or save" 2515 2646 } 2516 2647 } … … 2528 2659 set _currentColormap $name 2529 2660 SendCmd "glyphs colormap $_currentColormap" 2661 #SendCmd "cutplane colormap $_currentColormap" 2530 2662 } 2531 2663 … … 2585 2717 -activeforeground $itk_option(-plotforeground) \ 2586 2718 -font "Arial 8" \ 2587 -command [itcl::code $this Combo invoke]2719 -command [itcl::code $this LegendTitleAction save] 2588 2720 set _fields($fname) [list $label $units $components] 2589 2721 if { $_curFldName == "" } {
Note: See TracChangeset
for help on using the changeset viewer.