Changeset 6164 for branches/1.6
- Timestamp:
- Mar 21, 2016 7:15:07 AM (8 years ago)
- Location:
- branches/1.6/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.6/gui/scripts/analyzer.tcl
r6118 r6164 54 54 private variable _saved 55 55 private variable _name "" 56 private variable _revision 0; # Tool revision 56 57 57 58 constructor {tool args} { … … 120 121 private method SelectSimsetNameAndSave {} 121 122 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 {} 123 127 } 124 128 … … 176 180 global rapptureInfo 177 181 if { $rapptureInfo(appName) == "" } { 178 set _appName [$_tool xml get tool.id]182 set _appName [$_tool xml get "tool.id"] 179 183 } else { 180 184 set _appName $rapptureInfo(appName) 181 185 } 186 set num [$_tool xml get "tool.version.application.revision"] 187 if { $num == "" } { 188 set num 0 189 } 190 set _revision $num 182 191 set url [Rappture::Tool::resources -huburl] 183 192 … … 1661 1670 blt::table configure $top r0 c0 -resize both 1662 1671 } 1672 1673 itcl::body Rappture::Analyzer::CleanName { name } { 1674 regsub -all {/} $name {_} name 1675 return $name 1676 } 1677 1663 1678 # 1664 1679 # Get the results and display them in a table. … … 1670 1685 set appDir [file normalize ~/data/saved/$_appName] 1671 1686 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 $fileName1678 }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 1679 1694 } 1680 1695 } … … 1691 1706 if { [catch { 1692 1707 file mkdir $shareDir 1708 file attributes $shareDir -permissions o+r,g+rw 1693 1709 } errs] != 0 } { 1694 1710 puts stderr errs=$errs 1695 1711 return 1696 1712 } 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 $fileName1703 }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 1704 1720 } 1705 1721 } … … 1737 1753 set desc [string trim [$inner.desc get 0.0 end]] 1738 1754 set _saved(Application) $_appName 1755 set _saved(Revision) $_revision 1739 1756 set _saved(Date) [clock format [clock seconds]] 1740 1757 set _saved(Name) $name … … 1785 1802 # the root of the .save file name. 1786 1803 # 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/myName1804 itcl::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 1791 1808 set root [file root $fileName] 1792 1809 if { [file exists $root] } { … … 1796 1813 file mkdir $root 1797 1814 set f [open $fileName "w"] 1798 puts $f [list "Name" $_saved(Name)]1815 puts $f [list "Name" $_saved(Name)] 1799 1816 puts $f [list "Description" $_saved(Description)] 1800 puts $f [list "Date" $_saved(Date)]1817 puts $f [list "Date" $_saved(Date)] 1801 1818 global env 1802 puts $f [list "Creator" $env(USER)]1819 puts $f [list "Creator" $env(USER)] 1803 1820 puts $f [list "Application" $_saved(Application)] 1821 puts $f [list "Revision" $_saved(Revision)] 1804 1822 set runfiles "" 1805 1823 foreach file $_saved(Files) { … … 1807 1825 set dest [file join $root $tail] 1808 1826 file copy -force $file $dest 1827 if { $publish } { 1828 file attributes $dest -permissions o+r,g+rw 1829 } 1809 1830 lappend runfiles $tail 1810 1831 } 1811 1832 puts $f [list "Files" $runfiles] 1812 1833 close $f 1834 if { $publish } { 1835 file attributes $fileName -permissions o+r,g+rw 1836 } 1813 1837 } errs] != 0 } { 1814 puts stderr errs=$errs 1838 global errorInfo 1839 puts stderr "errs=$errs errorInfo=$errorInfo" 1815 1840 } 1816 1841 } … … 1960 1985 foreach fileName [glob -nocomplain ~/data/saved/$appName/*.sav] { 1961 1986 if { [ReadSimsetFile $fileName] } { 1987 if { $_revision > 0 && $_revision != $_saved(Revision) } { 1988 continue; # Revision doesn't match. 1989 } 1962 1990 $_tree insert 0 -label $_saved(Name) -data [array get _saved] 1963 1991 } … … 2054 2082 } 2055 2083 2084 itcl::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 2108 itcl::body Rappture::Analyzer::Save {} { 2109 set _done 1 2110 } 2111 2112 itcl::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 475 475 set w [winfo width $itk_component(image)] 476 476 set h [winfo height $itk_component(image)] 477 if {$w == 1 && $h == 1} {477 if {$w <= 1 && $h <= 1} { 478 478 return 0 479 479 }
Note: See TracChangeset
for help on using the changeset viewer.