Changeset 3708 for trunk/gui/scripts/vtkviewer.tcl
- Timestamp:
- Jun 23, 2013, 1:42:36 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkviewer.tcl
r3675 r3708 224 224 array set _settings [subst { 225 225 legend 1 226 226 molecule-representation "Ball and Stick" 227 227 molecule-edges 0 228 228 molecule-labels 0 … … 231 231 molecule-visible 1 232 232 molecule-wireframe 0 233 233 molecule-palette elementDefault 234 234 mesh-edges 0 235 235 mesh-lighting 1 … … 237 237 mesh-visible 1 238 238 mesh-wireframe 0 239 239 mesh-palette rainbow 240 240 }] 241 241 … … 280 280 pack $itk_component(reset) -side top -padx 2 -pady 2 281 281 Rappture::Tooltip::for $itk_component(reset) \ 282 282 "Reset the view to the default zoom level" 283 283 284 284 itk_component add zoomin { … … 307 307 308 308 if { [catch { BuildMeshTab } errs ] != 0 } { 309 309 puts stderr "errs=$errs" 310 310 } 311 311 if { [catch { BuildMoleculeTab } errs ] != 0 } { 312 313 312 global errorInfo 313 puts stderr "errs=$errs\nerrorInfo=$errorInfo" 314 314 } 315 315 BuildAxisTab … … 495 495 } 496 496 497 498 497 # ---------------------------------------------------------------------- 499 498 # USAGE: delete ?<dataobj1> <dataobj2> ...? … … 712 711 # Tell the server the viewer, hub, user and session. 713 712 # Do this immediately on connect before buffing any commands 714 713 global env 715 714 716 715 set info {} 717 716 set user "???" 718 717 if { [info exists env(USER)] } { 719 718 set user $env(USER) 720 719 } 721 720 set session "???" 722 721 if { [info exists env(SESSION)] } { 723 722 set session $env(SESSION) 724 723 } 725 724 lappend info "hub" [exec hostname] 726 725 lappend info "client" "vtkviewer" … … 897 896 if { ![info exists _datasets($tag)] } { 898 897 set bytes [$dataobj data $comp] 899 900 901 898 if { $bytes == "" } { 899 continue 900 } 902 901 set length [string length $bytes] 903 902 if { $_reportClientInfo } { … … 915 914 append _outbuf $bytes 916 915 set _datasets($tag) 1 917 switch -- [$dataobj type $comp] { 918 "polydata" { 919 SendCmd "polydata add $tag" 920 } 921 "glyphs" { 922 set shape [$dataobj shape $comp] 923 SendCmd "glyphs add $shape $tag" 924 } 925 "molecule" { 926 SendCmd "molecule add $tag" 927 } 928 } 916 SetObjectStyle $dataobj $comp 929 917 } 930 918 lappend _obj2datasets($dataobj) $tag … … 933 921 puts stderr "$count: dataset visible 1 $tag" 934 922 } 935 SetObjectStyle $dataobj $comp936 923 } 937 924 } … … 954 941 } 955 942 if { $_reset } { 956 957 943 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 944 $_arcball quaternion $q 958 945 SendCmd "camera reset" 959 946 if { $_view(ortho)} { … … 961 948 } else { 962 949 SendCmd "camera mode persp" 963 964 965 950 } 951 DoRotate 952 PanCamera 966 953 Zoom reset 967 954 } … … 1074 1061 SendCmd "camera pan $x $y" 1075 1062 } 1076 1077 1063 1078 1064 # ---------------------------------------------------------------------- … … 1215 1201 set sval [expr { 0.01 * double($val) }] 1216 1202 foreach dataset [CurrentDatasets -visible $_first] { 1217 1218 1219 1220 1221 1203 foreach { dataobj comp } [split $dataset -] break 1204 set type [$dataobj type $comp] 1205 if { $type == "polydata" } { 1206 SendCmd "$type opacity $sval $dataset" 1207 } 1222 1208 } 1223 1209 } … … 1225 1211 set bool $_settings(mesh-wireframe) 1226 1212 foreach dataset [CurrentDatasets -visible $_first] { 1227 1228 1229 1230 1231 1213 foreach { dataobj comp } [split $dataset -] break 1214 set type [$dataobj type $comp] 1215 if { $type == "polydata" } { 1216 SendCmd "$type wireframe $bool $dataset" 1217 } 1232 1218 } 1233 1219 } … … 1235 1221 set bool $_settings(mesh-visible) 1236 1222 foreach dataset [CurrentDatasets -visible $_first] { 1237 1238 1239 1240 1241 1223 foreach { dataobj comp } [split $dataset -] break 1224 set type [$dataobj type $comp] 1225 if { $type == "polydata" } { 1226 SendCmd "$type visible $bool $dataset" 1227 } 1242 1228 } 1243 1229 } … … 1245 1231 set bool $_settings(mesh-lighting) 1246 1232 foreach dataset [CurrentDatasets -visible $_first] { 1247 1248 1249 1250 1251 1233 foreach { dataobj comp } [split $dataset -] break 1234 set type [$dataobj type $comp] 1235 if { $type == "polydata" } { 1236 SendCmd "$type lighting $bool $dataset" 1237 } 1252 1238 } 1253 1239 } … … 1255 1241 set bool $_settings(mesh-edges) 1256 1242 foreach dataset [CurrentDatasets -visible $_first] { 1257 1258 1259 1260 1261 1243 foreach { dataobj comp } [split $dataset -] break 1244 set type [$dataobj type $comp] 1245 if { $type == "polydata" } { 1246 SendCmd "$type edges $bool $dataset" 1247 } 1262 1248 } 1263 1249 } … … 1267 1253 foreach dataset [CurrentDatasets -visible $_first] { 1268 1254 foreach {dataobj comp} [split $dataset -] break 1269 1270 1271 1272 1255 set type [$dataobj type $comp] 1256 if { $type == "polydata" } { 1257 ChangeColormap $dataobj $comp $palette 1258 } 1273 1259 } 1274 1260 set _legendPending 1 … … 1278 1264 set sval [expr { 0.01 * double($val) }] 1279 1265 foreach dataset [CurrentDatasets -visible $_first] { 1280 1281 1282 1283 1284 1266 foreach { dataobj comp } [split $dataset -] break 1267 set type [$dataobj type $comp] 1268 if { $type == "molecule" } { 1269 SendCmd "molecule opacity $sval $dataset" 1270 } 1285 1271 } 1286 1272 } … … 1288 1274 set bool $_settings(molecule-wireframe) 1289 1275 foreach dataset [CurrentDatasets -visible $_first] { 1290 1291 1292 1293 1294 1276 foreach { dataobj comp } [split $dataset -] break 1277 set type [$dataobj type $comp] 1278 if { $type == "molecule" } { 1279 SendCmd "molecule wireframe $bool $dataset" 1280 } 1295 1281 } 1296 1282 } … … 1298 1284 set bool $_settings(molecule-visible) 1299 1285 foreach dataset [CurrentDatasets -visible $_first] { 1300 1301 1302 1303 1304 1286 foreach { dataobj comp } [split $dataset -] break 1287 set type [$dataobj type $comp] 1288 if { $type == "molecule" } { 1289 SendCmd "molecule visible $bool $dataset" 1290 } 1305 1291 } 1306 1292 } … … 1308 1294 set bool $_settings(molecule-lighting) 1309 1295 foreach dataset [CurrentDatasets -visible $_first] { 1310 1311 1312 1313 1314 1296 foreach { dataobj comp } [split $dataset -] break 1297 set type [$dataobj type $comp] 1298 if { $type == "molecule" } { 1299 SendCmd "molecule lighting $bool $dataset" 1300 } 1315 1301 } 1316 1302 } … … 1318 1304 set bool $_settings(molecule-edges) 1319 1305 foreach dataset [CurrentDatasets -visible $_first] { 1320 1321 1322 1323 1324 1306 foreach { dataobj comp } [split $dataset -] break 1307 set type [$dataobj type $comp] 1308 if { $type == "molecule" } { 1309 SendCmd "molecule edges $bool $dataset" 1310 } 1325 1311 } 1326 1312 } … … 1330 1316 foreach dataset [CurrentDatasets -visible $_first] { 1331 1317 foreach {dataobj comp} [split $dataset -] break 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1318 set type [$dataobj type $comp] 1319 if { $type == "molecule" } { 1320 ChangeColormap $dataobj $comp $palette 1321 if { $palette == "elementDefault" } { 1322 SendCmd "molecule colormode by_elements element $dataset" 1323 } else { 1324 # FIXME: Set the chosen scalar field name here 1325 SendCmd "molecule colormode scalar {} $dataset" 1326 } 1327 } 1342 1328 } 1343 1329 set _legendPending 1 1344 1330 } 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1331 "molecule-representation" { 1332 set value [$itk_component(representation) value] 1333 set value [$itk_component(representation) translate $value] 1334 switch -- $value { 1335 "ballandstick" { 1336 set rscale covalent 1337 set ashow 1 1338 set bshow 1 1339 set bstyle cylinder 1340 set ascale 0.3 1341 set bscale 0.075 1342 } 1343 "balls" - "spheres" { 1344 set rscale covalent 1345 set ashow 1 1346 set bshow 0 1347 set bstyle cylinder 1348 set ascale 0.3 1349 set bscale 0.075 1350 } 1351 "sticks" { 1352 set rscale none 1353 set ashow 1 1354 set bshow 1 1355 set bstyle cylinder 1356 set ascale 0.075 1357 set bscale 0.075 1358 } 1359 "spacefilling" { 1360 set rscale van_der_waals 1361 set ashow 1 1362 set bshow 0 1363 set bstyle cylinder 1364 set ascale 1.0 1365 set bscale 0.075 1366 } 1367 "rods" { 1368 set rscale none 1369 set ashow 1 1370 set bshow 1 1371 set bstyle cylinder 1372 set ascale 0.1 1373 set bscale 0.1 1374 } 1375 "wireframe" - "lines" { 1376 set rscale none 1377 set ashow 0 1378 set bshow 1 1379 set bstyle line 1380 set ascale 1.0 1381 set bscale 1.0 1382 } 1383 default { 1384 error "unknown representation $value" 1385 } 1386 } 1387 foreach dataset [CurrentDatasets -visible $_first] { 1388 foreach {dataobj comp} [split $dataset -] break 1389 set type [$dataobj type $comp] 1390 if { $type == "molecule" } { 1391 SendCmd [subst {molecule rscale $rscale $dataset 1406 1392 molecule atoms $ashow $dataset 1407 1393 molecule bonds $bshow $dataset … … 1409 1395 molecule ascale $ascale $dataset 1410 1396 molecule bscale $bscale $dataset}] 1411 1412 1413 1397 } 1398 } 1399 } 1414 1400 "molecule-labels" { 1415 1401 set bool $_settings(molecule-labels) … … 1543 1529 1544 1530 if { $style(-color) == "elementDefault" } { 1545 1531 set name "$style(-color)" 1546 1532 } else { 1547 1533 set name "$style(-color):$style(-levels):$style(-opacity)" 1548 1534 } 1549 1535 if { ![info exists _colormaps($name)] } { … … 1554 1540 $_dataset2style($tag) != $name } { 1555 1541 set _dataset2style($tag) $name 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1542 switch -- [$dataobj type $comp] { 1543 "polygon" { 1544 SendCmd "pseudocolor colormap $name $tag" 1545 } 1546 "glyphs" { 1547 SendCmd "glyphs colormap $name $tag" 1548 } 1549 "molecule" { 1550 SendCmd "molecule colormap $name $tag" 1551 } 1552 } 1567 1553 } 1568 1554 } … … 1573 1559 itcl::body Rappture::VtkViewer::BuildColormap { name styles } { 1574 1560 if { $name == "elementDefault" } { 1575 1561 return 1576 1562 } 1577 1563 array set style $styles … … 1588 1574 SendCmd "colormap add $name { $cmap } { $wmap }" 1589 1575 } 1590 1591 1576 1592 1577 # ---------------------------------------------------------------------- … … 1617 1602 if { ![info exists _limits($tag)] } { 1618 1603 set data [$dataobj data $comp] 1619 1620 1621 1604 if { $data == "" } { 1605 continue 1606 } 1622 1607 set tmpfile file[pid].vtk 1623 1608 set f [open "$tmpfile" "w"] … … 1627 1612 set reader [vtkDataSetReader $tag-xvtkDataSetReader] 1628 1613 $reader SetFileName $tmpfile 1629 $reader ReadAllNormalsOn 1630 $reader ReadAllScalarsOn 1631 $reader ReadAllVectorsOn 1632 $reader ReadAllFieldsOn 1614 set debug 0 1615 if {$debug} { 1616 # Only needed for debug output below 1617 $reader ReadAllNormalsOn 1618 $reader ReadAllTCoordsOn 1619 $reader ReadAllScalarsOn 1620 $reader ReadAllColorScalarsOn 1621 $reader ReadAllVectorsOn 1622 $reader ReadAllTensorsOn 1623 $reader ReadAllFieldsOn 1624 } 1633 1625 $reader Update 1626 file delete $tmpfile 1634 1627 set output [$reader GetOutput] 1635 1628 set _limits($tag) [$output GetBounds] 1636 set pointData [$output GetPointData] 1637 set fieldData [$output GetFieldData] 1638 if 1 { 1639 puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]" 1640 puts stderr "\#vectors=[$reader GetNumberOfVectorsInFile]" 1641 puts stderr "\#tensors=[$reader GetNumberOfTensorsInFile]" 1642 puts stderr "\#normals=[$reader GetNumberOfNormalsInFile]" 1643 puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]" 1644 puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]" 1645 puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]" 1646 puts stderr "point \#arrays=[$pointData GetNumberOfArrays]" 1647 puts stderr "field \#components=[$fieldData GetNumberOfComponents]" 1648 puts stderr "point \#components=[$pointData GetNumberOfComponents]" 1649 puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]" 1650 puts stderr "point \#tuples=[$pointData GetNumberOfTuples]" 1651 puts stderr "point \#scalars=[$pointData GetScalars]" 1652 puts stderr vectors=[$pointData GetVectors] 1653 } 1629 if {$debug} { 1630 puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]" 1631 puts stderr "\#vectors=[$reader GetNumberOfVectorsInFile]" 1632 puts stderr "\#tensors=[$reader GetNumberOfTensorsInFile]" 1633 puts stderr "\#normals=[$reader GetNumberOfNormalsInFile]" 1634 puts stderr "\#tcoords=[$reader GetNumberOfTCoordsInFile]" 1635 puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]" 1636 puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]" 1637 set pointData [$output GetPointData] 1638 if { $pointData != ""} { 1639 puts stderr "point \#arrays=[$pointData GetNumberOfArrays]" 1640 puts stderr "point \#components=[$pointData GetNumberOfComponents]" 1641 puts stderr "point \#tuples=[$pointData GetNumberOfTuples]" 1642 puts stderr "point scalars=[$pointData GetScalars]" 1643 puts stderr "point vectors=[$pointData GetVectors]" 1644 } 1645 set cellData [$output GetCellData] 1646 if { $cellData != ""} { 1647 puts stderr "cell \#arrays=[$cellData GetNumberOfArrays]" 1648 puts stderr "cell \#components=[$cellData GetNumberOfComponents]" 1649 puts stderr "cell \#tuples=[$cellData GetNumberOfTuples]" 1650 puts stderr "cell scalars=[$cellData GetScalars]" 1651 puts stderr "cell vectors=[$cellData GetVectors]" 1652 } 1653 set fieldData [$output GetFieldData] 1654 if { $fieldData != ""} { 1655 puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]" 1656 puts stderr "field \#components=[$fieldData GetNumberOfComponents]" 1657 puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]" 1658 } 1659 } 1654 1660 rename $output "" 1655 1661 rename $reader "" 1656 file delete $tmpfile1657 1662 } 1658 1663 foreach { xMin xMax yMin yMax zMin zMax} $_limits($tag) break … … 1824 1829 } 1825 1830 1826 1827 1831 itcl::body Rappture::VtkViewer::BuildCameraTab {} { 1828 1832 set inner [$itk_component(main) insert end \ … … 2061 2065 $inner.rep choices insert end \ 2062 2066 "ballandstick" "Ball and Stick" \ 2063 "spheres" "Spheres" 2064 "sticks" "Sticks" \2065 "rods" "Rods" \2066 "wireframe" "Wireframe" \2067 "spheres" "Spheres" \ 2068 "sticks" "Sticks" \ 2069 "rods" "Rods" \ 2070 "wireframe" "Wireframe" \ 2067 2071 "spacefilling" "Space Filling" 2068 2072 2069 2073 bind $inner.rep <<Value>> \ 2070 2074 [itcl::code $this AdjustSetting molecule-representation] 2071 2075 $inner.rep value "Ball and Stick" 2072 2076 … … 2076 2080 } 2077 2081 $inner.palette choices insert end \ 2078 "elementDefault" "elementDefault"\2082 "elementDefault" "elementDefault" \ 2079 2083 "BCGYR" "BCGYR" \ 2080 2084 "BGYOR" "BGYOR" \ … … 2194 2198 } 2195 2199 2196 2197 2200 itcl::body Rappture::VtkViewer::GetVtkData { args } { 2198 2201 set bytes "" … … 2202 2205 set contents [$dataobj data $comp] 2203 2206 append bytes "$contents\n" 2204 2207 append bytes "\# End of VTK file\n\n" 2205 2208 } 2206 2209 } … … 2279 2282 -visible 1 2280 2283 } 2281 2284 set shape [$dataobj shape $comp] 2282 2285 array set settings $style 2286 SendCmd "glyphs add $shape $tag" 2283 2287 SendCmd "glyphs normscale 0 $tag" 2284 2288 SendCmd "glyphs gscale $settings(-gscale) $tag" … … 2293 2297 set _haveGlyphs 1 2294 2298 } elseif { $type == "molecule" } { 2299 SendCmd "molecule add $tag" 2295 2300 SendCmd "molecule rscale van_der_waals $tag" 2296 2301 set _haveMolecules 1 … … 2307 2312 } 2308 2313 array set settings $style 2314 SendCmd "polydata add $tag" 2309 2315 SendCmd "polydata visible $settings(-visible) $tag" 2310 2316 set _settings(mesh-visible) $settings(-visible) … … 2456 2462 } 2457 2463 2458 2459 2464 # ---------------------------------------------------------------------- 2460 2465 # USAGE: Slice move x|y|z <newval> … … 2508 2513 set _view(zoom) 1.0 2509 2514 } 2510
Note: See TracChangeset
for help on using the changeset viewer.