1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# Copyright (C) 1999-2018
# Smithsonian Astrophysical Observatory, Cambridge, MA, USA
# For conditions of distribution and use, see copyright notice in "copyright"
package provide DS9 1.0
proc AnalysisParam {strname param} {
upvar $strname str
global ianalysis
global ed
global ds9
global pds9
# find it
for {set i 0} {$i<$ianalysis(param,count)} {incr i} {
if {$ianalysis(param,$i) == "$param"} {
break
}
}
if {$i == $ianalysis(param,count)} {
return
}
set w {.param}
set ed(ok) 0
DialogCreate $w $param ed(ok)
# Param
set f [ttk::frame $w.param]
for {set j 0} {$j<$ianalysis(param,$i,count)} {incr j} {
set ianalysis(param,$i,$j,value) $ianalysis(param,$i,$j,last)
ttk::label $f.l$j -text "$ianalysis(param,$i,$j,title)"
switch -- $ianalysis(param,$i,$j,type) {
entry {
ttk::entry $f.a$j \
-textvariable ianalysis(param,$i,$j,value) \
-width 40
}
checkbox {
ttk::checkbutton $f.a$j -text {} \
-variable ianalysis(param,$i,$j,value)
}
menu {
set l [split $ianalysis(param,$i,$j,default) |]
ttk::menubutton $f.a$j \
-text "$ianalysis(param,$i,$j,value)" \
-menu $f.a$j.menu
set m [menu $f.a$j.menu]
for {set k 0} {$k<[llength $l]} {incr k} {
$m add command -label [lindex $l $k] \
-command "AnalysisParamMenu ianalysis(param,$i,$j,value) [lindex $l $k] $f.a$j"
}
}
}
ttk::label $f.i$j -text "$ianalysis(param,$i,$j,info)" \
-font "{$ds9(times)} $pds9(font,size) normal italic"
grid $f.l$j $f.a$j $f.i$j -padx 2 -pady 2 -sticky w
}
# Buttons
set f [ttk::frame $w.buttons]
ttk::button $f.ok -text [msgcat::mc {OK}] -command {set ed(ok) 1} \
-default active
ttk::button $f.cancel -text [msgcat::mc {Cancel}] -command {set ed(ok) 0}
pack $f.ok $f.cancel -side left -expand true -padx 2 -pady 4
bind $w <Return> {set ed(ok) 1}
# Fini
ttk::separator $w.sep -orient horizontal
pack $w.buttons $w.sep -side bottom -fill x
pack $w.param -side top -fill both -expand true
DialogCenter $w
DialogWait $w ed(ok) $w.buttons.ok
DialogDismiss $w
if {$ed(ok)} {
for {set j 0} {$j<$ianalysis(param,$i,count)} {incr j} {
set exp "\\\$$ianalysis(param,$i,$j,var)"
if {[regexp $exp $str]} {
regsub -all $exp $str "$ianalysis(param,$i,$j,value)" str
}
set ianalysis(param,$i,$j,last) $ianalysis(param,$i,$j,value)
}
}
set rr $ed(ok)
unset ed
return $rr
}
proc AnalysisParamMenu {varname value menu} {
upvar $varname var
set var $value
$menu configure -text $value
}
proc ParseIRAFParam {filename} {
global ianalysis
global env
# we are only concerned with unix like os
set uparm {}
if {[info exists env(UPARM)]} {
set uparm "$env(UPARM)/$filename"
}
set iraf {}
if {[info exists env(HOME)]} {
set iraf "$env(HOME)/$filename"
}
if {[file exists "$filename"]} {
catch {set ch [open "$filename"]}
} elseif {[file exists "$uparm"]} {
catch {set ch [open "$uparm"]}
} elseif {[file exists "$iraf"]} {
catch {set ch [open "$iraf"]}
} else {
return
}
set i $ianalysis(param,count)
while {[gets $ch line] >= 0} {
set exp {([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)}
if {[regexp $exp $line foo p1 p2 p3 p4 p5 p6 p7]} {
if {$p1 != {mode}} {
regsub -all {\"} $p4 {} p4
regsub -all {\"} $p7 {} p7
set j $ianalysis(param,$i,count)
set ianalysis(param,$i,$j,var) "$p1"
if {$p3 == {h}} {
set ianalysis(param,$i,$j,title) "(${p1})"
} else {
set ianalysis(param,$i,$j,title) "$p1"
}
set ianalysis(param,$i,$j,info) "$p7"
incr ianalysis(param,$i,count)
switch -- $p2 {
b {
set ianalysis(param,$i,$j,type) checkbox
set ianalysis(param,$i,$j,default) [FromYesNo $p4]
set ianalysis(param,$i,$j,last) [FromYesNo $p4]
set ianalysis(param,$i,$j,value) [FromYesNo $p4]
}
s {
if {$p5 != {}} {
set ianalysis(param,$i,$j,type) menu
set ianalysis(param,$i,$j,default) "$p5"
} else {
set ianalysis(param,$i,$j,type) entry
set ianalysis(param,$i,$j,default) "$p4"
}
set ianalysis(param,$i,$j,last) "$p4"
set ianalysis(param,$i,$j,value) "$p4"
}
default {
set ianalysis(param,$i,$j,type) entry
set ianalysis(param,$i,$j,default) "$p4"
set ianalysis(param,$i,$j,last) "$p4"
set ianalysis(param,$i,$j,value) "$p4"
}
}
}
}
}
close $ch
}
|