Changeset 3785 for branches/1.3/gui/scripts/vtkviewer.tcl
- Timestamp:
- Jul 12, 2013, 12:06:27 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/vtkviewer.tcl
r3709 r3785 86 86 private method BuildCutawayTab {} 87 87 private method BuildDownloadPopup { widget command } 88 private method BuildMeshTab {}89 88 private method BuildMoleculeTab {} 90 private method ConvertToVtkData { dataobj comp } 89 private method BuildPolydataTab {} 90 private method ChangeColormap { dataobj comp color } 91 91 private method DrawLegend {} 92 92 private method EnterLegend { x y } 93 private method EventuallySetAtomScale { args } 94 private method EventuallySetBondScale { args } 95 private method EventuallySetMoleculeOpacity { args } 96 private method EventuallySetPolydataOpacity { args } 93 97 private method EventuallyResize { w h } 94 98 private method EventuallyRotate { q } … … 100 104 private method PanCamera {} 101 105 private method RequestLegend {} 106 private method SetAtomScale {} 107 private method SetBondScale {} 102 108 private method SetColormap { dataobj comp } 103 private method ChangeColormap { dataobj comp color }104 109 private method SetLegendTip { x y } 110 private method SetMoleculeOpacity {} 105 111 private method SetObjectStyle { dataobj comp } 112 private method SetOpacity { dataset } 113 private method SetOrientation { side } 114 private method SetPolydataOpacity {} 106 115 private method Slice {option args} 107 private method SetOrientation { side }108 116 109 117 private variable _arcball "" 110 118 private variable _dlist ""; # list of data objects 111 private variable _allDataObjs112 119 private variable _obj2datasets 113 120 private variable _obj2ovride; # maps dataobj => style override … … 130 137 private variable _haveGlyphs 0 131 138 private variable _haveMolecules 0 139 private variable _havePolydata 0 132 140 133 141 private variable _first "" ;# This is the topmost dataset. … … 141 149 private variable _resizePending 0 142 150 private variable _rotatePending 0 151 private variable _atomScalePending 0 152 private variable _bondScalePending 0 153 private variable _moleculeOpacityPending 0 154 private variable _polydataOpacityPending 0 155 private variable _glyphsOpacityPending 0 143 156 private variable _updatePending 0; 157 private variable _rotateDelay 150 158 private variable _scaleDelay 100 159 144 160 private variable _outline 145 161 } … … 173 189 $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list" 174 190 191 # Atom scale event 192 $_dispatcher register !atomscale 193 $_dispatcher dispatch $this !atomscale \ 194 "[itcl::code $this SetAtomScale]; list" 195 196 # Bond scale event 197 $_dispatcher register !bondscale 198 $_dispatcher dispatch $this !bondscale \ 199 "[itcl::code $this SetBondScale]; list" 200 201 # Molecule opacity event 202 $_dispatcher register !moleculeOpacity 203 $_dispatcher dispatch $this !moleculeOpacity \ 204 "[itcl::code $this SetMoleculeOpacity]; list" 205 206 # Polydata opacity event 207 $_dispatcher register !polydataOpacity 208 $_dispatcher dispatch $this !polydataOpacity \ 209 "[itcl::code $this SetPolydataOpacity]; list" 175 210 # 176 211 # Populate parser with commands handle incoming requests … … 223 258 }] 224 259 array set _settings [subst { 225 legend 1 226 molecule-representation "Ball and Stick" 227 molecule-edges 0 228 molecule-labels 0 229 molecule-lighting 1 230 molecule-opacity 100 231 molecule-visible 1 232 molecule-wireframe 0 233 molecule-palette elementDefault 234 mesh-edges 0 235 mesh-lighting 1 236 mesh-opacity 40 237 mesh-visible 1 238 mesh-wireframe 0 239 mesh-palette rainbow 260 legend 1 261 polydata-edges 0 262 polydata-lighting 1 263 polydata-opacity 40 264 polydata-palette rainbow 265 polydata-visible 1 266 polydata-wireframe 0 267 molecule-atomscale 1.0 268 molecule-bondscale 1.0 269 molecule-atoms-visible 1 270 molecule-bonds-visible 1 271 molecule-edges 0 272 molecule-labels 0 273 molecule-lighting 1 274 molecule-opacity 100 275 molecule-palette elementDefault 276 molecule-representation "Ball and Stick" 277 molecule-visible 1 278 molecule-wireframe 0 240 279 }] 241 242 280 itk_component add view { 243 281 canvas $itk_component(plotarea).view \ … … 306 344 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 307 345 308 if { [catch { BuildMeshTab } errs ] != 0 } {309 puts stderr "errs=$errs"310 }311 if { [catch { BuildMoleculeTab } errs ] != 0 } {312 global errorInfo313 puts stderr "errs=$errs\nerrorInfo=$errorInfo"314 }315 346 BuildAxisTab 316 347 #BuildCutawayTab … … 347 378 [itcl::code $this EventuallyResize %w %h] 348 379 349 if 0 {350 bind $itk_component(view) <Configure> \351 [itcl::code $this EventuallyResize %w %h]352 }353 380 # Bindings for panning via mouse 354 381 bind $itk_component(view) <ButtonPress-2> \ … … 442 469 } 443 470 444 set rotate_delay 150445 446 471 itcl::body Rappture::VtkViewer::EventuallyRotate { q } { 447 472 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 448 473 if { !$_rotatePending } { 449 474 set _rotatePending 1 450 global rotate_delay 451 $_dispatcher event -after $rotate_delay !rotate 475 $_dispatcher event -after $_rotateDelay !rotate 476 } 477 } 478 479 itcl::body Rappture::VtkViewer::SetAtomScale {} { 480 SendCmd "molecule ascale $_settings(molecule-atomscale)" 481 set _atomScalePending 0 482 } 483 484 itcl::body Rappture::VtkViewer::SetBondScale {} { 485 SendCmd "molecule bscale $_settings(molecule-bondscale)" 486 set _bondScalePending 0 487 } 488 489 itcl::body Rappture::VtkViewer::SetMoleculeOpacity {} { 490 set _moleculeOpacityPending 0 491 foreach dataset [CurrentDatasets -visible $_first] { 492 foreach { dataobj comp } [split $dataset -] break 493 if { [$dataobj type $comp] == "molecule" } { 494 SetOpacity $dataset 495 } 496 } 497 } 498 499 itcl::body Rappture::VtkViewer::SetPolydataOpacity {} { 500 set _polydataOpacityPending 0 501 foreach dataset [CurrentDatasets -visible $_first] { 502 foreach { dataobj comp } [split $dataset -] break 503 if { [$dataobj type $comp] == "polydata" } { 504 SetOpacity $dataset 505 } 506 } 507 } 508 509 itcl::body Rappture::VtkViewer::EventuallySetAtomScale { args } { 510 if { !$_atomScalePending } { 511 set _atomScalePending 1 512 $_dispatcher event -after $_scaleDelay !atomscale 513 } 514 } 515 516 itcl::body Rappture::VtkViewer::EventuallySetBondScale { args } { 517 if { !$_bondScalePending } { 518 set _bondScalePending 1 519 $_dispatcher event -after $_scaleDelay !bondscale 520 } 521 } 522 523 itcl::body Rappture::VtkViewer::EventuallySetMoleculeOpacity { args } { 524 if { !$_moleculeOpacityPending } { 525 set _moleculeOpacityPending 1 526 $_dispatcher event -after $_scaleDelay !moleculeOpacity 527 } 528 } 529 530 itcl::body Rappture::VtkViewer::EventuallySetPolydataOpacity { args } { 531 if { !$_polydataOpacityPending } { 532 set _polydataOpacityPending 1 533 $_dispatcher event -after $_scaleDelay !polydataOpacity 452 534 } 453 535 } … … 488 570 lappend _dlist $dataobj 489 571 } 490 set _allDataObjs($dataobj) 1491 572 set _obj2ovride($dataobj-color) $params(-color) 492 573 set _obj2ovride($dataobj-width) $params(-width) … … 612 693 itcl::body Rappture::VtkViewer::scale {args} { 613 694 foreach dataobj $args { 695 foreach comp [$dataobj components] { 696 set type [$dataobj type $comp] 697 switch -- $type { 698 "polydata" { 699 set _havePolydata 1 700 } 701 "glyphs" { 702 set _haveGlyphs 1 703 } 704 "molecule" { 705 set _haveMolecules 1 706 } 707 } 708 } 614 709 array set bounds [limits $dataobj] 615 710 if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} { … … 632 727 if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} { 633 728 set _limits(zmax) $bounds(zmax) 729 } 730 } 731 if { $_havePolydata } { 732 if { ![$itk_component(main) exists "Mesh Settings"] } { 733 if { [catch { BuildPolydataTab } errs ] != 0 } { 734 puts stderr "errs=$errs" 735 } 736 } 737 } 738 if { $_haveMolecules } { 739 if { ![$itk_component(main) exists "Molecule Settings"]} { 740 if { [catch { BuildMoleculeTab } errs ] != 0 } { 741 global errorInfo 742 puts stderr "errs=$errs\nerrorInfo=$errorInfo" 743 } 634 744 } 635 745 } … … 876 986 FixSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \ 877 987 axis-visible axis-labels \ 878 mesh-edges mesh-lighting mesh-opacity mesh-visible \ 879 mesh-wireframe 988 989 if { $_havePolydata } { 990 FixSettings polydata-edges polydata-lighting polydata-opacity \ 991 polydata-visible polydata-wireframe 992 } 880 993 SendCmd "imgflush" 881 994 } … … 917 1030 } 918 1031 lappend _obj2datasets($dataobj) $tag 1032 SendCmd "dataset visible 1 $tag" 919 1033 if { [info exists _obj2ovride($dataobj-raise)] } { 920 SendCmd "dataset visible 1 $tag" 921 puts stderr "$count: dataset visible 1 $tag" 1034 SetOpacity $tag 922 1035 } 923 1036 } … … 953 1066 Zoom reset 954 1067 } 955 FixSettings molecule-representation956 1068 957 1069 SendCmd "dataset maprange visible" 958 1070 1071 if { $_haveMolecules } { 1072 #FixSettings molecule-representation 1073 } 959 1074 set _reset 0 960 1075 global readyForNextFrame … … 1197 1312 } 1198 1313 switch -- $what { 1199 "mesh-opacity" { 1200 set val $_settings(mesh-opacity) 1201 set sval [expr { 0.01 * double($val) }] 1314 "polydata-opacity" { 1202 1315 foreach dataset [CurrentDatasets -visible $_first] { 1203 1316 foreach { dataobj comp } [split $dataset -] break 1204 set type [$dataobj type $comp] 1205 if { $type == "polydata" } { 1206 SendCmd "$type opacity $sval $dataset" 1207 } 1208 } 1209 } 1210 "mesh-wireframe" { 1211 set bool $_settings(mesh-wireframe) 1317 if { [$dataobj type $comp] == "polydata" } { 1318 SetOpacity $dataset 1319 } 1320 } 1321 } 1322 "polydata-wireframe" { 1323 set bool $_settings(polydata-wireframe) 1212 1324 foreach dataset [CurrentDatasets -visible $_first] { 1213 1325 foreach { dataobj comp } [split $dataset -] break … … 1218 1330 } 1219 1331 } 1220 " mesh-visible" {1221 set bool $_settings( mesh-visible)1332 "polydata-visible" { 1333 set bool $_settings(polydata-visible) 1222 1334 foreach dataset [CurrentDatasets -visible $_first] { 1223 1335 foreach { dataobj comp } [split $dataset -] break … … 1228 1340 } 1229 1341 } 1230 " mesh-lighting" {1231 set bool $_settings( mesh-lighting)1342 "polydata-lighting" { 1343 set bool $_settings(polydata-lighting) 1232 1344 foreach dataset [CurrentDatasets -visible $_first] { 1233 1345 foreach { dataobj comp } [split $dataset -] break … … 1238 1350 } 1239 1351 } 1240 " mesh-edges" {1241 set bool $_settings( mesh-edges)1352 "polydata-edges" { 1353 set bool $_settings(polydata-edges) 1242 1354 foreach dataset [CurrentDatasets -visible $_first] { 1243 1355 foreach { dataobj comp } [split $dataset -] break … … 1248 1360 } 1249 1361 } 1250 " mesh-palette" {1362 "polydata-palette" { 1251 1363 set palette [$itk_component(meshpalette) value] 1252 set _settings( mesh-palette) $palette1364 set _settings(polydata-palette) $palette 1253 1365 foreach dataset [CurrentDatasets -visible $_first] { 1254 1366 foreach {dataobj comp} [split $dataset -] break … … 1265 1377 foreach dataset [CurrentDatasets -visible $_first] { 1266 1378 foreach { dataobj comp } [split $dataset -] break 1267 set type [$dataobj type $comp] 1268 if { $type == "molecule" } { 1269 SendCmd "molecule opacity $sval $dataset" 1379 if { [$dataobj type $comp] == "molecule" } { 1380 SetOpacity $dataset 1270 1381 } 1271 1382 } … … 1313 1424 "molecule-palette" { 1314 1425 set palette [$itk_component(moleculepalette) value] 1315 set _ settings(molecule-palette) $palette1426 set _moelculeSettings(palette) $palette 1316 1427 foreach dataset [CurrentDatasets -visible $_first] { 1317 1428 foreach {dataobj comp} [split $dataset -] break … … 1335 1446 "ballandstick" { 1336 1447 set rscale covalent 1337 set ashow11338 set bshow11448 set _settings(molecule-atoms-visible) 1 1449 set _settings(molecule-bonds-visible) 1 1339 1450 set bstyle cylinder 1340 set ascale0.31341 set bscale0.0751451 set _settings(molecule-atomscale) 0.3 1452 set _settings(molecule-bondscale) 0.075 1342 1453 } 1343 1454 "balls" - "spheres" { 1344 1455 set rscale covalent 1345 set ashow11346 set bshow01456 set _settings(molecule-atoms-visible) 1 1457 set _settings(molecule-bonds-visible) 0 1347 1458 set bstyle cylinder 1348 set ascale0.31349 set bscale0.0751459 set _settings(molecule-atomscale) 0.3 1460 set _settings(molecule-bondscale) 0.075 1350 1461 } 1351 1462 "sticks" { 1352 1463 set rscale none 1353 set ashow11354 set bshow11464 set _settings(molecule-atoms-visible) 1 1465 set _settings(molecule-bonds-visible) 1 1355 1466 set bstyle cylinder 1356 set ascale0.0751357 set bscale0.0751467 set _settings(molecule-atomscale) 0.075 1468 set _settings(molecule-bondscale) 0.075 1358 1469 } 1359 1470 "spacefilling" { 1360 1471 set rscale van_der_waals 1361 set ashow11362 set bshow01472 set _settings(molecule-atoms-visible) 1 1473 set _settings(molecule-bonds-visible) 0 1363 1474 set bstyle cylinder 1364 set ascale1.01365 set bscale0.0751475 set _settings(molecule-atomscale) 1.0 1476 set _settings(molecule-bondscale) 0.075 1366 1477 } 1367 1478 "rods" { 1368 1479 set rscale none 1369 set ashow11370 set bshow11480 set _settings(molecule-atoms-visible) 1 1481 set _settings(molecule-bonds-visible) 1 1371 1482 set bstyle cylinder 1372 set ascale0.11373 set bscale0.11483 set _settings(molecule-atomscale) 0.1 1484 set _settings(molecule-bondscale) 0.1 1374 1485 } 1375 1486 "wireframe" - "lines" { 1376 1487 set rscale none 1377 set ashow01378 set bshow11488 set _settings(molecule-atoms-visible) 0 1489 set _settings(molecule-bonds-visible) 1 1379 1490 set bstyle line 1380 set ascale1.01381 set bscale1.01491 set _settings(molecule-atomscale) 1.0 1492 set _settings(molecule-bondscale) 1.0 1382 1493 } 1383 1494 default { … … 1390 1501 if { $type == "molecule" } { 1391 1502 SendCmd [subst {molecule rscale $rscale $dataset 1392 molecule a toms $ashow$dataset1393 molecule b onds $bshow$dataset1503 molecule ascale $_settings(molecule-atomscale) $dataset 1504 molecule bscale $_settings(molecule-bondscale) $dataset 1394 1505 molecule bstyle $bstyle $dataset 1395 molecule a scale $ascale$dataset1396 molecule b scale $bscale$dataset}]1506 molecule atoms $_settings(molecule-atoms-visible) $dataset 1507 molecule bonds $_settings(molecule-bonds-visible) $dataset}] 1397 1508 } 1398 1509 } … … 1570 1681 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1571 1682 } 1572 if { ![info exists _settings( mesh-opacity)] } {1573 set _settings( mesh-opacity) $style(-opacity)1574 } 1575 set max $_settings( mesh-opacity)1683 if { ![info exists _settings(polydata-opacity)] } { 1684 set _settings(polydata-opacity) $style(-opacity) 1685 } 1686 set max $_settings(polydata-opacity) 1576 1687 1577 1688 set wmap "0.0 1.0 1.0 1.0" … … 1601 1712 1602 1713 itcl::body Rappture::VtkViewer::limits { dataobj } { 1603 puts stderr components=[$dataobj components]1604 1714 foreach comp [$dataobj components] { 1605 1715 set tag $dataobj-$comp … … 1688 1798 } 1689 1799 1690 itcl::body Rappture::VtkViewer::Build MeshTab {} {1800 itcl::body Rappture::VtkViewer::BuildPolydataTab {} { 1691 1801 1692 1802 set fg [option get $itk_component(hull) font Font] … … 1700 1810 checkbutton $inner.mesh \ 1701 1811 -text "Show Mesh" \ 1702 -variable [itcl::scope _settings( mesh-visible)] \1703 -command [itcl::code $this AdjustSetting mesh-visible] \1812 -variable [itcl::scope _settings(polydata-visible)] \ 1813 -command [itcl::code $this AdjustSetting polydata-visible] \ 1704 1814 -font "Arial 9" -anchor w 1705 1815 1706 1816 checkbutton $inner.wireframe \ 1707 1817 -text "Show Wireframe" \ 1708 -variable [itcl::scope _settings( mesh-wireframe)] \1709 -command [itcl::code $this AdjustSetting mesh-wireframe] \1818 -variable [itcl::scope _settings(polydata-wireframe)] \ 1819 -command [itcl::code $this AdjustSetting polydata-wireframe] \ 1710 1820 -font "Arial 9" -anchor w 1711 1821 1712 1822 checkbutton $inner.lighting \ 1713 1823 -text "Enable Lighting" \ 1714 -variable [itcl::scope _settings( mesh-lighting)] \1715 -command [itcl::code $this AdjustSetting mesh-lighting] \1824 -variable [itcl::scope _settings(polydata-lighting)] \ 1825 -command [itcl::code $this AdjustSetting polydata-lighting] \ 1716 1826 -font "Arial 9" -anchor w 1717 1827 1718 1828 checkbutton $inner.edges \ 1719 1829 -text "Show Edges" \ 1720 -variable [itcl::scope _settings( mesh-edges)] \1721 -command [itcl::code $this AdjustSetting mesh-edges] \1830 -variable [itcl::scope _settings(polydata-edges)] \ 1831 -command [itcl::code $this AdjustSetting polydata-edges] \ 1722 1832 -font "Arial 9" -anchor w 1723 1833 … … 1746 1856 $itk_component(meshpalette) value "BCGYR" 1747 1857 bind $inner.palette <<Value>> \ 1748 [itcl::code $this AdjustSetting mesh-palette]1858 [itcl::code $this AdjustSetting polydata-palette] 1749 1859 1750 1860 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 1751 1861 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1752 -variable [itcl::scope _settings( mesh-opacity)] \1862 -variable [itcl::scope _settings(polydata-opacity)] \ 1753 1863 -width 10 \ 1754 1864 -showvalue off \ 1755 -command [itcl::code $this AdjustSetting mesh-opacity]1865 -command [itcl::code $this AdjustSetting polydata-opacity] 1756 1866 1757 1867 blt::table $inner \ … … 2123 2233 $inner.cell select 2124 2234 2235 label $inner.atomscale_l -text "Atom Scale" -font "Arial 9" 2236 ::scale $inner.atomscale -width 15 -font "Arial 7" \ 2237 -from 0.0 -to 2.0 -resolution 0.05 -label "" \ 2238 -showvalue true -orient horizontal \ 2239 -command [itcl::code $this EventuallyAtomScale] \ 2240 -variable [itcl::scope _settings(molecule-atomscale)] 2241 $inner.atomscale set $_settings(molecule-atomscale) 2242 Rappture::Tooltip::for $inner.atomscale \ 2243 "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius." 2244 2245 label $inner.bondscale_l -text "Bond Scale" -font "Arial 9" 2246 ::scale $inner.bondscale -width 15 -font "Arial 7" \ 2247 -from 0.0 -to 1.0 -resolution 0.025 -label "" \ 2248 -showvalue true -orient horizontal \ 2249 -command [itcl::code $this EventuallyBondScale] \ 2250 -variable [itcl::scope _settings(molecule-bondscale)] 2251 Rappture::Tooltip::for $inner.bondscale \ 2252 "Adjust scale of bonds (sticks)." 2253 $inner.bondscale set $_settings(molecule-bondscale) 2254 2125 2255 label $inner.opacity_l -text "Opacity" -font "Arial 9" 2126 2256 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2127 2257 -variable [itcl::scope _settings(molecule-opacity)] \ 2128 -width 1 0\2129 -showvalue o ff\2130 -command [itcl::code $this AdjustSetting molecule-opacity]2258 -width 15 -font "Arial 7" \ 2259 -showvalue on \ 2260 -command [itcl::code $this EventuallyMoleculeOpacity] 2131 2261 2132 2262 blt::table $inner \ 2133 0,0 $inner.molecule -anchor w -pady {1 0} \ 2134 1,0 $inner.label -anchor w -pady {1 0} \ 2135 2,0 $inner.edges -anchor w -pady {1 0} \ 2136 3,0 $inner.rep_l -anchor w -pady { 2 0 } \ 2137 4,0 $inner.rep -anchor w \ 2138 5,0 $inner.palette_l -anchor w -pady 2 \ 2139 6,0 $inner.palette -fill x -pady 2 \ 2140 7,0 $inner.opacity_l -anchor w -pady 2 \ 2141 8,0 $inner.opacity -fill x -pady 2 2263 0,0 $inner.molecule -anchor w -pady {1 0} \ 2264 1,0 $inner.label -anchor w -pady {1 0} \ 2265 2,0 $inner.edges -anchor w -pady {1 0} \ 2266 3,0 $inner.rep_l -anchor w -pady { 2 0 } \ 2267 4,0 $inner.rep -fill x -pady 2 \ 2268 5,0 $inner.palette_l -anchor w -pady 0 \ 2269 6,0 $inner.palette -fill x -padx 2 \ 2270 7,0 $inner.atomscale_l -anchor w -pady {3 0} \ 2271 8,0 $inner.atomscale -fill x -padx 2 \ 2272 9,0 $inner.bondscale_l -anchor w -pady {3 0} \ 2273 10,0 $inner.bondscale -fill x -padx 2 \ 2274 11,0 $inner.opacity_l -anchor w -pady {3 0} \ 2275 12,0 $inner.opacity -fill x -padx 2 2142 2276 2143 2277 blt::table configure $inner r* -resize none 2144 blt::table configure $inner r 9-resize expand2278 blt::table configure $inner r13 -resize expand 2145 2279 } 2146 2280 … … 2184 2318 } 2185 2319 2186 itcl::body Rappture::VtkViewer::ConvertToVtkData { dataobj comp } {2187 foreach { x1 x2 xN y1 y2 yN } [$dataobj mesh $comp] break2188 set values [$dataobj values $comp]2189 append out "# vtk DataFile Version 2.0 \n"2190 append out "Test data \n"2191 append out "ASCII \n"2192 append out "DATASET STRUCTURED_POINTS \n"2193 append out "DIMENSIONS $xN $yN 1 \n"2194 append out "ORIGIN 0 0 0 \n"2195 append out "SPACING 1 1 1 \n"2196 append out "POINT_DATA [expr $xN * $yN] \n"2197 append out "SCALARS field double 1 \n"2198 append out "LOOKUP_TABLE default \n"2199 append out [join $values "\n"]2200 append out "\n"2201 return $out2202 }2203 2204 2320 itcl::body Rappture::VtkViewer::GetVtkData { args } { 2205 2321 set bytes "" … … 2209 2325 set contents [$dataobj data $comp] 2210 2326 append bytes "$contents\n" 2211 append bytes "\# End of VTK file\n\n" 2212 } 2213 } 2214 return [list .txt $bytes] 2327 } 2328 } 2329 return [list .vtk $bytes] 2215 2330 } 2216 2331 … … 2274 2389 set settings(-wireframe) 1 2275 2390 } 2276 if { $type == "glyphs" } { 2277 array set settings { 2278 -color \#808080 2279 -gscale 1 2280 -edges 0 2281 -edgecolor black 2282 -linewidth 1.0 2283 -opacity 1.0 2284 -wireframe 0 2285 -lighting 1 2286 -visible 1 2287 } 2288 set shape [$dataobj shape $comp] 2289 array set settings $style 2290 SendCmd "glyphs add $shape $tag" 2291 SendCmd "glyphs normscale 0 $tag" 2292 SendCmd "glyphs gscale $settings(-gscale) $tag" 2293 SendCmd "glyphs wireframe $settings(-wireframe) $tag" 2294 #SendCmd "glyphs ccolor [Color2RGB $settings(-color)] $tag" 2295 #SendCmd "glyphs colormode ccolor {} $tag" 2296 SendCmd "glyphs gorient 0 {} $tag" 2297 SendCmd "glyphs smode vcomp {} $tag" 2298 SendCmd "glyphs opacity $settings(-opacity) $tag" 2299 SendCmd "glyphs visible $settings(-visible) $tag" 2300 set _settings(glyphs-wireframe) $settings(-wireframe) 2301 set _haveGlyphs 1 2302 } elseif { $type == "molecule" } { 2303 SendCmd "molecule add $tag" 2304 SendCmd "molecule rscale van_der_waals $tag" 2305 set _haveMolecules 1 2306 } else { 2307 array set settings { 2308 -color \#6666FF 2309 -edges 1 2310 -edgecolor black 2311 -linewidth 1.0 2312 -opacity 1.0 2313 -wireframe 0 2314 -lighting 1 2315 -visible 1 2316 } 2317 array set settings $style 2318 SendCmd "polydata add $tag" 2319 SendCmd "polydata visible $settings(-visible) $tag" 2320 set _settings(mesh-visible) $settings(-visible) 2321 SendCmd "polydata edges $settings(-edges) $tag" 2322 set _settings(mesh-edges) $settings(-edges) 2323 SendCmd "polydata color [Color2RGB $settings(-color)] $tag" 2324 SendCmd "polydata lighting $settings(-lighting) $tag" 2325 set _settings(mesh-lighting) $settings(-lighting) 2326 SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag" 2327 SendCmd "polydata linewidth $settings(-linewidth) $tag" 2328 SendCmd "polydata opacity $settings(-opacity) $tag" 2329 set _settings(mesh-opacity) $settings(-opacity) 2330 SendCmd "polydata wireframe $settings(-wireframe) $tag" 2331 set _settings(mesh-wireframe) $settings(-wireframe) 2391 switch -- $type { 2392 "glyphs" { 2393 array set settings { 2394 -color \#808080 2395 -gscale 1 2396 -edges 0 2397 -edgecolor black 2398 -linewidth 1.0 2399 -opacity 1.0 2400 -wireframe 0 2401 -lighting 1 2402 -visible 1 2403 } 2404 set shape [$dataobj shape $comp] 2405 array set settings $style 2406 SendCmd "glyphs add $shape $tag" 2407 SendCmd "glyphs normscale 0 $tag" 2408 SendCmd "glyphs gscale $settings(-gscale) $tag" 2409 SendCmd "glyphs wireframe $settings(-wireframe) $tag" 2410 #SendCmd "glyphs ccolor [Color2RGB $settings(-color)] $tag" 2411 #SendCmd "glyphs colormode ccolor {} $tag" 2412 SendCmd "glyphs gorient 0 {} $tag" 2413 SendCmd "glyphs smode vcomp {} $tag" 2414 SendCmd "glyphs opacity $settings(-opacity) $tag" 2415 SendCmd "glyphs visible $settings(-visible) $tag" 2416 set _settings(glyphs-wireframe) $settings(-wireframe) 2417 } 2418 "molecule" { 2419 SendCmd "molecule add $tag" 2420 SendCmd "molecule rscale van_der_waals $tag" 2421 set _haveMolecules 1 2422 } 2423 "polydata" { 2424 array set settings { 2425 -color \#6666FF 2426 -edges 1 2427 -edgecolor black 2428 -linewidth 1.0 2429 -opacity 1.0 2430 -wireframe 0 2431 -lighting 1 2432 -visible 1 2433 } 2434 array set settings $style 2435 SendCmd "polydata add $tag" 2436 SendCmd "polydata visible $settings(-visible) $tag" 2437 set _settings(polydata-visible) $settings(-visible) 2438 SendCmd "polydata edges $settings(-edges) $tag" 2439 set _settings(polydata-edges) $settings(-edges) 2440 SendCmd "polydata color [Color2RGB $settings(-color)] $tag" 2441 SendCmd "polydata lighting $settings(-lighting) $tag" 2442 set _settings(polydata-lighting) $settings(-lighting) 2443 SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag" 2444 SendCmd "polydata linewidth $settings(-linewidth) $tag" 2445 SendCmd "polydata opacity $settings(-opacity) $tag" 2446 set _settings(polydata-opacity) $settings(-opacity) 2447 SendCmd "polydata wireframe $settings(-wireframe) $tag" 2448 set _settings(polydata-wireframe) $settings(-wireframe) 2449 set havePolyData 1 2450 } 2332 2451 } 2333 2452 SetColormap $dataobj $comp … … 2517 2636 set _view(zoom) 1.0 2518 2637 } 2638 2639 itcl::body Rappture::VtkViewer::SetOpacity { dataset } { 2640 foreach {dataobj comp} [split $dataset -] break 2641 set type [$dataobj type $comp] 2642 set val $_settings($type-opacity) 2643 set sval [expr { 0.01 * double($val) }] 2644 if { !$_obj2ovride($dataobj-raise) } { 2645 # This is wrong. Need to figure out why raise isn't set with 1 2646 #set sval [expr $sval * .6] 2647 } 2648 SendCmd "$type opacity $sval $dataset" 2649 }
Note: See TracChangeset
for help on using the changeset viewer.