summaryrefslogtreecommitdiffstats
path: root/ds9/library/mregion.tcl
blob: 08a1539d1d601e0858d623d59071080cb1b3b9cf (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
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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
#  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

# Menus

proc RegionMainMenu {} {
    global ds9
    global marker

    menu $ds9(mb).region
    $ds9(mb).region add command -label "[msgcat::mc {Get Information}]..." \
	-command MarkerInfo
    $ds9(mb).region add separator
    $ds9(mb).region add cascade -label [msgcat::mc {Shape}] \
	-menu $ds9(mb).region.shape
    $ds9(mb).region add cascade -label [msgcat::mc {Composite Region}] \
	-menu $ds9(mb).region.composite
    $ds9(mb).region add cascade -label [msgcat::mc {Instrument FOV}] \
	-menu $ds9(mb).region.fov
    $ds9(mb).region add cascade -label [msgcat::mc {Template}] \
	-menu $ds9(mb).region.template
    $ds9(mb).region add separator
    $ds9(mb).region add cascade -label [msgcat::mc {Color}] \
	-menu $ds9(mb).region.color
    $ds9(mb).region add cascade -label [msgcat::mc {Width}] \
	-menu $ds9(mb).region.width
    $ds9(mb).region add cascade -label [msgcat::mc {Properties}] \
	-menu $ds9(mb).region.properties
    $ds9(mb).region add cascade -label [msgcat::mc {Font}] \
	-menu $ds9(mb).region.font
    $ds9(mb).region add separator
    $ds9(mb).region add command -label [msgcat::mc {Centroid}] \
	-command MarkerCentroid
    $ds9(mb).region add command -label [msgcat::mc {Move to Front}] \
	-command MarkerFront
    $ds9(mb).region add command -label [msgcat::mc {Move to Back}] \
	-command MarkerBack
    $ds9(mb).region add separator
    $ds9(mb).region add command -label [msgcat::mc {New Group}] \
	-command GroupCreate
    $ds9(mb).region add command -label "[msgcat::mc {Groups}]..." \
	-command GroupDialog
    $ds9(mb).region add separator
    $ds9(mb).region add command -label [msgcat::mc {Select All}] \
	-command MarkerSelectAll -accelerator "${ds9(ctrl)}A"
    $ds9(mb).region add command -label [msgcat::mc {Select None}] \
	-command MarkerUnselectAll
    $ds9(mb).region add command -label [msgcat::mc {Invert Selection}] \
	-command MarkerSelectInvert
    $ds9(mb).region add separator
    $ds9(mb).region add command -label [msgcat::mc {Delete Selected Regions}] \
	-command MarkerDeleteSelect
    $ds9(mb).region add command -label [msgcat::mc {Delete All Regions}] \
	-command MarkerDeleteAllMenu
    $ds9(mb).region add separator
    $ds9(mb).region add command -label "[msgcat::mc {List Regions}]..." \
	-command MarkerList
    $ds9(mb).region add command -label "[msgcat::mc {Load Regions}]..." \
	-command MarkerLoad
    $ds9(mb).region add command \
	-label "[msgcat::mc {Delete and Load Regions}]..." \
	-command MarkerDeleteLoad
    $ds9(mb).region add separator
    $ds9(mb).region add command -label "[msgcat::mc {Save Regions}]..." \
	-command MarkerSave
    $ds9(mb).region add separator
    $ds9(mb).region add cascade -label [msgcat::mc {Region Parameters}] \
	-menu $ds9(mb).region.params

    menu $ds9(mb).region.shape
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Circle}] \
	-variable marker(shape) -value circle
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Ellipse}] \
	-variable marker(shape) -value ellipse
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Box}] \
	-variable marker(shape) -value box
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Polygon}] \
	-variable marker(shape) -value polygon
    $ds9(mb).region.shape add separator
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Line}] \
	-variable marker(shape) -value line
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Vector}] \
	-variable marker(shape) -value vector
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Projection}] \
	-variable marker(shape) -value projection
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Segment}] \
	-variable marker(shape) -value segment
    $ds9(mb).region.shape add separator
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Text}] \
	-variable marker(shape) -value text
    $ds9(mb).region.shape add cascade -label [msgcat::mc {Point}] \
	-menu $ds9(mb).region.shape.point
    $ds9(mb).region.shape add separator
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Ruler}] \
	-variable marker(shape) -value ruler
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Compass}] \
	-variable marker(shape) -value compass
    $ds9(mb).region.shape add separator
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Annulus}] \
	-variable marker(shape) -value annulus
    $ds9(mb).region.shape add radiobutton \
	-label [msgcat::mc {Elliptical Annulus}] \
	-variable marker(shape) -value ellipseannulus
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Box Annulus}] \
	-variable marker(shape) -value boxannulus
    $ds9(mb).region.shape add separator
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Panda}] \
	-variable marker(shape) -value panda
    $ds9(mb).region.shape add radiobutton \
	-label [msgcat::mc {Elliptical Panda}]\
	-variable marker(shape) -value epanda
    $ds9(mb).region.shape add radiobutton -label [msgcat::mc {Box Panda}] \
	-variable marker(shape) -value bpanda

    menu $ds9(mb).region.shape.point
    $ds9(mb).region.shape.point add radiobutton -label [msgcat::mc {Circle}] \
	-variable marker(shape) -value {circle point}
    $ds9(mb).region.shape.point add radiobutton -label [msgcat::mc {Box}] \
	-variable marker(shape) -value {box point}
    $ds9(mb).region.shape.point add radiobutton -label [msgcat::mc {Diamond}] \
	-variable marker(shape) -value {diamond point}
    $ds9(mb).region.shape.point add radiobutton -label [msgcat::mc {Cross}] \
	-variable marker(shape) -value {cross point}
    $ds9(mb).region.shape.point add radiobutton -label [msgcat::mc {X}] \
	-variable marker(shape) -value {x point}
    $ds9(mb).region.shape.point add radiobutton -label [msgcat::mc {Arrow}] \
	-variable marker(shape) -value {arrow point}
    $ds9(mb).region.shape.point add radiobutton -label [msgcat::mc {BoxCircle}]\
	-variable marker(shape) -value {boxcircle point}

    menu $ds9(mb).region.composite
    $ds9(mb).region.composite add command -label [msgcat::mc {Create}] \
	-command CompositeCreate
    $ds9(mb).region.composite add command -label [msgcat::mc {Dissolve}] \
	-command CompositeDelete

    CreateFOVMenu

    menu $ds9(mb).region.template
    $ds9(mb).region.template add command -label "[msgcat::mc {Load}]..." \
	-command OpenTemplateMarker
    $ds9(mb).region.template add command -label "[msgcat::mc {Save}]..." \
	-command SaveAsTemplateMarker

    ColorMenu $ds9(mb).region.color marker color MarkerColor
    WidthDashMenu $ds9(mb).region.width marker width dash \
	MarkerWidth [list MarkerProp dash]

    menu $ds9(mb).region.properties
    $ds9(mb).region.properties add checkbutton \
	-label [msgcat::mc {Fixed in Size}] \
	-variable marker(fixed) -command {MarkerProp fixed}
    $ds9(mb).region.properties add separator
    $ds9(mb).region.properties add checkbutton \
	-label [msgcat::mc {Can Edit}] \
	-variable marker(edit) -command {MarkerProp edit}
    $ds9(mb).region.properties add checkbutton \
	-label [msgcat::mc {Can Move}] \
	-variable marker(move) -command {MarkerProp move}
    $ds9(mb).region.properties add checkbutton \
	-label [msgcat::mc {Can Rotate}] \
	-variable marker(rotate) -command {MarkerProp rotate}
    $ds9(mb).region.properties add checkbutton \
	-label [msgcat::mc {Can Delete}] \
	-variable marker(delete) -command {MarkerProp delete}
    $ds9(mb).region.properties add separator
    $ds9(mb).region.properties add radiobutton \
	-label [msgcat::mc {Include}] \
	-variable marker(include) -value 1 -command {MarkerProp include}
    $ds9(mb).region.properties add radiobutton \
	-label [msgcat::mc {Exclude}] \
	-variable marker(include) -value 0 -command {MarkerProp include}
    $ds9(mb).region.properties add separator
    $ds9(mb).region.properties add radiobutton \
	-label [msgcat::mc {Source}] \
	-variable marker(source) -value 1 -command {MarkerProp source}
    $ds9(mb).region.properties add radiobutton \
	-label [msgcat::mc {Background}] \
	-variable marker(source) -value 0 -command {MarkerProp source}

    FontMenu $ds9(mb).region.font marker font font,size font,weight \
	font,slant MarkerFont

    menu $ds9(mb).region.params
    $ds9(mb).region.params add checkbutton \
	-label [msgcat::mc {Show}] \
	-variable marker(show) -command MarkerShow
    $ds9(mb).region.params add checkbutton \
	-label [msgcat::mc {Show Text}] \
	-variable marker(show,text) -command MarkerShowText
    $ds9(mb).region.params add separator
    $ds9(mb).region.params add checkbutton \
	-label [msgcat::mc {Auto Plot 2D}] -variable marker(plot2d)
    $ds9(mb).region.params add checkbutton \
	-label [msgcat::mc {Auto Plot 3D}] -variable marker(plot3d)
    $ds9(mb).region.params add checkbutton \
	-label [msgcat::mc {Auto Plot Statistics}] -variable marker(stats)
    $ds9(mb).region.params add separator
    $ds9(mb).region.params add checkbutton \
	-label [msgcat::mc {Auto Centroid}] \
	-variable marker(centroid,auto) -command MarkerCentroidAuto
    $ds9(mb).region.params add command \
	-label "[msgcat::mc {Centroid Parameters}]..." \
	-command CentroidDialog

    # Bindings
    bind $ds9(top) <<SelectAll>> MarkerSelectAll
}

proc PrefsDialogRegionMenu {w} {
    set f [ttk::labelframe $w.mregion -text [msgcat::mc {Region}]]

    ttk::menubutton $f.menu -text [msgcat::mc {Menu}] -menu $f.menu.menu
    PrefsDialogButtonbarRegion $f.buttonbar

    grid $f.menu $f.buttonbar -padx 2 -pady 2 -sticky w

    set m $f.menu.menu
    menu $m
    $m add cascade -label [msgcat::mc {Shape}] -menu $m.shape
    $m add separator
    $m add cascade -label [msgcat::mc {Color}] -menu $m.color
    $m add cascade -label [msgcat::mc {Width}] -menu $m.width
    $m add cascade -label [msgcat::mc {Properties}] -menu $m.properties
    $m add cascade -label [msgcat::mc {Font}] -menu $m.font
    $m add separator
    $m add cascade -label [msgcat::mc {Region Parameters}] -menu $m.params

    menu $m.shape
    $m.shape add radiobutton -label [msgcat::mc {Circle}] \
	-variable pmarker(shape) -value circle
    $m.shape add radiobutton -label [msgcat::mc {Ellipse}] \
	-variable pmarker(shape) -value ellipse
    $m.shape add radiobutton -label [msgcat::mc {Box}] \
	-variable pmarker(shape) -value box
    $m.shape add radiobutton -label [msgcat::mc {Polygon}] \
	-variable pmarker(shape) -value polygon
    $m.shape add separator
    $m.shape add radiobutton -label [msgcat::mc {Line}] \
	-variable pmarker(shape) -value line
    $m.shape add radiobutton -label [msgcat::mc {Vector}] \
	-variable pmarker(shape) -value vector
    $m.shape add radiobutton -label [msgcat::mc {Projection}] \
	-variable pmarker(shape) -value projection
    $m.shape add radiobutton -label [msgcat::mc {Segment}] \
	-variable pmarker(shape) -value segment
    $m.shape add separator
    $m.shape add radiobutton -label [msgcat::mc {Text}] \
	-variable pmarker(shape) -value text
    $m.shape add cascade -label [msgcat::mc {Point}] \
	-menu $m.shape.point
    $m.shape add separator
    $m.shape add radiobutton -label [msgcat::mc {Ruler}] \
	-variable pmarker(shape) -value ruler
    $m.shape add radiobutton -label [msgcat::mc {Compass}] \
	-variable pmarker(shape) -value compass
    $m.shape add separator
    $m.shape add radiobutton -label [msgcat::mc {Annulus}] \
	-variable pmarker(shape) -value annulus
    $m.shape add radiobutton -label [msgcat::mc {Elliptical Annulus}] \
	-variable pmarker(shape) -value ellipseannulus
    $m.shape add radiobutton -label [msgcat::mc {Box Annulus}] \
	-variable pmarker(shape) -value boxannulus
    $m.shape add separator
    $m.shape add radiobutton -label [msgcat::mc {Panda}] \
	-variable pmarker(shape) -value panda
    $m.shape add radiobutton -label [msgcat::mc {Elliptical Panda}] \
	-variable pmarker(shape) -value epanda
    $m.shape add radiobutton -label [msgcat::mc {Box Panda}] \
	-variable pmarker(shape) -value bpanda

    menu $m.shape.point
    $m.shape.point add radiobutton -label [msgcat::mc {Circle}] \
	-variable pmarker(shape) -value {circle point}
    $m.shape.point add radiobutton -label [msgcat::mc {Box}] \
	-variable pmarker(shape) -value {box point}
    $m.shape.point add radiobutton -label [msgcat::mc {Diamond}] \
	-variable pmarker(shape) -value {diamond point}
    $m.shape.point add radiobutton -label [msgcat::mc {Cross}] \
	-variable pmarker(shape) -value {cross point}
    $m.shape.point add radiobutton -label [msgcat::mc {X}] \
	-variable pmarker(shape) -value {x point}
    $m.shape.point add radiobutton -label [msgcat::mc {Arrow}] \
	-variable pmarker(shape) -value {arrow point}
    $m.shape.point add radiobutton -label [msgcat::mc {BoxCircle}]\
	-variable pmarker(shape) -value {boxcircle point}

    ColorMenu $m.color pmarker color {}
    WidthDashMenu $m.width pmarker width dash {} {}

    menu $m.properties
    $m.properties add checkbutton -label [msgcat::mc {Fixed in Size}] \
	-variable pmarker(fixed)
    $m.properties add separator
    $m.properties add checkbutton -label [msgcat::mc {Can Edit}] \
	-variable pmarker(edit)
    $m.properties add checkbutton -label [msgcat::mc {Can Move}] \
	-variable pmarker(move)
    $m.properties add checkbutton -label [msgcat::mc {Can Rotate}] \
	-variable pmarker(rotate)
    $m.properties add checkbutton -label [msgcat::mc {Can Delete}] \
	-variable pmarker(delete)
    $m.properties add separator
    $m.properties add radiobutton -label [msgcat::mc {Include}] \
	-variable pmarker(include) -value 1
    $m.properties add radiobutton -label [msgcat::mc {Exclude}] \
	-variable pmarker(include) -value 0
    $m.properties add separator
    $m.properties add radiobutton -label [msgcat::mc {Source}] \
	-variable pmarker(source) -value 1
    $m.properties add radiobutton -label [msgcat::mc {Background}] \
	-variable pmarker(source) -value 0

    FontMenu $m.font pmarker font font,size font,weight font,slant {}

    menu $m.params
    $m.params add checkbutton -label [msgcat::mc {Show}] \
	-variable pmarker(show)
    $m.params add checkbutton -label [msgcat::mc {Show Text}] \
	-variable pmarker(show,text)
    $m.params add separator
    $m.params add checkbutton -label [msgcat::mc {Auto Centroid}] \
	-variable pmarker(centroid,auto)

    pack $f -side top -fill both -expand true
}

proc PrefsDialogRegion {} {
    global dprefs

    set w $dprefs(tab)

    $dprefs(list) insert end [msgcat::mc {Region}]
    lappend dprefs(tabs) [ttk::frame $w.region]

    # Format
    set f [ttk::labelframe $w.region.format -text [msgcat::mc {Default Format}]]

    ttk::menubutton $f.format -textvariable pmarker(format) \
	-menu $f.format.menu

    grid $f.format -padx 2 -pady 2 -sticky w

    menu $f.format.menu
    $f.format.menu add radiobutton -label {DS9/Funtools} \
	-variable pmarker(format) -value ds9
    $f.format.menu add radiobutton -label {XML} \
	-variable pmarker(format) -value xml
    $f.format.menu add radiobutton -label {CIAO} \
	-variable pmarker(format) -value ciao
    $f.format.menu add radiobutton -label {SAOtng} \
	-variable pmarker(format) -value saotng
    $f.format.menu add radiobutton -label {SAOimage} \
	-variable pmarker(format) -value saoimage
    $f.format.menu add radiobutton -label {IRAF PROS} \
	-variable pmarker(format) -value pros
    $f.format.menu add radiobutton -label {X Y} \
	-variable pmarker(format) -value xy

    # Length
    set f [ttk::labelframe $w.region.dformat \
	       -text [msgcat::mc {Default Length}]]

    ttk::menubutton $f.dformat -textvariable pmarker(dformat) \
	-menu $f.dformat.menu

    grid $f.dformat -padx 2 -pady 2 -sticky w

    menu $f.dformat.menu
    $f.dformat.menu add radiobutton -label {Degrees} \
	-variable pmarker(dformat) -value degrees
    $f.dformat.menu add radiobutton -label {ArcMin} \
	-variable pmarker(dformat) -value arcmin
    $f.dformat.menu add radiobutton -label {ArcSec} \
	-variable pmarker(dformat) -value arcsec

    # Epsilon
    set f [ttk::labelframe $w.region.epsilon \
	       -text [msgcat::mc {Mouse Click Epsilon}]]

    ttk::label $f.title -text [msgcat::mc {Pixels}]
    ttk::menubutton $f.epsilon -textvariable pmarker(epsilon) \
	-menu $f.epsilon.menu

    grid $f.title $f.epsilon -padx 2 -pady 2 -sticky w

    menu $f.epsilon.menu
    $f.epsilon.menu add radiobutton -label {2} -variable pmarker(epsilon) \
	-value 2 -command MarkerEpsilon
    $f.epsilon.menu add radiobutton -label {3} -variable pmarker(epsilon) \
	-value 3 -command MarkerEpsilon
    $f.epsilon.menu add radiobutton -label {4} -variable pmarker(epsilon) \
	-value 4 -command MarkerEpsilon
    $f.epsilon.menu add radiobutton -label {5} -variable pmarker(epsilon) \
	-value 5 -command MarkerEpsilon
    $f.epsilon.menu add radiobutton -label {6} -variable pmarker(epsilon) \
	-value 6 -command MarkerEpsilon
    $f.epsilon.menu add radiobutton -label {8} -variable pmarker(epsilon) \
	-value 8 -command MarkerEpsilon
    $f.epsilon.menu add radiobutton -label {10} -variable pmarker(epsilon) \
	-value 10 -command MarkerEpsilon

    grid $f.title $f.epsilon -padx 2 -pady 2 -sticky w

    # Centroid
    set f [ttk::labelframe $w.region.centroid -text [msgcat::mc {Centroid}]]

    ttk::label $f.ititle -text [msgcat::mc {Iteration}]
    ttk::entry $f.iteration -textvariable pmarker(centroid,iteration) -width 10
    ttk::label $f.rtitle -text [msgcat::mc {Radius}]
    ttk::entry $f.radius -textvariable pmarker(centroid,radius) -width 10
   
    grid $f.ititle $f.iteration $f.rtitle $f.radius -padx 2 -pady 2 -sticky w
    # Plots
    set f [ttk::labelframe $w.region.plot -text [msgcat::mc {Auto Plot}]]
    ttk::checkbutton $f.2d -text [msgcat::mc {2D}] -variable pmarker(plot2d)
    ttk::checkbutton $f.3d -text [msgcat::mc {3D}] -variable pmarker(plot3d)
    ttk::checkbutton $f.stats -text [msgcat::mc {Statistics}] \
	-variable pmarker(stats)

    grid $f.2d $f.3d -padx 2 -pady 2 -sticky w
    grid $f.stats -padx 2 -pady 2 -sticky w

    # Circle
    set f [ttk::labelframe $w.region.circle -text [msgcat::mc {Circle}]]

    ttk::label $f.title -text [msgcat::mc {Radius}]
    ttk::entry $f.radius -textvariable pmarker(circle,radius) -width 10
    ttk::label $f.unit -text [msgcat::mc {Image}]
   
    grid $f.title $f.radius $f.unit -padx 2 -pady 2 -sticky w

    # Ellipse
    set f [ttk::labelframe $w.region.ellipse -text [msgcat::mc {Ellipse}]]

    ttk::label $f.title -text "Radius 1"
    ttk::entry $f.radius1 -textvariable pmarker(ellipse,radius1) -width 10 
    ttk::label $f.unit -text [msgcat::mc {Image}]
    
    ttk::label $f.title2 -text "Radius 2"
    ttk::entry $f.radius2 -textvariable pmarker(ellipse,radius2) -width 10 
    ttk::label $f.unit2 -text [msgcat::mc {Image}]

    grid $f.title $f.radius1 $f.unit -padx 2 -pady 2 -sticky w
    grid $f.title2 $f.radius2 $f.unit2 -padx 2 -pady 2 -sticky w
    
    # Box
    set f [ttk::labelframe $w.region.box -text [msgcat::mc {Box}]]

    ttk::label $f.title -text "Size 1"
    ttk::entry $f.radius1 -textvariable pmarker(box,radius1) -width 10 
    ttk::label $f.unit -text [msgcat::mc {Image}]
    
    ttk::label $f.title2 -text "Size 2"
    ttk::entry $f.radius2 -textvariable pmarker(box,radius2) -width 10 
    ttk::label $f.unit2 -text [msgcat::mc {Image}]

    grid $f.title $f.radius1 $f.unit -padx 2 -pady 2 -sticky w
    grid $f.title2 $f.radius2 $f.unit2 -padx 2 -pady 2 -sticky w

    # Projection
    set f [ttk::labelframe $w.region.projection -text [msgcat::mc {Projection}]]

    ttk::label $f.title -text [msgcat::mc {Thickness}]
    ttk::entry $f.thick -textvariable pmarker(projection,thick) -width 10
    ttk::label $f.unit -text [msgcat::mc {Image}]
    
    grid $f.title $f.thick $f.unit -padx 2 -pady 2 -sticky w

    # Point
    set f [ttk::labelframe $w.region.point -text [msgcat::mc {Point}]]

    ttk::label $f.title -text [msgcat::mc {Size}]
    ttk::entry $f.size -textvariable pmarker(point,size) -width 10
    ttk::label $f.unit -text [msgcat::mc {Pixels}]
    
    grid $f.title $f.size $f.unit -padx 2 -pady 2 -sticky w

    pack $w.region.format $w.region.dformat $w.region.epsilon \
	$w.region.centroid $w.region.plot \
	$w.region.circle $w.region.ellipse \
	$w.region.box $w.region.projection $w.region.point \
	-side top -fill both -expand true
}

proc PrefsDialogAnnulus {} {
    global dprefs

    set w $dprefs(tab)

    $dprefs(list) insert end [msgcat::mc {Annulus}]
    lappend dprefs(tabs) [ttk::frame $w.annulus]

    # Annulus
    set f [ttk::labelframe $w.annulus.annulus -text [msgcat::mc {Annulus}]]

    ttk::label $f.innerTitle -text [msgcat::mc {Inner}]
    ttk::label $f.outerTitle -text [msgcat::mc {Outer}]
    ttk::label $f.radiusTitle -text [msgcat::mc {Radius}]
    ttk::entry $f.inner -textvariable pmarker(annulus,inner) -width 10
    ttk::entry $f.outer -textvariable pmarker(annulus,outer) -width 10
    ttk::label $f.unit -text [msgcat::mc {Image}]
    ttk::label $f.annuliTitle -text [msgcat::mc {Annuli}]
    ttk::entry $f.annuli -textvariable pmarker(annulus,annuli) -width 10
    
    grid x $f.innerTitle $f.outerTitle -padx 2 -pady 2 -sticky w
    grid $f.radiusTitle $f.inner $f.outer $f.unit -padx 2 -pady 2 -sticky w
    grid $f.annuliTitle $f.annuli -padx 2 -pady 2 -sticky w

    # Ellipse Annulus
    set f [ttk::labelframe $w.annulus.ellipseannulus \
	       -text [msgcat::mc {Elliptical Annulus}]]

    ttk::label $f.majorTitle -text [msgcat::mc {Major}]
    ttk::label $f.minorTitle -text [msgcat::mc {Minor}]

    ttk::label $f.innerTitle -text [msgcat::mc {Inner}]
    ttk::entry $f.radius1 -textvariable pmarker(ellipseannulus,radius1) \
	-width 10 	
    ttk::entry $f.radius2 -textvariable pmarker(ellipseannulus,radius2) \
	-width 10 
    ttk::label $f.unit -text [msgcat::mc {Image}]

    ttk::label $f.outerTitle -text [msgcat::mc {Outer}]
    ttk::entry $f.radius3 -textvariable pmarker(ellipseannulus,radius3) \
	-width 10 

    ttk::label $f.annuliTitle -text [msgcat::mc {Annuli}]
    ttk::entry $f.annuli -textvariable pmarker(ellipseannulus,annuli) -width 10
    
    grid x $f.majorTitle $f.minorTitle -padx 2 -pady 2 -sticky w
    grid $f.innerTitle $f.radius1 $f.radius2 $f.unit -padx 2 -pady 2 -sticky w
    grid $f.outerTitle $f.radius3 -padx 2 -pady 2 -sticky w
    grid $f.annuliTitle $f.annuli -padx 2 -pady 2 -sticky w

    # Box Annulus
    set f [ttk::labelframe $w.annulus.boxannulus \
	       -text [msgcat::mc {Box Annulus}]]

    ttk::label $f.majorTitle -text [msgcat::mc {Width}]
    ttk::label $f.minorTitle -text [msgcat::mc {Height}]

    ttk::label $f.innerTitle -text [msgcat::mc {Inner}]
    ttk::entry $f.radius1 -textvariable pmarker(boxannulus,radius1) -width 10
    ttk::entry $f.radius2 -textvariable pmarker(boxannulus,radius2) -width 10 
    ttk::label $f.unit -text [msgcat::mc {Image}]

    ttk::label $f.outerTitle -text [msgcat::mc {Outer}]
    ttk::entry $f.radius3 -textvariable pmarker(boxannulus,radius3) -width 10 

    ttk::label $f.annuliTitle -text [msgcat::mc {Annuli}]
    ttk::entry $f.annuli -textvariable pmarker(boxannulus,annuli) -width 10 
    
    grid x $f.majorTitle $f.minorTitle -padx 2 -pady 2 -sticky w
    grid $f.innerTitle $f.radius1 $f.radius2 $f.unit -padx 2 -pady 2 -sticky w
    grid $f.outerTitle $f.radius3 -padx 2 -pady 2 -sticky w
    grid $f.annuliTitle $f.annuli -padx 2 -pady 2 -sticky w

    pack $w.annulus.annulus $w.annulus.ellipseannulus $w.annulus.boxannulus \
	-side top -fill both -expand true
}

proc PrefsDialogPanda {} {
    global dprefs

    set w $dprefs(tab)

    $dprefs(list) insert end [msgcat::mc {Panda}]
    lappend dprefs(tabs) [ttk::frame $w.panda]

    # Panda
    set f [ttk::labelframe $w.panda.panda -text [msgcat::mc {Panda}]]

    ttk::label $f.innerTitle -text [msgcat::mc {Inner}]
    ttk::label $f.outerTitle -text [msgcat::mc {Outer}]
    ttk::label $f.radiusTitle -text [msgcat::mc {Radius}]
    ttk::entry $f.inner -textvariable pmarker(panda,inner) -width 10
    ttk::entry $f.outer -textvariable pmarker(panda,outer) -width 10
    ttk::label $f.unit -text [msgcat::mc {Image}]
    ttk::label $f.annuliTitle -text [msgcat::mc {Annuli}]
    ttk::entry $f.annuli -textvariable pmarker(panda,annuli) -width 10
    
    grid x $f.innerTitle $f.outerTitle -padx 2 -pady 2 -sticky w
    grid $f.radiusTitle $f.inner $f.outer $f.unit -padx 2 -pady 2 -sticky w
    grid $f.annuliTitle $f.annuli -padx 2 -pady 2 -sticky w

    ttk::label $f.ang1Title -text [msgcat::mc {Start}]
    ttk::label $f.ang2Title -text [msgcat::mc {Stop}]
    ttk::label $f.angTitle -text [msgcat::mc {Angles}]
    ttk::entry $f.ang1 -textvariable pmarker(panda,ang1) -width 10
    ttk::entry $f.ang2 -textvariable pmarker(panda,ang2) -width 10
    ttk::label $f.angunit -text [msgcat::mc {Degrees}]
    ttk::label $f.angnumTitle -text [msgcat::mc {Number}]
    ttk::entry $f.angnum -textvariable pmarker(panda,angnum) -width 10
    
    grid x $f.ang1Title $f.ang2Title -padx 2 -pady 2 -sticky w
    grid $f.angTitle $f.ang1 $f.ang2 $f.angunit -padx 2 -pady 2 -sticky w
    grid $f.angnumTitle $f.angnum -padx 2 -pady 2 -sticky w

    # Elliptical Panda
    set f [ttk::labelframe $w.panda.epanda \
	       -text [msgcat::mc {Elliptical Panda}]]

    ttk::label $f.majorTitle -text [msgcat::mc {Major}]
    ttk::label $f.minorTitle -text [msgcat::mc {Minor}]

    ttk::label $f.innerTitle -text [msgcat::mc {Inner}]
    ttk::entry $f.radius1 -textvariable pmarker(epanda,radius1) -width 10
    ttk::entry $f.radius2 -textvariable pmarker(epanda,radius2) -width 10 
    ttk::label $f.unit -text [msgcat::mc {Image}]

    ttk::label $f.outerTitle -text [msgcat::mc {Outer}]
    ttk::entry $f.radius3 -textvariable pmarker(epanda,radius3) -width 10 

    ttk::label $f.annuliTitle -text [msgcat::mc {Annuli}]
    ttk::entry $f.annuli -textvariable pmarker(epanda,annuli) -width 10
    
    grid x $f.majorTitle $f.minorTitle -padx 2 -pady 2 -sticky w
    grid $f.innerTitle $f.radius1 $f.radius2 $f.unit -padx 2 -pady 2 -sticky w
    grid $f.outerTitle $f.radius3 -padx 2 -pady 2 -sticky w
    grid $f.annuliTitle $f.annuli -padx 2 -pady 2 -sticky w

    ttk::label $f.ang1Title -text [msgcat::mc {Start}]
    ttk::label $f.ang2Title -text [msgcat::mc {Stop}]
    ttk::label $f.angTitle -text [msgcat::mc {Angles}]
    ttk::entry $f.ang1 -textvariable pmarker(epanda,ang1) -width 10
    ttk::entry $f.ang2 -textvariable pmarker(epanda,ang2) -width 10
    ttk::label $f.angunit -text [msgcat::mc {Degrees}]
    ttk::label $f.angnumTitle -text [msgcat::mc {Number}]
    ttk::entry $f.angnum -textvariable pmarker(epanda,angnum) -width 10
    
    grid x $f.ang1Title $f.ang2Title -padx 2 -pady 2 -sticky w
    grid $f.angTitle $f.ang1 $f.ang2 $f.angunit -padx 2 -pady 2 -sticky w
    grid $f.angnumTitle $f.angnum -padx 2 -pady 2 -sticky w

    # Default Box Panda
    set f [ttk::labelframe $w.panda.bpanda -text [msgcat::mc {Box Panda}]]

    ttk::label $f.majorTitle -text [msgcat::mc {Major}]
    ttk::label $f.minorTitle -text [msgcat::mc {Minor}]

    ttk::label $f.innerTitle -text [msgcat::mc {Inner}]
    ttk::entry $f.radius1 -textvariable pmarker(bpanda,radius1) -width 10
    ttk::entry $f.radius2 -textvariable pmarker(bpanda,radius2) -width 10 
    ttk::label $f.unit -text [msgcat::mc {Image}]

    ttk::label $f.outerTitle -text [msgcat::mc {Outer}]
    ttk::entry $f.radius3 -textvariable pmarker(bpanda,radius3) -width 10 

    ttk::label $f.annuliTitle -text [msgcat::mc {Annuli}]
    ttk::entry $f.annuli -textvariable pmarker(bpanda,annuli) -width 10
    
    grid x $f.majorTitle $f.minorTitle -padx 2 -pady 2 -sticky w
    grid $f.innerTitle $f.radius1 $f.radius2 $f.unit -padx 2 -pady 2 -sticky w
    grid $f.outerTitle $f.radius3 -padx 2 -pady 2 -sticky w
    grid $f.annuliTitle $f.annuli -padx 2 -pady 2 -sticky w

    ttk::label $f.ang1Title -text [msgcat::mc {Start}]
    ttk::label $f.ang2Title -text [msgcat::mc {Stop}]
    ttk::label $f.angTitle -text [msgcat::mc {Angles}]
    ttk::entry $f.ang1 -textvariable pmarker(bpanda,ang1) -width 10
    ttk::entry $f.ang2 -textvariable pmarker(bpanda,ang2) -width 10
    ttk::label $f.angunit -text [msgcat::mc {Degrees}]
    ttk::label $f.angnumTitle -text [msgcat::mc {Number}]
    ttk::entry $f.angnum -textvariable pmarker(bpanda,angnum) -width 10
    
    grid x $f.ang1Title $f.ang2Title -padx 2 -pady 2 -sticky w
    grid $f.angTitle $f.ang1 $f.ang2 $f.angunit -padx 2 -pady 2 -sticky w
    grid $f.angnumTitle $f.angnum -padx 2 -pady 2 -sticky w

    pack $w.panda.panda $w.panda.epanda $w.panda.bpanda \
	-side top -fill both -expand true
}

# Buttons

proc ButtonsRegionDef {} {
    global pbuttons

    array set pbuttons {
	region,info 1
	region,circle 0
	region,ellipse 0
	region,box 0
	region,polygon 0
	region,line 0
	region,vector 0
	region,projection 0
	region,segment 0
	region,text 0
	region,point 0
	region,ruler 0
	region,compass 0
	region,annulus 0
	region,ellipseannulus 0
	region,boxannulus 0
	region,panda 0
	region,epanda 0
	region,bpanda 0
	region,create 0
	region,dissolve 0
	region,loadtemplate 0
	region,savetemplate 0
	region,centroid 0
	region,front 1
	region,back 1
	region,all 1
	region,none 1
	region,invert 0
	region,delete 1
	region,deleteall 0
	region,newgroup 0
	region,group 0
	region,list 1
	region,load 1
	region,deleteload 0
	region,save 1
	region,mask 0
	region,show 0
	region,showtext 0
	region,autocentroid 0
    }
}

proc CreateButtonsRegion {} {
    global buttons
    global ds9

    ttk::frame $ds9(buttons).region

    ButtonButton $ds9(buttons).region.info \
	[string tolower [msgcat::mc {Information}]] MarkerInfo

    RadioButton $ds9(buttons).region.circle \
	[string tolower [msgcat::mc {Circle}]] \
	marker(shape) circle {}
    RadioButton $ds9(buttons).region.ellipse \
	[string tolower [msgcat::mc {Ellipse}]] \
	marker(shape) ellipse {}
    RadioButton $ds9(buttons).region.box \
	[string tolower [msgcat::mc {Box}]] \
	marker(shape) box {}
    RadioButton $ds9(buttons).region.polygon \
	[string tolower [msgcat::mc {Polygon}]] \
	marker(shape) polygon {}
    RadioButton $ds9(buttons).region.line \
	[string tolower [msgcat::mc {Line}]] \
	marker(shape) line {}
    RadioButton $ds9(buttons).region.vector \
	[string tolower [msgcat::mc {Vector}]] \
	marker(shape) vector {}
    RadioButton $ds9(buttons).region.projection \
	[string tolower [msgcat::mc {Projection}]] \
	marker(shape) projection {}
    RadioButton $ds9(buttons).region.segment \
	[string tolower [msgcat::mc {Segment}]] \
	marker(shape) segment {}
    RadioButton $ds9(buttons).region.text \
	[string tolower [msgcat::mc {Text}]] \
	marker(shape) text {}
    RadioButton $ds9(buttons).region.point \
	[string tolower [msgcat::mc {Point}]] \
	marker(shape) {circle point} {}
    RadioButton $ds9(buttons).region.ruler \
	[string tolower [msgcat::mc {Ruler}]] \
	marker(shape) ruler {}
    RadioButton $ds9(buttons).region.compass \
	[string tolower [msgcat::mc {Compass}]] \
	marker(shape) compass {}
    RadioButton $ds9(buttons).region.annulus \
	[string tolower [msgcat::mc {Annulus}]] \
	marker(shape) annulus {}
    RadioButton $ds9(buttons).region.ellipseannulus \
	[string tolower [msgcat::mc {Elliptical Annulus}]] \
	marker(shape) ellipseannulus {}
    RadioButton $ds9(buttons).region.boxannulus \
	[string tolower [msgcat::mc {Box Annulus}]] \
	marker(shape) boxannulus {}
    RadioButton $ds9(buttons).region.panda \
	[string tolower [msgcat::mc {Panda}]] \
	marker(shape) panda {}
    RadioButton $ds9(buttons).region.epanda \
	[string tolower [msgcat::mc {Ellipse Panda}]] \
	marker(shape) epanda {}
    RadioButton $ds9(buttons).region.bpanda \
	[string tolower [msgcat::mc {Box Panda}]] \
	marker(shape) bpanda {}

    ButtonButton $ds9(buttons).region.create \
	[string tolower [msgcat::mc {Composite}]] CompositeCreate
    ButtonButton $ds9(buttons).region.dissolve \
	[string tolower [msgcat::mc {Dissolve}]] CompositeDelete

    ButtonButton $ds9(buttons).region.loadtemplate \
	[string tolower [msgcat::mc {Load Template}]] OpenTemplateMarker
    ButtonButton $ds9(buttons).region.savetemplate \
	[string tolower [msgcat::mc {Save Template}]] SaveAsTemplateMarker

    ButtonButton $ds9(buttons).region.centroid \
	[string tolower [msgcat::mc {Centroid}]] MarkerCentroid
    ButtonButton $ds9(buttons).region.front \
	[string tolower [msgcat::mc {Front}]] MarkerFront
    ButtonButton $ds9(buttons).region.back \
	[string tolower [msgcat::mc {Back}]] MarkerBack

    ButtonButton $ds9(buttons).region.all \
	[string tolower [msgcat::mc {All}]] MarkerSelectAll
    ButtonButton $ds9(buttons).region.none \
	[string tolower [msgcat::mc {None}]] MarkerUnselectAll
    ButtonButton $ds9(buttons).region.invert \
	[string tolower [msgcat::mc {Invert}]] MarkerSelectInvert
    ButtonButton $ds9(buttons).region.delete \
	[string tolower [msgcat::mc {Delete}]] MarkerDeleteSelect
    ButtonButton $ds9(buttons).region.deleteall \
	[string tolower [msgcat::mc {Delete All}]] MarkerDeleteAllMenu

    ButtonButton $ds9(buttons).region.newgroup \
	[string tolower [msgcat::mc {New Group}]] GroupCreate
    ButtonButton $ds9(buttons).region.group \
	[string tolower [msgcat::mc {Groups}]] GroupDialog

    ButtonButton $ds9(buttons).region.list \
	[string tolower [msgcat::mc {List}]] MarkerList
    ButtonButton $ds9(buttons).region.load \
	[string tolower [msgcat::mc {Load}]] MarkerLoad
    ButtonButton $ds9(buttons).region.deleteload \
	[string tolower [msgcat::mc {Delete Load}]] MarkerDeleteLoad

    ButtonButton $ds9(buttons).region.save \
	[string tolower [msgcat::mc {Save}]] MarkerSave
    
    ButtonButton $ds9(buttons).region.mask \
	[string tolower [msgcat::mc {Mask}]] MarkerMask

    CheckButton $ds9(buttons).region.show \
	[string tolower [msgcat::mc {Show}]] \
	marker(show) MarkerShow
    CheckButton $ds9(buttons).region.showtext \
	[string tolower [msgcat::mc {Show Text}]] \
	marker(show,text) MarkerShowText
    CheckButton $ds9(buttons).region.autocentroid \
	[string tolower [msgcat::mc {Auto Centroid}]] \
	marker(centroid,auto) MarkerCentroidAuto

    set buttons(region) "
        $ds9(buttons).region.info pbuttons(region,info)
        $ds9(buttons).region.circle pbuttons(region,circle)
        $ds9(buttons).region.ellipse pbuttons(region,ellipse)
        $ds9(buttons).region.box pbuttons(region,box)
        $ds9(buttons).region.polygon pbuttons(region,polygon)
        $ds9(buttons).region.line pbuttons(region,line)
        $ds9(buttons).region.vector pbuttons(region,vector)
        $ds9(buttons).region.projection pbuttons(region,projection)
        $ds9(buttons).region.segment pbuttons(region,segment)
        $ds9(buttons).region.text pbuttons(region,text)
        $ds9(buttons).region.point pbuttons(region,point)
        $ds9(buttons).region.ruler pbuttons(region,ruler)
        $ds9(buttons).region.compass pbuttons(region,compass)
        $ds9(buttons).region.annulus pbuttons(region,annulus)
        $ds9(buttons).region.ellipseannulus pbuttons(region,ellipseannulus)
        $ds9(buttons).region.boxannulus pbuttons(region,boxannulus)
        $ds9(buttons).region.panda pbuttons(region,panda)
        $ds9(buttons).region.epanda pbuttons(region,epanda)
        $ds9(buttons).region.bpanda pbuttons(region,bpanda)
        $ds9(buttons).region.create pbuttons(region,create)
        $ds9(buttons).region.dissolve pbuttons(region,dissolve)
        $ds9(buttons).region.loadtemplate pbuttons(region,loadtemplate)
        $ds9(buttons).region.savetemplate pbuttons(region,savetemplate)
        $ds9(buttons).region.centroid pbuttons(region,centroid)
        $ds9(buttons).region.front pbuttons(region,front)
        $ds9(buttons).region.back pbuttons(region,back)
        $ds9(buttons).region.all pbuttons(region,all)
        $ds9(buttons).region.none pbuttons(region,none)
        $ds9(buttons).region.invert pbuttons(region,invert)
        $ds9(buttons).region.delete pbuttons(region,delete)
        $ds9(buttons).region.deleteall pbuttons(region,deleteall)
        $ds9(buttons).region.newgroup pbuttons(region,newgroup)
        $ds9(buttons).region.group pbuttons(region,group)
        $ds9(buttons).region.list pbuttons(region,list)
        $ds9(buttons).region.load pbuttons(region,load)
        $ds9(buttons).region.deleteload pbuttons(region,deleteload)
        $ds9(buttons).region.save pbuttons(region,save)
        $ds9(buttons).region.mask pbuttons(region,mask)
        $ds9(buttons).region.show pbuttons(region,show)
        $ds9(buttons).region.showtext pbuttons(region,showtext)
        $ds9(buttons).region.autocentroid pbuttons(region,autocentroid)
    "
}

proc PrefsDialogButtonbarRegion {f} {
    global buttons
    global pbuttons

    ttk::menubutton $f -text [msgcat::mc {Buttonbar}] -menu $f.menu
    
    set m $f.menu
    menu $m
    $m add checkbutton -label "[msgcat::mc {Get Information}]..." \
	-variable pbuttons(region,info) \
	-command {UpdateButtons buttons(region)}
    $m add separator
    $m add cascade -label [msgcat::mc {Shape}] -menu $m.shape
    $m add cascade -label [msgcat::mc {Composite Region}] -menu $m.composite
    $m add cascade -label [msgcat::mc {Template}] -menu $m.template
    $m add separator
    $m add checkbutton -label [msgcat::mc {Centroid}] \
	-variable pbuttons(region,centroid) \
	-command {UpdateButtons buttons(region)}
    $m add checkbutton -label [msgcat::mc {Move to Front}] \
	-variable pbuttons(region,front) \
	-command {UpdateButtons buttons(region)}
    $m add checkbutton -label [msgcat::mc {Move to Back}] \
	-variable pbuttons(region,back) \
	-command {UpdateButtons buttons(region)}
    $m add separator
    $m add checkbutton -label [msgcat::mc {Select All}] \
	-variable pbuttons(region,all) \
	-command {UpdateButtons buttons(region)}
    $m add checkbutton -label [msgcat::mc {Select None}] \
	-variable pbuttons(region,none) \
	-command {UpdateButtons buttons(region)}
    $m add checkbutton -label [msgcat::mc {Invert Selection}] \
	-variable pbuttons(region,invert) \
	-command {UpdateButtons buttons(region)}
    $m add separator
    $m add checkbutton -label [msgcat::mc {Delete Selected Regions}] \
	-variable pbuttons(region,delete) \
	-command {UpdateButtons buttons(region)}
    $m add checkbutton -label [msgcat::mc {Delete All Regions}] \
	-variable pbuttons(region,deleteall) \
	-command {UpdateButtons buttons(region)}
    $m add separator
    $m add checkbutton -label [msgcat::mc {New Group}] \
	-variable pbuttons(region,newgroup) \
	-command {UpdateButtons buttons(region)}
    $m add checkbutton -label "[msgcat::mc {Groups}]..." \
	-variable pbuttons(region,group) \
	-command {UpdateButtons buttons(region)}
    $m add separator
    $m add checkbutton -label "[msgcat::mc {List Regions}]..." \
	-variable pbuttons(region,list) \
	-command {UpdateButtons buttons(region)}
    $m add checkbutton -label "[msgcat::mc {Load Regions}]..." \
	-variable pbuttons(region,load) \
	-command {UpdateButtons buttons(region)}
    $m add checkbutton -label "[msgcat::mc {Delete and Load Regions}]..." \
	-variable pbuttons(region,deleteload) \
	-command {UpdateButtons buttons(region)}
    $m add separator
    $m add checkbutton -label "[msgcat::mc {Save Regions}]..." \
	-variable pbuttons(region,save) \
	-command {UpdateButtons buttons(region)}
    $m add separator
    $m add cascade -label [msgcat::mc {Region Parameters}] -menu $m.params

    menu $m.shape
    $m.shape add checkbutton -label [msgcat::mc {Circle}] \
	-variable pbuttons(region,circle) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Ellipse}] \
	-variable pbuttons(region,ellipse) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Box}] \
	-variable pbuttons(region,box) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Polygon}] \
	-variable pbuttons(region,polygon) \
	-command {UpdateButtons buttons(region)}
    $m.shape add separator
    $m.shape add checkbutton -label [msgcat::mc {Line}] \
	-variable pbuttons(region,line) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Vector}] \
	-variable pbuttons(region,vector) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Projection}] \
	-variable pbuttons(region,projection) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Segment}] \
	-variable pbuttons(region,segment) \
	-command {UpdateButtons buttons(region)}
    $m.shape add separator
    $m.shape add checkbutton -label [msgcat::mc {Text}] \
	-variable pbuttons(region,text) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Point}] \
	-variable pbuttons(region,point) \
	-command {UpdateButtons buttons(region)}
    $m.shape add separator
    $m.shape add checkbutton -label [msgcat::mc {Ruler}] \
	-variable pbuttons(region,ruler) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Compass}] \
	-variable pbuttons(region,compass) \
	-command {UpdateButtons buttons(region)}
    $m.shape add separator
    $m.shape add checkbutton -label [msgcat::mc {Annulus}] \
	-variable pbuttons(region,annulus) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Elliptical Annulus}] \
	-variable pbuttons(region,ellipseannulus) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Box Annulus}] \
	-variable pbuttons(region,boxannulus) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Panda}] \
	-variable pbuttons(region,panda) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Elliptical Panda}]\
	-variable pbuttons(region,epanda) \
	-command {UpdateButtons buttons(region)}
    $m.shape add checkbutton -label [msgcat::mc {Box Panda}] \
	-variable pbuttons(region,bpanda) \
	-command {UpdateButtons buttons(region)}

    menu $m.composite
    $m.composite add checkbutton -label [msgcat::mc {Create}] \
	-variable pbuttons(region,create) \
	-command {UpdateButtons buttons(region)}
    $m.composite add checkbutton -label [msgcat::mc {Dissolve}] \
	-variable pbuttons(region,dissolve) \
	-command {UpdateButtons buttons(region)}

    menu $m.template
    $m.template add checkbutton -label "[msgcat::mc {Load}]..." \
	-variable pbuttons(region,loadtemplate) \
	-command {UpdateButtons buttons(region)}
    $m.template add checkbutton -label "[msgcat::mc {Save}]..." \
	-variable pbuttons(region,savetemplate) \
	-command {UpdateButtons buttons(region)}

    menu $m.params
    $m.params add checkbutton -label [msgcat::mc {Show}] \
	-variable pbuttons(region,show) \
	-command {UpdateButtons buttons(region)}
    $m.params add checkbutton -label [msgcat::mc {Show Text}] \
	-variable pbuttons(region,showtext) \
	-command {UpdateButtons buttons(region)}
    $m.params add separator
    $m.params add checkbutton -label [msgcat::mc {Auto Centroid}] \
	-variable pbuttons(region,autocentroid) \
	-command {UpdateButtons buttons(region)}
}

# Support

proc UpdateRegionMenu {} {
    global current
    global marker
    global pmarker
    global ds9

    set mm $ds9(mb).region
    set bb $ds9(buttons).region

    if {$current(frame) != {}} {
	$ds9(mb) entryconfig [msgcat::mc {Region}] -state normal
	ConfigureButtons region normal

	set marker(show) [$current(frame) get marker show]
	set marker(show,text) [$current(frame) get marker show text]
	set marker(centroid,auto) [$current(frame) get marker centroid auto]
	set marker(centroid,radius) [$current(frame) get marker centroid radius]
	set marker(centroid,iteration) \
	    [$current(frame) get marker centroid iteration]
	set marker(preserve) [$current(frame) get marker preserve]

	switch -- $current(mode) {
	    pointer -
	    region {
		if {[$current(frame) get marker select number] == 1} {
		    set marker(color) \
			[$current(frame) get marker color]
		    set marker(width) \
			[$current(frame) get marker width]
		    set marker(dash) \
			[$current(frame) get marker property dash]
		    set marker(fixed) \
			[$current(frame) get marker property fixed]
		    set marker(edit) \
			[$current(frame) get marker property edit]
		    set marker(move) \
			[$current(frame) get marker property move]
		    set marker(rotate) \
			[$current(frame) get marker property rotate]
		    set marker(delete) \
			[$current(frame) get marker property delete]
		    set marker(include) \
			[$current(frame) get marker property include]
		    set marker(source) \
			[$current(frame) get marker property source]

		    set f [$current(frame) get marker font]

		    set marker(font) [lindex $f 0]
		    set marker(font,size) [lindex $f 1]
		    set marker(font,weight) [lindex $f 2]
		    set marker(font,slant) [lindex $f 3]
		} else {
		    # defaults
		    set marker(color) $pmarker(color)
		    set marker(width) $pmarker(width) 
		    set marker(dash) $pmarker(dash) 
		    set marker(fixed) $pmarker(fixed) 
		    set marker(edit) $pmarker(edit) 
		    set marker(move) $pmarker(move) 
		    set marker(rotate) $pmarker(rotate) 
		    set marker(delete) $pmarker(delete) 
		    set marker(include) $pmarker(include) 
		    set marker(source) $pmarker(source) 

		    set marker(font) $pmarker(font) 
		    set marker(font,size) $pmarker(font,size) 
		    set marker(font,weight) $pmarker(font,weight) 
		    set marker(font,slant) $pmarker(font,slant) 
		}
	    }
	}

	if {[$current(frame) has fits]} {
	    $mm entryconfig "[msgcat::mc {Get Information}]..." -state normal

	    $mm entryconfig [msgcat::mc {Composite Region}] -state normal
	    $mm entryconfig [msgcat::mc {Instrument FOV}] -state normal
	    $mm entryconfig [msgcat::mc {Template}] -state normal

	    $mm entryconfig [msgcat::mc {Centroid}] -state normal
	    $mm entryconfig [msgcat::mc {Move to Front}] -state normal
	    $mm entryconfig [msgcat::mc {Move to Back}] -state normal

	    $mm entryconfig [msgcat::mc {New Group}] -state normal
	    $mm entryconfig "[msgcat::mc {Groups}]..." -state normal

	    $mm entryconfig [msgcat::mc {Select All}] -state normal
	    $mm entryconfig [msgcat::mc {Select None}] -state normal
	    $mm entryconfig [msgcat::mc {Invert Selection}] -state normal

	    $mm entryconfig [msgcat::mc {Delete Selected Regions}] -state normal
	    $mm entryconfig [msgcat::mc {Delete All Regions}] -state normal

	    $mm entryconfig "[msgcat::mc {List Regions}]..." -state normal
	    $mm entryconfig "[msgcat::mc {Load Regions}]..." -state normal
	    $mm entryconfig "[msgcat::mc {Delete and Load Regions}]..." -state normal
	    $mm entryconfig "[msgcat::mc {Save Regions}]..." -state normal

	    $bb.info configure -state normal

	    $bb.create configure -state normal
	    $bb.dissolve configure -state normal

	    $bb.loadtemplate configure -state normal
	    $bb.savetemplate configure -state normal

	    $bb.centroid configure -state normal
	    $bb.front configure -state normal
	    $bb.back configure -state normal

	    $bb.newgroup configure -state normal
	    $bb.group configure -state normal

	    $bb.all configure -state normal
	    $bb.none configure -state normal
	    $bb.invert configure -state normal

	    $bb.delete configure -state normal
	    $bb.deleteall configure -state normal

	    $bb.list configure -state normal
	    $bb.load configure -state normal
	    $bb.deleteload configure -state normal
	    $bb.save configure -state normal
	} else {
	    $mm entryconfig "[msgcat::mc {Get Information}]..." -state disabled

	    $mm entryconfig [msgcat::mc {Composite Region}] -state disabled
	    $mm entryconfig [msgcat::mc {Instrument FOV}] -state disabled
	    $mm entryconfig [msgcat::mc {Template}] -state disabled

	    $mm entryconfig [msgcat::mc {Centroid}] -state disabled
	    $mm entryconfig [msgcat::mc {Move to Front}] -state disabled
	    $mm entryconfig [msgcat::mc {Move to Back}] -state disabled

	    $mm entryconfig [msgcat::mc {New Group}] -state disabled
	    $mm entryconfig "[msgcat::mc {Groups}]..." -state disabled

	    $mm entryconfig [msgcat::mc {Select All}] -state disabled
	    $mm entryconfig [msgcat::mc {Select None}] -state disabled
	    $mm entryconfig [msgcat::mc {Invert Selection}] -state disabled

	    $mm entryconfig [msgcat::mc {Delete Selected Regions}] -state disabled
	    $mm entryconfig [msgcat::mc {Delete All Regions}] -state disabled

	    $mm entryconfig "[msgcat::mc {List Regions}]..." -state disabled
	    $mm entryconfig "[msgcat::mc {Load Regions}]..." -state disabled
	    $mm entryconfig "[msgcat::mc {Delete and Load Regions}]..." -state disabled
	    $mm entryconfig "[msgcat::mc {Save Regions}]..." -state disabled

	    $bb.info configure -state disabled

	    $bb.create configure -state disabled
	    $bb.dissolve configure -state disabled

	    $bb.loadtemplate configure -state disabled
	    $bb.savetemplate configure -state disabled

	    $bb.centroid configure -state disabled
	    $bb.front configure -state disabled
	    $bb.back configure -state disabled

	    $bb.newgroup configure -state disabled
	    $bb.group configure -state disabled

	    $bb.all configure -state disabled
	    $bb.none configure -state disabled
	    $bb.invert configure -state disabled

	    $bb.delete configure -state disabled
	    $bb.deleteall configure -state disabled

	    $bb.list configure -state disabled
	    $bb.load configure -state disabled
	    $bb.deleteload configure -state disabled
	    $bb.save configure -state disabled
	}
    } else {
	$ds9(mb) entryconfig [msgcat::mc {Region}] -state disabled
	ConfigureButtons region disabled
    }
}