Changeset 5033
- Timestamp:
- Feb 19, 2015, 8:33:41 AM (10 years ago)
- Location:
- branches/uiuc_vtk_viewers/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uiuc_vtk_viewers/gui/scripts/gauge.tcl
r5032 r5033 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 } … … 290 291 } 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] 300 } 301 292 302 if {$onlycheck} { 293 303 return -
branches/uiuc_vtk_viewers/gui/scripts/vtkisosurfaceviewer.tcl
r4992 r5033 94 94 private method LegendProbeSingleContour { x y } 95 95 private method LegendRangeAction { option args } 96 private method LegendRangeValidate { widget which value } 96 97 private method LegendTitleAction { option } 97 98 private method MotionLegend { x y } 99 private method MouseOver2Which {} 98 100 private method Pan {option x y} 99 101 private method PanCamera {} … … 258 260 -colormapvisible 1 259 261 -customrange 0 260 -customrangevmin 0261 -customrangevmax 1262 262 -cutplaneedges 0 263 263 -cutplanelighting 1 … … 775 775 # customrangevmin and customrangevmax 776 776 foreach {min max} $lim break 777 if { ![info exists _settings(-customrangevmin)] } { 778 set _settings(-customrangevmin) $min 779 } 780 if { ![info exists _settings(-customrangevmax)] } { 781 set _settings(-customrangevmax) $max 782 } 777 $itk_component(min) value $min 778 $itk_component(max) value $max 783 779 784 780 continue … … 786 782 foreach {min max} $lim break 787 783 foreach {fmin fmax} $_limits($fname) break 788 # if { $fname == $_curFldName && ! $_settings(-customrange) } {}789 784 if { ! $_settings(-customrange) } { 790 set _settings(-customrangevmin)$fmin791 set _settings(-customrangevmax)$fmax785 $itk_component(min) value $fmin 786 $itk_component(max) value $fmax 792 787 } 793 788 if { $fmin > $min } { … … 1493 1488 foreach { vmin vmax } $_limits($_curFldName) break 1494 1489 if { $_settings(-customrange) } { 1495 if { $_settings(-customrangevmin)> $vmin } {1496 set vmin $_settings(-customrangevmin)1490 if { [$itk_component(min) value] > $vmin } { 1491 set vmin [$itk_component(min) value] 1497 1492 } 1498 if { $_settings(-customrangevmax)< $vmax } {1499 set vmax $_settings(-customrangevmax)1493 if { [$itk_component(max) value] < $vmax } { 1494 set vmax [$itk_component(max) value] 1500 1495 } 1501 1496 } … … 1582 1577 $itk_component(l_max) configure -state normal 1583 1578 $itk_component(max) configure -state normal 1584 # foreach { vmin vmax } $_limits($_curFldName) break 1585 # if { $_settings(-customrangevmin) < $vmin } { 1586 # set _settings(-customrangevmin) $vmin 1587 # } 1588 # if { $_settings(-customrangevmin) > $vmax } { 1589 # set _settings(-customrangevmin) $vmax 1590 # } 1591 # if { $_settings(-customrangevmax) < $vmin } { 1592 # set _settings(-customrangevmax) $vmin 1593 # } 1594 # if { $_settings(-customrangevmax) > $vmax } { 1595 # set _settings(-customrangevmax) $vmax 1596 # } 1597 # 1598 if { $_settings(-customrangevmin) > $vmin } { 1599 set vmin $_settings(-customrangevmin) 1600 } 1601 if { $_settings(-customrangevmax) < $vmax } { 1602 set vmax $_settings(-customrangevmax) 1579 if { [$itk_component(min) value] > $vmin } { 1580 set vmin [$itk_component(min) value] 1581 } 1582 if { [$itk_component(max) value] < $vmax } { 1583 set vmax [$itk_component(max) value] 1603 1584 } 1604 1585 } else { … … 1845 1826 } 1846 1827 itk_component add min { 1847 entry $inner.min -font "Arial 9" -bg white \ 1848 -textvariable [itcl::scope _settings(-customrangevmin)] 1849 } { 1850 ignore -font -background 1851 } 1852 bind $inner.min <Return> \ 1853 [itcl::code $this AdjustSetting -range] 1854 bind $inner.min <KP_Enter> \ 1828 Rappture::Gauge $inner.min \ 1829 -validatecommand [itcl::code $this LegendRangeValidate "" vmin] 1830 } 1831 bind $itk_component(min) <<Value>> \ 1855 1832 [itcl::code $this AdjustSetting -range] 1856 1833 … … 1859 1836 } 1860 1837 itk_component add max { 1861 entry $inner.max -font "Arial 9" -bg white \ 1862 -textvariable [itcl::scope _settings(-customrangevmax)] 1863 } { 1864 ignore -font -background 1865 } 1866 bind $inner.max <Return> \ 1867 [itcl::code $this AdjustSetting -range] 1868 bind $inner.max <KP_Enter> \ 1838 Rappture::Gauge $inner.max \ 1839 -validatecommand [itcl::code $this LegendRangeValidate "" vmax] 1840 } 1841 bind $itk_component(max) <<Value>> \ 1869 1842 [itcl::code $this AdjustSetting -range] 1870 1843 … … 2468 2441 if { [info exists _limits($fname)] } { 2469 2442 if { $_settings(-customrange) } { 2470 set vmin $_settings(-customrangevmin)2471 set vmax $_settings(-customrangevmax)2443 set vmin [$itk_component(min) value] 2444 set vmax [$itk_component(max) value] 2472 2445 } else { 2473 2446 foreach { vmin vmax } $_limits($fname) break … … 2685 2658 2686 2659 if { $_settings(-customrange) } { 2687 set vmin $_settings(-customrangevmin)2688 set vmax $_settings(-customrangevmax)2660 set vmin [$itk_component(min) value] 2661 set vmax [$itk_component(max) value] 2689 2662 } else { 2690 2663 foreach { vmin vmax } $_limits($_curFldName) break … … 2717 2690 if { [info exists _limits($_curFldName)] } { 2718 2691 if { $_settings(-customrange) } { 2719 set vmin $_settings(-customrangevmin)2720 set vmax $_settings(-customrangevmax)2692 set vmin [$itk_component(min) value] 2693 set vmax [$itk_component(max) value] 2721 2694 } else { 2722 2695 foreach { vmin vmax } $_limits($_curFldName) break … … 2792 2765 2793 2766 # ---------------------------------------------------------------------- 2767 # USAGE: LegendRangeValidate <widget> <which> <value> 2768 # 2769 # Used internally to validate a legend range min/max value. 2770 # Returns a boolean value telling if <value> was accepted (1) or rejected (0) 2771 # If the value is rejected, a tooltip/warning message is popped up 2772 # near the widget that asked for the validation, specified by <widget> 2773 # 2774 # <widget> is the widget where a tooltip/warning message should show up on 2775 # <which> is either "vmin" or "vmax". 2776 # <value> is the value to be validated. 2777 # 2778 # ---------------------------------------------------------------------- 2779 itcl::body Rappture::VtkIsosurfaceViewer::LegendRangeValidate {widget which value} { 2780 2781 #check for a valid value 2782 if {[string is double $value] != 1} { 2783 set msg "should be valid number" 2784 if {$widget != ""} { 2785 Rappture::Tooltip::cue $widget $msg 2786 } else { 2787 # error "bad value \"$value\": $msg" 2788 error $msg 2789 } 2790 return 0 2791 } 2792 2793 switch -- $which { 2794 vmin { 2795 # check for min > max 2796 if {$value > [$itk_component(max) value]} { 2797 set msg "min > max, change max first" 2798 if {$widget != ""} { 2799 Rappture::Tooltip::cue $widget $msg 2800 } else { 2801 # error "bad value \"$value\": $msg" 2802 error $msg 2803 } 2804 return 0 2805 } 2806 } 2807 vmax { 2808 # check for max < min 2809 if {$value < [$itk_component(min) value]} { 2810 set msg "max < min, change min first" 2811 if {$widget != ""} { 2812 Rappture::Tooltip::cue $widget $msg 2813 } else { 2814 # error "bad value \"$value\": $msg" 2815 error $msg 2816 } 2817 return 0 2818 } 2819 } 2820 default { 2821 error "bad option \"$which\": should be vmin, vmax" 2822 } 2823 } 2824 } 2825 2826 2827 itcl::body Rappture::VtkIsosurfaceViewer::MouseOver2Which {} { 2828 switch -- $_mouseOver { 2829 vmin { 2830 set which min 2831 } 2832 vmax { 2833 set which max 2834 } 2835 default { 2836 error "bad _mouseOver \"$_mouseOver\": should be vmin, vmax" 2837 } 2838 } 2839 return $which 2840 } 2841 2842 2843 # ---------------------------------------------------------------------- 2794 2844 # USAGE: LegendRangeAction enter <which> 2795 2845 # USAGE: LegendRangeAction leave <which> 2796 2846 # 2797 # USAGE: Legend TitleAction popup <which>2798 # USAGE: Legend TitleAction activate2799 # USAGE: Legend TitleAction validate <value>2800 # USAGE: Legend TitleAction apply <value>2847 # USAGE: LegendRangeAction popup <which> 2848 # USAGE: LegendRangeAction activate 2849 # USAGE: LegendRangeAction validate <value> 2850 # USAGE: LegendRangeAction apply <value> 2801 2851 # 2802 2852 # Used internally to handle the mouseover and popup entry for the field range … … 2814 2864 itcl::body Rappture::VtkIsosurfaceViewer::LegendRangeAction {option args} { 2815 2865 set c $itk_component(view) 2816 # FIXME: check $which for valid values 2866 2817 2867 switch -- $option { 2818 2868 enter { … … 2832 2882 activate { 2833 2883 foreach { x1 y1 x2 y2 } [$c bbox $_mouseOver] break 2834 set info(text) $_settings(-customrange$_mouseOver) 2884 set which [MouseOver2Which] 2885 set info(text) [$itk_component($which) value] 2835 2886 set info(x) [expr $x1 + [winfo rootx $c]] 2836 2887 set info(y) [expr $y1 + [winfo rooty $c]] … … 2843 2894 error "wrong # args: should be \"editor validate value\"" 2844 2895 } 2896 2897 set value [lindex $args 0] 2898 if {[LegendRangeValidate $itk_component(editor) $_mouseOver $value] == 0} { 2899 return 0 2900 } 2901 2902 # value was good, apply it 2903 # reset the mouse rotation bindings 2845 2904 SetupMouseRotationBindings 2846 2905 } … … 2849 2908 error "wrong # args: should be \"editor apply value\"" 2850 2909 } 2851 set _settings(-customrange$_mouseOver) [lindex $args 0] 2852 $itk_component(crange) select 2910 set value [string trim [lindex $args 0]] 2911 2912 set which [MouseOver2Which] 2913 2914 # only set custom range if value changed 2915 if {[$itk_component($which) value] != $value} { 2916 $itk_component($which) value $value 2917 $itk_component(crange) select 2918 } 2853 2919 AdjustSetting -range 2854 2920 } … … 2858 2924 } 2859 2925 } 2926 2860 2927 2861 2928 # … … 2927 2994 # range, use the custom min and max to generate contour list values 2928 2995 if { $_settings(-customrange) } { 2929 if { $_settings(-customrangevmin)> $vmin } {2930 set vmin $_settings(-customrangevmin)2931 } 2932 if { $_settings(-customrangevmax)< $vmax } {2933 set vmax $_settings(-customrangevmax)2996 if { [$itk_component(min) value] > $vmin } { 2997 set vmin [$itk_component(min) value] 2998 } 2999 if { [$itk_component(max) value] < $vmax } { 3000 set vmax [$itk_component(max) value] 2934 3001 } 2935 3002 }
Note: See TracChangeset
for help on using the changeset viewer.