blob: 58036b4f545d4520be9d7049419aba41e9b99635 (
plain)
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
# 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 MaskDef {} {
global mask
global imask
global pmask
set imask(top) .msk
set imask(mb) .mskmb
set mask(color) red
set mask(mark) 1
set mask(transparency) 0
array set pmask [array get mask]
}
proc MaskMark {} {
global mask
global current
if {$current(frame) != {}} {
$current(frame) mask mark $mask(mark)
}
}
proc MaskColor {} {
global mask
global current
if {$current(frame) != {}} {
$current(frame) mask color $mask(color)
}
}
proc MaskTransparency {} {
global mask
global current
if {$current(frame) != {}} {
$current(frame) mask transparency $mask(transparency)
}
}
proc MaskClear {} {
global current
if {$current(frame) != {}} {
$current(frame) mask clear
}
}
proc MaskDialog {} {
global mask
global imask
global current
global ds9
# see if we already have a ctr window visible
if {[winfo exists $imask(top)]} {
raise $imask(top)
return
}
# create the mask window
set w $imask(top)
set mb $imask(mb)
Toplevel $w $mb 6 [msgcat::mc {Mask Parameters}] MaskDestroyDialog
$mb add cascade -label [msgcat::mc {File}] -menu $mb.file
$mb add cascade -label [msgcat::mc {Edit}] -menu $mb.edit
menu $mb.file
$mb.file add command -label "[msgcat::mc {Open}]..." \
-command [list OpenDialog fits mask]
$mb.file add cascade -label [msgcat::mc {Open as}] \
-menu $mb.file.open
$mb.file add separator
$mb.file add cascade -label [msgcat::mc {Import}] \
-menu $mb.file.import
$mb.file add separator
$mb.file add command -label [msgcat::mc {Apply}] -command MaskApplyDialog
$mb.file add command -label [msgcat::mc {Clear}] -command MaskClear
$mb.file add separator
$mb.file add command -label [msgcat::mc {Close}] -command MaskDestroyDialog
menu $mb.file.open
$mb.file.open add command \
-label "[msgcat::mc {Mosaic WCS}]..." \
-command [list OpenDialog mosaicimagewcs mask]
$mb.file.open add command \
-label "[msgcat::mc {Mosaic WCS Segment}]..." \
-command [list OpenDialog mosaicwcs mask]
$mb.file.open add command \
-label "[msgcat::mc {Mosaic IRAF}]..." \
-command [list OpenDialog mosaicimageiraf mask]
$mb.file.open add command \
-label "[msgcat::mc {Mosaic IRAF Segment}]..." \
-command [list OpenDialog mosaiciraf mask]
menu $mb.file.import
$mb.file.import add command \
-label "[msgcat::mc {Array}]..." \
-command [list ImportDialog array mask]
$mb.file.import add command \
-label "[msgcat::mc {NRRD}]..." \
-command [list ImportDialog nrrd mask]
EditMenu $mb imask
# Param
set f [ttk::frame $w.param]
slider $f.slider 0 100 [msgcat::mc {Transparency}] \
mask(transparency) [list MaskTransparency]
grid $f.slider -padx 2 -pady 2 -sticky ew
grid columnconfigure $f 0 -weight 1
# Buttons
set f [ttk::frame $w.buttons]
ttk::button $f.apply -text [msgcat::mc {Apply}] -command MaskApplyDialog
ttk::button $f.clear -text [msgcat::mc {Clear}] -command MaskClear
ttk::button $f.close -text [msgcat::mc {Close}] -command MaskDestroyDialog
pack $f.apply $f.clear $f.close -side left -expand true -padx 2 -pady 4
# 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
}
proc MaskApplyDialog {} {
global mask
MaskTransparency
}
proc MaskDestroyDialog {} {
global imask
if {[winfo exists $imask(top)]} {
destroy $imask(top)
destroy $imask(mb)
}
}
proc UpdateMaskMenu {} {
global mask
global current
global ds9
global debug
if {$debug(tcl,update)} {
puts stderr "UpdateMaskMenu"
}
if {$current(frame) == {}} {
return
}
set mask(color) [$current(frame) get mask color]
set mask(mark) [$current(frame) get mask mark]
set mask(transparency) [$current(frame) get mask transparency]
switch -- [$current(frame) get type] {
base {
$ds9(mb).analysis entryconfig \
"[msgcat::mc {Mask Parameters}]..." -state normal
}
3d -
rgb {
$ds9(mb).analysis entryconfig \
"[msgcat::mc {Mask Parameters}]..." -state disabled
}
}
}
proc MaskLoad {} {
global current
global mask
set rr [MaskParamsDialog]
if {$current(frame) != {}} {
if {$rr} {
$current(frame) mask color $mask(color)
$current(frame) mask mark $mask(mark)
}
}
return $rr
}
proc MaskParamsDialog {} {
global mask
global ed
set w {.mskd}
set ed(ok) 0
set ed(color) $mask(color)
set ed(mark) $mask(mark)
DialogCreate $w [msgcat::mc {Mask Parameters}] ed(ok)
# Param
set f [ttk::frame $w.param]
ttk::label $f.colortitle -text [msgcat::mc {Color}]
ColorMenuButton $f.colorbutton ed color {}
ttk::label $f.marktitle -text [msgcat::mc {Block}]
ttk::radiobutton $f.markz -text [msgcat::mc {Zero}] \
-variable ed(mark) -value 0
ttk::radiobutton $f.marknz -text [msgcat::mc {Non-zero}] \
-variable ed(mark) -value 1
ttk::label $f.marktitle2 -text [msgcat::mc {Value}]
grid $f.colortitle $f.colorbutton - -padx 2 -pady 2 -sticky w
grid $f.marktitle $f.markz $f.marknz $f.marktitle2 -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)
DialogDismiss $w
if {$ed(ok)} {
set mask(color) [string tolower $ed(color)]
set mask(mark) $ed(mark)
}
set rr $ed(ok)
unset ed
return $rr
}
proc MaskBackup {ch which} {
puts $ch "$which mask color [$which get mask color]"
puts $ch "$which mask mark [$which get mask mark]"
puts $ch "$which mask transparency [$which get mask transparency]"
}
proc ProcessMaskCmd {varname iname} {
upvar $varname var
upvar $iname i
global mask
global parse
set parse(result) {}
mask::YY_FLUSH_BUFFER
mask::yy_scan_string [lrange $var $i end]
mask::yyparse
incr i [expr $mask::yycnt-1]
return $parse(result)
}
proc ProcessSendMaskCmd {proc id param {sock {}} {fn {}}} {
global parse
set parse(proc) $proc
set parse(id) $id
masksend::YY_FLUSH_BUFFER
masksend::yy_scan_string $param
masksend::yyparse
}
|