-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan2d_overlay.pro
1858 lines (1619 loc) · 51.8 KB
/
scan2d_overlay.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.
;*************************************************************************
; supoort scan2d, scanSee and any image_array > 15 detectors
; overlay.tbl - default save file for overlay color table
; overlay_pvt.tbl - private save file for overlay color table
@PS_open.pro
PRO scan2d::Overlay,scanno,row=row,col=col,pixels=pixels,selects=selects,discrete=discrete
;
;+
; NAME:
; scan2d::Overlay
;
; PURPOSE:
; Using an overlay composite image reveals information about the
; superposition of the images of selected detectors. It provides
; another way of data interpretation of catcher generated images.
;
; This method constructs a composite image based on user selected
; detectors for a given 2D scanno. The composite image is composed
; of the basic composite element area. Each composite element area
; consists of ColxRow of small squares. Each colored filled small
; square area represents a data point from the selected image (or
; detector). So each composite area is composed of one data point
; from each selected detectors and they are arranged in row order.
;
; The resultant composite image with width of ColxWidth,
; and height of RowxHeight squares. (each Detector dimension is
; Width x Height)
;
; In the basic element area all selected detectors are filled in row
; order until the area is full then it re-starts from the first row
; again, i.e. if more detectors than the available squares are
; available then the overlay of colored squares may be resulted.
;
; Default 2x2 squares are used for basic element area which can hold
; 4 detects without overlapping. Each square has width of 2 pixels.
;
; Each detector has a fixed color table associated with it, it is linearly
; divided into 16 levels. The detector value is linearly interpreted
; by 16 levels (see restriction).
;
; CATEGORY:
; Widgets.
;
; CALLING SEQUENCE:
; Obj->[scan2d::]Overlay [,Scanno] [,Row=row] [,Col=col] [,Pixels=pixels]
; [,Selects=selects] [,Discrete=discrete]
;
; ARGUMENTS:
; Scanno: Optional, specifies the corresponding 2D scan seq #, normally
; it is internally determined by the [scan2d::View] method.
;
; KEYWORDS:
; Col: Specifies the number of squares in the composite area , default 2
; Row: Specifies the number of squares in the composite area , default 2
; Pixels: Specifies the number of pixels used for each square, default 2
; Selects: Specifies the list of selected detectors, default 1,2
; Discrete: Plots selected detecor image seperately with info of min and max
;
; RESTRICTION:
; The postscript "Print" button read the TV sceen and generate the PS output.
; The PS output only good for the screen size within 750x750 pixels.
;
; The image array size may varies from the scan to scan. In order to
; make sure this method works properly, the scan2d::View method has to be
; called first to establish the proper image array size for the desired
; 2D scanno.
;
; 16 colors are used and they are shaded with gray
;
; Detector 1 Red
; Detector 2 Green
; Detector 3 Blue
; Detector 4 Yellow
; Detector 5 Cyne
; Detector 6 Magenta
; Detector 7 Gray
; Detector 8 Orange
; Detector 9 Light Green
; Detector 10 Purple
; Detector 11 Gold
; Detector 12 Light Orange
; Detector 13 Light Cyne
; Detector 14 Light purple
; Detector 15 Dark Gray
; Detector 16 Dark Yellow
;
; The 'Color ...' button let user access various color tables comes with IDL.
; The 'myColr' button let user switch back to overlay image color table.
;
; EXAMPLES:
; The 2D image file is '/home/oxygen/LEGNINI/data/root/plla.june97.image'
; The scanno 29 consists of 10 detectors, with 2D image # 202 to 211.
;
; Example 1 - Use the default overlay of detectors 1 and 2 image for
; scanno 29 from this file. The panImage method shows all detectors
; images for the 2D scan.
;
; The object v2 need to be defined only if it is not yet defined.
;
; filename='/home/oxygen/LEGNINI/data/root/plla.june97.image'
; v2 = obj_new('scan2d',file=filename)
; v2->view,202
; v2->panimage
; v2->overlay
;
; Example 2 - Use 2x2 composite area with 4 detectors selected, number
; of pixels used for each square is 8.
;
; v2->overlay,row=2,col=2,pixels=8,selects=[1,8,9,10]
;
; Toggle the 'Default' and 'Color ...' buttons from the Overlay window
; to access various color map.
;
; Example 3 - Plot detector 9's discrete image (pixel scaled by 4)
;
; v2->overlay,pixels=4,selects=9,/discrete
;
; Example 3 - Plot discrete images of detectors 8,9,10 (pixel scaled by 4)
;
; v2->overlay,pixels=4,selects=[8,9,10],/discrete
;
; MODIFICATION HISTORY:
; Written by: Ben-chin Cha, Jan 19, 1998.
; 01-08-02 Add Print, Printer... button
; Add slider control on Color Table used
; Default Color will set Bg slider to bg=128, Fg ratio=8
;-
; pixels - no of pixels used for each data point, default 2
; detectors overlay matrix (col x row)
; col - no of detectors in col used for overlay, default 2
; row - no of detectors in row used for overlay, default 2
; selects - list of selected detectors, default to first two detectors:[0,1]
; discrete - if defined each detector has its own image,
; Color table is devided into 15 color schemes.
;
unit = self.opened
seq = self.scanno_current
if n_elements(scanno) then seq = scanno
xdim = self.width
ydim = self.y_req_npts
last = self.scanno_2d_last
if unit le 0 then begin
res=WIDGET_MESSAGE('Error: no image file loaded in')
return
end
if seq lt 1 or seq gt self.scanno_2d_last then begin
res=WIDGET_MESSAGE('Error: outside range 2D scanno entered')
return
end
seqno = self.image_no(seq-1)
point_lun, unit, self.fptr(seqno)
image_array = make_array(xdim,ydim,15,/float)
def = make_array(15,value=0)
vmin = make_array(15,/float)
vmax = make_array(15,/float)
scanno_2d = seq
for i=0,14 do begin
if EOF(unit) eq 1 then goto,update
u_read, unit, pvs
u_read, unit, nos
if nos(4) ne seq then goto,update
u_read, unit, x
u_read, unit, y
u_read, unit, t_image
def(nos(3)) = 1
image_array(*,*,nos(3)) = t_image
rmax = max(t_image,min=rmin)
vmax(nos(3)) = rmax
vmin(nos(3)) = rmin
end
update:
overlayInitState,overlay_state,image_array,def,vmax,vmin,col=col,row=row,pixels=pixels,selects=selects,discrete=discrete
; panImage,image_array,def,detnm=overlay_state.dname
SCAN2D_OVERLAYIMAGE,overlay_state
END
PRO box,x0,y0,x1,y1,color
polyfill,[x0,x0,x1,x1], [y0,y1,y1,y0],col=color,/device
END
PRO scan2d_setOverlayColorTbl,base,rat
r = make_array(256,/int)
g = make_array(256,/int)
b = make_array(256,/int)
if n_elements(base) eq 0 then $
base = 128; base color: 0 is black, 128 dark gray
if n_elements(rat) eq 0 then $
rat = 8 ; for black use 16, for dark gray use 8
for j=0,15 do begin
ij = j*16
CASE j OF
15:BEGIN ; red
for i=1,16 do begin
r(i-1+ij) = i*rat-1
g(i-1+ij) = 0
b(i-1+ij) = 0
end
END
14:BEGIN ; green
for i=1,16 do begin
r(i-1+ij) = 0
g(i-1+ij) = i*rat-1
b(i-1+ij) = 0
end
END
13:BEGIN ; blue
for i=1,16 do begin
r(i-1+ij) = 0
g(i-1+ij) = 0
b(i-1+ij) = i*rat-1
end
END
12:BEGIN ; yellow
for i=1,16 do begin
r(i-1+ij) = i*rat-1
g(i-1+ij) = i*rat-1
b(i-1+ij) = 0
end
END
11:BEGIN ; cyan
for i=1,16 do begin
r(i-1+ij) = 0
b(i-1+ij) = i*rat-1
g(i-1+ij) = i*rat-1
end
END
10:BEGIN ; magenta
for i=1,16 do begin
r(i-1+ij) = i*rat-1
g(i-1+ij) = 0
b(i-1+ij) = i*rat-1
end
END
9:BEGIN ; gray
for i=1,16 do begin
r(i-1+ij) = i*rat-1
g(i-1+ij) = i*rat-1
b(i-1+ij) = i*rat-1
end
END
8:BEGIN ; orange
for i=1,16 do begin
r(i-1+ij) = i*rat-1
g(i-1+ij) = i*rat/2-1
b(i-1+ij) = 0
end
END
7:BEGIN ; light green
for i=1,16 do begin
r(i-1+ij) = i*rat/2-1
g(i-1+ij) = i*rat-1
b(i-1+ij) = i*rat/2-1
end
END
6:BEGIN ; purple
for i=1,16 do begin
r(i-1+ij) = i*rat/2-1
g(i-1+ij) = 0
b(i-1+ij) = i*rat-1
end
END
5:BEGIN ; gold
for i=1,16 do begin
r(i-1+ij) = i*rat-1
g(i-1+ij) = i*rat-1
b(i-1+ij) = i*rat/2-1
end
END
4:BEGIN ; light orange
for i=1,16 do begin
r(i-1+ij) = i*rat-1
g(i-1+ij) = i*rat/2-1
b(i-1+ij) = i*rat/2-1
end
END
3:BEGIN ; light cyne
for i=1,16 do begin
r(i-1+ij) = i*rat/2-1
g(i-1+ij) = i*rat-1
b(i-1+ij) = i*rat-1
end
END
2:BEGIN ; light purple
for i=1,16 do begin
r(i-1+ij) = i*rat/2-1
g(i-1+ij) = i*rat/2-1
b(i-1+ij) = i*rat-1
end
END
1:BEGIN ; dark gray
for i=1,16 do begin
r(i-1+ij) = i*rat/2-1
g(i-1+ij) = i*rat/2-1
b(i-1+ij) = i*rat/2-1
end
END
0:BEGIN ; dark yellow
for i=1,16 do begin
r(i-1+ij) = i*rat/2-1
g(i-1+ij) = i*rat/2-1
b(i-1+ij) = 0
end
END
ELSE:
ENDCASE
end
tvlct,r+base,g+base,b+base
; xpalette
scan2d_saveOverlayColorTbl
END
PRO scan2d_saveOverlayColorTbl
tvlct,red,green,blue,/get
save,red,green,blue,file='overlay.tbl'
END
PRO scan2d_getOverlayColorTbl
catch,error_status
if error_status ne 0 then return
restore,'overlay.tbl'
tvlct,red,green,blue
END
PRO scan2d_overlay_help,Event
str = [" Help on Overlay 2D Image",'', $
'Pane Images : Show discrete images ', $
'List of names: Show name of images selected', $
'Plot Type : Overlay / Discrete / Composite', $
'XDR : Save the composite as XDR data', $
'Contrast : On or Off', $
'List of DIs : List of initially picked images', $
'Image seq # : Enter images sequence numbers seperated by comma', $
'Pixel : Number of pixels used for each value point, default 2', $
'Column : Columns used in overlay/splice selected image, default 2', $
'Row : Rows used in overlay/splice selected image, default 2', $
'Image Area : Drawing area for displaying overlaid/discrete images', $
'Color Control:',$
' "Bg " - Control the Background Color level ', $
' "Fg " - Control the number of Foreground Color number', $
' "Default" - Set Bg to 128, and Fg to 8', $
'Save PvtColorT : Save current color table in overlay.tbl', $
'Load PvtColorT : Load in the private overlay color table ', $
'Color ... : Access of default IDL color tables, default pepermint', $
'Print : Dump the Image area to PS printer', $
'Printer... : Override the default PS printer', $
'Help... : Display this help page', $
'Done : Exit 2D overlay program' $
]
xdisplayfile,text=str,GROUP=Event.top
END
PRO SCAN2D_OVERLAY_Event, Event
WIDGET_CONTROL,Event.Top,GET_UVALUE=overlay_state
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
CASE Ev OF
'scan2d_overlay': BEGIN
Print, 'Event for scan2d_overlay'
END
'BUTTON6': BEGIN
WIDGET_CONTROL,Event.Top,/DESTROY
return
END
'BUTTON7': BEGIN
; loadct,31 ;pepermint waves=37
XLOADCT
overlayImage,overlay_state
WIDGET_CONTROL,overlay_state.tyWID,SET_VALUE=overlay_state.discrete
END
'OVERLAY_SAVE_PVTCT': BEGIN
tvlct,R,G,B,/get
save,R,G,B,file='overlay_pvt.tbl'
END
'OVERLAY_LOAD_PVTCT': BEGIN
catch,error_status
if error_status eq 0 then begin
restore,'overlay_pvt.tbl'
tvlct,R,G,B
end
overlayImage,overlay_state
END
'BUTTON8': BEGIN
widget_control,overlay_state.bg_sdr,SET_VALUE=128,bad=bad
if bad then return
widget_control,overlay_state.ratio_sdr,SET_VALUE=8
scan2d_setOverlayColorTbl,128,8
SCAN2D_GETOVERLAYCOLORTBL
overlayImage,overlay_state
END
'BUTTON9': BEGIN
PS_TVRD,file='ovl.ps',wid=overlay_state.win,scale=2
END
'BUTTON10': BEGIN
PS_printer
END
'BUTTON11': BEGIN
scan2d_overlay_help,Event
END
'OVERLAY_NX': BEGIN
WIDGET_CONTROL,Event.ID,GET_VALUE=ncol
if ncol le 0 then begin
widget_control,Event.ID,set_value=1
ncol = 1
end
overlay_state.ncol = ncol
overlayImage_draw2,overlay_state
END
'OVERLAY_NY': BEGIN
WIDGET_CONTROL,Event.ID,GET_VALUE=nrow
if nrow le 0 then begin
widget_control,Event.ID,set_value=1
nrow = 1
end
overlay_state.nrow = nrow
overlayImage_draw2,overlay_state
END
'OVERLAY_SELECTS': BEGIN
WIDGET_CONTROL,Event.ID,GET_VALUE=detectors
selects = str_sep(detectors(0),',')
selects = fix(selects) - 1
if max(selects) ge 15 then begin
res=dialog_message('Image # value can not exceed 15',/Error)
return
end
pick = make_array(15,/int)
if n_elements(selects) gt 0 then begin
for i=0,n_elements(selects)-1 do begin
if selects(i) ge 0 then pick(selects(i)) = 1
end
end
; old_string = overlay_state.pick_string
pick_string=strcompress(detectors(0),/remove_all)
overlay_state.pick_string = pick_string
overlay_state.pick = pick
overlay_state.selects = fix(total(pick))
pick = where(overlay_state.pick gt 0)
str ='SELECTED: '
for i=0,N_ELEMENTS(pick)-1 do begin
str = str + overlay_state.dname(pick(i))
if (i+1) lt N_ELEMENTS(pick) then str=str+','
end
WIDGET_CONTROL,overlay_state.labelWID,SET_VALUE=str
overlayImage_draw2,overlay_state
END
'OVERLAYTABLE_BG': BEGIN
WIDGET_CONTROL,Event.ID,GET_VALUE=bg
overlay_state.tbl_bg = bg
scan2d_setOverlayColorTbl,overlay_state.tbl_bg,overlay_state.tbl_ratio
overlayImage,overlay_state
END
'OVERLAYTABLE_RATIO': BEGIN
WIDGET_CONTROL,Event.ID,GET_VALUE=v
overlay_state.tbl_ratio = v
scan2d_setOverlayColorTbl,overlay_state.tbl_bg,overlay_state.tbl_ratio
overlayImage,overlay_state
END
'OVERLAY_PIXELS': BEGIN
WIDGET_CONTROL,Event.ID,GET_VALUE=pixels
if pixels le 0 then begin
widget_control,Event.ID,set_value=1
pixels = 1
end
overlay_state.pixels = pixels
overlayImage_draw2,overlay_state
END
'OVERLAY_XDR': BEGIN
overlay_state.xdr = Event.Value
END
'OVERLAY_TYPE': BEGIN
overlay_state.discrete = Event.Value
overlayImage_draw1,overlay_state
overlayImage_draw2,overlay_state
END
'OVERLAY_SHOWMINPT': BEGIN
overlay_state.minpt = Event.Value
overlayImage_draw2,overlay_state
END
ENDCASE
WIDGET_CONTROL,Event.Top,SET_UVALUE=overlay_state
END
PRO overlayInitState,overlay_state,image_array,def,vmax,vmin,col=col,row=row,pixels=pixels,selects=selects,discrete=discrete,fdname=fdname
s = size(image_array)
xdim=s(1)
ydim=s(2)
vcol = make_array(15,/int)
dcol = 16
found = findfile('overlay.tbl')
if found(0) eq '' then SCAN2D_SETOVERLAYCOLORTBL,128,8
SCAN2D_GETOVERLAYCOLORTBL
for i=0,14 do begin
vcol(i) = 256 - i * dcol -1
end
magnifyfactor = 2
if keyword_set(pixels) then magnifyfactor=pixels
nrow=2
ncol=2
if keyword_set(row) then nrow=row
if keyword_set(col) then ncol=col
if keyword_set(discrete) then begin
ncol = 1
nrow = 1
end
if nrow*ncol gt 16 then nrow = 16/ncol+1
pick_string=''
pick = make_array(15,/int)
if n_elements(selects) gt 0 then begin
for i=0,n_elements(selects)-1 do begin
pick(selects(i) - 1) = 1
pick_string=pick_string+strtrim(selects(i),2)+','
end
endif else begin
pick_string='1,2' ;'0,1'
pick(0:1)=1
end
; construct overlay array
overlay_state = { $
base : 0L, $
bg_sdr: 0L, $
ratio_sdr: 0L, $
labelWID : 0L, $
ncolWID : 0L, $
nrowWID : 0L, $
panWID : 0L, $
WID : 0L, $
tyWID: 0L, $
panWin : 0L, $
win : 0L, $
width: magnifyfactor*ncol*xdim +250,$
height: magnifyfactor*nrow*ydim,$
xdr: 0, $
xsize : 400, $
ysize : 600, $
xdim : xdim, $
ydim : ydim, $
def : def, $
images : image_array, $
vmin: vmin, $
vmax: vmax, $
ncol: ncol, $
nrow: nrow, $
minpt: 0, $ ; 0 - show min pt, 1 - not show min, use next color number
pixels: magnifyfactor, $
pick_string: pick_string, $
pick: pick, $
selects : total(pick), $
discrete : 0, $
dcol: dcol, $
vcol: vcol, $
tbl_bg:128, $
tbl_ratio:8, $
dname: ['D1','D2','D3','D4','D5','D6','D7','D8','D9','DA','DB','DC','DD','DE','DF'] $
}
if keyword_set(discrete) then begin
overlay_state.discrete=discrete ;1-discrete 2-composite
; overlay_state.height=magnifyfactor*ydim*10 ; overlay_state.selects
end
if keyword_set(fdname) then begin
overlay_state.dname = '???'
for i=0,n_elements(fdname)-1 do begin
overlay_state.dname(i)=fdname(i)
end
end
END
PRO overlayImage,overlay_state
overlayImage_draw1,overlay_state
overlayImage_draw2,overlay_state
END
PRO overlayImage_draw1,overlay_state
xdim = overlay_state.xdim
ydim = overlay_state.ydim
selects = overlay_state.selects
def = overlay_state.def
vmax = overlay_state.vmax
vmin = overlay_state.vmin
image_array = overlay_state.images
ncol = overlay_state.ncol
nrow = overlay_state.nrow
magnifyfactor = overlay_state.pixels
vcol = overlay_state.vcol
dcol = overlay_state.dcol
pick = overlay_state.pick
discrete = overlay_state.discrete
minpt= overlay_state.minpt
if !d.name eq 'X' then WSET,overlay_state.panWin
erase
for k=0,14 do begin
ki = k mod 8
kj = k / 8
if def(k) eq 1 then begin
if vmax(k) gt vmin(k) then begin
factor = (image_array(*,*,k) - vmin(k))/(vmax(k)-vmin(k))
; kcolor = vcol(k)-dcol*factor + 1
kcolor = vcol(k+1)+ceil(dcol*factor)
if minpt then begin
pt = where(factor lt 0.0001)
kcolor(pt)=kcolor(pt)+1
end
endif else begin
kcolor = make_array(xdim,ydim,value=vcol(k))
end
x0 = ki * 61
y0 = (1-kj) * 61
tv,congrid(kcolor,61,61),x0,y0
end
end
if !d.name eq 'X' then WSET,overlay_state.win
END
PRO overlayImage_draw2,overlay_state
widget_control,/hourglass
xdim = overlay_state.xdim
ydim = overlay_state.ydim
selects = overlay_state.selects
def = overlay_state.def
vmax = overlay_state.vmax
vmin = overlay_state.vmin
image_array = overlay_state.images
ncol = overlay_state.ncol
nrow = overlay_state.nrow
magnifyfactor = overlay_state.pixels
vcol = overlay_state.vcol
dcol = overlay_state.dcol
pick = overlay_state.pick
discrete = overlay_state.discrete
minpt= overlay_state.minpt
; reset ncol for overlay mode
if discrete eq 0 and ncol le 1 then begin
overlay_state.ncol=2
overlay_state.nrow=2
widget_control,overlay_state.ncolWID,set_value=2
widget_control,overlay_state.nrowWID,set_value=2
ncol = 2
nrow = 2
end
; resize the drawing area
CASE discrete OF
0: begin
wd = overlay_state.ncol * overlay_state.xdim *overlay_state.pixels
ht = overlay_state.nrow * overlay_state.ydim *overlay_state.pixels
end
1: begin
wd = overlay_state.pixels*overlay_state.ncol*overlay_state.xdim+250
ht = overlay_state.pixels*overlay_state.ydim*overlay_state.selects
end
2: begin
wd = overlay_state.xdim *overlay_state.pixels + 250
ht = overlay_state.ydim *overlay_state.pixels
end
ENDCASE
overlay_state.height = fix(ht+1)
overlay_state.width = fix(wd+1)
WIDGET_CONTROL,overlay_state.WID,draw_xsize=overlay_state.width, $
draw_ysize=overlay_state.height
if discrete lt 2 then $
im = make_array(overlay_state.width,overlay_state.height)
if !d.name eq 'X' then WSET,overlay_state.win
erase
if discrete eq 0 then begin
xyouts,5,overlay_state.height-50,charsize=2, $
'GENERATING OVERLAY IMAGE ...',/device
kk=0
for k=0,14 do begin
IF def(k) EQ 1 and pick(k) gt 0 THEN BEGIN
for j=0,ydim-1 do begin
jj = j * nrow
for i=0,xdim-1 do begin
ii = i * ncol
factor = 0. ; 1.
if vmax(k) gt vmin(k) then begin
factor = (float(image_array(i,j,k)) - vmin(k)) / (vmax(k)-vmin(k))
; kcolor = vcol(k) - fix(dcol*(1 - factor))
kcolor = vcol(k+1)+ceil(dcol*factor)
if minpt then begin
if factor le 0. then kcolor = vcol(k+1)+1
end
endif else begin
kcolor = vcol(k)
end
ki = kk mod ncol
kj = kk / ncol
x0=(ii+ki)*magnifyfactor
x1=(ii+ki+1)*magnifyfactor
y0=(jj+kj)*magnifyfactor
y1=(jj+kj+1)*magnifyfactor
; box,x0,y0,x1,y1,kcolor
catch,error_status
if error_status ne 0 then begin
print,kk,i,j,k,ki,kj,x0,x1,y0,y1,magnifyfactor
help,im
return
end
im(x0:x1-1,y0:y1-1) = kcolor
end
end
kk=kk+1
END
end
tv,im
end
;
; plot discrete selected detectors with color scheme
;
if discrete eq 1 then begin
xyouts,5,overlay_state.height-50,charsize=2, $
'GENERATING DISCRETE IMAGES ...',/device
numj=0
ncol = 1
for k=0,14 do begin
IF pick(k) EQ 1 THEN BEGIN
ki = k mod ncol
kj1 = overlay_state.height - numj*ydim*magnifyfactor
kj0 = kj1 - ydim*magnifyfactor
for i=0,xdim-1 do begin
ii = i * ncol
for j=0,ydim-1 do begin
jj = j
factor = 0
if vmax(k) gt vmin(k) then begin
factor = (image_array(i,j,k) - vmin(k)) / (vmax(k)-vmin(k))
; kcolor = vcol(k) - dcol*factor
kcolor = vcol(k+1)+ceil(dcol*factor)
if minpt then begin
if factor le 0. then kcolor = vcol(k+1)+1
end
endif else begin
kcolor = vcol(k)
end
x0=(ii+ki)*magnifyfactor
x1=(ii+ki+1)*magnifyfactor
y0= kj0+jj*magnifyfactor
y1= y0 + magnifyfactor
; box,x0,y0,x1,y1,kcolor
im(x0:x1-1,y0:y1-1) = kcolor
end
end
numj = numj+1
END
end
tv,im
; write the detector info here min,max,detector
for k=0,14 do begin
if pick(k) gt 0 then begin
kj0 = overlay_state.height - k*ydim*magnifyfactor
str = overlay_state.dname(k) + ', Max='+strtrim(vmax(k),2)
xyouts,x1,kj0-ydim/2*magnifyfactor,str,charsize=1.5,/device
str = ' , Min='+strtrim(vmin(k),2)
xyouts,x1,kj0-15-ydim/2*magnifyfactor,str,charsize=1.5,/device
end
end
end
if discrete eq 2 then begin
t_im = make_array(xdim,ydim)
for k=0,14 do begin
if pick(k) eq 1 then begin
for j=0,ydim-1 do begin
for i=0,xdim-1 do begin
t_im(i,j) = t_im(i,j)+ image_array(i,j,k)
end
end
end
end
col_range = overlay_state.dcol * overlay_state.selects
col_start = overlay_state.vcol(0)
factor = col_range * (max(t_im)-t_im)/(max(t_im)-min(t_im))
factor = col_start - fix(factor)
x1 = xdim*magnifyfactor
y1 = ydim*magnifyfactor
factor = congrid(factor,x1,y1)
tv,factor
str = 'Sum: '+ ', Max='+strtrim(max(t_im),2)
xyouts,x1,y1/2,str,charsize=1.5,/device
str = ' , Min='+strtrim(min(t_im),2)
xyouts,x1,y1/2-15,str,charsize=1.5,/device
; write xdr output
if overlay_state.xdr then begin
xdr_open,unit,'ovl.xdr',/write
xdr_write,unit,t_im
xdr_write,unit,[0,xdim-1,0,ydim-1,min(t_im),max(t_im)]
xdr_close,unit
end
end
END
PRO SCAN2D_OVERLAYIMAGE,overlay_state, GROUP=Group
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
xsize =overlay_state.width
ysize =overlay_state.height
SCAN2D_OVERLAY = WIDGET_BASE(GROUP_LEADER=Group, $
COLUMN=1, TITLE='Overlay 2D Image (R1.0)', $
MAP=1, $
UVALUE='SCAN2D_OVERLAY')
BASE2 = WIDGET_BASE(SCAN2D_OVERLAY, $
COLUMN=1, $
MAP=1, $
UVALUE='BASE2')
DRAW1 = WIDGET_DRAW( BASE2, $
RETAIN=1, $
UVALUE='scan2d_overlay_panimage', $
XSIZE=61*8, $ ;15, $
YSIZE=61*2 ) ;, $
; X_SCROLL_SIZE=400, $
; Y_SCROLL_SIZE=400)
BASE2_2 = WIDGET_BASE(BASE2, $
COLUMN=1, /frame, $
MAP=1, $
UVALUE='BASE2_2')
str =''
for i=0,N_ELEMENTS(overlay_state.dname)-1 do begin
str = str + overlay_state.dname(i)
if (i+1) lt N_ELEMENTS(overlay_state.dname) then str=str+','
end
label2 = WIDGET_LABEL(BASE2_2,VALUE=str)
BASE2_3 = WIDGET_BASE(BASE2_2, $
ROW=1, /frame, $
MAP=1, $
UVALUE='BASE2_3')
BGROUP4 = CW_BGROUP( BASE2_3, ['Overlay','Discrete','Composite'], $
ROW=1, /frame, $
EXCLUSIVE=1, /NO_RELEASE, $
LABEL_LEFT='Type:', $
UVALUE='OVERLAY_TYPE')
WIDGET_CONTROL,BGROUP4,SET_VALUE=overlay_state.discrete
BGROUP43 = CW_BGROUP( BASE2_3, ['No','Yes'], $
ROW=1, /frame, $
EXCLUSIVE=1, /NO_RELEASE, $
LABEL_LEFT='Xdr:', $
UVALUE='OVERLAY_XDR')
WIDGET_CONTROL,BGROUP43,SET_VALUE=overlay_state.xdr
BGROUP44 = CW_BGROUP( BASE2_3, ['On','Off'], $
ROW=1, /frame, $
EXCLUSIVE=1, /NO_RELEASE, $
LABEL_LEFT='Contrast:', $
UVALUE='OVERLAY_SHOWMINPT')
WIDGET_CONTROL,BGROUP44,SET_VALUE=overlay_state.minpt
selects_FIELD3 = CW_FIELD( BASE2_2,VALUE=overlay_state.pick_string, $
ROW=1, $
STRING=1, $
RETURN_EVENTS=1, $
TITLE='Image Seq #', $
UVALUE='OVERLAY_SELECTS', $
XSIZE=50)
pick = where(overlay_state.pick gt 0)
str ='SELECTED: '
for i=0,N_ELEMENTS(pick)-1 do begin
str = str + overlay_state.dname(pick(i))
if (i+1) lt N_ELEMENTS(pick) then str=str+','
end
label3 = WIDGET_LABEL(BASE2_2,VALUE=str,/align_left)
BASE2_1 = WIDGET_BASE(BASE2, $
ROW=1, $
MAP=1, $
UVALUE='BASE2_1')
BASE3 = WIDGET_BASE(BASE2, $
ROW=1, $
MAP=1, $
UVALUE='BASE3')
DRAW3 = WIDGET_DRAW( BASE3, $
RETAIN=1, $
UVALUE='scan2d_overlay', $
XSIZE=xsize, $
X_SCROLL_SIZE=400, $
YSIZE=ysize, $
Y_SCROLL_SIZE=400)
pixels_FIELD2 = CW_FIELD( BASE2_1,VALUE=overlay_state.pixels, $
ROW=1, $
INTEGER=1, $
RETURN_EVENTS=1, $
TITLE='Pixel Sz', $
UVALUE='OVERLAY_PIXELS', $
XSIZE=2)
;if overlay_state.discrete eq 0 then begin
Ncol_FIELD3 = CW_FIELD( BASE2_1,VALUE=overlay_state.ncol, $
ROW=1, $
INTEGER=1, $
RETURN_EVENTS=1, $
TITLE='Col', $
UVALUE='OVERLAY_NX', $
XSIZE=2)
overlay_state.ncolWID = Ncol_FIELD3
Nrow_FIELD4 = CW_FIELD( BASE2_1,VALUE=overlay_state.nrow, $
ROW=1, $
INTEGER=1, $
RETURN_EVENTS=1, $
TITLE='Row', $
UVALUE='OVERLAY_NY', $
XSIZE=2)
overlay_state.nrowWID = Nrow_FIELD4
;end
BASE4 = WIDGET_BASE(BASE2_1, $
ROW=1, /Frame, $
MAP=1, $
UVALUE='BASE4')
label1 = WIDGET_LABEL(BASE4,VALUE='Color Bg:')
mycolor_bg = WIDGET_SLIDER( BASE4, $
MINIMUM=0,MAXIMUM=256,UVALUE='OVERLAYTABLE_BG', $
XSIZE=50,VALUE=overlay_state.tbl_bg,/scroll)