Changeset 6164 for branches/1.6


Ignore:
Timestamp:
Mar 21, 2016 7:15:07 AM (7 years ago)
Author:
gah
Message:

merge changes from 1.5 (remove tk_getSaveFile calls)

Location:
branches/1.6/gui/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.6/gui/scripts/analyzer.tcl

    r6118 r6164  
    5454    private variable _saved
    5555    private variable _name ""
     56    private variable _revision 0;       # Tool revision
    5657   
    5758    constructor {tool args} {
     
    120121    private method SelectSimsetNameAndSave {}
    121122    private method SelectSimsetToPublish {}
    122     private method WriteSimsetFile { appName fileName }
     123    private method WriteSimsetFile { appName fileName publish }
     124    private method OverwriteSaveFile {}
     125    private method BuildQuestionDialog { popup }
     126    private method Save {}
    123127}
    124128
     
    176180    global rapptureInfo
    177181    if { $rapptureInfo(appName) == "" } {
    178         set _appName [$_tool xml get tool.id]
     182        set _appName [$_tool xml get "tool.id"]
    179183    } else {
    180184        set _appName $rapptureInfo(appName)
    181185    }
     186    set num [$_tool xml get "tool.version.application.revision"]
     187    if { $num == "" } {
     188        set num 0
     189    }
     190    set _revision $num
    182191    set url [Rappture::Tool::resources -huburl]
    183192
     
    16611670    blt::table configure $top r0 c0 -resize both
    16621671}
     1672
     1673itcl::body Rappture::Analyzer::CleanName { name } {
     1674    regsub -all {/} $name {_} name
     1675    return $name
     1676}
     1677
    16631678#
    16641679# Get the results and display them in a table.
     
    16701685        set appDir [file normalize ~/data/saved/$_appName]
    16711686        file mkdir $appDir
    1672         set fileName [tk_getSaveFile \
    1673                           -initialdir $appDir \
    1674                           -filetypes {{ "Simulations Save File" ".sav" }} \
    1675                           -title "Save Simulations To File"]
    1676         if { $fileName != "" } {
    1677             WriteSimsetFile $_appName $fileName
    1678         }
     1687        set fileName [file join $appDir [CleanName $_saved(Name).sav]]
     1688        if { [file exists $fileName] } {
     1689            if { ![OverwriteSaveFile] } {
     1690                return
     1691            }
     1692        }
     1693        WriteSimsetFile $_appName $fileName 0
    16791694    }
    16801695}
     
    16911706        if { [catch {
    16921707            file mkdir $shareDir
     1708            file attributes $shareDir -permissions o+r,g+rw
    16931709        } errs] != 0 } {
    16941710            puts stderr errs=$errs
    16951711            return
    16961712        }
    1697         set fileName [tk_getSaveFile \
    1698                           -initialdir $shareDir \
    1699                           -filetypes {{ "Simulations Set File" ".sav" }} \
    1700                           -title "Save Simulations To File"]
    1701         if { $fileName != "" } {
    1702             WriteSimsetFile $_appName $fileName
    1703         }
     1713        set fileName [file join $shareDir [CleanName $_saved(Name).sav]]
     1714        if { [file exists $fileName] } {
     1715            if { ![OverwriteSaveFile] } {
     1716                return
     1717            }
     1718        }
     1719        WriteSimsetFile $_appName $fileName 1
    17041720    }
    17051721}
     
    17371753    set desc [string trim [$inner.desc get 0.0 end]]
    17381754    set _saved(Application) $_appName
     1755    set _saved(Revision) $_revision
    17391756    set _saved(Date) [clock format [clock seconds]]
    17401757    set _saved(Name) $name
     
    17851802#       the root of the .save file name.
    17861803#
    1787 itcl::body Rappture::Analyzer::WriteSimsetFile { appName fileName } {
    1788     # The runfiles directory is the root of the filename.
    1789     # For example, if the simset file is /path/to/myName.sav,
    1790     # the runfile directory is /path/to/myName
     1804itcl::body Rappture::Analyzer::WriteSimsetFile { appName fileName publish } {
     1805    # The runfiles directory is the root of the filename.  For example, if
     1806    # the simset file is /path/to/myName.sav, the runfile directory is
     1807    # /path/to/myName
    17911808    set root [file root $fileName]
    17921809    if { [file exists $root] } {
     
    17961813        file mkdir $root
    17971814        set f [open $fileName "w"]
    1798         puts $f [list "Name" $_saved(Name)]
     1815        puts $f [list "Name"        $_saved(Name)]
    17991816        puts $f [list "Description" $_saved(Description)]
    1800         puts $f [list "Date" $_saved(Date)]
     1817        puts $f [list "Date"        $_saved(Date)]
    18011818        global env
    1802         puts $f [list "Creator" $env(USER)]
     1819        puts $f [list "Creator"     $env(USER)]
    18031820        puts $f [list "Application" $_saved(Application)]
     1821        puts $f [list "Revision"    $_saved(Revision)]
    18041822        set runfiles ""
    18051823        foreach file $_saved(Files) {
     
    18071825            set dest [file join $root $tail]
    18081826            file copy -force $file $dest
     1827            if { $publish } {
     1828                file attributes $dest -permissions o+r,g+rw
     1829            }
    18091830            lappend runfiles $tail
    18101831        }
    18111832        puts $f [list "Files" $runfiles]
    18121833        close $f
     1834        if { $publish } {
     1835            file attributes $fileName -permissions o+r,g+rw
     1836        }
    18131837    } errs] != 0 } {
    1814         puts stderr errs=$errs
     1838        global errorInfo
     1839        puts stderr "errs=$errs errorInfo=$errorInfo"
    18151840    }
    18161841}
     
    19601985    foreach fileName [glob -nocomplain ~/data/saved/$appName/*.sav] {
    19611986        if { [ReadSimsetFile $fileName] } {
     1987            if { $_revision > 0 && $_revision != $_saved(Revision) } {
     1988                continue;               # Revision doesn't match.
     1989            }
    19621990            $_tree insert 0 -label $_saved(Name) -data [array get _saved]
    19631991        }
     
    20542082}
    20552083
     2084itcl::body Rappture::Analyzer::BuildQuestionDialog { popup } {
     2085    toplevel $popup -background grey92 -bd 2 -relief raised
     2086    wm withdraw $popup
     2087    wm overrideredirect $popup true
     2088    set inner $popup
     2089    # Create the print dialog widget and add it to the the balloon popup.
     2090    label $popup.title -text " " \
     2091        -padx 10 -pady 10 \
     2092        -background grey92
     2093    button $popup.yes -text "Yes" \
     2094        -highlightthickness 0 \
     2095        -bd 2  \
     2096        -command [itcl::code $this Save]
     2097    button $popup.no -text "No" \
     2098        -highlightthickness 0 \
     2099        -bd 2 \
     2100        -command [itcl::code $this Cancel]
     2101    blt::table $popup \
     2102        0,0 $popup.title -cspan 2  -fill x -pady 4 \
     2103        1,0 $popup.yes -width { 0 1i .6i } -pady 4 \
     2104        1,1 $popup.no -width { 0 1i .6i }  -pady 4
     2105    blt::table configure $popup  r2 -height 0.125i
     2106}
     2107
     2108itcl::body Rappture::Analyzer::Save {} {
     2109    set _done 1
     2110}
     2111
     2112itcl::body Rappture::Analyzer::OverwriteSaveFile {} {
     2113    set popup .question
     2114    if { ![winfo exists $popup] } {
     2115        BuildQuestionDialog $popup
     2116    }
     2117    set text "Simulation set \"$_saved(Name)\" already exists. Overwrite?"
     2118    $popup.title configure -text $text
     2119    $popup.yes configure -text "Save"
     2120    $popup.no configure -text "Cancel"
     2121    set main [winfo toplevel $itk_component(help)]
     2122    set pw [winfo reqwidth $popup]
     2123    set ph [winfo reqheight $popup]
     2124    set sw [winfo reqwidth $main]
     2125    set sh [winfo reqheight $main]
     2126    set rootx [winfo rootx $main]
     2127    set rooty [winfo rooty $main]
     2128    set x [expr $rootx + (($sw - $pw) / 2)]
     2129    set y [expr $rooty + (($sh - $ph) / 2)]
     2130    wm geometry $popup +$x+$y
     2131    wm deiconify $popup
     2132    update
     2133    grab $popup
     2134    # Activate the popup and call for the output.
     2135    Cancel
     2136    tkwait variable [itcl::scope _done]
     2137    set doSave $_done
     2138    grab release $popup
     2139    destroy $popup
     2140    return $doSave
     2141}
  • branches/1.6/gui/scripts/imageresult.tcl

    r5679 r6164  
    475475                set w [winfo width $itk_component(image)]
    476476                set h [winfo height $itk_component(image)]
    477                 if {$w == 1 && $h == 1} {
     477                if {$w <= 1 && $h <= 1} {
    478478                    return 0
    479479                }
Note: See TracChangeset for help on using the changeset viewer.