source: trunk/gui/scripts/analyzer.tcl @ 4344

Last change on this file since 4344 was 4261, checked in by gah, 10 years ago

initial map object

File size: 53.6 KB
Line 
1# -*- mode: tcl; indent-tabs-mode: nil -*-
2# ----------------------------------------------------------------------
3#  COMPONENT: analyzer - output area for Rappture
4#
5#  This widget acts as the output side of a Rappture application.
6#  When the input has changed, it displays a Simulate button that
7#  launches the simulation.  When a simulation is running, this
8#  area shows status.  When it is finished, the results appear
9#  in place of the button, according to the specs in the <analyze>
10#  XML data.
11# ======================================================================
12#  AUTHOR:  Michael McLennan, Purdue University
13#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
14#
15#  See the file "license.terms" for information on usage and
16#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
17# ======================================================================
18package require Itk
19
20option add *Analyzer.width 3.5i widgetDefault
21option add *Analyzer.height 4i widgetDefault
22option add *Analyzer.simControl "auto" widgetDefault
23option add *Analyzer.simControlBackground "" widgetDefault
24option add *Analyzer.simControlOutline gray widgetDefault
25option add *Analyzer.simControlActiveBackground #ffffcc widgetDefault
26option add *Analyzer.simControlActiveOutline black widgetDefault
27option add *Analyzer.notebookpage "about" widgetDefault
28
29option add *Analyzer.font \
30    -*-helvetica-medium-r-normal-*-12-* widgetDefault
31option add *Analyzer.codeFont \
32    -*-courier-medium-r-normal-*-12-* widgetDefault
33option add *Analyzer.textFont \
34    -*-helvetica-medium-r-normal-*-12-* widgetDefault
35option add *Analyzer.boldTextFont \
36    -*-helvetica-bold-r-normal-*-12-* widgetDefault
37
38itcl::class Rappture::Analyzer {
39    inherit itk::Widget
40
41    itk_option define -codefont codeFont Font ""
42    itk_option define -textfont textFont Font ""
43    itk_option define -boldtextfont boldTextFont Font ""
44    itk_option define -simcontrol simControl SimControl ""
45    itk_option define -simcontroloutline simControlOutline Background ""
46    itk_option define -simcontrolbackground simControlBackground Background ""
47    itk_option define -simcontrolactiveoutline simControlActiveOutline Background ""
48    itk_option define -simcontrolactivebackground simControlActiveBackground Background ""
49    itk_option define -holdwindow holdWindow HoldWindow ""
50    itk_option define -notebookpage notebookPage NotebookPage ""
51
52    constructor {tool args} {
53        # defined below
54    }
55    destructor {
56        # defined below
57    }
58
59    public method simulate {args}
60    public method reset {{when -eventually}}
61    public method load {xmlobj}
62    public method clear {{xmlobj "all"}}
63    public method download {option args}
64
65    protected method _plot {args}
66    protected method _reorder {comps}
67    protected method _autoLabel {xmlobj path title cntVar}
68    protected method _fixResult {}
69    protected method _fixResultSet {args}
70    protected method _fixSize {}
71    protected method _fixSimControl {}
72    protected method _fixNotebook {}
73    protected method _simState {state args}
74    protected method _simOutput {message}
75    protected method _resultTooltip {}
76    protected method _isPdbTrajectory {data}
77    protected method _isLammpsTrajectory {data}
78    protected method _pdbToSequence {xmlobj path id child data}
79    protected method _lammpsToSequence {xmlobj path id child data}
80    protected method _trajToSequence {xmlobj {path ""}}
81
82    private variable _tool ""          ;# belongs to this tool
83    private variable _appName ""       ;# Name of application
84    private variable _control "manual" ;# start mode
85    private variable _resultset ""     ;# ResultSet object with all results
86    private variable _pages 0          ;# number of pages for result sets
87    private variable _label2page       ;# maps output label => result set
88    private variable _label2desc       ;# maps output label => description
89    private variable _label2item       ;# maps output label => output.xxx item
90    private variable _lastlabel ""     ;# label of last example loaded
91    private variable _plotlist ""      ;# items currently being plotted
92    private variable _lastPlot
93    private common job                 ;# array var used for blt::bgexec jobs
94}
95
96itk::usual Analyzer {
97    keep -background -cursor foreground -font
98}
99
100# ----------------------------------------------------------------------
101# CONSTRUCTOR
102# ----------------------------------------------------------------------
103itcl::body Rappture::Analyzer::constructor {tool args} {
104    set _tool $tool
105
106    # use this to store all simulation results
107    set _resultset [Rappture::ResultSet ::\#auto]
108    $_resultset notify add $this [itcl::code $this _fixResultSet]
109
110    # widget settings...
111    itk_option add hull.width hull.height
112    pack propagate $itk_component(hull) no
113
114    frame $itk_interior.simol -borderwidth 1 -relief flat
115    pack $itk_interior.simol -fill x
116
117    itk_component add simbg {
118        frame $itk_interior.simol.simbg -borderwidth 0
119    } {
120        usual
121        rename -background -simcontrolcolor simControlColor Color
122    }
123    pack $itk_component(simbg) -expand yes -fill both
124
125    set simtxt [string trim [$tool xml get tool.action.label]]
126    if {"" == $simtxt} {
127        set simtxt "Simulate"
128    }
129    itk_component add simulate {
130        button $itk_component(simbg).simulate -text $simtxt \
131            -command [itcl::code $this simulate]
132    } {
133        usual
134        rename -highlightbackground -simcontrolcolor simControlColor Color
135    }
136    pack $itk_component(simulate) -side left -padx 4 -pady 4
137
138    # BE CAREFUL: Shift focus when we click on "Simulate".
139    #   This shifts focus away from input widgets and causes them to
140    #   finalize and log any pending changes.  A better way would be
141    #   to have the "sync" operation finalize/sync, but this works
142    #   for now.
143    bind $itk_component(simulate) <ButtonPress> {focus %W}
144
145    # if there's a hub url, then add "About" and "Questions" links
146    set _appName [$_tool xml get tool.id]
147    set url [Rappture::Tool::resources -huburl]
148    if {"" != $url && "" != $_appName} {
149        itk_component add hubcntls {
150            frame $itk_component(simbg).hubcntls
151        } {
152            usual
153            rename -background -simcontrolcolor simControlColor Color
154        }
155        pack $itk_component(hubcntls) -side right -padx 4
156
157        itk_component add icon {
158            label $itk_component(hubcntls).icon -image [Rappture::icon ask] \
159                -highlightthickness 0
160        } {
161            usual
162            ignore -highlightthickness
163            rename -background -simcontrolcolor simControlColor Color
164        }
165        pack $itk_component(icon) -side left
166
167        itk_component add about {
168            button $itk_component(hubcntls).about -text "About this tool" \
169                -command [list Rappture::filexfer::webpage \
170                              "$url/tools/$_appName"]
171        } {
172            usual
173            ignore -font
174            rename -background -simcontrolcolor simControlColor Color
175            rename -highlightbackground -simcontrolcolor simControlColor Color
176        }
177        pack $itk_component(about) -side top -anchor w
178
179        itk_component add questions {
180            button $itk_component(hubcntls).questions -text Questions? \
181                -command [list Rappture::filexfer::webpage \
182                              "$url/resources/$_appName/questions"]
183        } {
184            usual
185            ignore -font
186            rename -background -simcontrolcolor simControlColor Color
187            rename -highlightbackground -simcontrolcolor simControlColor Color
188        }
189        pack $itk_component(questions) -side top -anchor w
190    }
191
192    itk_component add simstatus {
193        text $itk_component(simbg).simstatus -borderwidth 0 \
194            -highlightthickness 0 -height 1 -width 1 -wrap none \
195            -state disabled
196    } {
197        usual
198        ignore -highlightthickness
199        rename -background -simcontrolcolor simControlColor Color
200        rename -font -textfont textFont Font
201    }
202    pack $itk_component(simstatus) -side left -expand yes -fill x
203
204    $itk_component(simstatus) tag configure popup \
205        -underline 1 -foreground blue
206
207    $itk_component(simstatus) tag bind popup \
208        <Enter> {%W configure -cursor center_ptr}
209    $itk_component(simstatus) tag bind popup \
210        <Leave> {%W configure -cursor ""}
211    $itk_component(simstatus) tag bind popup \
212        <ButtonPress> {after idle {Rappture::Tooltip::tooltip show %W}}
213
214
215    itk_component add notebook {
216        Rappture::Notebook $itk_interior.nb
217    }
218    pack $itk_interior.nb -expand yes -fill both
219
220    # ------------------------------------------------------------------
221    # ABOUT PAGE
222    # ------------------------------------------------------------------
223    set w [$itk_component(notebook) insert end about]
224
225    Rappture::Scroller $w.info -xscrollmode off -yscrollmode auto
226    pack $w.info -expand yes -fill both -padx 4 -pady 20
227    itk_component add toolinfo {
228        text $w.info.text -width 1 -height 1 -wrap word \
229            -borderwidth 0 -highlightthickness 0
230    } {
231        usual
232        ignore -borderwidth -relief
233        rename -font -textfont textFont Font
234    }
235    $w.info contents $w.info.text
236
237    # ------------------------------------------------------------------
238    # SIMULATION PAGE
239    # ------------------------------------------------------------------
240    set w [$itk_component(notebook) insert end simulate]
241    frame $w.cntls
242    pack $w.cntls -side bottom -fill x -pady 12
243    frame $w.cntls.sep -background black -height 1
244    pack $w.cntls.sep -side top -fill x
245
246    itk_component add abort {
247        button $w.cntls.abort -text "Abort" \
248            -command [itcl::code $_tool abort]
249    }
250    pack $itk_component(abort) -side left -expand yes -padx 4 -pady 4
251
252    Rappture::Scroller $w.info -xscrollmode auto -yscrollmode auto
253    pack $w.info -expand yes -fill both -padx 4 -pady 4
254    itk_component add runinfo {
255        text $w.info.text -width 1 -height 1 -wrap none \
256            -borderwidth 0 -highlightthickness 0 \
257            -state disabled
258    } {
259        usual
260        ignore -borderwidth -relief
261        rename -font -codefont codeFont Font
262    }
263    $w.info contents $w.info.text
264
265    itk_component add progress {
266        Rappture::Progress $w.progress
267    }
268
269    # ------------------------------------------------------------------
270    # ANALYZE PAGE
271    # ------------------------------------------------------------------
272    set w [$itk_component(notebook) insert end analyze]
273
274    frame $w.top
275    pack $w.top -side top -fill x -pady 8
276    label $w.top.l -text "Result:" -font $itk_option(-font)
277    pack $w.top.l -side left
278
279    itk_component add viewselector {
280        Rappture::Combobox $w.top.sel -width 10 -editable no
281    } {
282        usual
283        rename -font -textfont textFont Font
284    }
285    pack $itk_component(viewselector) -side left -expand yes -fill x
286    bind $itk_component(viewselector) <<Value>> [itcl::code $this _fixResult]
287    bind $itk_component(viewselector) <Enter> \
288        [itcl::code $this download coming]
289
290    Rappture::Tooltip::for $itk_component(viewselector) \
291        "@[itcl::code $this _resultTooltip]"
292
293    $itk_component(viewselector) choices insert end \
294        --- "---"
295
296    itk_component add download {
297        button $w.top.dl -image [Rappture::icon download] -anchor e \
298            -borderwidth 1 -relief flat -overrelief raised \
299            -command [itcl::code $this download start $w.top.dl]
300    }
301    pack $itk_component(download) -side right -padx {4 0}
302    bind $itk_component(download) <Enter> \
303        [itcl::code $this download coming]
304
305    $itk_component(viewselector) choices insert end \
306        @download [Rappture::filexfer::label download]
307
308    if {[Rappture::filexfer::enabled]} {
309        Rappture::Tooltip::for $itk_component(download) "Downloads the current result to a new web browser window on your desktop.  From there, you can easily print or save results.
310
311NOTE:  Your web browser must allow pop-ups from this site.  If your output does not appear, look for a 'pop-up blocked' message and enable pop-ups."
312    } else {
313        Rappture::Tooltip::for $itk_component(download) "Saves the current result to a file on your desktop."
314    }
315
316    itk_component add results {
317        Rappture::Panes $w.pane -sashwidth 1 -sashrelief solid -sashpadding {4 0}
318    }
319    pack $itk_component(results) -expand yes -fill both
320    set f [$itk_component(results) pane 0]
321
322    itk_component add resultpages {
323        Rappture::Notebook $f.nb
324    }
325    pack $itk_component(resultpages) -expand yes -fill both
326
327    set f [$itk_component(results) insert end -fraction 0.1]
328    itk_component add resultselector {
329        Rappture::ResultSelector $f.rsel -resultset $_resultset \
330            -settingscommand [itcl::code $this _plot]
331    }
332    pack $itk_component(resultselector) -expand yes -fill both
333    bind $itk_component(resultselector) <<Layout>> [itcl::code $this _fixSize]
334    bind $itk_component(results) <Configure> [itcl::code $this _fixSize]
335
336    eval itk_initialize $args
337
338    $itk_component(runinfo) tag configure ERROR -foreground red
339    $itk_component(runinfo) tag configure text -font $itk_option(-textfont)
340
341    #
342    # Load up tool info on the first page.
343    #
344    $itk_component(toolinfo) tag configure title \
345        -font $itk_option(-boldtextfont)
346
347    set mesg [string trim [$tool xml get tool.title]]
348    if {"" != $mesg} {
349        $itk_component(toolinfo) insert end $mesg title
350        $itk_component(toolinfo) insert end "\n\n"
351    }
352
353    set mesg [string trim [$tool xml get tool.about]]
354    if {"" != $mesg} {
355        $itk_component(toolinfo) insert end $mesg
356    }
357    $itk_component(toolinfo) configure -state disabled
358    $itk_component(notebook) current about
359
360    # tool can run on "manual" (default) or "auto"
361    set cntl [string trim [$tool xml get tool.control]]
362    if {"" == $cntl} {
363        set cntl [string trim [$tool xml get tool.control.type]]
364    }
365    if {"" != $cntl} {
366        set _control $cntl
367    }
368
369    # reset everything to a clean state
370    reset
371}
372
373# ----------------------------------------------------------------------
374# DESTRUCTOR
375# ----------------------------------------------------------------------
376itcl::body Rappture::Analyzer::destructor {} {
377    after cancel [itcl::code $this simulate]
378    $_resultset notify remove $this
379    itcl::delete object $_resultset
380}
381
382# ----------------------------------------------------------------------
383# USAGE: simulate ?-ifneeded?
384# USAGE: simulate ?<path1> <value1> <path2> <value2> ...?
385#
386# Kicks off the simulator by executing the tool.command associated
387# with the tool.  If any arguments are specified, they are used to
388# set parameters for the simulation.  While the simulation is running,
389# it shows status.  When the simulation is finished, it switches
390# automatically to "analyze" mode and shows the results.
391# ----------------------------------------------------------------------
392itcl::body Rappture::Analyzer::simulate {args} {
393    if {$args == "-ifneeded"} {
394        # check to see if simulation is really needed
395        $_tool sync
396        if {[$_resultset contains [$_tool xml object]]
397              && ![string equal $_control "manual-resim"]} {
398            # not needed -- show results and return
399            $itk_component(notebook) current analyze
400            return
401        }
402        set args ""
403    }
404
405    # simulation is needed -- go to simulation page
406    $itk_component(notebook) current simulate
407
408    # no progress messages yet
409    pack forget $itk_component(progress)
410    lappend args -output [itcl::code $this _simOutput]
411
412    _simState off
413    $itk_component(runinfo) configure -state normal
414    $itk_component(runinfo) delete 1.0 end
415    $itk_component(runinfo) insert end "Running simulation...\n\n" text
416    $itk_component(runinfo) configure -state disabled
417
418    # if the hold window is set, then put up a busy cursor
419    if {$itk_option(-holdwindow) != ""} {
420        blt::busy hold $itk_option(-holdwindow)
421        raise $itk_component(hull)
422    }
423
424    # execute the job
425    foreach {status result} [eval $_tool run $args] break
426
427    # if job was aborted, then allow simulation again
428    if {$result == "ABORT"} {
429        _simState on "Aborted"
430    }
431
432    # load results from run.xml into analyzer
433    if {$status == 0 && $result != "ABORT"} {
434        set status [catch {load $result} result]
435    }
436
437    # back to normal
438    if {$itk_option(-holdwindow) != ""} {
439        blt::busy release $itk_option(-holdwindow)
440    }
441    $itk_component(abort) configure -state disabled
442
443    if {$status != 0} {
444        $itk_component(runinfo) configure -state normal
445        # Don't erase program error messages.
446        # $itk_component(runinfo) delete 1.0 end
447        $itk_component(runinfo) insert end "\n\nProblem launching job:\n\n" text
448        _simOutput $result
449        $itk_component(runinfo) configure -state disabled
450        $itk_component(runinfo) see 1.0
451
452        # Try to create a support ticket for this error.
453        # It may be a real problem.
454        if {[Rappture::bugreport::shouldReport for jobs]} {
455            set ::errorInfo "\n\n== RAPPTURE INPUT ==\n[$_tool xml xml]"
456            Rappture::bugreport::register "Problem launching job:\n$result"
457            Rappture::bugreport::attachment [$_tool xml xml]
458            Rappture::bugreport::send
459        }
460    } else {
461        $itk_component(notebook) current analyze
462    }
463
464    # do this last -- after _simOutput above
465    pack forget $itk_component(progress)
466}
467
468# ----------------------------------------------------------------------
469# USAGE: reset ?-eventually|-now?
470#
471# Used to reset the analyzer whenever the input to a simulation has
472# changed.  Sets the mode back to "simulate", so the user has to
473# simulate again to see the output.  If the <start> option is set
474# to "auto", the simulation is invoked immediately.
475# ----------------------------------------------------------------------
476itcl::body Rappture::Analyzer::reset {{when -eventually}} {
477    if {$when == "-eventually"} {
478        after cancel [list catch [itcl::code $this reset -now]]
479        after idle [list catch [itcl::code $this reset -now]]
480        return
481    }
482
483    # check to see if simulation is really needed
484    $_tool sync
485    if {![$_resultset contains [$_tool xml object]]
486          || [string equal $_control "manual-resim"]} {
487        # if control mode is "auto", then simulate right away
488        if {[string match auto* $_control]} {
489            # auto control -- don't need button
490            pack forget $itk_interior.simol
491
492            after cancel [itcl::code $this simulate]
493            after idle [itcl::code $this simulate]
494        } else {
495            _simState on "new input parameters"
496        }
497    } else {
498        _simState off
499    }
500}
501
502# ----------------------------------------------------------------------
503# USAGE: load <xmlobj>
504#
505# Loads the data from the given <xmlobj> into the appropriate results
506# sets.  If necessary, new results sets are created to store the data.
507# ----------------------------------------------------------------------
508itcl::body Rappture::Analyzer::load {xmlobj} {
509    # only show the last result? then clear first
510    if {[string trim [$_tool xml get tool.analyzer]] == "last"} {
511        clear
512    }
513    $_resultset add $xmlobj
514
515    # NOTE: Adding will trigger a !change event on the ResultSet
516    # object, which will trigger calls to _fixResultSet to add
517    # the results to display.
518}
519
520# ----------------------------------------------------------------------
521# USAGE: clear ?<xmlobj>?
522#
523# Discards one or more results previously loaded into the analyzer.
524# If an <xmlobj> is specified, then that one result is cleared.
525# Otherwise, all results are cleared.
526# ----------------------------------------------------------------------
527itcl::body Rappture::Analyzer::clear {{xmlobj "all"}} {
528    if {$xmlobj eq "" || $xmlobj eq "all"} {
529        $_resultset clear
530    } else {
531        $_resultset clear $xmlobj
532    }
533
534    # NOTE: Clearing will trigger a !change event on the ResultSet
535    # object, which will trigger calls to _fixResultSet to clean up
536    # the results being displayed.
537}
538
539# ----------------------------------------------------------------------
540# USAGE: download coming
541# USAGE: download controls <downloadCommand>
542# USAGE: download start ?widget?
543# USAGE: download now ?widget?
544#
545# Spools the current result so the user can download it.
546# ----------------------------------------------------------------------
547itcl::body Rappture::Analyzer::download {option args} {
548    set title [$itk_component(viewselector) value]
549    set page [$itk_component(viewselector) translate $title]
550
551    switch -- $option {
552        coming {
553            #
554            # Warn result that a download is coming, in case
555            # it needs to take a screen snap.
556            #
557            if {![regexp {^(|@download|---)$} $page]} {
558                set f [$itk_component(resultpages) page $page]
559                $f.rviewer download coming
560            }
561        }
562        controls {
563            # no controls for this download yet
564            return ""
565        }
566        start {
567            set widget $itk_component(download)
568            if {[llength $args] > 0} {
569                set widget [lindex $args 0]
570                if {[catch {winfo class $widget}]} {
571                    set widget $itk_component(download)
572                }
573            }
574            #
575            # See if this download has any controls.  If so, then
576            # post them now and let the user continue the download
577            # after selecting a file format.
578            #
579            if {$page != ""} {
580                set ext ""
581                set f [$itk_component(resultpages) page $page]
582                set arg [itcl::code $this download now $widget]
583                set popup [$f.rviewer download controls $arg]
584                if {"" != $popup} {
585                    $popup activate $widget below
586                } else {
587                    download now $widget
588                }
589            } else {
590                # this shouldn't happen
591                set file error.html
592                set data "<h1>Not Found</h1>There is no result selected."
593            }
594        }
595        now {
596            set widget $itk_component(download)
597            if {[llength $args] > 0} {
598                set widget [lindex $args 0]
599                if {[catch {winfo class $widget}]} {
600                    set widget $itk_component(download)
601                }
602            }
603            #
604            # Perform the actual download.
605            #
606            if {$page != ""} {
607                set ext ""
608                set f [$itk_component(resultpages) page $page]
609                set item [$itk_component(viewselector) value]
610                set result [$f.rviewer download now $widget $_appName $item]
611                if { $result == "" } {
612                    return;                # User cancelled the download.
613                }
614                foreach {ext data} $result break
615                if {"" == $ext} {
616                    if {"" != $widget} {
617                        Rappture::Tooltip::cue $widget \
618                            "Can't download this result."
619                    }
620                    return
621                }
622                regsub -all {[\ -\/\:-\@\{-\~]} $title {} title
623                set file "$title$ext"
624            } else {
625                # this shouldn't happen
626                set file error.html
627                set data "<h1>Not Found</h1>There is no result selected."
628            }
629
630            Rappture::Logger::log download [$itk_component(viewselector) value]
631            set mesg [Rappture::filexfer::download $data $file]
632            if {[string length $mesg] > 0} {
633                Rappture::Tooltip::cue $widget $mesg
634            }
635        }
636        default {
637            error "bad option \"$option\": should be coming, controls, now, start"
638        }
639    }
640}
641
642# ----------------------------------------------------------------------
643# USAGE: _plot ?<index> <options> <index> <options>...?
644#
645# Used internally to update the plot shown in the current result
646# viewer whenever the resultselector settings have changed.  Causes the
647# desired results to show up on screen.
648# ----------------------------------------------------------------------
649itcl::body Rappture::Analyzer::_plot {args} {
650    set _plotlist $args
651
652    set page [$itk_component(viewselector) value]
653    set page [$itk_component(viewselector) translate $page]
654    if {"" != $page} {
655        set f [$itk_component(resultpages) page $page]
656        $f.rviewer plot clear
657        foreach {index opts} $_plotlist {
658            $f.rviewer plot add $index $opts
659        }
660    }
661}
662
663# ----------------------------------------------------------------------
664# USAGE: _reorder <compList>
665#
666# Used internally to change the order of a series of output components
667# found in the <output> section.  Moves the <log> elements to the end
668# and returns the updated list.
669# ----------------------------------------------------------------------
670itcl::body Rappture::Analyzer::_reorder {comps} {
671    set i 0
672    set max [llength $comps]
673    while {$i < $max} {
674        set c [lindex $comps $i]
675        if {[string match log* $c]} {
676            set comps [lreplace $comps $i $i]
677            lappend comps $c
678            incr max -1
679        } else {
680            incr i
681        }
682    }
683    return $comps
684}
685
686# ----------------------------------------------------------------------
687# USAGE: _autoLabel <xmlobj> <path> <title> <cntVar>
688#
689# Used internally to check for an about.label property at the <path>
690# in <xmlobj>.  If this object doesn't have a label, then one is
691# supplied using the given <title>.  The <cntVar> is an array of
692# counters in the calling scopes for titles that have been used
693# in the past.  This is used to create titles like "Plot #2" the
694# second time it is encountered.
695#
696# The <xmlobj> is updated so that the label is inserted directly in
697# the tree.
698# ----------------------------------------------------------------------
699itcl::body Rappture::Analyzer::_autoLabel {xmlobj path title cntVar} {
700    upvar $cntVar counters
701
702    set group [$xmlobj get $path.about.group]
703    set label [$xmlobj get $path.about.label]
704    if {"" == $label} {
705        # no label -- make one up using the title specified
706        if {![info exists counters($group-$title)]} {
707            set counters($group-$title) 1
708            set label $title
709        } else {
710            set label "$title (#[incr counters($group-$title)])"
711        }
712        $xmlobj put $path.about.label $label
713    } else {
714        # handle the case of two identical labels in <output>
715        if {![info exists counters($group-$label)]} {
716            set counters($group-$label) 1
717        } else {
718            set label "$label (#[incr counters($group-$label)])"
719            $xmlobj put $path.about.label $label
720        }
721    }
722    return $label
723}
724
725# ----------------------------------------------------------------------
726# USAGE: _fixResult
727#
728# Used internally to change the result page being displayed whenever
729# the user selects a page from the results combobox.
730# ----------------------------------------------------------------------
731itcl::body Rappture::Analyzer::_fixResult {} {
732    set name [$itk_component(viewselector) value]
733    set page ""
734    if {"" != $name} {
735        set page [$itk_component(viewselector) translate $name]
736    }
737    if {$page == "@download"} {
738        # put the combobox back to its last value
739        $itk_component(viewselector) component entry configure -state normal
740        $itk_component(viewselector) component entry delete 0 end
741        $itk_component(viewselector) component entry insert end $_lastlabel
742        $itk_component(viewselector) component entry configure -state disabled
743        # perform the actual download
744        download start $itk_component(download)
745    } elseif {$page == "---"} {
746        # put the combobox back to its last value
747        $itk_component(viewselector) component entry configure -state normal
748        $itk_component(viewselector) component entry delete 0 end
749        $itk_component(viewselector) component entry insert end $_lastlabel
750        $itk_component(viewselector) component entry configure -state disabled
751    } elseif {$page != ""} {
752        set _lastlabel $name
753        set win [winfo toplevel $itk_component(hull)]
754        $itk_component(resultpages) current $page
755        set f [$itk_component(resultpages) page $page]
756
757        # We don't want to replot if we're using an existing viewer with the
758        # the same list of objects to plot.  So track the viewer and the list.
759        if { ![info exists _lastPlot($f)] || $_plotlist != $_lastPlot($f) } {
760            set _lastPlot($f) $_plotlist
761            blt::busy hold $win
762            $f.rviewer plot clear
763            eval $f.rviewer plot add $_plotlist
764            blt::busy release [winfo toplevel $itk_component(hull)]
765        }
766        Rappture::Logger::log output $_label2item($name)
767        Rappture::Tooltip::for $itk_component(viewselector) \
768            "@[itcl::code $this _resultTooltip]" -log $_label2item($name)
769    }
770}
771
772# ----------------------------------------------------------------------
773# USAGE: _fixResultSet ?<eventData>...?
774#
775# Used internally to react to changes within the ResultSet.  When a
776# result is added, a new result viewer is created for the object.
777# When all results are cleared, the viewers are deleted.
778# ----------------------------------------------------------------------
779itcl::body Rappture::Analyzer::_fixResultSet {args} {
780    array set eventData $args
781    switch -- $eventData(op) {
782        add {
783            set xmlobj $eventData(what)
784
785            # Detect molecule elements that contain trajectory data
786            # and convert to sequences.
787            _trajToSequence $xmlobj output
788
789            # Go through the analysis and find all result sets.
790            set haveresults 0
791            foreach item [_reorder [$xmlobj children output]] {
792                switch -glob -- $item {
793                    log* {
794                        _autoLabel $xmlobj output.$item "Output Log" counters
795                    }
796                    number* {
797                        _autoLabel $xmlobj output.$item "Number" counters
798                    }
799                    integer* {
800                        _autoLabel $xmlobj output.$item "Integer" counters
801                    }
802                    string* {
803                        _autoLabel $xmlobj output.$item "String" counters
804                    }
805                    histogram* - curve* - field* - map* {
806                        _autoLabel $xmlobj output.$item "Plot" counters
807                    }
808                    drawing* {
809                        _autoLabel $xmlobj output.$item "Drawing" counters
810                    }
811                    structure* {
812                        _autoLabel $xmlobj output.$item "Structure" counters
813                    }
814                    table* {
815                        _autoLabel $xmlobj output.$item "Energy Levels" counters
816                    }
817                    sequence* {
818                        _autoLabel $xmlobj output.$item "Sequence" counters
819                    }
820                }
821                set label [$xmlobj get output.$item.about.group]
822                if {"" == $label} {
823                    set label [$xmlobj get output.$item.about.label]
824                }
825
826                set hidden [$xmlobj get output.$item.hide]
827                set hidden [expr {"" != $hidden && $hidden}]
828
829                if {"" != $label && !$hidden} {
830                    set haveresults 1
831                }
832            }
833
834            # if there are any valid results, add them to the resultset
835            if {$haveresults} {
836                set index [$_resultset get simnum $xmlobj]
837
838                # add each result to a result viewer
839                foreach item [_reorder [$xmlobj children output]] {
840                    set label [$xmlobj get output.$item.about.group]
841                    if {"" == $label} {
842                        set label [$xmlobj get output.$item.about.label]
843                    }
844                    set hidden [$xmlobj get output.$item.hide]
845                    if { $hidden == "" } {
846                        set hidden 0
847                    }
848                    if {"" != $label && !$hidden} {
849                        if {![info exists _label2page($label)]} {
850                            set name "page[incr _pages]"
851                            set page [$itk_component(resultpages) \
852                                insert end $name]
853                            set _label2page($label) $page
854                            set _label2item($label) output.$item
855                            set _label2desc($label) \
856                                [$xmlobj get output.$item.about.description]
857                            Rappture::ResultViewer $page.rviewer
858                            pack $page.rviewer -expand yes -fill both -pady 4
859
860                            set end [$itk_component(viewselector) \
861                                choices index -value ---]
862                            if {$end < 0} {
863                                set end "end"
864                            }
865                            $itk_component(viewselector) choices insert $end \
866                                $name $label
867                        }
868
869                        # add/replace the latest result into this viewer
870                        set page $_label2page($label)
871
872                        if {![info exists reset($page)]} {
873                            $page.rviewer clear $index
874                            set reset($page) 1
875                        }
876                        $page.rviewer add $index $xmlobj output.$item
877                    }
878                }
879            }
880
881            # show the first page by default
882            set max [$itk_component(viewselector) choices size]
883            for {set i 0} {$i < $max} {incr i} {
884                set first [$itk_component(viewselector) choices get -label $i]
885                if {$first != ""} {
886                    set page [$itk_component(viewselector) choices get -value $i]
887                    set char [string index $page 0]
888                    if {$char != "@" && $char != "-"} {
889                        $itk_component(resultpages) current $page
890                        $itk_component(viewselector) value $first
891                        set _lastlabel $first
892                        break
893                    }
894                }
895            }
896        }
897        clear {
898            if {$eventData(what) ne "all"} {
899                # delete this result from all viewers
900                array set params $eventData(what)
901                foreach label [array names _label2page] {
902                    set page $_label2page($label)
903                    $page.rviewer clear $params(simnum)
904                }
905            }
906
907            if {[$_resultset size] == 0} {
908                # reset the size of the controls area
909                set ht [winfo height $itk_component(results)]
910                set cntlht [$itk_component(resultselector) size -controlarea]
911                set frac [expr {double($cntlht)/$ht}]
912                $itk_component(results) fraction end $frac
913
914                foreach label [array names _label2page] {
915                    set page $_label2page($label)
916                    destroy $page.rviewer
917                }
918                $itk_component(resultpages) delete -all
919                set _pages 0
920
921                $itk_component(viewselector) value ""
922                $itk_component(viewselector) choices delete 0 end
923                catch {unset _label2page}
924                catch {unset _label2item}
925                catch {unset _label2desc}
926                set _plotlist ""
927
928                $itk_component(viewselector) choices insert end --- "---"
929                $itk_component(viewselector) choices insert end \
930                    @download [Rappture::filexfer::label download]
931                set _lastlabel ""
932            }
933
934            # fix Simulate button state
935            reset
936        }
937        default {
938            error "don't know how to handle op \"$eventData(op)\""
939        }
940    }
941}
942
943# ----------------------------------------------------------------------
944# USAGE: _fixSize
945#
946# Used internally to change the size of the result set area whenever
947# a new control appears.  Adjusts the size available for the result
948# set up to some maximum.
949# ----------------------------------------------------------------------
950itcl::body Rappture::Analyzer::_fixSize {} {
951    set ht [winfo height $itk_component(results)]
952    if {$ht <= 1} { set ht [winfo reqheight $itk_component(results)] }
953    set cntlht [$itk_component(resultselector) size -controlarea]
954    set frac [expr {double($cntlht)/$ht}]
955
956    if {$frac < 0.4} {
957        $itk_component(results) fraction end $frac
958    }
959    _fixSimControl
960}
961
962# ----------------------------------------------------------------------
963# USAGE: _simState <boolean> ?<message>? ?<settings>?
964#
965# Used internally to change the "Simulation" button on or off.
966# If the <boolean> is on, then any <message> and <settings> are
967# displayed as well.  If the <boolean> is off, then only display
968# the message. The <message> is a note to the user about
969# what will be simulated, and the <settings> are a list of
970# tool parameter settings of the form {path1 val1 path2 val2 ...}.
971# When these are in place, the next Simulate operation will use
972# these settings.  This helps fill in missing data values.
973# ----------------------------------------------------------------------
974itcl::body Rappture::Analyzer::_simState {state args} {
975    if {$state} {
976        $itk_interior.simol configure \
977            -background $itk_option(-simcontrolactiveoutline)
978        configure -simcontrolcolor $itk_option(-simcontrolactivebackground)
979
980        $itk_component(abort) configure -state disabled
981        $itk_component(simulate) configure -state normal \
982            -command [itcl::code $this simulate]
983
984        #
985        # If there's a special message, then put it up next to the button.
986        #
987        set mesg [lindex $args 0]
988        if {"" != $mesg} {
989            $itk_component(simstatus) configure -state normal
990            $itk_component(simstatus) delete 1.0 end
991            $itk_component(simstatus) insert end $mesg
992
993            #
994            # If there are any settings, then install them in the
995            # "Simulate" button.  Also, pop them up as a tooltip
996            # for the message.
997            #
998            set settings [lindex $args 1]
999            if {[llength $settings] > 0} {
1000                $itk_component(simulate) configure \
1001                    -command [eval itcl::code $this simulate $settings]
1002
1003                set details ""
1004                foreach {path val} $settings {
1005                    set str [string trim [$_tool xml get $path.about.label]]
1006                    if {"" == $str} {
1007                        set str [$_tool xml element -as id $path]
1008                    }
1009                    append details "$str = $val\n"
1010                }
1011                set details [string trim $details]
1012
1013                Rappture::Tooltip::for $itk_component(simstatus) $details
1014                $itk_component(simstatus) insert end " "
1015                $itk_component(simstatus) insert end "(details...)" popup
1016            }
1017            $itk_component(simstatus) configure -state disabled
1018        }
1019    } else {
1020        if {"" != $itk_option(-simcontrolbackground)} {
1021            set simcbg $itk_option(-simcontrolbackground)
1022        } else {
1023            set simcbg $itk_option(-background)
1024        }
1025        $itk_interior.simol configure \
1026            -background $itk_option(-simcontroloutline)
1027        configure -simcontrolcolor $simcbg
1028
1029        $itk_component(simulate) configure -state disabled
1030        $itk_component(abort) configure -state normal
1031
1032        $itk_component(simstatus) configure -state normal
1033        $itk_component(simstatus) delete 1.0 end
1034        set mesg [lindex $args 0]
1035        if {"" != $mesg} {
1036            $itk_component(simstatus) insert end $mesg
1037        }
1038        $itk_component(simstatus) configure -state disabled
1039    }
1040}
1041
1042# ----------------------------------------------------------------------
1043# USAGE: _simOutput <message>
1044#
1045# Invoked automatically whenever output comes in while running the
1046# tool.  Extracts any =RAPPTURE-???=> messages from the output and
1047# sends the output to the display.  For example, any
1048# =RAPPTURE-PROGRESS=> message pops up the progress meter and updates
1049# it to show the latest progress message.  This is useful for
1050# long-running tools, to let the user know how much longer the
1051# simulation will take.
1052# ----------------------------------------------------------------------
1053itcl::body Rappture::Analyzer::_simOutput {message} {
1054    #
1055    # Scan through and pick out any =RAPPTURE-PROGRESS=> messages first.
1056    #
1057    while {[regexp -indices \
1058               {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)} $message \
1059                match percent mesg]} {
1060
1061        foreach {i0 i1} $percent break
1062        set percent [string range $message $i0 $i1]
1063
1064        foreach {i0 i1} $mesg break
1065        set mesg [string range $message $i0 $i1]
1066
1067        pack $itk_component(progress) -fill x -padx 10 -pady 10
1068        $itk_component(progress) settings -percent $percent -message $mesg
1069
1070        foreach {i0 i1} $match break
1071        set message [string replace $message $i0 $i1]
1072    }
1073
1074    #
1075    # Break up the remaining lines according to =RAPPTURE-ERROR=> messages.
1076    # Show errors in a special color.
1077    #
1078    $itk_component(runinfo) configure -state normal
1079
1080    while {[regexp -indices \
1081               {=RAPPTURE-([a-zA-Z]+)=>([^\n]*)(\n|$)} $message \
1082                match type mesg]} {
1083
1084        foreach {i0 i1} $match break
1085        set first [string range $message 0 [expr {$i0-1}]]
1086        if {[string length $first] > 0} {
1087            $itk_component(runinfo) insert end $first
1088            $itk_component(runinfo) insert end \n
1089        }
1090
1091        foreach {t0 t1} $type break
1092        set type [string range $message $t0 $t1]
1093        foreach {m0 m1} $mesg break
1094        set mesg [string range $message $m0 $m1]
1095        if {[string length $mesg] > 0 && $type != "RUN"} {
1096            $itk_component(runinfo) insert end $mesg $type
1097            $itk_component(runinfo) insert end \n $type
1098        }
1099
1100        set message [string range $message [expr {$i1+1}] end]
1101    }
1102
1103    if {[string length $message] > 0} {
1104        $itk_component(runinfo) insert end $message
1105        if {[$itk_component(runinfo) get end-2char] != "\n"} {
1106            $itk_component(runinfo) insert end "\n"
1107        }
1108        $itk_component(runinfo) see end
1109    }
1110    $itk_component(runinfo) configure -state disabled
1111}
1112
1113# ----------------------------------------------------------------------
1114# USAGE: _resultTooltip
1115#
1116# Used internally to build the tooltip string displayed for the
1117# result selector.  If the current page has an associated description,
1118# then it is displayed beneath the result.
1119#
1120# Returns the string for the tooltip.
1121# ----------------------------------------------------------------------
1122itcl::body Rappture::Analyzer::_resultTooltip {} {
1123    set tip ""
1124    set name [$itk_component(viewselector) value]
1125    if {[info exists _label2desc($name)] &&
1126         [string length $_label2desc($name)] > 0} {
1127        append tip "$_label2desc($name)\n\n"
1128    }
1129    if {[array size _label2page] > 1} {
1130        append tip "Use this control to display other output results."
1131    }
1132    return $tip
1133}
1134
1135# ----------------------------------------------------------------------
1136# USAGE: _fixSimControl
1137#
1138# Used internally to add or remove the simulation control at the
1139# top of the analysis area.  This is controlled by the -simcontrol
1140# option.
1141# ----------------------------------------------------------------------
1142itcl::body Rappture::Analyzer::_fixSimControl {} {
1143    switch -- $itk_option(-simcontrol) {
1144        on {
1145            pack $itk_interior.simol -fill x -before $itk_interior.nb
1146        }
1147        off {
1148            pack forget $itk_interior.simol
1149        }
1150        auto {
1151            #
1152            # If we have two or more radiodials, then there is a
1153            # chance of encountering a combination of parameters
1154            # with no data, requiring simulation.
1155            #
1156            if {[$itk_component(resultselector) size -controls] >= 2} {
1157                pack $itk_interior.simol -fill x -before $itk_interior.nb
1158            } else {
1159                pack forget $itk_interior.simol
1160            }
1161        }
1162        default {
1163            error "bad value \"$itk_option(-simcontrol)\": should be on, off, auto"
1164        }
1165    }
1166}
1167
1168# ----------------------------------------------------------------------
1169# USAGE: _fixNotebook
1170#
1171# Used internally to switch the active notebook page
1172# ----------------------------------------------------------------------
1173itcl::body Rappture::Analyzer::_fixNotebook {} {
1174    switch -- $itk_option(-notebookpage) {
1175        about {
1176            $itk_component(notebook) current about
1177        }
1178        simulate {
1179            $itk_component(notebook) current simulate
1180        }
1181        analyze {
1182            $itk_component(notebook) current analyze
1183        }
1184        default {
1185            error "bad value \"$itk_option(-notebookpage)\": should be about, simulate, analyze"
1186        }
1187    }
1188}
1189
1190# ----------------------------------------------------------------------
1191# USAGE: _isPdbTrajectory <data>
1192#
1193# Used internally to determine whether pdb or lammps data represents a
1194# trajectory rather than a single frame
1195# ----------------------------------------------------------------------
1196itcl::body Rappture::Analyzer::_isPdbTrajectory {data} {
1197    if { [llength $data] == 0 } {
1198        return 0
1199    }
1200    set nModels 0
1201    foreach line $data {
1202        if { [string match "MODEL*" $line] }  {
1203            incr nModels
1204            if { $nModels > 1 } {
1205                # Stop if more than one model found.  No need to count them
1206                # all.
1207                return 1
1208            }
1209        }
1210    }
1211    return 0
1212}
1213
1214# ----------------------------------------------------------------------
1215# USAGE: _isLammpsTrajectory <data>
1216#
1217# Used internally to determine whether pdb or lammps data represents a
1218# trajectory rather than a single frame
1219# ----------------------------------------------------------------------
1220itcl::body Rappture::Analyzer::_isLammpsTrajectory { data } {
1221    if { [llength $data] == 0 } {
1222        return 0
1223    }
1224    set nModels 0
1225    foreach line $data {
1226        if { [regexp {^[\t ]*ITEM:[ \t]+TIMESTEP} $line] } {
1227            incr nModels
1228            if { $nModels > 1 } {
1229                # Stop if more than one model found.  No need to count them
1230                # all.
1231                return 1
1232            }
1233        }
1234    }
1235    return 0
1236}
1237
1238# ----------------------------------------------------------------------
1239# USAGE: _pdbToSequence <xmlobj> ?<path>?
1240#
1241# If the molecule element is a trajectory, delete the original
1242# and create a sequence of individual molecules.
1243# Used internally to detect any molecule output elements that contain
1244# trajectory data.  Trajectories will be converted into sequences of
1245# individual molecules.  All other elements will be unaffected. Scans
1246# the entire xml tree if a starting path is not specified.
1247# ----------------------------------------------------------------------
1248itcl::body Rappture::Analyzer::_pdbToSequence {xmlobj path id child data} {
1249
1250    set seqLabel [$xmlobj get ${child}.about.label]
1251    set descr    [$xmlobj get ${child}.about.description]
1252    set formula  [$xmlobj get ${child}.components.molecule.formula]
1253    $xmlobj remove $child
1254
1255    set sequence  $path.sequence($id)
1256    $xmlobj put ${sequence}.about.label $seqLabel
1257    $xmlobj put ${sequence}.about.description $descr
1258    $xmlobj put ${sequence}.index.label "Frame"
1259
1260    set frameNum 0
1261    set numLines [llength $data]
1262    for { set i 0 } { $i < $numLines } { incr i } {
1263        set line [lindex $data $i]
1264        set line [string trim $line]
1265        set contents {}
1266        if { [string match "MODEL*" $line] } {
1267            # Save the contents until we get an ENDMDL record.
1268            for {} { $i < $numLines } { incr i } {
1269                set line [lindex $data $i]
1270                set line [string trim $line]
1271                if { $line == "" } {
1272                    continue;           # Skip blank lines.
1273                }
1274                if { [string match "ENDMDL*" $line] } {
1275                    break;
1276                }
1277                append contents $line\n
1278            }
1279            set frame ${sequence}.element($frameNum)
1280            $xmlobj put ${frame}.index $frameNum
1281           
1282            set molecule ${frame}.structure.components.molecule
1283            $xmlobj put ${molecule}.pdb $contents
1284            $xmlobj put ${molecule}.formula $formula
1285            incr frameNum
1286        }
1287    }
1288}
1289
1290# ----------------------------------------------------------------------
1291# USAGE: _lammpsToSequence <xmlobj> ?<path>?
1292#
1293# If the molecule element is a trajectory, delete the original
1294# and create a sequence of individual molecules.
1295# Used internally to detect any molecule output elements that contain
1296# trajectory data.  Trajectories will be converted into sequences of
1297# individual molecules.  All other elements will be unaffected. Scans
1298# the entire xml tree if a starting path is not specified.
1299# ----------------------------------------------------------------------
1300itcl::body Rappture::Analyzer::_lammpsToSequence {xmlobj path id child data} {
1301
1302    set seqLabel [$xmlobj get ${child}.about.label]
1303    set descr    [$xmlobj get ${child}.about.description]
1304    set typemap  [$xmlobj get ${child}.components.molecule.lammpstypemap]
1305    $xmlobj remove $child
1306
1307    set sequence ${path}.sequence($id)
1308    $xmlobj put ${sequence}.about.label $seqLabel
1309    $xmlobj put ${sequence}.about.description $descr
1310    $xmlobj put ${sequence}.index.label "Frame"
1311
1312    set frameNum 0
1313    set frameContents ""
1314    set inModel 0
1315    foreach line $data {
1316        set line [string trim $line]
1317        if { $line == "" } {
1318            continue;                   # Skip blank lines
1319        }
1320        if {[regexp {^[\t ]*ITEM:[ \t]+ATOMS} $line] } {
1321            if { $inModel && $frameContents != "" } {
1322                set frame ${sequence}.element($frameNum)
1323                $xmlobj put ${frame}.index $frameNum
1324               
1325                set molecule ${frame}.structure.components.molecule
1326                $xmlobj put ${molecule}.lammps $frameContents
1327                $xmlobj put ${molecule}.lammpstypemap $typemap
1328               
1329                incr frameNum
1330                set frameContents ""
1331            }
1332            set inModel 1
1333        } elseif { [scan $line "%d %d %f %f %f" a b c d e] == 5 } {
1334            if { !$inModel } {
1335                puts stderr "found \"$line\" without previous \"ITEM: ATOMS\""
1336                set inModel 1
1337            }
1338            append frameContents $line\n
1339        }
1340    }
1341    if { $frameContents != "" } {
1342        set frame ${sequence}.element($frameNum)
1343        $xmlobj put ${frame}.index $frameNum
1344       
1345        set molecule ${frame}.structure.components.molecule
1346        $xmlobj put ${molecule}.lammps $frameContents
1347        $xmlobj put ${molecule}.lammpstypemap $typemap
1348    }
1349}
1350
1351# ----------------------------------------------------------------------
1352# USAGE: _trajToSequence <xmlobj> ?<path>?
1353#
1354#       Check for PDB and LAMMPS trajectories in molecule data and rewrite
1355#       the individual models as a sequence of molecules.  Used internally
1356#       to detect any molecule output elements that contain trajectory data.
1357#       Trajectories will be converted into sequences of individual molecules.
1358#       All other elements will be unaffected. Scans the entire xml tree if a
1359#       starting path is not specified. 
1360#
1361# ----------------------------------------------------------------------
1362itcl::body Rappture::Analyzer::_trajToSequence {xmlobj {path ""}} {
1363    # Remove leading dot from path, if present.
1364    if { [string index $path 0] == "." } {
1365        set path [string range $path 1 end]
1366    }
1367    # Otherwise check each child.
1368    foreach child [$xmlobj children $path] {
1369        set current ${path}.${child}
1370        if { [string match "structure*" $child] } {
1371            set isTraj [$xmlobj get ${current}.components.molecule.trajectory]
1372            if { $isTraj == "" || !$isTraj } {
1373                continue;               # Not a trajectory.
1374            }
1375            # Look for trajectory if molecule element found.  Check both pdb
1376            # data and lammps data.
1377            set type [$xmlobj element -as type $current]
1378            set id   [$xmlobj element -as id $current]
1379            set pdbdata    [$xmlobj get ${current}.components.molecule.pdb]
1380            set lammpsdata [$xmlobj get ${current}.components.molecule.lammps]
1381            if { $pdbdata != "" && $lammpsdata != "" } {
1382                puts stderr \
1383                    "found both <pdb> and <lammps> elements: picking pdb"
1384            }
1385            set pdbdata [split $pdbdata \n]
1386            set lammpsdata [split $lammpsdata \n]
1387            if { [_isPdbTrajectory $pdbdata] } {
1388                _pdbToSequence $xmlobj $path $id $current $pdbdata
1389            } elseif { [_isLammpsTrajectory $lammpsdata] } {
1390                _lammpsToSequence $xmlobj $path $id $current $lammpsdata
1391            }
1392            continue
1393        }
1394        if 0 {
1395        # Recurse over all child nodes.
1396        _trajToSequence $xmlobj $current
1397        }
1398    }
1399}
1400
1401# ----------------------------------------------------------------------
1402# CONFIGURATION OPTION: -simcontrol
1403#
1404# Controls whether or not the Simulate button is showing.  In some
1405# cases, it is not needed.
1406# ----------------------------------------------------------------------
1407itcl::configbody Rappture::Analyzer::simcontrol {
1408    _fixSimControl
1409}
1410
1411# ----------------------------------------------------------------------
1412# CONFIGURATION OPTION: -notebookpage
1413#
1414# Controls which page of the analyzer notebook is shown. It is
1415# particularly needed when using rerun, when you don't want to
1416# "simulate -ifneeded" because an actual simulation might be
1417# kicked off due to differences between tool.xml and run.xml
1418# ----------------------------------------------------------------------
1419itcl::configbody Rappture::Analyzer::notebookpage {
1420    _fixNotebook
1421}
Note: See TracBrowser for help on using the repository browser.