Changeset 1550 for trunk/gui


Ignore:
Timestamp:
Jul 17, 2009 2:50:11 PM (15 years ago)
Author:
gah
Message:
 
Location:
trunk/gui/scripts
Files:
5 edited

Legend:

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

    r1549 r1550  
     1
    12# ----------------------------------------------------------------------
    23#  COMPONENT: barresult - X/Y plot in a ResultSet
     
    8384    public method delete {args}
    8485    public method scale {args}
    85     public method parameters {title args} { # do nothing }
     86    public method parameters {title args} {
     87        # do nothing
     88    }
    8689    public method download {option args}
    8790
     
    9699    protected method _enterMarker { g name x y text }
    97100    protected method _leaveMarker { g name }
     101    private method _formatTickLabel { w value }
    98102
    99103    private variable _dispatcher "" ;# dispatcher for !events
     
    116120    private variable cur_ ""
    117121    private variable initialized_ 0
     122    private variable _tickLabels
    118123}
    119124                                                                               
     
    164169        blt::barchart $f.plot \
    165170            -highlightthickness 0 -plotpadx 0 -plotpady 0 \
    166             -rightmargin 10
     171            -barmode aligned -rightmargin 1
    167172    } {
    168173        keep -background -foreground -cursor -font
     
    170175    pack $itk_component(plot) -expand yes -fill both
    171176
    172     $itk_component(plot) pen configure activeLine \
    173         -symbol square -pixels 3 -linewidth 2 \
    174         -outline black -fill red -color black
    175 
    176     #
     177    $itk_component(plot) pen configure activeBar \
     178        -borderwidth 2 -foreground black -background red
     179
    177180    # Add bindings so you can mouse over points to see values:
    178     #
    179181    bind $itk_component(plot) <Motion> \
    180182        [itcl::code $this _hilite at %x %y]
     
    182184        [itcl::code $this _hilite off %x %y]
    183185
    184     #
    185186    # Add support for editing axes:
    186     #
    187187    Rappture::Balloon $itk_component(hull).axes -title "Axis Options"
    188188    set inner [$itk_component(hull).axes component inner]
     
    281281        -brightness 0
    282282        -width 1
    283         -type "line"
     283        -type "bar"
    284284        -raise 0
    285285        -linestyle solid
     
    292292        }
    293293        set params($opt) $val
    294     }
    295 
    296     # if type is set to "scatter", then override the width
    297     if {"scatter" == $params(-type)} {
    298         set params(-width) 0
    299294    }
    300295
     
    618613    eval $g element delete [$g element names]
    619614    foreach axis [$g axis names] {
    620         $g axis configure $axis -hide yes -checklimits no
     615        $g axis configure $axis -hide yes -checklimits no -loose yes
    621616    }
    622617    # Presumably you want at least an X-axis and Y-axis displayed.
    623618    $g xaxis configure -hide no
    624619    $g yaxis configure -hide no
    625     catch {unset _label2axis}
     620    array unset _label2axis
    626621
    627622    #
     
    737732            set elem "elem[incr count]"
    738733            set _elem2curve($elem) $xydata
    739 
    740             $g element create $elem -x $xv -y $yv \
    741                 -symbol $sym -pixels $pixels -linewidth $lwidth -label $label \
    742                 -color $color -dashes $dashes \
    743                 -mapx $mapx -mapy $mapy
    744         }
     734            set labels [$xydata hints xticks]
     735            if { $labels != "" } {
     736                $g axis configure $mapx \
     737                    -command [itcl::code $this _formatTickLabel] \
     738                    -minorticks 0
     739                set _tickLabels $labels
     740            }
     741            $g element create $elem -x $xv -y $yv \
     742                -borderwidth $lwidth -label $label \
     743                -background $color -foreground $color -mapx $mapx -mapy $mapy
     744        }
    745745    }
    746746
     
    805805itcl::body Rappture::BarResult::_resetLimits {} {
    806806    set g $itk_component(plot)
     807    foreach axis [$g axis names] {
     808        $g axis configure $axis -min "" -max ""
     809    }
     810    return
    807811
    808812    #
     
    990994            Rappture::Tooltip::tooltip cancel
    991995        }
     996        set bg [$g element cget $elem -background]
     997        set fg [$g element cget $elem -background]
     998        foreach {h s v} [Rappture::color::RGBtoHSV $fg] break
     999        if { $v > 0.2 } {
     1000            set v [expr $v - 0.2]
     1001        }
     1002        set fg [Rappture::color::HSVtoRGB $h $s $v]
     1003        $g pen configure activeBar -background $bg -foreground $fg
    9921004        $g element activate $elem
    9931005        set _hilite(elem) $elem
     
    14751487itcl::body Rappture::BarResult::_getLineMarkerOptions {style} {
    14761488    array set lineOptions {
    1477         "-color"  "-outline"
     1489        "-color"  "-color"
    14781490        "-dashes" "-dashes"
    1479         "-linecolor" "-outline"
    1480         "-linewidth" "-linewidth"
     1491        "-linecolor" "-foreground"
     1492        "-linewidth" "-borderwidth"
    14811493    }
    14821494    set options {}
     
    15901602    }
    15911603}
     1604
     1605itcl::body Rappture::BarResult::_formatTickLabel { w value } {
     1606    # Determine the element name from the value
     1607
     1608    set index [expr round($value)]
     1609    if { $index != $value } {
     1610        return $value
     1611    }
     1612    return [lindex  $_tickLabels [expr $index - 1]]
     1613    if { $label == "" } {
     1614        return $value
     1615    }
     1616    return $label
     1617}
  • trunk/gui/scripts/curve.tcl

    r1549 r1550  
    220220            yticks  yaxis.ticklabels
    221221            yunits  yaxis.units
    222             bars    xaxis.bars
    223222        } {
    224223            set str [$_curve get $path]
  • trunk/gui/scripts/histogram.tcl

    r1342 r1550  
    1 
     1 
    22# ----------------------------------------------------------------------
    33#  COMPONENT: histogram - extracts data from an XML description of a field
  • trunk/gui/scripts/molvisviewer.tcl

    r1547 r1550  
    7474    public method ResetView {}
    7575    public method add {dataobj {options ""}}
    76     public method atomscale {option {models "all"} }
    77     public method bondthickness {option {models "all"} }
     76    public method spherescale {option {models "all"} }
     77    public method stickradius {option {models "all"} }
    7878    public method delete {args}
    7979    public method download {option args}
     
    8181    public method isconnected {}
    8282    public method labels {option {model "all"}}
     83    public method cartoon {option {model "all"}}
     84    public method cartoontrace {option {model "all"}}
    8385    public method opacity {option {models "all"} }
    8486    public method parameters {title args} {
     
    196198    # Setup default settings for widget.
    197199    array set _settings [subst {
     200        $this-spherescale 0.25
     201        $this-stickradius 0.14
     202        $this-cartoon   no
     203        $this-cartoontrace no
    198204        $this-model     ballnstick
    199205        $this-modelimg  [Rappture::icon ballnstick]
     206        $this-opacity   1.0
     207        $this-ortho     no
     208        $this-rock      no
     209        $this-showlabels no
    200210        $this-showlabels-initialized no
    201         $this-showlabels no
    202         $this-rock      no
    203         $this-ortho     no
    204         $this-atomscale 0.25
    205         $this-bondthickness 0.14
    206         $this-opacity   1.0
    207211    }]
    208212   
     
    398402    $inner configure -borderwidth 4
    399403
    400     label $inner.drawinglabel -text "Drawing Method" -font "Arial 9 bold"
     404    label $inner.drawinglabel -text "Molecule Reprsentation" \
     405        -font "Arial 9 bold"
    401406
    402407    label $inner.pict -image $_settings($this-modelimg)
     408
    403409    radiobutton $inner.bstick -text "balls and sticks" \
    404410        -command [itcl::code $this representation ballnstick all] \
    405411        -variable Rappture::MolvisViewer::_settings($this-model) \
    406412        -value ballnstick -font "Arial 9" -pady 0
     413    Rappture::Tooltip::for $inner.bstick \
     414        "Display atoms (balls) and connections (sticks) "
     415
    407416    radiobutton $inner.spheres -text "spheres" \
    408417        -command [itcl::code $this representation spheres all] \
    409418        -variable Rappture::MolvisViewer::_settings($this-model) \
    410419        -value spheres -font "Arial 9" -pady 0
     420    Rappture::Tooltip::for $inner.spheres \
     421        "Display atoms as spheres. Do not display bonds."
     422
     423    radiobutton $inner.sticks -text "sticks" \
     424        -command [itcl::code $this representation sticks all] \
     425        -variable Rappture::MolvisViewer::_settings($this-model) \
     426        -value sticks -font "Arial 9" -pady 0
     427    Rappture::Tooltip::for $inner.sticks \
     428        "Display bonds as sticks. Do not display atoms."
     429
    411430    radiobutton $inner.lines -text "lines" \
    412431        -command [itcl::code $this representation lines all] \
    413432        -variable Rappture::MolvisViewer::_settings($this-model) \
    414433        -value lines -font "Arial 9" -pady 0
    415 
    416     scale $inner.atomscale -width 10 -font "Arial 9 bold" \
    417         -from 0.1 -to 2.0 -resolution 0.05 -label "Atom Scale" \
     434    Rappture::Tooltip::for $inner.lines \
     435        "Display bonds as lines. Do not display atoms."
     436
     437    scale $inner.spherescale -width 10 -font "Arial 9 bold" \
     438        -from 0.1 -to 2.0 -resolution 0.05 -label "Sphere Scale" \
    418439        -showvalue true -orient horizontal \
    419         -command [itcl::code $this atomscale] \
    420         -variable Rappture::MolvisViewer::_settings($this-atomscale)
    421     $inner.atomscale set $_settings($this-atomscale)
    422 
    423     scale $inner.bondthickness -width 10 -font "Arial 9 bold" \
    424         -from 0.1 -to 1.0 -resolution 0.025 -label "Bond Thickness" \
     440        -command [itcl::code $this spherescale] \
     441        -variable Rappture::MolvisViewer::_settings($this-spherescale)
     442    $inner.spherescale set $_settings($this-spherescale)
     443    Rappture::Tooltip::for $inner.spherescale \
     444        "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."
     445
     446    scale $inner.stickradius -width 10 -font "Arial 9 bold" \
     447        -from 0.1 -to 1.0 -resolution 0.025 -label "Stick Radius" \
    425448        -showvalue true -orient horizontal \
    426         -command [itcl::code $this bondthickness] \
    427         -variable Rappture::MolvisViewer::_settings($this-bondthickness)
    428     $inner.bondthickness set $_settings($this-bondthickness)
     449        -command [itcl::code $this stickradius] \
     450        -variable Rappture::MolvisViewer::_settings($this-stickradius)
     451    Rappture::Tooltip::for $inner.stickradius \
     452        "Adjust scale of bonds (sticks)."
     453    $inner.stickradius set $_settings($this-stickradius)
    429454
    430455    checkbutton $inner.labels -text "Show labels on atoms" \
     
    432457        -variable [itcl::scope _settings($this-showlabels)] \
    433458        -font "Arial 9 bold"
     459    Rappture::Tooltip::for $inner.labels \
     460        "Display atom symbol and serial number."
     461
    434462    checkbutton $inner.rock -text "Rock model back and forth" \
    435463        -command [itcl::code $this rock toggle] \
    436464        -variable Rappture::MolvisViewer::_settings($this-rock) \
    437465        -font "Arial 9 bold"
     466    Rappture::Tooltip::for $inner.rock \
     467        "Rotate the object back and forth around the y-axis."
     468
    438469    checkbutton $inner.ortho -text "Orthoscopic projection" \
    439470        -command [itcl::code $this projection update] \
    440471        -variable Rappture::MolvisViewer::_settings($this-ortho) \
    441472         -font "Arial 9 bold"
     473    Rappture::Tooltip::for $inner.ortho \
     474        "Toggle between orthoscopic/perspective projection modes."
     475
     476    checkbutton $inner.cartoon -text "Cartoon" \
     477        -command [itcl::code $this cartoon update] \
     478        -variable [itcl::scope _settings($this-cartoon)] \
     479        -font "Arial 9 bold"
     480    Rappture::Tooltip::for $inner.cartoon \
     481        "Set cartoon representation of bonds (sticks)."
     482
     483    checkbutton $inner.cartoontrace -text "Cartoon Trace" \
     484        -command [itcl::code $this cartoontrace update] \
     485        -variable [itcl::scope _settings($this-cartoontrace)] \
     486        -font "Arial 9 bold"
     487    Rappture::Tooltip::for $inner.cartoontrace \
     488        "Set cartoon representation of bonds (sticks)."
    442489
    443490    label $inner.spacer
    444491    blt::table $inner \
    445492        0,0 $inner.drawinglabel -anchor w -columnspan 4 \
    446         1,1 $inner.pict -anchor w -rowspan 3 \
    447         1,2 $inner.spheres -anchor w -columnspan 2 \
    448         2,2 $inner.lines -anchor w -columnspan 2 \
    449         3,2 $inner.bstick -anchor w -columnspan 2 \
    450         4,0 $inner.labels -anchor w -columnspan 4 -pady {6 0} \
    451         5,0 $inner.rock -anchor w -columnspan 4 -pady {6 0} \
    452         6,0 $inner.ortho -anchor w -columnspan 4 -pady {6 0} \
    453         8,1 $inner.atomscale -fill x -columnspan 4 -pady {6 0} \
    454         10,1 $inner.bondthickness -fill x -columnspan 4 -pady {6 0}
     493        1,1 $inner.pict -anchor w -rowspan 4 \
     494        1,2 $inner.bstick -anchor w -columnspan 2 \
     495        2,2 $inner.spheres -anchor w -columnspan 2 \
     496        3,2 $inner.sticks -anchor w -columnspan 2 \
     497        4,2 $inner.lines -anchor w -columnspan 2 \
     498        5,0 $inner.labels -anchor w -columnspan 4 -pady {6 0} \
     499        6,0 $inner.rock -anchor w -columnspan 4 -pady {6 0} \
     500        7,0 $inner.ortho -anchor w -columnspan 4 -pady {6 0} \
     501        8,1 $inner.spherescale -fill x -columnspan 4 -pady {6 0} \
     502        10,1 $inner.stickradius -fill x -columnspan 4 -pady {6 0} \
     503        12,0 $inner.cartoon -anchor w -columnspan 4 -pady {6 0} \
     504        13,0 $inner.cartoontrace -anchor w -columnspan 4 -pady {6 0} \
    455505
    456506    blt::table configure $inner c0 -resize expand -width 2
     
    458508    blt::table configure $inner c3 -resize expand
    459509    blt::table configure $inner r* -resize none
    460     blt::table configure $inner r11 -resize expand
     510    blt::table configure $inner r14 -resize expand
    461511}
    462512
     
    800850                set rep $_model($model-newrepresentation)
    801851                set transp $_model($model-newtransparency)
    802                 SendCmd "$_model($model-newrepresentation) -defer -model $model"
     852                SendCmd "representation -defer -model $model $rep"
    803853                if { $_model($model-newtransparency) == "ghost" } {
    804854                    SendCmd "deactivate -defer -model $model"
     
    846896
    847897    projection update
    848     atomscale update
    849     bondthickness update
     898    spherescale update
     899    stickradius update
    850900    labels update
     901    cartoon update
     902    cartoontrace update
    851903    representation update
    852904    opacity update
     
    12051257
    12061258# ----------------------------------------------------------------------
    1207 # USAGE: representation spheres
    1208 # USAGE: representation ballnstick
    1209 # USAGE: representation lines
     1259# USAGE: representation spheres|ballnstick|lines|sticks
    12101260#
    12111261# Used internally to change the molecular representation used to render
     
    12191269        set option $_settings($this-model)
    12201270    }
    1221     set _settings($this-modelimg) [Rappture::icon $option]
     1271    if { $option == "sticks" } {
     1272        set _settings($this-modelimg) [Rappture::icon lines]
     1273    }  else {
     1274        set _settings($this-modelimg) [Rappture::icon $option]
     1275    }
    12221276    set inner [$itk_component(main) panel "View Settings"]
    12231277    $inner.pict configure -image $_settings($this-modelimg)
     
    12441298    }
    12451299    if { [isconnected] } {
    1246         SendCmd "$option -model $model"
     1300        SendCmd "representation -model $model $option"
    12471301        #$_dispatcher event -idle !rebuild
    12481302    }
     
    15361590
    15371591# ----------------------------------------------------------------------
    1538 # USAGE: atomscale radius ?model?
    1539 #        atomscale update ?model?
     1592# USAGE: spherescale radius ?model?
     1593#        spherescale update ?model?
    15401594#
    15411595# Used internally to change the molecular atom scale used to render
     
    15461600# ----------------------------------------------------------------------
    15471601
    1548 itcl::body Rappture::MolvisViewer::atomscale { option {models "all"} } {
     1602itcl::body Rappture::MolvisViewer::spherescale { option {models "all"} } {
    15491603    if { $option == "update" } {
    1550         set radius $_settings($this-atomscale)
     1604        set radius $_settings($this-spherescale)
    15511605    } elseif { [string is double $option] } {
    15521606        set radius $option
     
    15571611        error "bad option \"$option\""
    15581612    }
    1559     set _settings($this-atomscale) $radius
     1613    set _settings($this-spherescale) $radius
    15601614    if { $models == "all" } {
    15611615        set models [array names _mlist]
     
    15641618    foreach model $models {
    15651619        if { [info exists _active($model)] } {
    1566             SendCmd "atomscale -model $model $radius"
     1620            SendCmd "spherescale -model $model $radius"
    15671621        } else {
    1568             SendCmd "atomscale -model $model $overrideradius"
    1569         }
    1570     }
    1571 }
    1572 
    1573 # ----------------------------------------------------------------------
    1574 # USAGE: bondthickness thickness ?models?
    1575 #        bondthickness update ?models?
    1576 #
    1577 # Used internally to change the molecular bond thickness used to render
     1622            SendCmd "spherescale -model $model $overrideradius"
     1623        }
     1624    }
     1625}
     1626
     1627# ----------------------------------------------------------------------
     1628# USAGE: stickradius radius ?models?
     1629#        stickradius update ?models?
     1630#
     1631# Used internally to change the stick radius used to render
    15781632# our scene.
    15791633#
    1580 # Note: Only sets the specified thickness for active models.  If the model
     1634# Note: Only sets the specified radius for active models.  If the model
    15811635#       is inactive, then it overridden with the value "0.25".
    15821636# ----------------------------------------------------------------------
    15831637
    1584 itcl::body Rappture::MolvisViewer::bondthickness { option {models "all"} } {
     1638itcl::body Rappture::MolvisViewer::stickradius { option {models "all"} } {
    15851639    if { $option == "update" } {
    1586         set thickness $_settings($this-bondthickness)
     1640        set radius $_settings($this-stickradius)
    15871641    } elseif { [string is double $option] } {
    1588         set thickness $option
    1589         if { ($thickness < 0.1) || ($thickness > 2.0) } {
    1590             error "bad bind thickness \"$thickness\""
     1642        set radius $option
     1643        if { ($radius < 0.1) || ($radius > 2.0) } {
     1644            error "bad stick radius \"$radius\""
    15911645        }
    15921646    } else {
    15931647        error "bad option \"$option\""
    15941648    }
    1595     set _settings($this-bondthickness) $thickness
     1649    set _settings($this-stickradius) $radius
    15961650    if { $models == "all" } {
    15971651        set models [array names _mlist]
    15981652    }
    1599     set overridethickness [expr $thickness * 0.8]
     1653    set overrideradius [expr $radius * 0.8]
    16001654    foreach model $models {
    16011655        if { [info exists _active($model)] } {
    1602             SendCmd "bondthickness -model $model $thickness"
     1656            SendCmd "stickradius -model $model $radius"
    16031657        } else {
    1604             SendCmd "bondthickness -model $model $overridethickness"
     1658            SendCmd "stickradius -model $model $overrideradius"
    16051659        }
    16061660    }
     
    16111665#        opacity update ?models?
    16121666#
    1613 # Used internally to change the molecular bond thickness used to render
     1667# Used internally to change the opacity (transparency) used to render
    16141668# our scene.
    16151669#
    1616 # Note: Only sets the specified thickness for active models.  If the model
     1670# Note: Only sets the specified transparency for active models.  If the model
    16171671#       is inactive, then it overridden with the value "0.75".
    16181672# ----------------------------------------------------------------------
     
    16731727    }
    16741728}
     1729
     1730# ----------------------------------------------------------------------
     1731# USAGE: cartoon on|off|toggle
     1732# USAGE: cartoon update
     1733#
     1734# Used internally to turn labels associated with atoms on/off, and to
     1735# update the positions of the labels so they sit on top of each atom.
     1736# ----------------------------------------------------------------------
     1737itcl::body Rappture::MolvisViewer::cartoon {option {models "all"}} {
     1738    set cartoon $_settings($this-cartoon)
     1739    if { $option == "update" } {
     1740        set cartoon $_settings($this-cartoon)
     1741    } elseif { [string is boolean $option] } {
     1742        set cartoon $option
     1743    } else {
     1744        error "bad option \"$option\""
     1745    }
     1746    set _settings($this-cartoon) $cartoon
     1747    if { $models == "all" } {
     1748        set models [array names _mlist]
     1749    }
     1750    set overridecartoon "off"
     1751    foreach model $models {
     1752        if { [info exists _active($model)] } {
     1753            SendCmd "cartoon -model $model $cartoon"
     1754        } else {
     1755            SendCmd "cartoon -model $model $overridecartoon"
     1756        }
     1757    }
     1758}
     1759
     1760# ----------------------------------------------------------------------
     1761# USAGE: cartoontrace on|off|toggle
     1762# USAGE: cartoontrace update
     1763#
     1764# Used internally to turn labels associated with atoms on/off, and to
     1765# update the positions of the labels so they sit on top of each atom.
     1766# ----------------------------------------------------------------------
     1767itcl::body Rappture::MolvisViewer::cartoontrace {option {models "all"}} {
     1768    set trace $_settings($this-cartoontrace)
     1769    if { $option == "update" } {
     1770        set trace $_settings($this-cartoontrace)
     1771    } elseif { [string is boolean $option] } {
     1772        set trace $option
     1773    } else {
     1774        error "bad option \"$option\""
     1775    }
     1776    set _settings($this-cartoontrace) $trace
     1777    if { $models == "all" } {
     1778        set models [array names _mlist]
     1779    }
     1780    set overridetrace "off"
     1781    foreach model $models {
     1782        if { [info exists _active($model)] } {
     1783            SendCmd "cartoontrace -model $model $trace"
     1784        } else {
     1785            SendCmd "cartoontrace -model $model $overridetrace"
     1786        }
     1787    }
     1788}
  • trunk/gui/scripts/resultviewer.tcl

    r1549 r1550  
    218218        }
    219219        ::Rappture::Curve {
    220             set bars [$dataobj hints bars]
     220            set type [$dataobj hints type]
    221221            set mode "xy"
    222             if { $bars != "" && $bars } {
     222            if { $type == "bars" } {
    223223                if {![info exists _mode2widget($mode)]} {
    224224                    set w $itk_interior.xy
Note: See TracChangeset for help on using the changeset viewer.