blob: e06b447393878ab22121d9389dcf41cb9f009398 (
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
# 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 BlockDef {} {
global iblock
global block
global pblock
set iblock(top) .blk
set iblock(mb) .blkmb
set block(lock) 0
set block(factor) {1 1}
array set pblock [array get block]
}
proc BlockToFit {} {
global block
global current
if {$current(frame) != {}} {
SetWatchCursor
RGBEvalLockCurrent rgb(lock,block) [list $current(frame) block to fit]
ResetWatchCursor
set block(factor) [$current(frame) get block factor]
UpdateBlock
}
}
proc ChangeBlock {} {
global block
global current
if {$current(frame) != {}} {
SetWatchCursor
RGBEvalLockCurrent rgb(lock,block) [list $current(frame) block to $block(factor)]
ResetWatchCursor
UpdateBlock
}
}
proc Block {bx by} {
global block
global current
if {$current(frame) != {}} {
SetWatchCursor
RGBEvalLockCurrent rgb(lock,block) [list $current(frame) block $bx $by]
set block(factor) [$current(frame) get block factor]
ResetWatchCursor
UpdateBlock
}
}
proc UpdateBlock {} {
global current
# we need to be realized
RealizeDS9
LockBlockCurrent
UpdateBlockDialog
UpdatePanZoomDialog
UpdateCrosshairDialog
UpdateCropDialog
UpdateCubeDialog
UpdateScaleDialog
UpdateContourScale
UpdateContourDialog
UpdateWCSDialog
UpdateGraphAxis $current(frame)
UpdateMain
UpdateHeaderDialog
}
proc BlockDialog {} {
global block
global iblock
global dblock
global ds9
global current
# see if we already have a window visible
if {[winfo exists $iblock(top)]} {
raise $iblock(top)
return
}
# create the window
set w $iblock(top)
set mb $iblock(mb)
Toplevel $w $mb 6 [msgcat::mc {Block Parameters}] \
BlockDestroyDialog
$mb add cascade -label [msgcat::mc {File}] -menu $mb.file
$mb add cascade -label [msgcat::mc {Edit}] -menu $mb.edit
$mb add cascade -label [msgcat::mc {Block}] -menu $mb.block
menu $mb.file
$mb.file add command -label [msgcat::mc {Apply}] \
-command BlockApplyDialog
$mb.file add separator
$mb.file add command -label [msgcat::mc {Close}] \
-command BlockDestroyDialog
EditMenu $mb iblock
menu $mb.block
$mb.block add command -label [msgcat::mc {Block In}] -command {Block .5 .5}
$mb.block add command -label [msgcat::mc {Block Out}] -command {Block 2 2}
$mb.block add command -label [msgcat::mc {Block Fit}] -command BlockToFit
$mb.block add separator
$mb.block add radiobutton -label "[msgcat::mc {Block}] 1" \
-variable block(factor) -value {1 1} -command ChangeBlock
$mb.block add radiobutton -label "[msgcat::mc {Block}] 2" \
-variable block(factor) -value {2 2} -command ChangeBlock
$mb.block add radiobutton -label "[msgcat::mc {Block}] 4" \
-variable block(factor) -value {4 4} -command ChangeBlock
$mb.block add radiobutton -label "[msgcat::mc {Block}] 8" \
-variable block(factor) -value {8 8} -command ChangeBlock
$mb.block add radiobutton -label "[msgcat::mc {Block}] 16" \
-variable block(factor) -value {16 16} -command ChangeBlock
$mb.block add radiobutton -label "[msgcat::mc {Block}] 32" \
-variable block(factor) -value {32 32} -command ChangeBlock
# Param
set f [ttk::frame $w.param]
ttk::label $f.blocktitle -text [msgcat::mc {Block}]
ttk::entry $f.blockx -textvariable dblock(x) -width 14
ttk::entry $f.blocky -textvariable dblock(y) -width 14
grid $f.blocktitle $f.blockx $f.blocky -padx 2 -pady 2
# Buttons
set f [ttk::frame $w.buttons]
ttk::button $f.apply -text [msgcat::mc {Apply}] -command BlockApplyDialog
ttk::button $f.close -text [msgcat::mc {Close}] \
-command BlockDestroyDialog
pack $f.apply $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
$w.param.blockx select range 0 end
UpdateBlockDialog
}
proc BlockApplyDialog {} {
global block
global iblock
global dblock
global current
if {$current(frame) != {}} {
set block(factor) "$dblock(x) $dblock(y)"
RGBEvalLockCurrent rgb(lock,block) [list $current(frame) block to $block(factor)]
LockFrameCurrent
UpdateGraphAxis $current(frame)
UpdateBlockDialog
RefreshInfoBox $current(frame)
}
}
proc BlockDestroyDialog {} {
global iblock
global dblock
if {[winfo exists $iblock(top)]} {
destroy $iblock(top)
destroy $iblock(mb)
unset dblock
}
}
proc UpdateBlockDialog {} {
global block
global iblock
global dblock
global current
global debug
if {$debug(tcl,update)} {
puts stderr "UpdateBlockDialog"
}
if {![winfo exists $iblock(top)]} {
return
}
if {$current(frame) != {}} {
set zz [$current(frame) get block factor]
set dblock(x) [lindex $zz 0]
set dblock(y) [lindex $zz 1]
} else {
set dblock(x) {}
set dblock(y) {}
}
}
proc UpdateBlockMenu {} {
global block
global current
global debug
if {$debug(tcl,update)} {
puts stderr "UpdateBlockMenu"
}
if {$current(frame) != {}} {
set block(factor) [$current(frame) get block factor]
}
}
proc MatchBlockCurrent {} {
global current
if {$current(frame) != {}} {
MatchBlock $current(frame)
}
}
proc MatchBlock {which} {
global ds9
global rgb
set factor [$which get block factor]
foreach ff $ds9(frames) {
if {$ff != $which} {
RGBEvalLock rgb(lock,block) $ff [list $ff block to $factor]
}
}
}
proc LockBlockCurrent {} {
global current
if {$current(frame) != {}} {
LockBlock $current(frame)
}
}
proc LockBlock {which} {
global block
if {$block(lock)} {
MatchBlock $which
}
}
proc BlockBackup {ch which} {
switch [$which get type] {
base -
3d {BlockBackupBase $ch $which}
rgb {BlockBackupRGB $ch $which}
}
}
proc BlockBackupBase {ch which} {
set factor [$which get block factor]
puts $ch "$which block to $factor"
}
proc BlockBackupRGB {ch which} {
set sav [$which get rgb channel]
foreach cc {red green blue} {
$which rgb channel $cc
puts $ch "$which rgb channel $cc"
BlockBackupBase $ch $which
}
$which rgb channel $sav
puts $ch "$which rgb channel $sav"
}
proc ProcessBlockCmd {varname iname} {
upvar $varname var
upvar $iname i
# we need to be realized
ProcessRealizeDS9
block::YY_FLUSH_BUFFER
block::yy_scan_string [lrange $var $i end]
block::yyparse
incr i [expr $block::yycnt-1]
}
proc ProcessSendBlockCmd {proc id param {sock {}} {fn {}}} {
global parse
set parse(proc) $proc
set parse(id) $id
blocksend::YY_FLUSH_BUFFER
blocksend::yy_scan_string $param
blocksend::yyparse
}
proc BlockSendCmd {} {
global parse
global block
set z1 [lindex $block(factor) 0]
set z2 [lindex $block(factor) 1]
if {$z1 != $z2} {
$parse(proc) $parse(id) "$block(factor)\n"
} else {
$parse(proc) $parse(id) "$z1\n"
}
}
|