Changeset 711


Ignore:
Timestamp:
May 7, 2007, 3:18:15 PM (17 years ago)
Author:
mmc
Message:

Fixed the older MoleculeViewer? to work properly with the add/delete
calls needed for the new PyMol?-based viewer.

Disabled the syncCutBuffer stuff in mainwin that used to be used for
copy/paste with desktop. This never worked very well, and we have
the newer upload/download stuff in place now.

A few small tweaks to the graph example and the loader example.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/graph/graph.py

    r555 r711  
    2727
    2828io.put('output.curve(result).about.label','Formula: Y vs X',append=0)
     29io.put('output.curve(result).yaxis.label','Y')
     30io.put('output.curve(result).xaxis.label','X')
    2931
    3032for i in range(npts):
  • trunk/examples/zoo/loader/tool.xml

    r72 r711  
    2222    </about>
    2323    <example>*.xml</example>
     24    <upload>
     25      <to>input.string(one)</to>
     26      <to>input.string(two)</to>
     27    </upload>
     28    <download>
     29      <from>input.string(one)</from>
     30      <from>input.string(two)</from>
     31    </download>
    2432  </loader>
    2533
     
    3442    </about>
    3543  </string>
     44  <number id="e">
     45    <about>
     46      <label>Mass</label>
     47    </about>
     48    <units>kg</units>
     49    <default>10g</default>
     50  </number>
    3651</input>
    3752</run>
  • trunk/gui/scripts/mainwin.tcl

    r676 r711  
    150150    set _sync(selection) ""
    151151
    152     global tcl_platform
    153     if {$tcl_platform(platform) == "unix"} {
    154         # this sync stuff works only for X windows
    155         blt::cutbuffer set ""
    156         syncCutBuffer ifneeded
    157     }
     152    #
     153    # We used to do this to make "copy/paste with desktop" work
     154    # properly.  Well, it never really worked *properly*, but
     155    # it was an attempt.  We might as well skip it.  We use
     156    # the importfile/exportfile stuff now.
     157    #
     158    ##global tcl_platform
     159    ##if {$tcl_platform(platform) == "unix"} {
     160    ##    # this sync stuff works only for X windows
     161    ##    blt::cutbuffer set ""
     162    ##    syncCutBuffer ifneeded
     163    ##}
    158164}
    159165
  • trunk/gui/scripts/moleculeViewer.tcl

    r464 r711  
    3131    destructor { # defined below }
    3232
     33    public method add {dataobj {settings ""}}
     34    public method get {}
     35    public method delete {args}
     36
    3337    public method emblems {option}
    3438    public method download {option args}
     
    4448
    4549    private variable _tool ""    ;# tool containing this viewer
     50    private variable _dlist ""   ;# list of dataobj objects
     51    private variable _dobj2raise ;# maps dataobj => raise flag
    4652    private variable _actors ""  ;# list of actors in renderer
    4753    private variable _label2atom ;# maps 2D text actor => underlying atom
     
    201207
    202208    image delete $_download
     209}
     210
     211# ----------------------------------------------------------------------
     212# USAGE: add <dataobj> ?<settings>?
     213#
     214# Clients use this to add a data object to the plot.  The optional
     215# <settings> are used to configure the plot.  Allowed settings are
     216# -color, -brightness, -width, -linestyle, and -raise. Only
     217# -brightness and -raise do anything.
     218# ----------------------------------------------------------------------
     219itcl::body Rappture::MoleculeViewer::add {dataobj {settings ""}} {
     220    array set params {
     221        -color auto
     222        -brightness 0
     223        -width 1
     224        -raise 0
     225        -linestyle solid
     226        -description ""
     227    }
     228    foreach {opt val} $settings {
     229        if {![info exists params($opt)]} {
     230            error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]"
     231        }
     232        set params($opt) $val
     233    }
     234 
     235    set pos [lsearch -exact $dataobj $_dlist]
     236
     237    if {$pos < 0} {
     238        if {![Rappture::library isvalid $dataobj]} {
     239            error "bad value \"$dataobj\": should be Rappture::library object"
     240        }
     241   
     242        set emblem [$dataobj get components.molecule.about.emblems]
     243        if {$emblem == "" || ![string is boolean $emblem] || !$emblem} {
     244            emblems off
     245        } else {
     246            emblems on
     247        }
     248
     249        lappend _dlist $dataobj
     250        set _dobj2raise($dataobj) $params(-raise)
     251
     252        $_dispatcher event -idle !redraw
     253    }
     254}
     255
     256# ----------------------------------------------------------------------
     257# USAGE: get
     258#
     259# Clients use this to query the list of objects being plotted, in
     260# order from bottom to top of this result.
     261# ----------------------------------------------------------------------
     262itcl::body Rappture::MoleculeViewer::get {} {
     263    # put the dataobj list in order according to -raise options
     264    set dlist $_dlist
     265    foreach obj $dlist {
     266        if {[info exists _dobj2raise($obj)] && $_dobj2raise($obj)} {
     267            set i [lsearch -exact $dlist $obj]
     268            if {$i >= 0} {
     269                set dlist [lreplace $dlist $i $i]
     270                lappend dlist $obj
     271            }
     272        }
     273    }
     274    return $dlist
     275}
     276
     277# ----------------------------------------------------------------------
     278# USAGE: delete ?<dataobj> <dataobj> ...?
     279#
     280# Clients use this to delete a dataobj from the plot. If no dataobjs
     281# are specified, then all dataobjs are deleted.
     282# ----------------------------------------------------------------------
     283itcl::body Rappture::MoleculeViewer::delete {args} {
     284    if {[llength $args] == 0} {
     285        set args $_dlist
     286    }
     287
     288    # delete all specified dataobjs
     289    set changed 0
     290    foreach dataobj $args {
     291        set pos [lsearch -exact $_dlist $dataobj]
     292        if {$pos >= 0} {
     293            set _dlist [lreplace $_dlist $pos $pos]
     294            catch {unset _dobj2raise($dataobj)}
     295            set changed 1
     296        }
     297    }
     298
     299    # if anything changed, then rebuild the plot
     300    if {$changed} {
     301        $_dispatcher event -idle !redraw
     302    }
    203303}
    204304
     
    278378    _clear
    279379
    280     if {$itk_option(-device) != ""} {
    281         set dev $itk_option(-device)
     380    set dev [lindex [get] end]
     381    if {"" != $dev} {
    282382        set lib [Rappture::library standard]
    283383
     
    585685# ----------------------------------------------------------------------
    586686itcl::configbody Rappture::MoleculeViewer::device {
    587     if {$itk_option(-device) != ""
     687    if {"" != $itk_option(-device)
    588688          && ![Rappture::library isvalid $itk_option(-device)]} {
    589689        error "bad value \"$itk_option(-device)\": should be Rappture::library object"
    590690    }
    591     _clear
    592 
    593     if {$itk_option(-device) != ""} {
     691    delete
     692
     693    if {"" != $itk_option(-device)} {
     694        add $itk_option(-device)
    594695        set state [$itk_option(-device) get components.molecule.about.emblems]
    595696        if {$state == "" || ![string is boolean $state] || !$state} {
Note: See TracChangeset for help on using the changeset viewer.