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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
|
################################################################################
#
# XIMTOOL-ALT -- Procedures and declarations for the ALT GUI.
#
################################################################################
# Creat the bitmaps needed for the alternate optional bars.
createBitmap tools 16 16 {
0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xf3, 0xcf, 0xf3, 0xcf, 0xf3, 0xcf,
0x83, 0xc1, 0x83, 0xc1, 0x83, 0xc1, 0x83, 0xc1, 0x83, 0xc1, 0x83, 0xc1,
0x83, 0xc1, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff};
createBitmap control 16 16 {
0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xe3, 0xc7, 0xe3, 0xcf, 0x33, 0xcc,
0x33, 0xc0, 0x1b, 0xc0, 0x1b, 0xc0, 0x1b, 0xc0, 0x33, 0xcc, 0xf3, 0xcf,
0xe3, 0xc7, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff};
createBitmap tile 16 16 {
0xff, 0xff, 0xff, 0xff, 0x83, 0xc1, 0x83, 0xc1, 0x83, 0xc1, 0x83, 0xc1,
0x83, 0xc1, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc1, 0x83, 0xc1, 0x83, 0xc1,
0x83, 0xc1, 0x83, 0xc1, 0xff, 0xff, 0xff, 0xff};
createBitmap compass 16 16 {
0x00, 0x00, 0x00, 0x02, 0x00, 0x07, 0x80, 0x0f, 0xc0, 0x1f, 0x00, 0x07,
0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0xfc, 0x07,
0xfc, 0x07, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00}
createBitmap plus 11 11 {
0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0xfe, 0x03, 0xfe, 0x03,
0xfe, 0x03, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, 0x00};
createBitmap minus 11 11 {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x03, 0xfe, 0x03,
0xfe, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
createBitmap disk 16 16 {
0xfe,0x1f,0x11,0x25,0x11,0x45,0x11,0x44,0xf1,0x47,0x01,0x40,0x01,0x40,0xf9,
0x4f,0x05,0x50,0x05,0x50,0x05,0x50,0x05,0x50,0x05,0x50,0x05,0x50,0xff,0x7f,
0x00,0x00};
createBitmap printer 32 16 {
0x00, 0xfe, 0x07, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x02, 0x12, 0x00,
0x00, 0x02, 0x22, 0x00, 0x00, 0x02, 0x3e, 0x00, 0x00, 0x02, 0x20, 0x00,
0x00, 0x02, 0x20, 0x00, 0xe0, 0x03, 0xe0, 0x03, 0x10, 0x03, 0xe0, 0x06,
0x08, 0xff, 0x7f, 0x09, 0x04, 0x00, 0x00, 0x10, 0xfc, 0xff, 0xff, 0x1f,
0x04, 0x00, 0x00, 0x10, 0xfc, 0xff, 0xff, 0x1f, 0x08, 0x00, 0x00, 0x08,
0xf8, 0xff, 0xff, 0x0f};
send tbBlinkDec "set bitmap larrow" ;# Assign the bitmaps to the buttons.
send tbBlinkInc "set bitmap rarrow"
send tbZoomIn "set bitmap plus"
send tbZoomOut "set bitmap minus"
send tbTile "set bitmap tile"
send tbCompass "set bitmap compass; addCallback toggleCompass"
#send helpButton "set bitmap qmark; addCallback Help"
send mXflipButton "set bitmap xflip; addCallback xflip"
send mYflipButton "set bitmap yflip; addCallback yflip"
send mNextButton "set bitmap rarrow; addCallback nextFrame"
send mPrevButton "set bitmap larrow; addCallback prevFrame"
# toolBox -- Toggle the toolbox and panelbar display.
set toolbox_up [ true $showToolBar ]
set panelbar_up [ true $showPanelBar ]
proc toolBoxToggle args \
{
global toolbox_up
set w [send display get width] ; set h [send display get height]
set iw [send imagewin get width] ; set ih [send imagewin get height]
if {$toolbox_up} {
send toolbar set height 0
send toolButton set state 0
send imagewin "set width $iw; set height $ih"
set nh [expr $h - 25]
send display "set width $w; set height $nh"
set toolbox_up 0
send mXflipButton map
send mYflipButton map
send mPrevButton map
send mFrameButton map
send mNextButton map
} else {
send toolbar set height 25
send toolButton set state 1
send imagewin "set width $iw; set height $ih"
set nh [expr $h + 25]
send display "set width $w ; set height $nh"
set toolbox_up 1
send mXflipButton unmap
send mYflipButton unmap
send mPrevButton unmap
send mFrameButton unmap
send mNextButton unmap
}
}
proc panelBarToggle args \
{
global panelbar_up
set w [send display get width] ; set h [send display get height]
set iw [send imagewin get width] ; set ih [send imagewin get height]
if {$panelbar_up} {
send panelbar set height 0
send panelButton set state 0
send imagewin "set width $iw; set height $ih"
set nh [expr $h - 25]
send display "set width $w ; set height $nh"
set panelbar_up 0
} else {
send panelbar set height 25
send panelButton set state 1
send imagewin "set width $iw; set height $ih"
set nh [expr $h + 25]
send display "set width $w ; set height $nh"
set panelbar_up 1
}
}
# Initialize the bars to be displayed if the resource was set.
send toolButton "set bitmap tools; addCallback toolBoxToggle"
if { ! [ true $showToolBar ] } {
send display set height [expr [send display get height] - 25]
send toolbar set height 0
send toolButton set state 0
} else {
send toolButton set state 1
send mXflipButton unmap
send mYflipButton unmap
send mPrevButton unmap
send mFrameButton unmap
send mNextButton unmap
}
send panelButton "deleteCallback panel"
send panelButton "set bitmap control; addCallback panelBarToggle"
if { ! [ true $showPanelBar ] } {
send display set height [expr [send display get height] - 25]
send panelbar set height 0
send panelButton set state 0
} else {
send panelButton set state 1
}
##############################################
# Panelbar callbacks.
##############################################
send pbQuit addCallback Quit
send helpClose addCallback "send helpButton set state 0"
# Control Panel.
#------------------------------------------------------
proc pbToggleControl {name element op} \
{
upvar $name panel_up
send pbDisplayP set state [expr !($panel_up)]
} ; #trace variable panel_up w pbToggleControl
proc pbResetPanel {param old new} \
{
global displayPanner displayMagnifier displayCoords
switch $new {
done { send pbPanM set state [true $displayPanner]
send pbMagM set state [true $displayMagnifier]
send pbWcsM set state [true $displayCoords]
}
}
} ; send initialize addCallback pbResetPanel
set WidgetToTab(pbDisplayP) display_panel
set WidgetToTab(pbInfoP) info_panel
set WidgetToTab(pbLoadP) load_panel
set WidgetToTab(pbPrintP) print_panel
set WidgetToTab(pbSaveP) save_panel
set WidgetToTab(pbTileP) tile_panel
set WidgetToTab(pbCoordP) wcs_panel
set TabToWidget(display_panel) pbDisplayP
set TabToWidget(print_panel) pbPrintP
set TabToWidget(load_panel) pbLoadP
set TabToWidget(save_panel) pbSaveP
set TabToWidget(info_panel) pbInfoP
set TabToWidget(tile_panel) pbTileP
set TabToWidget(wcs_panel) pbCoordP
set pbTabTop "pbDisplayP"
proc pbPanelDismiss args \
{
global tabTop TabToWidget WidgetToTab
set panel $TabToWidget($tabTop)
send $panel set state 0
} ; send panelClose addCallback pbPanelDismiss
proc pbResizeCB {widget event a b c d e args} \
{
global pbTabTop TabToWidget WidgetToTab
if { $a == 0 && $b == 0 && $c == 0 && $d == 0 && $e == 0 } {
send $pbTabTop set state 0
set new $TabToWidget($widget)
send $new set state 1
set pbTabTop $new
}
} ; foreach w $cpTabs {send $w addEventHandler pbResizeCB exposureMask}
proc pbPanelTabs { widget type state args } \
{
global pbTabTop tabTop panel_up
global TabToWidget WidgetToTab
set panel $WidgetToTab($widget)
if {$tabTop == $panel && $panel_up} {
send panelShell unmap
send $widget set state 0
set panel_up 0
return
}
send $TabToWidget($tabTop) set state 0
set tabTop $panel
set pbTabTop $TabToWidget($panel)
send panelTabs setTop $panel
# Now fire it up if it's not already open.
if {$panel_up == 0} {
send $widget set state 1
send panelShell map
set panel_up 1
}
}
foreach w { pbDisplayP pbInfoP pbLoadP pbPrintP pbSaveP pbTileP pbCoordP } {
send $w addCallback pbPanelTabs
}
# Load Panel. (Really need to clean this up.)
#------------------------------------------------------
proc pbDoLoadOptions { param old new } \
{
set val [ join [lrange $new 1 end] " " ]
switch [lindex $new 0] {
newfile { send fnameText set string $val }
}
} ; send loadOptions addCallback pbDoLoadOptions
proc pbFileLoad { widget mode fname args } \
{
set fpath [format "%s/%s" \
[string range [send dirLabel get label] 12 end] $fname ]
send imagewin setCursorType idle
} ; send fnameText addCallback pbFileLoad
proc pbflSelectPrint {widget cbtype selections args} \
{
foreach selection $selections {
;
}
}; #send imageList addCallback pbflSelectPrint
proc pbFileLoadB args \
{
set fname [send fnameText get string]
if {$fname != ""} {
set fpath [format "%s/%s" \
[string range [send dirLabel get label] 12 end] $fname ]
}
} ; send filesLoadButton addCallback pbFileLoadB
# Panner Marker.
#------------------------------------------------------
proc pbTracePanner {name element op} \
{
global last_compass
catch {
upvar $name panner_enable
send pbPanM set state $panner_enable
if { $panner_enable } {
send tbCompass "setSensitive True ; set state $last_compass"
drawCompass
} else {
send tbCompass "setSensitive False ; set state False"
eraseCompass
}
}
} ; trace variable panner_enable w pbTracePanner
proc pannerPanel args \
{
global panner_enable displayPanner
setPanner [expr !$panner_enable]
send pannerButton set on [expr $panner_enable]
}; send pbPanM addCallback pannerPanel
# Magnifier Marker.
#------------------------------------------------------
proc pbTraceMagnifier {name element op} \
{
upvar $name magnifier_enable
send pbMagM set state $magnifier_enable
} ; trace variable magnifier_enable w pbTraceMagnifier
proc magnifierPanel args \
{
global magnifier_enable displayMagnifier
setMagnifier [expr !$magnifier_enable]
send magnifierButton set on [expr $magnifier_enable]
}; send pbMagM addCallback magnifierPanel
# CoordsBox Marker.
#------------------------------------------------------
proc pbTraceCoordsBox {name element op} \
{
upvar $name track_enable
send pbWcsM set state $track_enable
} ; trace variable track_enable w pbTraceCoordsBox
proc wcsPanel args \
{
global track_enable
setTrack [expr !$track_enable]
}; send pbWcsM addCallback wcsPanel
# WPIX ISM Callbacks.
#------------------------------------------------------
proc altIsmToggle { widget type state args } \
{
ismToggle pbIsm junk $state
} ; send pbIsm addCallback altIsmToggle
proc pbTraceIsm {name element op} \
{
upvar $name ism_enable
send pbIsm set state $ism_enable
} ; trace variable ism_enable w pbTraceIsm
proc altIsmMsgCB { param old new } \
{
set cmd [lindex $new 0] ;# command name
set ism [lindex $new 1] ;# determine ISM name
set argv [lrange $new 2 end] ;# get args
set argc [llength $argv]
switch $cmd {
deliver { ${ism}_alt_msg $argc $argv }
}
} ; send ism_msg addCallback altIsmMsgCB
proc wcspix_alt_msg { argc argv } \
{
set arg [string trimleft [ string trimright [lindex $argv 0] ] ]
set cmd [lindex $arg 0]
switch $cmd {
startup { }
shutdown { }
disable { send pbIsm "set state False ; setSensitive False" }
capable { send pbIsm "setSensitive True" }
}
}
##############################################
# Toolbar callbacks.
##############################################
send tbNormalize addCallback normalize
send tbInvert addCallback cpInvert
send tbRegister addCallback cpRegisterFrames
send tbMatchLUT addCallback cpMatchFrames
# Frame Selection.
#------------------
createMenu mFrameMenu mFrameButton $frameMenuDescription
proc altFrameChanged {param old new} \
{
send mFrameButton set label $new
} ; send frame addCallback altFrameChanged
# Image Flipping.
#------------------------------------------------------
proc tbSetFlip {param old new} \
{
if {$param == "xflip"} {
send mXflipButton set state [true $new]
} else {
send mYflipButton set state [true $new]
}
}; foreach i {xflip yflip} { send $i addCallback tbSetFlip }
# Zoom/Pan buttons.
#------------------------------------------------------
proc tbZoomAction { widget args } \
{
global frameWidth frameHeight
switch $widget {
tbZoom0 { cpZoom 1 1 fixed }
tbZoomIn { cpZoom 2.0 2.0 relative }
tbZoomOut { cpZoom 0.5 0.5 relative }
tbCenter { send client pan [expr $frameWidth/2.0] [expr $frameHeight/2.0] }
}
}
foreach widget { tbCenter tbZoomIn tbZoom0 tbZoomOut } {
send $widget addCallback tbZoomAction
}
# Frame Blink.
#------------------------------------------------------
proc tbSetBlinkRate {w args} \
{
if {$w == "tbBlinkInc"} {
cpSetBlinkRate BRincrease
} else {
cpSetBlinkRate BRdeccrease
}
}
foreach w {tbBlinkDec tbBlinkInc} { send $w addCallback tbSetBlinkRate }
proc tbBlink { widget args } \
{
global blinkRate blinkId
if {$blinkRate < 0.01} {
send tbBlink set state 0
} else {
if {$widget != "tbBlink"} {
if {($blinkId != 0) != [send $widget get on]} {
toggleBlink
}
} else {
if {($blinkId != 0) != [send $widget get state]} {
toggleBlink
}
}
}
} ; send tbBlink addCallback tbBlink
proc tbTraceBlink {name element op} \
{
upvar $name blinkId
send tbBlink set state [expr $blinkId != 0]
} ; trace variable blinkId w tbTraceBlink
# Auto-register.
#------------------------------------------------------
proc tbAutoRegister { widget type state args } \
{
send tbAutoReg set state $state
}
foreach w {autoregButton brAregButton tbAutoReg} {
send $w addCallback cpAutoRegister
}
proc tbToggleAutoReg args \
{
global auto_reg
if {$auto_reg} {
cpAutoRegister autoregButton dummy 0
set auto_reg 0
} else {
cpAutoRegister autoregButton dummy 1
set auto_reg 1
}
}
# Frame Tiles.
#------------------------------------------------------
proc tbSetTileFrames args \
{
global tileOpt
# Send the option to the client.
if {[send tbTile get state ]} {
if {$tileOpt == 0} {
# If mode is disabled, turn on the tile selection.
selectTileOrientation junk junk Best
} else {
# Otherwise, turn on in current mode.
selectTileOrientation junk junk [tileSelToLabel $tileOpt]
}
} else {
selectTileOrientation junk junk Disabled
}
}; send tbTile addCallback tbSetTileFrames
proc tbTrackTileFrames {param old new} \
{
send tileFramesButton set on [true $new]
send tbTile set state $new
}; send tileFrames addCallback tbTrackTileFrames
proc tbTileFramesToggle args \
{
set value [send tileFramesButton get on]
if {$value} { set not 0 } else { set not 1 }
send tileFramesButton set on [expr $not]
send tbTile set on [expr $not]
cpSetTileFrames
}
# Compass Indicator.
#------------------------------------------------------
proc tbToggleCompass { widget type state args } \
{
global frame
if {$state} {
send compass set on True
send tbCompass set state 1
drawCompass
} else {
send compass set on False
send tbCompass set state 0
eraseCompass
}
} ; foreach w {compass tbCompass} { send $w addCallback tbToggleCompass }
|