-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcviewer.pro
487 lines (412 loc) · 11.8 KB
/
dcviewer.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
;*************************************************************************
; 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.
;*************************************************************************
;
; data catcher viewer
;
; @view1d.pro
; @view2d.pro
PRO COMMANDTEXT_Event, Event
WIDGET_CONTROL,Event.Top,GET_UVALUE=info
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
CASE Ev OF
'COMMANDTEXT_FIELD': BEGIN
WIDGET_CONTROL,info.command_field,GET_VALUE=name
if strtrim(name(0),2) ne '' then begin
x = string(name,/print)
; r = execute(x)
call_procedure,x
if !err lt 0 then begin
res = WIDGET_MESSAGE(!err_string,/Error,dialog_parent=Event.top)
end
end
END
'COMMANDTEXT_BUTTON6': BEGIN
WIDGET_CONTROL,info.base,/DESTROY
return
END
ENDCASE
END
;
;
PRO commandtext_dialog, GROUP=Group
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
COMMANDTEXT = WIDGET_BASE(GROUP_LEADER=Group, $
ROW=1, $
MAP=1, $
UVALUE='COMMANDTEXT')
BASE2 = WIDGET_BASE(COMMANDTEXT, $
COLUMN=1, $
MAP=1, $
UVALUE='BASE2')
COMMANDTEXT_FIELD = CW_FIELD( BASE2,VALUE='', $
ROW=1, $
STRING=1, $
RETURN_EVENTS=1, $
TITLE='IDL> ', $
UVALUE='COMMANDTEXT_FIELD', $
XSIZE=60)
BASE4 = WIDGET_BASE(BASE2, $
COLUMN=2, $
MAP=1, $
UVALUE='BASE4')
COMMANDTEXT_BUTTON6 = WIDGET_BUTTON( BASE4, $
UVALUE='COMMANDTEXT_BUTTON6', $
VALUE='Close')
info = { $
base : COMMANDTEXT, $
command_field : COMMANDTEXT_FIELD $
}
WIDGET_CONTROL, COMMANDTEXT, SET_UVALUE=info
WIDGET_CONTROL, COMMANDTEXT, /REALIZE
XMANAGER, 'COMMANDTEXT', COMMANDTEXT
END
PRO BI2XDR_Event, Event
COMMON BI2XDR_BLOCK, bi2xdr_ids
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
CASE Ev OF
'BI2XDR_FILE': begin
WIDGET_CONTROL,Event.id,GET_VALUE=filename
bi2xdr_convertData,filename(0)
end
'BI2XDR_ACCEPT': begin
WIDGET_CONTROL,bi2xdr_ids.filename,GET_VALUE=filename
bi2xdr_convertData,filename(0)
end
'BI2XDR_CANCEL': begin
WIDGET_CONTROL,Event.top,/DESTROY
end
ENDCASE
END
PRO bi2xdr_convertData,file
found = findfile(file)
if found(0) eq '' then begin
res=WIDGET_MESSAGE('Error: file not found')
endif else u_bi2xdr,file
END
PRO bi2xdr_converter, file=file, GROUP=Group
;+
; NAME:
; BI2XDR_CONVERTER
;
; PURPOSE:
; This IDL program converts native binary data into platform-
; independent XDR binary data.
;
;
; CATEGORY:
; Widgets.
;
; CALLING SEQUENCE:
; BI2XDR_CONVERTER [,file=file] [,GROUP=Group]
;
; INPUTS:
; None.
;
; KEYWORD PARAMETERS:
; file: Specifies the input data file name. The input file should
; contain pure binary data objects.
; GROUP: The widget ID of the group leader of the widget. If this
; keyword is specified, the death of the group leader
; results in the death of BI2XDR_CONVERTER.
;
; OUTPUTS:
; The output filename uses the input filename suffixed with '.xdr'.
; Output file contains the converted XDR binary data objects.
;
; COMMON BLOCKS:
; COMMON BI2XDR_BLOCK
;
; RESTRICTIONS:
; The input data file should contain pure native binary data objects.
; The 'os.init' and 'dcviewer.pro' must be loaded into IDL first.
;
; EXAMPLE:
;
; @os.init
; .RUN dcviewer
; BI2XDR_CONVERTER
;
; MODIFICATION HISTORY:
; Written by: Ben-chin K. Cha, 06-01-97.
;
; xx-xx-xx iii comment
;-
;
COMMON BI2XDR_BLOCK, bi2xdr_ids
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
BI2XDR = WIDGET_BASE(GROUP_LEADER=Group, $
TITLE='BI2XDR', $
ROW=1, $
MAP=1, $
UVALUE='BI2XDR')
BASE2 = WIDGET_BASE(BI2XDR, $
COLUMN=1, $
MAP=1, $
UVALUE='BASE2')
LABEL4 = WIDGET_LABEL(BASE2, $
FONT=!os.font, $
UVALUE='LABEL4', $
VALUE='BI2XDR Data Converter')
FieldVal575 = [ $
'catch1d.trashcan' ]
if keyword_set(file) then FieldVal575=strtrim(file,2)
BI2XDR_FILE = CW_FIELD( BASE2,VALUE=FieldVal575, $
ROW=1, XSIZE=70, $
STRING=1, $
RETURN_EVENTS=1, $
TITLE='Filename:', $
UVALUE='BI2XDR_FILE')
BASE4 = WIDGET_BASE(BASE2, $
ROW=1, $
MAP=1, $
UVALUE='BASE4')
BI2XDR_ACCEPT = WIDGET_BUTTON( BASE4, $
UVALUE='BI2XDR_ACCEPT', $
VALUE='Accept')
BI2XDR_CANCEL = WIDGET_BUTTON( BASE4, $
UVALUE='BI2XDR_CANCEL', $
VALUE='Cancel')
bi2xdr_ids = { $
filename : BI2XDR_FILE $
}
WIDGET_CONTROL, BI2XDR, /REALIZE
XMANAGER, 'BI2XDR', BI2XDR
END
PRO dcViewer_event, Event
COMMON DCVIEWER_BLOCK,dcviewer_ids
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
CASE Ev OF
'PROMPT_IDL': begin
commandtext_dialog,GROUP=Event.top
end
'1D_OVERLAY ...': BEGIN
view1d_overlay,GROUP=Event.Top
END
'BUTTON2': BEGIN
dnames = strtrim(indgen(15)+1,2)
assignname_read,dnames
END
'BUTTON3': BEGIN
Print, 'Event for VIEW1D ...'
found = findfile(dcviewer_ids.data)
if found(0) ne '' then begin
if !d.name eq 'WIN' then begin
view1d,data=dcviewer_ids.data,/XDR,GROUP=Event.Top
return
end
if dcviewer_ids.xdr eq 1 and dcviewer_ids.datatype eq 0 then $
view1d,data=dcviewer_ids.data,/XDR,GROUP=Event.Top else $
view1d,data=dcviewer_ids.data,GROUP=Event.Top
endif else view1d,GROUP=Event.Top
END
'BUTTON4': BEGIN
Print, 'Event for VIEW2D ...'
found = findfile(dcviewer_ids.file)
if found(0) ne '' then begin
if dcviewer_ids.xdr eq 1 and dcviewer_ids.filetype eq 0 then $
view2d,file=dcviewer_ids.file,/XDR,GROUP=Event.Top else $
view2d,file=dcviewer_ids.file,GROUP=Event.Top
endif else view2d,GROUP=Event.Top
END
'BUTTON5': BEGIN
Print, 'Event for BI2XDR ...'
bi2xdr_converter,GROUP=Event.Top
END
'BUTTON7': BEGIN
WIDGET_CONTROL,Event.Top,/DESTROY
END
'BUTTON6': BEGIN
WIDGET_CONTROL,Event.Top,/DESTROY
exit
END
ENDCASE
END
PRO dcViewer,data=data,file=file, XDR=XDR, GROUP=Group
;+
; NAME:
; DCVIEWER
;
; PURPOSE:
; This program integrates the view1D and view2D program into a single
; system. It provides 1D and 2D data viewing features for data
; catcher. It operates on the same set of data files generated by
; the data catcher.
;
; It is written in pure IDL language and it is platform-independent.
; It can read data either in native binary form or XDR binary form.
;
; It can be invoked as an XDR data converter to convert native data
; into XDR binary form.
;
; CATEGORY:
; Widgets.
;
; CALLING SEQUENCE:
;
; DCVIEWER [,DATA='1data'] [,FILE='1data.image'] [,/XDR] [,GROUP=Group]
;
; INPUTS:
; None.
;
; KEYWORD PARAMETERS:
; DATA: Specifies the input filename for the 1D scan data on the
; command line.
; FILE: Specifies the input filename for the 2D image data on the
; command line.
; XDR: Starts the DCVIEWER as the XDR data convert program.
; GROUP: The widget ID of the group leader of the widget. If this
; keyword is specified, the death of the group leader results in
; the death of DCVIEWER.
;
; OUTPUTS:
; It provides all the viewing and report features available in the
; EPICS data catcher except with the channel access functions been
; removed.
;
; COMMON BLOCKS:
; COMMON DCVIEWER_BLOCK
; COMMON BI2XDR_BLOCK
;
; SIDE EFFECTS:
; If the data catcher has appended new scan data on the same file,
; a user has to reload the data file to get the newly added scan
; data into the DCVIEWER.
;
; RESTRICTIONS:
; A complete package of DCVIEWER includes the following files:
; os.init
; dcviewer.pro
; view1d.init
; view1d.pro
; view1d_overlay.pro
; view2d.init
; view2d.pro
; plot1d.pro
; The path to these files must be included in the IDL_PATH. Before
; invoking DCVIEWER, the file 'os.init' must be loaded into IDL
; first.
;
; PROCEDURE:
; On the UNIX operating system, the script file 'viewer' can be
; used to directly invoke the data viewer. The environment, path
; settings, and running procedure are automatically taking cared
; by the script file 'viewer'.
;
; EXAMPLE:
; Start the DCVIEWER as scan data display package -
; @os.init
; dcviewer
;
; Start the DCVIEWER as an XDR data converter -
; @os.init
; dcviewer,/XDR
;
; MODIFICATION HISTORY:
; Written by: Ben-chin K. Cha, 6-01-97.
; 12-19-97 bkc - Allows the access of the view1d_overlay program
; Add the IDL> prompt dialog which let the user
; run any IDL command
; 09-06-02 bkc - The Close button will close viewer program but stay in
; IDL sesseion with all the routines intact
; The Exit button will exit the IDL session
;-
COMMON DCVIEWER_BLOCK,dcviewer_ids
COMMON COLORS, R_ORIG, G_ORIG, B_ORIG, R_CURR, G_CURR, B_CURR
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
dcviewer_ids = { $
data : '', $
file : '', $
datatype : 0, $
filetype : 0, $
xdr : 0 $
}
dcViewer = WIDGET_BASE(GROUP_LEADER=Group, $
TITLE='Data Viewer', $
COL=1, $
MAP=1, $
UVALUE='dcViewer')
BASE1 = WIDGET_BASE(dcViewer, $
COL=1, $
MAP=1, $
UVALUE='BASE2')
LABEL4 = WIDGET_LABEL(BASE1, $
FONT = !os.font, $
UVALUE='LABEL4', $
VALUE='Catcher 1D/2D Data Viewer')
if keyword_set(data) then begin
LABEL5 = WIDGET_LABEL(BASE1, $
UVALUE='LABEL5', /ALIGN_LEFT, $
VALUE='1D DATA : '+data)
dcviewer_ids.data = strtrim(data,2)
end
if keyword_set(file) then begin
LABEL6 = WIDGET_LABEL(BASE1, $
UVALUE='LABEL6', /ALIGN_LEFT, $
VALUE='2D IMAGE : '+file)
dcviewer_ids.file = strtrim(file,2)
end
BASE2 = WIDGET_BASE(dcViewer, $
COLUMN=1, $
MAP=1, $
UVALUE='BASE2')
BUTTON3 = WIDGET_BUTTON( BASE2, $
UVALUE='BUTTON3', $
VALUE='VIEW1D ...')
BUTTON1 = WIDGET_BUTTON( BASE2, $
UVALUE='1D_OVERLAY ...',$
VALUE='1D_OVERLAY ...')
BUTTON2 = WIDGET_BUTTON( BASE2, $
UVALUE='BUTTON2', $
VALUE='Assign Di Names for view2d ...')
BUTTON4 = WIDGET_BUTTON( BASE2, $
UVALUE='BUTTON4', $
VALUE='VIEW2D ...')
PROMPT_IDL = WIDGET_BUTTON( BASE2, $
UVALUE='PROMPT_IDL', $
VALUE='IDL Prompt ...')
if keyword_set(XDR) then begin
BUTTON5 = WIDGET_BUTTON( BASE2, $
UVALUE='BUTTON5', $
VALUE='BI2XDR ...')
dcviewer_ids.xdr = 1
end
BUTTON7 = WIDGET_BUTTON( BASE2, $
UVALUE='BUTTON7', $
VALUE=' Close ')
BUTTON6 = WIDGET_BUTTON( BASE2, $
UVALUE='BUTTON6', $
VALUE=' Exit ')
WIDGET_CONTROL, dcViewer, /REALIZE
if dcviewer_ids.xdr eq 1 then begin
if dcviewer_ids.data ne '' then begin
parts = str_sep(dcviewer_ids.data,'.')
id1 = n_elements(parts) - 1
if strupcase(parts(id1)) ne 'XDR' then begin
dcviewer_ids.datatype = -1
res = WIDGET_MESSAGE('Error: XDR type of 1D data required !')
end
end
if dcviewer_ids.file ne '' then begin
parts = str_sep(dcviewer_ids.file,'.')
id2 = n_elements(parts) - 1
if strupcase(parts(id2)) ne 'XDR' then begin
dcviewer_ids.filetype = -1
res = WIDGET_MESSAGE('Error: XDR type of 2D image data required !')
end
end
if dcviewer_ids.file eq '' and dcviewer_ids.data eq '' then begin
WIDGET_CONTROL,BUTTON3,SENSITIVE=0
WIDGET_CONTROL,BUTTON4,SENSITIVE=0
end
end
XMANAGER, 'dcViewer', dcViewer
END