Changeset 5014
- Timestamp:
- Feb 12, 2015, 12:59:45 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/vtkglyphviewer.tcl
r4951 r5014 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 2 # ---------------------------------------------------------------------- 4 3 # COMPONENT: vtkglyphviewer - Vtk 3D glyphs object viewer … … 8 7 # ====================================================================== 9 8 # AUTHOR: Michael McLennan, Purdue University 10 # Copyright (c) 2004-20 05 Purdue Research Foundation9 # Copyright (c) 2004-2014 HUBzero Foundation, LLC 11 10 # 12 11 # See the file "license.terms" for information on usage and … … 58 57 public method get {args} 59 58 public method isconnected {} 60 public method limits { colormap }61 59 public method parameters {title args} { 62 60 # do nothing … … 64 62 public method scale {args} 65 63 66 protected method Connect {}67 protected method CurrentDatasets {args}68 protected method Disconnect {}69 protected method DoResize {}70 protected method DoRotate {}71 protected method AdjustSetting {what {value ""}}72 protected method InitSettings { args }73 protected method Pan {option x y}74 protected method Pick {x y}75 protected method Rebuild {}76 protected method ReceiveDataset { args }77 protected method ReceiveImage { args }78 protected method ReceiveLegend { colormap title vmin vmax size }79 protected method Rotate {option x y}80 protected method Zoom {option}81 82 64 # The following methods are only used by this class. 65 private method AdjustSetting {what {value ""}} 83 66 private method BuildAxisTab {} 84 67 private method BuildCameraTab {} … … 89 72 private method DrawLegend {} 90 73 private method Combo { option } 74 private method Connect {} 75 private method CurrentDatasets {args} 76 private method Disconnect {} 77 private method DoResize {} 78 private method DoRotate {} 91 79 private method EnterLegend { x y } 92 80 private method EventuallyResize { w h } … … 96 84 private method GetImage { args } 97 85 private method GetVtkData { args } 86 private method InitSettings { args } 98 87 private method IsValidObject { dataobj } 99 88 private method LeaveLegend {} 100 89 private method MotionLegend { x y } 90 private method Pan {option x y} 101 91 private method PanCamera {} 92 private method Pick {x y} 93 private method QuaternionToView { q } { 94 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 95 } 96 private method Rebuild {} 97 private method ReceiveDataset { args } 98 private method ReceiveImage { args } 99 private method ReceiveLegend { colormap title vmin vmax size } 102 100 private method RequestLegend {} 101 private method Rotate {option x y} 103 102 private method SetLegendTip { x y } 104 103 private method SetObjectStyle { dataobj comp } … … 106 105 private method SetCurrentColormap { color } 107 106 private method SetOrientation { side } 107 private method ViewToQuaternion {} { 108 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 109 } 110 private method Zoom {option} 108 111 109 112 private variable _arcball "" … … 119 122 # heightmaps displayed. 120 123 private variable _currentColormap "" 121 private variable _currentOpacity ""122 124 123 125 private variable _dataset2style ;# maps dataobj-component to transfunc … … 146 148 private variable _legendPending 0 147 149 private variable _field "" 148 private variable _colorMode "vmag"; 150 private variable _colorMode "vmag"; # Mode of colormap (vmag or scalar) 149 151 private variable _fieldNames {} 150 152 private variable _fields … … 184 186 $_dispatcher register !xcutplane 185 187 $_dispatcher dispatch $this !xcutplane \ 186 "[itcl::code $this AdjustSetting cutplaneXPosition]; list"188 "[itcl::code $this AdjustSetting -cutplanexposition]; list" 187 189 188 190 # Y-Cutplane event 189 191 $_dispatcher register !ycutplane 190 192 $_dispatcher dispatch $this !ycutplane \ 191 "[itcl::code $this AdjustSetting cutplaneYPosition]; list"193 "[itcl::code $this AdjustSetting -cutplaneyposition]; list" 192 194 193 195 # Z-Cutplane event 194 196 $_dispatcher register !zcutplane 195 197 $_dispatcher dispatch $this !zcutplane \ 196 "[itcl::code $this AdjustSetting cutplaneZPosition]; list"198 "[itcl::code $this AdjustSetting -cutplanezposition]; list" 197 199 198 200 # … … 205 207 # Initialize the view to some default parameters. 206 208 array set _view { 207 qw 0.853553208 qx -0.353553209 qy0.353553210 qz 0.146447211 zoom 1.0212 xpan 0213 ypan 0214 ortho0209 -ortho 0 210 -qw 0.853553 211 -qx -0.353553 212 -qy 0.353553 213 -qz 0.146447 214 -xpan 0 215 -ypan 0 216 -zoom 1.0 215 217 } 216 218 set _arcball [blt::arcball create 100 100] 217 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 218 $_arcball quaternion $q 219 $_arcball quaternion [ViewToQuaternion] 219 220 220 221 array set _settings [subst { 221 background black 222 colormap BCGYR 223 colormapVisible 1 224 field "Default" 225 axesVisible 1 226 axisLabelsVisible 1 227 axisXGrid 0 228 axisYGrid 0 229 axisZGrid 0 230 cutplaneEdges 0 231 cutplaneLighting 1 232 cutplanePreinterp 1 233 cutplaneOpacity 100 234 cutplaneVisible 0 235 cutplaneWireframe 0 236 cutplaneXPosition 50 237 cutplaneXVisible 1 238 cutplaneYPosition 50 239 cutplaneYVisible 1 240 cutplaneZPosition 50 241 cutplaneZVisible 1 242 glyphEdges 0 243 glyphLighting 1 244 glyphOpacity 100 245 saveGlyphOpacity 100 246 glyphOutline 0 247 glyphVisible 1 248 glyphWireframe 0 249 legendVisible 1 222 -axesvisible 1 223 -axislabels 1 224 -axisminorticks 1 225 -axismode "static" 226 -background black 227 -colormap BCGYR 228 -colormapvisible 1 229 -cutplaneedges 0 230 -cutplanelighting 1 231 -cutplanepreinterp 1 232 -cutplaneopacity 100 233 -cutplanevisible 0 234 -cutplanewireframe 0 235 -cutplanexposition 50 236 -cutplanexvisible 1 237 -cutplaneyposition 50 238 -cutplaneyvisible 1 239 -cutplanezposition 50 240 -cutplanezvisible 1 241 -field "Default" 242 -glyphedges 0 243 -glyphlighting 1 244 -glyphnormscale 1 245 -glyphopacity 100 246 -glyphorient 1 247 -glyphoutline 0 248 -glyphscale 1 249 -glyphscalemode "vmag" 250 -glyphshape "arrow" 251 -glyphvisible 1 252 -glyphwireframe 0 253 -legendvisible 1 254 -saveglyphopacity 100 255 -xgrid 0 256 -ygrid 0 257 -zgrid 0 250 258 }] 251 259 array set _changed { 252 glyphOpacity0253 colormap0260 -colormap 0 261 -glyphopacity 0 254 262 } 255 263 … … 331 339 -onimage [Rappture::icon volume-on] \ 332 340 -offimage [Rappture::icon volume-off] \ 333 -variable [itcl::scope _settings( glyphVisible)] \334 -command [itcl::code $this AdjustSetting glyphVisible]341 -variable [itcl::scope _settings(-glyphvisible)] \ 342 -command [itcl::code $this AdjustSetting -glyphvisible] 335 343 } 336 344 $itk_component(glyphs) select … … 344 352 -onimage [Rappture::icon cutbutton] \ 345 353 -offimage [Rappture::icon cutbutton] \ 346 -variable [itcl::scope _settings( cutplaneVisible)] \347 -command [itcl::code $this AdjustSetting cutplaneVisible]354 -variable [itcl::scope _settings(-cutplanevisible)] \ 355 -command [itcl::code $this AdjustSetting -cutplanevisible] 348 356 } 349 357 Rappture::Tooltip::for $itk_component(cutplane) \ … … 462 470 463 471 itcl::body Rappture::VtkGlyphViewer::DoRotate {} { 464 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 465 SendCmd "camera orient $q" 472 SendCmd "camera orient [ViewToQuaternion]" 466 473 set _rotatePending 0 467 474 } … … 487 494 488 495 itcl::body Rappture::VtkGlyphViewer::EventuallyRotate { q } { 489 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break496 QuaternionToView $q 490 497 if { !$_rotatePending } { 491 498 set _rotatePending 1 … … 542 549 } 543 550 544 545 551 # ---------------------------------------------------------------------- 546 552 # USAGE: delete ?<dataobj1> <dataobj2> ...? 547 553 # 548 # 549 # 550 # 554 # Clients use this to delete a dataobj from the plot. If no dataobjs 555 # are specified, then all dataobjs are deleted. No data objects are 556 # deleted. They are only removed from the display list. 551 557 # 552 558 # ---------------------------------------------------------------------- … … 798 804 # isconnected -- 799 805 # 800 # 806 # Indicates if we are currently connected to the visualization server. 801 807 # 802 808 itcl::body Rappture::VtkGlyphViewer::isconnected {} { … … 815 821 # Disconnect -- 816 822 # 817 # 818 # 823 # Clients use this method to disconnect from the current rendering 824 # server. 819 825 # 820 826 itcl::body Rappture::VtkGlyphViewer::Disconnect {} { … … 833 839 array unset _data 834 840 array unset _colormaps 835 array unset _seeds836 841 array unset _dataset2style 837 842 array unset _obj2datasets … … 855 860 if { $info(-type) == "image" } { 856 861 if 0 { 857 set f [open "last.ppm" "w"] 858 puts $f $bytes 862 set f [open "last.ppm" "w"] 863 fconfigure $f -encoding binary 864 puts -nonewline $f $bytes 859 865 close $f 860 866 } … … 944 950 # Reset the camera and other view parameters 945 951 # 946 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 947 $_arcball quaternion $q 948 if {$_view(ortho)} { 952 $_arcball quaternion [ViewToQuaternion] 953 if {$_view(-ortho)} { 949 954 SendCmd "camera mode ortho" 950 955 } else { … … 954 959 PanCamera 955 960 set _first "" 956 InitSettings axisXGrid axisYGrid axisZGrid axisMode \ 957 axesVisible axisLabelsVisible 958 foreach axis { x y z } { 959 SendCmd "axis lformat $axis %g" 960 } 961 InitSettings -xgrid -ygrid -zgrid -axismode \ 962 -axesvisible -axislabels -axisminorticks 963 #SendCmd "axis lformat all %g" 961 964 StopBufferingCommands 962 965 SendCmd "imgflush" … … 974 977 if { ![info exists _datasets($tag)] } { 975 978 set bytes [$dataobj vtkdata $comp] 976 if 0 { 977 set f [open "/tmp/glyph.vtk" "w"] 978 puts $f $bytes 979 close $f 979 if 0 { 980 set f [open "/tmp/glyph.vtk" "w"] 981 fconfigure $f -translation binary -encoding binary 982 puts -nonewline $f $bytes 983 close $f 980 984 } 981 985 set length [string length $bytes] … … 992 996 SendCmd "clientinfo [list $info]" 993 997 } 994 append _outbuf "dataset add $tag data follows $length\n"998 SendCmd "dataset add $tag data follows $length" 995 999 append _outbuf $bytes 996 1000 set _datasets($tag) 1 … … 1001 1005 # Setting dataset visible enables outline 1002 1006 # and glyphs 1003 1007 SendCmd "dataset visible 1 $tag" 1004 1008 } 1005 1009 } … … 1007 1011 1008 1012 if { $_first != "" } { 1009 1010 1011 1013 $itk_component(field) choices delete 0 end 1014 $itk_component(fieldmenu) delete 0 end 1015 array unset _fields 1012 1016 set _curFldName "" 1013 1017 foreach cname [$_first components] { … … 1035 1039 $itk_component(field) value $_curFldLabel 1036 1040 } 1037 InitSettings glyphOutline1038 # cutplaneVisible1041 InitSettings -glyphoutline 1042 #-cutplanevisible 1039 1043 if { $_reset } { 1040 1044 # These are settings that rely on a dataset being loaded. 1041 1045 InitSettings \ 1042 glyphLighting \ 1043 field \ 1044 glyphEdges glyphLighting glyphOpacity \ 1045 glyphWireframe 1046 1047 #cutplaneXPosition cutplaneYPosition cutplaneZPosition \ 1048 cutplaneXVisible cutplaneYVisible cutplaneZVisible \ 1049 cutplanePreinterp 1046 -field \ 1047 -glyphedges -glyphlighting -glyphopacity \ 1048 -glyphwireframe 1049 1050 #-cutplanexposition -cutplaneyposition -cutplanezposition \ 1051 -cutplanexvisible -cutplaneyvisible -cutplanezvisible \ 1052 -cutplanepreinterp 1050 1053 1051 1054 Zoom reset 1052 1055 foreach axis { x y z } { 1053 1056 # Another problem fixed by a <view>. We looking into a data 1054 1057 # object for the name of the axes. This should be global to 1055 1058 # the viewer itself. 1056 1057 1059 set label [$_first hints ${axis}label] 1060 if { $label == "" } { 1058 1061 set label [string toupper $axis] 1059 1060 1061 1062 } 1063 # May be a space in the axis label. 1064 SendCmd [list axis name $axis $label] 1062 1065 } 1063 1066 if { [array size _fields] < 2 } { … … 1130 1133 switch -- $option { 1131 1134 "in" { 1132 set _view( zoom) [expr {$_view(zoom)*1.25}]1133 SendCmd "camera zoom $_view( zoom)"1135 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1136 SendCmd "camera zoom $_view(-zoom)" 1134 1137 } 1135 1138 "out" { 1136 set _view( zoom) [expr {$_view(zoom)*0.8}]1137 SendCmd "camera zoom $_view( zoom)"1139 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1140 SendCmd "camera zoom $_view(-zoom)" 1138 1141 } 1139 1142 "reset" { 1140 1143 array set _view { 1141 qw0.8535531142 qx-0.3535531143 qy0.3535531144 qz0.1464471145 zoom 1.01146 xpan01147 ypan01144 -qw 0.853553 1145 -qx -0.353553 1146 -qy 0.353553 1147 -qz 0.146447 1148 -xpan 0 1149 -ypan 0 1150 -zoom 1.0 1148 1151 } 1149 1152 if { $_first != "" } { … … 1153 1156 } 1154 1157 } 1155 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1156 $_arcball quaternion $q 1158 $_arcball quaternion [ViewToQuaternion] 1157 1159 DoRotate 1158 1160 SendCmd "camera reset" … … 1162 1164 1163 1165 itcl::body Rappture::VtkGlyphViewer::PanCamera {} { 1164 set x $_view( xpan)1165 set y $_view( ypan)1166 set x $_view(-xpan) 1167 set y $_view(-ypan) 1166 1168 SendCmd "camera pan $x $y" 1167 1169 } 1168 1169 1170 1170 1171 # ---------------------------------------------------------------------- … … 1222 1223 itcl::body Rappture::VtkGlyphViewer::Pick {x y} { 1223 1224 foreach tag [CurrentDatasets -visible] { 1224 SendCmd NoSplash"dataset getscalar pixel $x $y $tag"1225 SendCmd "dataset getscalar pixel $x $y $tag" 1225 1226 } 1226 1227 } … … 1241 1242 set x [expr $x / double($w)] 1242 1243 set y [expr $y / double($h)] 1243 set _view( xpan) [expr $_view(xpan) + $x]1244 set _view( ypan) [expr $_view(ypan) + $y]1244 set _view(-xpan) [expr $_view(-xpan) + $x] 1245 set _view(-ypan) [expr $_view(-ypan) + $y] 1245 1246 PanCamera 1246 1247 return … … 1264 1265 set _click(x) $x 1265 1266 set _click(y) $y 1266 set _view( xpan) [expr $_view(xpan) - $dx]1267 set _view( ypan) [expr $_view(ypan) - $dy]1267 set _view(-xpan) [expr $_view(-xpan) - $dx] 1268 set _view(-ypan) [expr $_view(-ypan) - $dy] 1268 1269 PanCamera 1269 1270 } … … 1287 1288 itcl::body Rappture::VtkGlyphViewer::InitSettings { args } { 1288 1289 foreach spec $args { 1289 if { [info exists _settings($_first -$spec)] } {1290 if { [info exists _settings($_first${spec})] } { 1290 1291 # Reset global setting with dataobj specific setting 1291 set _settings($spec) $_settings($_first -$spec)1292 set _settings($spec) $_settings($_first${spec}) 1292 1293 } 1293 1294 AdjustSetting $spec … … 1298 1299 # AdjustSetting -- 1299 1300 # 1300 # 1301 # 1302 # 1301 # Changes/updates a specific setting in the widget. There are 1302 # usually user-setable option. Commands are sent to the render 1303 # server. 1303 1304 # 1304 1305 itcl::body Rappture::VtkGlyphViewer::AdjustSetting {what {value ""}} { … … 1307 1308 } 1308 1309 switch -- $what { 1309 " background" {1310 "-background" { 1310 1311 set bgcolor [$itk_component(background) value] 1311 1312 1313 1314 "grey""black"1315 1312 array set fgcolors { 1313 "black" "white" 1314 "white" "black" 1315 "grey" "black" 1316 } 1316 1317 configure -plotbackground $bgcolor \ 1317 1318 1319 1320 } 1321 " axesVisible" {1322 set bool $_settings( axesVisible)1318 -plotforeground $fgcolors($bgcolor) 1319 $itk_component(view) delete "legend" 1320 DrawLegend 1321 } 1322 "-axesvisible" { 1323 set bool $_settings($what) 1323 1324 SendCmd "axis visible all $bool" 1324 1325 } 1325 " axisLabelsVisible" {1326 set bool $_settings( axisLabelsVisible)1326 "-axislabels" { 1327 set bool $_settings($what) 1327 1328 SendCmd "axis labels all $bool" 1328 1329 } 1329 "axisXGrid" - "axisYGrid" - "axisZGrid" { 1330 set axis [string tolower [string range $what 4 4]] 1330 "-axisminorticks" { 1331 set bool $_settings($what) 1332 SendCmd "axis minticks all $bool" 1333 } 1334 "-xgrid" - "-ygrid" - "-zgrid" { 1335 set axis [string tolower [string range $what 1 1]] 1331 1336 set bool $_settings($what) 1332 1337 SendCmd "axis grid $axis $bool" 1333 1338 } 1334 " axisMode" {1339 "-axismode" { 1335 1340 set mode [$itk_component(axisMode) value] 1336 1341 set mode [$itk_component(axisMode) translate $mode] … … 1338 1343 SendCmd "axis flymode $mode" 1339 1344 } 1340 " cutplaneEdges" {1345 "-cutplaneedges" { 1341 1346 set bool $_settings($what) 1342 1347 SendCmd "cutplane edges $bool" 1343 1348 } 1344 " cutplaneVisible" {1349 "-cutplanevisible" { 1345 1350 set bool $_settings($what) 1346 SendCmd "cutplane visible $bool" 1347 } 1348 "cutplaneWireframe" { 1351 SendCmd "cutplane visible 0" 1352 if { $bool } { 1353 foreach tag [CurrentDatasets -visible] { 1354 SendCmd "cutplane visible $bool $tag" 1355 } 1356 } 1357 } 1358 "-cutplanewireframe" { 1349 1359 set bool $_settings($what) 1350 1360 SendCmd "cutplane wireframe $bool" 1351 1361 } 1352 " cutplaneLighting" {1362 "-cutplanelighting" { 1353 1363 set bool $_settings($what) 1354 1364 SendCmd "cutplane lighting $bool" 1355 1365 } 1356 " cutplaneOpacity" {1366 "-cutplaneopacity" { 1357 1367 set val $_settings($what) 1358 1368 set sval [expr { 0.01 * double($val) }] 1359 1369 SendCmd "cutplane opacity $sval" 1360 1370 } 1361 " cutplanePreinterp" {1371 "-cutplanepreinterp" { 1362 1372 set bool $_settings($what) 1363 1373 SendCmd "cutplane preinterp $bool" 1364 1374 } 1365 " cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" {1366 set axis [string tolower [string range $what 8 8]]1375 "-cutplanexvisible" - "-cutplaneyvisible" - "-cutplanezvisible" { 1376 set axis [string tolower [string range $what 9 9]] 1367 1377 set bool $_settings($what) 1368 1378 if { $bool } { … … 1373 1383 -troughcolor grey82 1374 1384 } 1375 1376 } 1377 " cutplaneXPosition" - "cutplaneYPosition" - "cutplaneZPosition" {1378 set axis [string tolower [string range $what 8 8]]1385 SendCmd "cutplane axis $axis $bool" 1386 } 1387 "-cutplanexposition" - "-cutplaneyposition" - "-cutplanezposition" { 1388 set axis [string tolower [string range $what 9 9]] 1379 1389 set pos [expr $_settings($what) * 0.01] 1380 1390 SendCmd "cutplane slice ${axis} ${pos}" 1381 1391 set _cutplanePending 0 1382 1392 } 1383 " colormap" {1384 set _changed( colormap) 11393 "-colormap" { 1394 set _changed($what) 1 1385 1395 StartBufferingCommands 1386 1396 set color [$itk_component(colormap) value] 1387 set _settings( colormap) $color1388 1389 if { $_settings(colormapVisible) } {1390 1391 set _settings(colormapVisible) 01392 1393 1394 if { !$_settings(colormapVisible) } {1395 1396 set _settings(colormapVisible) 11397 1398 1399 1397 set _settings($what) $color 1398 if { $color == "none" } { 1399 if { $_settings(-colormapvisible) } { 1400 SendCmd "glyphs colormode constant {}" 1401 set _settings(-colormapvisible) 0 1402 } 1403 } else { 1404 if { !$_settings(-colormapvisible) } { 1405 SendCmd "glyphs colormode $_colorMode $_curFldName" 1406 set _settings(-colormapvisible) 1 1407 } 1408 SetCurrentColormap $color 1409 } 1400 1410 StopBufferingCommands 1401 EventuallyRequestLegend 1402 } 1403 "glyphWireframe" { 1404 set bool $_settings(glyphWireframe) 1405 SendCmd "glyphs wireframe $bool" 1406 } 1407 "glyphVisible" { 1408 set bool $_settings(glyphVisible) 1409 SendCmd "glyphs visible $bool" 1411 EventuallyRequestLegend 1412 } 1413 "-glyphwireframe" { 1414 set bool $_settings($what) 1415 SendCmd "glyphs wireframe $bool" 1416 } 1417 "-glyphvisible" { 1418 set bool $_settings($what) 1419 SendCmd "glyphs visible 0" 1420 if { $bool } { 1421 foreach tag [CurrentDatasets -visible] { 1422 SendCmd "glyphs visible $bool $tag" 1423 } 1424 } 1410 1425 if { $bool } { 1411 1426 Rappture::Tooltip::for $itk_component(glyphs) \ … … 1415 1430 "Show the glyph" 1416 1431 } 1417 DrawLegend 1418 } 1419 "glyphLighting" { 1420 set bool $_settings(glyphLighting) 1421 SendCmd "glyphs lighting $bool" 1422 } 1423 "glyphEdges" { 1424 set bool $_settings(glyphEdges) 1425 SendCmd "glyphs edges $bool" 1426 } 1427 "glyphOutline" { 1428 set bool $_settings(glyphOutline) 1429 SendCmd "outline visible $bool" 1430 } 1431 "glyphOpacity" { 1432 set val $_settings(glyphOpacity) 1432 DrawLegend 1433 } 1434 "-glyphlighting" { 1435 set bool $_settings($what) 1436 SendCmd "glyphs lighting $bool" 1437 } 1438 "-glyphedges" { 1439 set bool $_settings($what) 1440 SendCmd "glyphs edges $bool" 1441 } 1442 "-glyphoutline" { 1443 set bool $_settings($what) 1444 SendCmd "outline visible 0" 1445 if { $bool } { 1446 foreach tag [CurrentDatasets -visible] { 1447 SendCmd "outline visible $bool $tag" 1448 } 1449 } 1450 } 1451 "-glyphopacity" { 1452 set val $_settings($what) 1433 1453 set sval [expr { 0.01 * double($val) }] 1434 SendCmd "glyphs opacity $sval" 1435 } 1436 "field" { 1454 SendCmd "glyphs opacity $sval" 1455 } 1456 "-glyphnormscale" { 1457 set bool $_settings($what) 1458 SendCmd "glyphs normscale $bool" 1459 } 1460 "-glyphorient" { 1461 set bool $_settings($what) 1462 SendCmd "glyphs gorient $bool {}" 1463 } 1464 "-glyphscale" { 1465 set val $_settings($what) 1466 if { [string is double $val] } { 1467 SendCmd "glyphs gscale $val" 1468 } 1469 } 1470 "-glyphscalemode" { 1471 set label [$itk_component(scaleMode) value] 1472 set mode [$itk_component(scaleMode) translate $label] 1473 set _settings($what) $mode 1474 SendCmd "glyphs smode $mode {}" 1475 } 1476 "-glyphshape" { 1477 set label [$itk_component(gshape) value] 1478 set shape [$itk_component(gshape) translate $label] 1479 set _settings($what) $shape 1480 SendCmd "glyphs shape $shape" 1481 } 1482 "-field" { 1437 1483 set label [$itk_component(field) value] 1438 1484 set fname [$itk_component(field) translate $label] 1439 set _settings( field) $fname1485 set _settings($what) $fname 1440 1486 if { [info exists _fields($fname)] } { 1441 1487 foreach { label units components } $_fields($fname) break … … 1451 1497 return 1452 1498 } 1453 #SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" 1499 #if { ![info exists _limits($_curFldName)] } { 1500 # SendCmd "dataset maprange all" 1501 #} else { 1502 # SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" 1503 #} 1454 1504 #SendCmd "cutplane colormode $_colorMode $_curFldName" 1455 1505 SendCmd "glyphs colormode $_colorMode $_curFldName" 1456 1506 DrawLegend 1457 1507 } 1458 " legendVisible" {1459 if { !$_settings( legendVisible) } {1508 "-legendvisible" { 1509 if { !$_settings($what) } { 1460 1510 $itk_component(view) delete legend 1461 1462 1511 } 1512 DrawLegend 1463 1513 } 1464 1514 default { … … 1468 1518 } 1469 1519 1470 1471 1520 # 1472 1521 # RequestLegend -- 1473 1522 # 1474 # 1475 # 1523 # Request a new legend from the server. The size of the legend 1524 # is determined from the height of the canvas. 1476 1525 # 1477 1526 # This should be called when 1478 # 1479 # 1480 # 1481 # 1482 # 1527 # 1. A new current colormap is set. 1528 # 2. Window is resized. 1529 # 3. The limits of the data have changed. (Just need a redraw). 1530 # 4. Number of glyph have changed. (Just need a redraw). 1531 # 5. Legend becomes visible (Just need a redraw). 1483 1532 # 1484 1533 itcl::body Rappture::VtkGlyphViewer::RequestLegend {} { 1485 1534 set _legendPending 0 1486 if { ![info exists _fields($_curFldName)] } { 1487 return 1488 } 1535 set font "Arial 8" 1536 set w 12 1537 set lineht [font metrics $font -linespace] 1538 # color ramp height = (canvas height) - (min and max value lines) - 2 1539 set h [expr {$_height - 2 * ($lineht + 2)}] 1540 1489 1541 set fname $_curFldName 1490 set font "Arial 8"1491 set lineht [font metrics $font -linespace]1492 set w 121493 set h [expr {$_height - 2 * ($lineht + 2)}]1494 if { $h < 1 } {1495 return1496 }1497 1542 if { [string match "component*" $fname] } { 1498 1543 set title "" 1499 1544 } else { 1500 1501 1502 1503 1504 1505 1506 1507 1545 if { [info exists _fields($fname)] } { 1546 foreach { title units } $_fields($fname) break 1547 if { $units != "" } { 1548 set title [format "%s (%s)" $title $units] 1549 } 1550 } else { 1551 set title $fname 1552 } 1508 1553 } 1509 1554 # If there's a title too, substract one more line … … 1511 1556 incr h -$lineht 1512 1557 } 1558 if { $h < 1 } { 1559 return 1560 } 1513 1561 # Set the legend on the first heightmap dataset. 1514 1562 if { $_currentColormap != "" } { 1515 1516 1563 set cmap $_currentColormap 1564 SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0" 1517 1565 } 1518 1566 } … … 1534 1582 if { [isconnected] } { 1535 1583 set rgb [Color2RGB $itk_option(-plotforeground)] 1536 1584 SendCmd "axis color all $rgb" 1537 1585 SendCmd "outline color $rgb" 1538 1586 #SendCmd "cutplane color $rgb" 1539 1587 } 1540 }1541 1542 itcl::body Rappture::VtkGlyphViewer::limits { dataobj } {1543 foreach { limits(xmin) limits(xmax) } [$dataobj limits x] break1544 foreach { limits(ymin) limits(ymax) } [$dataobj limits y] break1545 foreach { limits(zmin) limits(zmax) } [$dataobj limits z] break1546 foreach { limits(vmin) limits(vmax) } [$dataobj limits v] break1547 return [array get limits]1548 1588 } 1549 1589 … … 1560 1600 checkbutton $inner.glyphs \ 1561 1601 -text "Glyphs" \ 1562 -variable [itcl::scope _settings( glyphVisible)] \1563 -command [itcl::code $this AdjustSetting glyphVisible] \1602 -variable [itcl::scope _settings(-glyphvisible)] \ 1603 -command [itcl::code $this AdjustSetting -glyphvisible] \ 1564 1604 -font "Arial 9" 1605 1606 label $inner.gshape_l -text "Glyph shape" -font "Arial 9" 1607 itk_component add gshape { 1608 Rappture::Combobox $inner.gshape -width 10 -editable no 1609 } 1610 $inner.gshape choices insert end \ 1611 "arrow" "arrow" \ 1612 "cone" "cone" \ 1613 "cube" "cube" \ 1614 "cylinder" "cylinder" \ 1615 "dodecahedron" "dodecahedron" \ 1616 "icosahedron" "icosahedron" \ 1617 "line" "line" \ 1618 "octahedron" "octahedron" \ 1619 "point" "point" \ 1620 "sphere" "sphere" \ 1621 "tetrahedron" "tetrahedron" 1622 1623 $itk_component(gshape) value $_settings(-glyphshape) 1624 bind $inner.gshape <<Value>> [itcl::code $this AdjustSetting -glyphshape] 1625 1626 label $inner.scaleMode_l -text "Scale by" -font "Arial 9" 1627 itk_component add scaleMode { 1628 Rappture::Combobox $inner.scaleMode -width 10 -editable no 1629 } 1630 $inner.scaleMode choices insert end \ 1631 "scalar" "Scalar" \ 1632 "vmag" "Vector magnitude" \ 1633 "vcomp" "Vector components" \ 1634 "off" "Constant size" 1635 1636 $itk_component(scaleMode) value "[$itk_component(scaleMode) label $_settings(-glyphscalemode)]" 1637 bind $inner.scaleMode <<Value>> [itcl::code $this AdjustSetting -glyphscalemode] 1638 1639 checkbutton $inner.normscale \ 1640 -text "Normalize scaling" \ 1641 -variable [itcl::scope _settings(-glyphnormscale)] \ 1642 -command [itcl::code $this AdjustSetting -glyphnormscale] \ 1643 -font "Arial 9" 1644 Rappture::Tooltip::for $inner.normscale "If enabled, field values are normalized to \[0,1\] before scaling and scale factor is relative to a default size" 1645 1646 checkbutton $inner.gorient \ 1647 -text "Orient" \ 1648 -variable [itcl::scope _settings(-glyphorient)] \ 1649 -command [itcl::code $this AdjustSetting -glyphorient] \ 1650 -font "Arial 9" 1651 Rappture::Tooltip::for $inner.gorient "Orient glyphs by vector field directions" 1565 1652 1566 1653 checkbutton $inner.wireframe \ 1567 1654 -text "Wireframe" \ 1568 -variable [itcl::scope _settings( glyphWireframe)] \1569 -command [itcl::code $this AdjustSetting glyphWireframe] \1655 -variable [itcl::scope _settings(-glyphwireframe)] \ 1656 -command [itcl::code $this AdjustSetting -glyphwireframe] \ 1570 1657 -font "Arial 9" 1571 1658 1572 1659 checkbutton $inner.lighting \ 1573 1660 -text "Enable Lighting" \ 1574 -variable [itcl::scope _settings( glyphLighting)] \1575 -command [itcl::code $this AdjustSetting glyphLighting] \1661 -variable [itcl::scope _settings(-glyphlighting)] \ 1662 -command [itcl::code $this AdjustSetting -glyphlighting] \ 1576 1663 -font "Arial 9" 1577 1664 1578 1665 checkbutton $inner.edges \ 1579 1666 -text "Edges" \ 1580 -variable [itcl::scope _settings( glyphEdges)] \1581 -command [itcl::code $this AdjustSetting glyphEdges] \1667 -variable [itcl::scope _settings(-glyphedges)] \ 1668 -command [itcl::code $this AdjustSetting -glyphedges] \ 1582 1669 -font "Arial 9" 1583 1670 1584 1671 checkbutton $inner.outline \ 1585 1672 -text "Outline" \ 1586 -variable [itcl::scope _settings( glyphOutline)] \1587 -command [itcl::code $this AdjustSetting glyphOutline] \1673 -variable [itcl::scope _settings(-glyphoutline)] \ 1674 -command [itcl::code $this AdjustSetting -glyphoutline] \ 1588 1675 -font "Arial 9" 1589 1676 1590 1677 checkbutton $inner.legend \ 1591 1678 -text "Legend" \ 1592 -variable [itcl::scope _settings( legendVisible)] \1593 -command [itcl::code $this AdjustSetting legendVisible] \1679 -variable [itcl::scope _settings(-legendvisible)] \ 1680 -command [itcl::code $this AdjustSetting -legendvisible] \ 1594 1681 -font "Arial 9" 1595 1682 … … 1603 1690 "grey" "grey" 1604 1691 1605 $itk_component(background) value $_settings( background)1606 bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]1692 $itk_component(background) value $_settings(-background) 1693 bind $inner.background <<Value>> [itcl::code $this AdjustSetting -background] 1607 1694 1608 1695 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1609 1696 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1610 -variable [itcl::scope _settings( glyphOpacity)] \1697 -variable [itcl::scope _settings(-glyphopacity)] \ 1611 1698 -width 10 \ 1612 1699 -showvalue off \ 1613 -command [itcl::code $this AdjustSetting glyphOpacity] 1614 1615 label $inner.scale_l -text "Scale" -font "Arial 9" 1616 ::scale $inner.scale -from 1 -to 100 -orient horizontal \ 1617 -variable [itcl::scope _settings(glyphs-scale)] \ 1700 -command [itcl::code $this AdjustSetting -glyphopacity] 1701 1702 label $inner.gscale_l -text "Scale factor" -font "Arial 9" 1703 if {0} { 1704 ::scale $inner.gscale -from 1 -to 100 -orient horizontal \ 1705 -variable [itcl::scope _settings(-glyphscale)] \ 1618 1706 -width 10 \ 1619 1707 -showvalue off \ 1620 -command [itcl::code $this AdjustSetting glyphs-scale] 1708 -command [itcl::code $this AdjustSetting -glyphscale] 1709 } else { 1710 itk_component add gscale { 1711 entry $inner.gscale -font "Arial 9" -bg white \ 1712 -textvariable [itcl::scope _settings(-glyphscale)] 1713 } { 1714 ignore -font -background 1715 } 1716 bind $inner.gscale <Return> \ 1717 [itcl::code $this AdjustSetting -glyphscale] 1718 bind $inner.gscale <KP_Enter> \ 1719 [itcl::code $this AdjustSetting -glyphscale] 1720 } 1721 Rappture::Tooltip::for $inner.gscale "Set scaling multiplier (or constant size)" 1621 1722 1622 1723 itk_component add field_l { … … 1629 1730 } 1630 1731 bind $inner.field <<Value>> \ 1631 [itcl::code $this AdjustSetting field]1732 [itcl::code $this AdjustSetting -field] 1632 1733 1633 1734 label $inner.colormap_l -text "Colormap" -font "Arial 9" … … 1635 1736 Rappture::Combobox $inner.colormap -width 10 -editable no 1636 1737 } 1637 $inner.colormap choices insert end \ 1638 "BCGYR" "BCGYR" \ 1639 "BGYOR" "BGYOR" \ 1640 "blue" "blue" \ 1641 "blue-to-brown" "blue-to-brown" \ 1642 "blue-to-orange" "blue-to-orange" \ 1643 "blue-to-grey" "blue-to-grey" \ 1644 "green-to-magenta" "green-to-magenta" \ 1645 "greyscale" "greyscale" \ 1646 "nanohub" "nanohub" \ 1647 "rainbow" "rainbow" \ 1648 "spectral" "spectral" \ 1649 "ROYGB" "ROYGB" \ 1650 "RYGCB" "RYGCB" \ 1651 "brown-to-blue" "brown-to-blue" \ 1652 "grey-to-blue" "grey-to-blue" \ 1653 "orange-to-blue" "orange-to-blue" 1654 1738 1739 $inner.colormap choices insert end [GetColormapList] 1655 1740 $itk_component(colormap) value "BCGYR" 1656 1741 bind $inner.colormap <<Value>> \ 1657 [itcl::code $this AdjustSetting colormap]1742 [itcl::code $this AdjustSetting -colormap] 1658 1743 1659 1744 blt::table $inner \ 1660 0,0 $inner.field_l -anchor w -pady 2 \1661 0,1 $inner.field -anchor w -pady 2 -fill x \1662 1,0 $inner.colormap_l -anchor w -pady 2 \1663 1,1 $inner.colormap -anchor w -pady 2 -fill x \1664 1665 3,1 $inner.background-anchor w -pady 2 -fill x \1666 5,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \1667 6,0 $inner.lighting -anchor w -pady 2 -cspan 2 \1668 7,0 $inner.edges -anchor w -pady 2 -cspan 2 \1669 8,0 $inner.outline -anchor w -pady 2 -cspan 2 \1670 9,0 $inner.legend -anchor w -pady 2 \1671 10,0 $inner.opacity_l -anchor w -pady 2 \1672 10,1 $inner.opacity -fill x -pady 2 -fill x \1745 0,0 $inner.field_l -anchor w -pady 2 \ 1746 0,1 $inner.field -anchor w -pady 2 -fill x \ 1747 1,0 $inner.colormap_l -anchor w -pady 2 \ 1748 1,1 $inner.colormap -anchor w -pady 2 -fill x \ 1749 3,0 $inner.background_l -anchor w -pady 2 \ 1750 3,1 $inner.background -anchor w -pady 2 -fill x \ 1751 5,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \ 1752 6,0 $inner.lighting -anchor w -pady 2 -cspan 2 \ 1753 7,0 $inner.edges -anchor w -pady 2 -cspan 2 \ 1754 8,0 $inner.outline -anchor w -pady 2 -cspan 2 \ 1755 9,0 $inner.legend -anchor w -pady 2 \ 1756 10,0 $inner.opacity_l -anchor w -pady 2 \ 1757 10,1 $inner.opacity -fill x -pady 2 -fill x \ 1673 1758 1674 1759 blt::table configure $inner r* c* -resize none … … 1687 1772 1688 1773 checkbutton $inner.visible \ 1689 -text " ShowAxes" \1690 -variable [itcl::scope _settings( axesVisible)] \1691 -command [itcl::code $this AdjustSetting axesVisible] \1774 -text "Axes" \ 1775 -variable [itcl::scope _settings(-axesvisible)] \ 1776 -command [itcl::code $this AdjustSetting -axesvisible] \ 1692 1777 -font "Arial 9" 1693 1778 1694 1779 checkbutton $inner.labels \ 1695 -text " ShowAxis Labels" \1696 -variable [itcl::scope _settings( axisLabelsVisible)] \1697 -command [itcl::code $this AdjustSetting axisLabelsVisible] \1780 -text "Axis Labels" \ 1781 -variable [itcl::scope _settings(-axislabels)] \ 1782 -command [itcl::code $this AdjustSetting -axislabels] \ 1698 1783 -font "Arial 9" 1699 1700 checkbutton $inner. gridx\1701 -text " Show X Grid" \1702 -variable [itcl::scope _settings( axisXGrid)] \1703 -command [itcl::code $this AdjustSetting axisXGrid] \1784 label $inner.grid_l -text "Grid" -font "Arial 9" 1785 checkbutton $inner.xgrid \ 1786 -text "X" \ 1787 -variable [itcl::scope _settings(-xgrid)] \ 1788 -command [itcl::code $this AdjustSetting -xgrid] \ 1704 1789 -font "Arial 9" 1705 checkbutton $inner. gridy\1706 -text " Show Y Grid" \1707 -variable [itcl::scope _settings( axisYGrid)] \1708 -command [itcl::code $this AdjustSetting axisYGrid] \1790 checkbutton $inner.ygrid \ 1791 -text "Y" \ 1792 -variable [itcl::scope _settings(-ygrid)] \ 1793 -command [itcl::code $this AdjustSetting -ygrid] \ 1709 1794 -font "Arial 9" 1710 checkbutton $inner.gridz \ 1711 -text "Show Z Grid" \ 1712 -variable [itcl::scope _settings(axisZGrid)] \ 1713 -command [itcl::code $this AdjustSetting axisZGrid] \ 1795 checkbutton $inner.zgrid \ 1796 -text "Z" \ 1797 -variable [itcl::scope _settings(-zgrid)] \ 1798 -command [itcl::code $this AdjustSetting -zgrid] \ 1799 -font "Arial 9" 1800 checkbutton $inner.minorticks \ 1801 -text "Minor Ticks" \ 1802 -variable [itcl::scope _settings(-axisminorticks)] \ 1803 -command [itcl::code $this AdjustSetting -axisminorticks] \ 1714 1804 -font "Arial 9" 1715 1805 … … 1724 1814 "furthest_triad" "farthest" \ 1725 1815 "outer_edges" "outer" 1726 $itk_component(axisMode) value "static"1727 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisMode]1816 $itk_component(axisMode) value $_settings(-axismode) 1817 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] 1728 1818 1729 1819 blt::table $inner \ 1730 0,0 $inner.visible -anchor w -cspan 2 \ 1731 1,0 $inner.labels -anchor w -cspan 2 \ 1732 2,0 $inner.gridx -anchor w -cspan 2 \ 1733 3,0 $inner.gridy -anchor w -cspan 2 \ 1734 4,0 $inner.gridz -anchor w -cspan 2 \ 1735 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1736 6,0 $inner.mode -fill x -cspan 2 1820 0,0 $inner.visible -anchor w -cspan 4 \ 1821 1,0 $inner.labels -anchor w -cspan 4 \ 1822 2,0 $inner.minorticks -anchor w -cspan 4 \ 1823 4,0 $inner.grid_l -anchor w \ 1824 4,1 $inner.xgrid -anchor w \ 1825 4,2 $inner.ygrid -anchor w \ 1826 4,3 $inner.zgrid -anchor w \ 1827 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1828 5,1 $inner.mode -fill x -cspan 3 1737 1829 1738 1830 blt::table configure $inner r* c* -resize none 1739 blt::table configure $inner r7 c 1-resize expand1740 } 1741 1831 blt::table configure $inner r7 c6 -resize expand 1832 blt::table configure $inner r3 -height 0.125i 1833 } 1742 1834 1743 1835 itcl::body Rappture::VtkGlyphViewer::BuildCameraTab {} { … … 1759 1851 0,0 $inner.view_l -anchor e -pady 2 \ 1760 1852 0,1 $inner.view -anchor w -pady 2 1853 blt::table configure $inner r0 -resize none 1761 1854 1762 1855 set labels { qx qy qz qw xpan ypan zoom } … … 1765 1858 label $inner.${tag}label -text $tag -font "Arial 9" 1766 1859 entry $inner.${tag} -font "Arial 9" -bg white \ 1767 -textvariable [itcl::scope _view($tag)] 1768 bind $inner.${tag} <KeyPress-Return> \ 1769 [itcl::code $this camera set ${tag}] 1860 -textvariable [itcl::scope _view(-$tag)] 1861 bind $inner.${tag} <Return> \ 1862 [itcl::code $this camera set -${tag}] 1863 bind $inner.${tag} <KP_Enter> \ 1864 [itcl::code $this camera set -${tag}] 1770 1865 blt::table $inner \ 1771 1866 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1776 1871 checkbutton $inner.ortho \ 1777 1872 -text "Orthographic Projection" \ 1778 -variable [itcl::scope _view( ortho)] \1779 -command [itcl::code $this camera set ortho] \1873 -variable [itcl::scope _view(-ortho)] \ 1874 -command [itcl::code $this camera set -ortho] \ 1780 1875 -font "Arial 9" 1781 1876 blt::table $inner \ … … 1784 1879 incr row 1785 1880 1786 blt::table configure $inner c* r*-resize none1881 blt::table configure $inner c* -resize none 1787 1882 blt::table configure $inner c2 -resize expand 1788 1883 blt::table configure $inner r$row -resize expand … … 1801 1896 checkbutton $inner.visible \ 1802 1897 -text "Cutplanes" \ 1803 -variable [itcl::scope _settings( cutplaneVisible)] \1804 -command [itcl::code $this AdjustSetting cutplaneVisible] \1898 -variable [itcl::scope _settings(-cutplanevisible)] \ 1899 -command [itcl::code $this AdjustSetting -cutplanevisible] \ 1805 1900 -font "Arial 9" 1806 1901 1807 1902 checkbutton $inner.wireframe \ 1808 1903 -text "Wireframe" \ 1809 -variable [itcl::scope _settings( cutplaneWireframe)] \1810 -command [itcl::code $this AdjustSetting cutplaneWireframe] \1904 -variable [itcl::scope _settings(-cutplanewireframe)] \ 1905 -command [itcl::code $this AdjustSetting -cutplanewireframe] \ 1811 1906 -font "Arial 9" 1812 1907 1813 1908 checkbutton $inner.lighting \ 1814 1909 -text "Enable Lighting" \ 1815 -variable [itcl::scope _settings( cutplaneLighting)] \1816 -command [itcl::code $this AdjustSetting cutplaneLighting] \1910 -variable [itcl::scope _settings(-cutplanelighting)] \ 1911 -command [itcl::code $this AdjustSetting -cutplanelighting] \ 1817 1912 -font "Arial 9" 1818 1913 1819 1914 checkbutton $inner.edges \ 1820 1915 -text "Edges" \ 1821 -variable [itcl::scope _settings( cutplaneEdges)] \1822 -command [itcl::code $this AdjustSetting cutplaneEdges] \1916 -variable [itcl::scope _settings(-cutplaneedges)] \ 1917 -command [itcl::code $this AdjustSetting -cutplaneedges] \ 1823 1918 -font "Arial 9" 1824 1919 1825 1920 checkbutton $inner.preinterp \ 1826 1921 -text "Interpolate Scalars" \ 1827 -variable [itcl::scope _settings( cutplanePreinterp)] \1828 -command [itcl::code $this AdjustSetting cutplanePreinterp] \1922 -variable [itcl::scope _settings(-cutplanepreinterp)] \ 1923 -command [itcl::code $this AdjustSetting -cutplanepreinterp] \ 1829 1924 -font "Arial 9" 1830 1925 1831 1926 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1832 1927 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1833 -variable [itcl::scope _settings( cutplaneOpacity)] \1928 -variable [itcl::scope _settings(-cutplaneopacity)] \ 1834 1929 -width 10 \ 1835 1930 -showvalue off \ 1836 -command [itcl::code $this AdjustSetting cutplaneOpacity]1837 $inner.opacity set $_settings( cutplaneOpacity)1931 -command [itcl::code $this AdjustSetting -cutplaneopacity] 1932 $inner.opacity set $_settings(-cutplaneopacity) 1838 1933 1839 1934 # X-value slicer... … … 1842 1937 -onimage [Rappture::icon x-cutplane-red] \ 1843 1938 -offimage [Rappture::icon x-cutplane-red] \ 1844 -command [itcl::code $this AdjustSetting cutplaneXVisible] \1845 -variable [itcl::scope _settings( cutplaneXVisible)] \1939 -command [itcl::code $this AdjustSetting -cutplanexvisible] \ 1940 -variable [itcl::scope _settings(-cutplanexvisible)] \ 1846 1941 } 1847 1942 Rappture::Tooltip::for $itk_component(xbutton) \ … … 1853 1948 -borderwidth 1 -highlightthickness 0 \ 1854 1949 -command [itcl::code $this EventuallySetCutplane x] \ 1855 -variable [itcl::scope _settings( cutplaneXPosition)] \1856 1950 -variable [itcl::scope _settings(-cutplanexposition)] \ 1951 -foreground red2 -font "Arial 9 bold" 1857 1952 } { 1858 1953 usual … … 1870 1965 -onimage [Rappture::icon y-cutplane-green] \ 1871 1966 -offimage [Rappture::icon y-cutplane-green] \ 1872 -command [itcl::code $this AdjustSetting cutplaneYVisible] \1873 -variable [itcl::scope _settings( cutplaneYVisible)] \1967 -command [itcl::code $this AdjustSetting -cutplaneyvisible] \ 1968 -variable [itcl::scope _settings(-cutplaneyvisible)] \ 1874 1969 } 1875 1970 Rappture::Tooltip::for $itk_component(ybutton) \ … … 1882 1977 -borderwidth 1 -highlightthickness 0 \ 1883 1978 -command [itcl::code $this EventuallySetCutplane y] \ 1884 -variable [itcl::scope _settings( cutplaneYPosition)] \1885 1979 -variable [itcl::scope _settings(-cutplaneyposition)] \ 1980 -foreground green3 -font "Arial 9 bold" 1886 1981 } { 1887 1982 usual … … 1899 1994 -onimage [Rappture::icon z-cutplane-blue] \ 1900 1995 -offimage [Rappture::icon z-cutplane-blue] \ 1901 -command [itcl::code $this AdjustSetting cutplaneZVisible] \1902 -variable [itcl::scope _settings( cutplaneZVisible)] \1996 -command [itcl::code $this AdjustSetting -cutplanezvisible] \ 1997 -variable [itcl::scope _settings(-cutplanezvisible)] \ 1903 1998 } { 1904 1905 1999 usual 2000 ignore -foreground 1906 2001 } 1907 2002 Rappture::Tooltip::for $itk_component(zbutton) \ … … 1914 2009 -borderwidth 1 -highlightthickness 0 \ 1915 2010 -command [itcl::code $this EventuallySetCutplane z] \ 1916 -variable [itcl::scope _settings( cutplaneZPosition)] \1917 2011 -variable [itcl::scope _settings(-cutplanezposition)] \ 2012 -foreground blue3 -font "Arial 9 bold" 1918 2013 } { 1919 2014 usual … … 1926 2021 1927 2022 blt::table $inner \ 1928 0,0 $inner.visible -anchor w -pady 2 -cspan 3 \ 1929 1,0 $inner.lighting -anchor w -pady 2 -cspan 3 \ 1930 2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \ 1931 3,0 $inner.edges -anchor w -pady 2 -cspan 3 \ 1932 4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \ 1933 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 1934 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 1935 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 1936 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 1937 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 1938 6,1 $inner.xval -fill y -rspan 4 \ 1939 6,2 $inner.yval -fill y -rspan 4 \ 1940 6,3 $inner.zval -fill y -rspan 4 \ 1941 2023 0,0 $inner.visible -anchor w -pady 2 -cspan 3 \ 2024 1,0 $inner.lighting -anchor w -pady 2 -cspan 3 \ 2025 2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \ 2026 3,0 $inner.edges -anchor w -pady 2 -cspan 3 \ 2027 4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \ 2028 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 2029 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 2030 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 2031 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 2032 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 2033 6,1 $inner.xval -fill y -rspan 4 \ 2034 6,2 $inner.yval -fill y -rspan 4 \ 2035 6,3 $inner.zval -fill y -rspan 4 \ 1942 2036 1943 2037 blt::table configure $inner r* c* -resize none 1944 2038 blt::table configure $inner r9 c4 -resize expand 1945 2039 } 1946 1947 1948 2040 1949 2041 # … … 1956 2048 } 1957 2049 "set" { 1958 set wh o[lindex $args 0]1959 set x $_view($wh o)2050 set what [lindex $args 0] 2051 set x $_view($what) 1960 2052 set code [catch { string is double $x } result] 1961 2053 if { $code != 0 || !$result } { 1962 2054 return 1963 2055 } 1964 switch -- $wh o{1965 " ortho" {1966 if {$_view( ortho)} {2056 switch -- $what { 2057 "-ortho" { 2058 if {$_view($what)} { 1967 2059 SendCmd "camera mode ortho" 1968 2060 } else { … … 1970 2062 } 1971 2063 } 1972 " xpan" - "ypan" {2064 "-xpan" - "-ypan" { 1973 2065 PanCamera 1974 2066 } 1975 " qx" - "qy" - "qz" - "qw" {1976 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2067 "-qx" - "-qy" - "-qz" - "-qw" { 2068 set q [ViewToQuaternion] 1977 2069 $_arcball quaternion $q 1978 2070 EventuallyRotate $q 1979 2071 } 1980 " zoom" {1981 SendCmd "camera zoom $_view( zoom)"2072 "-zoom" { 2073 SendCmd "camera zoom $_view($what)" 1982 2074 } 1983 2075 } … … 2097 2189 # the code to handle aberrant cases. 2098 2190 2099 if { $_changed( glyphOpacity) } {2100 set style(-opacity) $_settings(glyphOpacity)2101 } 2102 if { $_changed( colormap) } {2103 set style(-color) $_settings( colormap)2191 if { $_changed(-glyphopacity) } { 2192 set style(-opacity) [expr $_settings(-glyphopacity) * 0.01] 2193 } 2194 if { $_changed(-colormap) } { 2195 set style(-color) $_settings(-colormap) 2104 2196 } 2105 2197 if { $_currentColormap == "" } { 2106 2198 $itk_component(colormap) value $style(-color) 2107 2199 } 2108 set _currentOpacity $style(-opacity) 2200 2201 SendCmd "outline add $tag" 2202 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 2203 SendCmd "outline visible $style(-outline) $tag" 2204 set _settings(-glyphoutline) $style(-outline) 2205 2109 2206 SendCmd "glyphs add $style(-shape) $tag" 2207 set _settings(-glyphshape) $style(-shape) 2208 $itk_component(gshape) value $style(-shape) 2110 2209 SendCmd "glyphs edges $style(-edges) $tag" 2210 set _settings(-glyphedges) $style(-edges) 2211 2111 2212 # normscale=1 and gscale=1 are defaults 2112 2213 if {$style(-normscale) != 1} { … … 2116 2217 SendCmd "glyphs gscale $style(-gscale) $tag" 2117 2218 } 2118 SendCmd "outline add $tag" 2119 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 2120 SendCmd "outline visible $style(-outline) $tag" 2121 set _settings(glyphOutline) $style(-outline) 2122 set _settings(glyphEdges) $style(-edges) 2219 set _settings(-glyphnormscale) $style(-normscale) 2220 set _settings(-glyphscale) $style(-gscale) 2221 2123 2222 # constant color only used if colormode set to constant 2124 2223 SendCmd "glyphs color [Color2RGB $itk_option(-plotforeground)] $tag" … … 2126 2225 # defaults to active scalars or vectors depending on mode 2127 2226 SendCmd "glyphs gorient $style(-orientGlyphs) {} $tag" 2227 set _settings(-glyphorient) $style(-orientGlyphs) 2128 2228 SendCmd "glyphs smode $style(-scaleMode) {} $tag" 2229 set _settings(-glyphscalemode) $style(-scaleMode) 2230 $itk_component(scaleMode) value "[$itk_component(scaleMode) label $style(-scaleMode)]" 2129 2231 SendCmd "glyphs quality $style(-quality) $tag" 2130 2232 SendCmd "glyphs lighting $style(-lighting) $tag" 2131 set _settings( glyphLighting) $style(-lighting)2233 set _settings(-glyphlighting) $style(-lighting) 2132 2234 SendCmd "glyphs linecolor [Color2RGB $style(-edgecolor)] $tag" 2133 2235 SendCmd "glyphs linewidth $style(-linewidth) $tag" 2134 2236 SendCmd "glyphs ptsize $style(-ptsize) $tag" 2135 SendCmd "glyphs opacity $ _currentOpacity$tag"2136 set _settings( glyphOpacity) $style(-opacity)2237 SendCmd "glyphs opacity $style(-opacity) $tag" 2238 set _settings(-glyphopacity) [expr $style(-opacity) * 100.0] 2137 2239 SetCurrentColormap $style(-color) 2138 2240 SendCmd "glyphs wireframe $style(-wireframe) $tag" 2139 set _settings(glyphWireframe) $style(-wireframe) 2140 set _settings(glyphOpacity) [expr $style(-opacity) * 100.0] 2241 set _settings(-glyphwireframe) $style(-wireframe) 2141 2242 } 2142 2243 … … 2192 2293 2193 2294 if { [string match "component*" $fname] } { 2194 2295 set title "" 2195 2296 } else { 2196 2197 2198 2199 2200 2201 2202 2203 2297 if { [info exists _fields($fname)] } { 2298 foreach { title units } $_fields($fname) break 2299 if { $units != "" } { 2300 set title [format "%s (%s)" $title $units] 2301 } 2302 } else { 2303 set title $fname 2304 } 2204 2305 } 2205 2306 # If there's a legend title, increase the offset by the line height. … … 2233 2334 } 2234 2335 2235 2236 2336 # ---------------------------------------------------------------------- 2237 2337 # USAGE: Slice move x|y|z <newval> … … 2267 2367 # ReceiveLegend -- 2268 2368 # 2269 # 2270 # 2271 # 2369 # Invoked automatically whenever the "legend" command comes in from 2370 # the rendering server. Indicates that binary image data with the 2371 # specified <size> will follow. 2272 2372 # 2273 2373 itcl::body Rappture::VtkGlyphViewer::ReceiveLegend { colormap title min max size } { … … 2283 2383 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2284 2384 if { [catch {DrawLegend} errs] != 0 } { 2285 2286 2385 global errorInfo 2386 puts stderr "errs=$errs errorInfo=$errorInfo" 2287 2387 } 2288 2388 } … … 2292 2392 # DrawLegend -- 2293 2393 # 2294 # 2394 # Draws the legend in the own canvas on the right side of the plot area. 2295 2395 # 2296 2396 itcl::body Rappture::VtkGlyphViewer::DrawLegend {} { … … 2303 2403 2304 2404 if { [string match "component*" $fname] } { 2305 2405 set title "" 2306 2406 } else { 2307 2308 2309 2310 2311 2312 2313 2314 2407 if { [info exists _fields($fname)] } { 2408 foreach { title units } $_fields($fname) break 2409 if { $units != "" } { 2410 set title [format "%s (%s)" $title $units] 2411 } 2412 } else { 2413 set title $fname 2414 } 2315 2415 } 2316 2416 set x [expr $w - 2] 2317 if { !$_settings( legendVisible) } {2318 2319 2417 if { !$_settings(-legendvisible) } { 2418 $c delete legend 2419 return 2320 2420 } 2321 2421 if { [$c find withtag "legend"] == "" } { 2322 2323 2422 set y 2 2423 # If there's a legend title, create a text item for the title. 2324 2424 $c create text $x $y \ 2325 -anchor ne \ 2326 -fill $itk_option(-plotforeground) -tags "title legend" \ 2327 -font $font 2328 incr y $lineht 2329 $c create text $x $y \ 2330 -anchor ne \ 2331 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2332 -font $font 2333 incr y $lineht 2334 $c create image $x $y \ 2335 -anchor ne \ 2336 -image $_image(legend) -tags "colormap legend" 2337 $c create rectangle $x $y 1 1 \ 2338 -fill "" -outline "" -tags "sensor legend" 2339 $c create text $x [expr {$h-2}] \ 2340 -anchor se \ 2341 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2342 -font $font 2343 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2344 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2345 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2425 -anchor ne \ 2426 -fill $itk_option(-plotforeground) -tags "title legend" \ 2427 -font $font 2428 if { $title != "" } { 2429 incr y $lineht 2430 } 2431 $c create text $x $y \ 2432 -anchor ne \ 2433 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2434 -font $font 2435 incr y $lineht 2436 $c create image $x $y \ 2437 -anchor ne \ 2438 -image $_image(legend) -tags "colormap legend" 2439 $c create rectangle $x $y 1 1 \ 2440 -fill "" -outline "" -tags "sensor legend" 2441 $c create text $x [expr {$h-2}] \ 2442 -anchor se \ 2443 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2444 -font $font 2445 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2446 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2447 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2346 2448 } 2347 2449 set x2 $x … … 2357 2459 if { [info exists _limits($_curFldName)] } { 2358 2460 foreach { vmin vmax } $_limits($_curFldName) break 2359 2360 2461 $c itemconfigure vmin -text [format %g $vmin] 2462 $c itemconfigure vmax -text [format %g $vmax] 2361 2463 } 2362 2464 set y 2 … … 2364 2466 if { $title != "" } { 2365 2467 $c itemconfigure title -text $title 2366 2367 2468 $c coords title $x $y 2469 incr y $lineht 2368 2470 $c raise title 2369 2471 } … … 2407 2509 invoke { 2408 2510 $itk_component(field) value $_curFldLabel 2409 AdjustSetting field2511 AdjustSetting -field 2410 2512 } 2411 2513 default { … … 2431 2533 # BuildColormap -- 2432 2534 # 2433 # 2535 # Build the designated colormap on the server. 2434 2536 # 2435 2537 itcl::body Rappture::VtkGlyphViewer::BuildColormap { name } { … … 2451 2553 bottom "0.707107 0.707107 0 0" 2452 2554 } 2453 foreach name { qw qx qyqz } value $positions($side) {2555 foreach name { -qw -qx -qy -qz } value $positions($side) { 2454 2556 set _view($name) $value 2455 } 2456 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2557 } 2558 set q [ViewToQuaternion] 2457 2559 $_arcball quaternion $q 2458 2560 SendCmd "camera orient $q" 2459 2561 SendCmd "camera reset" 2460 set _view(xpan) 0 2461 set _view(ypan) 0 2462 set _view(zoom) 1.0 2463 } 2464 2562 set _view(-xpan) 0 2563 set _view(-ypan) 0 2564 set _view(-zoom) 1.0 2565 }
Note: See TracChangeset
for help on using the changeset viewer.