-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui_left.tcl
490 lines (362 loc) · 17.3 KB
/
gui_left.tcl
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
global edit_icons
global regionshape_icons
global x11_colors
global color_icons
global regwidth_icons
set edit_icons [list [image create photo -file "$ds9_hack_root/UI/edit_none.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_region.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_crosshair.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_colorbar.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_pan.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_zoom.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_rotate.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_crop.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_catalog.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_footprint.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_3d.png" ] \
[image create photo -file "$ds9_hack_root/UI/edit_examine.png" ] \
]
set regionshape_icons [ list [image create photo -file "$ds9_hack_root/UI/circle.png"] \
[image create photo -file "$ds9_hack_root/UI/annulus.png"] \
[image create photo -file "$ds9_hack_root/UI/ellipse.png"] \
[image create photo -file "$ds9_hack_root/UI/box.png"] \
[image create photo -file "$ds9_hack_root/UI/poly.png"] \
[image create photo -file "$ds9_hack_root/UI/text.png"] \
[image create photo -file "$ds9_hack_root/UI/region_other.png"] \
]
set x11_colors [list \
"red" "floralwhite" "mistyrose" "seashell" "snow" "linen" "oldlace" \
"whitesmoke" "gainsboro" "lightgray" "dimgray" "green" "bisque" \
"blanchedalmond" "papayawhip" "antiquewhite" "rosybrown" "moccasin" \
"navajowhite" "peachpuff" "wheat" "tan" "blue" "darksalmon" "lightcoral" \
"burlywood" "lightsalmon" "indianred2" "salmon" "sandybrown" "indianred" \
"coral" "tomato" "cyan" "peru" "brown" "sienna" "chocolate" "goldenrod" \
"saddlebrown" "darkgoldenrod" "darkorange" "orangered" "ivory" "magenta" \
"lightyellow" "beige" "cornsilk" "lemonchiffon" "lightgoldenrodyellow" \
"palegoldenrod" "khaki" "lightgoldenrod" "darkkhaki" "darkolivegreen" \
"yellow" "greenyellow" "yellowgreen" "olivedrab" "gold" "honeydew" \
"darkseagreen" "palegreen" "limegreen" "forestgreen" "chartreuse" \
"black" "lawngreen" "darkgreen" "mintcream" "aquamarine" "turquoise" \
"seagreen" "lightseagreen" "springgreen" "aliceblue" "azure" "white" \
"lightcyan" "lightblue" "powderblue" "lightsteelblue" "lightslategray" \
"slategray" "paleturquoise" "lightskyblue" "skyblue" "cadetblue" "grey" \
"darkslategray" "cornflowerblue" "steelblue" "royalblue" "dodgerblue" \
"deepskyblue" "darkturquoise" "ghostwhite" "lavender" "lightslateblue" \
"orange" "slateblue" "darkslateblue" "midnightblue" "mediumblue" \
"navyblue" "thistle" "plum" "orchid" "blueviolet" "purple" "violet" \
"darkorchid" "darkviolet" "lavenderblush" "pink" "lightpink" \
"palevioletred" "hotpink" "maroon" "violetred" "deeppink" \
]
set regwidth_icons [list [image create photo -file "$ds9_hack_root/UI/lw1.png" ] \
[image create photo -file "$ds9_hack_root/UI/lw1.png" ] \
[image create photo -file "$ds9_hack_root/UI/lw2.png" ] \
[image create photo -file "$ds9_hack_root/UI/lw3.png" ] \
[image create photo -file "$ds9_hack_root/UI/lw4.png" ] ]
proc setup_left_button_bar {} {
global ds9
global current
global marker
if { [winfo exists $ds9(main).hack_left] } {
return
}
ttk::frame $ds9(main).hack_left
set ds9(hack_left) $ds9(main).hack_left
# Edit menu icons
setup_edit_menu_icons
pack $ds9(hack_left).edit_menu -side top -fill x
setup_shape_icons
pack $ds9(hack_left).shapes -side top -fill x
pack $ds9(hack_left).info -side top -fill x
pack $ds9(hack_left).list -side top -fill x
pack $ds9(hack_left).open -side top -fill x
pack $ds9(hack_left).save -side top -fill x
setup_region_color_icons
pack $ds9(hack_left).colors -side top -fill x
# width
setup_region_width_icons
pack $ds9(hack_left).size -side top -fill x
# state/layer/others
setup_region_prop_icons
pack $ds9(hack_left).src -side top -fill x
pack $ds9(hack_left).inc -side top -fill x
pack $ds9(hack_left).back -side top -fill x
pack $ds9(hack_left).front -side top -fill x
pack $ds9(hack_left).compose -side top -fill x
pack $ds9(hack_left).dissolve -side top -fill x
pack $ds9(hack_left).group -side top -fill x
if { ![catch {package present tooltip}] } {
tooltip::tooltip $ds9(hack_left).edit_menu "Edit Mode"
tooltip::tooltip $ds9(hack_left).shapes "Region Shape"
tooltip::tooltip $ds9(hack_left).info "Get Region Info"
tooltip::tooltip $ds9(hack_left).list "List Region"
tooltip::tooltip $ds9(hack_left).open "Load Region File"
tooltip::tooltip $ds9(hack_left).save "Save Region File"
tooltip::tooltip $ds9(hack_left).colors "Region Color"
tooltip::tooltip $ds9(hack_left).size "Region Line Width"
tooltip::tooltip $ds9(hack_left).src "Toggle Source/Background"
tooltip::tooltip $ds9(hack_left).inc "Toggle Include/Exclude"
tooltip::tooltip $ds9(hack_left).back "Send to Back"
tooltip::tooltip $ds9(hack_left).front "Bring to Front"
tooltip::tooltip $ds9(hack_left).compose "Create Composite Region"
tooltip::tooltip $ds9(hack_left).dissolve "Dissolve Composite Region"
tooltip::tooltip $ds9(hack_left).group "Tag New Region Group"
}
trace add variable current(mode) write "sync_edit_mode"
trace add variable marker(shape) write "sync_region_shape"
trace add variable marker(color) write "sync_region_color"
trace add variable marker(width) write "sync_region_width"
}
proc setup_edit_menu_icons {} {
global ds9
global edit_icons
ttk::menubutton $ds9(hack_left).edit_menu -menu $ds9(hack_left).edit_menu.m \
-text "Edit Mode" -direction right \
-image [lindex $edit_icons 1] -takefocus 0
menu $ds9(hack_left).edit_menu.m -tearoff 0
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {None}] -command "button_change_edit 0 none" \
-image [lindex $edit_icons 0] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Region}] -command "button_change_edit 1 region" \
-image [lindex $edit_icons 1] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Crosshair}] -command "button_change_edit 2 crosshair" \
-image [lindex $edit_icons 2] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Colorbar}] -command "button_change_edit 3 colorbar" \
-image [lindex $edit_icons 3] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Pan}] -command "button_change_edit 4 pan" \
-image [lindex $edit_icons 4] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Zoom}] -command "button_change_edit 5 zoom" \
-image [lindex $edit_icons 5] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Rotate}] -command "button_change_edit 6 rotate" \
-image [lindex $edit_icons 6] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Crop}] -command "button_change_edit 7 crop" \
-image [lindex $edit_icons 7] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Catalog}] -command "button_change_edit 8 catalog" \
-image [lindex $edit_icons 8] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Footprint}] -command "button_change_edit 9 footprint" \
-image [lindex $edit_icons 9] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {3D}] -command "button_change_edit 10 3d" \
-image [lindex $edit_icons 10] -compound left
$ds9(hack_left).edit_menu.m add command -label [msgcat::mc {Examine}] -command "button_change_edit 11 examine" \
-image [lindex $edit_icons 11] -compound left
}
proc setup_shape_icons {} {
global ds9
global regionshape_icons
global ds9_hack_root
ttk::menubutton $ds9(hack_left).shapes -menu $ds9(hack_left).shapes.m \
-text "Region Shapes" -direction right \
-image [lindex $regionshape_icons 0] -takefocus 0
menu $ds9(hack_left).shapes.m -tearoff 0
$ds9(hack_left).shapes.m add command -label [msgcat::mc {Circle}] \
-command "button_change_marker 0 circle" \
-image [lindex $regionshape_icons 0] -compound left
$ds9(hack_left).shapes.m add command -label [msgcat::mc {Annulus}] \
-command "button_change_marker 1 annulus" \
-image [lindex $regionshape_icons 1] -compound left
$ds9(hack_left).shapes.m add command -label [msgcat::mc {Ellipse}] \
-command "button_change_marker 2 ellipse" \
-image [lindex $regionshape_icons 2] -compound left
$ds9(hack_left).shapes.m add command -label [msgcat::mc {Box}] \
-command "button_change_marker 3 box" \
-image [lindex $regionshape_icons 3] -compound left
$ds9(hack_left).shapes.m add command -label [msgcat::mc {Polygon}] \
-command "button_change_marker 4 polygon" \
-image [lindex $regionshape_icons 4] -compound left
$ds9(hack_left).shapes.m add command -label [msgcat::mc {Text}] \
-command "button_change_marker 5 text" \
-image [lindex $regionshape_icons 5] -compound left
ttk::button $ds9(hack_left).info -text {Region Info} \
-takefocus 0 -command {ds9Cmd "-region getinfo"} \
-image [image create photo -file "$ds9_hack_root/UI/region_info.png"]
ttk::button $ds9(hack_left).list -text {Region List} \
-takefocus 0 -command {ds9Cmd "-region list"} \
-image [image create photo -file "$ds9_hack_root/UI/region_list.png"]
ttk::button $ds9(hack_left).open -text {Region Open} \
-takefocus 0 -command MarkerLoad \
-image [image create photo -file "$ds9_hack_root/UI/region_open.png"]
ttk::button $ds9(hack_left).save -text {Region Save} \
-takefocus 0 -command [list MarkerSave {}] \
-image [image create photo -file "$ds9_hack_root/UI/region_save.png"]
}
proc setup_region_color_icons {} {
global ds9
global ds9_hack_root
global color_icons
global x11_colors
set color_icons {}
foreach clr $x11_colors {
image create photo icon_$clr -file "$ds9_hack_root/UI/colors/$clr.png"
lappend color_icons icon_$clr
}
ttk::menubutton $ds9(hack_left).colors -menu $ds9(hack_left).colors.m \
-text "Region Color" -direction right \
-image [make_color_button_image 11] -takefocus 0
menu $ds9(hack_left).colors.m -tearoff 0
for {set ii 0} { $ii < [llength $color_icons]} {incr ii} {
set rr [expr $ii % 11]
if { $rr == 0 } {
set newcol 1
} else {
set newcol 0
}
$ds9(hack_left).colors.m add command \
-label [lindex $x11_colors $ii] \
-image [lindex $color_icons $ii] \
-command "button_change_color $ii" \
-columnbreak $newcol \
-hidemargin 1
}
}
proc make_color_button_image { newval } {
global color_icons
image create photo clr_retval -height 22 -width 22
set curimg [lindex $color_icons $newval]
clr_retval copy $curimg -zoom 2
return clr_retval
}
proc setup_region_width_icons {} {
global ds9
global regwidth_icons
ttk::menubutton $ds9(hack_left).size -menu $ds9(hack_left).size.m \
-text "Region Width" -direction right \
-image [make_button_image 1] -takefocus 0
menu $ds9(hack_left).size.m -tearoff 0
$ds9(hack_left).size.m add command -label "1" -command "button_change_width 1" \
-image [lindex $regwidth_icons 1] -compound left
$ds9(hack_left).size.m add command -label "2" -command "button_change_width 2" \
-image [lindex $regwidth_icons 2] -compound left
$ds9(hack_left).size.m add command -label "3" -command "button_change_width 3" \
-image [lindex $regwidth_icons 3] -compound left
$ds9(hack_left).size.m add command -label "4" -command "button_change_width 4" \
-image [lindex $regwidth_icons 4] -compound left
}
proc make_button_image { newval } {
global ds9
global regwidth_icons
image create photo rw_retval -height 22 -width 22
set curimg [lindex $regwidth_icons $newval]
rw_retval copy $curimg -from 0 0 -to 0 5
return rw_retval
}
proc setup_region_prop_icons {} {
global ds9
global ds9_hack_root
ttk::button $ds9(hack_left).src -text {S/B} -takefocus 0 -command {button_change_srcbkg} \
-image [image create photo -file "$ds9_hack_root/UI/srcbkg.png"]
ttk::button $ds9(hack_left).inc -text {I/E} -takefocus 0 -command {button_change_incexl} \
-image [image create photo -file "$ds9_hack_root/UI/incexl.png"]
ttk::button $ds9(hack_left).back -text {Back} -takefocus 0 -command {MarkerBack } \
-image [image create photo -file "$ds9_hack_root/UI/back.png"]
ttk::button $ds9(hack_left).front -text {Front} -takefocus 0 -command {MarkerFront} \
-image [image create photo -file "$ds9_hack_root/UI/front.png"]
ttk::button $ds9(hack_left).compose -text {Composite} -takefocus 0 -command {CompositeCreate } \
-image [image create photo -file "$ds9_hack_root/UI/region_compose.png"]
ttk::button $ds9(hack_left).dissolve -text {Dissolve} -takefocus 0 -command {CompositeDelete} \
-image [image create photo -file "$ds9_hack_root/UI/region_dissolve.png"]
ttk::button $ds9(hack_left).group -text {Group} -takefocus 0 -command {GroupCreate} \
-image [image create photo -file "$ds9_hack_root/UI/region_group.png"]
}
proc button_change_edit { newval cmd } {
global marker
global ds9
global edit_icons
ds9Cmd "-mode $cmd"
$ds9(hack_left).edit_menu configure -text $newval \
-image [lindex $edit_icons $newval]
}
proc button_change_marker { newval iswhat } {
global marker
global ds9
global regionshape_icons
if { $iswhat != "other" } {
set marker(shape) $iswhat
}
$ds9(hack_left).shapes configure -text $newval \
-image [lindex $regionshape_icons $newval]
}
proc button_change_color {newval} {
global marker
global x11_colors
global color_icons
global ds9
set color [lindex $x11_colors $newval]
set marker(color) $color
MarkerColor
$ds9(hack_left).colors configure \
-image [make_color_button_image $newval]
}
proc button_change_width { newval } {
global marker
global ds9
global regwidth_icons
set marker(width) $newval
$ds9(main).hack_left.size configure -text $newval \
-image [make_button_image $newval]
MarkerWidth
}
proc button_change_srcbkg {} {
global marker
if { $marker(source) == 0 } {
set marker(source) 1
} else {
set marker(source) 0
}
MarkerProp source
}
proc button_change_incexl {} {
global marker
if { $marker(include) == 0 } {
set marker(include) 1
} else {
set marker(include) 0
}
MarkerProp include
}
proc sync_edit_mode {name1 name2 op} {
global current
switch $current(mode) {
none {button_change_edit 0 $current(mode)}
region {button_change_edit 1 $current(mode)}
crosshair {button_change_edit 2 $current(mode)}
colorbar {button_change_edit 3 $current(mode)}
pan {button_change_edit 4 $current(mode)}
zoom {button_change_edit 5 $current(mode)}
rotate {button_change_edit 6 $current(mode)}
crop {button_change_edit 7 $current(mode)}
catalog {button_change_edit 8 $current(mode)}
footprint {button_change_edit 9 $current(mode)}
examine {button_change_edit 10 $current(mode)}
3d {button_change_edit 11 $current(mode)}
}
}
proc sync_region_shape {name1 name2 op} {
global marker
switch $marker(shape) {
circle {button_change_marker 0 $marker(shape)}
annulus {button_change_marker 1 $marker(shape)}
ellipse {button_change_marker 2 $marker(shape)}
box {button_change_marker 3 $marker(shape)}
polygon {button_change_marker 4 $marker(shape)}
text {button_change_marker 5 $marker(shape)}
default {button_change_marker 6 other}
}
}
proc sync_region_width {name1 name2 op} {
global marker
global ds9
global regwidth_icons
set newval $marker(width)
set idx [expr $newval - 1]
$ds9(main).hack_left.size configure -text $newval \
-image [make_button_image $newval]
}
proc sync_region_color {name1 name2 op} {
global marker
global x11_colors
global ds9
set idx [lsearch -exact $x11_colors "$marker(color)"]
if { $idx < 0 } {
set idx 11
}
$ds9(hack_left).colors configure \
-image [make_color_button_image $idx]
}