- Timestamp:
- Jun 26, 2009, 1:16:20 PM (15 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 9 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/field2dresult.tcl
r1463 r1531 60 60 "auto" - "heightmap" { 61 61 itk_component add renderer { 62 Rappture::HeightmapViewer $itk_interior.ren $servers 62 Rappture::HeightmapViewer $itk_interior.ren $servers 63 63 } 64 64 } -
trunk/gui/scripts/flowvisviewer.tcl
r1514 r1531 2259 2259 itk_component add xCutButton { 2260 2260 Rappture::PushButton $inner.xbutton \ 2261 -onimage [Rappture::icon x-cutplane -on] \2262 -offimage [Rappture::icon x-cutplane -off] \2261 -onimage [Rappture::icon x-cutplane] \ 2262 -offimage [Rappture::icon x-cutplane] \ 2263 2263 -command [itcl::code $this FixSettings xcutplane] \ 2264 2264 -variable [itcl::scope _settings($this-xcutplane)] … … 2286 2286 itk_component add yCutButton { 2287 2287 Rappture::PushButton $inner.ybutton \ 2288 -onimage [Rappture::icon y-cutplane -on] \2289 -offimage [Rappture::icon y-cutplane -off] \2288 -onimage [Rappture::icon y-cutplane] \ 2289 -offimage [Rappture::icon y-cutplane] \ 2290 2290 -command [itcl::code $this FixSettings ycutplane] \ 2291 2291 -variable [itcl::scope _settings($this-ycutplane)] … … 2313 2313 itk_component add zCutButton { 2314 2314 Rappture::PushButton $inner.zbutton \ 2315 -onimage [Rappture::icon z-cutplane -on] \2316 -offimage [Rappture::icon z-cutplane -off] \2315 -onimage [Rappture::icon z-cutplane] \ 2316 -offimage [Rappture::icon z-cutplane] \ 2317 2317 -command [itcl::code $this FixSettings zcutplane] \ 2318 2318 -variable [itcl::scope _settings($this-zcutplane)] … … 2972 2972 return 1 2973 2973 } 2974 -
trunk/gui/scripts/heightmapviewer.tcl
r1496 r1531 24 24 option add *HeightmapViewer.plotForeground white widgetDefault 25 25 option add *HeightmapViewer.plotOutline white widgetDefault 26 option add *HeightmapViewer.font \ 27 -*-helvetica-medium-r-normal-*-12-* widgetDefault 26 option add *HeightmapViewer.font -*-helvetica-medium-r-normal-*-12-* widgetDefault 28 27 29 28 # must use this name -- plugs into Rappture::resources::load … … 660 659 if {"" == [$c find withtag transfunc]} { 661 660 $c create image 0 [expr $lineht] -anchor ne \ 662 -image $_image(legend) -tags transfunc 661 -image $_image(legend) -tags transfunc 663 662 $c create text 10 [expr {$h-8}] -anchor se \ 664 -fill $itk_option(-plotforeground) -tags vmin 663 -fill $itk_option(-plotforeground) -tags vmin \ 664 -font "Arial 8 bold" 665 665 $c create text [expr {$w-10}] [expr {$h-8}] -anchor ne \ 666 -fill $itk_option(-plotforeground) -tags vmax 666 -fill $itk_option(-plotforeground) -tags vmax \ 667 -font "Arial 8 bold" 667 668 } 668 669 $c coords transfunc [expr $w - 5] [expr $lineht] … … 1037 1038 set style(-color) "white:yellow:green:cyan:blue:magenta" 1038 1039 } 1039 set clist [split $style(-color) :] 1040 set color white 1041 set cmap "0.0 [Color2RGB $color] " 1042 set range [expr $_limits(vmax) - $_limits(vmin)] 1043 for {set i 0} {$i < [llength $clist]} {incr i} { 1044 set xval [expr {double($i+1)/([llength $clist]+1)}] 1045 set color [lindex $clist $i] 1046 append cmap "$xval [Color2RGB $color] " 1047 } 1048 append cmap "1.0 [Color2RGB $color] " 1049 1040 if { [info exists style(-nonuniformcolors)] } { 1041 foreach { value color } $style(-nonuniformcolors) { 1042 append cmap "$value [Color2RGB $color] " 1043 } 1044 } else { 1045 set clist [split $style(-color) :] 1046 set cmap "0.0 [Color2RGB white] " 1047 for {set i 0} {$i < [llength $clist]} {incr i} { 1048 set x [expr {double($i+1)/([llength $clist]+1)}] 1049 set color [lindex $clist $i] 1050 append cmap "$x [Color2RGB $color] " 1051 } 1052 append cmap "1.0 [Color2RGB $color]" 1053 } 1050 1054 set opacity $style(-opacity) 1051 1055 set levels $style(-levels) -
trunk/gui/scripts/molvisviewer.tcl
r1483 r1531 62 62 public method parameters {title args} { # do nothing } 63 63 64 public method emblems {option}64 public method labels {option {model "all"}} 65 65 public method projection {option} 66 66 public method rock {option} 67 67 public method representation {option {model "all"} } 68 public method atomscale {option {model "all"} } 69 public method bondthickness {option {model "all"} } 68 public method atomscale {option {models "all"} } 69 public method bondthickness {option {models "all"} } 70 public method opacity {option {models "all"} } 70 71 public method ResetView {} 71 72 … … 93 94 private variable _dobj2transparency;# maps dataobj => transparency 94 95 private variable _dobj2raise; # maps dataobj => raise flag 0/1 95 private variable _dobj2ghost 96 97 private variable _active; # array of active models. 98 private variable _obj2models; # array containing list of models 99 # for each data object. 96 100 97 101 private variable _view … … 166 170 phi 45 167 171 psi 0 168 vx 169 vy 170 vz 171 zoom 172 mx 173 my 174 mz 175 x 176 y 177 z 178 width 179 height 0172 vx 0 173 vy 0 174 vz 0 175 zoom 0 176 mx 0 177 my 0 178 mz 0 179 x 0 180 y 0 181 z 0 182 width 0 183 height 0 180 184 } 181 185 … … 184 188 $this-model ballnstick 185 189 $this-modelimg [Rappture::icon ballnstick] 186 $this-emblems no 190 $this-showlabels-initialized no 191 $this-showlabels no 187 192 $this-rock no 188 193 $this-ortho no 189 194 $this-atomscale 0.25 190 $this-bondthickness 0.15 195 $this-bondthickness 0.14 196 $this-opacity 1.0 191 197 }] 192 198 193 199 # 194 200 # Set up the widgets in the main body … … 233 239 234 240 itk_component add labels { 235 label $f.labels -borderwidth 1 -padx 1 -pady 1 \ 236 -relief "raised" -image [Rappture::icon atom-label] 237 } 238 pack $itk_component(labels) -padx 2 -pady {6 2} -ipadx 1 -ipady 1 241 Rappture::PushButton $f.labels \ 242 -onimage [Rappture::icon molvis-labels-view] \ 243 -offimage [Rappture::icon molvis-labels-view] \ 244 -command [itcl::code $this labels update] \ 245 -variable [itcl::scope _settings($this-showlabels)] 246 } 247 $itk_component(labels) deselect 239 248 Rappture::Tooltip::for $itk_component(labels) \ 240 249 "Show/hide the labels on atoms" 241 bind $itk_component(labels) <ButtonPress> \ 242 [itcl::code $this emblems toggle] 250 pack $itk_component(labels) -padx 2 -pady {6 2} 243 251 244 252 itk_component add rock { 245 label $f.rock -borderwidth 1 -padx 1 -pady 1 \ 246 -relief "raised" -image [Rappture::icon rock-view] 247 } 248 pack $itk_component(rock) -padx 2 -pady 2 -ipadx 1 -ipady 1 253 Rappture::PushButton $f.rock \ 254 -onimage [Rappture::icon molvis-rock-view] \ 255 -offimage [Rappture::icon molvis-rock-view] \ 256 -command [itcl::code $this rock toggle] \ 257 -variable [itcl::scope _settings($this-rock)] 258 } 259 pack $itk_component(rock) -padx 2 -pady 2 249 260 Rappture::Tooltip::for $itk_component(rock) "Rock model back and forth" 250 251 bind $itk_component(rock) <ButtonPress> \252 [itcl::code $this rock toggle]253 254 261 255 262 itk_component add ortho { 256 263 label $f.ortho -borderwidth 1 -padx 1 -pady 1 \ 257 -relief "raised" -image [Rappture::icon 3dpers]264 -relief "raised" -image [Rappture::icon molvis-3dpers] 258 265 } 259 266 pack $itk_component(ortho) -padx 2 -pady 2 -ipadx 1 -ipady 1 260 267 Rappture::Tooltip::for $itk_component(ortho) \ 261 " Change toorthoscopic projection"268 "Use orthoscopic projection" 262 269 263 270 bind $itk_component(ortho) <ButtonPress> \ … … 275 282 # have already kicked in. We end up with a 1x1 viewport and image. 276 283 277 # So the idea is to set a ridiculously big requested width tothe label284 # So the idea is to force a ridiculously big requested width on the label 278 285 # (that's why we're using the blt::table to manage the geometry). It has 279 286 # to be big, because we don't know how big the user may want to stretch 280 287 # the window. This at least forces the sidebarframe to give the 3dview 281 # the maximum size available, which is perfect an initially closed288 # the maximum size available, which is perfect for an initially closed 282 289 # sidebar. 283 290 … … 407 414 408 415 checkbutton $inner.labels -text "Show labels on atoms" \ 409 -command [itcl::code $this emblems update] \410 -variable Rappture::MolvisViewer::_settings($this-emblems)\416 -command [itcl::code $this labels update] \ 417 -variable [itcl::scope _settings($this-showlabels)] \ 411 418 -font "Arial 9 bold" 412 419 checkbutton $inner.rock -text "Rock model back and forth" \ … … 676 683 677 684 # Turn on buffering of commands to the server. We don't want to 678 # be preempted by a server disconnect/reconnect ( whichautomatically685 # be preempted by a server disconnect/reconnect (that automatically 679 686 # generates a new call to Rebuild). 680 687 set _buffering 1 681 688 682 689 set dlist [get] 683 foreach dev $dlist { 684 set model [$dev get components.molecule.model] 685 set state [$dev get components.molecule.state] 686 690 foreach dataobj $dlist { 691 set model [$dataobj get components.molecule.model] 687 692 if {"" == $model } { 688 693 set model "molecule" 689 scan $d ev"::libraryObj%d" suffix694 scan $dataobj "::libraryObj%d" suffix 690 695 set model $model$suffix 691 696 } 692 693 if {"" == $state} { set state $_state(server) } 694 695 if { ![info exists _mlist($model)] } { # new, turn on 697 lappend _obj2models($dataobj) $model 698 set state [$dataobj get components.molecule.state] 699 if {"" == $state} { 700 set state $_state(server) 701 } 702 if { ![info exists _mlist($model)] } { # new, turn on 696 703 set _mlist($model) 2 697 } elseif { $_mlist($model) == 1 } { 704 } elseif { $_mlist($model) == 1 } { # on, leave on 698 705 set _mlist($model) 3 699 } elseif { $_mlist($model) == 0 } { 706 } elseif { $_mlist($model) == 0 } { # off, turn on 700 707 set _mlist($model) 2 701 708 } … … 704 711 set serial 1 705 712 706 foreach _atom [$d evchildren -type atom components.molecule] {707 set symbol [$d evget components.molecule.$_atom.symbol]708 set xyz [$d evget components.molecule.$_atom.xyz]713 foreach _atom [$dataobj children -type atom components.molecule] { 714 set symbol [$dataobj get components.molecule.$_atom.symbol] 715 set xyz [$dataobj get components.molecule.$_atom.xyz] 709 716 regsub {,} $xyz {} xyz 710 717 scan $xyz "%f %f %f" x y z … … 725 732 incr serial 726 733 } 727 set data2 [$dev get components.molecule.pdb]728 734 if {"" != $data1} { 729 735 set _pdbdata $data1 … … 732 738 } 733 739 # note that pdb files always overwrite xyz files 740 set data2 [$dataobj get components.molecule.pdb] 734 741 if {"" != $data2} { 735 742 set _pdbdata $data2 … … 739 746 } 740 747 if { ![info exists _model($model-transparency)] } { 741 set _model($model-transparency) " undefined"748 set _model($model-transparency) "" 742 749 } 743 750 if { ![info exists _model($model-representation)] } { 744 set _model($model-representation) " undefined"751 set _model($model-representation) "" 745 752 set _model($model-newrepresentation) $_mrepresentation 746 753 } 747 if { $_model($model-transparency) != $_dobj2transparency($dev) } { 748 set _model($model-newtransparency) $_dobj2transparency($dev) 754 if { $_model($model-transparency) != $_dobj2transparency($dataobj) } { 755 set _model($model-newtransparency) $_dobj2transparency($dataobj) 756 } 757 if { $_dobj2transparency($dataobj) == "ghost"} { 758 array unset _active $model 759 } else { 760 set _active($model) $dataobj 749 761 } 750 762 } … … 753 765 # 3=on->on) 754 766 755 foreach obj[array names _mlist] {756 if { $_mlist($ obj) == 1 } {757 SendCmd "disable -defer $ obj"758 set _mlist($ obj) 0767 foreach model [array names _mlist] { 768 if { $_mlist($model) == 1 } { 769 SendCmd "disable -defer $model" 770 set _mlist($model) 0 759 771 set changed 1 760 } elseif { $_mlist($obj) == 2 } { 761 set _mlist($obj) 1 762 SendCmd "enable -defer $obj" 772 } elseif { $_mlist($model) == 2 } { 773 set _mlist($model) 1 774 SendCmd "enable -defer $model" 775 if 0 { 763 776 if { $_labels } { 764 777 SendCmd "label -defer on" … … 766 779 SendCmd "label -defer off" 767 780 } 781 } 768 782 set changed 1 769 } elseif { $_mlist($ obj) == 3 } {770 set _mlist($ obj) 1771 } 772 773 if { $_mlist($ obj) == 1 } {774 if { [info exists _model($ obj-newtransparency)] ||775 [info exists _model($ obj-newrepresentation)] } {776 if { ![info exists _model($ obj-newrepresentation)] } {777 set _model($ obj-newrepresentation) $_model($obj-representation)783 } elseif { $_mlist($model) == 3 } { 784 set _mlist($model) 1 785 } 786 787 if { $_mlist($model) == 1 } { 788 if { [info exists _model($model-newtransparency)] || 789 [info exists _model($model-newrepresentation)] } { 790 if { ![info exists _model($model-newrepresentation)] } { 791 set _model($model-newrepresentation) $_model($model-representation) 778 792 } 779 if { ![info exists _model($ obj-newtransparency)] } {780 set _model($ obj-newtransparency) $_model($obj-transparency)793 if { ![info exists _model($model-newtransparency)] } { 794 set _model($model-newtransparency) $_model($model-transparency) 781 795 } 782 set rep $_model($obj-newrepresentation) 783 set transp $_model($obj-newtransparency) 784 SendCmd "$_model($obj-newrepresentation) -defer -model $obj -$_model($obj-newtransparency)" 796 set rep $_model($model-newrepresentation) 797 set transp $_model($model-newtransparency) 798 SendCmd "$_model($model-newrepresentation) -defer -model $model" 799 if { $_model($model-newtransparency) == "ghost" } { 800 SendCmd "deactivate -defer -model $model" 801 } else { 802 SendCmd "activate -defer -model $model" 803 } 785 804 set changed 1 786 set _model($ obj-transparency) $_model($obj-newtransparency)787 set _model($ obj-representation) $_model($obj-newrepresentation)805 set _model($model-transparency) $_model($model-newtransparency) 806 set _model($model-representation) $_model($model-newrepresentation) 788 807 catch { 789 unset _model($ obj-newtransparency)790 unset _model($ obj-newrepresentation)808 unset _model($model-newtransparency) 809 unset _model($model-newrepresentation) 791 810 } 792 811 } … … 822 841 debug "rebuild: rotate $_view(mx) $_view(my) $_view(mz)" 823 842 824 projection update 825 atomscale update 843 projection update 844 atomscale update 826 845 bondthickness update 827 emblems update 828 representation update 846 labels update 847 representation update 848 opacity update 829 849 830 850 $itk_component(3dview) configure -cursor "" … … 955 975 unset _rocker(afterid) 956 976 } 957 958 if { $option == "toggle" } { 959 if { $_rocker(on) } { 960 set option "off" 961 } else { 962 set option "on" 963 } 964 } 965 if { $option == "on" || ($option == "toggle" && !$_rocker(on)) } { 966 set _rocker(on) 1 967 set _settings($this-rock) 1 968 $itk_component(rock) configure -relief sunken 969 } elseif { $option == "off" || ($option == "toggle" && $_rocker(on)) } { 970 set _rocker(on) 0 971 set _settings($this-rock) 0 972 $itk_component(rock) configure -relief raised 973 } elseif { $option == "step"} { 977 set _rocker(on) $_settings($this-rock) 978 if { $option == "step"} { 974 979 if { $_rocker(client) >= 10 } { 975 980 set _rocker(dir) -1 … … 1216 1221 } 1217 1222 1218 foreach obj$models {1219 if { [info exists _model($ obj-representation)] } {1220 if { $_model($ obj-representation) != $option } {1221 set _model($ obj-newrepresentation) $option1223 foreach model $models { 1224 if { [info exists _model($model-representation)] } { 1225 if { $_model($model-representation) != $option } { 1226 set _model($model-newrepresentation) $option 1222 1227 } else { 1223 catch { unset _model($ obj-newrepresentation) }1228 catch { unset _model($model-newrepresentation) } 1224 1229 } 1225 1230 } … … 1231 1236 } 1232 1237 1233 # ----------------------------------------------------------------------1234 # USAGE: emblems on|off|toggle1235 # USAGE: emblems update1236 #1237 # Used internally to turn labels associated with atoms on/off, and to1238 # update the positions of the labels so they sit on top of each atom.1239 # ----------------------------------------------------------------------1240 itcl::body Rappture::MolvisViewer::emblems {option} {1241 switch -- $option {1242 on {1243 set emblem 11244 }1245 off {1246 set emblem 01247 }1248 toggle {1249 if {$_settings($this-emblems)} {1250 set emblem 01251 } else {1252 set emblem 11253 }1254 }1255 update {1256 set emblem $_settings($this-emblems)1257 }1258 default {1259 error "bad option \"$option\": should be on, off, toggle, or update"1260 }1261 }1262 set _labels $emblem1263 if {$emblem == $_settings($this-emblems) && $option != "update"} {1264 # nothing to do1265 return1266 }1267 1268 if {$emblem} {1269 $itk_component(labels) configure -relief sunken1270 set _settings($this-emblems) 11271 SendCmd "label on"1272 } else {1273 $itk_component(labels) configure -relief raised1274 set _settings($this-emblems) 01275 SendCmd "label off"1276 }1277 }1278 1238 1279 1239 # ---------------------------------------------------------------------- … … 1307 1267 } 1308 1268 if { $ortho } { 1309 $itk_component(ortho) configure -image [Rappture::icon 3dorth]1269 $itk_component(ortho) configure -image [Rappture::icon molvis-3dorth] 1310 1270 Rappture::Tooltip::for $itk_component(ortho) \ 1311 " Change toperspective projection"1271 "Use perspective projection" 1312 1272 set _settings($this-ortho) 1 1313 1273 SendCmd "orthoscopic on" 1314 1274 } else { 1315 $itk_component(ortho) configure -image [Rappture::icon 3dpers]1275 $itk_component(ortho) configure -image [Rappture::icon molvis-3dpers] 1316 1276 Rappture::Tooltip::for $itk_component(ortho) \ 1317 " Change toorthoscopic projection"1277 "Use orthoscopic projection" 1318 1278 set _settings($this-ortho) 0 1319 1279 SendCmd "orthoscopic off" … … 1321 1281 } 1322 1282 1323 # ----------------------------------------------------------------------1324 # USAGE: atomscale scale ?model?1325 # atomscale update1326 #1327 # Used internally to change the molecular atom scale used to render1328 # our scene.1329 # ----------------------------------------------------------------------1330 1331 itcl::body Rappture::MolvisViewer::atomscale { option {model "all"} } {1332 if { $option == "update" } {1333 set scale $_settings($this-atomscale)1334 } elseif { [string is double $option] } {1335 set scale $option1336 if { ($scale < 0.1) || ($scale > 2.0) } {1337 error "bad atom size \"$scale\""1338 }1339 } else {1340 error "bad option \"$option\""1341 }1342 set _settings($this-atomscale) $scale1343 if { [isconnected] } {1344 SendCmd "atomscale -model $model $scale"1345 }1346 }1347 1348 # ----------------------------------------------------------------------1349 # USAGE: bondthickness scale ?model?1350 # bondthickness update1351 #1352 # Used internally to change the molecular bond thickness used to render1353 # our scene.1354 # ----------------------------------------------------------------------1355 1356 itcl::body Rappture::MolvisViewer::bondthickness { option {model "all"} } {1357 if { $option == "update" } {1358 set scale $_settings($this-bondthickness)1359 } elseif { [string is double $option] } {1360 set scale $option1361 if { ($scale < 0.1) || ($scale > 2.0) } {1362 error "bad bind thickness \"$scale\""1363 }1364 } else {1365 error "bad option \"$option\""1366 }1367 set _settings($this-bondthickness) $scale1368 if { [isconnected] } {1369 SendCmd "bondthickness -model $model $scale"1370 }1371 }1372 1283 1373 1284 # ---------------------------------------------------------------------- … … 1404 1315 } 1405 1316 1406 if { $_labels == "default" } { 1407 set emblem [$dataobj get components.molecule.about.emblems] 1408 1409 if {$emblem == "" || ![string is boolean $emblem] || !$emblem} { 1410 emblems off 1411 } else { 1412 emblems on 1413 } 1317 if { !$_settings($this-showlabels-initialized) } { 1318 set showlabels [$dataobj get components.molecule.about.emblems] 1319 if { $showlabels != "" && [string is boolean $showlabels] } { 1320 set _settings($this-showlabels) $showlabels 1321 } 1414 1322 } 1415 1323 … … 1491 1399 if {$pos >= 0} { 1492 1400 set _dlist [lreplace $_dlist $pos $pos] 1493 catch {unset _dobj2transparency($dataobj)} 1494 catch {unset _dobj2color($dataobj)} 1495 catch {unset _dobj2width($dataobj)} 1496 catch {unset _dobj2dashes($dataobj)} 1497 catch {unset _dobj2raise($dataobj)} 1401 foreach model $_obj2models($dataobj) { 1402 array unset _active $model 1403 } 1404 array unset _obj2models $dataobj 1405 array unset _dobj2transparency $dataobj 1406 array unset _dobj2color $dataobj 1407 array unset _dobj2width $dataobj 1408 array unset _dobj2dashes $dataobj 1409 array unset _dobj2raise $dataobj 1498 1410 set changed 1 1499 1411 } … … 1609 1521 return "" 1610 1522 } 1523 1524 # ---------------------------------------------------------------------- 1525 # USAGE: atomscale radius ?model? 1526 # atomscale update ?model? 1527 # 1528 # Used internally to change the molecular atom scale used to render 1529 # our scene. 1530 # 1531 # Note: Only sets the specified radius for active models. If the model 1532 # is inactive, then it overridden with the value "0.1". 1533 # ---------------------------------------------------------------------- 1534 1535 itcl::body Rappture::MolvisViewer::atomscale { option {models "all"} } { 1536 if { $option == "update" } { 1537 set radius $_settings($this-atomscale) 1538 } elseif { [string is double $option] } { 1539 set radius $option 1540 if { ($radius < 0.1) || ($radius > 2.0) } { 1541 error "bad atom size \"$radius\"" 1542 } 1543 } else { 1544 error "bad option \"$option\"" 1545 } 1546 set _settings($this-atomscale) $radius 1547 if { $models == "all" } { 1548 set models [array names _mlist] 1549 } 1550 set overrideradius [expr $radius * 0.8] 1551 foreach model $models { 1552 if { [info exists _active($model)] } { 1553 SendCmd "atomscale -model $model $radius" 1554 } else { 1555 SendCmd "atomscale -model $model $overrideradius" 1556 } 1557 } 1558 } 1559 1560 # ---------------------------------------------------------------------- 1561 # USAGE: bondthickness thickness ?models? 1562 # bondthickness update ?models? 1563 # 1564 # Used internally to change the molecular bond thickness used to render 1565 # our scene. 1566 # 1567 # Note: Only sets the specified thickness for active models. If the model 1568 # is inactive, then it overridden with the value "0.25". 1569 # ---------------------------------------------------------------------- 1570 1571 itcl::body Rappture::MolvisViewer::bondthickness { option {models "all"} } { 1572 if { $option == "update" } { 1573 set thickness $_settings($this-bondthickness) 1574 } elseif { [string is double $option] } { 1575 set thickness $option 1576 if { ($thickness < 0.1) || ($thickness > 2.0) } { 1577 error "bad bind thickness \"$thickness\"" 1578 } 1579 } else { 1580 error "bad option \"$option\"" 1581 } 1582 set _settings($this-bondthickness) $thickness 1583 if { $models == "all" } { 1584 set models [array names _mlist] 1585 } 1586 set overridethickness [expr $thickness * 0.8] 1587 foreach model $models { 1588 if { [info exists _active($model)] } { 1589 SendCmd "bondthickness -model $model $thickness" 1590 } else { 1591 SendCmd "bondthickness -model $model $overridethickness" 1592 } 1593 } 1594 } 1595 1596 # ---------------------------------------------------------------------- 1597 # USAGE: opacity value ?models? 1598 # opacity update ?models? 1599 # 1600 # Used internally to change the molecular bond thickness used to render 1601 # our scene. 1602 # 1603 # Note: Only sets the specified thickness for active models. If the model 1604 # is inactive, then it overridden with the value "0.75". 1605 # ---------------------------------------------------------------------- 1606 1607 itcl::body Rappture::MolvisViewer::opacity { option {models "all"} } { 1608 if { $option == "update" } { 1609 set opacity $_settings($this-opacity) 1610 } elseif { [string is double $option] } { 1611 set opacity $option 1612 if { ($opacity < 0.0) || ($opacity > 1.0) } { 1613 error "bad opacity \"$opacity\"" 1614 } 1615 } else { 1616 error "bad option \"$option\"" 1617 } 1618 set _settings($this-opacity) $opacity 1619 if { $models == "all" } { 1620 set models [array names _mlist] 1621 } 1622 set overridetransparency 0.60 1623 set transparency [expr 1.0 - $opacity] 1624 foreach model $models { 1625 if { [info exists _active($model)] } { 1626 SendCmd "transparency -model $model $transparency" 1627 } else { 1628 SendCmd "transparency -model $model $overridetransparency" 1629 } 1630 } 1631 } 1632 1633 # ---------------------------------------------------------------------- 1634 # USAGE: labels on|off|toggle 1635 # USAGE: labels update 1636 # 1637 # Used internally to turn labels associated with atoms on/off, and to 1638 # update the positions of the labels so they sit on top of each atom. 1639 # ---------------------------------------------------------------------- 1640 itcl::body Rappture::MolvisViewer::labels {option {models "all"}} { 1641 set showlabels $_settings($this-showlabels) 1642 if { $option == "update" } { 1643 set showlabels $_settings($this-showlabels) 1644 } elseif { [string is boolean $option] } { 1645 set showlabels $option 1646 } else { 1647 error "bad option \"$option\"" 1648 } 1649 set _settings($this-showlabels) $showlabels 1650 if { $models == "all" } { 1651 set models [array names _mlist] 1652 } 1653 set overrideshowlabels "off" 1654 foreach model $models { 1655 if { [info exists _active($model)] } { 1656 SendCmd "label -model $model $showlabels" 1657 } else { 1658 SendCmd "label -model $model $overrideshowlabels" 1659 } 1660 } 1661 } -
trunk/gui/scripts/nanovisviewer.tcl
r1514 r1531 1814 1814 itk_component add xCutButton { 1815 1815 Rappture::PushButton $inner.xbutton \ 1816 -onimage [Rappture::icon x-cutplane -on] \1817 -offimage [Rappture::icon x-cutplane -off] \1816 -onimage [Rappture::icon x-cutplane] \ 1817 -offimage [Rappture::icon x-cutplane] \ 1818 1818 -command [itcl::code $this FixSettings xcutplane] \ 1819 1819 -variable [itcl::scope _settings($this-xcutplane)] … … 1841 1841 itk_component add yCutButton { 1842 1842 Rappture::PushButton $inner.ybutton \ 1843 -onimage [Rappture::icon y-cutplane -on] \1844 -offimage [Rappture::icon y-cutplane -off] \1843 -onimage [Rappture::icon y-cutplane] \ 1844 -offimage [Rappture::icon y-cutplane] \ 1845 1845 -command [itcl::code $this FixSettings ycutplane] \ 1846 1846 -variable [itcl::scope _settings($this-ycutplane)] … … 1868 1868 itk_component add zCutButton { 1869 1869 Rappture::PushButton $inner.zbutton \ 1870 -onimage [Rappture::icon z-cutplane -on] \1871 -offimage [Rappture::icon z-cutplane -off] \1870 -onimage [Rappture::icon z-cutplane] \ 1871 -offimage [Rappture::icon z-cutplane] \ 1872 1872 -command [itcl::code $this FixSettings zcutplane] \ 1873 1873 -variable [itcl::scope _settings($this-zcutplane)] -
trunk/gui/scripts/pushbutton.tcl
r1491 r1531 14 14 package require Itk 15 15 16 option add *PushButton.width 16 widgetDefault 17 option add *PushButton.height 16 widgetDefault 18 16 19 itcl::class Rappture::PushButton { 17 20 inherit itk::Widget … … 19 22 itk_option define -variable variable Variable "normal" 20 23 itk_option define -command command Command "normal" 24 itk_option define -width width Width "normal" 25 itk_option define -height height Height "normal" 21 26 22 27 constructor {args} { # defined below } … … 100 105 } 101 106 102 103 107 itcl::body Rappture::PushButton::select {} { 104 108 upvar #0 $_variable state … … 132 136 } 133 137 } 138 139 # ---------------------------------------------------------------------- 140 # CONFIGURE: -width 141 # ---------------------------------------------------------------------- 142 itcl::configbody Rappture::PushButton::width { 143 $itk_component(button) configure -width $itk_option(-width) 144 } 145 146 # ---------------------------------------------------------------------- 147 # CONFIGURE: -height 148 # ---------------------------------------------------------------------- 149 itcl::configbody Rappture::PushButton::height { 150 set _height $itk_option(-height) 151 $itk_component(button) configure -height $itk_option(-height) 152 }
Note: See TracChangeset
for help on using the changeset viewer.