Changeset 5055
- Timestamp:
- Mar 3, 2015, 1:28:40 PM (10 years ago)
- Location:
- branches/1.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
- Property svn:mergeinfo changed
/branches/uiuc_vtk_viewers merged: 4952,4954,4991-4992,5032-5033,5049,5051-5053 /trunk merged: 4993,5054
- Property svn:mergeinfo changed
-
branches/1.3/gui/scripts/gauge.tcl
r3739 r5055 42 42 itk_option define -sampleheight sampleHeight SampleHeight 0 43 43 itk_option define -log log Log "" 44 itk_option define -validatecommand validateCommand ValidateCommand "" 44 45 45 46 constructor {args} { # defined below } … … 236 237 } 237 238 real { 238 239 240 241 242 243 239 # "scan" will reject the number if the string is "NaN" or 240 # "Inf" or the empty string. It also is accepts large numbers 241 # (e.g. 111111111111111111111) that "string is double" 242 # rejects. The problem with "scan" is that it doesn't care if 243 # there are extra characters trailing the number (eg. "123a"). 244 # The extra %s substitution is used to detect this case. 244 245 if { [scan $nv "%g%s" dummy1 dummy2] != 1 } { 245 246 error "bad value \"$nv\": should be a real number" … … 288 289 error "maximum value allowed here is $convMaxVal" 289 290 } 291 } 292 293 # 294 # If there's a -validatecommand option, then invoke the code 295 # now to check the new value. 296 # 297 if {[string length $itk_option(-validatecommand)] > 0} { 298 set cmd "uplevel #0 [list $itk_option(-validatecommand) [list $newval]]" 299 set result [eval $cmd] 290 300 } 291 301 -
branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl
r5017 r5055 70 70 private method BuildDownloadPopup { widget command } 71 71 private method BuildIsosurfaceTab {} 72 private method Combo { option }73 72 private method Connect {} 74 73 private method CurrentDatasets {args} 74 private method DisableMouseRotationBindings {} 75 75 private method Disconnect {} 76 76 private method DoChangeContourLevels {} … … 90 90 private method IsValidObject { dataobj } 91 91 private method LeaveLegend {} 92 private method LegendB1Motion {status x y} 93 private method LegendPointToValue { x y } 94 private method LegendProbeSingleContour { x y } 95 private method LegendRangeAction { option args } 96 private method LegendRangeValidate { widget which value } 97 private method LegendTitleAction { option } 92 98 private method MotionLegend { x y } 99 private method MouseOver2Which {} 93 100 private method Pan {option x y} 94 101 private method PanCamera {} … … 106 113 private method SetCurrentFieldName { dataobj } 107 114 private method SetLegendTip { x y } 115 private method SetMinMaxGauges { min max } 108 116 private method SetObjectStyle { dataobj comp } 109 117 private method SetOrientation { side } 118 private method SetupMouseRotationBindings {} 119 private method SetupMousePanningBindings {} 120 private method SetupKeyboardBindings {} 110 121 private method Slice {option args} 122 private method ToggleCustomRange { args } 111 123 private method ViewToQuaternion {} { 112 124 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] … … 162 174 private variable _curFldName "" 163 175 private variable _curFldLabel "" 176 177 private variable _mouseOver ""; # what called LegendRangeAction, vmin or vmax 178 private variable _customRangeClick 1; # what called ToggleCustomRange 164 179 } 165 180 … … 247 262 -colormap BCGYR 248 263 -colormapvisible 1 264 -customrange 0 265 -customrangemin 0 266 -customrangemax 1 249 267 -cutplaneedges 0 250 268 -cutplanelighting 1 … … 299 317 ignore -background -foreground -relief -tearoff 300 318 } 319 320 # add an editor for adjusting the legend min and max values 321 itk_component add editor { 322 Rappture::Editor $itk_interior.editor \ 323 -activatecommand [itcl::code $this LegendRangeAction activate] \ 324 -validatecommand [itcl::code $this LegendRangeAction validate] \ 325 -applycommand [itcl::code $this LegendRangeAction apply] 326 } 327 301 328 set c $itk_component(view) 302 329 bind $c <Configure> [itcl::code $this EventuallyResize %w %h] … … 409 436 blt::table configure $itk_component(plotarea) c1 -resize none 410 437 438 SetupMouseRotationBindings 439 SetupMousePanningBindings 440 SetupKeyboardBindings 441 442 443 #bind $itk_component(view) <ButtonRelease-3> \ 444 # [itcl::code $this Pick %x %y] 445 446 447 if {[string equal "x11" [tk windowingsystem]]} { 448 # Bindings for zoom via mouse 449 bind $itk_component(view) <4> [itcl::code $this Zoom out] 450 bind $itk_component(view) <5> [itcl::code $this Zoom in] 451 } 452 453 set _image(download) [image create photo] 454 455 eval itk_initialize $args 456 457 EnableWaitDialog 500 458 Connect 459 # FIXME: Removing this update breaks wizard mode (see examples/3D) 460 # However, it also allows an error in the initialization order 461 # where FieldResult::add is called from ResultViewer before this 462 # constructor is completed. 463 #update 464 } 465 466 # ---------------------------------------------------------------------- 467 # DESTRUCTOR 468 # ---------------------------------------------------------------------- 469 itcl::body Rappture::VtkIsosurfaceViewer::destructor {} { 470 Disconnect 471 image delete $_image(plot) 472 image delete $_image(download) 473 catch { blt::arcball destroy $_arcball } 474 } 475 476 itcl::body Rappture::VtkIsosurfaceViewer::SetupMouseRotationBindings {} { 411 477 # Bindings for rotation via mouse 412 478 bind $itk_component(view) <ButtonPress-1> \ … … 416 482 bind $itk_component(view) <ButtonRelease-1> \ 417 483 [itcl::code $this Rotate release %x %y] 418 484 } 485 486 itcl::body Rappture::VtkIsosurfaceViewer::DisableMouseRotationBindings {} { 487 # Bindings for rotation via mouse 488 bind $itk_component(view) <ButtonPress-1> "" 489 bind $itk_component(view) <B1-Motion> "" 490 bind $itk_component(view) <ButtonRelease-1> "" 491 } 492 493 itcl::body Rappture::VtkIsosurfaceViewer::SetupMousePanningBindings {} { 419 494 # Bindings for panning via mouse 420 495 bind $itk_component(view) <ButtonPress-2> \ … … 424 499 bind $itk_component(view) <ButtonRelease-2> \ 425 500 [itcl::code $this Pan release %x %y] 426 427 #bind $itk_component(view) <ButtonRelease-3> \ 428 # [itcl::code $this Pick %x %y] 429 501 } 502 503 itcl::body Rappture::VtkIsosurfaceViewer::SetupKeyboardBindings {} { 430 504 # Bindings for panning via keyboard 431 505 bind $itk_component(view) <KeyPress-Left> \ … … 453 527 454 528 bind $itk_component(view) <Enter> "focus $itk_component(view)" 455 456 if {[string equal "x11" [tk windowingsystem]]} {457 # Bindings for zoom via mouse458 bind $itk_component(view) <4> [itcl::code $this Zoom out]459 bind $itk_component(view) <5> [itcl::code $this Zoom in]460 }461 462 set _image(download) [image create photo]463 464 eval itk_initialize $args465 466 EnableWaitDialog 500467 Connect468 }469 470 # ----------------------------------------------------------------------471 # DESTRUCTOR472 # ----------------------------------------------------------------------473 itcl::body Rappture::VtkIsosurfaceViewer::destructor {} {474 Disconnect475 image delete $_image(plot)476 image delete $_image(download)477 catch { blt::arcball destroy $_arcball }478 529 } 479 530 … … 725 776 if { ![info exists _limits($fname)] } { 726 777 set _limits($fname) $lim 778 779 # set reasonable defaults for 780 # customrangevmin and customrangevmax 781 foreach {min max} $lim break 782 SetMinMaxGauges $min $max 783 set _settings(-customrangemin) $min 784 set _settings(-customrangemax) $max 785 727 786 continue 728 787 } 729 788 foreach {min max} $lim break 730 789 foreach {fmin fmax} $_limits($fname) break 790 if { ! $_settings(-customrange) } { 791 SetMinMaxGauges $fmin $fmax 792 } 731 793 if { $fmin > $min } { 732 794 set fmin $min … … 1055 1117 -isosurfacelighting \ 1056 1118 -field \ 1119 -range \ 1057 1120 -isosurfacevisible \ 1058 1121 -isosurfaceedges -isosurfacelighting -isosurfaceopacity \ … … 1429 1492 SendCmd "dataset maprange all" 1430 1493 } else { 1431 SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" 1494 if { $_settings(-customrange) } { 1495 set vmin [$itk_component(min) value] 1496 set vmax [$itk_component(max) value] 1497 } else { 1498 foreach { vmin vmax } $_limits($_curFldName) break 1499 # set the min / max gauges with limits from the field 1500 # the legend's min and max text will be updated 1501 # when the legend is redrawn in DrawLegend 1502 SetMinMaxGauges $vmin $vmax 1503 } 1504 SendCmd "dataset maprange explicit $vmin $vmax $_curFldName" 1432 1505 } 1433 1506 SendCmd "cutplane colormode $_colorMode $_curFldName" … … 1503 1576 } 1504 1577 } 1578 } 1579 "-range" { 1580 if { $_settings(-customrange) } { 1581 set vmin [$itk_component(min) value] 1582 set vmax [$itk_component(max) value] 1583 } else { 1584 foreach { vmin vmax } $_limits($_curFldName) break 1585 } 1586 GenerateContourList 1587 SendCmd [list contour3d contourlist $_contourList(values)] 1588 SendCmd "dataset maprange explicit $vmin $vmax $_curFldName" 1589 DrawLegend 1505 1590 } 1506 1591 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { … … 1575 1660 incr h -$lineht 1576 1661 } 1577 # Set the legend on the first heightmapdataset.1662 # Set the legend on the first isosurface dataset. 1578 1663 if { $_currentColormap != "" } { 1579 1664 set cmap $_currentColormap … … 1720 1805 bind $itk_component(numcontours) <<Value>> \ 1721 1806 [itcl::code $this AdjustSetting -numcontours] 1807 1808 1809 # add widgets for setting a custom range on the legend 1810 1811 itk_component add crange { 1812 checkbutton $inner.crange \ 1813 -text "Use Custom Range:" \ 1814 -variable [itcl::scope _settings(-customrange)] \ 1815 -command [itcl::code $this ToggleCustomRange] \ 1816 -font "Arial 9" 1817 } 1818 1819 itk_component add l_min { 1820 label $inner.l_min -text "Min" -font "Arial 9" 1821 } 1822 itk_component add min { 1823 Rappture::Gauge $inner.min \ 1824 -validatecommand [itcl::code $this LegendRangeValidate "" vmin] 1825 } 1826 bind $itk_component(min) <<Value>> \ 1827 [itcl::code $this AdjustSetting -range] 1828 1829 itk_component add l_max { 1830 label $inner.l_max -text "Max" -font "Arial 9" 1831 } 1832 itk_component add max { 1833 Rappture::Gauge $inner.max \ 1834 -validatecommand [itcl::code $this LegendRangeValidate "" vmax] 1835 } 1836 bind $itk_component(max) <<Value>> \ 1837 [itcl::code $this AdjustSetting -range] 1838 1839 $itk_component(min) configure -state disabled 1840 $itk_component(max) configure -state disabled 1841 1722 1842 1723 1843 blt::table $inner \ … … 1739 1859 10,0 $inner.opacity_l -anchor w -pady 2 \ 1740 1860 10,1 $inner.opacity -fill x -pady 2 -fill x \ 1861 11,0 $inner.crange -anchor w -pady 2 -cspan 2 \ 1862 12,0 $inner.l_min -anchor w -pady 2 \ 1863 12,1 $inner.min -anchor w -pady 2 -fill x \ 1864 13,0 $inner.l_max -anchor w -pady 2 \ 1865 13,1 $inner.max -anchor w -pady 2 -fill x \ 1741 1866 1742 1867 blt::table configure $inner r* c* -resize none 1743 blt::table configure $inner r1 1c1 -resize expand1868 blt::table configure $inner r14 c1 -resize expand 1744 1869 } 1745 1870 … … 2262 2387 } 2263 2388 2389 # ---------------------------------------------------------------------- 2390 # USAGE: LegendB1Motion press <x> <y> 2391 # USAGE: LegendB1Motion motion <x> <y> 2392 # USAGE: LegendB1Motion release <x> <y> 2393 # 2394 # Manage actions for Button 1 presses that happen over the legend. 2395 # Pressing mouse Button 1 on the legend sends a command to the 2396 # visualization server to show a specific isosurface. 2397 # ---------------------------------------------------------------------- 2398 itcl::body Rappture::VtkIsosurfaceViewer::LegendB1Motion { status x y } { 2399 2400 switch -- $status { 2401 "press" { 2402 DisableMouseRotationBindings 2403 LegendProbeSingleContour $x $y 2404 } 2405 "motion" { 2406 DisableMouseRotationBindings 2407 LegendProbeSingleContour $x $y 2408 } 2409 "release" { 2410 AdjustSetting -range 2411 SetupMouseRotationBindings 2412 } 2413 default { 2414 error "bad option \"$option\": should be one of press, motion, release." 2415 } 2416 } 2417 } 2418 2419 2420 # ---------------------------------------------------------------------- 2421 # USAGE: LegendPointToValue <x> <y> 2422 # 2423 # Convert an x,y point on the legend to a numeric isosurface value. 2424 # ---------------------------------------------------------------------- 2425 itcl::body Rappture::VtkIsosurfaceViewer::LegendPointToValue { x y } { 2426 2427 set fname $_curFldName 2428 2429 set font "Arial 8" 2430 set lineht [font metrics $font -linespace] 2431 2432 set ih [image height $_image(legend)] 2433 set iy [expr $y - ($lineht + 2)] 2434 2435 # Compute the value of the point 2436 if { [info exists _limits($fname)] } { 2437 if { $_settings(-customrange) } { 2438 set vmin [$itk_component(min) value] 2439 set vmax [$itk_component(max) value] 2440 } else { 2441 foreach { vmin vmax } $_limits($fname) break 2442 } 2443 set t [expr 1.0 - (double($iy) / double($ih-1))] 2444 set value [expr $t * ($vmax - $vmin) + $vmin] 2445 } else { 2446 set value 0.0 2447 } 2448 return $value 2449 } 2450 2451 2452 # ---------------------------------------------------------------------- 2453 # USAGE: LegendProbeSingleContour <x> <y> 2454 # 2455 # Calculate the isosurface value for the x,y point and send a commands 2456 # to the visualization server to show that isosurface. 2457 # ---------------------------------------------------------------------- 2458 itcl::body Rappture::VtkIsosurfaceViewer::LegendProbeSingleContour { x y } { 2459 2460 set value [LegendPointToValue $x $y] 2461 SendCmd [list contour3d contourlist $value] 2462 } 2463 2464 2264 2465 # 2265 2466 # SetLegendTip -- … … 2306 2507 2307 2508 # Compute the value of the point 2308 if { [info exists _limits($_curFldName)] } { 2309 foreach { vmin vmax } $_limits($_curFldName) break 2310 set t [expr 1.0 - (double($iy) / double($ih-1))] 2311 set value [expr $t * ($vmax - $vmin) + $vmin] 2312 } else { 2313 set value 0.0 2314 } 2509 set value [LegendPointToValue $x $y] 2510 2511 # Setup the location of the tooltip 2315 2512 set tx [expr $x + 15] 2316 2513 set ty [expr $y - 5] 2514 2515 # Setup the text for the tooltip 2317 2516 if { [info exists _isolines($y)] } { 2318 2517 Rappture::Tooltip::text $c [format "$title %g (isosurface)" $_isolines($y)] … … 2320 2519 Rappture::Tooltip::text $c [format "$title %g" $value] 2321 2520 } 2521 2522 # Show the tooltip 2322 2523 Rappture::Tooltip::tooltip show $c +$tx,+$ty 2323 2524 } … … 2361 2562 # 2362 2563 itcl::body Rappture::VtkIsosurfaceViewer::ReceiveLegend { colormap title min max size } { 2363 # puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size"2564 # puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size" 2364 2565 set _title $title 2365 2566 regsub {\(mag\)} $title "" _title … … 2381 2582 # DrawLegend -- 2382 2583 # 2383 # Draws the legend in the owncanvas on the right side of the plot area.2584 # Draws the legend on the canvas on the right side of the plot area. 2384 2585 # 2385 2586 itcl::body Rappture::VtkIsosurfaceViewer::DrawLegend {} { … … 2435 2636 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2436 2637 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2638 # $c bind sensor <ButtonPress-1> [itcl::code $this LegendB1Motion press %x %y] 2639 # $c bind sensor <B1-Motion> [itcl::code $this LegendB1Motion motion %x %y] 2640 # $c bind sensor <ButtonRelease-1> [itcl::code $this LegendB1Motion release %x %y] 2641 2437 2642 } 2438 2643 $c delete isoline … … 2447 2652 $_settings(-numcontours) > 0 } { 2448 2653 2449 foreach { vmin vmax } $_limits($_curFldName) break 2654 if { $_settings(-customrange) } { 2655 set vmin [$itk_component(min) value] 2656 set vmax [$itk_component(max) value] 2657 } else { 2658 foreach { vmin vmax } $_limits($_curFldName) break 2659 } 2450 2660 set range [expr double($vmax - $vmin)] 2451 2661 if { $range <= 0.0 } { … … 2468 2678 } 2469 2679 2470 $c bind title <ButtonPress> [itcl::code $this Combopost]2471 $c bind title <Enter> [itcl::code $this Combo activate]2472 $c bind title <Leave> [itcl::code $this Combo deactivate]2680 $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post] 2681 $c bind title <Enter> [itcl::code $this LegendTitleAction enter] 2682 $c bind title <Leave> [itcl::code $this LegendTitleAction leave] 2473 2683 # Reset the item coordinates according the current size of the plot. 2474 2684 $c itemconfigure title -text $title 2475 2685 if { [info exists _limits($_curFldName)] } { 2476 foreach { vmin vmax } $_limits($_curFldName) break 2686 if { $_settings(-customrange) } { 2687 set vmin [$itk_component(min) value] 2688 set vmax [$itk_component(max) value] 2689 } else { 2690 foreach { vmin vmax } $_limits($_curFldName) break 2691 } 2477 2692 $c itemconfigure vmin -text [format %g $vmin] 2478 2693 $c itemconfigure vmax -text [format %g $vmax] … … 2492 2707 $c raise sensor 2493 2708 $c coords vmin $x [expr {$h - 2}] 2494 } 2495 2496 # ---------------------------------------------------------------------- 2497 # USAGE: _dropdown post 2498 # USAGE: _dropdown unpost 2499 # USAGE: _dropdown select 2500 # 2501 # Used internally to handle the dropdown list for this combobox. The 2502 # post/unpost options are invoked when the list is posted or unposted 2503 # to manage the relief of the controlling button. The select option 2504 # is invoked whenever there is a selection from the list, to assign 2505 # the value back to the gauge. 2506 # ---------------------------------------------------------------------- 2507 itcl::body Rappture::VtkIsosurfaceViewer::Combo {option} { 2709 2710 $c bind vmin <ButtonPress> [itcl::code $this LegendRangeAction popup vmin] 2711 $c bind vmin <Enter> [itcl::code $this LegendRangeAction enter vmin] 2712 $c bind vmin <Leave> [itcl::code $this LegendRangeAction leave vmin] 2713 2714 $c bind vmax <ButtonPress> [itcl::code $this LegendRangeAction popup vmax] 2715 $c bind vmax <Enter> [itcl::code $this LegendRangeAction enter vmax] 2716 $c bind vmax <Leave> [itcl::code $this LegendRangeAction leave vmax] 2717 } 2718 2719 # ---------------------------------------------------------------------- 2720 # USAGE: LegendTitleAction post 2721 # USAGE: LegendTitleAction enter 2722 # USAGE: LegendTitleAction leave 2723 # USAGE: LegendTitleAction save 2724 # 2725 # Used internally to handle the dropdown list for the fields menu combobox. 2726 # The post option is invoked when the field title is pressed to launch the 2727 # dropdown. The enter option is invoked when the user mouses over the field 2728 # title. The leave option is invoked when the user moves the mouse away 2729 # from the field title. The save option is invoked whenever there is a 2730 # selection from the list, to alert the visualization server. 2731 # 2732 # ---------------------------------------------------------------------- 2733 itcl::body Rappture::VtkIsosurfaceViewer::LegendTitleAction {option} { 2508 2734 set c $itk_component(view) 2509 2735 switch -- $option { … … 2517 2743 tk_popup $itk_component(fieldmenu) $x $y 2518 2744 } 2519 activate{2745 enter { 2520 2746 $c itemconfigure title -fill red 2521 2747 } 2522 deactivate {2748 leave { 2523 2749 $c itemconfigure title -fill $itk_option(-plotforeground) 2524 2750 } 2525 invoke {2751 save { 2526 2752 $itk_component(field) value $_curFldLabel 2527 2753 AdjustSetting -field 2528 2754 } 2529 2755 default { 2530 error "bad option \"$option\": should be post, unpost, select" 2531 } 2532 } 2533 } 2756 error "bad option \"$option\": should be post, enter, leave, save" 2757 } 2758 } 2759 } 2760 2761 # ---------------------------------------------------------------------- 2762 # USAGE: LegendRangeValidate <widget> <which> <value> 2763 # 2764 # Used internally to validate a legend range min/max value. 2765 # Returns a boolean value telling if <value> was accepted (1) or rejected (0) 2766 # If the value is rejected, a tooltip/warning message is popped up 2767 # near the widget that asked for the validation, specified by <widget> 2768 # 2769 # <widget> is the widget where a tooltip/warning message should show up on 2770 # <which> is either "vmin" or "vmax". 2771 # <value> is the value to be validated. 2772 # 2773 # ---------------------------------------------------------------------- 2774 itcl::body Rappture::VtkIsosurfaceViewer::LegendRangeValidate {widget which value} { 2775 2776 #check for a valid value 2777 if {[string is double $value] != 1} { 2778 set msg "should be valid number" 2779 if {$widget != ""} { 2780 Rappture::Tooltip::cue $widget $msg 2781 } else { 2782 # error "bad value \"$value\": $msg" 2783 error $msg 2784 } 2785 return 0 2786 } 2787 2788 switch -- $which { 2789 vmin { 2790 # check for min > max 2791 if {$value > [$itk_component(max) value]} { 2792 set msg "min > max, change max first" 2793 if {$widget != ""} { 2794 Rappture::Tooltip::cue $widget $msg 2795 } else { 2796 # error "bad value \"$value\": $msg" 2797 error $msg 2798 } 2799 return 0 2800 } 2801 } 2802 vmax { 2803 # check for max < min 2804 if {$value < [$itk_component(min) value]} { 2805 set msg "max < min, change min first" 2806 if {$widget != ""} { 2807 Rappture::Tooltip::cue $widget $msg 2808 } else { 2809 # error "bad value \"$value\": $msg" 2810 error $msg 2811 } 2812 return 0 2813 } 2814 } 2815 default { 2816 error "bad option \"$which\": should be vmin, vmax" 2817 } 2818 } 2819 } 2820 2821 2822 itcl::body Rappture::VtkIsosurfaceViewer::MouseOver2Which {} { 2823 switch -- $_mouseOver { 2824 vmin { 2825 set which min 2826 } 2827 vmax { 2828 set which max 2829 } 2830 default { 2831 error "bad _mouseOver \"$_mouseOver\": should be vmin, vmax" 2832 } 2833 } 2834 return $which 2835 } 2836 2837 2838 # ---------------------------------------------------------------------- 2839 # USAGE: LegendRangeAction enter <which> 2840 # USAGE: LegendRangeAction leave <which> 2841 # 2842 # USAGE: LegendRangeAction popup <which> 2843 # USAGE: LegendRangeAction activate 2844 # USAGE: LegendRangeAction validate <value> 2845 # USAGE: LegendRangeAction apply <value> 2846 # 2847 # Used internally to handle the mouseover and popup entry for the field range 2848 # inputs. The enter option is invoked when the user moves the mouse over the 2849 # min or max field range. The leave option is invoked when the user moves the 2850 # mouse away from the min or max field range. The popup option is invoked when 2851 # the user click's on a field range. The popup option stores internally which 2852 # widget is requesting a popup ( in the _mouseOver variable) and calls the 2853 # activate command of the widget. The widget's activate command calls back to 2854 # this method to get the xywh dimensions of the popup editor. After the user 2855 # changes focus or sets the value in the editor, the editor calls this methods 2856 # validate and apply options to set the value. 2857 # 2858 # ---------------------------------------------------------------------- 2859 itcl::body Rappture::VtkIsosurfaceViewer::LegendRangeAction {option args} { 2860 set c $itk_component(view) 2861 2862 switch -- $option { 2863 enter { 2864 set which [lindex $args 0] 2865 $c itemconfigure $which -fill red 2866 } 2867 leave { 2868 set which [lindex $args 0] 2869 $c itemconfigure $which -fill $itk_option(-plotforeground) 2870 } 2871 popup { 2872 DisableMouseRotationBindings 2873 set which [lindex $args 0] 2874 set _mouseOver $which 2875 $itk_component(editor) activate 2876 } 2877 activate { 2878 foreach { x1 y1 x2 y2 } [$c bbox $_mouseOver] break 2879 set which [MouseOver2Which] 2880 set info(text) [$itk_component($which) value] 2881 set info(x) [expr $x1 + [winfo rootx $c]] 2882 set info(y) [expr $y1 + [winfo rooty $c]] 2883 set info(w) [expr $x2 - $x1] 2884 set info(h) [expr $y2 - $y1] 2885 return [array get info] 2886 } 2887 validate { 2888 if {[llength $args] != 1} { 2889 error "wrong # args: should be \"editor validate value\"" 2890 } 2891 2892 set value [lindex $args 0] 2893 if {[LegendRangeValidate $itk_component(editor) $_mouseOver $value] == 0} { 2894 return 0 2895 } 2896 2897 # value was good, apply it 2898 # reset the mouse rotation bindings 2899 SetupMouseRotationBindings 2900 } 2901 apply { 2902 if {[llength $args] != 1} { 2903 error "wrong # args: should be \"editor apply value\"" 2904 } 2905 set value [string trim [lindex $args 0]] 2906 2907 set which [MouseOver2Which] 2908 2909 # only set custom range if value changed 2910 if {[$itk_component($which) value] != $value} { 2911 # set the flag stating the custom range came from the legend 2912 # change the value in the gauge 2913 # turn on crange to enable the labels and gauges 2914 # call AdjustSetting -range (inside ToggleCustomRange) 2915 # to update drawing and legend 2916 set _customRangeClick 0 2917 $itk_component($which) value $value 2918 $itk_component(crange) select 2919 ToggleCustomRange 2920 } 2921 } 2922 default { 2923 error "bad option \"$option\": should be enter, leave, activate, validate, apply" 2924 } 2925 } 2926 } 2927 2928 2929 # ---------------------------------------------------------------------- 2930 # USAGE: ToggleCustomRange 2931 # 2932 # Called whenever the custom range is turned on or off. Used to save 2933 # the custom min and custom max set by the user. When the -customrange 2934 # setting is turned on, the range min and range max gauges are set 2935 # with the last value set by the user, or the default range if no 2936 # previous min and max were set. 2937 # 2938 # When the custom range is turned on, we check how it was turned on 2939 # by querying _customRangeClick. If the variable is 1, this means 2940 # the user clicked the crange checkbutton and we should pull the 2941 # custom range values from our backup variables. If the variable is 0, 2942 # the custom range was enabled through the user manipulating the 2943 # min and max value in the legend. 2944 # 2945 # ---------------------------------------------------------------------- 2946 itcl::body Rappture::VtkIsosurfaceViewer::ToggleCustomRange {args} { 2947 if { ! $_settings(-customrange) } { 2948 # custom range was turned off 2949 2950 # disable the min/max labels and gauge widgets 2951 $itk_component(l_min) configure -state disabled 2952 $itk_component(min) configure -state disabled 2953 $itk_component(l_max) configure -state disabled 2954 $itk_component(max) configure -state disabled 2955 2956 # backup the custom range 2957 set _settings(-customrangemin) [$itk_component(min) value] 2958 set _settings(-customrangemax) [$itk_component(max) value] 2959 2960 # set the gauges to dataset's min and max 2961 foreach { vmin vmax } $_limits($_curFldName) break 2962 SetMinMaxGauges $vmin $vmax 2963 } else { 2964 # custom range was turned on 2965 2966 # enable the min/max labels and gauge widgets 2967 $itk_component(l_min) configure -state normal 2968 $itk_component(min) configure -state normal 2969 $itk_component(l_max) configure -state normal 2970 $itk_component(max) configure -state normal 2971 2972 # if the custom range is being turned on by clicking the 2973 # checkbox, restore the min and max gauges from the backup 2974 # variables. otherwise, new values for the min and max 2975 # widgets will be set later from the legend's editor. 2976 if { $_customRangeClick } { 2977 SetMinMaxGauges $_settings(-customrangemin) $_settings(-customrangemax) 2978 } 2979 2980 # reset the click flag 2981 set _customRangeClick 1 2982 } 2983 AdjustSetting -range 2984 } 2985 2986 2987 # ---------------------------------------------------------------------- 2988 # USAGE: SetMinMaxGauges <min> <max> 2989 # 2990 # Set the min and max gauges in the correct order, avoiding the 2991 # error where you try to set the min > max before updating the max or 2992 # set the max < min before updating the min. 2993 # 2994 # There are five range cases to consider with our current range validation. 2995 # For example: 2996 # [2,3] -> [0,1] : update min first, max last 2997 # [2,3] -> [4,5] : update max first, min last 2998 # [2,3] -> [0,2.5] : update min or max first 2999 # [2,3] -> [2.5,5] : update min or max first 3000 # [2,3] -> [2.25,2.75] : update min or max first 3001 # 3002 # In 4 of the cases we can update min first and max last, so we only 3003 # need to check the case where old max < new min, where we update 3004 # max first and min last. 3005 # ---------------------------------------------------------------------- 3006 itcl::body Rappture::VtkIsosurfaceViewer::SetMinMaxGauges {min max} { 3007 3008 if { [$itk_component(max) value] < $min} { 3009 # old max < new min 3010 # shift range toward right 3011 # extend max first, then update min 3012 $itk_component(max) value $max 3013 $itk_component(min) value $min 3014 } else { 3015 # extend min first, then update max 3016 $itk_component(min) value $min 3017 $itk_component(max) value $max 3018 } 3019 } 3020 2534 3021 2535 3022 # … … 2595 3082 set values $_contourList(reqValues) 2596 3083 } else { 3084 # use the field limits to calculate the contour list values 2597 3085 foreach { vmin vmax } $_limits($_curFldName) break 3086 3087 # if custom range has been set and are within the field's 3088 # range, use the custom min and max to generate contour list values 3089 if { $_settings(-customrange) } { 3090 if { [$itk_component(min) value] > $vmin } { 3091 set vmin [$itk_component(min) value] 3092 } 3093 if { [$itk_component(max) value] < $vmax } { 3094 set vmax [$itk_component(max) value] 3095 } 3096 } 3097 2598 3098 set v [blt::vector create \#auto] 2599 3099 $v seq $vmin $vmax [expr $_contourList(numLevels)+2] … … 2625 3125 -activeforeground $itk_option(-plotforeground) \ 2626 3126 -font "Arial 8" \ 2627 -command [itcl::code $this Combo invoke]3127 -command [itcl::code $this LegendTitleAction save] 2628 3128 set _fields($fname) [list $label $units $components] 2629 3129 if { $_curFldName == "" } {
Note: See TracChangeset
for help on using the changeset viewer.