Changeset 1663


Ignore:
Timestamp:
Feb 19, 2010, 2:36:21 PM (15 years ago)
Author:
dkearney
Message:

updating the action when user presses Download from the Results menu. we always give the download button as the widget to reference where download related popups should be placed.

File:
1 edited

Legend:

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

    r1606 r1663  
    9999
    100100    itk_component add simbg {
    101         frame $itk_interior.simol.simbg -borderwidth 0
     101        frame $itk_interior.simol.simbg -borderwidth 0
    102102    } {
    103         usual
    104         rename -background -simcontrolcolor simControlColor Color
     103        usual
     104        rename -background -simcontrolcolor simControlColor Color
    105105    }
    106106    pack $itk_component(simbg) -expand yes -fill both
     
    108108    set simtxt [$tool xml get tool.action.label]
    109109    if {"" == $simtxt} {
    110         set simtxt "Simulate"
     110        set simtxt "Simulate"
    111111    }
    112112    itk_component add simulate {
    113         button $itk_component(simbg).simulate -text $simtxt \
    114             -command [itcl::code $this simulate]
     113        button $itk_component(simbg).simulate -text $simtxt \
     114            -command [itcl::code $this simulate]
    115115    } {
    116         usual
    117         rename -highlightbackground -simcontrolcolor simControlColor Color
     116        usual
     117        rename -highlightbackground -simcontrolcolor simControlColor Color
    118118    }
    119119    pack $itk_component(simulate) -side left -padx 4 -pady 4
     
    123123    set url [Rappture::Tool::resources -huburl]
    124124    if {"" != $url && "" != $_appName} {
    125         itk_component add hubcntls {
    126             frame $itk_component(simbg).hubcntls
    127         } {
    128             usual
    129             rename -background -simcontrolcolor simControlColor Color
    130         }
    131         pack $itk_component(hubcntls) -side right -padx 4
    132 
    133         itk_component add icon {
    134             label $itk_component(hubcntls).icon -image [Rappture::icon ask] \
    135                 -highlightthickness 0
    136         } {
    137             usual
    138             ignore -highlightthickness
    139             rename -background -simcontrolcolor simControlColor Color
    140         }
    141         pack $itk_component(icon) -side left
    142 
    143         itk_component add about {
    144             button $itk_component(hubcntls).about -text "About this tool" \
    145                 -command [list Rappture::filexfer::webpage \
    146                               "$url/tools/$_appName"]
    147         } {
    148             usual
    149             ignore -font
    150             rename -background -simcontrolcolor simControlColor Color
    151             rename -highlightbackground -simcontrolcolor simControlColor Color
    152         }
    153         pack $itk_component(about) -side top -anchor w
    154 
    155         itk_component add questions {
    156             button $itk_component(hubcntls).questions -text Questions? \
    157                 -command [list Rappture::filexfer::webpage \
    158                               "$url/resources/$_appName/questions"]
    159         } {
    160             usual
    161             ignore -font
    162             rename -background -simcontrolcolor simControlColor Color
    163             rename -highlightbackground -simcontrolcolor simControlColor Color
    164         }
    165         pack $itk_component(questions) -side top -anchor w
     125        itk_component add hubcntls {
     126            frame $itk_component(simbg).hubcntls
     127        } {
     128            usual
     129            rename -background -simcontrolcolor simControlColor Color
     130        }
     131        pack $itk_component(hubcntls) -side right -padx 4
     132
     133        itk_component add icon {
     134            label $itk_component(hubcntls).icon -image [Rappture::icon ask] \
     135                -highlightthickness 0
     136        } {
     137            usual
     138            ignore -highlightthickness
     139            rename -background -simcontrolcolor simControlColor Color
     140        }
     141        pack $itk_component(icon) -side left
     142
     143        itk_component add about {
     144            button $itk_component(hubcntls).about -text "About this tool" \
     145                -command [list Rappture::filexfer::webpage \
     146                              "$url/tools/$_appName"]
     147        } {
     148            usual
     149            ignore -font
     150            rename -background -simcontrolcolor simControlColor Color
     151            rename -highlightbackground -simcontrolcolor simControlColor Color
     152        }
     153        pack $itk_component(about) -side top -anchor w
     154
     155        itk_component add questions {
     156            button $itk_component(hubcntls).questions -text Questions? \
     157                -command [list Rappture::filexfer::webpage \
     158                              "$url/resources/$_appName/questions"]
     159        } {
     160            usual
     161            ignore -font
     162            rename -background -simcontrolcolor simControlColor Color
     163            rename -highlightbackground -simcontrolcolor simControlColor Color
     164        }
     165        pack $itk_component(questions) -side top -anchor w
    166166    }
    167167
    168168    itk_component add simstatus {
    169         text $itk_component(simbg).simstatus -borderwidth 0 \
    170             -highlightthickness 0 -height 1 -width 1 -wrap none \
    171             -state disabled
     169        text $itk_component(simbg).simstatus -borderwidth 0 \
     170            -highlightthickness 0 -height 1 -width 1 -wrap none \
     171            -state disabled
    172172    } {
    173         usual
    174         ignore -highlightthickness
    175         rename -background -simcontrolcolor simControlColor Color
    176         rename -font -textfont textFont Font
     173        usual
     174        ignore -highlightthickness
     175        rename -background -simcontrolcolor simControlColor Color
     176        rename -font -textfont textFont Font
    177177    }
    178178    pack $itk_component(simstatus) -side left -expand yes -fill x
    179179
    180180    $itk_component(simstatus) tag configure popup \
    181         -underline 1 -foreground blue
     181        -underline 1 -foreground blue
    182182
    183183    $itk_component(simstatus) tag bind popup \
    184         <Enter> {%W configure -cursor center_ptr}
     184        <Enter> {%W configure -cursor center_ptr}
    185185    $itk_component(simstatus) tag bind popup \
    186         <Leave> {%W configure -cursor ""}
     186        <Leave> {%W configure -cursor ""}
    187187    $itk_component(simstatus) tag bind popup \
    188         <ButtonPress> {after idle {Rappture::Tooltip::tooltip show %W}}
     188        <ButtonPress> {after idle {Rappture::Tooltip::tooltip show %W}}
    189189
    190190
    191191    itk_component add notebook {
    192         Rappture::Notebook $itk_interior.nb
     192        Rappture::Notebook $itk_interior.nb
    193193    }
    194194    pack $itk_interior.nb -expand yes -fill both
     
    202202    pack $w.info -expand yes -fill both -padx 4 -pady 20
    203203    itk_component add toolinfo {
    204         text $w.info.text -width 1 -height 1 -wrap word \
    205             -borderwidth 0 -highlightthickness 0
     204        text $w.info.text -width 1 -height 1 -wrap word \
     205            -borderwidth 0 -highlightthickness 0
    206206    } {
    207         usual
    208         ignore -borderwidth -relief
    209         rename -font -textfont textFont Font
     207        usual
     208        ignore -borderwidth -relief
     209        rename -font -textfont textFont Font
    210210    }
    211211    $w.info contents $w.info.text
     
    221221
    222222    itk_component add abort {
    223         button $w.cntls.abort -text "Abort" \
    224             -command [itcl::code $_tool abort]
     223        button $w.cntls.abort -text "Abort" \
     224            -command [itcl::code $_tool abort]
    225225    }
    226226    pack $itk_component(abort) -side left -expand yes -padx 4 -pady 4
     
    229229    pack $w.info -expand yes -fill both -padx 4 -pady 4
    230230    itk_component add runinfo {
    231         text $w.info.text -width 1 -height 1 -wrap none \
    232             -borderwidth 0 -highlightthickness 0 \
    233             -state disabled
     231        text $w.info.text -width 1 -height 1 -wrap none \
     232            -borderwidth 0 -highlightthickness 0 \
     233            -state disabled
    234234    } {
    235         usual
    236         ignore -borderwidth -relief
    237         rename -font -codefont codeFont Font
     235        usual
     236        ignore -borderwidth -relief
     237        rename -font -codefont codeFont Font
    238238    }
    239239    $w.info contents $w.info.text
    240240
    241241    itk_component add progress {
    242         Rappture::Progress $w.progress
     242        Rappture::Progress $w.progress
    243243    }
    244244
     
    254254
    255255    itk_component add resultselector {
    256         Rappture::Combobox $w.top.sel -width 10 -editable no
     256        Rappture::Combobox $w.top.sel -width 10 -editable no
    257257    } {
    258         usual
    259         rename -font -textfont textFont Font
     258        usual
     259        rename -font -textfont textFont Font
    260260    }
    261261    pack $itk_component(resultselector) -side left -expand yes -fill x
    262262    bind $itk_component(resultselector) <<Value>> [itcl::code $this _fixResult]
    263263    bind $itk_component(resultselector) <Enter> \
    264         [itcl::code $this download coming]
     264        [itcl::code $this download coming]
    265265
    266266    Rappture::Tooltip::for $itk_component(resultselector) \
    267         "@[itcl::code $this _resultTooltip]"
     267        "@[itcl::code $this _resultTooltip]"
    268268
    269269    $itk_component(resultselector) choices insert end \
    270         --- "---"
     270        --- "---"
    271271
    272272    itk_component add download {
    273         button $w.top.dl -image [Rappture::icon download] -anchor e \
    274             -borderwidth 1 -relief flat -overrelief raised \
    275             -command [itcl::code $this download start $w.top.dl]
     273        button $w.top.dl -image [Rappture::icon download] -anchor e \
     274            -borderwidth 1 -relief flat -overrelief raised \
     275            -command [itcl::code $this download start $w.top.dl]
    276276    }
    277277    pack $itk_component(download) -side right -padx {4 0}
    278278    bind $itk_component(download) <Enter> \
    279         [itcl::code $this download coming]
     279        [itcl::code $this download coming]
    280280
    281281    $itk_component(resultselector) choices insert end \
    282         @download [Rappture::filexfer::label download]
     282        @download [Rappture::filexfer::label download]
    283283
    284284    if {[Rappture::filexfer::enabled]} {
    285         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.
     285        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.
    286286
    287287NOTE:  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."
    288288    } else {
    289         Rappture::Tooltip::for $itk_component(download) "Saves the current result to a file on your desktop."
     289        Rappture::Tooltip::for $itk_component(download) "Saves the current result to a file on your desktop."
    290290    }
    291291
    292292    itk_component add results {
    293         Rappture::Panes $w.pane -sashwidth 1 -sashrelief solid -sashpadding {4 0}
     293        Rappture::Panes $w.pane -sashwidth 1 -sashrelief solid -sashpadding {4 0}
    294294    }
    295295    pack $itk_component(results) -expand yes -fill both
     
    297297
    298298    itk_component add resultpages {
    299         Rappture::Notebook $f.nb
     299        Rappture::Notebook $f.nb
    300300    }
    301301    pack $itk_component(resultpages) -expand yes -fill both
     
    303303    set f [$itk_component(results) insert end -fraction 0.1]
    304304    itk_component add resultset {
    305         Rappture::ResultSet $f.rset \
    306             -clearcommand [itcl::code $this clear] \
    307             -settingscommand [itcl::code $this _plot] \
    308             -promptcommand [itcl::code $this _simState]
     305        Rappture::ResultSet $f.rset \
     306            -clearcommand [itcl::code $this clear] \
     307            -settingscommand [itcl::code $this _plot] \
     308            -promptcommand [itcl::code $this _simState]
    309309    }
    310310    pack $itk_component(resultset) -expand yes -fill both
     
    321321    #
    322322    $itk_component(toolinfo) tag configure title \
    323         -font $itk_option(-boldtextfont)
     323        -font $itk_option(-boldtextfont)
    324324
    325325    set mesg [$tool xml get tool.title]
    326326    if {"" != $mesg} {
    327         $itk_component(toolinfo) insert end $mesg title
    328         $itk_component(toolinfo) insert end "\n\n"
     327        $itk_component(toolinfo) insert end $mesg title
     328        $itk_component(toolinfo) insert end "\n\n"
    329329    }
    330330
    331331    set mesg [$tool xml get tool.about]
    332332    if {"" != $mesg} {
    333         $itk_component(toolinfo) insert end $mesg
     333        $itk_component(toolinfo) insert end $mesg
    334334    }
    335335    $itk_component(toolinfo) configure -state disabled
     
    339339    set cntl [$tool xml get tool.control]
    340340    if {"" == $cntl} {
    341         set cntl [$tool xml get tool.control.type]
     341        set cntl [$tool xml get tool.control.type]
    342342    }
    343343    if {"" != $cntl} {
    344         set _control $cntl
     344        set _control $cntl
    345345    }
    346346
     
    354354itcl::body Rappture::Analyzer::destructor {} {
    355355    foreach obj $_runs {
    356         itcl::delete object $obj
     356        itcl::delete object $obj
    357357    }
    358358    after cancel [itcl::code $this simulate]
     
    371371itcl::body Rappture::Analyzer::simulate {args} {
    372372    if {$args == "-ifneeded"} {
    373         # check to see if simulation is really needed
    374         $_tool sync
    375         if {[$itk_component(resultset) contains [$_tool xml object]]
    376               && ![string equal $_control "manual-resim"]} {
    377             # not needed -- show results and return
    378             $itk_component(notebook) current analyze
    379             return
    380         }
    381         set args ""
     373        # check to see if simulation is really needed
     374        $_tool sync
     375        if {[$itk_component(resultset) contains [$_tool xml object]]
     376              && ![string equal $_control "manual-resim"]} {
     377            # not needed -- show results and return
     378            $itk_component(notebook) current analyze
     379            return
     380        }
     381        set args ""
    382382    }
    383383
     
    397397    # if the hold window is set, then put up a busy cursor
    398398    if {$itk_option(-holdwindow) != ""} {
    399         blt::busy hold $itk_option(-holdwindow)
    400         raise $itk_component(hull)
     399        blt::busy hold $itk_option(-holdwindow)
     400        raise $itk_component(hull)
    401401    }
    402402
     
    406406    # if job was aborted, then allow simulation again
    407407    if {$result == "ABORT"} {
    408         _simState on "Aborted"
     408        _simState on "Aborted"
    409409    }
    410410
    411411    # load results from run.xml into analyzer
    412412    if {$status == 0 && $result != "ABORT"} {
    413         set status [catch {load $result} result]
     413        set status [catch {load $result} result]
    414414    }
    415415
    416416    # back to normal
    417417    if {$itk_option(-holdwindow) != ""} {
    418         blt::busy release $itk_option(-holdwindow)
     418        blt::busy release $itk_option(-holdwindow)
    419419    }
    420420    $itk_component(abort) configure -state disabled
    421421
    422422    if {$status != 0} {
    423         $itk_component(runinfo) configure -state normal
    424         $itk_component(runinfo) delete 1.0 end
    425         $itk_component(runinfo) insert end "Problem launching job:\n\n" text
    426         _simOutput $result
    427         $itk_component(runinfo) configure -state disabled
    428         $itk_component(runinfo) see 1.0
    429 
    430         # Try to create a support ticket for this error.
    431         # It may be a real problem.
    432         if {[Rappture::bugreport::shouldReport for jobs]} {
    433             Rappture::bugreport::register "Problem launching job:\n\n$result\n== RAPPTURE INPUT ==\n[$_tool xml xml]"
    434         }
     423        $itk_component(runinfo) configure -state normal
     424        $itk_component(runinfo) delete 1.0 end
     425        $itk_component(runinfo) insert end "Problem launching job:\n\n" text
     426        _simOutput $result
     427        $itk_component(runinfo) configure -state disabled
     428        $itk_component(runinfo) see 1.0
     429
     430        # Try to create a support ticket for this error.
     431        # It may be a real problem.
     432        if {[Rappture::bugreport::shouldReport for jobs]} {
     433            Rappture::bugreport::register "Problem launching job:\n\n$result\n== RAPPTURE INPUT ==\n[$_tool xml xml]"
     434        }
    435435    } else {
    436         $itk_component(notebook) current analyze
     436        $itk_component(notebook) current analyze
    437437    }
    438438
     
    451451itcl::body Rappture::Analyzer::reset {{when -eventually}} {
    452452    if {$when == "-eventually"} {
    453         after cancel [list catch [itcl::code $this reset -now]]
    454         after idle [list catch [itcl::code $this reset -now]]
    455         return
     453        after cancel [list catch [itcl::code $this reset -now]]
     454        after idle [list catch [itcl::code $this reset -now]]
     455        return
    456456    }
    457457
     
    459459    $_tool sync
    460460    if {![$itk_component(resultset) contains [$_tool xml object]]
    461           || [string equal $_control "manual-resim"]} {
    462         # if control mode is "auto", then simulate right away
    463         if {[string match auto* $_control]} {
    464             # auto control -- don't need button
    465             pack forget $itk_interior.simol
    466 
    467             after cancel [itcl::code $this simulate]
    468             after idle [itcl::code $this simulate]
    469         } else {
    470             _simState on "new input parameters"
    471         }
     461          || [string equal $_control "manual-resim"]} {
     462        # if control mode is "auto", then simulate right away
     463        if {[string match auto* $_control]} {
     464            # auto control -- don't need button
     465            pack forget $itk_interior.simol
     466
     467            after cancel [itcl::code $this simulate]
     468            after idle [itcl::code $this simulate]
     469        } else {
     470            _simState on "new input parameters"
     471        }
    472472    } else {
    473         _simState off
     473        _simState off
    474474    }
    475475}
     
    484484    # only show the last result? then clear first
    485485    if {[$_tool xml get tool.analyzer] == "last"} {
    486         clear
     486        clear
    487487    }
    488488
     
    490490    # each run.xml is loaded as a previous simulation.
    491491    foreach item [$xmlobj children -type run output.load] {
    492         set loadfile [$xmlobj get output.load.$item]
    493         set loadobj [Rappture::library $loadfile]
    494         load $loadobj
     492        set loadfile [$xmlobj get output.load.$item]
     493        set loadobj [Rappture::library $loadfile]
     494        load $loadobj
    495495    }
    496496
    497497    foreach item [$xmlobj children -type run output.include] {
    498         set id [$xmlobj element -as id output.include.$item]
    499         set inclfile [$xmlobj get output.include.$item]
    500         set inclobj [Rappture::library $inclfile]
    501         foreach c [$inclobj children output] {
    502             switch -glob -- $c {
    503                 # we don't want to include these tags
    504                 include* - time* - status* - user* {
    505                     continue
    506                 }
    507                 default {
    508                     set oldid [$inclobj element -as id output.$c]
    509                     set oldtype [$inclobj element -as type output.$c]
    510                     set newcomp "$oldtype\($id-$oldid\)"
    511                     $xmlobj copy output.$newcomp from $inclobj output.$c
    512                 }
    513             }
    514         }
     498        set id [$xmlobj element -as id output.include.$item]
     499        set inclfile [$xmlobj get output.include.$item]
     500        set inclobj [Rappture::library $inclfile]
     501        foreach c [$inclobj children output] {
     502            switch -glob -- $c {
     503                # we don't want to include these tags
     504                include* - time* - status* - user* {
     505                    continue
     506                }
     507                default {
     508                    set oldid [$inclobj element -as id output.$c]
     509                    set oldtype [$inclobj element -as type output.$c]
     510                    set newcomp "$oldtype\($id-$oldid\)"
     511                    $xmlobj copy output.$newcomp from $inclobj output.$c
     512                }
     513            }
     514        }
    515515    }
    516516
     
    520520    set haveresults 0
    521521    foreach item [_reorder [$xmlobj children output]] {
    522         switch -glob -- $item {
    523             log* {
    524                 _autoLabel $xmlobj output.$item "Output Log" counters
    525             }
    526             number* {
    527                 _autoLabel $xmlobj output.$item "Number" counters
    528             }
    529             integer* {
    530                 _autoLabel $xmlobj output.$item "Integer" counters
    531             }
    532             string* {
    533                 _autoLabel $xmlobj output.$item "String" counters
    534             }
    535             histogram* - curve* - field* {
    536                 _autoLabel $xmlobj output.$item "Plot" counters
    537             }
    538             structure* {
    539                 _autoLabel $xmlobj output.$item "Structure" counters
    540             }
    541             table* {
    542                 _autoLabel $xmlobj output.$item "Energy Levels" counters
    543             }
    544             sequence* {
    545                 _autoLabel $xmlobj output.$item "Sequence" counters
    546             }
    547         }
    548         set label [$xmlobj get output.$item.about.group]
    549         if {"" == $label} {
    550             set label [$xmlobj get output.$item.about.label]
    551         }
    552 
    553         set hidden [$xmlobj get output.$item.hide]
    554         set hidden [expr {"" != $hidden && $hidden}]
    555 
    556         if {"" != $label && !$hidden} {
    557             set haveresults 1
    558         }
     522        switch -glob -- $item {
     523            log* {
     524                _autoLabel $xmlobj output.$item "Output Log" counters
     525            }
     526            number* {
     527                _autoLabel $xmlobj output.$item "Number" counters
     528            }
     529            integer* {
     530                _autoLabel $xmlobj output.$item "Integer" counters
     531            }
     532            string* {
     533                _autoLabel $xmlobj output.$item "String" counters
     534            }
     535            histogram* - curve* - field* {
     536                _autoLabel $xmlobj output.$item "Plot" counters
     537            }
     538            structure* {
     539                _autoLabel $xmlobj output.$item "Structure" counters
     540            }
     541            table* {
     542                _autoLabel $xmlobj output.$item "Energy Levels" counters
     543            }
     544            sequence* {
     545                _autoLabel $xmlobj output.$item "Sequence" counters
     546            }
     547        }
     548        set label [$xmlobj get output.$item.about.group]
     549        if {"" == $label} {
     550            set label [$xmlobj get output.$item.about.label]
     551        }
     552
     553        set hidden [$xmlobj get output.$item.hide]
     554        set hidden [expr {"" != $hidden && $hidden}]
     555
     556        if {"" != $label && !$hidden} {
     557            set haveresults 1
     558        }
    559559    }
    560560
    561561    # if there are any valid results, add them to the resultset
    562562    if {$haveresults} {
    563         set index [$itk_component(resultset) add $xmlobj]
    564 
    565         # add each result to a result viewer
    566         foreach item [_reorder [$xmlobj children output]] {
    567             set label [$xmlobj get output.$item.about.group]
    568             if {"" == $label} {
    569                 set label [$xmlobj get output.$item.about.label]
    570             }
    571 
    572             set hidden [$xmlobj get output.$item.hide]
    573             set hidden [expr {"" != $hidden && $hidden}]
    574 
    575             if {"" != $label && !$hidden} {
    576                 if {![info exists _label2page($label)]} {
    577                     set name "page[incr _pages]"
    578                     set page [$itk_component(resultpages) insert end $name]
    579                     set _label2page($label) $page
    580                     set _label2desc($label) \
    581                         [$xmlobj get output.$item.about.description]
    582                     Rappture::ResultViewer $page.rviewer
    583                     pack $page.rviewer -expand yes -fill both -pady 4
    584 
    585                     set end [$itk_component(resultselector) \
    586                         choices index -value ---]
    587                     if {$end < 0} {
    588                         set end "end"
    589                     }
    590                     $itk_component(resultselector) choices insert $end \
    591                         $name $label
    592                 }
    593 
    594                 # add/replace the latest result into this viewer
    595                 set page $_label2page($label)
    596 
    597                 if {![info exists reset($page)]} {
    598                     $page.rviewer clear $index
    599                     set reset($page) 1
    600                 }
    601                 $page.rviewer add $index $xmlobj output.$item
    602             }
    603         }
     563        set index [$itk_component(resultset) add $xmlobj]
     564
     565        # add each result to a result viewer
     566        foreach item [_reorder [$xmlobj children output]] {
     567            set label [$xmlobj get output.$item.about.group]
     568            if {"" == $label} {
     569                set label [$xmlobj get output.$item.about.label]
     570            }
     571
     572            set hidden [$xmlobj get output.$item.hide]
     573            set hidden [expr {"" != $hidden && $hidden}]
     574
     575            if {"" != $label && !$hidden} {
     576                if {![info exists _label2page($label)]} {
     577                    set name "page[incr _pages]"
     578                    set page [$itk_component(resultpages) insert end $name]
     579                    set _label2page($label) $page
     580                    set _label2desc($label) \
     581                        [$xmlobj get output.$item.about.description]
     582                    Rappture::ResultViewer $page.rviewer
     583                    pack $page.rviewer -expand yes -fill both -pady 4
     584
     585                    set end [$itk_component(resultselector) \
     586                        choices index -value ---]
     587                    if {$end < 0} {
     588                        set end "end"
     589                    }
     590                    $itk_component(resultselector) choices insert $end \
     591                        $name $label
     592                }
     593
     594                # add/replace the latest result into this viewer
     595                set page $_label2page($label)
     596
     597                if {![info exists reset($page)]} {
     598                    $page.rviewer clear $index
     599                    set reset($page) 1
     600                }
     601                $page.rviewer add $index $xmlobj output.$item
     602            }
     603        }
    604604    }
    605605
     
    607607    set max [$itk_component(resultselector) choices size]
    608608    for {set i 0} {$i < $max} {incr i} {
    609         set first [$itk_component(resultselector) choices get -label $i]
    610         if {$first != ""} {
    611             set page [$itk_component(resultselector) choices get -value $i]
    612             set char [string index $page 0]
    613             if {$char != "@" && $char != "-"} {
    614                 $itk_component(resultpages) current $page
    615                 $itk_component(resultselector) value $first
    616                 set _lastlabel $first
    617                 break
    618             }
    619         }
     609        set first [$itk_component(resultselector) choices get -label $i]
     610        if {$first != ""} {
     611            set page [$itk_component(resultselector) choices get -value $i]
     612            set char [string index $page 0]
     613            if {$char != "@" && $char != "-"} {
     614                $itk_component(resultpages) current $page
     615                $itk_component(resultselector) value $first
     616                set _lastlabel $first
     617                break
     618            }
     619        }
    620620    }
    621621}
     
    628628itcl::body Rappture::Analyzer::clear {} {
    629629    foreach obj $_runs {
    630         itcl::delete object $obj
     630        itcl::delete object $obj
    631631    }
    632632    set _runs ""
     
    641641
    642642    foreach label [array names _label2page] {
    643         set page $_label2page($label)
    644         $page.rviewer clear
     643        set page $_label2page($label)
     644        $page.rviewer clear
    645645    }
    646646    $itk_component(resultselector) value ""
     
    652652    $itk_component(resultselector) choices insert end --- "---"
    653653    $itk_component(resultselector) choices insert end \
    654         @download [Rappture::filexfer::label download]
     654        @download [Rappture::filexfer::label download]
    655655    set _lastlabel ""
    656656
     
    682682
    683683    switch -- $option {
    684         coming {
    685             #
    686             # Warn result that a download is coming, in case
    687             # it needs to take a screen snap.
    688             #
    689             if {![regexp {^(|@download|---)$} $page]} {
    690                 set f [$itk_component(resultpages) page $page]
    691                 $f.rviewer download coming
    692             }
    693         }
    694         controls {
    695             # no controls for this download yet
    696             return ""
    697         }
    698         start {
    699             set widget $itk_component(download)
    700             if {[llength $args] > 0} {
    701                 set widget [lindex $args 0]
    702                 if {[catch {winfo class $widget}]} {
    703                     set widget $itk_component(download)
    704                 }
    705             }
    706             #
    707             # See if this download has any controls.  If so, then
    708             # post them now and let the user continue the download
    709             # after selecting a file format.
    710             #
    711             if {$page != ""} {
    712                 set ext ""
    713                 set f [$itk_component(resultpages) page $page]
    714                 set arg [itcl::code $this download now $widget]
    715                 set popup [$f.rviewer download controls $arg]
    716                 if {"" != $popup} {
    717                     $popup activate $widget below
    718                 } else {
    719                     download now $widget
    720                 }
    721             } else {
    722                 # this shouldn't happen
    723                 set file error.html
    724                 set data "<h1>Not Found</h1>There is no result selected."
    725             }
    726         }
    727         now {
    728             set widget $itk_component(download)
    729             if {[llength $args] > 0} {
    730                 set widget [lindex $args 0]
    731                 if {[catch {winfo class $widget}]} {
    732                     set widget $itk_component(download)
    733                 }
    734             }
    735             #
    736             # Perform the actual download.
    737             #
    738             if {$page != ""} {
    739                 set ext ""
    740                 set f [$itk_component(resultpages) page $page]
    741                 set item [$itk_component(resultselector) value]
    742                 set result [$f.rviewer download now $widget $_appName $item]
    743                 if { $result == "" } {
    744                     return;             # User cancelled the download.
    745                 }
    746                 foreach {ext data} $result break
    747                 if {"" == $ext} {
    748                     if {"" != $widget} {
    749                         Rappture::Tooltip::cue $widget \
    750                             "Can't download this result."
    751                     }
    752                     return
    753                 }
    754                 regsub -all {[\ -\/\:-\@\{-\~]} $title {} title
    755                 set file "$title$ext"
    756             } else {
    757                 # this shouldn't happen
    758                 set file error.html
    759                 set data "<h1>Not Found</h1>There is no result selected."
    760             }
    761 
    762             set mesg [Rappture::filexfer::download $data $file]
    763             if {[string length $mesg] > 0} {
    764                 Rappture::Tooltip::cue $widget $mesg
    765             }
    766         }
    767         default {
    768             error "bad option \"$option\": should be coming, controls, now, start"
    769         }
     684        coming {
     685            #
     686            # Warn result that a download is coming, in case
     687            # it needs to take a screen snap.
     688            #
     689            if {![regexp {^(|@download|---)$} $page]} {
     690                set f [$itk_component(resultpages) page $page]
     691                $f.rviewer download coming
     692            }
     693        }
     694        controls {
     695            # no controls for this download yet
     696            return ""
     697        }
     698        start {
     699            set widget $itk_component(download)
     700            if {[llength $args] > 0} {
     701                set widget [lindex $args 0]
     702                if {[catch {winfo class $widget}]} {
     703                    set widget $itk_component(download)
     704                }
     705            }
     706            #
     707            # See if this download has any controls.  If so, then
     708            # post them now and let the user continue the download
     709            # after selecting a file format.
     710            #
     711            if {$page != ""} {
     712                set ext ""
     713                set f [$itk_component(resultpages) page $page]
     714                set arg [itcl::code $this download now $widget]
     715                set popup [$f.rviewer download controls $arg]
     716                if {"" != $popup} {
     717                    $popup activate $widget below
     718                } else {
     719                    download now $widget
     720                }
     721            } else {
     722                # this shouldn't happen
     723                set file error.html
     724                set data "<h1>Not Found</h1>There is no result selected."
     725            }
     726        }
     727        now {
     728            set widget $itk_component(download)
     729            if {[llength $args] > 0} {
     730                set widget [lindex $args 0]
     731                if {[catch {winfo class $widget}]} {
     732                    set widget $itk_component(download)
     733                }
     734            }
     735            #
     736            # Perform the actual download.
     737            #
     738            if {$page != ""} {
     739                set ext ""
     740                set f [$itk_component(resultpages) page $page]
     741                set item [$itk_component(resultselector) value]
     742                set result [$f.rviewer download now $widget $_appName $item]
     743                if { $result == "" } {
     744                    return;                # User cancelled the download.
     745                }
     746                foreach {ext data} $result break
     747                if {"" == $ext} {
     748                    if {"" != $widget} {
     749                        Rappture::Tooltip::cue $widget \
     750                            "Can't download this result."
     751                    }
     752                    return
     753                }
     754                regsub -all {[\ -\/\:-\@\{-\~]} $title {} title
     755                set file "$title$ext"
     756            } else {
     757                # this shouldn't happen
     758                set file error.html
     759                set data "<h1>Not Found</h1>There is no result selected."
     760            }
     761
     762            set mesg [Rappture::filexfer::download $data $file]
     763            if {[string length $mesg] > 0} {
     764                Rappture::Tooltip::cue $widget $mesg
     765            }
     766        }
     767        default {
     768            error "bad option \"$option\": should be coming, controls, now, start"
     769        }
    770770    }
    771771}
     
    784784    set page [$itk_component(resultselector) translate $page]
    785785    if {"" != $page} {
    786         set f [$itk_component(resultpages) page $page]
    787         $f.rviewer plot clear
    788         foreach {index opts} $_plotlist {
    789             $f.rviewer plot add $index $opts
    790         }
     786        set f [$itk_component(resultpages) page $page]
     787        $f.rviewer plot clear
     788        foreach {index opts} $_plotlist {
     789            $f.rviewer plot add $index $opts
     790        }
    791791    }
    792792}
     
    803803    set max [llength $comps]
    804804    while {$i < $max} {
    805         set c [lindex $comps $i]
    806         if {[string match log* $c]} {
    807             set comps [lreplace $comps $i $i]
    808             lappend comps $c
    809             incr max -1
    810         } else {
    811             incr i
    812         }
     805        set c [lindex $comps $i]
     806        if {[string match log* $c]} {
     807            set comps [lreplace $comps $i $i]
     808            lappend comps $c
     809            incr max -1
     810        } else {
     811            incr i
     812        }
    813813    }
    814814    return $comps
     
    834834    set label [$xmlobj get $path.about.label]
    835835    if {"" == $label} {
    836         # no label -- make one up using the title specified
    837         if {![info exists counters($group-$title)]} {
    838             set counters($group-$title) 1
    839             set label $title
    840         } else {
    841             set label "$title (#[incr counters($group-$title)])"
    842         }
    843         $xmlobj put $path.about.label $label
     836        # no label -- make one up using the title specified
     837        if {![info exists counters($group-$title)]} {
     838            set counters($group-$title) 1
     839            set label $title
     840        } else {
     841            set label "$title (#[incr counters($group-$title)])"
     842        }
     843        $xmlobj put $path.about.label $label
    844844    } else {
    845         # handle the case of two identical labels in <output>
    846         if {![info exists counters($group-$label)]} {
    847             set counters($group-$label) 1
    848         } else {
    849             set label "$label (#[incr counters($group-$label)])"
    850             $xmlobj put $path.about.label $label
    851         }
     845        # handle the case of two identical labels in <output>
     846        if {![info exists counters($group-$label)]} {
     847            set counters($group-$label) 1
     848        } else {
     849            set label "$label (#[incr counters($group-$label)])"
     850            $xmlobj put $path.about.label $label
     851        }
    852852    }
    853853    return $label
     
    864864    set page ""
    865865    if {"" != $name} {
    866         set page [$itk_component(resultselector) translate $name]
     866        set page [$itk_component(resultselector) translate $name]
    867867    }
    868868    if {$page == "@download"} {
    869         # put the combobox back to its last value
    870         $itk_component(resultselector) component entry configure -state normal
    871         $itk_component(resultselector) component entry delete 0 end
    872         $itk_component(resultselector) component entry insert end $_lastlabel
    873         $itk_component(resultselector) component entry configure -state disabled
    874         # perform the actual download
    875         download start $itk_component(resultselector)
     869        # put the combobox back to its last value
     870        $itk_component(resultselector) component entry configure -state normal
     871        $itk_component(resultselector) component entry delete 0 end
     872        $itk_component(resultselector) component entry insert end $_lastlabel
     873        $itk_component(resultselector) component entry configure -state disabled
     874        # perform the actual download
     875        download start $itk_component(download)
    876876    } elseif {$page == "---"} {
    877         # put the combobox back to its last value
    878         $itk_component(resultselector) component entry configure -state normal
    879         $itk_component(resultselector) component entry delete 0 end
    880         $itk_component(resultselector) component entry insert end $_lastlabel
    881         $itk_component(resultselector) component entry configure -state disabled
     877        # put the combobox back to its last value
     878        $itk_component(resultselector) component entry configure -state normal
     879        $itk_component(resultselector) component entry delete 0 end
     880        $itk_component(resultselector) component entry insert end $_lastlabel
     881        $itk_component(resultselector) component entry configure -state disabled
    882882    } elseif {$page != ""} {
    883         set _lastlabel $name
    884         set win [winfo toplevel $itk_component(hull)]
    885         blt::busy hold $win
    886         $itk_component(resultpages) current $page
    887 
    888         set f [$itk_component(resultpages) page $page]
    889         $f.rviewer plot clear
    890         eval $f.rviewer plot add $_plotlist
    891         blt::busy release [winfo toplevel $itk_component(hull)]
     883        set _lastlabel $name
     884        set win [winfo toplevel $itk_component(hull)]
     885        blt::busy hold $win
     886        $itk_component(resultpages) current $page
     887
     888        set f [$itk_component(resultpages) page $page]
     889        $f.rviewer plot clear
     890        eval $f.rviewer plot add $_plotlist
     891        blt::busy release [winfo toplevel $itk_component(hull)]
    892892    }
    893893}
     
    907907
    908908    if {$frac < 0.4} {
    909         $itk_component(results) fraction end $frac
     909        $itk_component(results) fraction end $frac
    910910    }
    911911    _fixSimControl
     
    926926itcl::body Rappture::Analyzer::_simState {state args} {
    927927    if {$state} {
    928         $itk_interior.simol configure \
    929             -background $itk_option(-simcontrolactiveoutline)
    930         configure -simcontrolcolor $itk_option(-simcontrolactivebackground)
    931 
    932         $itk_component(abort) configure -state disabled
    933         $itk_component(simulate) configure -state normal \
    934             -command [itcl::code $this simulate]
    935 
    936         #
    937         # If there's a special message, then put it up next to the button.
    938         #
    939         set mesg [lindex $args 0]
    940         if {"" != $mesg} {
    941             $itk_component(simstatus) configure -state normal
    942             $itk_component(simstatus) delete 1.0 end
    943             $itk_component(simstatus) insert end $mesg
    944 
    945             #
    946             # If there are any settings, then install them in the
    947             # "Simulate" button.  Also, pop them up as a tooltip
    948             # for the message.
    949             #
    950             set settings [lindex $args 1]
    951             if {[llength $settings] > 0} {
    952                 $itk_component(simulate) configure \
    953                     -command [eval itcl::code $this simulate $settings]
    954 
    955                 set details ""
    956                 foreach {path val} $settings {
    957                     set str [$_tool xml get $path.about.label]
    958                     if {"" == $str} {
    959 1                       set str [$_tool xml element -as id $path]
    960                     }
    961                     append details "$str = $val\n"
    962                 }
    963                 set details [string trim $details]
    964 
    965                 Rappture::Tooltip::for $itk_component(simstatus) $details
    966                 $itk_component(simstatus) insert end " "
    967                 $itk_component(simstatus) insert end "(details...)" popup
    968             }
    969             $itk_component(simstatus) configure -state disabled
    970         }
     928        $itk_interior.simol configure \
     929            -background $itk_option(-simcontrolactiveoutline)
     930        configure -simcontrolcolor $itk_option(-simcontrolactivebackground)
     931
     932        $itk_component(abort) configure -state disabled
     933        $itk_component(simulate) configure -state normal \
     934            -command [itcl::code $this simulate]
     935
     936        #
     937        # If there's a special message, then put it up next to the button.
     938        #
     939        set mesg [lindex $args 0]
     940        if {"" != $mesg} {
     941            $itk_component(simstatus) configure -state normal
     942            $itk_component(simstatus) delete 1.0 end
     943            $itk_component(simstatus) insert end $mesg
     944
     945            #
     946            # If there are any settings, then install them in the
     947            # "Simulate" button.  Also, pop them up as a tooltip
     948            # for the message.
     949            #
     950            set settings [lindex $args 1]
     951            if {[llength $settings] > 0} {
     952                $itk_component(simulate) configure \
     953                    -command [eval itcl::code $this simulate $settings]
     954
     955                set details ""
     956                foreach {path val} $settings {
     957                    set str [$_tool xml get $path.about.label]
     958                    if {"" == $str} {
     9591                        set str [$_tool xml element -as id $path]
     960                    }
     961                    append details "$str = $val\n"
     962                }
     963                set details [string trim $details]
     964
     965                Rappture::Tooltip::for $itk_component(simstatus) $details
     966                $itk_component(simstatus) insert end " "
     967                $itk_component(simstatus) insert end "(details...)" popup
     968            }
     969            $itk_component(simstatus) configure -state disabled
     970        }
    971971    } else {
    972         if {"" != $itk_option(-simcontrolbackground)} {
    973             set simcbg $itk_option(-simcontrolbackground)
    974         } else {
    975             set simcbg $itk_option(-background)
    976         }
    977         $itk_interior.simol configure \
    978             -background $itk_option(-simcontroloutline)
    979         configure -simcontrolcolor $simcbg
    980 
    981         $itk_component(simulate) configure -state disabled
    982         $itk_component(abort) configure -state normal
    983 
    984         $itk_component(simstatus) configure -state normal
    985         $itk_component(simstatus) delete 1.0 end
    986         set mesg [lindex $args 0]
    987         if {"" != $mesg} {
    988             $itk_component(simstatus) insert end $mesg
    989         }
    990         $itk_component(simstatus) configure -state disabled
     972        if {"" != $itk_option(-simcontrolbackground)} {
     973            set simcbg $itk_option(-simcontrolbackground)
     974        } else {
     975            set simcbg $itk_option(-background)
     976        }
     977        $itk_interior.simol configure \
     978            -background $itk_option(-simcontroloutline)
     979        configure -simcontrolcolor $simcbg
     980
     981        $itk_component(simulate) configure -state disabled
     982        $itk_component(abort) configure -state normal
     983
     984        $itk_component(simstatus) configure -state normal
     985        $itk_component(simstatus) delete 1.0 end
     986        set mesg [lindex $args 0]
     987        if {"" != $mesg} {
     988            $itk_component(simstatus) insert end $mesg
     989        }
     990        $itk_component(simstatus) configure -state disabled
    991991    }
    992992}
     
    10081008    #
    10091009    while {[regexp -indices \
    1010                {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)} $message \
    1011                 match percent mesg]} {
    1012 
    1013         foreach {i0 i1} $percent break
    1014         set percent [string range $message $i0 $i1]
    1015 
    1016         foreach {i0 i1} $mesg break
    1017         set mesg [string range $message $i0 $i1]
    1018 
    1019         pack $itk_component(progress) -fill x -padx 10 -pady 10
    1020         $itk_component(progress) settings -percent $percent -message $mesg
    1021 
    1022         foreach {i0 i1} $match break
    1023         set message [string replace $message $i0 $i1]
     1010               {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)} $message \
     1011                match percent mesg]} {
     1012
     1013        foreach {i0 i1} $percent break
     1014        set percent [string range $message $i0 $i1]
     1015
     1016        foreach {i0 i1} $mesg break
     1017        set mesg [string range $message $i0 $i1]
     1018
     1019        pack $itk_component(progress) -fill x -padx 10 -pady 10
     1020        $itk_component(progress) settings -percent $percent -message $mesg
     1021
     1022        foreach {i0 i1} $match break
     1023        set message [string replace $message $i0 $i1]
    10241024    }
    10251025
     
    10311031
    10321032    while {[regexp -indices \
    1033                {=RAPPTURE-([a-zA-Z]+)=>([^\n]*)(\n|$)} $message \
    1034                 match type mesg]} {
    1035 
    1036         foreach {i0 i1} $match break
    1037         set first [string range $message 0 [expr {$i0-1}]]
    1038         if {[string length $first] > 0} {
    1039             $itk_component(runinfo) insert end $first
    1040             $itk_component(runinfo) insert end \n
    1041         }
    1042 
    1043         foreach {t0 t1} $type break
    1044         set type [string range $message $t0 $t1]
    1045         foreach {m0 m1} $mesg break
    1046         set mesg [string range $message $m0 $m1]
    1047         if {[string length $mesg] > 0 && $type != "RUN"} {
    1048             $itk_component(runinfo) insert end $mesg $type
    1049             $itk_component(runinfo) insert end \n $type
    1050         }
    1051 
    1052         set message [string range $message [expr {$i1+1}] end]
     1033               {=RAPPTURE-([a-zA-Z]+)=>([^\n]*)(\n|$)} $message \
     1034                match type mesg]} {
     1035
     1036        foreach {i0 i1} $match break
     1037        set first [string range $message 0 [expr {$i0-1}]]
     1038        if {[string length $first] > 0} {
     1039            $itk_component(runinfo) insert end $first
     1040            $itk_component(runinfo) insert end \n
     1041        }
     1042
     1043        foreach {t0 t1} $type break
     1044        set type [string range $message $t0 $t1]
     1045        foreach {m0 m1} $mesg break
     1046        set mesg [string range $message $m0 $m1]
     1047        if {[string length $mesg] > 0 && $type != "RUN"} {
     1048            $itk_component(runinfo) insert end $mesg $type
     1049            $itk_component(runinfo) insert end \n $type
     1050        }
     1051
     1052        set message [string range $message [expr {$i1+1}] end]
    10531053    }
    10541054
    10551055    if {[string length $message] > 0} {
    1056         $itk_component(runinfo) insert end $message
    1057         if {[$itk_component(runinfo) get end-2char] != "\n"} {
    1058             $itk_component(runinfo) insert end "\n"
    1059         }
    1060         $itk_component(runinfo) see end
     1056        $itk_component(runinfo) insert end $message
     1057        if {[$itk_component(runinfo) get end-2char] != "\n"} {
     1058            $itk_component(runinfo) insert end "\n"
     1059        }
     1060        $itk_component(runinfo) see end
    10611061    }
    10621062    $itk_component(runinfo) configure -state disabled
     
    10761076    set name [$itk_component(resultselector) value]
    10771077    if {[info exists _label2desc($name)] &&
    1078         [string length $_label2desc($name)] > 0} {
    1079         append tip "$_label2desc($name)\n\n"
     1078        [string length $_label2desc($name)] > 0} {
     1079        append tip "$_label2desc($name)\n\n"
    10801080    }
    10811081    if {[array size _label2page] > 1} {
    1082         append tip "Use this control to display other output results."
     1082        append tip "Use this control to display other output results."
    10831083    }
    10841084    return $tip
     
    10941094itcl::body Rappture::Analyzer::_fixSimControl {} {
    10951095    switch -- $itk_option(-simcontrol) {
    1096         on {
    1097             pack $itk_interior.simol -fill x -before $itk_interior.nb
    1098         }
    1099         off {
    1100             pack forget $itk_interior.simol
    1101         }
    1102         auto {
    1103             #
    1104             # If we have two or more radiodials, then there is a
    1105             # chance of encountering a combination of parameters
    1106             # with no data, requiring simulation.
    1107             #
    1108             if {[$itk_component(resultset) size -controls] >= 2} {
    1109                 pack $itk_interior.simol -fill x -before $itk_interior.nb
    1110             } else {
    1111                 pack forget $itk_interior.simol
    1112             }
    1113         }
    1114         default {
    1115             error "bad value \"$itk_option(-simcontrol)\": should be on, off, auto"
    1116         }
     1096        on {
     1097            pack $itk_interior.simol -fill x -before $itk_interior.nb
     1098        }
     1099        off {
     1100            pack forget $itk_interior.simol
     1101        }
     1102        auto {
     1103            #
     1104            # If we have two or more radiodials, then there is a
     1105            # chance of encountering a combination of parameters
     1106            # with no data, requiring simulation.
     1107            #
     1108            if {[$itk_component(resultset) size -controls] >= 2} {
     1109                pack $itk_interior.simol -fill x -before $itk_interior.nb
     1110            } else {
     1111                pack forget $itk_interior.simol
     1112            }
     1113        }
     1114        default {
     1115            error "bad value \"$itk_option(-simcontrol)\": should be on, off, auto"
     1116        }
    11171117    }
    11181118}
     
    11251125itcl::body Rappture::Analyzer::_fixNotebook {} {
    11261126    switch -- $itk_option(-notebookpage) {
    1127         about {
    1128             $itk_component(notebook) current about
    1129         }
    1130         simulate {
    1131             $itk_component(notebook) current simulate
    1132         }
    1133         analyze {
    1134             $itk_component(notebook) current analyze
    1135         }
    1136         default {
    1137             error "bad value \"$itk_option(-notebookpage)\": should be about, simulate, analyze"
    1138         }
     1127        about {
     1128            $itk_component(notebook) current about
     1129        }
     1130        simulate {
     1131            $itk_component(notebook) current simulate
     1132        }
     1133        analyze {
     1134            $itk_component(notebook) current analyze
     1135        }
     1136        default {
     1137            error "bad value \"$itk_option(-notebookpage)\": should be about, simulate, analyze"
     1138        }
    11391139    }
    11401140}
Note: See TracChangeset for help on using the changeset viewer.