Changeset 1531 for trunk


Ignore:
Timestamp:
Jun 26, 2009, 1:16:20 PM (15 years ago)
Author:
gah
Message:

fixed bug when displaying ALL in molvisviewer

Location:
trunk/gui/scripts
Files:
9 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/field2dresult.tcl

    r1463 r1531  
    6060            "auto" - "heightmap" {
    6161                itk_component add renderer {
    62                     Rappture::HeightmapViewer $itk_interior.ren $servers
     62                    Rappture::HeightmapViewer $itk_interior.ren $servers 
    6363                }
    6464            }
  • trunk/gui/scripts/flowvisviewer.tcl

    r1514 r1531  
    22592259    itk_component add xCutButton {
    22602260        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] \
    22632263            -command [itcl::code $this FixSettings xcutplane] \
    22642264            -variable [itcl::scope _settings($this-xcutplane)]
     
    22862286    itk_component add yCutButton {
    22872287        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] \
    22902290            -command [itcl::code $this FixSettings ycutplane] \
    22912291            -variable [itcl::scope _settings($this-ycutplane)]
     
    23132313    itk_component add zCutButton {
    23142314        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] \
    23172317            -command [itcl::code $this FixSettings zcutplane] \
    23182318            -variable [itcl::scope _settings($this-zcutplane)]
     
    29722972    return 1
    29732973}
     2974
  • trunk/gui/scripts/heightmapviewer.tcl

    r1496 r1531  
    2424option add *HeightmapViewer.plotForeground white widgetDefault
    2525option add *HeightmapViewer.plotOutline white widgetDefault
    26 option add *HeightmapViewer.font \
    27     -*-helvetica-medium-r-normal-*-12-* widgetDefault
     26option add *HeightmapViewer.font -*-helvetica-medium-r-normal-*-12-* widgetDefault
    2827
    2928# must use this name -- plugs into Rappture::resources::load
     
    660659        if {"" == [$c find withtag transfunc]} {
    661660            $c create image 0 [expr $lineht] -anchor ne \
    662                  -image $_image(legend) -tags transfunc
     661                 -image $_image(legend) -tags transfunc 
    663662            $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"
    665665            $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"
    667668        }
    668669        $c coords transfunc [expr $w - 5] [expr $lineht]
     
    10371038        set style(-color) "white:yellow:green:cyan:blue:magenta"
    10381039    }
    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    }
    10501054    set opacity $style(-opacity)
    10511055    set levels $style(-levels)
  • trunk/gui/scripts/molvisviewer.tcl

    r1483 r1531  
    6262    public method parameters {title args} { # do nothing }
    6363
    64     public method emblems {option}
     64    public method labels {option {model "all"}}
    6565    public method projection {option}
    6666    public method rock {option}
    6767    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"} }
    7071    public method ResetView {}
    7172
     
    9394    private variable _dobj2transparency;# maps dataobj => transparency
    9495    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.
    96100
    97101    private variable _view
     
    166170        phi     45
    167171        psi     0
    168         vx 0
    169         vy 0
    170         vz 0
    171         zoom 0
    172         mx 0
    173         my 0
    174         mz 0
    175         x  0
    176         y  0
    177         z  0
    178         width 0
    179         height 0
     172        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
    180184    }
    181185
     
    184188        $this-model     ballnstick
    185189        $this-modelimg  [Rappture::icon ballnstick]
    186         $this-emblems   no
     190        $this-showlabels-initialized no
     191        $this-showlabels no
    187192        $this-rock      no
    188193        $this-ortho     no
    189194        $this-atomscale 0.25
    190         $this-bondthickness 0.15
     195        $this-bondthickness 0.14
     196        $this-opacity   1.0
    191197    }]
    192 
     198   
    193199    #
    194200    # Set up the widgets in the main body
     
    233239
    234240    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
    239248    Rappture::Tooltip::for $itk_component(labels) \
    240249        "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}
    243251
    244252    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
    249260    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 
    254261
    255262    itk_component add ortho {
    256263        label $f.ortho -borderwidth 1 -padx 1 -pady 1 \
    257             -relief "raised" -image [Rappture::icon 3dpers]
     264            -relief "raised" -image [Rappture::icon molvis-3dpers]
    258265    }
    259266    pack $itk_component(ortho) -padx 2 -pady 2 -ipadx 1 -ipady 1
    260267    Rappture::Tooltip::for $itk_component(ortho) \
    261         "Change to orthoscopic projection"
     268        "Use orthoscopic projection"
    262269
    263270    bind $itk_component(ortho) <ButtonPress> \
     
    275282    # have already kicked in.  We end up with a 1x1 viewport and image.
    276283
    277     # So the idea is to set a ridiculously big requested width to the label
     284    # So the idea is to force a ridiculously big requested width on the label
    278285    # (that's why we're using the blt::table to manage the geometry).  It has
    279286    # to be big, because we don't know how big the user may want to stretch
    280287    # the window.  This at least forces the sidebarframe to give the 3dview
    281     # the maximum size available, which is perfect an initially closed
     288    # the maximum size available, which is perfect for an initially closed
    282289    # sidebar.
    283290
     
    407414
    408415    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)] \
    411418        -font "Arial 9 bold"
    412419    checkbutton $inner.rock -text "Rock model back and forth" \
     
    676683
    677684    # Turn on buffering of commands to the server.  We don't want to
    678     # be preempted by a server disconnect/reconnect (which automatically
     685    # be preempted by a server disconnect/reconnect (that automatically
    679686    # generates a new call to Rebuild).   
    680687    set _buffering 1
    681688
    682689    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]
    687692        if {"" == $model } {
    688693            set model "molecule"
    689             scan $dev "::libraryObj%d" suffix
     694            scan $dataobj "::libraryObj%d" suffix
    690695            set model $model$suffix
    691696        }
    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
    696703            set _mlist($model) 2
    697         } elseif { $_mlist($model) == 1 } { # on, leave on
     704        } elseif { $_mlist($model) == 1 } {     # on, leave on
    698705            set _mlist($model) 3
    699         } elseif { $_mlist($model) == 0 } { # off, turn on
     706        } elseif { $_mlist($model) == 0 } {     # off, turn on
    700707            set _mlist($model) 2
    701708        }
     
    704711            set serial    1
    705712
    706             foreach _atom [$dev children -type atom components.molecule] {
    707                 set symbol [$dev get components.molecule.$_atom.symbol]
    708                 set xyz [$dev get 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]
    709716                regsub {,} $xyz {} xyz
    710717                scan $xyz "%f %f %f" x y z
     
    725732                incr serial
    726733            }
    727             set data2 [$dev get components.molecule.pdb]
    728734            if {"" != $data1} {
    729735                set _pdbdata $data1
     
    732738            }
    733739            # note that pdb files always overwrite xyz files
     740            set data2 [$dataobj get components.molecule.pdb]
    734741            if {"" != $data2} {
    735742                set _pdbdata $data2
     
    739746        }
    740747        if { ![info exists _model($model-transparency)] } {
    741             set _model($model-transparency) "undefined"
     748            set _model($model-transparency) ""
    742749        }
    743750        if { ![info exists _model($model-representation)] } {
    744             set _model($model-representation) "undefined"
     751            set _model($model-representation) ""
    745752            set _model($model-newrepresentation) $_mrepresentation
    746753        }
    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
    749761        }
    750762    }
     
    753765    # 3=on->on)
    754766
    755     foreach obj [array names _mlist] {
    756         if { $_mlist($obj) == 1 } {
    757             SendCmd "disable -defer $obj"
    758             set _mlist($obj) 0
     767    foreach model [array names _mlist] {
     768        if { $_mlist($model) == 1 } {
     769            SendCmd "disable -defer $model"
     770            set _mlist($model) 0
    759771            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 {
    763776            if { $_labels } {
    764777                SendCmd "label -defer on"
     
    766779                SendCmd "label -defer off"
    767780            }
     781            }
    768782            set changed 1
    769         } elseif { $_mlist($obj) == 3 } {
    770             set _mlist($obj) 1
    771         }
    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)
    778792                }
    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)
    781795                }
    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                }
    785804                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)
    788807                catch {
    789                     unset _model($obj-newtransparency)
    790                     unset _model($obj-newrepresentation)
     808                    unset _model($model-newtransparency)
     809                    unset _model($model-newrepresentation)
    791810                }
    792811            }
     
    822841    debug "rebuild: rotate $_view(mx) $_view(my) $_view(mz)"
    823842
    824     projection update
    825     atomscale update
     843    projection update 
     844    atomscale update 
    826845    bondthickness update
    827     emblems update
    828     representation update
     846    labels update
     847    representation update
     848    opacity update
    829849
    830850    $itk_component(3dview) configure -cursor ""
     
    955975        unset _rocker(afterid)
    956976    }
    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"} {
    974979        if { $_rocker(client) >= 10 } {
    975980            set _rocker(dir) -1
     
    12161221    }
    12171222
    1218     foreach obj $models {
    1219         if { [info exists _model($obj-representation)] } {
    1220             if { $_model($obj-representation) != $option } {
    1221                 set _model($obj-newrepresentation) $option
     1223    foreach model $models {
     1224        if { [info exists _model($model-representation)] } {
     1225            if { $_model($model-representation) != $option } {
     1226                set _model($model-newrepresentation) $option
    12221227            } else {
    1223                 catch { unset _model($obj-newrepresentation) }
     1228                catch { unset _model($model-newrepresentation) }
    12241229            }
    12251230        }
     
    12311236}
    12321237
    1233 # ----------------------------------------------------------------------
    1234 # USAGE: emblems on|off|toggle
    1235 # USAGE: emblems update
    1236 #
    1237 # Used internally to turn labels associated with atoms on/off, and to
    1238 # 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 1
    1244         }
    1245         off {
    1246             set emblem 0
    1247         }
    1248         toggle {
    1249             if {$_settings($this-emblems)} {
    1250                 set emblem 0
    1251             } else {
    1252                 set emblem 1
    1253             }
    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 $emblem
    1263     if {$emblem == $_settings($this-emblems) && $option != "update"} {
    1264         # nothing to do
    1265         return
    1266     }
    1267 
    1268     if {$emblem} {
    1269         $itk_component(labels) configure -relief sunken
    1270         set _settings($this-emblems) 1
    1271         SendCmd "label on"
    1272     } else {
    1273         $itk_component(labels) configure -relief raised
    1274         set _settings($this-emblems) 0
    1275         SendCmd "label off"
    1276     }
    1277 }
    12781238
    12791239# ----------------------------------------------------------------------
     
    13071267    }
    13081268    if { $ortho } {
    1309         $itk_component(ortho) configure -image [Rappture::icon 3dorth]
     1269        $itk_component(ortho) configure -image [Rappture::icon molvis-3dorth]
    13101270        Rappture::Tooltip::for $itk_component(ortho) \
    1311             "Change to perspective projection"
     1271            "Use perspective projection"
    13121272        set _settings($this-ortho) 1
    13131273        SendCmd "orthoscopic on"
    13141274    } else {
    1315         $itk_component(ortho) configure -image [Rappture::icon 3dpers]
     1275        $itk_component(ortho) configure -image [Rappture::icon molvis-3dpers]
    13161276        Rappture::Tooltip::for $itk_component(ortho) \
    1317             "Change to orthoscopic projection"
     1277            "Use orthoscopic projection"
    13181278        set _settings($this-ortho) 0
    13191279        SendCmd "orthoscopic off"
     
    13211281}
    13221282
    1323 # ----------------------------------------------------------------------
    1324 # USAGE: atomscale scale ?model?
    1325 #        atomscale update
    1326 #
    1327 # Used internally to change the molecular atom scale used to render
    1328 # 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 $option
    1336         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) $scale
    1343     if { [isconnected] } {
    1344         SendCmd "atomscale -model $model $scale"
    1345     }
    1346 }
    1347 
    1348 # ----------------------------------------------------------------------
    1349 # USAGE: bondthickness scale ?model?
    1350 #        bondthickness update
    1351 #
    1352 # Used internally to change the molecular bond thickness used to render
    1353 # 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 $option
    1361         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) $scale
    1368     if { [isconnected] } {
    1369         SendCmd "bondthickness -model $model $scale"
    1370     }
    1371 }
    13721283
    13731284# ----------------------------------------------------------------------
     
    14041315        }
    14051316
    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            }
    14141322        }
    14151323
     
    14911399        if {$pos >= 0} {
    14921400            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
    14981410            set changed 1
    14991411        }
     
    16091521    return ""
    16101522}
     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
     1535itcl::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
     1571itcl::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
     1607itcl::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# ----------------------------------------------------------------------
     1640itcl::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  
    18141814    itk_component add xCutButton {
    18151815        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] \
    18181818            -command [itcl::code $this FixSettings xcutplane] \
    18191819            -variable [itcl::scope _settings($this-xcutplane)]
     
    18411841    itk_component add yCutButton {
    18421842        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] \
    18451845            -command [itcl::code $this FixSettings ycutplane] \
    18461846            -variable [itcl::scope _settings($this-ycutplane)]
     
    18681868    itk_component add zCutButton {
    18691869        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] \
    18721872            -command [itcl::code $this FixSettings zcutplane] \
    18731873            -variable [itcl::scope _settings($this-zcutplane)]
  • trunk/gui/scripts/pushbutton.tcl

    r1491 r1531  
    1414package require Itk
    1515
     16option add *PushButton.width 16 widgetDefault
     17option add *PushButton.height 16 widgetDefault
     18
    1619itcl::class Rappture::PushButton {
    1720    inherit itk::Widget
     
    1922    itk_option define -variable variable Variable "normal"
    2023    itk_option define -command command Command "normal"
     24    itk_option define -width width Width "normal"
     25    itk_option define -height height Height "normal"
    2126
    2227    constructor {args} { # defined below }
     
    100105}
    101106
    102 
    103107itcl::body Rappture::PushButton::select {} {
    104108    upvar #0 $_variable state
     
    132136    }
    133137}
     138
     139# ----------------------------------------------------------------------
     140# CONFIGURE: -width
     141# ----------------------------------------------------------------------
     142itcl::configbody Rappture::PushButton::width {
     143    $itk_component(button) configure -width $itk_option(-width)
     144}
     145
     146# ----------------------------------------------------------------------
     147# CONFIGURE: -height
     148# ----------------------------------------------------------------------
     149itcl::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.