-
Notifications
You must be signed in to change notification settings - Fork 0
/
scanSee.pro
1527 lines (1336 loc) · 44.2 KB
/
scanSee.pro
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
;*************************************************************************
; Copyright (c) 2002 The University of Chicago, as Operator of Argonne
; National Laboratory.
; Copyright (c) 2002 The Regents of the University of California, as
; Operator of Los Alamos National Laboratory.
; This file is distributed subject to a Software License Agreement found
; in the file LICENSE that is included with this distribution.
;*************************************************************************
;@scanSee__define
@panimage.pro
PRO DC_view_writeConfig,state
openw,unit,'scanSee.config',/get_lun
printf,unit,state.filename
printf,unit,state.path
printf,unit,''
free_lun,unit
END
PRO DC_view_readConfig,filename,path
filename=''
path=''
openr,unit,'scanSee.config',/get_lun
readf,unit,filename
readf,unit,path
free_lun,unit
END
PRO DC_view_init, filename , DC_view_ids, print=print
WIDGET_CONTROL,/HOURGLASS
ret = obj_valid(DC_view_ids.v)
; if ret then obj_destroy,DC_view_ids.v
if ret eq 0 then begin
r = read_scan(filename,scan,/header)
dim = *scan.dim
DC_view_ids.toobig = 0
if dim eq 3 then begin
cpt = *scan.cpt
if cpt(0) ge 1000 or cpt(1) ge 500 or cpt(2) ge 500 then begin
DC_view_ids.toobig = 1
if DC_view_ids.detno le 0 then $
DC_view_ids.detno = 16
WIDGET_CONTROL,DC_view_ids.list2DWID,SET_LIST_SELECT=DC_view_ids.detno-1
end
end
free_scanAlloc,scan
if dim eq 3 then begin
if DC_view_ids.bypass3d then $
v = obj_new('scanSee',file=filename,pickDet=-1) else $
if DC_view_ids.toobig then $
v = obj_new('scanSee',file=filename,pickDet=DC_view_ids.detno) $
else v = obj_new('scanSee',file=filename)
endif else begin
v = obj_new('scanSee',file=filename)
end
DC_view_ids.v = v
endif else v = DC_view_ids.v
v->read,dim=dim,num_pts=num_pts,cpt=cpt,pv=pv,labels=labels,$
scanno=scanno,id_def=id_def, $
pa1d=pa1d,da1d=da1d,pa2d=pa2d,da2d=da2d,pa3d=pa3d,da3d=da3d, $
x=x,y=y,z=z,class=class,outpath=outpath
if n_elements(dim) eq 0 then begin
st = ['Read failed on:',filename,'','You have to use "File..." button to pick another file']
r=dialog_message(/error,st)
return
end
if dim gt 3 then begin
st = ['File: '+filename+' is a '+strtrim(dim,2)+'D scan','Sorry! '+strtrim(dim,2)+'D scan not supported']
r = dialog_message(st ,/info)
return
end
DC_view_ids.toobig = 0
if dim eq 3 then begin
if cpt(0) ge 1000 or cpt(1) ge 500 or cpt(2) ge 500 then begin
DC_view_ids.toobig = 1
if DC_view_ids.detno le 0 then $
DC_view_ids.detno = 16
WIDGET_CONTROL,DC_view_ids.list2DWID,SET_LIST_SELECT=DC_view_ids.detno-1
end
end
if scanno lt 0 then begin
str = ['Error encountered in reading the file:',filename,'', $
'You have to use File... selection dialog','' , $
'to select a new file.']
r=dialog_message(str, /Error)
return
end
if keyword_set(print) then $
help,scanno,dim,num_pts,cpt,pv,labels,id_def,pa1d,da1d,pa2d,da2d, $
pa3d,da3d,x,y,z
; DC_view_ids.startno = 1
; DC_view_ids.detno = 16 ; default to D01
DC_view_ids.endno = 1
DC_view_ids.fileno = scanno
DC_view_ids.filename = filename
DC_view_ids.dim = dim
DC_view_ids.width = num_pts(0)
DC_view_ids.maxno = 1
DC_view_ids.def = id_def
DC_view_ids.outpath = outpath
DC_view_ids.class = class
if dim eq 2 then begin
DC_view_ids.height = num_pts(1)
h = cpt(1)
if h eq 0 then h = 1
DC_view_ids.maxno = h
if h eq 0 then begin
r=dialog_message('Error in read file: '+ DC_view_ids.filename,/Error)
end
str1 = indgen(h,/string)
WIDGET_CONTROL, DC_view_ids.base2DWID,SENSITIVE=1
WIDGET_CONTROL,DC_view_ids.list1dWID,SET_VALUE=str1
endif else WIDGET_CONTROL, DC_view_ids.base2DWID,SENSITIVE=0
id_def1 = id_def(*,0)
ndet = n_elements(id_def1)-4
str2 = DC_view_ids.list(1:ndet)
str2 = DC_view_ids.detname(0:ndet-1)
WIDGET_CONTROL,DC_view_ids.list2DWID,SET_VALUE=str2
WIDGET_CONTROL,DC_view_ids.list2DWID,SET_LIST_SELECT=DC_view_ids.detno-1
WIDGET_CONTROL,DC_view_ids.list1dWID,SET_LIST_SELECT=DC_view_ids.list_sel(0:DC_view_ids.sel_no-1)
WIDGET_CONTROL, DC_view_ids.base1DWID1,SENSITIVE=1
WIDGET_CONTROL, DC_view_ids.base1DWID2,SENSITIVE=1
if dim eq 3 then begin
WIDGET_CONTROL, DC_view_ids.base1DWID1,SENSITIVE=0
WIDGET_CONTROL, DC_view_ids.base1DWID2,SENSITIVE=0
DC_view_ids.height = cpt(1)
if cpt(1) le 0 then DC_view_ids.height = num_pts(1)
DC_view_ids.depth = num_pts(2)
if cpt(2) lt num_pts(2) then DC_view_ids.depth = cpt(2)+1
num = DC_view_ids.depth
if DC_view_ids.rank eq 0 then num = DC_view_ids.width
if DC_view_ids.rank eq 1 then num = DC_view_ids.height
str2= strtrim(indgen(num),2)
WIDGET_CONTROL,DC_view_ids.list3dWID,SET_VALUE=str2
DC_view_ids.slice = 0
WIDGET_CONTROL,DC_view_ids.list3dWID,SET_LIST_SELECT=DC_view_ids.slice
end
type = ' 3D Data '
if dim eq 1 then begin
v->plot1d,/data,group=DC_view_ids.base
type = ' 1D Data '
end
if dim eq 2 then begin
v->view2d,DC_view_ids.detno,group=DC_view_ids.base
type = ' 2D Data '
end
if dim eq 3 then WIDGET_CONTROL,DC_view_ids.base3dWID,SENSITIVE=1 else $
WIDGET_CONTROL,DC_view_ids.base3dWID,SENSITIVE=0
; if DC_view_ids.toobig eq 1 then $
; WIDGET_CONTROL,DC_view_ids.base3dWID2,SENSITIVE=0 else $
; WIDGET_CONTROL,DC_view_ids.base3dWID2,SENSITIVE=1
WIDGET_CONTROL,DC_view_ids.filetypeWID,set_value=type
WIDGET_CONTROL,DC_view_ids.filenoWID,set_value=DC_view_ids.fileno
if dim eq 3 then begin
sz = size(da2D)
def = id_def(4:4+sz(3)-1,1) ;make_array(sz(3),/int,value=1)
new_win = DC_view_ids.wid2d
panimage,da2D,def,numd=10,new_win=new_win, $
title='3D SCAN # '+strtrim(DC_view_ids.fileno,2)+' (All 2D Di)'
DC_view_ids.wid2d=new_win
end
END
PRO DC_view_cleanup,state
v = state.v
ret = obj_valid(v)
if ret then v->delete
v = 0
END
PRO scansee_getLabels,labels,id_def,rank=rank,label_state,def=def
; rank : 0-scanH, 1-scan1, 2-scan2
;
irank = 0
if keyword_set(rank) then irank=rank
id = id_def(4:88,irank)
def = where(id gt 0)
ndet = n_elements(def)
s_array = labels(267*irank:(irank+1)*267-1)
s_array = reform(s_array,89,3)
p_name = s_array(0:3,0)
p_desc = s_array(0:3,1)
p_unit = s_array(0:3,2)
d_name = s_array(4:88,0)
d_desc = s_array(4:88,1)
d_unit = s_array(4:88,2)
label_state = { $
p_name : p_name , $
p_desc : p_desc, $
p_unit : p_unit, $
d_name : d_name , $
d_desc : d_desc, $
d_unit : d_unit, $
ndet : ndet, $
def : def, $
rank : irank $
}
END
PRO scansee_pickouter1d,state,Event,rank=rank
rk=0
if keyword_set(rank) then rk=rank
v = state.v
v->read,dim=dim,cpt=cpt,num_pts=num_pts, $
da1d=da1d,pa1d=pa1d,da2d=da2d,pa2d=pa2d, $
pv=pv,x=xa,y=ya,im=im,labels=labels,id_def=id_def
; if dim eq 2 then begin
if dim eq 2 then rk = 1
if dim eq 3 then rk = 2
scansee_getLabels,labels,id_def,rank=rk,label_state
descs = strtrim(label_state.d_name,2) + ' ' + $
strtrim(label_state.d_desc,2) + ' ' + $
strtrim(label_state.d_unit,2)
legend = state.detname + ': '+ descs
xdisplayfile,text=legend,Group=Event.top,title='Di Info for : '+pv(rk)+ ' (Scan # '+ strtrim(state.fileno,2) +')'
idet = id_def(4:88,rk) ; outer loop 1D
nd = where(idet gt 0)
if nd(0) eq -1 then return
dname = state.detname(nd)
da = make_array(cpt(rk),n_elements(nd))
for i=0,n_elements(nd)-1 do begin
da(*,i) = da1d(0:cpt(rk)-1,nd(i))
end
ipos = state.paxis
if ipos ge 4 then x = indgen(cpt(rk)) else $
x = pa1d(*,ipos)
plot1d,x,da,Group=Event.top,/data,legend=dname, $ ;xylegend=[1.5,-1.5], $
title=pv(rk),comment='Scan # '+strtrim(state.fileno,2)
;end
END
PRO VIEWSPEC_3D_2DMENU_event, Event, state
title=''
v = state.v
v->read,view=state.detno,dim=dim,cpt=cpt, $
da1d=da1d,pa1d=pa1d,da2d=da2d,pa2d=pa2d, $
da3d=da3d,pa3d=pa3d,pv=pv, outpath=outpath, $
x=xa,y=ya,im=im,labels=labels,id_def=id_def
x = pa2d(*,0)
y = pa1d(*,0)
CASE Event.Value OF
'3D_2D Menu.VW2D...': BEGIN
; to be implemented
END
'3D_2D Menu.Pick 2D...': BEGIN
pick2d,da2d,x,y,GROUP=Event.top,class=state.class,path=state.outpath
END
'3D_2D Menu.PanImages...': BEGIN
sz = size(da2d)
def = state.def(4:4+sz(3)-1,1)
; def = demake_array(sz(3),value=1,/int)
panimage_sel,da2d,def,title='3D_2D ( All 2D Di)',Group=Event.top
END
'3D_2D Menu.Calibration...': BEGIN
sz = size(da2d)
def = make_array(sz(3),value=1,/int)
new_win = state.wid2d
panimage,da2d,def,new_win=new_win,title='3D_2D ( All 2D Di)'
state.wid2d=new_win
; calibration_factor,da2d,def, $
; title=title,Group=Event.top else $
calibration_factor,da2d,def, $
title=title,Group=Event.top, $
xv = x, yv=y
END
'3D_2D Menu.Plot/Pick 1D...': BEGIN
scansee_pickouter1d,state,Event,rank=2
END
'3D_2D Menu.CALIB1D...': BEGIN
x = y
sz = size(da1d)
def = make_array(sz(2),value=1,/int)
plot1d,x,da1d,Group=Event.top,/data
calibration_factor,da1d,def,xv=x,title='3D_2D ( All 1D Di)', $
Group=Event.top
END
ENDCASE
END
PRO DC_viewOutputFilename,state,subclass,type,filename
; type is a string can be 'TIFF','XDR','PICT'
; subclass is a subclass string, e.g. '.pan.'
; lp = rstrpos(state.filename,!os.file_sep)+1
; classname = strmid(state.filename,lp,strlen(state.filename)-lp)
classname = state.class
outpath = state.outpath+type+!os.file_sep
found = findfile(outpath,count=ct)
if ct lt 1 then spawn,!os.mkdir + ' '+outpath
filename = outpath+classname+subclass+ strlowcase(type)
;print,'DC_viewOutputFilename:',filename
END
PRO ALLASCII1DSETUP_Event, Event
WIDGET_CONTROL,Event.top,GET_UVALUE=state
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
v = state.v
CASE Ev OF
'VIEWSPEC_STARTNO': BEGIN
WIDGET_CONTROL,Event.Id,GET_VALUE=n1
state.lineno = n1
END
'VIEWSPEC_ENDNO': BEGIN
WIDGET_CONTROL,Event.Id,GET_VALUE=n2
state.endno = n2
END
'VIEWSPEC_ALLASCII1DCREATE': BEGIN
v->ascii1dAll,state.lineno,state.endno,/nowin
END
'VIEWSPEC_ALLASCII1DFIRST': BEGIN
v->ascii1d,state.lineno,GROUP=Event.top
END
'VIEWSPEC_ALLASCII1DLAST': BEGIN
v->ascii1d,state.endno,GROUP=Event.top
END
'VIEWSPEC_ALLASCII1DVIEW': BEGIN
v->ascii1dAll,state.lineno,state.endno,GROUP=Event.top
END
'VIEWSPEC_ALLASCII1DDONE': BEGIN
WIDGET_CONTROL,Event.top,/DESTROY
return
END
ENDCASE
WIDGET_CONTROL,Event.top,SET_UVALUE=state
END
PRO AllASCII1DSetup, state, GROUP=Group
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
ALLASCII1DSETUP = WIDGET_BASE(GROUP_LEADER=Group, $
ROW=1, MAP=1, TITLE='ASCII1D-SETUP', $
UVALUE='ALLASCII1DSETUP')
BASE2 = WIDGET_BASE(ALLASCII1DSETUP, $
COLUMN=1, $
MAP=1, $
UVALUE='BASE2')
LABEL3 = WIDGET_LABEL( BASE2, $
UVALUE='LABEL3', $
VALUE='MULTIPLE 1D ASCII Reports')
LABEL4 = WIDGET_LABEL( BASE2, $
UVALUE='LABEL4', $
VALUE='(Total 1D Lines : '+strtrim(state.maxno,2)+')')
FIELD4 = CW_FIELD( BASE2,VALUE='1', $
ROW=1, $
INTEGER=1, $
RETURN_EVENTS=1, $
TITLE='Begin 1D Line #', $
UVALUE='VIEWSPEC_STARTNO', $
XSIZE=5)
FIELD5 = CW_FIELD( BASE2,VALUE='1', $
ROW=1, $
INTEGER=1, $
RETURN_EVENTS=1, $
TITLE='End 1D Line # ( < '+strtrim(state.maxno,2)+' )', $
UVALUE='VIEWSPEC_ENDNO', $
XSIZE=5)
BASE20 = WIDGET_BASE(BASE2, $
ROW=1, $
MAP=1, $
UVALUE='BASE20')
BUTTON9 = WIDGET_BUTTON( BASE20, $
UVALUE='VIEWSPEC_ALLASCII1DCREATE', $
VALUE='Generate')
BUTTON11 = WIDGET_BUTTON( BASE20, $
UVALUE='VIEWSPEC_ALLASCII1DFIRST', $
VALUE='ViewFirst')
BUTTON12 = WIDGET_BUTTON( BASE20, $
UVALUE='VIEWSPEC_ALLASCII1DLAST', $
VALUE='ViewLast')
BUTTON10 = WIDGET_BUTTON( BASE20, $
UVALUE='VIEWSPEC_ALLASCII1DVIEW', $
VALUE='ViewAll')
BUTTON11 = WIDGET_BUTTON( BASE20, $
UVALUE='VIEWSPEC_ALLASCII1DDONE', $
VALUE='Done')
WIDGET_CONTROL, ALLASCII1DSETUP, /REALIZE
WIDGET_CONTROL, ALLASCII1DSETUP, SET_UVALUE=state
XMANAGER, 'ALLASCII1DSETUP', ALLASCII1DSETUP
END
PRO PDMENU_ASCII1D_Event,state,Event
v = state.v
CASE Event.Value OF
'ASCII1D.1D SCAN...': begin
if state.dim eq 1 then $
v->ascii1d,state.lineno,GROUP=Event.top
end
'ASCII1D.2D SCAN...': begin
if state.dim eq 2 then $
ALLASCII1DSETUP,state,GROUP=Event.top
end
ENDCASE
END
PRO scanSee_PDMENU2D_Info_Event,state,Event
CASE Event.Value OF
'Color.Color...': BEGIN
xloadct,Group=Event.top
END
'Color.Restore Pvt...': BEGIN
found = findfile('pvtcolors.dat')
if found(0) eq '' then begin
st = ['Error: Private color table never been saved before. ', $
' You have to use Color->Save Pvt... to save the private color first, before', $
' you can load it into the scanSee program.']
xdisplayfile,text=st,Group=Event.top
endif else begin
restore,'pvtcolors.dat'
TVLCT,red,green,blue
end
return
END
'Color.Save Pvt...': BEGIN
tvlct,red,green,blue,/get
save,red,green,blue,file='pvtcolors.dat'
return
END
'Info.Scan Records...': BEGIN
v = state.v
v->read,dim=dim,cpt=cpt, $
da1d=da1d,pa1d=pa1d,da2d=da2d,pa2d=pa2d, $
da3d=da3d,pa3d=pa3d,pv=pv, $
x=xa,y=ya,im=im,labels=labels,id_def=id_def
for i=1,dim do begin
rank=i-1
scansee_getLabels,labels,id_def,rank=rank,label_state
descs = strtrim(label_state.d_name,2) + ' ' + $
strtrim(label_state.d_desc,2) + ' ' + $
strtrim(label_state.d_unit,2)
legend = state.detname + ': '+ descs
xdisplayfile,text=legend,Group=Event.top,title='Di Info for : '+pv(rank)+ ' (Scan # '+ strtrim(state.fileno,2) +')'
end
END
ENDCASE
END
PRO scanSee_PDMENU2D_PanImage_Event,state,Event
v = state.v
CASE Event.Value OF
'PanImage.Options...': begin
v->panImage,/sel
end
'PanImage.Default': begin
v->panImage
end
ENDCASE
END
PRO scanSee_PDMENU3D_PanImage_Event,state,Event
v = state.v
slice = state.slice
rank = state.rank
v->read,dim=dim,x=x,y=y,z=z,pv=pv,labels=labels,scanno=scanno, $
pa1d=pa1d,pa2d=pa2d,pa3d=pa3d, id_def=id_def, $
da1d=da1d,da2d=da2d,da3d=da3d
sz = size(da3d)
title = ' Axis:3D_2D PanImage Slice # '+strtrim(slice,2)
st = 'Z_'
if rank eq 0 then st = 'X_'
if rank eq 1 then st = 'Y_'
if rank eq 0 then begin
title='X'+title
xv = y
yv = z
xdescs = pv[1]
ydescs = pv[2]
zdescs = 'S#'+ strtrim(indgen(sz(1))+1,2)
end
if rank eq 1 then begin
title='Y'+title
xv = x
yv = z
xdescs = pv[0]
ydescs = pv[2]
zdescs = 'S#'+ strtrim(indgen(sz(2))+1,2)
end
if rank eq 2 then begin
title='Z'+title
xv = x
yv = y
xdescs = pv[0]
ydescs = pv[1]
zdescs = 'S#'+ strtrim(indgen(sz(3))+1,2)
end
if sz(0) eq 4 then begin
CASE Event.Value OF
'3D PanImage.Calibration...': begin
v->view3d_panImage,slice,rank,image_array
calibration_factor,image_array,state.def,xv=xv,yv=yv, $
classname=state.class,inpath=state.path, $
title=title,GROUP=Event.top
return
end
'3D PanImage.PanImages+TIFF': begin
DC_viewOutputFilename,state,'.pan.','TIFF',filename
v->view3d_panImage,slice,rank,image_array,tiff=filename,/reverse
end
'3D PanImage.PanImages+PICT': begin
DC_viewOutputFilename,state,'.pan.','PICT',filename
v->view3d_panImage,slice,rank,image_array,pict=filename
end
'3D PanImage.PanImages+XDR': begin
DC_viewOutputFilename,state,'.pan.','XDR',filename
v->view3d_panImage,slice,rank,image_array,xdr=filename
end
'3D PanImage.Image2d...': begin
DC_viewOutputFilename,state,'.pan.','TIFF',filename
v->view3d_panImage,slice,rank,image_array,tiff=filename ;,/sel
end
ENDCASE
s = size(image_array)
print,id_def
scansee_getLabels,labels,id_def,rank=0,label_state,def=def
zdescs = label_state.d_desc(0:s(3)-1)
dname = '3D Array Slice : '+st+strtrim(slice,2) + ' (Scan #'+strtrim(scanno,2)+')'
endif else begin
; big 3D array case use image2d
dname = '3D Array : '+ state.detname(state.detno-1) + ' (Scan #'+strtrim(scanno,2)+') ' + st+'slices'
xr = [min(xv),max(xv)]
if xr(1) eq xr(0) then xv = indgen(n_elements(xv))
if rank eq 0 then begin
image_array = make_array(sz(2),sz(3),sz(1))
for i=0,sz(1)-1 do begin
data = reform(da3d(i,*,*),sz(2),sz(3))
image_array(*,*,i) = data(*,*)
end
end
if rank eq 1 then begin
image_array = make_array(sz(1),sz(3),sz(2))
for i=0,sz(2)-1 do begin
data = reform(da3d(*,i,*),sz(1),sz(3))
image_array(*,*,i) = data(*,*)
end
end
if rank eq 2 then begin
image_array = make_array(sz(1),sz(2),sz(3))
for i=0,sz(3)-1 do begin
data = reform(da3d(*,*,i),sz(1),sz(2))
image_array(*,*,i) = data(*,*)
end
end
end
image2d,image_array,xv,yv,title=dname,scanno=scanno,xdescs=xdescs,ydescs=ydescs,zdescs=zdescs,/seqnm
END
PRO SS_VIEWSPEC_Event, Event
WIDGET_CONTROL,Event.top,GET_UVALUE=state
v = state.v
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
CASE Ev OF
'VIEWSPEC_FILE_OPEN': BEGIN
F = dialog_pickfile(filter='*.mda*',GET_PATH=p,GROUP=Event.Top,/MUST_EXIST,$
PATH=state.path,TITLE='Select scanSee File',/READ)
if F eq '' then return
state.path = p
state.filename = F
if state.bypass3d then $
nv = obj_new('scanSee',file=F,pickDet=-1) else $
nv = obj_new('scanSee',file=F)
if obj_valid(nv) eq 0 then return
if obj_valid(v) then v->delete
state.v = nv
WIDGET_CONTROL,state.filenameWID,SET_VALUE=F
DC_view_init,F,state
WIDGET_CONTROL,state.filenoWID,SET_VALUE=state.fileno
WIDGET_CONTROL, state.basefileWID,SENSITIVE=1
END
'VIEWSPEC_HELP': BEGIN
str = [ $
'This program can display and extract scan data for 1D/2D/3D scan file.','', $
'The file name is automatically created by the scan saveData file', $
'system. The "scanSee.config" file is used for re-start configuration.',$
'At the normal completion of scanBrowser this configuration file is updated.',$
'', $
'File... - uses the file selection dialog picking the initial file',$
'Color - Color pull down menu', $
' Color... - call the xloadct routine', $
' Restore Pvt... - restore color table from the pvtcolors.dat', $
' Save Pvt... - save color table to the pvtcolors.dat file', $
'Info - Scan record info pull down menu', $
' Scan Records... - Pi & Di info in scan records', $
'Help... - show this help page', $
'DONE - close the scanBrowser program',$
'',' WORKED ON FILENAME',$
'File Seq #: - enters the desired scan number saved by IOC', $
'First - opens the first scan file', $
'Next - opens the next scan file', $
'Prev - opens the prev scan file', $
'Last - opens the last scan file', $
'Slider - picks the desired scan file number', $
'Filename - reflects the name of the opened scan file ', $
'',' WORKED ON 1D/2D SCAN DATA',$
'Format - specifies the column format used in ASCII reports', $
'PLOT1D... - calls plot1d to access all detectors of a scan line #', $
'vs P1 - plots versus the selected positioner #', $
'ASCII1D... - generates 1D ASCII report for single/multiple 1D line #',$
'Ez_fit... - runs ez_fit for the selected detector # and 1D line # ',$
'Statistic...- calculates FWHM for selected detector # and 1D line # ',$
'Run Calibra... - run calibration program for all detectors ', $
'',' WORKED ON 3D SCAN DATA ONLY',$
'3D_Slicer...- runs view3d_2d program to get 2D slice from the 3D data', $
'3D PanImage - panImage for 3D scan with option of save as TIFF/GIFF/PICT', $
'X/Y/Z GBTN - pick the 3D panImage view axis of the 2D slice plane', $
'Index # - pick the 3D panImage slice # of the picked axis', $
'',' VALID ON 2D/3D SCAN DATA',$
'Detector # List - selects the detector number, defaults to 16', $
'Bypass 3D Array - Yes/NO, default to Yes, no 3D data array returned', $
' No, large 3D data array will be returned for the ', $
' selected detector #', $
'',' WORKED ON 2D SCAN DATA ONLY',$
'PLOT2D... - access various plot2d features of 2D image', $
'ASCII2D... - saves and displays the ASCII report of 2D image', $
'PanImage... - panImage with option of save TIFF/XDR/PICT file', $
'Images 2D... - access with image2D processing program', $
'2D_1D Data... - access the outer most 1D scan data', $
; 'Overlay Plot... - overlays plot of multiple 1D scan lines ',$
; 'Help 1D Line #...- hints on selecting multiple lines of a detector', $
; ' defaults to line 1 ', $
; '1D Line # List - multiple slections of 2D line list' $
'Pick1D... - picks columns or rows from a widget table' $
]
xdisplayfile,text=str,title='Help on scanBrowser'
return
END
'VIEWSPEC_CANCEL': BEGIN
DC_view_writeConfig,state
DC_view_cleanup,state
WIDGET_CONTROL,event.top,/DESTROY
exit
END
'VIEWSPEC_FILE_SEQNO': BEGIN
WIDGET_CONTROL,event.ID,GET_VALUE=n
seqno = n
state.fileno = seqno
if state.dim eq 3 then begin
if state.bypass3d then $
v->next,seqno,filename,error=er,pickDet=-1 else $
if state.toobig then $
v->next,seqno,filename,error=er,pickDet=state.detno $
else v->next,seqno,filename,error=er
endif else begin
v->next,seqno,filename,error=er
end
if er eq 0 then begin
state.v = v
DC_view_init,filename,state
WIDGET_CONTROL,state.filenameWID,SET_VALUE=filename
end
END
'VIEWSPEC_SLIDER': BEGIN
WIDGET_CONTROL,event.id,GET_VALUE=seqno
state.fileno = seqno
WIDGET_CONTROL,state.filenoWID,SET_VALUE=seqno
if state.dim eq 3 then begin
if state.bypass3d then $
v->next,seqno,filename,error=er,pickDet=-1 else $
if state.toobig then $
v->next,seqno,filename,error=er,pickDet=state.detno $
else v->next,seqno,filename,error=er
endif else begin
v->next,seqno,filename,error=er
end
state.v = v
if er eq 0 then begin
DC_view_init,filename,state
WIDGET_CONTROL,state.filenameWID,SET_VALUE=filename
end
END
'VIEWSPEC_FIRST_FILE': BEGIN
seqno = 0
state.fileno = seqno
if state.dim eq 3 then begin
if state.bypass3d then $
v->first,seqno,filename,pickDet=-1 else $
if state.toobig then $
v->first,seqno,filename,pickDet=state.detno $
else v->first,seqno,filename
endif else begin
v->first,seqno,filename
end
state.v = v
DC_view_init,filename,state
WIDGET_CONTROL,state.filenoWID,SET_VALUE=seqno
WIDGET_CONTROL,state.filenameWID,SET_VALUE=filename
END
'VIEWSPEC_NEXT_FILE': BEGIN
seqno = state.fileno+1
state.fileno = seqno
WIDGET_CONTROL,state.filenoWID,SET_VALUE=seqno
if state.dim eq 3 then begin
if state.bypass3d then $
v->next,seqno,filename,error=er,pickDet=-1 else $
if state.toobig then $
v->next,seqno,filename,error=er,pickDet=state.detno $
else v->next,seqno,filename,error=er
endif else begin
v->next,seqno,filename,error=er
end
state.v = v
if er eq 0 then begin
DC_view_init,filename,state
WIDGET_CONTROL,state.filenameWID,SET_VALUE=filename
end
END
'VIEWSCAN_PREV_FILE': BEGIN
seqno = state.fileno-1
state.fileno = seqno
WIDGET_CONTROL,state.filenoWID,SET_VALUE=seqno
if state.dim eq 3 then begin
if state.bypass3d then $
v->prev,seqno,filename,error=er,pickDet=-1 else $
if state.toobig then $
v->prev,seqno,filename,error=er,pickDet=state.detno $
else v->prev,seqno,filename,error=er
endif else begin
v->prev,seqno,filename,error=er
end
state.v = v
if er eq 0 then begin
DC_view_init,filename,state
WIDGET_CONTROL,state.filenameWID,SET_VALUE=filename
end
END
'VIEWSPEC_LAST_FILE': BEGIN
if state.dim eq 3 then begin
if state.bypass3d then $
v->last,seqno,filename,pickDet=-1 else $
if state.toobig then $
v->last,seqno,filename,pickDet=state.detno $
else v->last,seqno,filename
endif else begin
v->last,seqno,filename
end
state.lastno = seqno
state.v = v
state.fileno = seqno
WIDGET_CONTROL,state.filenoWID,SET_VALUE=seqno
DC_view_init,filename,state
WIDGET_CONTROL,state.filenameWID,SET_VALUE=filename
WIDGET_CONTROL,state.sliderWID,SET_SLIDER_MAX=seqno,bad_id=bad
WIDGET_CONTROL,state.sliderWID,SET_VALUE=seqno,bad_id=bad
END
'VIEWSPEC_LINE_SEQNO': BEGIN
WIDGET_CONTROL,event.ID,GET_VALUE=n
if n(0) lt 1 or n(0) gt state.maxno then begin
str = ['Invalid 1D Line seq # entered', $
'Valid range: [1-'+strtrim(state.maxno,2)+']', $
'Reset to 1']
ret=dialog_message(str,/Info)
n = 1
WIDGET_CONTROL,event.ID,SET_VALUE=n
end
state.lineno = n(0)
END
'VIEWSPEC_PLOT1D': BEGIN
if state.dim eq 1 then $
v->plot1d,state.lineno,/data,group=Event.top
return
END
'VIEWSPEC_PICKXAXIS': BEGIN
if state.dim eq 1 then $
v->plot1d,state.lineno,group=Event.top,xsel=Event.Index ;.xaxis
state.paxis = Event.Index
END
'VIEWSPEC_BYPASS3D': BEGIN
state.bypass3d = Event.Index
if state.bypass3d eq 1 then begin
widget_control,state.list2DWID,sensitive=0
widget_control,state.base3dWID2,sensitive=0
endif else begin
widget_control,state.list2DWID,sensitive=1
widget_control,state.base3dWID2,sensitive=1
end
if state.filename ne '' and state.bypass3d eq 0 then begin
F = state.filename
v = state.v
nv = obj_new('scanSee',file=F)
if obj_valid(nv) then begin
if obj_valid(v) then v->delete
state.v = nv
DC_view_init,F,state
end
end
END
'VIEWSPEC_STATISTIC': BEGIN
title = '1D Line # '+strtrim(state.lineno,2) + $
', Detector D'+strtrim(state.detno,2)
v->statistic,detector=state.detno,row=state.lineno,group=Event.top,$
Title=title,report='statistic.rpt'
return
END
'VIEWSPEC_EZFIT': BEGIN
v->ezfit,row=state.lineno,detno=state.detno
return
v->read,view=state.detno,dim=dim,cpt=cpt, $
da1d=da1d,pa1d=pa1d,da2d=da2d,pa2d=pa2d, $
x=xa,y=ya,im=im,labels=labels,id_def=id_def
if dim eq 2 then begin
ez_fit,xarray=xa,yarray=ya,im=im,group=Event.top,inpath=state.path, $
ipick=state.lineno-1
end
if dim eq 1 then begin
xa = pa1d(*,0)
def = id_def(*,0)
def = def(4:n_elements(def)-1)
nd = fix(total(def)+.1)
ya = make_array(cpt(0),nd)
id =0
for i=0,nd-1 do begin
if def(i) gt 0 then begin
ya(*,id) = da1d(*,i)
id = id + 1
end
end
ez_fit,xarray=xa,yarray=ya,group=Event.top,inpath=state.path, $
jpick=state.detno
end
END
'VIEWSPEC_ASCII1D': BEGIN
if state.dim eq 1 then $
v->ascii1d,state.lineno,format=state.format,group=Event.top
END
'VIEWSPEC_VIEW3D_VW2D': BEGIN
v->read,view=state.detno,dim=dim,cpt=cpt,num_pts=num_pts, $
da1d=da1d,pa1d=pa1d,da2d=da2d,pa2d=pa2d, $
da3d=da3d,pa3d=pa3d,pv=pv, outpath=outpath,$
x=xa,y=ya,im=im,labels=labels,id_def=id_def
x = pa2d(*,0)
y = pa1d(0:cpt(2)-1,0)
sz = size(da2d)
scansee_getLabels,labels,id_def,rank=2,label_state,def=def
ydescs = label_state.p_desc
scansee_getLabels,labels,id_def,rank=1,label_state,def=def
xdescs = label_state.p_desc
zdescs = label_state.d_desc(0:sz(3)-1)
def = id_def(4:4+sz(3)-1,1)
if total(def) gt 0. then begin
image2d,da2d,x,y,GROUP=Event.top,title=state.filename,pv=pv(1:2), $
outpath=outpath,id_def=def,scanno=state.fileno, $
xdescs=xdescs,ydescs=ydescs,zdescs=zdescs
endif else begin
r = dialog_message(/error,'No image found!!',title='image2d_message')
end
END
'VIEWSPEC_VIEW3D_2D': BEGIN
v->view3d_2d,state.detno,group=Event.top
END
'VIEWSPEC_STARTNO': BEGIN
WIDGET_CONTROL,Event.ID,GET_VALUE=no
state.lineno = no
END
'VIEWSPEC_ENDNO': BEGIN
WIDGET_CONTROL,Event.ID,GET_VALUE=no
state.endno = no
END
'VIEWSPEC_ASCII2D': BEGIN
v->ascii2d,state.detno,format=state.format,group=Event.top
END
'VIEWSPEC_PLOT2D': BEGIN
v->view2d,state.detno,/plot,group=Event.top
END
'VIEWSPEC_FORMAT': BEGIN
WIDGET_CONTROL,event.ID,GET_VALUE=fm
state.format = fm(0)
END
'VIEWSPEC_HELPMULTI': BEGIN
str = [ 'Multiple Selection:', $
'Select 1D scan # for Overlay plot from 2D image ', $
'Click any item from scroll list selecting the line scan', $
'Click while hold down CNTL adding the item to the list', $
'Click while hold down SHIFT adding the items between last two clicks', $
'Press Overlay Plot... button plot the selected lines']
res = dialog_message(str,/info,title='Help on Multiple Selection')
return
END
'VIEWSPEC_OVERLAY': BEGIN
v->read,view=state.detno,dim=dim,cpt=cpt, $
x=x,y=y,im=im,labels=labels,id_def=id_def
res = state.list_sel(0:state.sel_no-1)
ndim = n_elements(res)
sz = size(im)
newy = make_array(sz(1),ndim)
for i=0,n_elements(res)-1 do begin
newy(*,i) = im(*,res(i))
if i eq 0 then legend = strtrim(res(i)+1,2) else $
legend = [legend,strtrim(res(i)+1,2)]
end
title = 'Detector '+state.detname(state.detno-1) + ' Overlay Plot'
xtitle=labels(0)
ytitle=labels(4,0)
wtitle = '1D Overlay Plot'
comment=['','File: '+state.filename]
plot1d,x,newy,xtitle=xtitle,ytitle=ytitle,wtitle=wtitle, $
legend=legend, /data, $
title=title,comment=comment,group=Event.top
END
'VIEWSPEC_1DSELECT': BEGIN
res = widget_info(Event.ID,/LIST_SELECT)
state.lineno = res(0) + 1
if n_elements(res) gt 1 then begin
state.sel_no = n_elements(res)
state.list_sel = res(0:state.sel_no-1)
end
END
'VIEWSPEC_2DSELECT': BEGIN