Changeset 5049
- Timestamp:
- Feb 26, 2015 1:10:41 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uiuc_vtk_viewers/gui/scripts/vtkisosurfaceviewer.tcl
r5033 r5049 113 113 private method SetCurrentFieldName { dataobj } 114 114 private method SetLegendTip { x y } 115 private method SetMinMaxGauges { min max } 115 116 private method SetObjectStyle { dataobj comp } 116 117 private method SetOrientation { side } … … 119 120 private method SetupKeyboardBindings {} 120 121 private method Slice {option args} 122 private method ToggleCustomRange { args } 121 123 private method ViewToQuaternion {} { 122 124 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] … … 174 176 175 177 private variable _mouseOver ""; # what called LegendRangeAction, vmin or vmax 178 private variable _customRangeClick 1; # what called ToggleCustomRange 179 private variable _ignoreRangeUpdate 0; # update min/max gauges without redrawing 176 180 } 177 181 … … 260 264 -colormapvisible 1 261 265 -customrange 0 266 -customrangemin 0 267 -customrangemax 1 262 268 -cutplaneedges 0 263 269 -cutplanelighting 1 … … 775 781 # customrangevmin and customrangevmax 776 782 foreach {min max} $lim break 777 $itk_component(min) value $min 778 $itk_component(max) value $max 783 SetMinMaxGauges $min $max 784 set _settings(-customrangemin) $min 785 set _settings(-customrangemax) $max 779 786 780 787 continue … … 783 790 foreach {fmin fmax} $_limits($fname) break 784 791 if { ! $_settings(-customrange) } { 785 $itk_component(min) value $fmin 786 $itk_component(max) value $fmax 792 SetMinMaxGauges $fmin $fmax 787 793 } 788 794 if { $fmin > $min } { … … 1486 1492 SendCmd "dataset maprange all" 1487 1493 } else { 1488 foreach { vmin vmax } $_limits($_curFldName) break1489 1494 if { $_settings(-customrange) } { 1490 if { [$itk_component(min) value] > $vmin } { 1491 set vmin [$itk_component(min) value] 1492 } 1493 if { [$itk_component(max) value] < $vmax } { 1494 set vmax [$itk_component(max) value] 1495 } 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 set _ignoreRangeUpdate 1 1503 SetMinMaxGauges $vmin $vmax 1496 1504 } 1497 1505 SendCmd "dataset maprange explicit $vmin $vmax $_curFldName" … … 1571 1579 } 1572 1580 "-range" { 1573 foreach { vmin vmax } $_limits($_curFldName) break 1574 if { $_settings(-customrange) } { 1575 $itk_component(l_min) configure -state normal 1576 $itk_component(min) configure -state normal 1577 $itk_component(l_max) configure -state normal 1578 $itk_component(max) configure -state normal 1579 if { [$itk_component(min) value] > $vmin } { 1581 if { ! $_ignoreRangeUpdate } { 1582 if { $_settings(-customrange) } { 1580 1583 set vmin [$itk_component(min) value] 1581 }1582 if { [$itk_component(max) value] < $vmax } {1583 1584 set vmax [$itk_component(max) value] 1584 } 1585 } else { 1586 $itk_component(l_min) configure -state disabled 1587 $itk_component(min) configure -state disabled 1588 $itk_component(l_max) configure -state disabled 1589 $itk_component(max) configure -state disabled 1590 } 1591 GenerateContourList 1592 SendCmd [list contour3d contourlist $_contourList(values)] 1593 SendCmd "dataset maprange explicit $vmin $vmax $_curFldName" 1594 DrawLegend 1585 } else { 1586 foreach { vmin vmax } $_limits($_curFldName) break 1587 } 1588 GenerateContourList 1589 SendCmd [list contour3d contourlist $_contourList(values)] 1590 SendCmd "dataset maprange explicit $vmin $vmax $_curFldName" 1591 DrawLegend 1592 } 1593 set _ignoreRangeUpdate 0 1595 1594 } 1596 1595 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { … … 1818 1817 -text "Use Custom Range:" \ 1819 1818 -variable [itcl::scope _settings(-customrange)] \ 1820 -command [itcl::code $this AdjustSetting -range] \1821 1819 -font "Arial 9" 1822 1820 } 1821 # use a trace so we can adjust the value of our variable 1822 # and still have the ToggleCustomRange command called, 1823 # which doesn't seem to happen when using -command. 1824 trace add variable _settings(-customrange) write \ 1825 [itcl::code $this ToggleCustomRange] 1823 1826 1824 1827 itk_component add l_min { … … 2914 2917 # only set custom range if value changed 2915 2918 if {[$itk_component($which) value] != $value} { 2919 # turn on crange first to enable and update the gauge, 2920 # then change the value in the gauge 2921 set _customRangeClick 0 2922 $itk_component(crange) select 2916 2923 $itk_component($which) value $value 2917 $itk_component(crange) select 2918 } 2919 AdjustSetting -range 2924 } 2920 2925 } 2921 2926 default { 2922 2927 error "bad option \"$option\": should be enter, leave, activate, validate, apply" 2923 2928 } 2929 } 2930 } 2931 2932 2933 # ---------------------------------------------------------------------- 2934 # USAGE: ToggleCustomRange 2935 # 2936 # Called whenever the custom range is turned on or off. Used to save 2937 # the custom min and custom max set by the user. When the -customrange 2938 # setting is turned on, the range min and range max gauges are set 2939 # with the last value set by the user, or the default range if no 2940 # previous min and max were set. 2941 # 2942 # When the custom range is turned on, we check how it was turned on 2943 # by querying _customRangeClick. If the variable is 1, this means 2944 # the user clicked the crange checkbutton and we should pull the 2945 # custom range values from our backup variables. If the variable is 0, 2946 # the custom range was enabled through the user manipulating the 2947 # min and max value in the legend. 2948 # 2949 # ---------------------------------------------------------------------- 2950 itcl::body Rappture::VtkIsosurfaceViewer::ToggleCustomRange {args} { 2951 2952 if { ! $_settings(-customrange) } { 2953 # custom range was turned off 2954 2955 # disable the min/max labels and gauge widgets 2956 $itk_component(l_min) configure -state disabled 2957 $itk_component(min) configure -state disabled 2958 $itk_component(l_max) configure -state disabled 2959 $itk_component(max) configure -state disabled 2960 2961 # backup the custom range 2962 set _settings(-customrangemin) [$itk_component(min) value] 2963 set _settings(-customrangemax) [$itk_component(max) value] 2964 2965 # set the gauges to dataset's min and max 2966 foreach { vmin vmax } $_limits($_curFldName) break 2967 SetMinMaxGauges $vmin $vmax 2968 } else { 2969 # custom range was turned on 2970 2971 # enable the min/max labels and gauge widgets 2972 $itk_component(l_min) configure -state normal 2973 $itk_component(min) configure -state normal 2974 $itk_component(l_max) configure -state normal 2975 $itk_component(max) configure -state normal 2976 2977 # if the custom range is being turned on by clicking the 2978 # checkbox, restore the min and max gauges from the backup 2979 # variables. otherwise, new values for the min and max 2980 # widgets will be set later from the legend's editor. 2981 if { $_customRangeClick } { 2982 SetMinMaxGauges $_settings(-customrangemin) $_settings(-customrangemax) 2983 } 2984 2985 # reset the click flag 2986 set _customRangeClick 1 2987 } 2988 AdjustSetting -range 2989 } 2990 2991 2992 # ---------------------------------------------------------------------- 2993 # USAGE: SetMinMaxGauges <min> <max> 2994 # 2995 # Set the min and max gauges in the correct order, avoiding the 2996 # error where you try to set the min > max before updating the max or 2997 # set the max < min before updating the min. 2998 # 2999 # There are five range cases to consider with our current range validation. 3000 # For example: 3001 # [2,3] -> [0,1] : update min first, max last 3002 # [2,3] -> [4,5] : update max first, min last 3003 # [2,3] -> [0,2.5] : update min or max first 3004 # [2,3] -> [2.5,5] : update min or max first 3005 # [2,3] -> [2.25,2.75] : update min or max first 3006 # 3007 # In 4 of the cases we can update min first and max last, so we only 3008 # need to check the case where old max < new min, where we update 3009 # max first and min last. 3010 # ---------------------------------------------------------------------- 3011 itcl::body Rappture::VtkIsosurfaceViewer::SetMinMaxGauges {min max} { 3012 3013 if { [$itk_component(max) value] < $min} { 3014 # old max < new min 3015 # shift range toward right 3016 # extend max first, then update min 3017 $itk_component(max) value $max 3018 $itk_component(min) value $min 3019 } else { 3020 # extend min first, then update max 3021 $itk_component(min) value $min 3022 $itk_component(max) value $max 2924 3023 } 2925 3024 }
Note: See TracChangeset
for help on using the changeset viewer.