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
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
|
# Copyright (C) 1999-2016
# Smithsonian Astrophysical Observatory, Cambridge, MA, USA
# For conditions of distribution and use, see copyright notice in "copyright"
package provide DS9 1.0
proc GridDef {} {
global igrid
global grid
global pgrid
set igrid(top) .grid
set igrid(mb) .gridmb
set grid(view) 0
array set pgrid [array get grid]
GridDefault
}
proc GridDefault {} {
global grid
set grid(type) analysis
set grid(system) wcs
set grid(sky) fk5
set grid(skyformat) sexagesimal
set grid(grid) 1
set grid(grid,color) blue
set grid(grid,width) 1
set grid(grid,style) 0
set grid(grid,gap1) {}
set grid(grid,gap2) {}
set grid(grid,gap3) {}
set grid(grid,gapunit1) {}
set grid(grid,gapunit2) {}
set grid(grid,gapunit3) {}
set grid(axes) 1
set grid(axes,color) red
set grid(axes,width) 1
set grid(axes,style) 0
set grid(axes,type) interior
set grid(axes,origin) lll
set grid(tick) 1
set grid(tick,color) white
set grid(tick,width) 1
set grid(tick,style) 0
set grid(border) 1
set grid(border,color) blue
set grid(border,width) 1
set grid(border,style) 0
set grid(format1) {}
set grid(format2) {}
set grid(numlab) 1
set grid(numlab,font) helvetica
set grid(numlab,size) 10
set grid(numlab,weight) normal
set grid(numlab,slant) roman
set grid(numlab,color) green
set grid(numlab,gap1) {}
set grid(numlab,gap2) {}
set grid(numlab,gap3) {}
set grid(numlab,type) interior
set grid(numlab,vertical) 0
set grid(title) 1
set grid(title,text) {}
set grid(title,def) 1
set grid(title,gap) {}
set grid(title,font) helvetica
set grid(title,size) 12
set grid(title,weight) normal
set grid(title,slant) roman
set grid(title,color) black
set grid(textlab) 1
set grid(textlab,text1) {}
set grid(textlab,text2) {}
set grid(textlab,def1) 1
set grid(textlab,def2) 1
set grid(textlab,gap1) {}
set grid(textlab,gap2) {}
set grid(textlab,font) helvetica
set grid(textlab,size) 10
set grid(textlab,weight) normal
set grid(textlab,slant) roman
set grid(textlab,color) black
}
proc GridUpdateCurrent {} {
global current
if {$current(frame) != {}} {
GridUpdate $current(frame)
}
}
proc GridUpdate {which} {
global grid
GridAdjustOptions $which
if {$grid(view) && [$which has fits]} {
$which grid create $grid(system) $grid(sky) \
$grid(skyformat) $grid(type) \
[GridBuildOptions $which] "\"[array get grid]\""
} else {
$which grid delete
}
}
proc GridUpdateZoom {} {
global grid
if {$grid(type) == "publication"} {
GridUpdateCurrent
}
}
proc GridAdjustOptions {which} {
global grid
if {$which != {}} {
if {[$which has fits]} {
# change values if needed for coordmenu
AdjustCoordSystem grid system
}
}
set grid(grid,gapunit1) pixels
set grid(grid,gapunit2) pixels
set grid(grid,gapunit3) pixels
# adjust units
switch -- $grid(system) {
image -
physical -
amplifier -
detector {}
default {
if {$which != {}} {
if {[$which has wcs celestrial $grid(system)]} {
set grid(grid,gapunit1) degrees
set grid(grid,gapunit2) degrees
}
if {[$which has wcs 3d $grid(system)]} {
set tt [string trim [$which get fits header keyword CTYPE3]]
if {$tt != {}} {
set grid(grid,gapunit3) $tt
}
}
}
}
}
}
proc GridBuildOptions {which} {
global grid
global current
set opt "\""
# Grid
append opt " Grid=$grid(grid),"
append opt " Colour(grid)=[GridColor2Ast $grid(grid,color)],"
append opt " Width(grid)=$grid(grid,width),"
append opt " Style(grid)=$grid(grid,style),"
# Axes
append opt " DrawAxes=$grid(axes),"
append opt " Colour(axes)=[GridColor2Ast $grid(axes,color)],"
append opt " Width(axes)=$grid(axes,width),"
append opt " Style(axes)=$grid(axes,style),"
# Format
if {$grid(format1) != {}} {
append opt " Format(1)=$grid(format1),"
} else {
set ff [GridDefaultFormat1]
if {$ff != {}} {
append opt " Format(1)=$ff,"
}
}
if {$grid(format2) != {}} {
append opt " Format(2)=$grid(format2),"
} else {
set ff [GridDefaultFormat2]
if {$ff != {}} {
append opt " Format(2)=$ff,"
}
}
# Ticks
if {!$grid(tick)} {
append opt " MajTickLen=0,"
append opt " MinTick(1)=0,"
append opt " MinTick(2)=0,"
switch -- $grid(type) {
analysis {}
publication {
switch -- [$which get type] {
base -
rgb {}
3d {append opt " MinTick(3)=0,"}
}
}
}
}
append opt " Colour(ticks)=[GridColor2Ast $grid(tick,color)],"
append opt " Width(ticks)=$grid(tick,width),"
append opt " Style(ticks)=$grid(tick,style),"
# Border
append opt " Border=$grid(border),"
append opt " Colour(border)=[GridColor2Ast $grid(border,color)],"
append opt " Width(border)=$grid(border,width),"
append opt " Style(border)=$grid(border,style),"
# Labels
append opt " Labelling=$grid(axes,type),"
switch -- [$which get type] {
base -
rgb {append opt " LabelUp=$grid(numlab,vertical),"}
3d {append opt " LabelUp=1,"}
}
# NumLab
append opt " NumLab=$grid(numlab),"
set opt "$opt Font(numlab)=[GridFont2Ast $grid(numlab,font) $grid(numlab,weight) $grid(numlab,slant)],"
append opt " Size(numlab)=$grid(numlab,size),"
append opt " Colour(numlab)=[GridColor2Ast $grid(numlab,color)],"
# TextLab
switch -- $grid(type) {
analysis {append opt " TextLab=0,"}
publication {
switch -- [$which get type] {
base -
rgb {append opt " TextLab=$grid(textlab),"}
3d {append opt " TextLab=0,"}
}
}
}
if {!$grid(textlab,def1)} {
append opt " Label(1)=[GridStripComma $grid(textlab,text1)] ,"
}
if {!$grid(textlab,def2)} {
append opt " Label(2)=[GridStripComma $grid(textlab,text2)] ,"
}
set opt "$opt Font(textlab)=[GridFont2Ast $grid(textlab,font) $grid(textlab,weight) $grid(textlab,slant)],"
append opt " Size(textlab)=$grid(textlab,size),"
append opt " Colour(textlab)=[GridColor2Ast $grid(textlab,color)],"
# Title
switch -- $grid(type) {
analysis {append opt " DrawTitle=0,"}
publication {
switch -- [$which get type] {
base -
rgb {append opt " DrawTitle=$grid(title),"}
3d {append opt " DrawTitle=0,"}
}
}
}
if {$grid(title,def)} {
set t [GridStripComma "[$which get fits object name]"]
if {$t != {}} {
append opt " Title=$t ,"
}
} else {
set t [GridStripComma "$grid(title,text)"]
if {$t != {}} {
append opt " Title=$t ,"
}
}
set opt "$opt Font(title)=[GridFont2Ast $grid(title,font) $grid(title,weight) $grid(title,slant)],"
append opt " Size(title)=$grid(title,size),"
append opt " Colour(title)=[GridColor2Ast $grid(title,color)],"
# Grid Spacing
if {$grid(grid,gap1) != {}} {
if {$grid(grid,gapunit1) == "degrees"} {
append opt " Gap(1)=[expr 3.14159/180.*$grid(grid,gap1)],"
} else {
append opt " Gap(1)=$grid(grid,gap1),"
}
}
if {$grid(grid,gap2) != {}} {
if {$grid(grid,gapunit2) == "degrees"} {
append opt " Gap(2)=[expr 3.14159/180.*$grid(grid,gap2)],"
} else {
append opt " Gap(2)=$grid(grid,gap2),"
}
}
switch -- [$which get type] {
base -
rgb {}
3d {
if {$grid(grid,gap3) != {}} {
if {$grid(grid,gapunit3) == "degrees"} {
append opt " Gap(3)=[expr 3.14159/180.*$grid(grid,gap3)],"
} else {
append opt " Gap(3)=$grid(grid,gap3),"
}
}
}
}
# axes numerics
set flip 0
set numx 0
set numy 0
switch -- $grid(type) {
analysis {
switch -- [$which get type] {
base -
rgb {
set numx -.03
set numy -.03
}
3d {}
}
}
publication {
switch -- [$which get type] {
base -
rgb {
set numx -.02
set numy -.01
switch -- $grid(axes,type) {
interior {}
exterior {
switch -- $grid(numlab,type) {
interior {}
exterior {set flip 1}
}
}
}
}
3d {}
}
}
}
# override
if {$grid(numlab,gap1) != {}} {
set numx [expr -$grid(numlab,gap1)/100.]
}
if {$grid(numlab,gap2) != {}} {
set numy [expr -$grid(numlab,gap2)/100.]
}
if {$grid(numlab,gap3) != {}} {
set numy [expr -$grid(numlab,gap3)/100.]
}
if {$flip} {
set numx [expr -$numx]
set numy [expr -$numy]
}
append opt " NumLabGap(1)=$numx,"
append opt " NumLabGap(2)=$numy,"
# Label gaps
switch -- $grid(type) {
analysis {
set axisx 0
set axisy 0
set title 0
}
publication {
if {$grid(textlab,gap1) != {}} {
set axisx [expr $grid(textlab,gap1)/100.]
} else {
set axisx 0
}
if {$grid(textlab,gap2) != {}} {
set axisy [expr $grid(textlab,gap2)/100.]
} else {
set axisy .1
}
if {$grid(title,gap) != {}} {
set title [expr $grid(title,gap)/100.]
} else {
set title .30
}
}
}
append opt " TextLabGap(1)=$axisx,"
append opt " TextLabGap(2)=$axisy,"
append opt " TitleGap=[expr -1-$title],"
# Orientation
switch -- [$which get type] {
base -
rgb {
append opt " Edge(1)=top,"
append opt " Edge(2)=left,"
}
3d {
switch -- $grid(type) {
analysis {
append opt " Edge(1)=bottom,"
append opt " Edge(2)=left,"
}
publication {
append opt " RootCorner=$grid(axes,origin),"
}
}
}
}
# 3D Normal
switch -- $grid(type) {
analysis {}
publication {
switch -- [$which get type] {
base -
rgb {}
3d {append opt " Norm(1)=0, Norm(2)=0, Norm(3)=-1,"}
}
}
}
# The End
append opt " \""
global debug
if {$debug(tcl,grid)} {
puts stderr "GridBuildOptions"
puts stderr "$opt"
}
return $opt
}
proc GridAst2Color {ast} {
switch -- $ast {
0 {return {black}}
1 {return white}
2 {return red}
3 {return green}
4 {return blue}
5 {return cyan}
6 {return magenta}
7 {return yellow}
16777215 {return {white}}
16711680 {return {red}}
65280 {return {green}}
255 {return {blue}}
65535 {return {cyan}}
16711935 {return {magenta}}
16776960 {return {yellow}}
default {return "#[format %x $ast]"}
}
}
proc GridColor2Ast {which} {
switch -- $which {
black {return [expr 0x000000]}
white {return [expr 0xffffff]}
red {return [expr 0xff0000]}
green {return [expr 0x00ff00]}
blue {return [expr 0x0000ff]}
cyan {return [expr 0x00ffff]}
magenta {return [expr 0xff00ff]}
yellow {return [expr 0xffff00]}
default {
if {[string range $which 0 0] == "#"} {
return [expr 0x[string range $which 1 end]]
} else {
return [expr $which]
}
}
}
}
proc GridAst2Font {ast fnvar fwvar fsvar} {
upvar $fnvar fn
upvar $fwvar fw
upvar $fsvar fs
switch -- $ast {
0 -
2 -
3 {set fn "helvetica"; set fw "normal"; set fs "roman"}
1 {set fn "times"; set fw "normal"; set fs "roman"}
4 {set fn "courier"; set fw "normal"; set fs "roman"}
10 -
12 -
13 {set fn "helvetica"; set fw "bold"; set fs "roman"}
11 {set fn "times"; set fw "bold"; set fs "roman"}
14 {set fn "courier"; set fw "bold"; set fs "roman"}
20 -
22 -
23 {set fn "helvetica"; set fw "normal"; set fs "italic"}
21 {set fn "times"; set fw "normal"; set fs "italic"}
24 {set fn "courier"; set fw "normal"; set fs "italic"}
30 -
32 -
33 {set fn "helvetica"; set fw "bold"; set fs "italic"}
31 {set fn "times"; set fw "bold"; set fs "italic"}
34 {set fn "courier"; set fw "bold"; set fs "italic"}
default {set fn "helvetica"; set fw "normal"; set fs "roman"}
}
}
proc GridFont2Ast {fn fw fs} {
if {$fn == "times" && $fw == "normal" && $fs == "roman"} {
return 1;
} elseif {$fn == "helvetica" && $fw == "normal" && $fs == "roman"} {
return 2;
} elseif {$fn == "courier" && $fw == "normal" && $fs == "roman"} {
return 4;
} elseif {$fn == "times" && $fw == "bold" && $fs == "roman"} {
return 11;
} elseif {$fn == "helvetica" && $fw == "bold" && $fs == "roman"} {
return 12;
} elseif {$fn == "courier" && $fw == "bold" && $fs == "roman"} {
return 14;
} elseif {$fn == "times" && $fw == "normal" && $fs == "italic"} {
return 21;
} elseif {$fn == "helvetica" && $fw == "normal" && $fs == "italic"} {
return 22;
} elseif {$fn == "courier" && $fw == "normal" && $fs == "italic"} {
return 24;
} elseif {$fn == "times" && $fw == "bold" && $fs == "italic"} {
return 31;
} elseif {$fn == "helvetica" && $fw == "bold" && $fs == "italic"} {
return 32;
} elseif {$fn == "courier" && $fw == "bold" && $fs == "italic"} {
return 34;
} else {
return 2;
}
}
proc GridDialog {} {
global igrid
global grid
global current
global ds9
# see if we already have a window visible
if {[winfo exists $igrid(top)]} {
raise $igrid(top)
return
}
# create the window
set w $igrid(top)
set mb $igrid(mb)
Toplevel $w $mb 6 [msgcat::mc {Coordinate Grid Parameters}] \
GridDestroyDialog
$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 {Type}] -menu $mb.type
$mb add cascade -label [msgcat::mc {Coordinate}] -menu $mb.coord
$mb add cascade -label [msgcat::mc {Grid}] -menu $mb.grid
$mb add cascade -label [msgcat::mc {Axes}] -menu $mb.axes
$mb add cascade -label [msgcat::mc {Numerics}] -menu $mb.numlab
$mb add cascade -label [msgcat::mc {Labels}] -menu $mb.textlab
$mb add cascade -label [msgcat::mc {Tickmarks}] -menu $mb.tick
$mb add cascade -label [msgcat::mc {Title}] -menu $mb.title
$mb add cascade -label [msgcat::mc {Border}] -menu $mb.border
# File
menu $mb.file
$mb.file add command -label [msgcat::mc {Apply}] -command GridApplyDialog
$mb.file add command -label [msgcat::mc {Reset}] -command GridResetDialog
$mb.file add command -label [msgcat::mc {Clear}] -command GridClearDialog
$mb.file add separator
$mb.file add command -label "[msgcat::mc {Load Configuration}]..." \
-command GridLoadDialog
$mb.file add command -label "[msgcat::mc {Save Configuration}]..." \
-command GridSaveDialog
$mb.file add separator
$mb.file add command -label [msgcat::mc {Close}] -command GridDestroyDialog
# Edit
EditMenu $mb igrid
# Type
menu $mb.type
$mb.type add radiobutton -label [msgcat::mc {Analysis}] \
-variable grid(type) -value analysis -command GridApplyDialog
$mb.type add radiobutton -label [msgcat::mc {Publication}] \
-variable grid(type) -value publication -command GridApplyDialog
$mb.type add separator
$mb.type add radiobutton -label [msgcat::mc {Interior Axes}] \
-variable grid(axes,type) -value interior -command GridApplyDialog
$mb.type add radiobutton -label [msgcat::mc {Exterior Axes}] \
-variable grid(axes,type) -value exterior -command GridApplyDialog
$mb.type add separator
$mb.type add radiobutton -label [msgcat::mc {Interior Numerics}] \
-variable grid(numlab,type) -value interior -command GridApplyDialog
$mb.type add radiobutton -label [msgcat::mc {Exterior Numerics}] \
-variable grid(numlab,type) -value exterior -command GridApplyDialog
$mb.type add separator
$mb.type add checkbutton -label [msgcat::mc {Vertical Text}] \
-variable grid(numlab,vertical) -command GridApplyDialog
# Coordinate
CoordMenu $mb.coord grid system 1 sky skyformat GridApplyDialog
# Grid
menu $mb.grid
$mb.grid add checkbutton -label [msgcat::mc {Show}] \
-variable grid(grid) -command GridApplyDialog
$mb.grid add separator
$mb.grid add cascade -label [msgcat::mc {Color}] -menu $mb.grid.color
$mb.grid add cascade -label [msgcat::mc {Line}] -menu $mb.grid.line
ColorMenu $mb.grid.color grid grid,color GridApplyDialog
GridCreateLineMenu $mb.grid.line grid,width grid,style
# Axes
menu $mb.axes
$mb.axes add checkbutton -label [msgcat::mc {Show}] \
-variable grid(axes) -command GridApplyDialog
$mb.axes add separator
$mb.axes add cascade -label [msgcat::mc {Color}] -menu $mb.axes.color
$mb.axes add cascade -label [msgcat::mc {Line}] -menu $mb.axes.line
$mb.axes add separator
$mb.axes add cascade -label [msgcat::mc {Origin}] -menu $mb.axes.origin
ColorMenu $mb.axes.color grid axes,color GridApplyDialog
GridCreateLineMenu $mb.axes.line axes,width axes,style
menu $mb.axes.origin
$mb.axes.origin add radiobutton -label [msgcat::mc {Lower Left Front}] \
-variable grid(axes,origin) -value lll -command GridApplyDialog
$mb.axes.origin add radiobutton -label [msgcat::mc {Lower Right Front}] \
-variable grid(axes,origin) -value ull -command GridApplyDialog
$mb.axes.origin add radiobutton -label [msgcat::mc {Upper Right Front}] \
-variable grid(axes,origin) -value uul -command GridApplyDialog
$mb.axes.origin add radiobutton -label [msgcat::mc {Upper Left Front}] \
-variable grid(axes,origin) -value lul -command GridApplyDialog
$mb.axes.origin add separator
$mb.axes.origin add radiobutton -label [msgcat::mc {Lower Left Back}] \
-variable grid(axes,origin) -value llu -command GridApplyDialog
$mb.axes.origin add radiobutton -label [msgcat::mc {Lower Right Back}] \
-variable grid(axes,origin) -value ulu -command GridApplyDialog
$mb.axes.origin add radiobutton -label [msgcat::mc {Upper Right Back}] \
-variable grid(axes,origin) -value uuu -command GridApplyDialog
$mb.axes.origin add radiobutton -label [msgcat::mc {Upper Left Back}] \
-variable grid(axes,origin) -value luu -command GridApplyDialog
# Numerics
menu $mb.numlab
$mb.numlab add checkbutton -label [msgcat::mc {Show}] \
-variable grid(numlab) -command GridApplyDialog
$mb.numlab add separator
$mb.numlab add cascade -label [msgcat::mc {Color}] \
-menu $mb.numlab.color
$mb.numlab add cascade -label [msgcat::mc {Font}] \
-menu $mb.numlab.font
ColorMenu $mb.numlab.color grid numlab,color GridApplyDialog
FontMenu $mb.numlab.font \
grid numlab,font numlab,size numlab,weight numlab,slant \
GridApplyDialog
# Labels
menu $mb.textlab
$mb.textlab add checkbutton -label [msgcat::mc {Show}] \
-variable grid(textlab) -command GridApplyDialog
$mb.textlab add separator
$mb.textlab add cascade -label [msgcat::mc {Color}] \
-menu $mb.textlab.color
$mb.textlab add cascade -label [msgcat::mc {Font}] \
-menu $mb.textlab.font
ColorMenu $mb.textlab.color grid textlab,color GridApplyDialog
FontMenu $mb.textlab.font \
grid textlab,font textlab,size textlab,weight textlab,slant \
GridApplyDialog
# Tickmarks
menu $mb.tick
$mb.tick add checkbutton -label [msgcat::mc {Show}] \
-variable grid(tick) -command GridApplyDialog
$mb.tick add separator
$mb.tick add cascade -label [msgcat::mc {Color}] \
-menu $mb.tick.color
$mb.tick add cascade -label [msgcat::mc {Line}] \
-menu $mb.tick.line
ColorMenu $mb.tick.color grid tick,color GridApplyDialog
GridCreateLineMenu $mb.tick.line tick,width tick,style
# Title
menu $mb.title
$mb.title add checkbutton -label [msgcat::mc {Show}] \
-variable grid(title) -command GridApplyDialog
$mb.title add separator
$mb.title add cascade -label [msgcat::mc {Color}] -menu $mb.title.color
$mb.title add cascade -label [msgcat::mc {Font}] -menu $mb.title.font
ColorMenu $mb.title.color grid title,color GridApplyDialog
FontMenu $mb.title.font \
grid title,font title,size title,weight title,slant \
GridApplyDialog
# Border
menu $mb.border
$mb.border add checkbutton -label [msgcat::mc {Show}] \
-variable grid(border) -command GridApplyDialog
$mb.border add separator
$mb.border add cascade -label [msgcat::mc {Color}] -menu $mb.border.color
$mb.border add cascade -label [msgcat::mc {Line}] -menu $mb.border.line
ColorMenu $mb.border.color grid border,color GridApplyDialog
GridCreateLineMenu $mb.border.line border,width border,style
# Labels
set f [ttk::labelframe $w.label -text [msgcat::mc {Labels}] -padding 2]
ttk::label $f.label -text [msgcat::mc {Title}]
ttk::entry $f.title -textvariable grid(title,text) \
-width 60
ttk::checkbutton $f.default -text [msgcat::mc {Default}] \
-variable grid(title,def) -command GridApplyDialog
ttk::label $f.label1 -text "[msgcat::mc {Axis}] 1"
ttk::entry $f.title1 -textvariable grid(textlab,text1) \
-width 60
ttk::checkbutton $f.default1 -text [msgcat::mc {Default}] \
-variable grid(textlab,def1) -command GridApplyDialog
ttk::label $f.label2 -text "[msgcat::mc {Axis}] 2"
ttk::entry $f.title2 -textvariable grid(textlab,text2) \
-width 60
ttk::checkbutton $f.default2 -text [msgcat::mc {Default}] \
-variable grid(textlab,def2) -command GridApplyDialog
grid $f.label $f.title $f.default -padx 2 -pady 2 -sticky ew
grid $f.label1 $f.title1 $f.default1 -padx 2 -pady 2 -sticky ew
grid $f.label2 $f.title2 $f.default2 -padx 2 -pady 2 -sticky ew
grid columnconfigure $f 1 -weight 1
# Params
set f [ttk::labelframe $w.param -text [msgcat::mc {Spacing}] -padding 2]
ttk::label $f.lspace -text "[msgcat::mc {Label}] %"
ttk::label $f.ngap -text "[msgcat::mc {Numerics}] %"
ttk::label $f.lformat -text [msgcat::mc {Format}]
ttk::label $f.lgap -text [msgcat::mc {Grid Gap}]
ttk::label $f.titlet -text [msgcat::mc {Title}]
ttk::entry $f.spacet -textvariable grid(title,gap) \
-width 8
ttk::label $f.title1 -text "[msgcat::mc {Axis}] 1"
ttk::entry $f.tspace1 -textvariable grid(textlab,gap1) -width 8
ttk::entry $f.nspace1 -textvariable grid(numlab,gap1) -width 8
ttk::entry $f.format1 -textvariable grid(format1) -width 8
ttk::entry $f.gap1 -textvariable grid(grid,gap1) -width 8
ttk::label $f.gapunit1 -textvariable grid(grid,gapunit1)
ttk::label $f.title2 -text "[msgcat::mc {Axis}] 2"
ttk::entry $f.tspace2 -textvariable grid(textlab,gap2) -width 8
ttk::entry $f.nspace2 -textvariable grid(numlab,gap2) -width 8
ttk::entry $f.format2 -textvariable grid(format2) -width 8
ttk::entry $f.gap2 -textvariable grid(grid,gap2) -width 8
ttk::label $f.gapunit2 -textvariable grid(grid,gapunit2)
ttk::label $f.title3 -text "[msgcat::mc {Axis}] 3"
ttk::entry $f.nspace3 -textvariable grid(numlab,gap3) -width 8
ttk::entry $f.format3 -textvariable grid(format3) -width 8
ttk::entry $f.gap3 -textvariable grid(grid,gap3) -width 8
ttk::label $f.gapunit3 -textvariable grid(grid,gapunit3)
grid x $f.lspace $f.ngap $f.lformat $f.lgap -padx 2 -pady 2 -sticky w
grid $f.titlet $f.spacet -padx 2 -pady 2 -sticky w
grid $f.title1 $f.tspace1 $f.nspace1 $f.format1 $f.gap1 $f.gapunit1 \
-padx 2 -pady 2 -sticky w
grid $f.title2 $f.tspace2 $f.nspace2 $f.format2 $f.gap2 $f.gapunit2 \
-padx 2 -pady 2 -sticky w
# Buttons
set f [ttk::frame $w.buttons]
ttk::button $f.apply -text [msgcat::mc {Apply}] -command GridApplyDialog
ttk::button $f.reset -text [msgcat::mc {Reset}] -command GridResetDialog
ttk::button $f.clear -text [msgcat::mc {Clear}] -command GridClearDialog
ttk::button $f.close -text [msgcat::mc {Close}] -command GridDestroyDialog
pack $f.apply $f.reset $f.clear $f.close -side left -expand true \
-padx 2 -pady 4
bind $w <Return> "GridApplyDialog"
# Fini
grid $w.label -sticky news
grid $w.param -sticky news
grid $w.buttons -sticky ew
grid rowconfigure $w 0 -weight 1
grid rowconfigure $w 1 -weight 1
grid columnconfigure $w 0 -weight 1
# some window managers need a hint
raise $w
UpdateGridDialog
}
proc GridApplyDialog {} {
global grid
set grid(view) 1
GridUpdateCurrent
}
proc GridResetDialog {} {
GridDefault
GridUpdateCurrent
}
proc GridClearDialog {} {
global grid
set grid(view) 0
GridUpdateCurrent
}
proc GridDestroyDialog {} {
global igrid
if {[winfo exists $igrid(top)]} {
destroy $igrid(top)
destroy $igrid(mb)
}
}
proc UpdateGridMenu {} {
global grid
global current
global wcs
global debug
if {$debug(tcl,update)} {
puts stderr "UpdateGridMenu"
}
if {($current(frame) == {})} {
return
}
# set menu
if {[$current(frame) has fits]} {
set grid(view) [$current(frame) has grid]
}
# reassign system and format
if {[$current(frame) has fits] && [$current(frame) has grid]} {
set ll [$current(frame) get grid]
set grid(system) [lindex $ll 0]
set grid(sky) [lindex $ll 1]
set grid(skyformat) [lindex $ll 2]
set grid(type) [lindex $ll 3]
# fix for grids create with old backup command
if {[$current(frame) get grid var] == {}} {
$current(frame) grid delete
$current(frame) grid create $grid(system) $grid(sky) \
$grid(skyformat) $grid(type) \
[GridBuildOptions $current(frame)] "\"[array get grid]\""
}
array set grid [$current(frame) get grid var]
} else {
# can be changed by wcs
SetCoordSystem grid system sky skyformat
}
}
proc UpdateGridDialog {} {
global current
global igrid
global grid
set mb $igrid(mb)
global debug
if {$debug(tcl,update)} {
puts stderr "UpdateGridDialog"
}
GridAdjustOptions $current(frame)
if {[winfo exists $igrid(top)]} {
set f $igrid(top).label
set g $igrid(top).param
if {$current(frame) != {}} {
switch -- [$current(frame) get type] {
base -
rgb {
$mb entryconfig [msgcat::mc {Labels}] -state normal
$mb entryconfig [msgcat::mc {Title}] -state normal
$mb.type entryconfig [msgcat::mc {Interior Numerics}] \
-state normal
$mb.type entryconfig [msgcat::mc {Exterior Numerics}] \
-state normal
$mb.type entryconfig [msgcat::mc {Vertical Text}] \
-state normal
$mb.axes entryconfig [msgcat::mc {Origin}] \
-state disable
$f.label configure -state normal
$f.title configure -state normal
$f.default configure -state normal
$f.label1 configure -state normal
$f.title1 configure -state normal
$f.default1 configure -state normal
$f.label2 configure -state normal
$f.title2 configure -state normal
$f.default2 configure -state normal
$g.lspace configure -state normal
$g.spacet configure -state normal
$g.tspace1 configure -state normal
$g.tspace2 configure -state normal
grid forget $g.title3 $g.nspace3 $g.format3 $g.gap3 \
$g.gapunit3
}
3d {
$mb entryconfig [msgcat::mc {Labels}] -state disabled
$mb entryconfig [msgcat::mc {Title}] -state disabled
$mb.type entryconfig [msgcat::mc {Interior Numerics}] \
-state disabled
$mb.type entryconfig [msgcat::mc {Exterior Numerics}] \
-state disabled
$mb.type entryconfig [msgcat::mc {Vertical Text}] \
-state disabled
$mb.axes entryconfig [msgcat::mc {Origin}] -state normal
$f.label configure -state disabled
$f.title configure -state disabled
$f.default configure -state disabled
$f.label1 configure -state disabled
$f.title1 configure -state disabled
$f.default1 configure -state disabled
$f.label2 configure -state disabled
$f.title2 configure -state disabled
$f.default2 configure -state disabled
$g.lspace configure -state disabled
$g.spacet configure -state disabled
$g.tspace1 configure -state disabled
$g.tspace2 configure -state disabled
grid $g.title3 x $g.nspace3 $g.format3 $g.gap3 $g.gapunit3 \
-padx 2 -pady 2 -sticky w
}
}
set grid(frame) $current(frame)
if {[$current(frame) has fits]} {
CoordMenuEnable $igrid(mb).coord grid system 1 sky skyformat
} else {
CoordMenuReset $igrid(mb).coord grid system 1 sky skyformat
}
}
}
}
proc GridCreateLineMenu {which width dash} {
global igrid
global grid
WidthDashMenu $which grid $width $dash GridApplyDialog GridApplyDialog
}
proc GridLoadDialog {} {
GridLoad [OpenFileDialog gridfbox]
}
proc GridLoad {filename} {
global grid
if {$filename != {}} {
source $filename
}
# backward compatibility
FixFontVar grid(numlab,weight) grid(numlab,slant) grid(numlab,style)
FixFontVar grid(textlab,weight) grid(textlab,slant) grid(textlab,style)
FixFontVar grid(title,weight) grid(title,slant) grid(title,style)
set grid(view) 1
GridUpdateCurrent
}
proc GridSaveDialog {} {
GridSave [SaveFileDialog gridfbox]
}
proc GridSave {filename} {
global grid
if {$filename != {}} {
set file [open $filename w]
puts $file "global grid"
puts $file "array set grid \{ [array get grid] \}"
close $file
}
}
proc GridStripComma {str} {
# strip ','
set t {}
regsub -all "," "$str" " " t
return $t
}
proc GridDefaultFormat1 {} {
global grid
global current
switch $grid(system) {
image -
physical -
detector -
amplifier {return {}}
default {
if {[$current(frame) has wcs equatorial $grid(system)]} {
switch $grid(sky) {
fk4 -
fk5 -
icrs {
switch $grid(skyformat) {
degrees {return {d.3}}
sexagesimal {return {hms.1}}
hms {return {lhms.1}}
}
}
galactic -
ecliptic {
switch $grid(skyformat) {
degrees {return {d.3}}
sexagesimal {return {dms.1}}
hms {return {ldms}}
}
}
}
return {}
}
if {[$current(frame) has wcs celestrial $grid(system)]} {
switch $grid(skyformat) {
degrees {return {d.3}}
sexagesimal {return {dms.1}}
hms {return {ldms}}
}
return {}
}
}
}
}
proc GridDefaultFormat2 {} {
global grid
global current
switch $grid(system) {
image -
physical -
detector -
amplifier {return {}}
default {
if {[$current(frame) has wcs equatorial $grid(system)]} {
switch $grid(sky) {
fk4 -
fk5 -
icrs {
switch $grid(skyformat) {
degrees {return {d.3}}
sexagesimal {return {dms.1}}
hms {return {ldms.1}}
}
}
galactic -
ecliptic {
switch $grid(skyformat) {
degrees {return {d.3}}
sexagesimal {return {dms.1}}
hms {return {ldms}}
}
}
}
return {}
}
if {[$current(frame) has wcs celestrial $grid(system)]} {
switch $grid(skyformat) {
degrees {return {d.3}}
sexagesimal {return {dms.1}}
hms {return {ldms}}
}
return {}
}
}
}
}
proc GridBackup {ch which} {
global grid
if {[$which has grid]} {
set ll [$which get grid]
set system [lindex $ll 0]
set sky [lindex $ll 1]
set skyformat [lindex $ll 2]
set type [lindex $ll 3]
set opts [$which get grid option]
set vars [array get grid]
puts $ch "$which grid create $system $sky $skyformat $type \{\"$opts\"\} \{\"$vars\"\}"
}
}
# Process Cmds
proc ProcessGridCmd {varname iname} {
upvar $varname var
upvar $iname i
global grid
switch -- [string tolower [lindex $var $i]] {
open {GridDialog}
close {GridDestroyDialog}
yes -
true -
on -
1 -
no -
false -
off -
0 {
set grid(view) [FromYesNo [lindex $var $i]]
GridUpdateCurrent
}
type {
incr i
switch -- [string tolower [lindex $var $i]] {
axes {
# backward compatible
incr i; set grid(axes,type) [lindex $var $i]
}
numerics {
# backward compatible
incr i; set grid(numlab,type) [lindex $var $i]
}
default {set grid(type) [lindex $var $i]}
}
GridUpdateCurrent
}
system {incr i; set grid(system) [lindex $var $i]; GridUpdateCurrent}
sky {incr i
set grid(sky) [string tolower [lindex $var $i]]
GridUpdateCurrent
}
skyformat {
incr i
switch -- [string tolower [lindex $var $i]] {
deg -
degree -
degrees {set grid(skyformat) degrees}
default {set grid(skyformat) [string tolower [lindex $var $i]]}
}
GridUpdateCurrent
}
grid {
incr i
switch -- [string tolower [lindex $var $i]] {
color {incr i; set grid(grid,color) [lindex $var $i]}
width {incr i; set grid(grid,width) [lindex $var $i]}
style {incr i; set grid(grid,style) [lindex $var $i]}
gap1 {incr i; set grid(grid,gap1) [lindex $var $i]}
gap2 {incr i; set grid(grid,gap2) [lindex $var $i]}
gap3 {incr i; set grid(grid,gap3) [lindex $var $i]}
default {set grid(grid) [FromYesNo [lindex $var $i]]}
}
GridUpdateCurrent
}
axes {
incr i
switch -- [string tolower [lindex $var $i]] {
color {incr i; set grid(axes,color) [lindex $var $i]}
width {incr i; set grid(axes,width) [lindex $var $i]}
style {incr i; set grid(axes,style) [lindex $var $i]}
type {incr i; set grid(axes,type) [lindex $var $i]}
origin {incr i; set grid(axes,origin) [lindex $var $i]}
default {set grid(axes) [FromYesNo [lindex $var $i]]}
}
GridUpdateCurrent
}
format1 {
incr i; set grid(format1) [lindex $var $i]
GridUpdateCurrent
}
format2 {
incr i; set grid(format2) [lindex $var $i]
GridUpdateCurrent
}
tickmark -
tickmarks -
tick {
incr i
switch -- [string tolower [lindex $var $i]] {
color {incr i; set grid(tick,color) [lindex $var $i]}
width {incr i; set grid(tick,width) [lindex $var $i]}
style {incr i; set grid(tick,style) [lindex $var $i]}
default {set grid(tick) [FromYesNo [lindex $var $i]]}
}
GridUpdateCurrent
}
border {
incr i
switch -- [string tolower [lindex $var $i]] {
color {incr i; set grid(border,color) [lindex $var $i]}
width {incr i; set grid(border,width) [lindex $var $i]}
style {incr i; set grid(border,style) [lindex $var $i]}
default {set grid(border) [FromYesNo [lindex $var $i]]}
}
GridUpdateCurrent
}
numeric -
numerics -
numlab {
incr i
switch -- [string tolower [lindex $var $i]] {
font {incr i; set grid(numlab,font) [lindex $var $i]}
fontsize {incr i; set grid(numlab,size) [lindex $var $i]}
fontweight {incr i; set grid(numlab,weight) [lindex $var $i]}
fontslant {incr i; set grid(numlab,slant) [lindex $var $i]}
fontstyle {
incr i
switch [lindex $var $i] {
normal {
set grid(numlab,weight) normal
set grid(numlab,slant) roman
}
bold {
set grid(numlab,weight) bold
set grid(numlab,slant) roman
}
italic {
set grid(numlab,weight) normal
set grid(numlab,slant) italic
}
}
}
color {incr i; set grid(numlab,color) [lindex $var $i]}
gap1 {incr i; set grid(numlab,gap1) [lindex $var $i]}
gap2 {incr i; set grid(numlab,gap2) [lindex $var $i]}
gap3 {incr i; set grid(numlab,gap3) [lindex $var $i]}
type {incr i; set grid(numlab,type) [lindex $var $i]}
vertical {incr i; set grid(numlab,vertical) [FromYesNo [lindex $var $i]]}
default {set grid(numlab) [FromYesNo [lindex $var $i]]}
}
GridUpdateCurrent
}
title {
incr i
switch -- [string tolower [lindex $var $i]] {
text {incr i; set grid(title,text) [lindex $var $i]}
def {incr i; set grid(title,def) [FromYesNo [lindex $var $i]]}
gap {incr i; set grid(title,gap) [lindex $var $i]}
font {incr i; set grid(title,font) [lindex $var $i]}
fontsize {incr i; set grid(title,size) [lindex $var $i]}
fontweight {incr i; set grid(title,weight) [lindex $var $i]}
fontslant {incr i; set grid(title,slant) [lindex $var $i]}
fontstyle {
incr i
switch [lindex $var $i] {
normal {
set grid(title,weight) normal
set grid(title,slant) roman
}
bold {
set grid(title,weight) bold
set grid(title,slant) roman
}
italic {
set grid(title,weight) normal
set grid(title,slant) italic
}
}
}
color {incr i; set grid(title,color) [lindex $var $i]}
default {set grid(title) [FromYesNo [lindex $var $i]]}
}
GridUpdateCurrent
}
label -
labels -
textlab {
incr i
switch -- [string tolower [lindex $var $i]] {
text1 {incr i; set grid(textlab,text1) [lindex $var $i]}
text2 {incr i; set grid(textlab,text2) [lindex $var $i]}
def1 {incr i; set grid(textlab,def1) [FromYesNo [lindex $var $i]]}
def2 {incr i; set grid(textlab,def2) [FromYesNo [lindex $var $i]]}
gap1 {incr i; set grid(textlab,gap1) [lindex $var $i]}
gap2 {incr i; set grid(textlab,gap2) [lindex $var $i]}
font {incr i; set grid(textlab,font) [lindex $var $i]}
fontsize {incr i; set grid(textlab,size) [lindex $var $i]}
fontweight {incr i; set grid(textlab,weight) [lindex $var $i]}
fontslant {incr i; set grid(textlab,slant) [lindex $var $i]}
fontstyle {
incr i
switch [lindex $var $i] {
normal {
set grid(textlab,weight) normal
set grid(textlab,slant) roman
}
bold {
set grid(textlab,weight) bold
set grid(textlab,slant) roman
}
italic {
set grid(textlab,weight) normal
set grid(textlab,slant) italic
}
}
}
color {incr i; set grid(textlab,color) [lindex $var $i]}
default {set grid(textlab) [FromYesNo [lindex $var $i]]}
}
GridUpdateCurrent
}
view {
# backward compatable
incr i
switch -- [string tolower [lindex $var $i]] {
grid {incr i; set grid(grid) [FromYesNo [lindex $var $i]]}
axes {
incr i
switch -- [string tolower [lindex $var $i]] {
numbers {incr i; set grid(numlab) \
[FromYesNo [lindex $var $i]]}
tickmarks {incr i; set grid(tick) \
[FromYesNo [lindex $var $i]]}
label {incr i; set grid(textlab) \
[FromYesNo [lindex $var $i]]}
default {set grid(axes) [FromYesNo [lindex $var $i]]}
}
}
title {incr i; set grid(title) [FromYesNo [lindex $var $i]]}
border {incr i; set grid(border) [FromYesNo [lindex $var $i]]}
vertical {
incr i
set grid(numlab,vertical) [FromYesNo [lindex $var $i]]
}
}
GridUpdateCurrent
}
reset {GridResetDialog}
load {
incr i
set fn [lindex $var $i]
FileLast gridfbox $fn
GridLoad $fn
}
save {
incr i
set fn [lindex $var $i]
FileLast gridfbox $fn
GridSave $fn
}
default {
set grid(view) 1
GridUpdateCurrent
incr i -1
}
}
}
proc ProcessSendGridCmd {proc id param} {
global grid
switch -- [lindex $param 0] {
type {
switch -- [lindex $param 1] {
axes {
# backward compatible
$proc $id "$grid(axes,type)\n"
}
numerics {
# backward compatible
$proc $id "$grid(numlab,type)\n"
}
default {$proc $id "$grid(type)\n"}
}
}
system {$proc $id "$grid(system)\n"}
sky {$proc $id "$grid(sky)\n"}
skyformat {$proc $id "$grid(skyformat)\n"}
grid {
switch -- [lindex $param 1] {
color {$proc $id "$grid(grid,color)\n"}
width {$proc $id "$grid(grid,width)\n"}
style {$proc $id "$grid(grid,style)\n"}
gap1 {$proc $id "$grid(grid,gap1)\n"}
gap2 {$proc $id "$grid(grid,gap2)\n"}
gap3 {$proc $id "$grid(grid,gap3)\n"}
default {$proc $id [ToYesNo $grid(grid)]}
}
}
axes {
switch -- [lindex $param 1] {
color {$proc $id "$grid(axes,color)\n"}
width {$proc $id "$grid(axes,width)\n"}
style {$proc $id "$grid(axes,style)\n"}
type {$proc $id "$grid(axes,type)\n"}
origin {$proc $id "$grid(axes,origin)\n"}
default {$proc $id [ToYesNo $grid(axes)]}
}
}
format1 {$proc $id "$grid(format1)\n"}
format2 {$proc $id "$grid(format2)\n"}
tickmark -
tickmarks -
tick {
switch -- [lindex $param 1] {
color {$proc $id "$grid(tick,color)\n"}
width {$proc $id "$grid(tick,width)\n"}
style {$proc $id "$grid(tick,style)\n"}
default {$proc $id [ToYesNo $grid(tick)]}
}
}
border {
switch -- [lindex $param 1] {
color {$proc $id "$grid(border,color)\n"}
width {$proc $id "$grid(border,width)\n"}
style {$proc $id "$grid(border,style)\n"}
default {$proc $id [ToYesNo $grid(border)]}
}
}
numeric -
numerics -
numlab {
switch -- [lindex $param 1] {
font {$proc $id "$grid(numlab,font)\n"}
fontsize {$proc $id "$grid(numlab,size)\n"}
fontstyle -
fontweight {$proc $id "$grid(numlab,weight)\n"}
fontslant {$proc $id "$grid(numlab,slant)\n"}
color {$proc $id "$grid(numlab,color)\n"}
gap1 {$proc $id "$grid(numlab,gap1)\n"}
gap2 {$proc $id "$grid(numlab,gap2)\n"}
gap3 {$proc $id "$grid(numlab,gap3)\n"}
type {$proc $id "$grid(numlab,type)\n"}
vertical {$proc $id "$grid(numlab,vertical)\n"}
default {$proc $id [ToYesNo $grid(numlab)]}
}
}
title {
switch -- [lindex $param 1] {
text {$proc $id "$grid(title,text)\n"}
def {$proc $id [ToYesNo $grid(title,def)]}
gap {$proc $id "$grid(title,gap)\n"}
font {$proc $id "$grid(title,font)\n"}
fontsize {$proc $id "$grid(title,size)\n"}
fontstyle -
fontweight {$proc $id "$grid(title,weight)\n"}
fontslant {$proc $id "$grid(title,slant)\n"}
color {$proc $id "$grid(title,color)\n"}
default {$proc $id [ToYesNo $grid(title)]}
}
}
label -
labels -
textlab {
switch -- [lindex $param 1] {
text1 {$proc $id "$grid(textlab,text1)\n"}
text2 {$proc $id "$grid(textlab,text2)\n"}
def1 {$proc $id [ToYesNo $grid(textlab,def1)]}
def2 {$proc $id [ToYesNo $grid(textlab,def2)]}
gap1 {$proc $id "$grid(textlab,gap1)\n"}
gap2 {$proc $id "$grid(textlab,gap2)\n"}
font {$proc $id "$grid(textlab,font)\n"}
fontsize {$proc $id "$grid(textlab,size)\n"}
fontstyle -
fontweight {$proc $id "$grid(textlab,weight)\n"}
fontslant {$proc $id "$grid(textlab,slant)\n"}
color {$proc $id "$grid(textlab,color)\n"}
default {$proc $id [ToYesNo $grid(textlab)]}
}
}
view {
# backward compatible
switch -- [lindex $param 1] {
grid {$proc $id [ToYesNo $grid(grid)]}
axes {
switch -- [lindex $param 2] {
numbers {$proc $id [ToYesNo $grid(numlab)]}
tickmarks {$proc $id [ToYesNo $grid(tick)]}
label {$proc $id [ToYesNo $grid(textlab)]}
default {$proc $id [ToYesNo $grid(axes)]}
}
}
title {$proc $id [ToYesNo $grid(title)]}
border {$proc $id [ToYesNo $grid(border)]}
vertical {$proc $id [ToYesNo $grid(numlab,vertical)]}
}
}
default {$proc $id [ToYesNo $grid(view)]}
}
}
|