-
Notifications
You must be signed in to change notification settings - Fork 0
/
calibdrv.pro
284 lines (230 loc) · 6.48 KB
/
calibdrv.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
;*************************************************************************
; 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.
;*************************************************************************
@scan1d__define.pro
@scan2d__define.pro
PRO calibdrv_cleanup,info
calib_v2 = info.calib_v2
ret = obj_valid(calib_v2)
if ret then calib_v2->delete
calib_v2=0
; ret = obj_valid()
; print,ret
END
PRO calibdrv_init,info
calibdrv_cleanup,info
if info.dim eq 1 then begin
calib_v2 = obj_new('scan1d')
calib_v2->open,info.filename
calib_v2->scan_read_All,maxno
info.maxno = maxno
info.scanno_last = maxno
end
if info.dim eq 2 then begin
calib_v2 = obj_new('scan2d')
calib_v2->open,info.filename
calib_v2->readAll,maxno,scanno_last
info.maxno = maxno
info.scanno_last = scanno_last
end
WIDGET_CONTROL,info.scanno_id,SET_VALUE=1
WIDGET_CONTROL,info.slider_id,SET_SLIDER_MAX=info.scanno_last
info.scanno = 1
info.calib_v2 = calib_v2
if info.dim eq 2 then $
info.calib_v2->panImage,info.scanno else $
info.calib_v2->plot,info.scanno
END
PRO PDMENU4_Event,info, Event
CASE Event.Value OF
'File.Open...': BEGIN
F = dialog_pickfile(filter='*.image',GET_PATH=p,GROUP=Event.Top,/MUST_EXIST,$
PATH=info.inpath,TITLE='Select Image File',/READ)
if F eq '' then return
info.inpath = p
info.filename = F
info.classname = strmid(f,strlen(p),strlen(f)-strlen(p))
WIDGET_CONTROL,info.filename_id,SET_VALUE=F
if strpos(info.filename,'.image') gt 0 then info.dim=2 else info.dim=1
calibdrv_init,info
WIDGET_CONTROL,info.base,SET_UVALUE=info
END
'File.Quit': BEGIN
WIDGET_CONTROL,Event.top,/DESTROY
calibdrv_cleanup,info
END
'Color...': BEGIN
xloadct,GROUP=Event.top
END
'Help...': BEGIN
PRINT, 'Event for Help...'
END
ENDCASE
END
PRO CALIBDRV_Event, Event
WIDGET_CONTROL, Event.top, GET_UVALUE=info
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
CASE Ev OF
; Event for PDMENU4
'PDMENU4': BEGIN
PDMENU4_Event,info, Event
return
END
'CALIBDRV_FILENAME': BEGIN
WIDGET_CONTROL,info.filename_id,GET_VALUE=fn
F = fn(0)
info.filename=f
p=''
p1 = rstrpos(f,!os.file_sep)
if p1 ge 0 then p = strmid(f,0,p1+1)
info.inpath = p
info.filename = F
info.classname = strmid(f,strlen(p),strlen(f)-strlen(p))
if strpos(info.filename,'.image') gt 0 then info.dim=2 else info.dim=1
calibdrv_init,info
END
'CALIBDRV_SEQNO': BEGIN
WIDGET_CONTROL,info.scanno_id,GET_VALUE=f
info.scanno=f(0)
if info.dim eq 2 then $
info.calib_v2->panImage,info.scanno else $
info.calib_v2->plot,info.scanno
END
'CALIBDRV_FIRST': BEGIN
WIDGET_CONTROL,info.scanno_id,SET_VALUE=1
info.scanno=1
if info.dim eq 2 then $
info.calib_v2->panImage,info.scanno else $
info.calib_v2->plot,info.scanno
END
'CALIBDRV_NEXT': BEGIN
if info.scanno lt info.scanno_last then begin
info.scanno = info.scanno+1
WIDGET_CONTROL,info.scanno_id,SET_VALUE=info.scanno
if info.dim eq 2 then $
info.calib_v2->panImage,info.scanno else $
info.calib_v2->plot,info.scanno
endif else res = dialog_message('End of file',/Info)
END
'CALIBDRV_PREV': BEGIN
if info.scanno gt 1 then begin
info.scanno = info.scanno-1
WIDGET_CONTROL,info.scanno_id,SET_VALUE=info.scanno
if info.dim eq 2 then $
info.calib_v2->panImage,info.scanno else $
info.calib_v2->plot,info.scanno
end
END
'CALIBDRV_LAST': BEGIN
info.scanno = info.scanno_last
WIDGET_CONTROL,info.scanno_id,SET_VALUE=info.scanno
if info.dim eq 2 then $
info.calib_v2->panImage,info.scanno else $
info.calib_v2->plot,info.scanno
END
'CALIBDRV_SLIDER': BEGIN
WIDGET_CONTROL,info.slider_id,GET_VALUE=no
info.scanno = no
WIDGET_CONTROL,info.scanno_id,SET_VALUE=no
if info.dim eq 2 then $
info.calib_v2->panImage,info.scanno else $
info.calib_v2->plot,info.scanno
END
'CALIBDRV_RUN': BEGIN
scanno = info.scanno
title = ': Scan # '+strtrim(scanno,2)
info.calib_v2->calibration,scanno,GROUP=Event.top
END
ENDCASE
WIDGET_CONTROL, Event.top, SET_UVALUE=info
END
PRO calibdrv, GROUP=Group
device,retain=2,decomposed=0
loadct,39
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
CALIBDRV = WIDGET_BASE(GROUP_LEADER=Group, $
ROW=1, $
MAP=1, $
UVALUE='CALIBDRV')
BASE2 = WIDGET_BASE(CALIBDRV, $
COLUMN=1, $
MAP=1, $
UVALUE='BASE2')
BASE3 = WIDGET_BASE(BASE2, $
ROW=1, $
MAP=1, $
UVALUE='BASE3')
MenuDesc695 = [ $
{ CW_PDMENU_S, 1, 'File' }, $ ; 0
{ CW_PDMENU_S, 0, 'Open...' }, $ ; 1
{ CW_PDMENU_S, 2, 'Quit' }, $ ; 2
{ CW_PDMENU_S, 0, 'Color...' }, $ ; 3
{ CW_PDMENU_S, 2, 'Help...' } $ ; 4
]
PDMENU4 = CW_PDMENU( BASE3, MenuDesc695, /RETURN_FULL_NAME, $
UVALUE='PDMENU4')
FieldVal746 = [ $
'' ]
FIELD6 = CW_FIELD( BASE2,VALUE=FieldVal746, $
ROW=1, $
STRING=1, $
RETURN_EVENTS=1, $
TITLE='Catcher Image File:', $
UVALUE='CALIBDRV_FILENAME', $
XSIZE=60)
BASE9 = WIDGET_BASE(BASE2, $
ROW=1, $
MAP=1, $
UVALUE='BASE9')
FieldVal1008 = [ $
'' ]
FIELD10 = CW_FIELD( BASE9,VALUE=FieldVal1008, $
ROW=1, $
INTEGER=1, $
RETURN_EVENTS=1, $
TITLE='Scan 2D #:', $
UVALUE='CALIBDRV_SEQNO', $
XSIZE=4)
BUTTON11 = WIDGET_BUTTON( BASE9, $
UVALUE='CALIBDRV_FIRST', $
VALUE='First')
BUTTON12 = WIDGET_BUTTON( BASE9, $
UVALUE='CALIBDRV_NEXT', $
VALUE='Next')
BUTTON13 = WIDGET_BUTTON( BASE9, $
UVALUE='CALIBDRV_PREV', $
VALUE='Prev')
BUTTON14 = WIDGET_BUTTON( BASE9, $
UVALUE='CALIBDRV_LAST', $
VALUE='Last')
SLIDER14 = WIDGET_SLIDER( BASE9, $
MAXIMUM=2, $
MINIMUM=1, $
UVALUE='CALIBDRV_SLIDER', $
VALUE=1)
BUTTON15 = WIDGET_BUTTON( BASE9, $
UVALUE='CALIBDRV_RUN', $
VALUE='Run Calibra...')
info = { base:CALIBDRV, $
filename_id:FIELD6, $
scanno_id:FIELD10, $
slider_id:SLIDER14, $
filename:'', $
inpath:'', $
classname:'', $
maxno:0, $
scanno_last:0, $
scanno:0, $
dim: 2, $
calib_v2: obj_new('scan2d') $
}
WIDGET_CONTROL, CALIBDRV, /REALIZE
WIDGET_CONTROL, CALIBDRV, SET_UVALUE=info
XMANAGER, 'CALIBDRV', CALIBDRV
END