- Timestamp:
- Aug 15, 2012 8:30:38 AM (12 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/choiceentry.tcl
r1929 r3139 240 240 # Assign the default value to this widget, if there is one. 241 241 # 242 set defval [ $_owner xml get $_path.default]242 set defval [string trim [$_owner xml get $_path.default]] 243 243 if {"" != $defval} { 244 244 if {[info exists _str2val($defval)]} { -
trunk/gui/scripts/controlOwner.tcl
r2977 r3139 59 59 # in coordination with loaders inside the load function 60 60 array set _type2curpath { 61 drawing components61 drawing all 62 62 choice current 63 63 boolean current … … 270 270 set type [[tool] xml element -as type $path] 271 271 if {[info exists _type2curpath($type)]} { 272 set currentpath $path.$_type2curpath($type) 272 if { $_type2curpath($type) == "all" } { 273 set currentpath $path 274 } else { 275 set currentpath $path.$_type2curpath($type) 276 } 273 277 } else { 274 278 # default incase i forgot an input type in _type2curpath -
trunk/gui/scripts/drawingentry.tcl
r3101 r3139 28 28 private variable _drawingWidth 0 29 29 private variable _owner 30 private variable _xmlobj "" 30 31 private variable _parser ""; # Slave interpreter where all 31 32 # substituted variables are stored. … … 99 100 set _path $path 100 101 set _owner $owner 102 set _xmlobj [$_owner xml object] 101 103 # 102 104 # Display the current drawing. … … 128 130 itcl::body Rappture::DrawingEntry::label {} { 129 131 return "" 130 set label [$_ owner xmlget $_path.about.label]132 set label [$_xmlobj get $_path.about.label] 131 133 if {"" == $label} { 132 134 set label "Drawing" … … 145 147 itcl::body Rappture::DrawingEntry::tooltip {} { 146 148 return "" 147 set str [$_ owner xmlget $_path.about.description]149 set str [$_xmlobj get $_path.about.description] 148 150 return [string trim $str] 149 151 } … … 194 196 ParseBackground 195 197 ParseSubstitutions 196 foreach cname [$_ owner xmlchildren $_path.components] {198 foreach cname [$_xmlobj children $_path.components] { 197 199 switch -glob -- $cname { 198 200 "line*" { … … 289 291 #puts stderr "ParseGrid owner=$_owner cpath=$cpath xcoords=$xcoords ycoords=$ycoords" 290 292 set list {} 291 foreach attr [$_ owner xmlchildren $cpath] {293 foreach attr [$_xmlobj children $cpath] { 292 294 if { [info exists attr2option($attr)] } { 293 295 set option $attr2option($attr) … … 325 327 } 326 328 array unset _cname2controls $cname 327 foreach attr [$_ owner xmlchildren $cpath] {329 foreach attr [$_xmlobj children $cpath] { 328 330 if { [info exists attr2option($attr)] } { 329 331 set option $attr2option($attr) … … 333 335 set value [XmlGetSubst $cpath.$attr] 334 336 lappend _cname2controls($cname) $value 335 $_ owner xmlput $value.hide 1337 $_xmlobj put $value.hide 1 336 338 } 337 339 } … … 387 389 #puts stderr "ParseLine owner=$_owner cpath=$cpath coords=$coords" 388 390 set list {} 389 foreach attr [$_ owner xmlchildren $cpath] {391 foreach attr [$_xmlobj children $cpath] { 390 392 if { [info exists attr2option($attr)] } { 391 393 set option $attr2option($attr) … … 417 419 -outline black 418 420 } 419 foreach attr [$_ owner xmlchildren $cpath] {421 foreach attr [$_xmlobj children $cpath] { 420 422 if { [info exists attr2option($attr)] } { 421 423 set option $attr2option($attr) … … 449 451 -anchor nw 450 452 } 451 foreach attr [$_ owner xmlchildren $cpath] {453 foreach attr [$_xmlobj children $cpath] { 452 454 if { [info exists attr2option($attr)] } { 453 455 set option $attr2option($attr) … … 558 560 #puts stderr "ParsePolygon owner=$_owner cpath=$cpath coords=$coords" 559 561 set list {} 560 foreach attr [$_ owner xmlchildren $cpath] {562 foreach attr [$_xmlobj children $cpath] { 561 563 if { [info exists attr2option($attr)] } { 562 564 set option $attr2option($attr) … … 588 590 -outline black 589 591 } 590 foreach attr [$_ owner xmlchildren $cpath] {592 foreach attr [$_xmlobj children $cpath] { 591 593 if { [info exists attr2option($attr)] } { 592 594 set option $attr2option($attr) … … 630 632 -anchor c 631 633 } 632 foreach attr [$_ owner xmlchildren $cpath] {634 foreach attr [$_xmlobj children $cpath] { 633 635 if { [info exists attr2option($attr)] } { 634 636 set option $attr2option($attr) … … 668 670 if { [info exists _name2path($varName)] } { 669 671 set path $_name2path($varName) 670 $_ owner xmlput $path.hide 1672 $_xmlobj put $path.hide 1 671 673 lappend _cname2controls($cname) $path 672 674 } else { … … 830 832 831 833 itcl::body Rappture::DrawingEntry::ParseBackground {} { 832 foreach elem [$_ owner xmlchildren $_path.background] {834 foreach elem [$_xmlobj children $_path.background] { 833 835 switch -glob -- $elem { 834 836 "color*" { … … 859 861 860 862 itcl::body Rappture::DrawingEntry::ParseSubstitutions {} { 861 foreach var [$_ owner xmlchildren $_path.substitutions] {863 foreach var [$_xmlobj children $_path.substitutions] { 862 864 if { ![string match "variable*" $var] } { 863 865 continue … … 867 869 set name "" 868 870 set path "" 869 foreach elem [$_ owner xmlchildren $varPath] {871 foreach elem [$_xmlobj children $varPath] { 870 872 switch -glob -- $elem { 871 873 "name*" { … … 981 983 # ---------------------------------------------------------------------- 982 984 itcl::body Rappture::DrawingEntry::value {args} { 983 # drawing entries have no value 985 # Redraw if there's a new library object. 986 if { [llength $args] > 0 } { 987 set libobj [lindex $args 0] 988 if { $libobj != "" } { 989 Redraw 990 } 991 } 984 992 return "" 985 993 } … … 1004 1012 1005 1013 itcl::body Rappture::DrawingEntry::XmlGet { path } { 1006 set value [$_ owner xmlget $path]1014 set value [$_xmlobj get $path] 1007 1015 return [string trim $value] 1008 1016 } 1009 1017 1010 1018 itcl::body Rappture::DrawingEntry::XmlGetSubst { path } { 1011 set value [$_ owner xmlget $path]1019 set value [$_xmlobj get $path] 1012 1020 if { $_parser == "" } { 1013 1021 return $value … … 1017 1025 1018 1026 itcl::body Rappture::DrawingEntry::IsEnabled { path } { 1019 set enable [string trim [$_ owner xmlget $path.about.enable]]1027 set enable [string trim [$_xmlobj get $path.about.enable]] 1020 1028 if {"" == $enable} { 1021 1029 return 1 -
trunk/gui/scripts/vtkviewer.tcl
r3137 r3139 69 69 protected method DoResize {} 70 70 protected method DoRotate {} 71 private method DoUpdate {}72 71 protected method AdjustSetting {what {value ""}} 73 72 protected method FixSettings { args } … … 95 94 private method EventuallyResize { w h } 96 95 private method EventuallyRotate { q } 97 private method EventuallyChangeSettings { args }98 96 private method GetImage { args } 99 97 private method GetVtkData { args } … … 232 230 array set _settings [subst { 233 231 legend 1 234 molecule-atomscale 0.5 235 molecule-bondscale 0.2 236 molecule-atomradius "Van der Waals" 237 molecule-representation "ball and stick" 232 molecule-representation "Ball and Stick" 238 233 molecule-edges 0 239 234 molecule-labels 0 … … 469 464 } 470 465 471 itcl::body Rappture::VtkViewer::DoUpdate { } {472 foreach dataset [CurrentDatasets -visible $_first] {473 foreach { dataobj comp } [split $dataset -] break474 set type [$dataobj type $comp]475 if { $type == "molecule" } {476 set val [expr $_settings(molecule-atomscale) * 0.1]477 SendCmd "molecule ascale $val $dataset"478 set val [expr $_settings(molecule-bondscale) * 0.1]479 SendCmd "molecule bscale $val $dataset"480 }481 }482 set _updatePending 0483 }484 485 itcl::body Rappture::VtkViewer::EventuallyChangeSettings { args } {486 if { !$_updatePending } {487 $_dispatcher event -after 250 !update488 set _updatePending 1489 }490 }491 492 466 # ---------------------------------------------------------------------- 493 467 # USAGE: add <dataobj> ?<settings>? … … 979 953 } 980 954 } 981 if { $_haveMolecules } { 982 FixSettings molecule-radius molecule-representation 983 } 955 FixSettings molecule-representation 956 984 957 SendCmd "dataset maprange visible" 985 958 … … 1349 1322 set _legendPending 1 1350 1323 } 1351 "molecule-radius" { 1352 set value [$itk_component(atomradius) value] 1353 set value [$itk_component(atomradius) translate $value] 1324 "molecule-representation" { 1325 set value [$itk_component(representation) value] 1326 set value [$itk_component(representation) translate $value] 1327 switch -- $value { 1328 "ballandstick" { 1329 set ashow 1 1330 set bshow 1 1331 set ascale 0.5 1332 set bscale 0.15 1333 } 1334 "balls" - "spheres" { 1335 set ashow 1 1336 set bshow 0 1337 set ascale 0.5 1338 set bscale 0.15 1339 } 1340 "sticks" { 1341 set ashow 0 1342 set bshow 1 1343 set ascale 0.5 1344 set bscale 0.15 1345 } 1346 "spacefilling" { 1347 set ashow 1 1348 set bshow 0 1349 set ascale 1.0 1350 set bscale 0.15 1351 } 1352 "rods" { 1353 set ashow 0 1354 set bshow 1 1355 set ascale 0.5 1356 set bscale 0.25 1357 } 1358 "wireframe" - "lines" { 1359 set ashow 0 1360 set bshow 1 1361 set ascale 0.5 1362 set bscale 0.05 1363 } 1364 default { 1365 error "unknown representation $value" 1366 } 1367 } 1368 set ascale [expr $ascale * 0.1] 1369 set bscale [expr $bscale * 0.1] 1354 1370 foreach dataset [CurrentDatasets -visible $_first] { 1355 1371 foreach {dataobj comp} [split $dataset -] break 1356 1372 set type [$dataobj type $comp] 1357 1373 if { $type == "molecule" } { 1358 SendCmd "molecule rscale $value $dataset" 1359 } 1360 } 1361 } 1362 "molecule-representation" { 1363 set value [$itk_component(representation) value] 1364 set value [$itk_component(representation) translate $value] 1365 foreach dataset [CurrentDatasets -visible $_first] { 1366 foreach {dataobj comp} [split $dataset -] break 1367 set type [$dataobj type $comp] 1368 if { $type == "molecule" } { 1369 switch -- $value { 1370 "ballandstick" { 1371 SendCmd "molecule atoms 1 $dataset" 1372 SendCmd "molecule bonds 1 $dataset" 1373 } 1374 "spheres" { 1375 SendCmd "molecule atoms 1 $dataset" 1376 SendCmd "molecule bonds 0 $dataset" 1377 } 1378 "sticks" - "lines" { 1379 SendCmd "molecule atoms 0 $dataset" 1380 SendCmd "molecule bonds 1 $dataset" 1381 } 1382 default { 1383 error "unknown representation $value" 1384 } 1385 } 1374 SendCmd [subst { 1375 molecule atoms $ashow $dataset 1376 molecule bonds $bshow $dataset 1377 molecule ascale $ascale $dataset 1378 molecule bscale $bscale $dataset 1379 }] 1386 1380 } 1387 1381 } … … 1514 1508 array set style $_style($tag) 1515 1509 1516 set name "$style(-color):$style(-levels):$style(-opacity)" 1510 if { $style(-color) == "elementDefault" } { 1511 set name "$style(-color)" 1512 } else { 1513 set name "$style(-color):$style(-levels):$style(-opacity)" 1514 } 1517 1515 if { ![info exists _colormaps($name)] } { 1518 1516 BuildColormap $name [array get style] … … 1752 1750 # 1753 1751 itcl::body Rappture::VtkViewer::BuildColormap { name styles } { 1752 puts stderr name=$name 1753 if { $name == "elementDefault" } { 1754 return 1755 } 1754 1756 array set style $styles 1755 1757 set cmap [ColorsToColormap $style(-color)] … … 2225 2227 } 2226 2228 $inner.rep choices insert end \ 2227 "ballandstick" "ball and stick" \ 2228 "spheres" "spheres" \ 2229 "sticks" "sticks" \ 2230 "lines" "lines" 2229 "ballandstick" "Ball and Stick" \ 2230 "spheres" "Spheres" \ 2231 "sticks" "Sticks" \ 2232 "rods" "Rods" \ 2233 "wireframe" "Wireframe" \ 2234 "spacefilling" "Space Filling" 2231 2235 2232 2236 bind $inner.rep <<Value>> \ 2233 2237 [itcl::code $this AdjustSetting molecule-representation] 2234 $inner.rep value " ball and stick"2238 $inner.rep value "Ball and Stick" 2235 2239 2236 2240 label $inner.palette_l -text "Palette" -font "Arial 9" … … 2239 2243 } 2240 2244 $inner.palette choices insert end \ 2245 "elementDefault" "elementDefault" \ 2241 2246 "BCGYR" "BCGYR" \ 2242 2247 "BGYOR" "BGYOR" \ … … 2260 2265 [itcl::code $this AdjustSetting molecule-palette] 2261 2266 2262 ::scale $inner.atomscale -width 10 -font "Arial 9" \2263 -from 0.1 -to 2.0 -resolution 0.005 -label "Atom Scale" \2264 -showvalue true -orient horizontal \2265 -command [itcl::code $this EventuallyChangeSettings] \2266 -variable [itcl::scope _settings(molecule-atomscale)]2267 $inner.atomscale set $_settings(molecule-atomscale)2268 Rappture::Tooltip::for $inner.atomscale \2269 "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."2270 2271 ::scale $inner.bondscale -width 10 -font "Arial 9" \2272 -from 0.1 -to 1.0 -resolution 0.0025 -label "Bond Scale" \2273 -showvalue true -orient horizontal \2274 -command [itcl::code $this EventuallyChangeSettings] \2275 -variable [itcl::scope _settings(molecule-bondscale)]2276 Rappture::Tooltip::for $inner.bondscale \2277 "Adjust scale of bonds (sticks)."2278 $inner.bondscale set $_settings(molecule-bondscale)2279 2280 2267 checkbutton $inner.labels -text "Show labels on atoms" \ 2281 2268 -command [itcl::code $this labels update] \ … … 2295 2282 $inner.cell select 2296 2283 2297 label $inner.atomradius_l -text "Radius Scaling Method" \2298 -font "Arial 9"2299 itk_component add atomradius {2300 Rappture::Combobox $inner.atomradius -width 20 -editable no2301 }2302 $inner.atomradius choices insert end \2303 "van_der_waals" "Van der Waals" \2304 "covalent" "Covalent" \2305 "atomic" "Atomic" \2306 "none" "None"2307 bind $inner.atomradius <<Value>> \2308 [itcl::code $this AdjustSetting molecule-radius]2309 $inner.atomradius value "Van der Waals"2310 label $inner.spacer2311 2312 2284 label $inner.opacity_l -text "Opacity" -font "Arial 9" 2313 2285 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ … … 2320 2292 0,0 $inner.molecule -anchor w -pady {1 0} \ 2321 2293 1,0 $inner.label -anchor w -pady {1 0} \ 2322 2,0 $inner.wireframe -anchor w -pady {1 0} \ 2323 4,0 $inner.edges -anchor w -pady {1 0} \ 2324 6,0 $inner.atomradius_l -anchor w -pady 2 \ 2325 7,0 $inner.atomradius -anchor w -pady {1 0} \ 2326 9,0 $inner.rep_l -anchor w -pady { 2 0 } \ 2327 10,0 $inner.rep -anchor w \ 2328 11,0 $inner.atomscale -fill x -pady {3 0} \ 2329 12,0 $inner.bondscale -fill x -pady {1 0} \ 2330 13,0 $inner.palette_l -anchor w -pady 2 \ 2331 14,0 $inner.palette -fill x -pady 2 \ 2332 15,0 $inner.opacity_l -anchor w -pady 2 \ 2333 16,0 $inner.opacity -fill x -pady 2 2294 2,0 $inner.edges -anchor w -pady {1 0} \ 2295 3,0 $inner.rep_l -anchor w -pady { 2 0 } \ 2296 4,0 $inner.rep -anchor w \ 2297 5,0 $inner.palette_l -anchor w -pady 2 \ 2298 6,0 $inner.palette -fill x -pady 2 \ 2299 7,0 $inner.opacity_l -anchor w -pady 2 \ 2300 8,0 $inner.opacity -fill x -pady 2 2334 2301 2335 2302 blt::table configure $inner r* -resize none 2336 blt::table configure $inner r 17-resize expand2303 blt::table configure $inner r9 -resize expand 2337 2304 } 2338 2305 … … 2490 2457 SendCmd "glyphs opacity $settings(-opacity) $tag" 2491 2458 SendCmd "glyphs visible $settings(-visible) $tag" 2459 set _settings(glyphs-wireframe) $settings(-wireframe) 2492 2460 set _haveGlyphs 1 2493 2461 } elseif { $type == "molecule" } { … … 2507 2475 SendCmd "molecule opacity $settings(-opacity) $tag" 2508 2476 SendCmd "molecule visible $settings(-visible) $tag" 2509 SendCmd "molecule rscale $_settings(molecule-atomradius) $tag" 2510 set val [expr $_settings(molecule-atomscale) * 0.1] 2511 SendCmd "molecule ascale $val $tag" 2512 set val [expr $_settings(molecule-bondscale) * 0.1] 2513 SendCmd "molecule bscale $val $tag" 2477 SendCmd "molecule rscale van_der_waals $tag" 2478 set _settings(molecule-wireframe) $settings(-wireframe) 2514 2479 set _haveMolecules 1 2515 2480 } else {
Note: See TracChangeset
for help on using the changeset viewer.