- Timestamp:
- Nov 19, 2014 2:39:21 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/1.3.5/gui/scripts/vtkisosurfaceviewer.tcl
r4351 r4752 57 57 public method get {args} 58 58 public method isconnected {} 59 public method limits { colormap }60 59 public method parameters {title args} { 61 60 # do nothing … … 63 62 public method scale {args} 64 63 65 protected method Connect {}66 protected method CurrentDatasets {args}67 protected method Disconnect {}68 protected method DoResize {}69 protected method DoRotate {}70 protected method AdjustSetting {what {value ""}}71 protected method InitSettings { args }72 protected method Pan {option x y}73 protected method Pick {x y}74 protected method Rebuild {}75 protected method ReceiveDataset { args }76 protected method ReceiveImage { args }77 protected method ReceiveLegend { colormap title vmin vmax size }78 protected method Rotate {option x y}79 protected method Zoom {option}80 81 64 # The following methods are only used by this class. 65 66 private method AdjustSetting {what {value ""}} 82 67 private method BuildAxisTab {} 83 68 private method BuildCameraTab {} … … 87 72 private method BuildIsosurfaceTab {} 88 73 private method Combo { option } 74 private method Connect {} 75 private method CurrentDatasets {args} 76 private method Disconnect {} 77 private method DoChangeContourLevels {} 78 private method DoResize {} 79 private method DoRotate {} 89 80 private method DrawLegend {} 90 81 private method EnterLegend { x y } 82 private method EventuallyChangeContourLevels {} 83 private method EventuallyRequestLegend {} 91 84 private method EventuallyResize { w h } 92 85 private method EventuallyRotate { q } 93 private method EventuallyRequestLegend {}94 86 private method EventuallySetCutplane { axis args } 87 private method GenerateContourList {} 95 88 private method GetImage { args } 96 89 private method GetVtkData { args } 90 private method InitSettings { args } 97 91 private method IsValidObject { dataobj } 98 92 private method LeaveLegend {} 99 93 private method MotionLegend { x y } 94 private method Pan {option x y} 100 95 private method PanCamera {} 96 private method Pick {x y} 97 private method Rebuild {} 98 private method ReceiveDataset { args } 99 private method ReceiveImage { args } 100 private method ReceiveLegend { colormap title vmin vmax size } 101 101 private method RequestLegend {} 102 private method Rotate {option x y} 103 private method SetCurrentColormap { color } 104 private method SetCurrentFieldName { dataobj } 102 105 private method SetLegendTip { x y } 103 private method SetObjectStyle { dataobj comp } 104 private method Slice {option args} 105 private method SetCurrentColormap { color } 106 private method SetObjectStyle { dataobj comp } 106 107 private method SetOrientation { side } 107 private method UpdateContourList {} 108 private method Slice {option args} 109 private method Zoom {option} 110 private method ViewToQuaternion {} { 111 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 112 } 108 113 109 114 private variable _arcball "" … … 120 125 private variable _currentColormap "" 121 126 private variable _currentNumContours -1 122 private variable _currentOpacity ""123 127 124 128 private variable _dataset2style ;# maps dataobj-component to transfunc … … 138 142 private variable _title "" 139 143 private variable _isolines 140 private variable _contourList "" 144 private variable _contourList 145 private variable _currentLimits "" 146 private variable _widget 141 147 142 148 common _downloadPopup; # download options from popup … … 184 190 $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list" 185 191 192 # Contour levels event 193 $_dispatcher register !contours 194 $_dispatcher dispatch $this !contours \ 195 "[itcl::code $this DoChangeContourLevels]; list" 196 186 197 # X-Cutplane event 187 198 $_dispatcher register !xcutplane … … 208 219 # Initialize the view to some default parameters. 209 220 array set _view { 210 qw 0.853553211 qx -0.353553212 qy0.353553213 qz 0.146447214 zoom 1.0215 xpan 0216 ypan 0217 ortho 0221 -ortho 0 222 -qw 0.853553 223 -qx -0.353553 224 -qy 0.353553 225 -qz 0.146447 226 -xpan 0 227 -ypan 0 228 -zoom 1.0 218 229 } 219 230 set _arcball [blt::arcball create 100 100] 220 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 221 $_arcball quaternion $q 222 231 $_arcball quaternion [ViewToQuaternion] 232 233 array set _contourList { 234 numLevels 10 235 reqValues "" 236 updatePending 0 237 values "" 238 } 223 239 array set _settings { 224 240 -axesvisible 1 225 -axislabelsvisible 1 226 -background black 227 -colormap BCGYR 228 -colormapvisible 1 241 -axislabels 1 242 -axisminorticks 1 243 -axismode "static" 244 -background black 245 -colormap BCGYR 246 -colormapvisible 1 229 247 -cutplaneedges 0 230 248 -cutplanelighting 1 231 -cutplaneopacity 1 00249 -cutplaneopacity 1.0 232 250 -cutplanepreinterp 1 233 251 -cutplanesvisible 0 234 252 -cutplanewireframe 0 235 236 253 -field "Default" 254 -isolinecolor white 237 255 -isosurfaceedges 0 238 256 -isosurfacelighting 1 239 -isosurfaceopacity 60 240 -isosurfaceoutline 0 257 -isosurfaceopacity 0.6 241 258 -isosurfacevisible 1 242 259 -isosurfacewireframe 0 243 260 -legendvisible 1 244 261 -numcontours 10 245 - xaxisgrid0262 -outline 0 246 263 -xcutplaneposition 50 247 264 -xcutplanevisible 1 248 - yaxisgrid0265 -xgrid 0 249 266 -ycutplaneposition 50 250 267 -ycutplanevisible 1 251 - zaxisgrid0268 -ygrid 0 252 269 -zcutplaneposition 50 253 270 -zcutplanevisible 1 271 -zgrid 0 254 272 } 255 273 array set _changed { 274 -colormap 0 256 275 -isosurfaceopacity 0 257 -c olormap0276 -cutplaneopacity 0 258 277 -numcontours 0 278 } 279 array set _widget { 280 -isosurfaceopacity 60 281 -cutplaneopacity 100 259 282 } 260 283 … … 341 364 $itk_component(contour) select 342 365 Rappture::Tooltip::for $itk_component(contour) \ 343 " Don't displaythe isosurface"366 "Hide the isosurface" 344 367 pack $itk_component(contour) -padx 2 -pady 2 345 368 … … 352 375 } 353 376 Rappture::Tooltip::for $itk_component(cutplane) \ 354 "Show /Hide cutplanes"377 "Show the cutplanes" 355 378 pack $itk_component(cutplane) -padx 2 -pady 2 356 379 … … 441 464 EnableWaitDialog 500 442 465 Connect 443 update444 466 } 445 467 … … 468 490 } 469 491 492 itcl::body Rappture::VtkIsosurfaceViewer::DoChangeContourLevels {} { 493 GenerateContourList 494 SendCmd [list contour3d contourlist $_contourList(values)] 495 SendCmd [list camera reset] 496 DrawLegend 497 set _contourList(updatePending) 0 498 } 499 470 500 itcl::body Rappture::VtkIsosurfaceViewer::DoRotate {} { 471 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 472 SendCmd "camera orient $q" 501 SendCmd "camera orient [ViewToQuaternion]" 473 502 set _rotatePending 0 474 503 } … … 494 523 495 524 itcl::body Rappture::VtkIsosurfaceViewer::EventuallyRotate { q } { 496 foreach { _view( qw) _view(qx) _view(qy) _view(qz) } $q break525 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 497 526 if { !$_rotatePending } { 498 527 set _rotatePending 1 … … 506 535 set _cutplanePending 1 507 536 $_dispatcher event -after 100 !${axis}cutplane 537 } 538 } 539 540 itcl::body Rappture::VtkIsosurfaceViewer::EventuallyChangeContourLevels {} { 541 set n $_contourList(numLevels) 542 set _contourList(values) "" 543 if { !$_contourList(updatePending) } { 544 set _contourList(updatePending) 1 545 global rotate_delay 546 $_dispatcher event -after $rotate_delay !contours 508 547 } 509 548 } … … 784 823 set session $env(SESSION) 785 824 } 825 lappend info "version" "$Rappture::version" 826 lappend info "build" "$Rappture::build" 827 lappend info "installdir" "$Rappture::installdir" 786 828 lappend info "hub" [exec hostname] 787 829 lappend info "client" "vtkisosurfaceviewer" … … 833 875 # disconnected -- no more data sitting on server 834 876 set _outbuf "" 835 array unset _datasets 836 array unset _data 837 array unset _colormaps 838 array unset _seeds 839 array unset _dataset2style 840 array unset _obj2datasets 877 array unset _datasets 878 array unset _data 879 array unset _colormaps 880 array unset _dataset2style 881 array unset _obj2datasets 841 882 } 842 883 … … 940 981 # generates a new call to Rebuild). 941 982 StartBufferingCommands 942 943 983 if { $_reset } { 944 984 set _width $w … … 946 986 $_arcball resize $w $h 947 987 DoResize 948 # 988 949 989 # Reset the camera and other view parameters 950 # 951 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 952 $_arcball quaternion $q 953 if {$_view(ortho)} { 954 SendCmd "camera mode ortho" 955 } else { 956 SendCmd "camera mode persp" 957 } 990 $_arcball quaternion [ViewToQuaternion] 991 InitSettings -ortho 958 992 DoRotate 959 993 PanCamera 960 994 set _first "" 961 InitSettings -xaxisgrid -yaxisgrid -zaxisgrid -axismode \ 962 -axesvisible -axislabelsvisible 963 foreach axis { x y z } { 964 SendCmd "axis lformat $axis %g" 965 } 995 InitSettings -background \ 996 -xgrid -ygrid -zgrid -axismode \ 997 -axesvisible -axislabels -axisminorticks 998 #SendCmd "axis lformat all %g" 966 999 StopBufferingCommands 967 1000 SendCmd "imgflush" … … 969 1002 } 970 1003 set _first "" 971 SendCmd "contour3d visible 0" 1004 SendCmd "dataset visible 0" 1005 eval scale $_dlist 972 1006 foreach dataobj [get -objects] { 973 1007 if { [info exists _obj2ovride($dataobj-raise)] && $_first == "" } { 974 1008 set _first $dataobj 1009 SetCurrentFieldName $dataobj 975 1010 } 976 1011 set _obj2datasets($dataobj) "" … … 987 1022 if { $_reportClientInfo } { 988 1023 set info {} 989 lappend info "tool_id" [$dataobj hints toolId] 990 lappend info "tool_name" [$dataobj hints toolName] 991 lappend info "tool_version" [$dataobj hints toolRevision] 992 lappend info "tool_title" [$dataobj hints toolTitle] 1024 lappend info "tool_id" [$dataobj hints toolid] 1025 lappend info "tool_name" [$dataobj hints toolname] 1026 lappend info "tool_title" [$dataobj hints tooltitle] 1027 lappend info "tool_command" [$dataobj hints toolcommand] 1028 lappend info "tool_revision" [$dataobj hints toolrevision] 993 1029 lappend info "dataset_label" [$dataobj hints label] 994 1030 lappend info "dataset_size" $length … … 996 1032 SendCmd "clientinfo [list $info]" 997 1033 } 998 append _outbuf "dataset add $tag data follows $length\n"1034 SendCmd "dataset add $tag data follows $length" 999 1035 append _outbuf $bytes 1000 1036 set _datasets($tag) 1 … … 1003 1039 lappend _obj2datasets($dataobj) $tag 1004 1040 if { [info exists _obj2ovride($dataobj-raise)] } { 1005 # Setting dataset visible enables outline1006 # and contour3d1007 1041 SendCmd "contour3d visible 1 $tag" 1008 1042 } … … 1010 1044 } 1011 1045 1012 if { $_first != "" } { 1013 $itk_component(field) choices delete 0 end 1014 $itk_component(fieldmenu) delete 0 end 1015 array unset _fields 1016 set _curFldName "" 1017 foreach cname [$_first components] { 1018 foreach fname [$_first fieldnames $cname] { 1019 if { [info exists _fields($fname)] } { 1020 continue 1021 } 1022 foreach { label units components } \ 1023 [$_first fieldinfo $fname] break 1024 $itk_component(field) choices insert end "$fname" "$label" 1025 $itk_component(fieldmenu) add radiobutton -label "$label" \ 1026 -value $label -variable [itcl::scope _curFldLabel] \ 1027 -selectcolor red \ 1028 -activebackground $itk_option(-plotbackground) \ 1029 -activeforeground $itk_option(-plotforeground) \ 1030 -font "Arial 8" \ 1031 -command [itcl::code $this Combo invoke] 1032 set _fields($fname) [list $label $units $components] 1033 if { $_curFldName == "" } { 1034 set _curFldName $fname 1035 set _curFldLabel $label 1036 } 1037 } 1038 } 1039 $itk_component(field) value $_curFldLabel 1040 } 1041 InitSettings -cutplanesvisible -isosurfacevisible -isosurfaceoutline 1046 InitSettings -cutplanesvisible -isosurfacevisible -outline 1042 1047 if { $_reset } { 1043 1048 # These are settings that rely on a dataset being loaded. … … 1062 1067 set label [string toupper $axis] 1063 1068 } 1064 # May be a space in the axis label.1065 1069 SendCmd [list axis name $axis $label] 1066 1070 } 1067 1071 if { [array size _fields] < 2 } { 1068 blt::table forget $itk_component(field) $itk_component(field_l)1072 catch {blt::table forget $itk_component(field) $itk_component(field_l)} 1069 1073 } 1070 1074 set _reset 0 1071 1075 } 1076 # Redraw the legend even if we're using the same colormap. The position 1077 # of the isolines may have changed because the range of data changed. 1078 DrawLegend 1072 1079 1073 1080 # Actually write the commands to the server socket. If it fails, we don't … … 1134 1141 switch -- $option { 1135 1142 "in" { 1136 set _view( zoom) [expr {$_view(zoom)*1.25}]1137 SendCmd "camera zoom $_view( zoom)"1143 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1144 SendCmd "camera zoom $_view(-zoom)" 1138 1145 } 1139 1146 "out" { 1140 set _view( zoom) [expr {$_view(zoom)*0.8}]1141 SendCmd "camera zoom $_view( zoom)"1147 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1148 SendCmd "camera zoom $_view(-zoom)" 1142 1149 } 1143 1150 "reset" { 1144 1151 array set _view { 1145 qw 0.8535531146 qx -0.3535531147 qy 0.3535531148 qz 0.1464471149 zoom 1.01150 xpan 01151 ypan01152 -qw 0.853553 1153 -qx -0.353553 1154 -qy 0.353553 1155 -qz 0.146447 1156 -xpan 0 1157 -ypan 0 1158 -zoom 1.0 1152 1159 } 1153 1160 if { $_first != "" } { … … 1157 1164 } 1158 1165 } 1159 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1160 $_arcball quaternion $q 1166 $_arcball quaternion [ViewToQuaternion] 1161 1167 DoRotate 1162 1168 SendCmd "camera reset" … … 1166 1172 1167 1173 itcl::body Rappture::VtkIsosurfaceViewer::PanCamera {} { 1168 set x $_view( xpan)1169 set y $_view( ypan)1174 set x $_view(-xpan) 1175 set y $_view(-ypan) 1170 1176 SendCmd "camera pan $x $y" 1171 1177 } … … 1245 1251 set x [expr $x / double($w)] 1246 1252 set y [expr $y / double($h)] 1247 set _view( xpan) [expr $_view(xpan) + $x]1248 set _view( ypan) [expr $_view(ypan) + $y]1253 set _view(-xpan) [expr $_view(-xpan) + $x] 1254 set _view(-ypan) [expr $_view(-ypan) + $y] 1249 1255 PanCamera 1250 1256 return … … 1268 1274 set _click(x) $x 1269 1275 set _click(y) $y 1270 set _view( xpan) [expr $_view(xpan) - $dx]1271 set _view( ypan) [expr $_view(ypan) - $dy]1276 set _view(-xpan) [expr $_view(-xpan) - $dx] 1277 set _view(-ypan) [expr $_view(-ypan) - $dy] 1272 1278 PanCamera 1273 1279 } … … 1311 1317 } 1312 1318 switch -- $what { 1319 "-axesvisible" { 1320 set bool $_settings($what) 1321 SendCmd "axis visible all $bool" 1322 } 1323 "-axislabels" { 1324 set bool $_settings($what) 1325 SendCmd "axis labels all $bool" 1326 } 1327 "-axisminorticks" { 1328 set bool $_settings($what) 1329 SendCmd "axis minticks all $bool" 1330 } 1331 "-axismode" { 1332 set mode [$itk_component(axisMode) value] 1333 set mode [$itk_component(axisMode) translate $mode] 1334 set _settings($what) $mode 1335 SendCmd "axis flymode $mode" 1336 } 1313 1337 "-background" { 1314 1338 set bgcolor [$itk_component(background) value] … … 1323 1347 DrawLegend 1324 1348 } 1325 "-axesvisible" {1326 set bool $_settings(-axesvisible)1327 SendCmd "axis visible all $bool"1328 }1329 "-axislabelsvisible" {1330 set bool $_settings(-axislabelsvisible)1331 SendCmd "axis labels all $bool"1332 }1333 "-xaxisgrid" - "-yaxisgrid" - "-zaxisgrid" {1334 set axis [string tolower [string range $what 1 1]]1335 set bool $_settings($what)1336 SendCmd "axis grid $axis $bool"1337 }1338 "-axismode" {1339 set mode [$itk_component(axisMode) value]1340 set mode [$itk_component(axisMode) translate $mode]1341 set _settings($what) $mode1342 SendCmd "axis flymode $mode"1343 }1344 1349 "-cutplaneedges" { 1345 1350 set bool $_settings($what) 1346 1351 SendCmd "cutplane edges $bool" 1347 1352 } 1353 "-cutplanelighting" { 1354 set bool $_settings($what) 1355 SendCmd "cutplane lighting $bool" 1356 } 1357 "-cutplaneopacity" { 1358 set _settings($what) [expr $_widget($what) * 0.01] 1359 SendCmd "cutplane opacity $_settings($what)" 1360 } 1361 "-cutplanepreinterp" { 1362 set bool $_settings($what) 1363 SendCmd "cutplane preinterp $bool" 1364 } 1348 1365 "-cutplanesvisible" { 1349 1366 set bool $_settings($what) 1350 SendCmd "cutplane visible $bool" 1367 SendCmd "cutplane visible 0" 1368 if { $bool } { 1369 foreach tag [CurrentDatasets -visible] { 1370 SendCmd "cutplane visible $bool $tag" 1371 } 1372 } 1373 if { $bool } { 1374 Rappture::Tooltip::for $itk_component(cutplane) \ 1375 "Hide the cutplanes" 1376 } else { 1377 Rappture::Tooltip::for $itk_component(cutplane) \ 1378 "Show the cutplanes" 1379 } 1351 1380 } 1352 1381 "-cutplanewireframe" { … … 1354 1383 SendCmd "cutplane wireframe $bool" 1355 1384 } 1356 "-cutplanelighting" {1357 set bool $_settings($what)1358 SendCmd "cutplane lighting $bool"1359 }1360 "-cutplaneopacity" {1361 set val $_settings($what)1362 set sval [expr { 0.01 * double($val) }]1363 SendCmd "cutplane opacity $sval"1364 }1365 "-cutplanepreinterp" {1366 set bool $_settings($what)1367 SendCmd "cutplane preinterp $bool"1368 }1369 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {1370 set axis [string tolower [string range $what 1 1]]1371 set bool $_settings($what)1372 if { $bool } {1373 $itk_component(${axis}position) configure -state normal \1374 -troughcolor white1375 } else {1376 $itk_component(${axis}position) configure -state disabled \1377 -troughcolor grey821378 }1379 SendCmd "cutplane axis $axis $bool"1380 }1381 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {1382 set axis [string tolower [string range $what 1 1]]1383 set pos [expr $_settings($what) * 0.01]1384 SendCmd "cutplane slice ${axis} ${pos}"1385 set _cutplanePending 01386 }1387 1385 "-colormap" { 1388 set _changed( -colormap) 11386 set _changed($what) 1 1389 1387 StartBufferingCommands 1390 1388 set color [$itk_component(colormap) value] 1391 set _settings( -colormap) $color1389 set _settings($what) $color 1392 1390 if { $color == "none" } { 1393 1391 if { $_settings(-colormapvisible) } { … … 1405 1403 EventuallyRequestLegend 1406 1404 } 1407 "-numcontours" {1408 set _settings($what) [$itk_component(numcontours) value]1409 set _currentNumContours $_settings($what)1410 UpdateContourList1411 set _changed($what) 11412 SendCmd "contour3d contourlist [list $_contourList]"1413 DrawLegend1414 }1415 "-isosurfacewireframe" {1416 set bool $_settings($what)1417 SendCmd "contour3d wireframe $bool"1418 }1419 "-isosurfacevisible" {1420 set bool $_settings($what)1421 SendCmd "contour3d visible 0"1422 if { $bool } {1423 foreach tag [CurrentDatasets -visible] {1424 SendCmd "contour3d visible $bool $tag"1425 }1426 }1427 if { $bool } {1428 Rappture::Tooltip::for $itk_component(contour) \1429 "Hide the isosurface"1430 } else {1431 Rappture::Tooltip::for $itk_component(contour) \1432 "Show the isosurface"1433 }1434 DrawLegend1435 }1436 "-isosurfacelighting" {1437 set bool $_settings($what)1438 SendCmd "contour3d lighting $bool"1439 }1440 "-isosurfaceedges" {1441 set bool $_settings($what)1442 SendCmd "contour3d edges $bool"1443 }1444 "-isosurfaceoutline" {1445 set bool $_settings($what)1446 SendCmd "outline visible $bool"1447 }1448 "-isolinecolor" {1449 set color [$itk_component(isolineColor) value]1450 set _settings($what) $color1451 DrawLegend1452 }1453 "-isosurfaceopacity" {1454 set val $_settings($what)1455 set sval [expr { 0.01 * double($val) }]1456 SendCmd "contour3d opacity $sval"1457 }1458 1405 "-field" { 1459 1406 set label [$itk_component(field) value] … … 1482 1429 SendCmd "contour3d colormode $_colorMode $_curFldName" 1483 1430 SendCmd "camera reset" 1484 UpdateContourList1431 GenerateContourList 1485 1432 DrawLegend 1433 } 1434 "-isolinecolor" { 1435 set color [$itk_component(isolineColor) value] 1436 set _settings($what) $color 1437 DrawLegend 1438 } 1439 "-isosurfaceedges" { 1440 set bool $_settings($what) 1441 SendCmd "contour3d edges $bool" 1442 } 1443 "-isosurfacelighting" { 1444 set bool $_settings($what) 1445 SendCmd "contour3d lighting $bool" 1446 } 1447 "-isosurfaceopacity" { 1448 set _settings($what) [expr $_widget($what) * 0.01] 1449 SendCmd "contour3d opacity $_settings($what)" 1450 } 1451 "-isosurfacevisible" { 1452 set bool $_settings($what) 1453 SendCmd "contour3d visible 0" 1454 if { $bool } { 1455 foreach tag [CurrentDatasets -visible] { 1456 SendCmd "contour3d visible $bool $tag" 1457 } 1458 } 1459 if { $bool } { 1460 Rappture::Tooltip::for $itk_component(contour) \ 1461 "Hide the isosurface" 1462 } else { 1463 Rappture::Tooltip::for $itk_component(contour) \ 1464 "Show the isosurface" 1465 } 1466 } 1467 "-isosurfacewireframe" { 1468 set bool $_settings($what) 1469 SendCmd "contour3d wireframe $bool" 1486 1470 } 1487 1471 "-legendvisible" { … … 1490 1474 } 1491 1475 DrawLegend 1476 } 1477 "-numcontours" { 1478 set _settings($what) [$itk_component(numcontours) value] 1479 if { $_contourList(numLevels) != $_settings($what) } { 1480 set _contourList(numLevels) $_settings($what) 1481 EventuallyChangeContourLevels 1482 } 1483 } 1484 "-ortho" { 1485 set bool $_view($what) 1486 if { $bool } { 1487 SendCmd "camera mode ortho" 1488 } else { 1489 SendCmd "camera mode persp" 1490 } 1491 } 1492 "-outline" { 1493 set bool $_settings($what) 1494 SendCmd "outline visible 0" 1495 if { $bool } { 1496 foreach tag [CurrentDatasets -visible] { 1497 SendCmd "outline visible $bool $tag" 1498 } 1499 } 1500 } 1501 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1502 set axis [string tolower [string range $what 1 1]] 1503 set bool $_settings($what) 1504 if { $bool } { 1505 $itk_component(${axis}position) configure -state normal \ 1506 -troughcolor white 1507 } else { 1508 $itk_component(${axis}position) configure -state disabled \ 1509 -troughcolor grey82 1510 } 1511 SendCmd "cutplane axis $axis $bool" 1512 } 1513 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" { 1514 set axis [string tolower [string range $what 1 1]] 1515 set pos [expr $_settings($what) * 0.01] 1516 SendCmd "cutplane slice ${axis} ${pos}" 1517 set _cutplanePending 0 1518 } 1519 "-xgrid" - "-ygrid" - "-zgrid" { 1520 set axis [string tolower [string range $what 1 1]] 1521 set bool $_settings($what) 1522 SendCmd "axis grid $axis $bool" 1492 1523 } 1493 1524 default { … … 1569 1600 } 1570 1601 1571 itcl::body Rappture::VtkIsosurfaceViewer::limits { dataobj } {1572 foreach { limits(xmin) limits(xmax) } [$dataobj limits x] break1573 foreach { limits(ymin) limits(ymax) } [$dataobj limits y] break1574 foreach { limits(zmin) limits(zmax) } [$dataobj limits z] break1575 foreach { limits(vmin) limits(vmax) } [$dataobj limits v] break1576 return [array get limits]1577 }1578 1579 1602 itcl::body Rappture::VtkIsosurfaceViewer::BuildIsosurfaceTab {} { 1580 1603 … … 1613 1636 checkbutton $inner.outline \ 1614 1637 -text "Outline" \ 1615 -variable [itcl::scope _settings(- isosurfaceoutline)] \1616 -command [itcl::code $this AdjustSetting - isosurfaceoutline] \1638 -variable [itcl::scope _settings(-outline)] \ 1639 -command [itcl::code $this AdjustSetting -outline] \ 1617 1640 -font "Arial 9" 1618 1641 … … 1658 1681 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1659 1682 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1660 -variable [itcl::scope _ settings(-isosurfaceopacity)] \1683 -variable [itcl::scope _widget(-isosurfaceopacity)] \ 1661 1684 -width 10 \ 1662 1685 -showvalue off \ 1663 1686 -command [itcl::code $this AdjustSetting -isosurfaceopacity] 1664 1665 label $inner.scale_l -text "Scale" -font "Arial 9" 1666 ::scale $inner.scale -from 1 -to 100 -orient horizontal \ 1667 -variable [itcl::scope _settings(-contourscale)] \ 1668 -width 10 \ 1669 -showvalue off \ 1670 -command [itcl::code $this AdjustSetting -contourscale] 1687 $inner.opacity set [expr $_settings(-isosurfaceopacity) * 100.0] 1671 1688 1672 1689 itk_component add field_l { … … 1685 1702 Rappture::Combobox $inner.colormap -width 10 -editable 0 1686 1703 } 1687 $inner.colormap choices insert end \ 1688 "BCGYR" "BCGYR" \ 1689 "BGYOR" "BGYOR" \ 1690 "blue" "blue" \ 1691 "blue-to-brown" "blue-to-brown" \ 1692 "blue-to-orange" "blue-to-orange" \ 1693 "blue-to-grey" "blue-to-grey" \ 1694 "green-to-magenta" "green-to-magenta" \ 1695 "greyscale" "greyscale" \ 1696 "nanohub" "nanohub" \ 1697 "rainbow" "rainbow" \ 1698 "spectral" "spectral" \ 1699 "ROYGB" "ROYGB" \ 1700 "RYGCB" "RYGCB" \ 1701 "brown-to-blue" "brown-to-blue" \ 1702 "grey-to-blue" "grey-to-blue" \ 1703 "orange-to-blue" "orange-to-blue" 1704 $inner.colormap choices insert end [GetColormapList] 1704 1705 1705 1706 $itk_component(colormap) value "BCGYR" … … 1750 1751 1751 1752 checkbutton $inner.visible \ 1752 -text " ShowAxes" \1753 -text "Axes" \ 1753 1754 -variable [itcl::scope _settings(-axesvisible)] \ 1754 1755 -command [itcl::code $this AdjustSetting -axesvisible] \ … … 1756 1757 1757 1758 checkbutton $inner.labels \ 1758 -text " ShowAxis Labels" \1759 -variable [itcl::scope _settings(-axislabels visible)] \1760 -command [itcl::code $this AdjustSetting -axislabels visible] \1759 -text "Axis Labels" \ 1760 -variable [itcl::scope _settings(-axislabels)] \ 1761 -command [itcl::code $this AdjustSetting -axislabels] \ 1761 1762 -font "Arial 9" 1762 1763 checkbutton $inner. gridx\1764 -text " Show X Grid" \1765 -variable [itcl::scope _settings(-x axisgrid)] \1766 -command [itcl::code $this AdjustSetting -x axisgrid] \1763 label $inner.grid_l -text "Grid" -font "Arial 9" 1764 checkbutton $inner.xgrid \ 1765 -text "X" \ 1766 -variable [itcl::scope _settings(-xgrid)] \ 1767 -command [itcl::code $this AdjustSetting -xgrid] \ 1767 1768 -font "Arial 9" 1768 checkbutton $inner. gridy\1769 -text " Show Y Grid" \1770 -variable [itcl::scope _settings(-y axisgrid)] \1771 -command [itcl::code $this AdjustSetting -y axisgrid] \1769 checkbutton $inner.ygrid \ 1770 -text "Y" \ 1771 -variable [itcl::scope _settings(-ygrid)] \ 1772 -command [itcl::code $this AdjustSetting -ygrid] \ 1772 1773 -font "Arial 9" 1773 checkbutton $inner.gridz \ 1774 -text "Show Z Grid" \ 1775 -variable [itcl::scope _settings(-zaxisgrid)] \ 1776 -command [itcl::code $this AdjustSetting -zaxisgrid] \ 1774 checkbutton $inner.zgrid \ 1775 -text "Z" \ 1776 -variable [itcl::scope _settings(-zgrid)] \ 1777 -command [itcl::code $this AdjustSetting -zgrid] \ 1778 -font "Arial 9" 1779 checkbutton $inner.minorticks \ 1780 -text "Minor Ticks" \ 1781 -variable [itcl::scope _settings(-axisminorticks)] \ 1782 -command [itcl::code $this AdjustSetting -axisminorticks] \ 1777 1783 -font "Arial 9" 1778 1784 … … 1787 1793 "furthest_triad" "farthest" \ 1788 1794 "outer_edges" "outer" 1789 $itk_component(axisMode) value "static"1795 $itk_component(axisMode) value $_settings(-axismode) 1790 1796 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] 1791 1797 1792 1798 blt::table $inner \ 1793 0,0 $inner.visible -anchor w -cspan 2 \ 1794 1,0 $inner.labels -anchor w -cspan 2 \ 1795 2,0 $inner.gridx -anchor w -cspan 2 \ 1796 3,0 $inner.gridy -anchor w -cspan 2 \ 1797 4,0 $inner.gridz -anchor w -cspan 2 \ 1798 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1799 6,0 $inner.mode -fill x -cspan 2 1799 0,0 $inner.visible -anchor w -cspan 4 \ 1800 1,0 $inner.labels -anchor w -cspan 4 \ 1801 2,0 $inner.minorticks -anchor w -cspan 4 \ 1802 4,0 $inner.grid_l -anchor w \ 1803 4,1 $inner.xgrid -anchor w \ 1804 4,2 $inner.ygrid -anchor w \ 1805 4,3 $inner.zgrid -anchor w \ 1806 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1807 5,1 $inner.mode -fill x -cspan 3 1800 1808 1801 1809 blt::table configure $inner r* c* -resize none 1802 blt::table configure $inner r7 c1 -resize expand 1810 blt::table configure $inner r7 c6 -resize expand 1811 blt::table configure $inner r3 -height 0.125i 1803 1812 } 1804 1813 … … 1822 1831 0,0 $inner.view_l -anchor e -pady 2 \ 1823 1832 0,1 $inner.view -anchor w -pady 2 1833 blt::table configure $inner r0 -resize none 1824 1834 1825 1835 set labels { qx qy qz qw xpan ypan zoom } … … 1828 1838 label $inner.${tag}label -text $tag -font "Arial 9" 1829 1839 entry $inner.${tag} -font "Arial 9" -bg white \ 1830 -textvariable [itcl::scope _view( $tag)]1840 -textvariable [itcl::scope _view(-$tag)] 1831 1841 bind $inner.${tag} <KeyPress-Return> \ 1832 1842 [itcl::code $this camera set ${tag}] … … 1839 1849 checkbutton $inner.ortho \ 1840 1850 -text "Orthographic Projection" \ 1841 -variable [itcl::scope _view( ortho)] \1842 -command [itcl::code $this camera setortho] \1851 -variable [itcl::scope _view(-ortho)] \ 1852 -command [itcl::code $this AdjustSetting -ortho] \ 1843 1853 -font "Arial 9" 1844 1854 blt::table $inner \ … … 1847 1857 incr row 1848 1858 1849 blt::table configure $inner c* r*-resize none1859 blt::table configure $inner c* -resize none 1850 1860 blt::table configure $inner c2 -resize expand 1851 1861 blt::table configure $inner r$row -resize expand … … 1894 1904 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1895 1905 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1896 -variable [itcl::scope _ settings(-cutplaneopacity)] \1906 -variable [itcl::scope _widget(-cutplaneopacity)] \ 1897 1907 -width 10 \ 1898 1908 -showvalue off \ 1899 1909 -command [itcl::code $this AdjustSetting -cutplaneopacity] 1900 $inner.opacity set $_settings(-cutplaneopacity)1910 $inner.opacity set [expr $_settings(-cutplaneopacity) * 100.0] 1901 1911 1902 1912 # X-value slicer... … … 2019 2029 } 2020 2030 "set" { 2021 set wh o[lindex $args 0]2022 set x $_view($wh o)2031 set what [lindex $args 0] 2032 set x $_view($what) 2023 2033 set code [catch { string is double $x } result] 2024 2034 if { $code != 0 || !$result } { 2025 2035 return 2026 2036 } 2027 switch -- $wh o{2028 " ortho" {2029 if {$_view( ortho)} {2037 switch -- $what { 2038 "-ortho" { 2039 if {$_view($what)} { 2030 2040 SendCmd "camera mode ortho" 2031 2041 } else { … … 2033 2043 } 2034 2044 } 2035 " xpan" - "ypan" {2045 "-xpan" - "-ypan" { 2036 2046 PanCamera 2037 2047 } 2038 " qx" - "qy" - "qz" - "qw" {2039 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2048 "-qx" - "-qy" - "-qz" - "-qw" { 2049 set q [ViewToQuaternion] 2040 2050 $_arcball quaternion $q 2041 2051 EventuallyRotate $q 2042 2052 } 2043 " zoom" {2044 SendCmd "camera zoom $_view( zoom)"2053 "-zoom" { 2054 SendCmd "camera zoom $_view(-zoom)" 2045 2055 } 2046 2056 } … … 2117 2127 set tag $dataobj-$comp 2118 2128 array set style { 2119 -color BCGYR2120 -cutplanesvisible 02121 -edgecolor black2122 -edges 02123 -isosurfacevisible 12124 -levels 102125 -lighting 12126 -linewidth 1.02127 -opacity 0.62128 -outline 02129 -wireframe 02130 -xcutplaneposition 502131 -xcutplanevisible 12132 -ycutplaneposition 502133 -ycutplanevisible 12134 -zcutplaneposition 502135 -zcutplanevisible 12129 -color BCGYR 2130 -cutplanesvisible 0 2131 -edgecolor black 2132 -edges 0 2133 -isosurfacevisible 1 2134 -levels 10 2135 -lighting 1 2136 -linewidth 1.0 2137 -opacity 0.6 2138 -outline 0 2139 -wireframe 0 2140 -xcutplaneposition 50 2141 -xcutplanevisible 1 2142 -ycutplaneposition 50 2143 -ycutplanevisible 1 2144 -zcutplaneposition 50 2145 -zcutplanevisible 1 2136 2146 } 2137 2147 array set style [$dataobj style $comp] 2138 2148 if { $dataobj != $_first || $style(-levels) == 1 } { 2139 set style(-opacity) 1 2140 } 2141 SendCmd "cutplane add $tag" 2142 SendCmd "cutplane visible 0 $tag" 2149 set style(-opacity) 1.0 2150 } 2143 2151 2144 2152 # This is too complicated. We want to set the colormap, number of … … 2164 2172 $itk_component(colormap) value $style(-color) 2165 2173 } 2166 set _currentOpacity $style(-opacity) 2167 if { $_currentNumContours != $style(-levels) } { 2168 set _currentNumContours $style(-levels) 2169 set _settings(-numcontours) $_currentNumContours 2170 $itk_component(numcontours) value $_currentNumContours 2171 UpdateContourList 2172 DrawLegend 2174 if { $_contourList(numLevels) != $style(-levels) } { 2175 if { [llength $style(-levels)] > 1 } { 2176 set _contourList(reqValues) [lsort -real $style(-levels)] 2177 } else { 2178 set _settings(-numcontours) $style(-levels) 2179 $itk_component(numcontours) value $style(-levels) 2180 set _contourList(numLevels) $style(-levels) 2181 } 2182 EventuallyChangeContourLevels 2173 2183 } 2174 2184 set _settings(-isosurfacevisible) $style(-isosurfacevisible) … … 2181 2191 set _settings(-zcutplaneposition) $style(-zcutplaneposition) 2182 2192 2183 SendCmd [list contour3d add contourlist $_contourList $tag] 2184 SendCmd "contour3d edges $style(-edges) $tag" 2193 SendCmd "cutplane add $tag" 2194 SendCmd "cutplane color [Color2RGB $itk_option(-plotforeground)] $tag" 2195 SendCmd "cutplane visible $style(-cutplanesvisible) $tag" 2196 2185 2197 SendCmd "outline add $tag" 2186 2198 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 2187 2199 SendCmd "outline visible $style(-outline) $tag" 2188 set _settings(-isosurfaceoutline) $style(-outline) 2200 set _settings(-outline) $style(-outline) 2201 2202 GenerateContourList 2203 SendCmd [list contour3d add contourlist $_contourList(values) $tag] 2204 SendCmd "contour3d visible $style(-isosurfacevisible) $tag" 2205 SendCmd "contour3d edges $style(-edges) $tag" 2189 2206 set _settings(-isosurfaceedges) $style(-edges) 2190 2207 #SendCmd "contour3d color [Color2RGB $settings(-color)] $tag" … … 2193 2210 SendCmd "contour3d linecolor [Color2RGB $style(-edgecolor)] $tag" 2194 2211 SendCmd "contour3d linewidth $style(-linewidth) $tag" 2195 SendCmd "contour3d opacity $ _currentOpacity$tag"2212 SendCmd "contour3d opacity $style(-opacity) $tag" 2196 2213 set _settings(-isosurfaceopacity) $style(-opacity) 2197 2214 SetCurrentColormap $style(-color) 2198 2215 SendCmd "contour3d wireframe $style(-wireframe) $tag" 2199 2216 set _settings(-isosurfacewireframe) $style(-wireframe) 2200 set _settings(-isosurfaceopacity) [expr $style(-opacity) * 100.0]2201 2217 } 2202 2218 … … 2432 2448 incr offset $lineht 2433 2449 } 2434 foreach value $_contourList {2450 foreach value $_contourList(values) { 2435 2451 set norm [expr 1.0 - (($value - $vmin) / $range)] 2436 2452 set y1 [expr int(round(($norm * $ih) + $offset))] … … 2545 2561 bottom "0.707107 0.707107 0 0" 2546 2562 } 2547 foreach name { qw qx qyqz } value $positions($side) {2563 foreach name { -qw -qx -qy -qz } value $positions($side) { 2548 2564 set _view($name) $value 2549 2565 } 2550 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2566 set q [ViewToQuaternion] 2551 2567 $_arcball quaternion $q 2552 2568 SendCmd "camera orient $q" 2553 2569 SendCmd "camera reset" 2554 set _view( xpan) 02555 set _view( ypan) 02556 set _view( zoom) 1.02557 } 2558 2559 itcl::body Rappture::VtkIsosurfaceViewer:: UpdateContourList {} {2570 set _view(-xpan) 0 2571 set _view(-ypan) 0 2572 set _view(-zoom) 1.0 2573 } 2574 2575 itcl::body Rappture::VtkIsosurfaceViewer::GenerateContourList {} { 2560 2576 if { ![info exists _limits($_curFldName)] } { 2561 return 2562 } 2563 if { $_currentNumContours < 1 } { 2564 set _contourList "" 2565 return 2566 } 2567 foreach { vmin vmax } $_limits($_curFldName) break 2568 set v [blt::vector create \#auto] 2569 $v seq $vmin $vmax [expr $_currentNumContours+2] 2570 $v delete end 0 2571 set _contourList [$v range 0 end] 2572 blt::vector destroy $v 2573 } 2574 2577 puts stderr "no _curFldName" 2578 return "" 2579 } 2580 if { $_contourList(numLevels) < 1 } { 2581 # There are tools that set 0 levels to get cutplanes only 2582 #puts stderr "numLevels < 1" 2583 return "" 2584 } 2585 if { [llength $_contourList(reqValues)] > 1 } { 2586 set values $_contourList(reqValues) 2587 } else { 2588 foreach { vmin vmax } $_limits($_curFldName) break 2589 set v [blt::vector create \#auto] 2590 $v seq $vmin $vmax [expr $_contourList(numLevels)+2] 2591 $v delete end 0 2592 set values [$v range 0 end] 2593 blt::vector destroy $v 2594 } 2595 set _contourList(values) $values 2596 } 2597 2598 itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentFieldName { dataobj } { 2599 set _first $dataobj 2600 $itk_component(field) choices delete 0 end 2601 $itk_component(fieldmenu) delete 0 end 2602 array unset _fields 2603 set _curFldName "" 2604 foreach cname [$_first components] { 2605 foreach fname [$_first fieldnames $cname] { 2606 if { [info exists _fields($fname)] } { 2607 continue 2608 } 2609 foreach { label units components } \ 2610 [$_first fieldinfo $fname] break 2611 $itk_component(field) choices insert end "$fname" "$label" 2612 $itk_component(fieldmenu) add radiobutton -label "$label" \ 2613 -value $label -variable [itcl::scope _curFldLabel] \ 2614 -selectcolor red \ 2615 -activebackground $itk_option(-plotbackground) \ 2616 -activeforeground $itk_option(-plotforeground) \ 2617 -font "Arial 8" \ 2618 -command [itcl::code $this Combo invoke] 2619 set _fields($fname) [list $label $units $components] 2620 if { $_curFldName == "" } { 2621 set _curFldName $fname 2622 set _curFldLabel $label 2623 } 2624 } 2625 } 2626 $itk_component(field) value $_curFldLabel 2627 if { ![info exists _limits($_curFldName)] } { 2628 SendCmd "dataset maprange all" 2629 } else { 2630 set limits $_limits($_curFldName) 2631 SendCmd "dataset maprange explicit $limits $_curFldName" 2632 if { $limits != $_currentLimits } { 2633 set _currentLimits $limits 2634 EventuallyChangeContourLevels 2635 } 2636 } 2637 }
Note: See TracChangeset
for help on using the changeset viewer.