Changeset 5181 for branches/1.3/gui/scripts/vtksurfaceviewer.tcl
- Timestamp:
- Apr 1, 2015, 11:06:08 PM (9 years ago)
- Location:
- branches/1.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
-
branches/1.3/gui/scripts/vtksurfaceviewer.tcl
r5177 r5181 99 99 private method Rotate {option x y} 100 100 private method SetCurrentColormap { color } 101 private method SetCurrentFieldName { dataobj } 101 102 private method SetLegendTip { x y } 102 103 private method SetObjectStyle { dataobj comp } … … 217 218 -legendvisible 1 218 219 -numcontours 10 220 -outline 0 219 221 -surfaceedges 0 220 222 -surfacelighting 1 221 223 -surfaceopacity 100 222 -outline 0223 224 -surfacevisible 1 224 225 -surfacewireframe 0 … … 229 230 array set _changed { 230 231 -colormap 0 232 -isolinecolor 0 233 -isolinesvisible 0 231 234 -numcontours 0 235 -outline 0 236 -surfaceedges 0 237 -surfacelighting 0 232 238 -surfaceopacity 0 239 -surfacevisible 0 240 -surfacewireframe 0 233 241 } 234 242 … … 918 926 set _first "" 919 927 SendCmd "dataset visible 0" 928 eval scale $_dlist 920 929 foreach dataobj [get -objects] { 921 930 if { [info exists _obj2ovride($dataobj-raise)] && $_first == "" } { 922 931 set _first $dataobj 932 SetCurrentFieldName $dataobj 923 933 } 924 934 set _obj2datasets($dataobj) "" … … 953 963 lappend _obj2datasets($dataobj) $tag 954 964 if { [info exists _obj2ovride($dataobj-raise)] } { 955 # Setting dataset visible enables outline 956 # and contour2d 957 SendCmd "dataset visible 1 $tag" 958 } 959 } 960 } 961 962 if { $_first != "" } { 963 $itk_component(field) choices delete 0 end 964 $itk_component(fieldmenu) delete 0 end 965 array unset _fields 966 set _curFldName "" 967 foreach cname [$_first components] { 968 foreach fname [$_first fieldnames $cname] { 969 if { [info exists _fields($fname)] } { 970 continue 971 } 972 foreach { label units components } \ 973 [$_first fieldinfo $fname] break 974 $itk_component(field) choices insert end "$fname" "$label" 975 $itk_component(fieldmenu) add radiobutton -label "$label" \ 976 -value $label -variable [itcl::scope _curFldLabel] \ 977 -selectcolor red \ 978 -activebackground $itk_option(-plotbackground) \ 979 -activeforeground $itk_option(-plotforeground) \ 980 -font "Arial 8" \ 981 -command [itcl::code $this Combo invoke] 982 set _fields($fname) [list $label $units $components] 983 if { $_curFldName == "" } { 984 set _curFldName $fname 985 set _curFldLabel $label 986 } 987 } 988 } 989 $itk_component(field) value $_curFldLabel 990 } 965 SendCmd "polydata visible 1 $tag" 966 } 967 } 968 } 969 991 970 InitSettings -isolinesvisible -surfacevisible -outline 992 971 if { $_reset } { … … 1016 995 set _reset 0 1017 996 } 997 # Redraw the legend even if we're using the same colormap. The position 998 # of the isolines may have changed because the range of data changed. 999 DrawLegend 1018 1000 1019 1001 # Actually write the commands to the server socket. If it fails, we don't … … 1357 1339 } 1358 1340 "-isolinecolor" { 1341 set _changed($what) 1 1359 1342 set color [$itk_component(isolineColor) value] 1360 1343 set _settings($what) $color … … 1363 1346 } 1364 1347 "-isolinesvisible" { 1348 set _changed($what) 1 1365 1349 set bool $_settings($what) 1366 SendCmd "contour2d visible $bool" 1350 SendCmd "contour2d visible 0" 1351 if { $bool } { 1352 foreach tag [CurrentDatasets -visible] { 1353 SendCmd "contour2d visible $bool $tag" 1354 } 1355 } 1367 1356 DrawLegend 1368 1357 } … … 1388 1377 } 1389 1378 "-outline" { 1379 set _changed($what) 1 1390 1380 set bool $_settings($what) 1391 SendCmd "outline visible $bool" 1381 SendCmd "outline visible 0" 1382 if { $bool } { 1383 foreach tag [CurrentDatasets -visible] { 1384 SendCmd "outline visible $bool $tag" 1385 } 1386 } 1392 1387 } 1393 1388 "-surfaceedges" { 1389 set _changed($what) 1 1394 1390 set bool $_settings($what) 1395 1391 SendCmd "polydata edges $bool" 1396 1392 } 1397 1393 "-surfacelighting" { 1394 set _changed($what) 1 1398 1395 set bool $_settings($what) 1399 1396 SendCmd "polydata lighting $bool" 1400 1397 } 1401 1398 "-surfaceopacity" { 1399 set _changed($what) 1 1402 1400 set val $_settings($what) 1403 1401 set sval [expr { 0.01 * double($val) }] … … 1405 1403 } 1406 1404 "-surfacevisible" { 1405 set _changed($what) 1 1407 1406 set bool $_settings($what) 1408 SendCmd "polydata visible $bool"1407 SendCmd "polydata visible 0" 1409 1408 if { $bool } { 1409 foreach tag [CurrentDatasets -visible] { 1410 SendCmd "polydata visible $bool $tag" 1411 } 1410 1412 Rappture::Tooltip::for $itk_component(surface) \ 1411 1413 "Hide the surface" … … 1417 1419 } 1418 1420 "-surfacewireframe" { 1421 set _changed($what) 1 1419 1422 set bool $_settings($what) 1420 1423 SendCmd "polydata wireframe $bool" … … 1889 1892 set tag $dataobj-$comp 1890 1893 array set style { 1891 -color BCGYR1892 -edgecolor black1893 -edges 01894 -isolinecolor white1894 -color BCGYR 1895 -edgecolor black 1896 -edges 0 1897 -isolinecolor white 1895 1898 -isolinesvisible 0 1896 -levels 101897 -lighting 11898 -linewidth 1.01899 -opacity 1.01900 -outline 01901 -surfacevisible 11902 -wireframe 01899 -levels 10 1900 -lighting 1 1901 -linewidth 1.0 1902 -opacity 1.0 1903 -outline 0 1904 -surfacevisible 1 1905 -wireframe 0 1903 1906 } 1904 1907 array set style [$dataobj style $comp] … … 1916 1919 # the code to handle aberrant cases. 1917 1920 1921 if { $_changed(-surfaceedges) } { 1922 set style(-edges) $_settings(-surfaceedges) 1923 } 1924 if { $_changed(-surfacelighting) } { 1925 set style(-lighting) $_settings(-surfacelighting) 1926 } 1918 1927 if { $_changed(-surfaceopacity) } { 1919 1928 set style(-opacity) [expr $_settings(-surfaceopacity) * 0.01] 1929 } 1930 if { $_changed(-surfacewireframe) } { 1931 set style(-wireframe) $_settings(-surfacewireframe) 1920 1932 } 1921 1933 if { $_changed(-numcontours) } { … … 1936 1948 DrawLegend 1937 1949 } 1938 set _settings(-isolinesvisible) $style(-isolinesvisible) 1939 set _settings(-surfacevisible) $style(-surfacevisible) 1950 foreach setting {-outline -isolinesvisible -surfacevisible -isolinecolor} { 1951 if {$_changed($setting)} { 1952 # User-modified UI setting overrides style 1953 set style($setting) $_settings($setting) 1954 } else { 1955 # Set UI control to style setting (tool provided or default) 1956 set _settings($setting) $style($setting) 1957 } 1958 } 1940 1959 1941 1960 SendCmd "outline add $tag" 1942 1961 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 1943 1962 SendCmd "outline visible $style(-outline) $tag" 1944 set _settings(-outline) $style(-outline)1945 1963 1946 1964 SendCmd "polydata add $tag" 1965 if { $_curFldName != "" } { 1966 SendCmd "polydata colormode $_colorMode $_curFldName $tag" 1967 } 1947 1968 SendCmd "polydata edges $style(-edges) $tag" 1948 1969 set _settings(-surfaceedges) $style(-edges) … … 2303 2324 blt::vector destroy $v 2304 2325 } 2326 2327 itcl::body Rappture::VtkSurfaceViewer::SetCurrentFieldName { dataobj } { 2328 set _first $dataobj 2329 $itk_component(field) choices delete 0 end 2330 $itk_component(fieldmenu) delete 0 end 2331 array unset _fields 2332 set _curFldName "" 2333 foreach cname [$_first components] { 2334 foreach fname [$_first fieldnames $cname] { 2335 if { [info exists _fields($fname)] } { 2336 continue 2337 } 2338 foreach { label units components } \ 2339 [$_first fieldinfo $fname] break 2340 $itk_component(field) choices insert end "$fname" "$label" 2341 $itk_component(fieldmenu) add radiobutton -label "$label" \ 2342 -value $label -variable [itcl::scope _curFldLabel] \ 2343 -selectcolor red \ 2344 -activebackground $itk_option(-plotbackground) \ 2345 -activeforeground $itk_option(-plotforeground) \ 2346 -font "Arial 8" \ 2347 -command [itcl::code $this LegendTitleAction save] 2348 set _fields($fname) [list $label $units $components] 2349 if { $_curFldName == "" } { 2350 set _curFldName $fname 2351 set _curFldLabel $label 2352 } 2353 } 2354 } 2355 $itk_component(field) value $_curFldLabel 2356 }
Note: See TracChangeset
for help on using the changeset viewer.